diff --git a/agenda-wm.js b/agenda-wm.js index e2b10b0..0141f71 100644 --- a/agenda-wm.js +++ b/agenda-wm.js @@ -13,8 +13,12 @@ */ function initAgendaWM() { + console.log("Initializing Agenda WM"); startTime(); + console.log("Starting widgets"); + startWidgets(); makeDraggable(); + console.log("Agenda WM Initialized"); } // Initialize Agenda function makeDraggable() { @@ -28,12 +32,17 @@ function moveToFront(app) { $('#' + app).css('z-index', 9999); } // Move a clicked application to the front -function openApplication(app, width, height, appIcon) { +function openApplication(app, width, height, appIcon, filename) { // Set width and height as default if one is <=-1 if (width <= -1 || height <= -1 || width == undefined || height == undefined) { width="500"; height="300"; } + if (filename == undefined) { + file = ""; + } else { + file = filename; + } var i = 0; // Get the first available application ID. while ($('#' + i).length) @@ -54,8 +63,8 @@ function openApplication(app, width, height, appIcon) { 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 application="
"; + var taskbarApp="
"; var parent=document.getElementById('appContainer'); parent.insertAdjacentHTML('beforeend', application); var parent=document.getElementById('taskbarApps'); @@ -65,12 +74,46 @@ function openApplication(app, width, height, appIcon) { moveToFront(i); makeDraggable(); } // Opens an application. + function openWidget(widget, filename) { + if (filename == undefined) { + file = ""; + } else { + file = filename; + } + var i = 0; + // Get the first available application ID. + while ($('#' + i).length) + i++; + var newWidget = "
"; + var parent=document.getElementById('appContainer'); + parent.insertAdjacentHTML('beforeend', newWidget); + makeDraggable(); + } // Start a new widget - function closeApplication(id) { - var application = document.getElementById(id); - var taskbarApp = document.getElementById('task' + id); - application.parentNode.removeChild(application); - taskbarApp.parentNode.removeChild(taskbarApp); + function startWidgets() { + jQuery.get('/enabled_widgets', function(data) { + var widgets = data.split("\n"); + for(i = 0; i < widgets.length-1; i++) { + if(true) { + console.log('Opening ' + widgets[i]); + openWidget(widgets[i]); + } else { + console.log("ERROR: Can't open widget - a network error occurred. This probably means this widget does not exist. Ignoring."); + } + } + }); + } // Start all enabled widgets + + function closeApplication(id) { + if(idExists(id)) { + var application = document.getElementById(id); + var taskbarApp = document.getElementById('task' + id); + application.parentNode.removeChild(application); + if(taskbarApp != null) + taskbarApp.parentNode.removeChild(taskbarApp); + } else { + console.log("Application with ID " + id + " does not exist. Ignoring."); + } } // Closes an application. function maximizeApplication(id) { @@ -108,4 +151,26 @@ function startTime() { function checkTime(i) { if (i < 10) {i = "0" + i}; // add zero in front of numbers < 10 return i; -} \ No newline at end of file +} + +/*function returnStatus(req, status) { + //console.log(req); + if(status == 200) { + console.log("The url is available"); + // send an event + } else { + console.log("The url returned status code " + status); + // send a different event + } +}*/ + +function fetchStatus(address) { + var client = new XMLHttpRequest(); + client.onreadystatechange = function() { + // in case of network errors this might not give reliable results + if(this.readyState == 4) + return this.status; + } + client.open("HEAD", address); + client.send(); +} diff --git a/apps/About/about.png b/apps/about/about.png similarity index 100% rename from apps/About/about.png rename to apps/about/about.png diff --git a/apps/About/index.html b/apps/about/index.html similarity index 90% rename from apps/About/index.html rename to apps/about/index.html index 9dd5754..e787a89 100644 --- a/apps/About/index.html +++ b/apps/about/index.html @@ -26,11 +26,22 @@

About DremJS

-

Version: 0.1.5b

-

Agenda WM 0.1.0b

+

Version: 0.1.6b

+

Agenda WM 0.1.1b

Changelog:
+ Version 0.1.6b
+ +Widget support (see wiki for more information)
+ +Made clicking apps in the taskbar move applications to the front instead of minimizing.
+ +Cowsay (PHP and JS interfacing experiment)
+ +Changed the start menu to the Drem Logo
+ +Added a task manager (combined with Server Status application)
+ +Added a CPU/memory monitor (see wiki for more information)
+ ~Windows now have a shaded background
+ ~Fixed a bug in terminal where white-space is ignored by output().
+ ~Made terminal themes consistent (no more cookies)
+ ~General system stability improvements to enhance the user's experience.

Version 0.1.5b
+Readded the start menu
+A lite theme for the terminal, if that's your thing. You can toggle the theme with "settheme".
diff --git a/apps/About/logo.png b/apps/about/logo.png similarity index 100% rename from apps/About/logo.png rename to apps/about/logo.png diff --git a/apps/about/name b/apps/about/name new file mode 100644 index 0000000..0c23b01 --- /dev/null +++ b/apps/about/name @@ -0,0 +1 @@ +About diff --git a/apps/debug/name b/apps/debug/name new file mode 100644 index 0000000..329d484 --- /dev/null +++ b/apps/debug/name @@ -0,0 +1 @@ +Debug diff --git a/apps/HowTo/ambient.mp3 b/apps/howto/ambient.mp3 similarity index 100% rename from apps/HowTo/ambient.mp3 rename to apps/howto/ambient.mp3 diff --git a/apps/HowTo/apps.png b/apps/howto/apps.png similarity index 100% rename from apps/HowTo/apps.png rename to apps/howto/apps.png diff --git a/apps/HowTo/howto.png b/apps/howto/howto.png similarity index 100% rename from apps/HowTo/howto.png rename to apps/howto/howto.png diff --git a/apps/HowTo/index.html b/apps/howto/index.html similarity index 100% rename from apps/HowTo/index.html rename to apps/howto/index.html diff --git a/apps/howto/name b/apps/howto/name new file mode 100644 index 0000000..2ffb473 --- /dev/null +++ b/apps/howto/name @@ -0,0 +1 @@ +How to Install Applications diff --git a/apps/HowTo/script.png b/apps/howto/script.png similarity index 100% rename from apps/HowTo/script.png rename to apps/howto/script.png diff --git a/apps/Market/index.html b/apps/market/index.html similarity index 100% rename from apps/Market/index.html rename to apps/market/index.html diff --git a/apps/Market/market.png b/apps/market/market.png similarity index 100% rename from apps/Market/market.png rename to apps/market/market.png diff --git a/apps/market/name b/apps/market/name new file mode 100644 index 0000000..8c5e7cb --- /dev/null +++ b/apps/market/name @@ -0,0 +1 @@ +DremJS Market diff --git a/apps/serverstatus/TaskManager.html b/apps/serverstatus/TaskManager.html new file mode 100644 index 0000000..845fa3c --- /dev/null +++ b/apps/serverstatus/TaskManager.html @@ -0,0 +1,60 @@ + + + + + + + + + +

