diff --git a/agenda-wm.js b/agenda-wm.js new file mode 100644 index 0000000..e2b10b0 --- /dev/null +++ b/agenda-wm.js @@ -0,0 +1,111 @@ +/* + * _____/\\\\\\\\\______________________________________________________/\\\_________________ + * ___/\\\\\\\\\\\\\___________________________________________________\/\\\_________________ + * __/\\\/////////\\\___/\\\\\\\\______________________________________\/\\\_________________ + * _\/\\\_______\/\\\__/\\\////\\\_____/\\\\\\\\___/\\/\\\\\\__________\/\\\___/\\\\\\\\\____ + * _\/\\\\\\\\\\\\\\\_\//\\\\\\\\\___/\\\/////\\\_\/\\\////\\\____/\\\\\\\\\__\////////\\\___ + * _\/\\\/////////\\\__\///////\\\__/\\\\\\\\\\\__\/\\\__\//\\\__/\\\////\\\____/\\\\\\\\\\__ + * _\/\\\_______\/\\\__/\\_____\\\_\//\\///////___\/\\\___\/\\\_\/\\\__\/\\\___/\\\/////\\\__ + * _\/\\\_______\/\\\_\//\\\\\\\\___\//\\\\\\\\\\_\/\\\___\/\\\_\//\\\\\\\/\\_\//\\\\\\\\/\\_ + * _\///________\///___\////////_____\//////////__\///____\///___\///////\//___\////////\//__ + * "So, what's on the agenda?" + * (C) Innovation Inc. 2020 + */ + +function initAgendaWM() { + startTime(); + makeDraggable(); +} // Initialize Agenda + +function makeDraggable() { + $(".framewrap") + .draggable() + .resizable(); +} // Makes all applications with the framewrap class draggable. Has to be ran every time applications are launched or things get sticky. + +function moveToFront(app) { + $('.framewrap').css('z-index', 1); + $('#' + app).css('z-index', 9999); +} // Move a clicked application to the front + +function openApplication(app, width, height, appIcon) { + // Set width and height as default if one is <=-1 + if (width <= -1 || height <= -1 || width == undefined || height == undefined) { + width="500"; + height="300"; + } + var i = 0; + // Get the first available application ID. + while ($('#' + i).length) + i++; + /* + This is just the following as a string: +
+ + + + +
+ [windowID] is replaced with i (defined above) + [application name] is replaced with parameter "app" (used to determine the application name to open). + + The app parameter points to a subdirectory called apps. This means if you were to run openApplication(foo), it will attempt to open an + Application stored at apps/foo/ + + Quite frustrating to work with, but it works. I'll make it fancier later, but right now it is good enough. + */ + var application="
"; + var taskbarApp="
"; + var parent=document.getElementById('appContainer'); + parent.insertAdjacentHTML('beforeend', application); + var parent=document.getElementById('taskbarApps'); + parent.insertAdjacentHTML('beforeend', taskbarApp); + if (width == "max" || height == "max") + maximizeApplication(i); + moveToFront(i); + makeDraggable(); + } // Opens an application. + + function closeApplication(id) { + var application = document.getElementById(id); + var taskbarApp = document.getElementById('task' + id); + application.parentNode.removeChild(application); + taskbarApp.parentNode.removeChild(taskbarApp); + } // Closes an application. + + function maximizeApplication(id) { + document.getElementById(id).setAttribute('style', "height: 92%; width: 99%; top: 42px; left: 0px"); + } // Maximize application + + function minimizeApplication(id) { + var application = document.getElementById(id); + if (application.style.display === "none") { + application.style.display = "block"; + } else { + application.style.display = "none"; + } + } // Minimize application + + function idExists(id) { + if ($('#' + id).length) + return $('#' + id).attr('name'); + else + return false; + } // Check if an ID exists + +function startTime() { + var today = new Date(); + var h = today.getHours(); + var m = today.getMinutes(); + var s = today.getSeconds(); + m = checkTime(m); + s = checkTime(s); + document.getElementById('txt').innerHTML = + h + ":" + m + ":" + s; + var t = setTimeout(startTime, 500); +} // Tick tock, Mr. Wick... + +function checkTime(i) { + if (i < 10) {i = "0" + i}; // add zero in front of numbers < 10 + return i; +} \ No newline at end of file diff --git a/apps/About/index.html b/apps/About/index.html index 5d7f857..5004d78 100644 --- a/apps/About/index.html +++ b/apps/About/index.html @@ -6,13 +6,18 @@

