You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
varcacheKeys=[];// Store the keys we need to drop here
83
85
// Lets get our loop on
84
86
for(i=0;i<window.localStorage.length;i++){
85
-
if(window.localStorage.key(i).substr(0,window.cacheImagesConfig.storagePrefix.length+1)!==window.cacheImagesConfig.storagePrefix+':'){continue;}// Does not match our prefix?
87
+
if(window.localStorage.key(i).substr(0,storagePrefix.length+1)!==storagePrefix+':'){continue;}// Does not match our prefix?
86
88
87
89
cacheKeys.push(window.localStorage.key(i));// Droping the keys here re-indexes the localStorage so that the offset in our loop is wrong
88
90
}
89
91
90
92
if(cacheKeys.length===0){
91
-
if(window.cacheImagesConfig.debug){console.log('No Images to Drop');}
93
+
if(window.debug){console.log('No Images to Drop');}
Copy file name to clipboardExpand all lines: jquery.cacheImages.js
+29-25Lines changed: 29 additions & 25 deletions
Original file line number
Diff line number
Diff line change
@@ -19,7 +19,7 @@
19
19
(function($){
20
20
$.fn.cacheImages=function(opts){
21
21
// Set the defaults
22
-
window.cacheImagesConfig=$.extend({},{
22
+
this.cacheImagesConfig=$.extend({},{
23
23
debug: false,// Boolean value to enable or disable some of the console messaging for trouble shooting
24
24
defaultImage: 'data:image/png;base64,/9j/4AAQSkZJRgABAgAAZABkAAD/7AARRHVja3kAAQAEAAAAHgAA/+4ADkFkb2JlAGTAAAAAAf/bAIQAEAsLCwwLEAwMEBcPDQ8XGxQQEBQbHxcXFxcXHx4XGhoaGhceHiMlJyUjHi8vMzMvL0BAQEBAQEBAQEBAQEBAQAERDw8RExEVEhIVFBEUERQaFBYWFBomGhocGhomMCMeHh4eIzArLicnJy4rNTUwMDU1QEA/QEBAQEBAQEBAQEBA/8AAEQgAZABkAwEiAAIRAQMRAf/EAEsAAQEAAAAAAAAAAAAAAAAAAAAFAQEAAAAAAAAAAAAAAAAAAAAAEAEAAAAAAAAAAAAAAAAAAAAAEQEAAAAAAAAAAAAAAAAAAAAA/9oADAMBAAIRAxEAPwCwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD//2Q==',// URL or base64 string for the default image (will obviously get cached) - default is at assets/default.jpg
25
25
encodeOnCanvas: false,// This is still experimental and should be disabled in production
if(window.localStorage.key(i).substr(0,window.cacheImagesConfig.storagePrefix.length+1)!==window.cacheImagesConfig.storagePrefix+':'){continue;}// Does not match our prefix?
248
+
if(window.localStorage.key(i).substr(0,storagePrefix.length+1)!==storagePrefix+':'){continue;}// Does not match our prefix?
245
249
246
250
dropKeys.push(window.localStorage.key(i));// Droping the keys here re-indexes the localStorage so that the offset in our loop is wrong
247
251
}
248
252
249
253
if(dropKeys.length===0){
250
-
if(window.cacheImagesConfig.debug){console.log('No Images to Drop');}
254
+
if(debug){console.log('No Images to Drop');}
251
255
returntrue;
252
256
}
253
257
254
258
// Drop the keys we found
255
259
for(i=0;i<dropKeys.length;i++){
256
-
if(window.cacheImagesConfig.debug){console.log('Dropping localStorage Key:',dropKeys[i]);}// Let them know what keys were dropped
260
+
if(debug){console.log('Dropping localStorage Key:',dropKeys[i]);}// Let them know what keys were dropped
257
261
window.localStorage.removeItem(dropKeys[i]);
258
262
}
259
263
260
-
if(window.cacheImagesConfig.debug){console.log('Dropped '+dropKeys.length+' images from localStorage');}// Provide a bit of feedback for developers
264
+
if(debug){console.log('Dropped '+dropKeys.length+' images from localStorage');}// Provide a bit of feedback for developers
0 commit comments