+ + +
+ + + + + + + + + +
IDProcess Name
+ + diff --git a/apps/serverstatus/index.php b/apps/serverstatus/index.php new file mode 100644 index 0000000..089e57f --- /dev/null +++ b/apps/serverstatus/index.php @@ -0,0 +1,110 @@ + + + + + + + + + + +
+ + +
+
+ +
+ + '; + echo($systemInfo); + //ob_flush(); + //flush(); + } + + function memory_usage() { + return memory_total() - memory_free(); + } + + function memory_free() { + $fh = fopen('/proc/meminfo','r'); + $mem = 0; + while ($line = fgets($fh)) { + $pieces = array(); + if (preg_match('/^MemFree:\s+(\d+)\skB$/', $line, $pieces)) { + $mem = $pieces[1]; + break; + } + } + fclose($fh); + return $mem; + } + + function memory_total() { + $fh = fopen('/proc/meminfo','r'); + $mem = 0; + while ($line = fgets($fh)) { + $pieces = array(); + if (preg_match('/^MemTotal:\s+(\d+)\skB$/', $line, $pieces)) { + $mem = $pieces[1]; + break; + } + } + fclose($fh); + return $mem; + } + + function getCpuUsage() { + if(stristr(PHP_OS, 'win')) { + $_ENV['typeperfCounter'] = '\processor(_total)\% processor time'; + exec('typeperf -sc 1 "'.$_ENV['typeperfCounter'].'"', $p); + $line = explode(',', $p[2]); + $load = trim($line[1], '"'); + return $load; + } else { + $usage = sys_getloadavg(); + return $usage[0]; + } + } + + displayInfo(); +?> diff --git a/apps/serverstatus/name b/apps/serverstatus/name new file mode 100644 index 0000000..35088d8 --- /dev/null +++ b/apps/serverstatus/name @@ -0,0 +1 @@ +Server Status diff --git a/apps/serverstatus/serverstatus.png b/apps/serverstatus/serverstatus.png new file mode 100644 index 0000000..5babe2c Binary files /dev/null and b/apps/serverstatus/serverstatus.png differ diff --git a/apps/terminal/name b/apps/terminal/name new file mode 100644 index 0000000..c15f6e0 --- /dev/null +++ b/apps/terminal/name @@ -0,0 +1 @@ +Terminal diff --git a/apps/widgets-settings/.addwidget.swp b/apps/widgets-settings/.addwidget.swp new file mode 100644 index 0000000..c2ce854 Binary files /dev/null and b/apps/widgets-settings/.addwidget.swp differ diff --git a/apps/widgets-settings/addwidget.php b/apps/widgets-settings/addwidget.php new file mode 100644 index 0000000..1f31aad --- /dev/null +++ b/apps/widgets-settings/addwidget.php @@ -0,0 +1,44 @@ + + + + + + "; + $widgets = array_filter(glob(getenv('DOCUMENT_ROOT').'/widgets/*'), 'is_dir'); + for($i = 0; $i<=sizeof($widgets)-1; $i++) { + $temp = explode("/", $widgets[$i]); + echo $temp[sizeof($temp)-1].' '; + } + echo "

Currently enabled widgets:
"; + $enabledWidgets = explode("\n", file_get_contents(getenv('DOCUMENT_ROOT')."/enabled_widgets")); + for($i = 0; $i<=sizeof($enabledWidgets)-1; $i++) + echo $enabledWidgets[$i].' '; + echo "
"; + if(array_key_exists('add', $_POST)) { + addWidget(); + } + function addWidget() { + $widget = $_REQUEST['widget']; + $widgets = array_filter(glob(getenv('DOCUMENT_ROOT').'/widgets/*'), 'is_dir'); + $enabledWidgets = explode("\n", file_get_contents(getenv('DOCUMENT_ROOT')."/enabled_widgets")); + //print($widget.'
'); + //print_r($widgets); + //print_r($enabledWidgets); + if(in_array(getenv('DOCUMENT_ROOT').'/widgets/'.$widget, $widgets) && !(in_array($widget, $enabledWidgets))) { + $file = fopen(getenv('DOCUMENT_ROOT').'/enabled_widgets', 'a'); + fwrite($file, $widget."\n"); + fclose($file); + echo "Added ".$widget; + } else { + echo "Can't add widget - it either doesn't exist or is already enabled"; + } + } + ?> +
+ + +
+ + + diff --git a/apps/widgets-settings/index.php b/apps/widgets-settings/index.php new file mode 100644 index 0000000..0c0b89d --- /dev/null +++ b/apps/widgets-settings/index.php @@ -0,0 +1,34 @@ + + + + + + "; + $widgets = array_filter(glob(getenv('DOCUMENT_ROOT').'/widgets/*'), 'is_dir'); + for($i = 0; $i<=sizeof($widgets)-1; $i++) { + $temp = explode("/", $widgets[$i]); + echo $temp[sizeof($temp)-1].' '; + } + echo "

Currently enabled widgets:
"; + $enabledWidgets = explode("\n", file_get_contents(getenv('DOCUMENT_ROOT')."/enabled_widgets")); + for($i = 0; $i<=sizeof($enabledWidgets)-1; $i++) + echo $enabledWidgets[$i].' '; + echo "
"; + if(array_key_exists('add', $_POST)) { + addWidgets(); + } else if(array_key_exists('remove', $_POST)) { + removeWidgets(); + } + function addWidgets() { + echo "Add"; + } + function removeWidgets() { + echo "Remove"; + } + ?> + + +

Changes take effect after restart.

+ + diff --git a/apps/widgets-settings/name b/apps/widgets-settings/name new file mode 100644 index 0000000..e43bcd2 --- /dev/null +++ b/apps/widgets-settings/name @@ -0,0 +1 @@ +Widgets Settings diff --git a/apps/widgets-settings/removewidget.php b/apps/widgets-settings/removewidget.php new file mode 100644 index 0000000..aa2efcf --- /dev/null +++ b/apps/widgets-settings/removewidget.php @@ -0,0 +1,4 @@ + diff --git a/apps/widgets-settings/widgets-settings.png b/apps/widgets-settings/widgets-settings.png new file mode 100644 index 0000000..645e1fe Binary files /dev/null and b/apps/widgets-settings/widgets-settings.png differ diff --git a/enabled_widgets b/enabled_widgets new file mode 100755 index 0000000..8b13789 --- /dev/null +++ b/enabled_widgets @@ -0,0 +1 @@ + diff --git a/favicon.ico b/favicon.ico index 0af508d..50fb9ea 100644 Binary files a/favicon.ico and b/favicon.ico differ diff --git a/favicon_old.ico b/favicon_old.ico new file mode 100644 index 0000000..0af508d Binary files /dev/null and b/favicon_old.ico differ diff --git a/index.html b/index.html index 672f2f1..74d9670 100644 --- a/index.html +++ b/index.html @@ -14,6 +14,7 @@ top: 50px; left: 10px; background-color:#87CEEB; + box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2); } .appFrame { width:99%; @@ -82,9 +83,9 @@ margin-top: 2px; } .startbtn { - background-color: gray; + background-color: transparent; color: black; - padding: 12px; + padding: 8px; // Bad way of doing this but that's a problem for future Sam font-size: 16px; border: none; z-index: 30000; @@ -116,17 +117,19 @@ -

DremJS Version 0.1.5b

+

DremJS Version 0.1.6b

© Innovation Inc.

- +
-

About DremJS

-

How to Install Applications

-

DremJS Market

+

About DremJS

+

How to Install Applications

+

DremJS Market

Report a Bug

Terminal

+

Server Status

+

Widgets Settings


Shutdown DremJS

