Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var Globals = function(){
- //set the initial values.
- <cfoutput>#toScript(session.festBuilder,"globals",true,true)#</cfoutput>
- //overwrite the values with the correct data types.
- parseIntToScript(globals);
- var setGlobalVal = function (name,val,sync){
- // default server side sync to true.
- if(typeof(sync) === 'undefined'){
- sync = true;
- };
- //update client side object.
- globals[name] = val;
- //synchronize server side object.
- if(sync){
- return saveGlobalValToSession(name,val);
- };
- };
- var getGlobalVal = function (name){
- return globals[name];
- };
- var getGlobalObj = function (){
- return globals;
- };
- var deleteGlobalVal = function(name,sync){
- // default server side sync to true.
- if(typeof(sync) === 'undefined'){
- sync = true;
- };
- delete globals[name];
- //synchronize server side object.
- if(sync){
- deleteGlobalValInSession(name);
- };
- };
- //PUBLIC METHODS.
- return{
- set : function(name,val,sync){
- if(typeof(val) === 'undefined'){
- result = {};
- result.error = 'val param required.';
- result.success = false;
- return result;
- };
- return setGlobalVal(name.toLowerCase(),val,sync);
- },
- get : function(name){
- return getGlobalVal(name.toLowerCase());
- },
- getObject : function(){
- return getGlobalObj();
- },
- del : function(name,sync){
- return deleteGlobalVal(name.toLowerCase(),sync);
- }
- }
- }(); //singleton.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement