sbenjamin

Glob

Jul 27th, 2011
81
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.     //PRIVATE METHODS. 
  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.             return setGlobalVal(name.toLowerCase(),val,sync)},
  53.         get: function(name){
  54.             return getGlobalVal(name.toLowerCase())},
  55.         del: function(name,sync){
  56.             return deleteGlobalVal(name.toLowerCase(),sync)},
  57.         getObject : function(){
  58.             return getGlobalObj()}
  59.         }
  60.     }(); //singleton.
Advertisement
Add Comment
Please, Sign In to add comment