Functional prototype

This commit is contained in:
Neale Pickett 2016-04-04 03:12:48 +00:00
parent ff1f84f1a5
commit f0ddfedf3e
9 changed files with 161 additions and 24 deletions

View File

@ -8,12 +8,25 @@
<link rel="icon" href="res/luna-moth.png">
<script src="res/terminal.js"></script>
<script src="res/moth.js"></script>
<script src="res/overview.js"></script>
<script src="res/messages.js"></script>
<script src="res/puzzles.js"></script>
<script src="res/main.js"></script>
<title>MOTH Dashboard</title>
</head>
<body>
<div id="output">
<div id="overview" class="terminal">
🎃
</div>
<div id="messages" class="terminal">
💾
</div>
<div id="puzzles" class="terminal">
🌮
</div>
<div id="main" class="terminal">
🎩
</div>
</body>
</html>

BIN
www/res/brown-lines.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 236 KiB

40
www/res/main.js Normal file
View File

@ -0,0 +1,40 @@
var main_proc;
function Main(element) {
console.log(element);
var term = new Terminal(element);
this.start = function() {
console.log(element);
term.clear();
term.par("Main terminal");
term.par("Main terminal");
term.par("Main terminal");
term.par("Main terminal");
term.par("Main terminal");
term.par("Main terminal");
term.par("Main terminal");
term.par("Main terminal");
term.par("Main terminal");
term.par("Main terminal");
term.par("Main terminal");
term.par("Main terminal");
term.par("Main terminal");
term.par("Main terminal");
term.par("Main terminal");
term.par("Main terminal");
term.par("Main terminal");
term.par("Main terminal");
term.par("Main terminal");
term.par("Main terminal");
term.par("Main main main main main main main main main main main main main main main main main main main main main main main main main main main main main main main main main main main main main main main main main main main main main main main main main main main main main main main main main main main main main main main main main main main main main main main main main main main main main main main main main main terminal");
}
}
function main_start() {
main_proc = new Main(document.getElementById("main"));
setTimeout(main_proc.start, 2500);
}
window.addEventListener("load", main_start);

18
www/res/messages.js Normal file
View File

@ -0,0 +1,18 @@
var messages_proc;
function Messages(element) {
var term = new Terminal(element);
this.start = function() {
term.clear();
term.par("Messages terminal");
}
}
function messages_start() {
messages_proc = new Messages(document.getElementById("messages"));
setTimeout(messages_proc.start, 500);
}
window.addEventListener("load", messages_start);

View File

@ -1,12 +0,0 @@
// Moth dashboard
// requires: terminal.js
function start() {
var t = new Terminal(document.getElementById("output"));
t.par("This is a paragraph, bitches!");
t.pre("This is pre");
t.par("Another par");
}
window.addEventListener("load", start);

18
www/res/overview.js Normal file
View File

@ -0,0 +1,18 @@
var overview_proc;
function Overview(element) {
var term = new Terminal(element);
this.start = function() {
term.clear();
term.par("Overview terminal");
}
}
function overview_start() {
overview_proc = new Overview(document.getElementById("overview"));
setTimeout(overview_proc.start, 4000);
}
window.addEventListener("load", overview_start);

18
www/res/puzzles.js Normal file
View File

@ -0,0 +1,18 @@
var puzzles_proc;
function Puzzles(element) {
var term = new Terminal(element);
this.start = function() {
term.clear();
term.par("Puzzles terminal");
}
}
function puzzles_start() {
puzzles_proc = new Puzzles(document.getElementById("puzzles"));
setTimeout(puzzles_proc.start, 3000);
}
window.addEventListener("load", puzzles_start);

View File

@ -1 +1,39 @@
html {
background: rgba(61, 50, 44, 0) url(brown-lines.jpg) no-repeat center center fixed;
background-size: cover;
color: #ccb;
height: 100%;
}
body {
margin: 0;
height: 100%
}
.terminal {
background: rgba(80, 70, 60, 0.9);
display: inline-block;
margin: 1%;
border: solid black 0.2em;
border-radius: 1em 0.25em 1em 1em;
overflow: auto;
}
.terminal p {
padding: 0.25em 0.5em;
}
#overview, #messages {
width: 47%;
height: 20%;
}
#puzzles {
width: 24%;
height: 70%;
}
#main {
width: 70%;
height: 70%;
}

View File

@ -1,22 +1,19 @@
function tx(element, text, bps) {
var drawTimer;
var sp = false;
var displayed = "";
function draw() {
c = text[0];
if ((c == " ") || (c == "\n")) {
sp = true;
c = " ";
} else if (sp) {
c = " " + c;
sp = false;
}
element.textContent += c;
displayed += c;
element.textContent = displayed;
text = text.substr(1);
if (text == "") {
if (text.length == 0) {
clearInterval(drawTimer);
return;
}
if (element.parentNode.lastChild == element) {
element.scrollIntoView();
}
}
// N81 uses 1 stop bit, and 1 parity bit.
@ -40,11 +37,18 @@ function Terminal(target, bps) {
target.appendChild(out);
tx(out, next[1], bps);
console.log(outq.length);
if (outq.length == 0) {
clearInterval(outTimer);
}
}
this.clear = function() {
while (target.firstChild) {
target.removeChild(target.firstChild);
}
}
this.enqueue = function(tag, txt) {
outq.push([tag, txt]);
if (! outTimer) {