Shopping list
dummy item 1
dummy item 2
const t={key:"shopping",items:[{text:"dummy item 1",isChecked:!1},{text:"dummy item 2",isChecked:!0}],init(){localStorage.getItem("shopping")&&(this.items=JSON.parse(localStorage.getItem(this.key))),this.drawList()},drawList(){let e="";this.items.forEach((t,i)=>{e+=`\n <div>\n <span class="fas fa-check"></span>\n <span class="fas fa-trash"></span>\n <div contenteditable class="${t.isChecked?"strike":""}">${t.text}</div>\n </div> \n `}),document.querySelector(".border-gray").innerHTML=e,localStorage.setItem(this.key,JSON.stringify(this.items)),document.querySelectorAll(".fa-check").forEach((function(e,i){e.addEventListener("click",(function(e){t.checkItem(i)}))})),document.querySelectorAll(".fa-trash").forEach((function(e,i){e.addEventListener("click",(function(e){t.trashItem(i)}))})),document.querySelectorAll("[contenteditable]").forEach((function(e,i){e.addEventListener("blur",(function(e){t.updateItem(i,e.target.innerHTML)}))}))},trashItem(t){this.items.splice(t,1),this.drawList()},checkItem(t){this.items[t].isChecked=!this.items[t].isChecked,this.drawList()},updateItem(t,e){console.log(t,e),this.items[t].text=e,this.drawList()},addItem(){console.log("add"),this.items.push({text:"...",isChecked:!1}),this.drawList()}};t.init(),document.getElementById("add").addEventListener("click",()=>t.addItem());
//# sourceMappingURL=shopping.js.map