/*! * Copyright (c) Christopher Keefer, 2017. * jquery-ajax-localstorage-cache: V2.0.0. * This file is generated by grunt - do not edit directly. * Alter source files as needed, then run `grunt` in project directory. * Compiled: 2017-09-18 */ !function(a,b){"use strict";var c=function(a){var b;return a.cacheKey?"function"==typeof a.cacheKey?a.cacheKey(a):a.cacheKey:(b=a.url.replace(/jQuery.*/,""),a.cache===!1&&(b=b.replace(/([?&])_=[^&]*/,"")),b+a.type+(a.data||""))},d=function(a){if(!a)return!1;if(a===!0)return b.localStorage;if("object"==typeof a&&"getItem"in a&&"removeItem"in a&&"setItem"in a)return a;throw new TypeError("localCache must either be a boolean value, or an object which implements the Storage interface.")},e=function(a,b){a.removeItem(b),a.removeItem(b+"cachettl"),a.removeItem(b+"dataType")};a.ajaxPrefilter(function(a,b,f){var g,h,i=d(a.localCache),j=a.cacheTTL||5,k=a.cacheKey=c(a),l=a.isCacheValid,m=a.isResponseValid,n=a.thenResponse||null;i&&(g=i.getItem(k+"cachettl"),l&&"function"==typeof l&&!l()&&(e(i,k),g=0),g&&g<+new Date&&(e(i,k),g=0),h=i.getItem(k),h||f.then(n).then(function(b,c,d){var f=b,g=a.dataType||d.getResponseHeader("Content-Type")||"text/plain";if(!m||"function"!=typeof m||m(b,c,d)){-1!==g.toLowerCase().indexOf("json")&&(f=JSON.stringify(b));try{i.setItem(k,f),i.setItem(k+"cachettl",+new Date+36e5*j),i.setItem(k+"dataType",g)}catch(h){e(i,k),console.log("Cache Error:"+h,k,f)}}}))}),a.ajaxTransport("+*",function(a){if(a.localCache){var b=a.cacheKey,c=d(a.localCache),e=a.dataType||c.getItem(b+"dataType")||"text",f=c?c.getItem(b):!1;if(f)return-1!==e.toLowerCase().indexOf("json")&&(f=JSON.parse(f)),{send:function(a,b){var c={};c[e]=f,b(200,"success",c,"")},abort:function(){console.log("Aborted ajax transport for json cache.")}}}})}(jQuery,window); //# sourceMappingURL=jalc.min.map