Current Path : C:/Users/Mahmood/Desktop/moodle/lib/amd/build/ |
Current File : C:/Users/Mahmood/Desktop/moodle/lib/amd/build/storagewrapper.min.js |
define ("core/storagewrapper",["core/config"],function(a){var b=function(b){this.storage=b;this.supported=this.detectSupport();this.hashSource=a.wwwroot+"/"+a.jsrev;this.hash=this.hashString(this.hashSource);this.prefix=this.hash+"/";this.jsrevPrefix=this.hashString(a.wwwroot)+"/jsrev";this.validateCache()};b.prototype.detectSupport=function(){if(-1==a.jsrev){return!1}if("undefined"==typeof this.storage){return!1}try{if(null===this.storage){return!1}this.storage.setItem("test","1");this.storage.removeItem("test");return!0}catch(a){return!1}};b.prototype.prefixKey=function(a){return this.prefix+a};b.prototype.validateCache=function(){var b=this.storage.getItem(this.jsrevPrefix);if(null===b){this.storage.setItem(this.jsrevPrefix,a.jsrev);return}var c=a.jsrev;if(c!=b){this.storage.clear();this.storage.setItem(this.jsrevPrefix,a.jsrev)}};b.prototype.hashString=function(a){var b=0,c,d,e;if(0===a.length){return b}for(c=0,e=a.length;c<e;c++){d=a.charCodeAt(c);b=(b<<5)-b+d;b|=0}return b};b.prototype.get=function(a){if(!this.supported){return!1}a=this.prefixKey(a);return this.storage.getItem(a)};b.prototype.set=function(a,b){if(!this.supported){return!1}a=this.prefixKey(a);try{this.storage.setItem(a,b)}catch(a){return!1}return!0};return b}); //# sourceMappingURL=storagewrapper.min.js.map