From 09e2b0f1e785bcc96e6436531a2b552a22ab61a3 Mon Sep 17 00:00:00 2001 From: Unknown Date: Tue, 3 Apr 2018 13:28:37 +0100 Subject: fix a few bugs --- pkg93.js | 65 ++++++++++++++++++++++++++++++++++++++++------------------------ 1 file changed, 41 insertions(+), 24 deletions(-) diff --git a/pkg93.js b/pkg93.js index 683e847..a70b189 100644 --- a/pkg93.js +++ b/pkg93.js @@ -39,6 +39,8 @@ function cmp (a, b) { return 0; } +var pkg93 = {debug: false}; + console.group("[pkg93]"); var failed = false; console.log("[pkg93] Injecting packages..."); @@ -58,18 +60,8 @@ le._apps.pkg93 = { exec: function() { const protected = ["3d","acid","acidbox","ansi","anthology","arena93","bananamp","base64","bytebeat","calc","castlegafa","catex","cd","clear","clearhist","clippy","code","contact","crazy","defrag","dmg","do a barrel roll","doctor","download","find","font","format","fullscreen","fx","gameoflife","glitch","global thermonuclear war","gravity","hampster","hello","help","hexed","history","hl3","hydra","ie6","iframe","img","info","js","key","killall","layer","lenna","lisa","ls","manifesto","marburg","messenger","mines","necronomicoin","pd","piskel","pkg93","pony","potato","progressquest","pwd","reboot","robby","rotate","shutdown","skifree","solitude","speech","starwars","superplayer","takethis","terminal","textarea","tree","trollbox","vega","virtualpc","vm","wat","whatif","whois","win","zkype"]; const args = this.arg.arguments; - const version = "v1.0.0"; - if (localStorage[".pkg93/config.json"] === undefined) { - localStorage[".pkg93/config.json"] = '{"repos": ["http://codinggamerhd.com/main-repo"], "installed": [], "pkglist": []}'; - } - if (localStorage[".pkg93/packages/"] === undefined) { - localStorage[".pkg93/packages/"] = ""; - } - localStorage[".pkg93/README.txt"] = "WARNING!\nThis folder contains important data about pkg93. Do not edit anything in here unless you want pkg93 to not work!\n\n~1024x2"; - var config = JSON.parse(localStorage[".pkg93/config.json"]); - var request = new XMLHttpRequest(); - if (args.length === 0) { - $log(`pkg93 ${version} + const version = "v1.0.1"; + const help = `pkg93 ${version} Usage: pkg93 [command] List of Commands @@ -85,10 +77,20 @@ le._apps.pkg93 = { Examples pkg93 get gud -pkg93 rm kebab - -WARN Not all packages are safe. Treat packages like EXE files.`); +pkg93 rm kebab`; + if (localStorage[".pkg93/config.json"] === undefined) { + localStorage[".pkg93/config.json"] = '{"repos": ["http://codinggamerhd.com/main-repo"], "installed": [], "pkglist": []}'; + } + if (localStorage[".pkg93/packages/"] === undefined) { + localStorage[".pkg93/packages/"] = ""; + } + localStorage[".pkg93/README.txt"] = "WARNING!\nThis folder contains important data about pkg93. Do not edit anything in here unless you want pkg93 to not work!\n\n~1024x2"; + var config = JSON.parse(localStorage[".pkg93/config.json"]); + var request = new XMLHttpRequest(); + if (args.length === 0) { + $log(help); } else if (args[0] == "pull") { + $log("WARN Windows93 may lag while getting packages.\n This is a normal thing."); var pkgs = []; config.pkglist = []; config.repos.forEach(function (source) { @@ -97,13 +99,20 @@ pkg93 rm kebab try { request.send(null); var json = JSON.parse(request.responseText); + $log("NAME " + json.name); + $log("MOTD \"" + json.motd + "\""); json.packages.forEach(function(item) { - $log("OK " + item + "@" + source); - pkgs.push(item + "@" + source); + try { + $log("OK " + item + "@" + source); + pkgs.push(item + "@" + source); + } catch (err) { + $log("ERR " + err.message); + } }); config.pkglist = config.pkglist.concat(pkgs); } catch (err) { $log("ERR " + err.message); + $log(request.responseText); } }); } else if (args[0] == "get") { @@ -163,10 +172,10 @@ pkg93 rm kebab $log("ERR Already removed."); } else { le._apps[config.installed[index]] = null; - localStorage[".pkg93/packages/" + config.installed[index]] + ".rm.js"] = null; - localStorage[".pkg93/packages/" + config.installed[index]] + ".js"] = null; - localStorage[".pkg93/packages/" + config.installed[index]] + ".json"] = null; - config.installed = config.installed.splice(index, 1); + console.log("no u"); + localStorage[".pkg93/packages/" + config.installed[index] + ".js"] = null; + localStorage[".pkg93/packages/" + config.installed[index] + ".json"] = null; + config.installed.splice(index, 1); $log("OK Removed!"); } } catch (err) { @@ -183,7 +192,8 @@ pkg93 rm kebab } } else if (args[0] == "rm-repo") { try { - config.repos = config.repos.splice(parseInt(args[1]), 1); + config.repos.splice(parseInt(args[1]), 1); + localStorage[".pkg93/config.json"] = JSON.stringify(config); $log("OK Done!\n Run \"pkg93 pull\" to update the package listing."); } catch (err) { $log("ERR " + err.message); @@ -194,10 +204,16 @@ pkg93 rm kebab } else if (args[1] == "installed") { $log(config.installed.join("\n")); } else if (args[1] == "repos") { - $log(config.repos.join("\n")); + lerepos = ""; + config.repos.forEach(function (repo, index) { + lerepos += "[" + index + "] " + repo; + }); + $log(lerepos); } else { $log("ERR You must select either pkgs, installed, or repos."); } + } else if (args[0] == "help") { + $log(help); } else { $log("ERR Invalid command. Type \"pkg93\" without any arguments for help."); } @@ -205,5 +221,6 @@ pkg93 rm kebab }, icon: "/c/sys/skins/w93/install.png", terminal: true, - hascli: true + hascli: true, + categories: "Network;" }; -- cgit v1.2.3