About DremJS

Version: 0.1.4b

-

Agenda WM 0.0.9b

+

Agenda WM 0.1.0b

Note: If something isn't right with your desktop, try reloading the frame! If that doesn't work, clear your browsers cache!

Another Note: When loading an app or clicking the Start button, flickering is normal. This is just because the IFrame is loading the application.

Changelog:

Version 0.1.4b

+Added ProcMan (Process Manager) to the terminal which allows you to list all processes or kill a process

-

~Updated to Agenda WM 0.0.9b, which adds some new features and tweaks including, but not limited to:

+

+Added insmod (Install Module). It's on its first prototype so it's not able to do much.

+

~Separated Terminal from Debug and made it accessible when not in Debug mode.

+

~Updated Terminal image.

+

~Probable a ton more changes that I forgot about before I went on a break

+

~Updated to Agenda WM 0.1.0b, which adds some new features and tweaks including, but not limited to:

+

~Made Agenda its own .js file

~Moved the taskbar that was originally in DremJS into Agenda WM

+Added the ability to minimize and restore applications (hence the taskbar move)

Version 0.1.3b

diff --git a/apps/debug/index.html b/apps/debug/index.html index 3edf79b..6be75bf 100644 --- a/apps/debug/index.html +++ b/apps/debug/index.html @@ -27,10 +27,10 @@
- + diff --git a/apps/terminal/index.html b/apps/terminal/index.html new file mode 100644 index 0000000..4098e02 --- /dev/null +++ b/apps/terminal/index.html @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/apps/terminal/terminal.png b/apps/terminal/terminal.png new file mode 100644 index 0000000..682a81e Binary files /dev/null and b/apps/terminal/terminal.png differ diff --git a/index.html b/index.html index 32fb906..ae37e79 100644 --- a/index.html +++ b/index.html @@ -107,10 +107,11 @@
- + diff --git a/js/.terminal.js.swp b/js/.terminal.js.swp new file mode 100644 index 0000000..4f098ff Binary files /dev/null and b/js/.terminal.js.swp differ diff --git a/js/index.js b/js/index.js index 82214b8..dc91286 100644 --- a/js/index.js +++ b/js/index.js @@ -2,7 +2,7 @@ $(function() { // Set the command-line prompt to include the user's IP Address //$('.prompt').html('[' + codehelper_ip["IP"] + '@HTML5] # '); - $('.prompt').html('[user@HTML5] # '); + $('.prompt').html('[user@DremJS] # '); // Initialize a new terminal object var term = new Terminal('#input-line .cmdline', '#container output'); @@ -19,4 +19,4 @@ $(function() { r("hour", 30*(d.getHours()%12) + d.getMinutes()/2) }, 1000); -}); \ No newline at end of file +}); diff --git a/js/terminal.js b/js/terminal.js index fb3e7a8..f0a4565 100644 --- a/js/terminal.js +++ b/js/terminal.js @@ -1,5 +1,13 @@ var util = util || {}; var infinateLoopDetect; +var i = 0; +var f = 0; +var moduleTypeFlag = 0; +var cmdString = ""; +var modules = []; +var moduleCode = []; +var modInstall; +var firstLine = ""; util.toArray = function(list) { return Array.prototype.slice.call(list || [], 0); @@ -23,8 +31,8 @@ var Terminal = Terminal || function(cmdLineContainer, outputContainer) { var cmdLine_ = document.querySelector(cmdLineContainer); var output_ = document.querySelector(outputContainer); - const CMDS_ = [ - 'cat', 'clear', 'clock', 'date', 'echo', 'help', 'uname', 'whoami', 'cmd_fm', 'procman', + cmds = [ + 'cat', 'clear', 'clock', 'date', 'echo', 'help', 'uname', 'cmd_fm', 'procman', 'insmod', 'rmmod' ]; var fs_ = null; @@ -137,22 +145,45 @@ var Terminal = Terminal || function(cmdLineContainer, outputContainer) { output( args.join(' ') ); break; case 'help': - output('
' + CMDS_.join('
') + '
'); + if (!arguments || (args[0] != "modules")) { + cmdString = ""; + output('DremJS Terminal Help Menu'); + output('All default commands (without modules) for the terminal are as follows:'); + for (i = 0; i < cmds.length; i++) + cmdString += cmds[i] + " "; + output(cmdString); + cmdString = ""; + output('Module commands:'); + for (i = 0; i < modules.length; i++) + cmdString += modules[i] + " "; + output(cmdString); + cmdString = ""; + output('For information on Modules, run "help modules"'); + } else if (args[0] == "modules") { + output('DremJS Terminal Help Menu - Modules'); + output('What are Modules?'); + output('Modules are a simple way to temporarily add new functionality to DremJS. Modules have a .djsm (DremJS Module) file extension and contain JavaScript code which can be ran immediately or from a terminal. DremJS Modules can also be installed in batch with a .djsms (DremJS Module Script). These scripts will automatically handle installations of modules that may be too complex to fit into one file and therefor have multiple modules.\n\n'); + output('Currently, there are three different types of modules: immediate, terminal, and parentscript. An immediate module does exactly what it says: run the code immediately. A terminal module adds functionality to the terminal, such as a new command. However, terminal modules are not persistent after you close the terminal (yet). A parentscript module adds functionality to the main Agenda WM script.\n\n'); + output('The pros and cons of modules'); + output('The pros of modules is that you can add new functionality to DremJS or the terminal without having to install an application.'); + output('The cons of a module is that, since it adds or runs code on-the-fly to DremJS, they are very insecure. A man-in-the-middle attack or other naughty module can cause your data to be stolen (please never use DremJS with any personal data), DremJS to become unstable, or completely crash. This is why we made it so modules are not permanently installed. If you want code that stays put, it is recommended to use an application.'); + } break; case 'uname': output(navigator.appVersion); break; - case 'whoami': + /*case 'whoami': var result = "

"; for (var prop in codehelper_ip) result += prop + ": " + codehelper_ip[prop] + "
"; output(result); - break; + break;*/ case 'cmd_fm': window.open("https://cmd.to/fm","_self") break; case 'spin': - show_image('spin.gif', 100, 100, 'Spinny'); + //show_image('spin.gif', 100, 100, 'Spinny'); + output(''); break; case 'procman': var arguments = args.join(' '); @@ -163,10 +194,10 @@ var Terminal = Terminal || function(cmdLineContainer, outputContainer) { break; } else if (args[0] == "list") { var i = 0; - output('ID Name'); + output('ID\t\tName'); while (i <= 1000) { if (parent.idExists(i)) - output(i + " " + parent.idExists(i)); + output(i + "\t\t" + parent.idExists(i)); i++; } break; @@ -180,20 +211,121 @@ var Terminal = Terminal || function(cmdLineContainer, outputContainer) { output("fatal: application ID " + args[1] + " does not exist."); } } + break; + case 'insmod': + i=0; + modInstall=""; + firstLine=""; + if (!arguments || (args[0] != "remote" && args[0] != "local")) { + output('Install Module (insmod) help'); + output('NOTICE: insmod is currently a prototype and is not yet feature-complete or secured at all. NEVER INSTALL A MODULE UNLESS YOU ARE ON YOUR LOCAL NETWORK!'); + output('To install a module not inside the DremJS folder (not recommended, insecure):'); + output('insmod remote https://example.com/path/to/foo.djsm\n'); + output('To install a module inside the DremJS folder'); + output('insmod remote http://your.local.ip.address/path/to/foo.djsm'); + output('Planned features that aren\'t yet implimented:'); + output('Batch installs (DremJS Module Installation Scripts)'); + output('Local installations'); + //output('insmod local path/to/module.djsm\n'); + //output('To run a module installation script for batch installations that is not inside the DremJS folder:'); + //output('insmod remote https://example.com/foo.djsms\n'); + //output('To run a module installation script that is not inside the DremJS folder:'); + //output('insmod local path/to/script.djsms\n'); + output('For more information on modules, please run: help modules'); + } else if (args[0] == "remote") { + if (args[1] != undefined) { + if ((args[1].substring(args[1].length-5)) == ".djsm") { + output('[insmod] Loading modue at ' + args[1] + '...'); + var modInstall; + jQuery.get(args[1], function(data) { + // Welcome to callback hell + modInstall = data; + output('[insmod] Parsing module...'); + i=0; + while (modInstall.charAt(i) != ';' && i < 50) { + firstLine += modInstall.charAt(i); + i++; + } + modInstall = modInstall.substring(i+1, modInstall.length); + if (firstLine == "type immediate") { + output('[insmod] module type is immediate'); + moduleTypeFlag = 1; + output('[insmod] fatal: module type "immediate" not implimented. Maybe 0.1.5b?'); + } else if (firstLine == "type terminal") { + output('[insmod] module type is terminal'); + moduleTypeFlag = 2; + firstLine = ""; + i=0; + while (modInstall.charAt(i) != ';' && i < 50) { + firstLine += modInstall.charAt(i); + i++; + } + newCmdName = firstLine.substring(6, firstLine.length); + output('[insmod] adding command with name "' + newCmdName + '" to terminal modules list...'); + modules.push(newCmdName); + output('[insmod] installing module...'); + modInstall = modInstall.substring(3+firstLine.length, modInstall.length); + moduleCode.push(modInstall); + } else if (firstLine == "type parentscript") { + output('[insmod] module type is parentscript'); + moduleTypeFlag = 3; + output('[insmod] fatal: module type "parentscript" not implimented. Maybe 0.1.5b?'); + } else { + output('[insmod] fatal: the input file is not a DremJS Module or DremJS Module Script'); + moduleTypeFlag = 0; + } + /*if (moduleTypeFlag = 1) { + output('[insmod] fatal: not implimented. Maybe 0.1.5b?'); + } else if */ + }); + + //output('[insmod] Installing module...'); + + break; + } else if ((args[1].substring(args[1].length-6)) == ".djsms") { + //output('Running module installation script at ' + args[1] + '...'); + output('[insmod] fatal: module installation scripts are not implimented. Maybe 0.1.5b?'); + } else { + output('[insmod] fatal: the input file is not a DremJS Module or DremJS Module Script'); + break; + } + } else { + output('[insmod] fatal: no input file was provided.'); + break; + } + } else if (args[0] == "local") { + output('[insmod] fatal: local installation is not yet implimented. Remote installation can do this. For example: insmod remote http://localhost:8000/modules/foo-0.0.0.djsm'); + } + break; + case 'rmmod': + output('[rmmod] fatal: not implimented. Maybe 0.1.5b?'); + break; default: - var notFoundFlag = 0; + + var notFoundFlag = 1; if (cmd != undefined) { - for (i = 0; i < CMDS_.length; i++) - if (cmd != CMDS_[i]) + // Checks if the default terminal command exists + for (i = 0; i < cmds.length; i++) + if (cmd != cmds[i]) notFoundFlag = 1; else { notFoundFlag = 0; - i = CMDS_.length; + i = cmds.length; } + + // Checks if a module with the command name is installed + for (i = 0; i < modules.length; i++) { + if (cmd != modules[i]) + notFoundFlag = 1; + else { + notFoundFlag = 0; + eval(moduleCode[i]); + } + } } else { cmd = ""; - notFoundFlag = 1; } + if (notFoundFlag == 1) { output(cmd + ': command not found'); } @@ -229,6 +361,16 @@ var Terminal = Terminal || function(cmdLineContainer, outputContainer) { output_.insertAdjacentHTML('beforeEnd', '

' + html + '

'); } + function sleep(delay) { + var start = new Date().getTime(); + while (new Date().getTime() < start + delay); + } // Cyclefucker 1000 + + function fileToVar(t) { + modInstall = t; + alert(modInstall); + } + // Cross-browser impl to get document's height. function getDocHeight_() { var d = document; @@ -242,7 +384,7 @@ var Terminal = Terminal || function(cmdLineContainer, outputContainer) { // return { init: function() { - output('

HTML5 Web Terminal

' + new Date() + '

Enter "help" for more information.

'); + output('

DremJS Terminal

' + new Date() + '

Enter "help" for more information.

'); }, output: output } diff --git a/modules/hello_world-0.0.0.djsm b/modules/hello_world-0.0.0.djsm new file mode 100644 index 0000000..da0f154 --- /dev/null +++ b/modules/hello_world-0.0.0.djsm @@ -0,0 +1,5 @@ +type terminal; +name hello; + +output("world"); +//break; \ No newline at end of file diff --git a/terminal.html b/terminal.html index 080f6eb..eb7b3a4 100644 --- a/terminal.html +++ b/terminal.html @@ -3,7 +3,7 @@ - HTML5 Web Terminal + DremJS Terminal @@ -18,7 +18,7 @@ - HTML5 Web Terminal + DremJS diff --git a/termlogo.png b/termlogo.png new file mode 100644 index 0000000..321dd4c Binary files /dev/null and b/termlogo.png differ diff --git a/termlogo_old.png b/termlogo_old.png new file mode 100644 index 0000000..7c00315 Binary files /dev/null and b/termlogo_old.png differ