mirror of
				https://github.com/librenms/librenms.git
				synced 2024-10-07 16:52:45 +00:00 
			
		
		
		
	Squashed 'lib/pace/' content from commit c6846cb
git-subtree-dir: lib/pace git-subtree-split: c6846cbf6b928e9903b569269fa9fbf32f2554f4
This commit is contained in:
		
							
								
								
									
										27
									
								
								docs/lib/themes.coffee
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										27
									
								
								docs/lib/themes.coffee
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,27 @@
 | 
			
		||||
if module?
 | 
			
		||||
  vm = require('vm')
 | 
			
		||||
 | 
			
		||||
  # Used by the eval'd code
 | 
			
		||||
  Color = require('color')
 | 
			
		||||
 | 
			
		||||
loadTheme = (name, cb) ->
 | 
			
		||||
  $.ajax
 | 
			
		||||
    url: "/pace/templates/pace-theme-#{ name }.tmpl.css"
 | 
			
		||||
    success: cb
 | 
			
		||||
 | 
			
		||||
compileTheme = (body, args={}) ->
 | 
			
		||||
  body.replace /`([\s\S]*?)`/gm, (match, code) ->
 | 
			
		||||
    if module?
 | 
			
		||||
      val = vm.runInNewContext code, {args, Color}
 | 
			
		||||
    else
 | 
			
		||||
      # It matters that args is in the context
 | 
			
		||||
      Color = window.Color
 | 
			
		||||
      val = eval(code)
 | 
			
		||||
 | 
			
		||||
    val
 | 
			
		||||
 | 
			
		||||
if module?
 | 
			
		||||
  module.exports = {compileTheme}
 | 
			
		||||
else
 | 
			
		||||
  window.loadTheme = loadTheme
 | 
			
		||||
  window.compileTheme = compileTheme
 | 
			
		||||
		Reference in New Issue
	
	Block a user