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 = "<table><tr><th>Name</th><th>Value</th></tr>\n";
var i=0;
for (i=0; i<=localStorage.length-1; i++) {
key = localStorage.key(i);
value = localStorage.getItem(key);
if( value == "true" )
pairs += "<tr><td onclick=doRemoveFavorite(this)>"+key+"</td>\n<td>"+value+"</td></tr>\n";
}
if (localStorage.length == 0){
pairs += "<tr><td><i>empty</i></td>\n<td><i>empty</i></td></tr>\n";
}
pairs += "</table>";
document.getElementById('favoriteList').innerHTML = pairs;
console.log("end do show all");
}
function doShowNFavorite(){
var key = "";
var pairs = "<table><tr><th>Name</th><th>Value</th></tr>\n";
var i=0;
for (i=0; i<=localStorage.length-1; i++) {
key = localStorage.key(i);
value = localStorage.getItem(key);
if( value == "false" )
pairs += "<tr><td onclick=doSetFavorite(this)>"+key+"</td>\n<td>"+value+"</td></tr>\n";
}
if (localStorage.length == 0){
pairs += "<tr><td><i>empty</i></td>\n<td><i>empty</i></td></tr>\n";
}
pairs += "</table>";
document.getElementById('allList').innerHTML = pairs;
}
function doShowAll() {
doShowNFavorite();
doShowFavorite();
}
function doClearAll(){
localStorage.clear();
doShowAll();
}