Update to 0.1.6b

This commit is contained in:
Innovation Inc 2020-05-26 23:26:34 -05:00
parent 7e06b5f4cf
commit 0501e9c455
43 changed files with 703 additions and 69 deletions

View file

@ -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="<div onclick=\"moveToFront('" + i + "')\" name='" + app + "' id='" + i + "' class='framewrap' style='width:" + width + "px; height:" + height + "px'><input type='button' onclick=\"closeApplication('" + i + "')\" value='X' /><input type='button' onclick=\"maximizeApplication('" + i + "')\" value='\u25A1' /><input type='button' onclick=\"minimizeApplication('" + i + "')\" value='_' /><iframe class='appFrame' src='apps/" + app + "/'></iframe></div>";
var taskbarApp="<div id='task" + i + "' onclick=\"minimizeApplication('" + i + "')\" class='taskbarApps'><img src='apps/" + app + "/" + appIcon + "' style='width:32px;height:32px' align='middle' /></div>";
var application="<div onclick=\"moveToFront('" + i + "')\" name='" + app + "' id='" + i + "' class='framewrap' style='width:" + width + "px; height:" + height + "px'><input type='button' onclick=\"closeApplication('" + i + "')\" value='X' /><input type='button' onclick=\"maximizeApplication('" + i + "')\" value='\u25A1' /><input type='button' onclick=\"minimizeApplication('" + i + "')\" value='_' /><iframe class='appFrame' src='apps/" + app + "/" + file + "'></iframe></div>";
var taskbarApp="<div id='task" + i + "' onclick=\"moveToFront('" + i + "')\" class='taskbarApps'><img src='apps/" + app + "/" + appIcon + "' style='width:32px;height:32px' align='middle' /></div>";
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 = "<div name='" + widget + "' id='" + i + "' class='framewrap' style='width:300px;height:300px;'><iframe class='appFrame' src='widgets/" + widget + "/" + file + "'></iframe></div>";
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;
}
}
/*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();
}

View file

Before

Width:  |  Height:  |  Size: 794 B

After

Width:  |  Height:  |  Size: 794 B

View file

@ -26,11 +26,22 @@
</div>
<div class="right">
<h1>About DremJS</h1>
<h2>Version: 0.1.5b</h2>
<h2>Agenda WM 0.1.0b</h2>
<h2>Version: 0.1.6b</h2>
<h2>Agenda WM 0.1.1b</h2>
</div>
</section>
<p>Changelog:<br />
Version 0.1.6b<br />
+Widget support (see wiki for more information)<br />
+Made clicking apps in the taskbar move applications to the front instead of minimizing.<br />
+Cowsay (PHP and JS interfacing experiment)<br />
+Changed the start menu to the Drem Logo<br />
+Added a task manager (combined with Server Status application)<br />
+Added a CPU/memory monitor (see wiki for more information)<br />
~Windows now have a shaded background<br />
~Fixed a bug in terminal where white-space is ignored by output().<br />
~Made terminal themes consistent (no more cookies)<br />
~General system stability improvements to enhance the user's experience.<br /><br />
Version 0.1.5b<br />
+Readded the start menu<br />
+A lite theme for the terminal, if that's your thing. You can toggle the theme with "settheme".<br />

View file

Before

Width:  |  Height:  |  Size: 508 KiB

After

Width:  |  Height:  |  Size: 508 KiB

1
apps/about/name Normal file
View file

@ -0,0 +1 @@
About

1
apps/debug/name Normal file
View file

@ -0,0 +1 @@
Debug

View file

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 16 KiB

View file

Before

Width:  |  Height:  |  Size: 569 B

After

Width:  |  Height:  |  Size: 569 B

1
apps/howto/name Normal file
View file

@ -0,0 +1 @@
How to Install Applications

View file

Before

Width:  |  Height:  |  Size: 4.7 KiB

After

Width:  |  Height:  |  Size: 4.7 KiB

View file

Before

Width:  |  Height:  |  Size: 349 B

After

Width:  |  Height:  |  Size: 349 B

1
apps/market/name Normal file
View file

@ -0,0 +1 @@
DremJS Market

View file

@ -0,0 +1,60 @@
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.17/jquery-ui.min.js"></script>
<link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.17/themes/base/jquery-ui.css" rel="stylesheet" type="text/css" />
<style>
body {
font-family: Calibri;
}
.buttonA, .buttonB {
display: inline-block;
}
.buttons {
width: 100%;
left: 0px;
top: 0px;
position: sticky;
background-color: #D3D3D3;
}
</style>
<script type="text/javascript">
$(function() {
var i = 0
while (i <= 1000) {
if (parent.idExists(i)) {
content='<tr><td><p>'+i+'</p></td><td><p>'+parent.idExists(i)+'</p></td><td><button class="sideRight" type="button" onclick="parent.closeApplication('+i+')">Kill</button></td></tr>';
var container=document.getElementById("container");
container.insertAdjacentHTML("beforeend", content);
//console.log(i + "\t\t" + parent.idExists(i));
}
i++;
}
});
function startRefresh() {
$.get("TaskManager.html", function(data) {
$(document.body).html(data);
});
}
$(function() {
setTimeout(startRefresh,1000);
});
</script>
</head>
<body>
<div class="buttons">
<a href="index.php"><button type="button" class="buttonA">Status</button></a>
<button type="button" class="buttonB" disabled>Task Manager</button>
</div>
<table id="container" style="width:100%">
<thead>
<tr>
<th>ID</th>
<th>Process Name</th>
<th></th>
</tr>
</thead>
</table>
</body>
</html>

110
apps/serverstatus/index.php Normal file
View file

@ -0,0 +1,110 @@
<?php
header('Refresh:10');
function displayInfo() {
$systemInfo = '<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.17/jquery-ui.min.js"></script>
<link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.17/themes/base/jquery-ui.css" rel="stylesheet" type="text/css" />
<script type="text/javascript">
$(function() {
var content = \'<center><p>CPU Usage: '.getCpuUsage().'%</p><div id="cpuUsageBar"></div><br /><p>Memory Usage (see docs): '.memory_usage()."KB/".memory_total()."KB".'</p><div id="memoryUsageBar"></div></center>\';
var parent=document.getElementById("container");
parent.insertAdjacentHTML("beforeend", content);
$( "#cpuUsageBar" ).progressbar({
value: '.getCpuUsage().'
});
$( "#memoryUsageBar" ).progressbar({
value: '.round((memory_usage()/memory_total())*100, 2).'
});
});
function startRefresh() {
$.get("index.php", function(data) {
$(document.body).html(data);
});
}
$(function() {
setTimeout(startRefresh,5000);
});
</script>
<style>
body {
font-family: Calibri;
}
.buttonA, .buttonB {
display: inline-block;
}
.buttons {
width: 100%;
top: 0px;
left: 0px;
position: sticky;
background-color: #D3D3D3;
}
</style>
</head>
<body>
<div class="buttons">
<button type="button" class="buttonA" disabled>Status</button>
<a href="TaskManager.html"><button type="button" class="buttonB">Task Manager</button></a>
</div>
<div id="container">
</div>
</body>
</html>';
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();
?>

1
apps/serverstatus/name Normal file
View file

@ -0,0 +1 @@
Server Status

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

1
apps/terminal/name Normal file
View file

@ -0,0 +1 @@
Terminal

Binary file not shown.

View file

@ -0,0 +1,44 @@
<html>
<head>
</head>
<body>
<?php
echo "List of availible widgets:<br />";
$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 "<br /><br />Currently enabled widgets:<br />";
$enabledWidgets = explode("\n", file_get_contents(getenv('DOCUMENT_ROOT')."/enabled_widgets"));
for($i = 0; $i<=sizeof($enabledWidgets)-1; $i++)
echo $enabledWidgets[$i].' ';
echo "<br />";
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.'<br />');
//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";
}
}
?>
<form method="post">
<input type="text" name="widget" class="text" />
<input type="submit" name="add" class="button" value="Add Widget" />
</form>
<a href="index.php"><button type=button>Back</button></a>
</body>
</html>

View file

@ -0,0 +1,34 @@
<html>
<head>
</head>
<body>
<?php
echo "List of availible widgets:<br />";
$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 "<br /><br />Currently enabled widgets:<br />";
$enabledWidgets = explode("\n", file_get_contents(getenv('DOCUMENT_ROOT')."/enabled_widgets"));
for($i = 0; $i<=sizeof($enabledWidgets)-1; $i++)
echo $enabledWidgets[$i].' ';
echo "<br />";
if(array_key_exists('add', $_POST)) {
addWidgets();
} else if(array_key_exists('remove', $_POST)) {
removeWidgets();
}
function addWidgets() {
echo "Add";
}
function removeWidgets() {
echo "Remove";
}
?>
<a href="addwidget.php"><button type=button>Add Widget</button></a>
<a href="removewidget.php"><button type=button>Clear Widget List</button></a>
<p>Changes take effect after restart.</p>
</body>
</html>

View file

@ -0,0 +1 @@
Widgets Settings

View file

@ -0,0 +1,4 @@
<?php
header("Location: index.php");
file_put_contents(getenv('DOCUMENT_ROOT').'/enabled_widgets', '');
?>

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.2 KiB

1
enabled_widgets Executable file
View file

@ -0,0 +1 @@

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

BIN
favicon_old.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

View file

@ -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 @@
</style>
</head>
<body onload="initAgendaWM()">
<p class="cwhite br2">DremJS Version 0.1.5b</p>
<p class="cwhite br2">DremJS Version 0.1.6b</p>
<p class="cwhite br1">&copy; Innovation Inc.</p>
<div class="start">
<button class="startbtn">Start</button>
<button class="startbtn"><img src="logo.png" style="width:24px;height24px;"></button>
<div class="start-content">
<a onclick="openApplication('About', 800, 500, 'about.png')"><p><img src="apps/About/about.png" align="top"> About DremJS</p></a>
<a onclick="openApplication('HowTo', 800, 500, 'howto.png')"><p><img src="apps/HowTo/howto.png" align="top"> How to Install Applications</p></a>
<a onclick="openApplication('Market', 'max', 'max', 'market.png')"><p><img src="apps/Market/market.png" align="top"> DremJS Market</p></a>
<a onclick="openApplication('about', 800, 500, 'about.png')"><p><img src="apps/about/about.png" align="top"> About DremJS</p></a>
<a onclick="openApplication('howto', 800, 500, 'howto.png')"><p><img src="apps/howto/howto.png" align="top"> How to Install Applications</p></a>
<a onclick="openApplication('market', 'max', 'max', 'market.png')"><p><img src="apps/market/market.png" align="top"> DremJS Market</p></a>
<a onclick="openApplication('debug', 700, 450, 'debug.png')"><p><img src="apps/debug/debug.png" align="top"> Report a Bug</p></a>
<a onclick="openApplication('terminal', 700, 450, 'terminal.png')"><p><img src="apps/terminal/terminal.png" align="top" width="16" height="16"> Terminal</p></a>
<a onclick="openApplication('serverstatus', '300', '300', 'serverstatus.png')"><p><img src="apps/serverstatus/serverstatus.png" align="top" style="width:16px;height:16px;"> Server Status</p></a>
<a onclick="openApplication('widgets-settings', -1, -1, 'widgets-settings.png')"><p><img src="apps/widgets-settings/widgets-settings.png" align="top" style="width:16px;height:16px"> Widgets Settings</p></a>
<hr />
<a target="_top" href="shuttingdown.html"><p><img src="shutdown.png" align="top" style="width:16px;height:16px;"> Shutdown DremJS</p>
</div>
@ -136,7 +139,7 @@
<div id="taskbar" class="taskbar">
<div id="taskbarTime" class="taskbarTime">
<!-- Add apps here -->
<div class="cwhite" style="text-align:left" id="txt"></div> <a onclick="openApplication('About', 800, 500, 'about.png')"><img src="apps/About/about.png"> |</a>
<div class="cwhite" style="text-align:left" id="txt"></div> <a onclick="openApplication('about', 800, 500, 'about.png')"><img src="apps/about/about.png"> |</a>
</div>
<div id="taskbarApps" class="taskbarApps">
@ -144,8 +147,5 @@
</div>
</div>
<script src="agenda-wm.js"></script>
<script>
console.log("tomato");
</script>
</body>
</html>

BIN
logo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 508 KiB

View file

@ -9,7 +9,7 @@
<!--<link rel="alternate stylesheet" type="text/css" title="lite" href="css/lite.css">-->
</head>
<body onload="setTheme();">
<body>
<html>
<head>
@ -19,8 +19,21 @@
<link href="https://fonts.googleapis.com/css?family=Inconsolata"
rel="stylesheet" type="text/css" />
</head>
<body>
<body onload="getTheme();">
<script>
function getTheme() {
jQuery.get('terminal/configs/theme.conf', function(data) {
if(data == "1") {
var cssLink = $('link[href*="css/dark.css"]');
cssLink.replaceWith('<link href="css/lite.css" type="text/css" rel="stylesheet">');
} else {
var cssLink = $('link[href*="css/lite.css"]');
cssLink.replaceWith('<link href="css/dark.css" type="text/css" rel="stylesheet">');
}
});
}
</script>
<!--<script> old script
function setTheme() {
if (checkCookie('terminalTheme') == false) {
document.cookie = "terminalTheme=0";
@ -59,7 +72,7 @@
}
return "";
}
</script>
</script>-->
<div id="container">
<output></output>
<div id="input-line" class="input-line">
@ -69,7 +82,7 @@
<!--<script src="http://www.codehelper.io/api/ips/?js"></script>-->
<script src="https://code.jquery.com/jquery-2.1.1.min.js"></script>
<script src="js/terminal.js"></script>
<script src="terminal/terminal.js"></script>
<div class="clock-container">
<svg viewBox="0 0 100 100">
@ -87,7 +100,7 @@
<script src="js/index.js"></script>
<script src="terminal/index.js"></script>

1
terminal/configs/theme.conf Executable file
View file

@ -0,0 +1 @@
0

View file

@ -0,0 +1,78 @@
<?php
//header('Content-type: text/plain');
$inputText = $_REQUEST['inputText'];
$skin = $_REQUEST['skin'];
$output = "";
// Getting some information about the string to figure out how to make the
// speech bubble. This is a terrible way of doing it, but that's a problem for
// future Sam (aka years after I forget about making this when it breaks).
if (strlen($inputText) > 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.=" _________________________________________<br />";
if($wrapTextTwiceFlag == True) {
$textArray = str_split($inputText, 39);
$output.="/ ".$textArray[0]." \<br />";
$counter = 1;
while($counter < sizeof($textArray)-2) {
$output.="| ".$textArray[$counter]." |<br />";
//$output.="Adding line ".$counter." of ".sizeof($textArray)-2."<br /";
$counter++;
}
$output.="\ ".$textArray[sizeof($textArray)-1].str_repeat(' ', 39-strlen($textArray[sizeof($textArray)-1]))." /<br />";
$output.=" -----------------------------------------<br />";
//$output.=$textArray[sizeof($textArray)-1];
} else {
$textArray = str_split($inputText, 39);
$output.="/ ".$textArray[0]." \<br />";
$output.="\ ".$textArray[1].str_repeat(' ', 39-strlen($textArray[1]))." /<br />";
$output.=" -----------------------------------------<br />";
}
} else {
$output.=" _".str_repeat("_", strlen($inputText))."_<br />";
$output.="< ".$inputText." ><br />";
$output.=" -".str_repeat("-", strlen($inputText))."-<br />";
}
if($skin == "tux") {
$output.=" \\ .--.<br />";
$output.=" \\ |_ |<br />";
$output.=" |:_/ |<br />";
$output.=" // \\ \\<br />";
$output.=" (| | )<br />";
$output.=" /'\\_ _/`\\<br />";
$output.=" \\___)=(___/";
/*
\ .--.
\ |_ |
|:_/ |
// \ \
(| | )
/'\_ _/`\
\___)=(___/
*/
} else {
$output.=" \\ ^__^<br />";
$output.=" \\ (oo)\\_______<br />";
$output.=" (__)\\ )\\/\\<br />";
$output.=" ||----w |<br />";
$output.=" || ||";
/*
\ ^__^
\ (oo)\_______
(__)\ )\/\
||----w |
|| ||
*/
}
echo $output;
?>

View file

@ -0,0 +1,10 @@
<?php
$theme = file_get_contents('../configs/theme.conf');
if($theme == "1") {
file_put_contents('../configs/theme.conf', '0');
} else {
file_put_contents('../configs/theme.conf', '1');
}
?>

View file

@ -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 <ca.length; i++) {
var c = ca[i];
while (c.charAt(0) == ' ') {
c = c.substring(1);
}
if (c.indexOf(name) == 0) {
return c.substring(name.length, c.length);
}
}
return "";
}
util.toArray = function(list) {
return Array.prototype.slice.call(list || [], 0);
@ -49,7 +32,7 @@ var Terminal = Terminal || function(cmdLineContainer, outputContainer) {
var output_ = document.querySelector(outputContainer);
cmds = [
'cat', 'clear', 'clock', 'date', 'echo', 'help', 'uname', 'cmd_fm', 'procman', 'insmod', 'rmmod', 'settheme'
'cat', 'clear', 'clock', 'date', 'echo', 'help', 'uname', 'cmd_fm', 'procman', 'insmod', 'rmmod', 'swaptheme', 'cowsay'
];
var fs_ = null;
@ -124,9 +107,12 @@ var Terminal = Terminal || function(cmdLineContainer, outputContainer) {
output_.appendChild(line);
if (this.value && this.value.trim()) {
var args = this.value.split(' ').filter(function(val, i) {
/*var args = this.value.split(' ').filter(function(val, i) {
return val;
});
});*/
var args = [].concat.apply([], this.value.split('"').map(function(v,i){
return i%2 ? v : v.split(' ')
})).filter(Boolean);
var cmd = args[0].toLowerCase();
args = args.splice(1); // Remove cmd from arg list.
}
@ -317,23 +303,27 @@ var Terminal = Terminal || function(cmdLineContainer, outputContainer) {
case 'rmmod':
output('[rmmod] fatal: not implimented. Maybe 0.1.6b?');
break;
case 'settheme':
if (args[0] == 0 || args[0] == "dark") {
document.cookie = "terminalTheme=0";
output('Terminal theme updated to dark mode. Please restart the terminal for changes to take effect.')
} else if (args[0] == 1 || args[0] == "lite") {
document.cookie = "terminalTheme=1";
output('Terminal theme updated to lite mode. Please restart the terminal for changes to take effect.')
} else {
output('Usage:');
output('settheme <theme>');
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] &lt;skin&gt;<br />Availible skins:<br />default\t\ttux<br />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', '<p>' + html + '</p>');
output_.insertAdjacentHTML('beforeEnd', '<p style="white-space:pre;">' + html + '</p>');
}
function sleep(delay) {
@ -416,11 +406,13 @@ var Terminal = Terminal || function(cmdLineContainer, outputContainer) {
//
return {
init: function() {
if(theme == 0) {
output('<img align="left" src="termlogo-dark.png" width="100" height="100" style="padding: 0px 10px 20px 0px"><h2 style="letter-spacing: 4px">DremJS Terminal</h2><p>' + new Date() + '</p><p>Enter "help" for more information.</p>');
} else {
output('<img align="left" src="termlogo-lite.png" width="100" height="100" style="padding: 0px 10px 20px 0px"><h2 style="letter-spacing: 4px">DremJS Terminal</h2><p>' + new Date() + '</p><p>Enter "help" for more information.</p>');
}
jQuery.get('terminal/configs/theme.conf', function(data) {
if(data == "1") {
output('<img align="left" src="termlogo-lite.png" width="100" height="100" style="padding: 0px 10px 20px 0px"><h2 style="letter-spacing: 4px">DremJS Terminal</h2><p>' + new Date() + '</p><p>Enter "help" for more information.</p>');
} else {
output('<img align="left" src="termlogo-dark.png" width="100" height="100" style="padding: 0px 10px 20px 0px"><h2 style="letter-spacing: 4px">DremJS Terminal</h2><p>' + new Date() + '</p><p>Enter "help" for more information.</p>');
}
});
},
output: output
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 508 KiB

After

Width:  |  Height:  |  Size: 402 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 508 KiB

After

Width:  |  Height:  |  Size: 394 KiB

92
widgets/clock/index.html Normal file
View file

@ -0,0 +1,92 @@
<!DOCTYPE html>
<html>
<body>
<center><canvas id="canvas" width="255px" height="255px" style="background-color:#FFF">
</canvas></center>
<script>
var canvas = document.getElementById("canvas");
var ctx = canvas.getContext("2d");
var radius = canvas.height / 2;
ctx.translate(radius, radius);
radius = radius * 0.90
setInterval(drawClock, 1000);
function drawClock() {
drawFace(ctx, radius);
drawNumbers(ctx, radius);
drawTime(ctx, radius);
}
function drawFace(ctx, radius) {
var grad;
ctx.beginPath();
ctx.arc(0, 0, radius, 0, 2*Math.PI);
ctx.fillStyle = 'white';
ctx.fill();
grad = ctx.createRadialGradient(0,0,radius*0.95, 0,0,radius*1.05);
grad.addColorStop(0, '#333');
grad.addColorStop(0.5, 'white');
grad.addColorStop(1, '#333');
ctx.strokeStyle = grad;
ctx.lineWidth = radius*0.1;
ctx.stroke();
ctx.beginPath();
ctx.arc(0, 0, radius*0.1, 0, 2*Math.PI);
ctx.fillStyle = '#333';
ctx.fill();
}
function drawNumbers(ctx, radius) {
var ang;
var num;
ctx.font = radius*0.15 + "px arial";
ctx.textBaseline="middle";
ctx.textAlign="center";
for(num = 1; num < 13; num++){
ang = num * Math.PI / 6;
ctx.rotate(ang);
ctx.translate(0, -radius*0.85);
ctx.rotate(-ang);
ctx.fillText(num.toString(), 0, 0);
ctx.rotate(ang);
ctx.translate(0, radius*0.85);
ctx.rotate(-ang);
}
}
function drawTime(ctx, radius){
var now = new Date();
var hour = now.getHours();
var minute = now.getMinutes();
var second = now.getSeconds();
//hour
hour=hour%12;
hour=(hour*Math.PI/6)+
(minute*Math.PI/(6*60))+
(second*Math.PI/(360*60));
drawHand(ctx, hour, radius*0.5, radius*0.07);
//minute
minute=(minute*Math.PI/30)+(second*Math.PI/(30*60));
drawHand(ctx, minute, radius*0.8, radius*0.07);
// second
second=(second*Math.PI/30);
drawHand(ctx, second, radius*0.9, radius*0.02);
}
function drawHand(ctx, pos, length, width) {
ctx.beginPath();
ctx.lineWidth = width;
ctx.lineCap = "round";
ctx.moveTo(0,0);
ctx.rotate(pos);
ctx.lineTo(0, -length);
ctx.stroke();
ctx.rotate(-pos);
}
</script>
</body>
</html>

1
widgets/clock/name Normal file
View file

@ -0,0 +1 @@
Clock

View file

@ -0,0 +1,110 @@
<?php
header('Refresh:10');
function displayInfo() {
$systemInfo = '<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.17/jquery-ui.min.js"></script>
<link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.17/themes/base/jquery-ui.css" rel="stylesheet" type="text/css" />
<script type="text/javascript">
$(function() {
var content = \'<center><p>CPU Usage: '.getCpuUsage().'%</p><div id="cpuUsageBar"></div><br /><p>Memory Usage (see docs): '.memory_usage()."KB/".memory_total()."KB".'</p><div id="memoryUsageBar"></div></center>\';
var parent=document.getElementById("container");
parent.insertAdjacentHTML("beforeend", content);
$( "#cpuUsageBar" ).progressbar({
value: '.getCpuUsage().'
});
$( "#memoryUsageBar" ).progressbar({
value: '.round((memory_usage()/memory_total())*100, 2).'
});
});
function startRefresh() {
$.get("index.php", function(data) {
$(document.body).html(data);
});
}
$(function() {
setTimeout(startRefresh,5000);
});
</script>
<style>
body {
font-family: Calibri;
}
.buttonA, .buttonB {
display: inline-block;
}
.buttons {
width: 100%;
top: 0px;
left: 0px;
position: sticky;
background-color: #D3D3D3;
}
</style>
</head>
<body>
<!--<div class="buttons">
<button type="button" class="buttonA" disabled>Status</button>
<a href="TaskManager.html"><button type="button" class="buttonB">Task Manager</button></a>
</div>-->
<div id="container">
</div>
</body>
</html>';
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();
?>

View file

@ -0,0 +1 @@
Server Status