-
Notifications
You must be signed in to change notification settings - Fork 0
/
communications.html
197 lines (185 loc) · 7.77 KB
/
communications.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
<!doctype html>
<html>
<head>
<meta charset="utf-8"/>
<title>COMMUNICATIONS</title>
<!--
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height, target-densitydpi=device-dpi" />
-->
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="manifest" href="manifest.json">
<!--
<link rel="stylesheet" href="/normalize.css" type="text/css">
<link rel="stylesheet" href="/style.css" type="text/css">
-->
<link href="./blueprint.css" rel="stylesheet" />
<link href="./snis-blueprint.css" rel="stylesheet" />
<link href="./snis-basic.css" type="text/css" rel="stylesheet" />
<link href="./snis-radar.css" type="text/css" rel="stylesheet" />
</head>
<body>
<div class="panel">
<h1 onClick="toggleFullScreen();">COMMUNICATIONS</h1>
</div>
<div id="main" bp="grid">
<div class="panel" bp="3">
<button id="btn_antenna_port" class="XXfoob" data-cmd="ANTENNA PORT">ANTENNA <br/>◂ PORT</button>
</div>
<div class="panel" bp="6">
<div bp="grid">
<div bp="6 offset-4 text-center">
<button id="btn_antenna_up" class="XXXbar" data-cmd="ANTENNA UP">ANTENNA ▴ UP</button>
<button id="btn_antenna_down" data-cmd="ANTENNA DOWN">ANTENNA ▾ DOWN</button>
</div>
</div>
<div bp="grid margin-top--lg">
<div bp="6 offset-4">
GAIN<input type="range" class="horizontal" />
<fieldset name="throttle">
<legend>ENCRYPTION CONTROL</legend>
<button id="btn_encrypt" data-cmd="ENCRYPT">ENCRYPT</button>
<button id="btn_arm" class="secondary" XXdata-cmd="SAY CRYPTOGRAPHIC SYSTEMS ENABLED">DISABLE ◬ CRYPTO SYSTEMS</button>
<button id="btn_decrypt" data-cmd="DECRYPT">DECRYPT</button>
</fieldset>
<button id="btn_red_alert" class="secondary" data-cmd="RED ALERT">◬ RED ALERT ◬</button>
</div>
</div>
</div>
<div class="panel" bp="3 text-right">
<button id="btn_antenna_starboard" data-cmd="ANTENNA STARBOARD">ANTENNA STARBOARD ▸</button>
</div>
</div>
<div bp="grid">
<div bp="4">
<!--
<div><button id="btn_docking_magnets" data-cmd="DOCKING MAGNETS" class="action">DOCKING MAGNETS</button></div>
<div> STATUS: NOMINAL </div>
<div><a id="btn_main_menu" class="buttonize" href="menu.html">MAIN MENU</a></div>
-->
</div>
<div class="panel" bp="4">
<!-- perhaps this should be a partialpage/client-injection (ajax'd into dom), or SSI, "navigation.nonsense.html_fragment" file ...-->
<!-- BEGIN CHUNK -->
<table>
<tr><th>Doppler Comp.</th><th>Delta-a</th><th>Delta-v</th></tr>
<tr><td>01</td><td>03</td><td>05</td></tr>
<tr><td>02</td><td>04</td><td>06</td></tr>
</table>
<!-- END CHUNK -->
</div>
<div class="radar" bp="4 text-right float-center">
<div class="waveguide"></div>
</div>
</div>
</body>
<script>
function toggleFullScreen() {
if (!document.fullscreenElement) {
document.documentElement.requestFullscreen();
} else {
if (document.exitFullscreen) {
document.exitFullscreen();
}
}
}
function command(text) {
var data = { command: text };
//sanitize data?
console.info("Transmitting command: "+text);
//fetch('/SHIP/STATIONNAME/TARGETNOUN/VERB?parametername=value', {
fetch("/SHIP/COMMUNICATIONS/" + text.toUpperCase().replace(" ","/"), {
method: 'POST', // or 'PUT'
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(data),
})
.then(response => response.json())
.then(data => {
console.log('Success:', data);
soundACK.play();
})
.catch((error) => {
console.error('Error:', error);
soundNACK.play();
});
}
document.addEventListener('click', function (event) {
// Don't follow the link (unless back to menu...)
if (event.target.id == "btn_main_menu") {
console.log("Exception: main menu button should navigate as normal...");
} else {
event.preventDefault();
if (event.target.dataset.cmd) {
console.info("FYI: this element had a cmd attribute: " + event.target.dataset.cmd);
//todo: mild validation (alphanumeric+space?)
command(event.target.dataset.cmd);
} else {
console.error("ERROR: element did not contain recognized command data. Add data-cmd attribute in correct format to the control element tag.");
}
}
// Log the clicked element in the console
console.log(event.target.tagName);
}, false);
</script>
<script src="./howler.js"></script>
<script>
var soundACK = new Howl({ src: ['./sounds/tactinput_acknowledge.ogg', './sounds/tactinput_acknowledge.m4a', './sounds/tactinput_acknowledge.webm'] });
var soundNACK = new Howl({ src: ['./sounds/tactinput_neg_acknowledge.ogg', './sounds/tactinput_neg_acknowledge.m4a', './sounds/tactinput_neg_acknowledge.webm'] });
try {
toggleFullScreen();
} catch (error) {
console.warn("just warning, kinda expected this..." + error);
}
function faux_mutation() {
var row = Math.floor(Math.random() * 2) + 2;
var col = Math.floor(Math.random() * 3) + 1;
var dd = document.querySelector("body > div:nth-child(3) > div.panel > table > tbody > tr:nth-child("+row+") > td:nth-child("+col+")");
dd.innerText = (Math.floor(dd.innerText) * Math.floor(Math.random() * 99) ) % 999 + (Math.floor(Math.random() * 100)/10);
//quasi-recursion
var tmr = setTimeout(function() {
faux_mutation();
},1000*Math.floor(Math.random() * 12));
}
function faux_highlight() {
var row = Math.floor(Math.random() * 2) + 2;
var col = Math.floor(Math.random() * 3) + 1;
var dd = document.querySelector("body > div:nth-child(3) > div.panel > table > tbody > tr:nth-child("+row+") > td:nth-child("+col+")");
dd.classList.toggle("highlight");
//TODO: probably need unique cartesian grid-id action here....
var tmr1= setTimeout(function(ddd) { ddd.classList.toggle("highlight"); }, 600, dd);
var tmr2 = setTimeout(function(ddd) { ddd.classList.toggle("highlight"); }, 1300, dd);
var tmr3 = setTimeout(function(ddd) { ddd.classList.toggle("highlight"); }, 2000, dd);
var tmr2 = setTimeout(function(ddd) { ddd.classList.toggle("highlight"); }, 2600, dd);
var tmr3 = setTimeout(function(ddd) { ddd.classList.toggle("highlight"); }, 3500, dd);
//TODO: sometimes, do a contagion-style lightup of the whole row instead.
//quasi-recursion
var blinkyDelay = 1000*Math.floor(Math.abs(Math.random() * 90 - Math.random() * 10));
console.info((blinkyDelay/1000) + "s until next blinky fauxh highlight.");
var tmr = setTimeout(function() {
faux_highlight();
}, blinkyDelay);
}
faux_mutation();
faux_highlight();
document.addEventListener("DOMContentLoaded", function() {
// code...
document.querySelector("#btn_fire_phasers").setAttribute("disabled","true");
document.querySelector("#btn_fire_torpedoes").setAttribute("disabled","true");
//styling/classes too?
});
document.getElementById("btn_arm").addEventListener("click", function(event) {
if (event.target.innerText.startsWith("EN")){
document.querySelector("#btn_encrypt").removeAttribute("disabled");
document.querySelector("#btn_decrypt").removeAttribute("disabled");
event.target.innerText = event.target.innerText.replace("EN","DIS");
} else {
document.querySelector("#btn_encrypt").setAttribute("disabled","true");
document.querySelector("#btn_decrypt").setAttribute("disabled","true");
event.target.innerText = event.target.innerText.replace("DIS","EN");
}
});
</script>
</html>