11< DOCTYPE html >
22< html >
33 < head >
4- < title > Quad -OS</ title >
4+ < title > Quad-OS</ title >
55 < link rel ="apple-touch-icon-precomposed " sizes ="57x57 " href ="apple-touch-icon-57x57.png " />
66< link rel ="apple-touch-icon-precomposed " sizes ="114x114 " href ="apple-touch-icon-114x114.png " />
77< link rel ="apple-touch-icon-precomposed " sizes ="72x72 " href ="apple-touch-icon-72x72.png " />
@@ -118,15 +118,15 @@ <h1>Quad-OS</h1>
118118 < br >
119119 < h1 > Allow Box</ h1 >
120120 < div class ="onoffswitch ">
121- < input type =" checkbox " onclick ="if(this.checked){boxAllowed()} else {boxNotAllowed()} "name ="onoffswitch " class ="onoffswitch-checkbox " id ="myonoffswitch " checked >
121+ < input type =' checkbox ' store =" checkbox1 " onclick ="if(this.checked){boxAllowed()} else {boxNotAllowed()} "name ="onoffswitch " class ="onoffswitch-checkbox " id ="myonoffswitch " checked >
122122 < label class ="onoffswitch-label " for ="myonoffswitch ">
123123 < span class ="onoffswitch-inner "> </ span >
124124 < span class ="onoffswitch-switch "> </ span >
125125 </ label >
126126</ div >
127127< h1 > Something</ h1 >
128128< div class ="onoffswitch ">
129- < input type =" checkbox " name ="onoffswitch2 " class ="onoffswitch-checkbox " id ="myonoffswitch2 " checked >
129+ < input type =' checkbox ' store =" checkbox2 " name ="onoffswitch2 " class ="onoffswitch-checkbox " id ="myonoffswitch2 " checked >
130130 < label class ="onoffswitch-label " for ="myonoffswitch2 ">
131131 < span class ="onoffswitch-inner "> </ span >
132132 < span class ="onoffswitch-switch "> </ span >
@@ -140,43 +140,44 @@ <h1>Something</h1>
140140 } else {
141141 document.getElementById("myonoffswitch").checked = false;
142142 }*/
143- $ ( '.onoffswitch-checkbox' ) . on ( 'click' , function ( ) {
144- var fav , favs = [ ] ;
145- $ ( '.onoffswitch-checkbox' ) . each ( function ( ) { // run through each of the checkboxes
146- fav = { id : $ ( this ) . attr ( 'id' ) , value : $ ( this ) . prop ( 'checked' ) } ;
147- favs . push ( fav ) ;
148- } ) ;
149- localStorage . setItem ( "favorites" , JSON . stringify ( favs ) ) ;
150- } ) ;
151-
152- $ ( document ) . ready ( function ( ) {
153- var favorites = JSON . parse ( localStorage . getItem ( 'favorites' ) ) ;
154- if ( ! favorites . length ) { return } ;
155- console . debug ( favorites ) ;
156-
157- for ( var i = 0 ; i < favorites . length ; i ++ ) {
158- console . debug ( favorites [ i ] . value == 'on' ) ;
159- $ ( '#' + favorites [ i ] . id ) . prop ( 'checked' , favorites [ i ] . value ) ;
160- }
161- } ) ;
143+ ( function ( ) {
144+ var boxes = document . querySelectorAll ( "input[type='checkbox']" ) ;
145+ for ( var i = 0 ; i < boxes . length ; i ++ ) {
146+ var box = boxes [ i ] ;
147+ if ( box . hasAttribute ( "store" ) ) {
148+ setupBox ( box ) ;
149+ }
150+ }
151+
152+ function setupBox ( box ) {
153+ var storageId = box . getAttribute ( "store" ) ;
154+ var oldVal = localStorage . getItem ( storageId ) ;
155+ console . log ( oldVal ) ;
156+ box . checked = oldVal === "true" ? true : false ;
157+
158+ box . addEventListener ( "change" , function ( ) {
159+ localStorage . setItem ( storageId , this . checked ) ;
160+ } ) ;
161+ }
162+ } ) ( ) ;
162163 function boxNotAllowed ( ) {
163164 document . getElementById ( "boxButton" ) . style . visibility = "hidden" ;
164165 boxStatus = 0 ;
165- if ( typeof ( Storage ) !== "undefined" ) {
166+ /* if (typeof(Storage) !== "undefined") {
166167 localStorage.setItem("isBoxAllowed", boxStatus);
167168 document.getElementById("example").innerHTML = localStorage.getItem("isBoxAllowed");
168169 } else {
169170 document.getElementById("example").innerHTML = "Sorry, your browser does not support Web Storage...";
170- }
171+ }*/
171172 function boxAllowed ( ) {
172173 document . getElementById ( "boxButton" ) . style . visibility = "visible" ;
173174 boxStatus = 1 ;
174- if ( typeof ( Storage ) !== "undefined" ) {
175+ /* if (typeof(Storage) !== "undefined") {
175176 localStorage.setItem("isBoxAllowed", boxStatus);
176177 document.getElementById("example").innerHTML = localStorage.getItem("isBoxAllowed");
177178 } else {
178179 document.getElementById("example").innerHTML = "Sorry, your browser does not support Web Storage...";
179- }
180+ }*/
180181 }
181182 }
182183 </ script >
0 commit comments