Skip to content

Instantly share code, notes, and snippets.

@benhowdle89
Last active February 7, 2024 11:30
Show Gist options
  • Star 10 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save benhowdle89/7584827 to your computer and use it in GitHub Desktop.
Save benhowdle89/7584827 to your computer and use it in GitHub Desktop.
A todo app you can run from the browser's address bar. No persistence (boo localstorage security risk). Made by @benhowdle.
data:text/html,<div class="wrap"> <h1>Todo<span>, no fuss lists</span></h1> <input placeholder="Add a todo" type="text" id="item" /> <button id="go">Save</button> <span class="help">* tap to delete</span> <ul id="tudu_list"> </ul> </div><script type="text/javascript">var tudu_list = document.getElementById('tudu_list'); var item = document.getElementById('item'); var new_li; var new_obj = {}; function prependElement(parentID,child) { parent=parentID; parent.insertBefore(child,parent.childNodes[0]); } function remove(element){ element.parentNode.removeChild(element); } function deleteItem(){ var answer = confirm('Sure you want to remove this?'); if(answer){ var deleteId = this.getAttribute('rel'); remove(this); } } function addItem(){ if(item.value !== ''){ new_li = document.createElement('li'); new_li.innerHTML = item.value; prependElement(tudu_list, new_li); new_li.onclick = deleteItem; item.value = ''; } } function callAdd(e){ if(event.keyCode == 13){ addItem(); } } item.onkeyup = function(e){ callAdd(e) }; document.getElementById('go').onclick = addItem;</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment