Skip to content
This repository
Browse code

persist prefs in localStorage if possible

  • Loading branch information...
commit 86a1ab8e906efe548e8c89aaeb91082315decc9d 1 parent 6baa8aa
authored June 16, 2012

Showing 1 changed file with 5 additions and 3 deletions. Show diff stats Hide diff stats

  1. 8  picturefill.js
8  picturefill.js
@@ -8,12 +8,11 @@
8 8
 	"use strict";
9 9
 	
10 10
 	// User preference for HD content when available
11  
-	var prefHD = false;
  11
+	var prefHD = false || w.localStorage && w.localStorage[ "picturefill-prefHD" ] === "true";
12 12
 
13 13
 	w.picturefill = function() {
14 14
 		var ps = w.document.getElementsByTagName( "div" );
15  
-			//prefHDLoc = prefHD;// || w.localStorage && w.localStorage[ "img-pref-hd" ];
16  
-		
  15
+				
17 16
 		// Loop the pictures
18 17
 		for( var i = 0, il = ps.length; i < il; i++ ){
19 18
 			if( ps[ i ].getAttribute( "data-picture" ) !== null ){
@@ -66,6 +65,9 @@
66 65
 						ps[ i ].appendChild( picSwitch );
67 66
 						picSwitch.onmouseup = function(){
68 67
 							prefHD = !prefHD;
  68
+							if( w.localStorage ){
  69
+								w.localStorage[ "picturefill-prefHD" ] = prefHD; 
  70
+							}
69 71
 							w.picturefill();
70 72
 							return false;
71 73
 						};

0 notes on commit 86a1ab8

Please sign in to comment.
Something went wrong with that request. Please try again.