@@ -136,7 +139,7 @@
@@ -144,8 +147,5 @@
- diff --git a/logo.png b/logo.png new file mode 100644 index 0000000..321dd4c Binary files /dev/null and b/logo.png differ diff --git a/terminal.html b/terminal.html index 887806f..f51e7d5 100644 --- a/terminal.html +++ b/terminal.html @@ -9,7 +9,7 @@ - + @@ -19,8 +19,21 @@ - + +
@@ -69,7 +82,7 @@ - +
@@ -87,7 +100,7 @@ - + diff --git a/terminal/configs/theme.conf b/terminal/configs/theme.conf new file mode 100755 index 0000000..c227083 --- /dev/null +++ b/terminal/configs/theme.conf @@ -0,0 +1 @@ +0 \ No newline at end of file diff --git a/js/index.js b/terminal/index.js similarity index 100% rename from js/index.js rename to terminal/index.js diff --git a/terminal/scripts/cowsay.php b/terminal/scripts/cowsay.php new file mode 100644 index 0000000..85cc13d --- /dev/null +++ b/terminal/scripts/cowsay.php @@ -0,0 +1,78 @@ + 39) { + $wrapTextOnceFlag = True; + } else { + $wrapTextOnceFlag = False; + } + if (strlen($inputText) > 78) { + $wrapTextTwiceFlag = True; + } else { + $wrapTextTwiceFlag = False; + } + // Now that we know how to process the speech bubble, we now need to process + // the input string. + if($wrapTextOnceFlag == True) { + $output.=" _________________________________________
"; + if($wrapTextTwiceFlag == True) { + $textArray = str_split($inputText, 39); + $output.="/ ".$textArray[0]." \
"; + $counter = 1; + while($counter < sizeof($textArray)-2) { + $output.="| ".$textArray[$counter]." |
"; + //$output.="Adding line ".$counter." of ".sizeof($textArray)-2."
"; + $output.=" -----------------------------------------
"; + //$output.=$textArray[sizeof($textArray)-1]; + } else { + $textArray = str_split($inputText, 39); + $output.="/ ".$textArray[0]." \
"; + $output.="\ ".$textArray[1].str_repeat(' ', 39-strlen($textArray[1]))." /
"; + $output.=" -----------------------------------------
"; + } + } else { + $output.=" _".str_repeat("_", strlen($inputText))."_
"; + $output.="< ".$inputText." >
"; + $output.=" -".str_repeat("-", strlen($inputText))."-
"; + } + if($skin == "tux") { + $output.=" \\ .--.
"; + $output.=" \\ |_ |
"; + $output.=" |:_/ |
"; + $output.=" // \\ \\
"; + $output.=" (| | )
"; + $output.=" /'\\_ _/`\\
"; + $output.=" \\___)=(___/"; + /* + \ .--. + \ |_ | + |:_/ | + // \ \ + (| | ) + /'\_ _/`\ + \___)=(___/ + */ + } else { + $output.=" \\ ^__^
"; + $output.=" \\ (oo)\\_______
"; + $output.=" (__)\\ )\\/\\
"; + $output.=" ||----w |
"; + $output.=" || ||"; + /* + \ ^__^ + \ (oo)\_______ + (__)\ )\/\ + ||----w | + || || + */ + } + echo $output; +?> diff --git a/terminal/scripts/swapTheme.php b/terminal/scripts/swapTheme.php new file mode 100644 index 0000000..1d82204 --- /dev/null +++ b/terminal/scripts/swapTheme.php @@ -0,0 +1,10 @@ + diff --git a/js/terminal.js b/terminal/terminal.js similarity index 90% rename from js/terminal.js rename to terminal/terminal.js index 8a1834a..dc30662 100644 --- a/js/terminal.js +++ b/terminal/terminal.js @@ -8,23 +8,6 @@ var modules = []; var moduleCode = []; var modInstall; var firstLine = ""; -var theme = getCookie('terminalTheme'); - -function getCookie(cname) { - var name = cname + "="; - var decodedCookie = decodeURIComponent(document.cookie); - var ca = decodedCookie.split(';'); - for(var i = 0; i '); - output('Possible themes:'); - output('0 - dark'); - output('1 - lite'); - } - break; + case 'swaptheme': + $.ajax({ + url: 'terminal/scripts/swapTheme.php' + }); + output('Theme swapped. Please restart the terminal and refresh it a few times.'); + break; + case 'cowsay': + if(args[0] == null) { + output("cowsay [text] <skin>
Availible skins:
default\t\ttux
If no skin is provided or it is invalid, the default is used instead."); + } else { + var oReq = new XMLHttpRequest(); + oReq.onload = function() { + output(this.responseText); + }; + if(args[1] == null) + args[1] = "cow"; + oReq.open("get", "terminal/scripts/cowsay.php?inputText=" + args[0] + "&skin=" + args[1], true); + oReq.send(); + } + break; default: - var notFoundFlag = 1; if (cmd != undefined) { // Checks if the default terminal command exists @@ -390,7 +380,7 @@ var Terminal = Terminal || function(cmdLineContainer, outputContainer) { // function output(html) { - output_.insertAdjacentHTML('beforeEnd', '

