{"version":3,"file":"/m/all/js/common/emu_storage.js.map","sources":["/m/all/js/common/emu_storage.js"],"sourcesContent":["function EmuStorage(IsSessionStorage){\n\tthis.h5storage=false;\n\tthis.IsSessionStorage=IsSessionStorage;\n\tthis.setItem=function(key,value){\n\t\tif(this.h5storage){\n\t\t\tvar storage= this.IsSessionStorage?window.sessionStorage:window.localStorage;\n\t\t\treturn storage.setItem(key,value);\n\t\t}else{\n\t\t\tthis[key]=value;\n\t\t\treturn true;\n\t\t}\t\t\n\t};\n\tthis.getItem=function(key){\n\t\tif(this.h5storage){\n\t\t\tvar storage= this.IsSessionStorage?window.sessionStorage:window.localStorage;\n\t\t\treturn storage.getItem(key);\n\t\t}else{\n\t\t\treturn this[key];\n\t\t}\t\t\n\t};\n\tthis.removeItem=function(key){\n\t\tif(this.h5storage){\n\t\t\tvar storage= this.IsSessionStorage?window.sessionStorage:window.localStorage;\n\t\t\treturn storage.removeItem(key);\n\t\t}else{\n\t\t\treturn delete this[key];\n\t\t}\t\t\n\t};\n\tthis.isDataProperty=function(propertyName){\n\t\treturn typeof(this[propertyName])!=\"function\" && propertyName!=\"h5storage\" && propertyName!=\"IsSessionStorage\" && propertyName!=\"length\";\n\t};\n\tthis.clear=function(){\n\t\tif(this.h5storage){\n\t\t\tvar storage= this.IsSessionStorage?window.sessionStorage:window.localStorage;\n\t\t\treturn storage.clear();\n\t\t}else{\n\t\t\tfor(var property in this){\n\t\t\t\tif(this.isDataProperty(property)){\n\t\t\t\t\tdelete this[property];\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn true;\t\t\n\t\t}\t\t\n\t};\n\tthis.getProperties=function(){\n\t\tvar props=[];\n\t\tfor(var p in this){\n\t\t\tif(this.isDataProperty(p)){\n\t\t\t\tprops.push(p);\n\t\t\t}\n\t\t}\n\t\tprops.sort();\n\t\treturn props;\n\t};\n\tthis.key=function(i){\n\t\tvar properties=this.getProperties();\n\t\tif(properties.length>i && i>=0){\n\t\t\treturn properties[i];\n\t\t}\n\t}\n\t\n\tthis.debug=function(){\n\t\tvar msg=\"\";\n\t\tfor(var property in this){\n\t\t\tmsg=\" \"+property+\"=\"+this[property];\n\t\t}\n\t\treturn msg;\n\t};\n\t\n\tvar check_key=\"__h5_storage_check\";\n\tif(window.localStorage){\n\t\ttry{\n\t\t\twindow.localStorage[check_key]=\"hello\";\n\t\t\twindow.localStorage.removeItem(check_key);\n\t\t\tthis.h5storage=true;\n\t\t}catch(ex){\n\t\t\ttry{\n\t\t\t\twindow.localStorage.clear();\n\t\t\t\twindow.localStorage[check_key]=\"hello\";\n\t\t\t\twindow.localStorage.removeItem(check_key);\n\t\t\t\tthis.h5storage=true;\n\t\t\t}catch(error){\n\t\t\t}\n\t\t}\n\t}\n\tif(this.h5storage){\n\t\treturn IsSessionStorage?window.sessionStorage:window.localStorage;\n\t}\n}\n\nwindow.gLocalStorage=new EmuStorage(false);\nwindow.gSessionStorage=new EmuStorage(true);\n\nif(typeof(window.gSessionStorage[\"h5storage\"])!=\"undefined\" && window.gSessionStorage[\"h5storage\"]==false){\n\tObject.defineProperty(window.gLocalStorage,\"length\",{\n\t\tget:function(){\n\t\t\tvar properties=this.getProperties();\n\t\t\treturn properties.length;\n\t\t}\t\t\n\t});\t\n\tObject.defineProperty(window.gSessionStorage,\"length\",{\n\t\tget:function(){\n\t\t\tvar properties=this.getProperties();\n\t\t\treturn properties.length;\n\t\t}\t\t\n\t});\t\n}\n\nwindow.onerror =function(errorMessage, scriptURI, lineNumber,columnNumber,error) {\n\t/**\n * 如果单页路由的下一个页面js有报错,前一个页面会报alert但是里面没有报错信息\n * 所以改成有报错地址才显示报错弹窗\n * 要查看下一个页面的js报错信息,可以刷新页面就会alert\n * \n */\n\tif (scriptURI){ \n\t\tvar errorMsg=JSON.stringify({\n\t\t\tmessage: errorMessage,\n\t\t\tscript: scriptURI,\n\t\t\tline: lineNumber,\n\t\t\tcolumn:columnNumber,\n\t\t\terror:error});\n\t\talert(errorMsg);\n\t}\n\t\n}"],"names":["EmuStorage","IsSessionStorage","this","h5storage","setItem","key","value","storage","window","sessionStorage","localStorage","getItem","removeItem","isDataProperty","propertyName","clear","property","getProperties","props","p","push","sort","i","properties","length","debug","msg","check_key","ex","error","gLocalStorage","gSessionStorage","Object","defineProperty","get","onerror","errorMessage","scriptURI","lineNumber","columnNumber","errorMsg","JSON","stringify","message","script","line","column","alert"],"mappings":"AAAA,QAASA,YAAWC,GACnBC,KAAKC,WAAU,EACfD,KAAKD,iBAAiBA,EACtBC,KAAKE,QAAQ,SAASC,EAAIC,GACzB,GAAGJ,KAAKC,UAAU,CACjB,GAAII,GAASL,KAAKD,iBAAiBO,OAAOC,eAAeD,OAAOE,YAChE,OAAOH,GAAQH,QAAQC,EAAIC,GAG3B,MADAJ,MAAKG,GAAKC,GACH,GAGTJ,KAAKS,QAAQ,SAASN,GACrB,GAAGH,KAAKC,UAAU,CACjB,GAAII,GAASL,KAAKD,iBAAiBO,OAAOC,eAAeD,OAAOE,YAChE,OAAOH,GAAQI,QAAQN,GAEvB,MAAOH,MAAKG,IAGdH,KAAKU,WAAW,SAASP,GACxB,GAAGH,KAAKC,UAAU,CACjB,GAAII,GAASL,KAAKD,iBAAiBO,OAAOC,eAAeD,OAAOE,YAChE,OAAOH,GAAQK,WAAWP,GAE1B,aAAcH,MAAKG,IAGrBH,KAAKW,eAAe,SAASC,GAC5B,MAAmC,kBAArBZ,MAAKY,IAA4C,aAAdA,GAA2C,oBAAdA,GAAkD,UAAdA,GAEnHZ,KAAKa,MAAM,WACV,GAAGb,KAAKC,UAAU,CACjB,GAAII,GAASL,KAAKD,iBAAiBO,OAAOC,eAAeD,OAAOE,YAChE,OAAOH,GAAQQ,QAEf,IAAI,GAAIC,KAAYd,MAChBA,KAAKW,eAAeG,UACfd,MAAKc,EAGd,QAAO,GAGTd,KAAKe,cAAc,WAClB,GAAIC,KACJ,KAAI,GAAIC,KAAKjB,MACTA,KAAKW,eAAeM,IACtBD,EAAME,KAAKD,EAIb,OADAD,GAAMG,OACC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