diff options
author | Unknown | 2018-04-05 20:57:25 +0100 |
---|---|---|
committer | Unknown | 2018-04-05 20:57:25 +0100 |
commit | e8557e7fd10d9ffa8ae180d5e6bf90721b408829 (patch) | |
tree | 3446e050a9e654354996a2e9eeca3e69d3704db7 | |
parent | f1fbfaf111205a1ebee7f00a8d83375977e52ece (diff) |
realise that delete exists
-rw-r--r-- | pkg93.js | 39 |
1 files changed, 19 insertions, 20 deletions
@@ -126,32 +126,31 @@ var pkg93 = { }, rm: function(pkg) { var request = new XMLHttpRequest(); - if (!!localStorage[".pkg93/packages/" + pkg + ".rm.js"]) { + var index = config.installed.indexOf(pkg); + if (index < 0) { + $log("<b><span style='color:#f00'>ERR</span></b> Not found."); + return false; + } else if (!!localStorage[".pkg93/packages/" + pkg + ".rm.js"]) { eval(localStorage[".pkg93/packages/" + pkg + ".rm.js"]); // Typing eval makes me feel dirty. + delete le._apps[config.installed[index]]; delete localStorage[".pkg93/packages/" + pkg + ".rm.js"] delete localStorage[".pkg93/packages/" + pkg + ".js"] delete localStorage[".pkg93/packages/" + pkg + ".json"] } else { - var index = config.installed.indexOf(pkg); - if (index < 0) { - $log("<b><span style='color:#f00'>ERR</span></b> Not found."); - return false; - } else { - try { - if (le._apps[config.installed[index]] === null) { - $log("<b><span style='color:#f00'>ERR</span></b> Already removed."); - } else { - delete le._apps[config.installed[index]]; - delete localStorage[".pkg93/packages/" + config.installed[index] + ".js"]; - delete localStorage[".pkg93/packages/" + config.installed[index] + ".json"]; - config.installed.splice(index, 1); - $log("<b><span style='color:#0f0'>OK</span></b> Removed!"); - } - return true; - } catch (err) { - $log("<b><span style='color:#f00'>ERR</span></b> " + err.message); - return false; + try { + if (le._apps[config.installed[index]] === null) { + $log("<b><span style='color:#f00'>ERR</span></b> Already removed."); + } else { + delete le._apps[config.installed[index]]; + delete localStorage[".pkg93/packages/" + config.installed[index] + ".js"]; + delete localStorage[".pkg93/packages/" + config.installed[index] + ".json"]; + config.installed.splice(index, 1); + $log("<b><span style='color:#0f0'>OK</span></b> Removed!"); } + return true; + } catch (err) { + $log("<b><span style='color:#f00'>ERR</span></b> " + err.message); + return false; } } } |