Permalink
Browse files

persist prefs in localStorage if possible

  • Loading branch information...
1 parent 6baa8aa commit 86a1ab8e906efe548e8c89aaeb91082315decc9d Scott Jehl committed Jun 16, 2012
Showing with 5 additions and 3 deletions.
  1. +5 −3 picturefill.js
View
@@ -8,12 +8,11 @@
"use strict";
// User preference for HD content when available
- var prefHD = false;
+ var prefHD = false || w.localStorage && w.localStorage[ "picturefill-prefHD" ] === "true";
w.picturefill = function() {
var ps = w.document.getElementsByTagName( "div" );
- //prefHDLoc = prefHD;// || w.localStorage && w.localStorage[ "img-pref-hd" ];
-
+
// Loop the pictures
for( var i = 0, il = ps.length; i < il; i++ ){
if( ps[ i ].getAttribute( "data-picture" ) !== null ){
@@ -66,6 +65,9 @@
ps[ i ].appendChild( picSwitch );
picSwitch.onmouseup = function(){
prefHD = !prefHD;
+ if( w.localStorage ){
+ w.localStorage[ "picturefill-prefHD" ] = prefHD;
+ }
w.picturefill();
return false;
};

0 comments on commit 86a1ab8

Please sign in to comment.