_/Chapter_9/ImagesInc/js/Modules/Core/StorageHandler.js
// if the key does not exist, then create the key with the value passed in either as an object or as an array of objects
if the key does not exist, then create the key with the value passed in either as an object or as an array of objects
if the key does not exist then create the key with the value passed in either as an object or as an array of objects
function appendObjectToLocalStorageArray(key, objToSave, encode) {
            var storedValue = null,
                valueToStore = null;
            if (typeof objToSave !== 'object') {
                ImagesInc_Core.log(3,
                    'DataMismatch, from appendObjectToLocalStorageArray',
                    'orange');
                return false;
            }
            storedValue = getValueForKeyAsObject(key, true);
            if (storedValue) {
                if (ImagesInc_Core.checkIfArray(storedValue)) {
                    storedValue[storedValue.length] = objToSave;
                    valueToStore = storedValue;
                } else { 
                    valueToStore = objToSave;
                }
            } else { 
                valueToStore = objToSave;
            }
            valueToStore = JSON.stringify(valueToStore);
            if (encode) {
                valueToStore = encodeURI(valueToStore);
            }
            localStorage.setItem(key, valueToStore);
        }
function appendObjectToLocalStorageArray ( key , objToSave , encode ) { var storedValue = null , valueToStore = null ; if ( typeof objToSave !== 'object' ) { ImagesInc_Core . log ( 3 , 'DataMismatch, from appendObjectToLocalStorageArray' , 'orange' ) ; return false ; } storedValue = getValueForKeyAsObject ( key , true ) ; if ( storedValue ) { if ( ImagesInc_Core . checkIfArray ( storedValue ) ) { storedValue [ storedValue . length ] = objToSave ; valueToStore = storedValue ; } else { valueToStore = objToSave ; } } else { valueToStore = objToSave ; } valueToStore = JSON . stringify ( valueToStore ) ; if ( encode ) { valueToStore = encodeURI ( valueToStore ) ; } localStorage . setItem ( key , valueToStore ) ; }
if the key does not exist, then create the key with the value passed in either as an object or as an array of objects
if the key does not exist then create the key with the value passed in either as an object or as an array of objects
//if there was a previously stored value for the key // if the stored value is an object but not an array, just replace it // if there was no value previously in the storage