All pastes #2095943 Raw Edit

Something

public text v1 · immutable
#2095943 ·published 2011-12-23 03:43 UTC
rendered paste body
                getValue: function (storedVar, varScope, isFunction) {
                    if (arguments.length > 1 && varScope === 'tab') {
                            storedVar = sessionStorage[gMB.namespace + "__" + storedVar];
                    } else {
                        storedVar = localStorage[gMB.namespace + "__" + storedVar];
                        isFunction = isDefined(varScope) ? varScope : false; // If arguments.length == 2 and varScope != 'tab', then arg #2 is isFunction.
                    }
                    if (isNull(storedVar)) { return undefinedVar; } // storedVar is undefined, not null.
                    if (typeof storedVar === 'object') { // storedVar is either an object or an array.
                        return JSON.parse(storedVar);
                    } else {
                        if (isFunction === true) { return eval('(' + storedVar + ')'); }
                        else { return storedVar; }                        
                    }                        
                },