-
Notifications
You must be signed in to change notification settings - Fork 0
/
eve.xhtml
295 lines (265 loc) · 9.1 KB
/
eve.xhtml
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
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Exploration Log</title>
<script type="text/javascript"><![CDATA[
var log_form, log_password, log_system,
log_input, log_output, log_current;
function removeChildren(r) {
var child;
while ((child = r.firstChild))
r.removeChild(child);
}
function logSetOutput(obj) {
log_output.parentNode.replaceChild(obj, log_output);
log_output = obj;
obj.setAttribute("id", "log-output");
}
function logSetOutputText(str) {
var p = document.createElement("p");
p.appendChild(document.createTextNode(str));
logSetOutput(p);
}
function pad(n){return n<10 ? '0'+n : n}
function formatTime(time) {
return time.getFullYear() +
"-" + pad(time.getMonth()+1) +
"-" + pad(time.getDate()) +
" " + pad(time.getHours()) +
":" + pad(time.getMinutes());
}
function formatDate(time) {
return pad(time.getYear()-100) +
"-" + pad(time.getMonth()+1) +
"-" + pad(time.getDate());
}
function getLastDowntime() {
var t = new Date();
if (t.getUTCHours() < 11)
t.setUTCDate(t.getUTCDate() - 1);
t.setUTCHours(11);
return t;
}
function logFormatOutput(signatures) {
if (signatures.length == 0) {
logSetOutputText("no signatures");
} else {
var div = document.createElement("div");
var btn = document.createElement("button");
btn.appendChild(document.createTextNode("Clear results"));
btn.addEventListener("click", function(e) {
logSetOutput(document.createElement("p"));
});
div.appendChild(btn);
var table = document.createElement("table");
table.setAttribute("class", "siglist");
var tr = document.createElement("tr");
["Time", "ID", "Type", "Name"].forEach(function(str) {
var th = document.createElement("th");
th.appendChild(document.createTextNode(str));
tr.appendChild(th);
});
table.appendChild(tr);
var downtime = getLastDowntime();
for (var i = 0; i < signatures.length; ++i) {
var item = signatures[i];
var time = new Date(item.time * 1000);
item.time = formatTime(time);
tr = document.createElement("tr");
var cl = []
if (time > downtime)
cl.push("sig-recent");
if (item.updated)
cl.push("sig-updated");
if (cl.length)
tr.setAttribute("class", cl.join(" "));
var td;
["time", "id", "type"].forEach(function(str) {
td = document.createElement("td");
td.appendChild(document.createTextNode(item[str]));
td.setAttribute("class", "sig-" + str);
tr.appendChild(td);
});
td = document.createElement("td");
var name = item["name"];
if (name && name.length > 0) {
var link = document.createElement("a");
link.appendChild(document.createTextNode(name));
link.setAttribute("href",
"https://wiki.goonfleet.com/"+name.replace(/ /g, "_"));
td.appendChild(link);
} else {
td.appendChild(document.createTextNode(""));
}
td.setAttribute("class", "sig-name");
tr.appendChild(td);
table.appendChild(tr);
}
div.appendChild(table);
logSetOutput(div);
}
}
function onLogResponse(data) {
var sigs;
try {
sigs = JSON.parse(data);
} catch (e) {
logSetOutputText("error: bad json data: " + data);
return;
}
logFormatOutput(sigs);
log_input.value = "";
}
function onLogSubmit(e) {
e.preventDefault();
logSetOutputText("Submitting...");
if (log_current)
log_current.abort();
var r = log_current = new XMLHttpRequest();
r.open("POST", "http://londeroth.org/~ben/eve.cgi");
r.onreadystatechange = function(e) {
if (r.readyState != 4)
return;
if (r.status == 200) {
onLogResponse(r.responseText);
} else {
var pre = document.createElement("pre");
pre.appendChild(document.createTextNode(
"Error: " + r.statusText + ": " + r.responseText));
logSetOutput(pre);
}
}
var post = "password=" + encodeURIComponent(log_password.value) +
"&system=" + encodeURIComponent(log_system.value) +
"&input=" + encodeURIComponent(log_input.value);
r.send(post)
}
function go() {
if (window.CCPEVE) {
// would limit to /~ben/, but looks like the igb chokes on ~
CCPEVE.requestTrust("http://londeroth.org/");
}
var noscript = document.getElementById("noscript");
noscript.parentNode.removeChild(noscript);
log_form = document.getElementById("log-form");
log_password = document.getElementById("log-password");
log_system = document.getElementById("log-system");
log_input = document.getElementById("log-input");
log_output = document.getElementById("log-output");
log_form.addEventListener("submit", onLogSubmit);
var date = document.getElementById("date");
date.appendChild(document.createTextNode(formatDate(new Date())));
}
]]></script>
<style type="text/css"><![CDATA[
body, html {
color: #989898;
background: #222;
font-family: "EVE Sans Neue",sans-serif;
font-size: 10pt;
}
::selection {
background: #adadad ! important;
}
.section {
background-color: black;
border: 1px solid #636363;
margin: 0.3em;
padding: 0.3em;
color: #bfbfbf;
}
h1 {
margin: 0;
font-size: 10pt;
font-weight: normal;
}
.section h2 {
float: right;
padding-left: 0.3em;
padding-right: 0.3em;
margin-top: 0;
font-size: 10pt;
font-weight: normal;
}
input, textarea {
font-family: "EVE Sans Neue",sans-serif;
font-size: 10pt;
background-color: #222;
color: #bfbfbf;
border: 1px solid black;
}
textarea {
font-family: monospace;
width: 100%;
}
.textarea-container {
padding-left: 8px;
padding-right: 16px;
}
button {
font-family: "EVE Sans Neue",sans-serif;
font-size: 10pt;
color: #9a9a9a;
background-image: -moz-linear-gradient(to bottom, black, #151515);
background: -webkit-gradient(linear, left top, left bottom, from(black), to(#151515));
border: 1px solid black;
border-bottom: 1px solid #353535;
}
button:hover {
border: 1px solid #999;
}
button:active {
border: 1px solid white;
}
form {
display: inline;
}
table.siglist {
white-space: nowrap;
border-spacing: 0;
border-collapse: collapse;
}
table.siglist .sig-recent td, table.siglist .sig-recent td a {
color: #65bf65;
}
table.siglist .sig-updated .sig-id {
font-weight: bold;
}
table.siglist th {
text-align: left;
font-weight: normal
}
table.siglist td, table.siglist th {
background-color: #222;
border-top: 1px solid #595959;
border-bottom: 1px solid #595959;
border-left: 1px solid #3e3e3e;
border-right: 1px solid #3e3e3e;
padding: 2px 6px;
}
table.siglist .sig-id {
font-family: monospace;
}
]]></style>
</head>
<body onload="go()">
<h1>Exploration logging tool</h1>
<p id="noscript">JavaScript is recommended.</p>
<div class="section">
<form id="log-form" method="post" action="eve.cgi">
<p>
<input type="password" size="12" placeholder="Password"
name="password" id="log-password" />
<input type="text" size="12" placeholder="Solar system"
name="system" id="log-system" />
<button>Log</button>
<span id="date"/>
</p>
<p class="textarea-container">
<textarea rows="3" name="input" id="log-input" />
</p>
</form>
<p id="log-output" />
</div>
</body>
</html>