function init(){document.getElementById("button1").onclick=add,document.getElementById("button2").onclick=allesLoeschen,document.getElementById("button3").onclick=deleteLast;for(var e=HoleEintraege(),t=0;t<e.length;t++){var n=e[t];insDocSchreiben(n,JSON.parse(localStorage[n]))}}function add(){var e=HoleEintraege(),t=document.getElementById("element").value,n=document.getElementById("menge").value;console.log(element.value);var l="aufgabe_"+(new Date).getTime();localStorage.setItem(l,JSON.stringify(t+"   "+n)),e.push(l),localStorage.setItem("eintraegeArray",JSON.stringify(e)),insDocSchreiben(l,t+"   "+n)}function deleteLast(){var e=document.getElementById("liste");e.removeChild(e.lastChild),e.removeChild(e.lastChild),e.removeChild(e.lastChild);HoleEintraege()}function allesLoeschen(){localStorage.clear();for(var e=document.getElementById("liste"),t=e.childNodes,n=t.length-1;0<=n;n--)e.removeChild(t[n]);HoleEintraege()}function HoleEintraege(){var e=localStorage.getItem("eintraegeArray");return e?e=JSON.parse(e):(e=[],localStorage.setItem("eintraegeArray",JSON.stringify(e))),e}function insDocSchreiben(e,t){var n=document.getElementById("liste"),l=document.createElement("input");l.setAttribute("type","checkbox"),l.setAttribute("id",e),l.setAttribute("class","checkmark");var a=document.createElement("label");a.innerHTML=t,a.setAttribute("for",e),n.appendChild(l),n.appendChild(a),n.appendChild(document.createElement("br"))}window.onload=init;