Advertisement
Guest User

Untitled

a guest
Sep 26th, 2017
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var Globals = function(){
  2.                     //set the initial values.
  3.                     <cfoutput>#toScript(session.festBuilder,"globals",true,true)#</cfoutput>
  4.        
  5.                     //overwrite the values with the correct data types.
  6.                     parseIntToScript(globals);
  7.                    
  8.                    
  9.                     var setGlobalVal = function (name,val,sync){
  10.                    
  11.                             // default server side sync to true.
  12.                             if(typeof(sync) === 'undefined'){
  13.                                 sync = true;
  14.                             };
  15.                            
  16.                             //update client side object.
  17.                             globals[name] = val;
  18.                            
  19.                             //synchronize server side object.
  20.                             if(sync){
  21.                                 return saveGlobalValToSession(name,val);
  22.                            
  23.                             };
  24.                         };
  25.                    
  26.                     var getGlobalVal = function (name){
  27.                             return globals[name];
  28.                         }; 
  29.                        
  30.                     var getGlobalObj = function (){
  31.                             return globals;
  32.                         }; 
  33.                        
  34.                     var deleteGlobalVal = function(name,sync){
  35.                             // default server side sync to true.
  36.                             if(typeof(sync) === 'undefined'){
  37.                                 sync = true;
  38.                             };
  39.                            
  40.                             delete globals[name];
  41.                            
  42.                             //synchronize server side object.
  43.                             if(sync){
  44.                                 deleteGlobalValInSession(name);
  45.                             };
  46.                         }; 
  47.                    
  48.            
  49.                     //PUBLIC METHODS.  
  50.                     return{
  51.                             set       : function(name,val,sync){
  52.                                             if(typeof(val) === 'undefined'){
  53.                                                 result = {};
  54.                                                 result.error = 'val param required.';
  55.                                                 result.success = false;
  56.                                                 return result;
  57.                                             };
  58.                                             return setGlobalVal(name.toLowerCase(),val,sync);
  59.                                 },
  60.                             get       : function(name){
  61.                                             return getGlobalVal(name.toLowerCase());
  62.                                 },
  63.                             getObject : function(){
  64.                                             return getGlobalObj();
  65.                                 },
  66.                             del       : function(name,sync){
  67.                                             return deleteGlobalVal(name.toLowerCase(),sync);
  68.                                 }  
  69.            
  70.                         }
  71.                  }(); //singleton.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement