-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathchecky-min.js
1 lines (1 loc) · 950 Bytes
/
checky-min.js
1
function Checky(){var a={ch:[]};if(!localStorage.checks){localStorage.checks=JSON.stringify(a);}a=JSON.parse(localStorage.checks);a.ch.forEach(function(b){document.getElementById(b.id).checked=b.status;});this.checkyfy=function(c,b){if(typeof b==="undefined"){this.checkybox(c);}else{this.checkyanchor(c,b);}};this.checkybox=function(b){document.getElementById(b).onclick=function(){var c=false;for(var d=0;d<a.ch.length;d++){if(a.ch[d].id===b){a.ch[d].status=document.getElementById(b).checked;localStorage.checks=JSON.stringify(a);c=true;break;}}if(!c){obj={id:b,status:document.getElementById(b).checked};a.ch.push(obj);localStorage.checks=JSON.stringify(a);}};};this.checkyanchor=function(e,c){var b=false;for(var d=0;d<a.ch.length;d++){if(a.ch[d].id===e){b=true;break;}}if(!b){document.getElementById(c).onclick=function(){obj={id:e,status:true};document.getElementById(e).checked=true;a.ch.push(obj);localStorage.checks=JSON.stringify(a);};}};}