[[pagelist(html5practice/*)]] == html == {{{ html favorite list test

add to list

favorite

allList

}}} == javascript == {{{ function doSetItem(aForm) { localStorage.setItem( document.formInput.elements['textInput'].value, "false"); document.formInput.elements['textInput'].value = ""; doShowAll(); } function doRemoveItem(itemName) { localStorage.setItem(itemName, "false"); doShowAll(); } function doSetFavorite(eTD){ console.log(eTD.innerHTML); localStorage.removeItem(eTD.innerHTML); localStorage.setItem(eTD.innerHTML, "true"); doShowAll(); } function doRemoveFavorite(eTD){ console.log(eTD.innerHTML); localStorage.removeItem(eTD.innerHTML); localStorage.setItem(eTD.innerHTML, "false"); doShowAll(); } function doShowFavorite(){ console.log("do show all"); var key = ""; var pairs = "\n"; var i=0; for (i=0; i<=localStorage.length-1; i++) { key = localStorage.key(i); value = localStorage.getItem(key); if( value == "true" ) pairs += "\n\n"; } if (localStorage.length == 0){ pairs += "\n\n"; } pairs += "
NameValue
"+key+""+value+"
emptyempty
"; document.getElementById('favoriteList').innerHTML = pairs; console.log("end do show all"); } function doShowNFavorite(){ var key = ""; var pairs = "\n"; var i=0; for (i=0; i<=localStorage.length-1; i++) { key = localStorage.key(i); value = localStorage.getItem(key); if( value == "false" ) pairs += "\n\n"; } if (localStorage.length == 0){ pairs += "\n\n"; } pairs += "
NameValue
"+key+""+value+"
emptyempty
"; document.getElementById('allList').innerHTML = pairs; } function doShowAll() { doShowNFavorite(); doShowFavorite(); } function doClearAll(){ localStorage.clear(); doShowAll(); } }}}