1
1
< DOCTYPE html >
2
2
< html >
3
3
< head >
4
- < title > Quad -OS</ title >
4
+ < title > Quad-OS</ title >
5
5
< link rel ="apple-touch-icon-precomposed " sizes ="57x57 " href ="apple-touch-icon-57x57.png " />
6
6
< link rel ="apple-touch-icon-precomposed " sizes ="114x114 " href ="apple-touch-icon-114x114.png " />
7
7
< link rel ="apple-touch-icon-precomposed " sizes ="72x72 " href ="apple-touch-icon-72x72.png " />
@@ -118,15 +118,15 @@ <h1>Quad-OS</h1>
118
118
< br >
119
119
< h1 > Allow Box</ h1 >
120
120
< 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 >
122
122
< label class ="onoffswitch-label " for ="myonoffswitch ">
123
123
< span class ="onoffswitch-inner "> </ span >
124
124
< span class ="onoffswitch-switch "> </ span >
125
125
</ label >
126
126
</ div >
127
127
< h1 > Something</ h1 >
128
128
< 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 >
130
130
< label class ="onoffswitch-label " for ="myonoffswitch2 ">
131
131
< span class ="onoffswitch-inner "> </ span >
132
132
< span class ="onoffswitch-switch "> </ span >
@@ -140,43 +140,44 @@ <h1>Something</h1>
140
140
} else {
141
141
document.getElementById("myonoffswitch").checked = false;
142
142
}*/
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
+ } ) ( ) ;
162
163
function boxNotAllowed ( ) {
163
164
document . getElementById ( "boxButton" ) . style . visibility = "hidden" ;
164
165
boxStatus = 0 ;
165
- if ( typeof ( Storage ) !== "undefined" ) {
166
+ /* if (typeof(Storage) !== "undefined") {
166
167
localStorage.setItem("isBoxAllowed", boxStatus);
167
168
document.getElementById("example").innerHTML = localStorage.getItem("isBoxAllowed");
168
169
} else {
169
170
document.getElementById("example").innerHTML = "Sorry, your browser does not support Web Storage...";
170
- }
171
+ }*/
171
172
function boxAllowed ( ) {
172
173
document . getElementById ( "boxButton" ) . style . visibility = "visible" ;
173
174
boxStatus = 1 ;
174
- if ( typeof ( Storage ) !== "undefined" ) {
175
+ /* if (typeof(Storage) !== "undefined") {
175
176
localStorage.setItem("isBoxAllowed", boxStatus);
176
177
document.getElementById("example").innerHTML = localStorage.getItem("isBoxAllowed");
177
178
} else {
178
179
document.getElementById("example").innerHTML = "Sorry, your browser does not support Web Storage...";
179
- }
180
+ }*/
180
181
}
181
182
}
182
183
</ script >
0 commit comments