' + html + '

'); + output_.insertAdjacentHTML('beforeEnd', '

' + html + '

'); } function sleep(delay) { @@ -416,11 +406,13 @@ var Terminal = Terminal || function(cmdLineContainer, outputContainer) { // return { init: function() { - if(theme == 0) { - output('

DremJS Terminal

' + new Date() + '

Enter "help" for more information.

'); - } else { - output('

DremJS Terminal

' + new Date() + '

Enter "help" for more information.

'); - } + jQuery.get('terminal/configs/theme.conf', function(data) { + if(data == "1") { + output('

DremJS Terminal

' + new Date() + '

Enter "help" for more information.

'); + } else { + output('

DremJS Terminal

' + new Date() + '

Enter "help" for more information.

'); + } + }); }, output: output } diff --git a/termlogo-dark.png b/termlogo-dark.png index 321dd4c..4fc5f25 100644 Binary files a/termlogo-dark.png and b/termlogo-dark.png differ diff --git a/termlogo-lite.png b/termlogo-lite.png index 321dd4c..d047c45 100644 Binary files a/termlogo-lite.png and b/termlogo-lite.png differ diff --git a/widgets/clock/index.html b/widgets/clock/index.html new file mode 100644 index 0000000..b009992 --- /dev/null +++ b/widgets/clock/index.html @@ -0,0 +1,92 @@ + + + + +
+
+ + + + + + diff --git a/widgets/clock/name b/widgets/clock/name new file mode 100644 index 0000000..e066761 --- /dev/null +++ b/widgets/clock/name @@ -0,0 +1 @@ +Clock diff --git a/widgets/serverstatus/index.php b/widgets/serverstatus/index.php new file mode 100644 index 0000000..cea440e --- /dev/null +++ b/widgets/serverstatus/index.php @@ -0,0 +1,110 @@ + + + + + + + + + + + +
+ +
+ + '; + echo($systemInfo); + //ob_flush(); + //flush(); + } + + function memory_usage() { + return memory_total() - memory_free(); + } + + function memory_free() { + $fh = fopen('/proc/meminfo','r'); + $mem = 0; + while ($line = fgets($fh)) { + $pieces = array(); + if (preg_match('/^MemFree:\s+(\d+)\skB$/', $line, $pieces)) { + $mem = $pieces[1]; + break; + } + } + fclose($fh); + return $mem; + } + + function memory_total() { + $fh = fopen('/proc/meminfo','r'); + $mem = 0; + while ($line = fgets($fh)) { + $pieces = array(); + if (preg_match('/^MemTotal:\s+(\d+)\skB$/', $line, $pieces)) { + $mem = $pieces[1]; + break; + } + } + fclose($fh); + return $mem; + } + + function getCpuUsage() { + if(stristr(PHP_OS, 'win')) { + $_ENV['typeperfCounter'] = '\processor(_total)\% processor time'; + exec('typeperf -sc 1 "'.$_ENV['typeperfCounter'].'"', $p); + $line = explode(',', $p[2]); + $load = trim($line[1], '"'); + return $load; + } else { + $usage = sys_getloadavg(); + return $usage[0]; + } + } + + displayInfo(); +?> diff --git a/widgets/serverstatus/name b/widgets/serverstatus/name new file mode 100644 index 0000000..35088d8 --- /dev/null +++ b/widgets/serverstatus/name @@ -0,0 +1 @@ +Server Status