Skip to content
This repository has been archived by the owner on Sep 6, 2022. It is now read-only.

Commit

Permalink
persist prefs in localStorage if possible
Browse files Browse the repository at this point in the history
  • Loading branch information
Scott Jehl committed Jun 16, 2012
1 parent 6baa8aa commit 86a1ab8
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions picturefill.js
Expand Up @@ -8,12 +8,11 @@
"use strict"; "use strict";


// User preference for HD content when available // User preference for HD content when available
var prefHD = false; var prefHD = false || w.localStorage && w.localStorage[ "picturefill-prefHD" ] === "true";


w.picturefill = function() { w.picturefill = function() {
var ps = w.document.getElementsByTagName( "div" ); var ps = w.document.getElementsByTagName( "div" );
//prefHDLoc = prefHD;// || w.localStorage && w.localStorage[ "img-pref-hd" ];

// Loop the pictures // Loop the pictures
for( var i = 0, il = ps.length; i < il; i++ ){ for( var i = 0, il = ps.length; i < il; i++ ){
if( ps[ i ].getAttribute( "data-picture" ) !== null ){ if( ps[ i ].getAttribute( "data-picture" ) !== null ){
Expand Down Expand Up @@ -66,6 +65,9 @@
ps[ i ].appendChild( picSwitch ); ps[ i ].appendChild( picSwitch );
picSwitch.onmouseup = function(){ picSwitch.onmouseup = function(){
prefHD = !prefHD; prefHD = !prefHD;
if( w.localStorage ){
w.localStorage[ "picturefill-prefHD" ] = prefHD;
}
w.picturefill(); w.picturefill();
return false; return false;
}; };
Expand Down

0 comments on commit 86a1ab8

Please sign in to comment.