-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
270 lines (231 loc) · 13.2 KB
/
index.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
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
<!DOCTYPE html>
<html>
<head>
<link rel="icon" href="data:image/svg+xml,%3C%3Fxml version='1.0' encoding='UTF-8' standalone='no'%3F%3E%3C!-- Created with Inkscape (http://www.inkscape.org/) --%3E%3Csvg xmlns:dc='http://purl.org/dc/elements/1.1/' xmlns:cc='http://creativecommons.org/ns%23' xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns%23' xmlns:svg='http://www.w3.org/2000/svg' xmlns='http://www.w3.org/2000/svg' xmlns:sodipodi='http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd' xmlns:inkscape='http://www.inkscape.org/namespaces/inkscape' width='22.624374mm' height='19.99967mm' viewBox='0 0 22.624372 19.99967' version='1.1' id='svg8' inkscape:version='0.92.5 (2060ec1f9f, 2020-04-08)' sodipodi:docname='favicon.svg'%3E%3Cdefs id='defs2' /%3E%3Csodipodi:namedview id='base' pagecolor='%23ffffff' bordercolor='%23666666' borderopacity='1.0' inkscape:pageopacity='0.0' inkscape:pageshadow='2' inkscape:zoom='1.0557596' inkscape:cx='-9.856362' inkscape:cy='-23.299544' inkscape:document-units='mm' inkscape:current-layer='layer1' showgrid='false' inkscape:window-width='1848' inkscape:window-height='1016' inkscape:window-x='72' inkscape:window-y='27' inkscape:window-maximized='1' inkscape:snap-global='false' inkscape:snap-bbox='true' inkscape:bbox-paths='true' inkscape:snap-bbox-edge-midpoints='true' inkscape:snap-bbox-midpoints='true' inkscape:bbox-nodes='true' inkscape:object-paths='true' inkscape:snap-intersection-paths='true' inkscape:snap-smooth-nodes='true' inkscape:snap-midpoints='true' inkscape:snap-object-midpoints='true' inkscape:snap-center='true' inkscape:snap-text-baseline='true' inkscape:snap-page='true' /%3E%3Cmetadata id='metadata5'%3E%3Crdf:RDF%3E%3Ccc:Work rdf:about=''%3E%3Cdc:format%3Eimage/svg+xml%3C/dc:format%3E%3Cdc:type rdf:resource='http://purl.org/dc/dcmitype/StillImage' /%3E%3Cdc:title /%3E%3C/cc:Work%3E%3C/rdf:RDF%3E%3C/metadata%3E%3Cg inkscape:label='Capa 1' inkscape:groupmode='layer' id='layer1' transform='translate(-65.182096,-265.7626)'%3E%3Cg id='g1127' transform='translate(-0.66138018,47.491646)'%3E%3Cpath style='opacity:1;fill:%23666666;fill-opacity:1;stroke:none;stroke-width:0.0702962;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1' d='m 76.259417,230.02522 c -0.268204,0.5221 -0.06231,1.16277 0.459817,1.43096 0.383231,0.19661 0.847224,0.14258 1.17495,-0.13691 0.618165,0.30249 0.563548,0.58581 0.524641,0.82564 -0.03889,0.23981 -0.107021,0.46852 -0.02515,1.03061 0.08184,0.56211 2.279661,2.23631 2.528176,2.41976 0.248494,0.18344 0.716738,-0.0131 0.31111,-0.41704 -0.405583,-0.4039 -2.002734,-1.52457 -2.157449,-1.8643 -0.154724,-0.33973 0.0862,-0.47847 0.291265,-0.37311 0.205142,0.10535 6.791403,4.92398 7.152629,5.16841 0.489623,0.33134 0.760222,-0.40957 0.452586,-0.63873 0,0 -4.320887,-2.87949 -3.936943,-3.57839 0.384188,-0.69875 4.850797,1.50871 4.850797,1.50871 0.313544,0.14971 0.893537,-0.4697 0.374257,-0.72853 -0.519277,-0.25881 -7.868904,-3.42924 -8.07165,-3.52478 -0.202765,-0.0955 -0.131015,-0.41434 0.121957,-0.38786 0.361164,0.0378 2.639583,0.59383 2.90835,0.68958 0.268777,0.0957 0.784417,-0.16459 0.245157,-0.47713 -0.539277,-0.3125 -3.32994,-0.82638 -3.566649,-0.81063 -0.23671,0.0157 -0.461706,0.13296 -0.673077,0.37757 -0.21139,0.2446 -0.476284,0.19116 -0.956733,-0.0245 0.0014,-0.39968 -0.221509,-0.76637 -0.576977,-0.94906 -0.52215,-0.26832 -1.162942,-0.0625 -1.431168,0.4597 z' id='use1116' inkscape:connector-curvature='0' sodipodi:nodetypes='ccczzzzzzsccczzszzzzcccc' inkscape:transform-center-x='-5.0971913' inkscape:transform-center-y='3.2857771' /%3E%3Cpath inkscape:transform-center-y='3.3261128' inkscape:transform-center-x='5.1462801' sodipodi:nodetypes='ccczzzzzzsccczzszzzzcccc' inkscape:connector-curvature='0' id='use1118' d='m 78.097473,229.91983 c -0.328062,-0.48672 -0.988605,-0.61528 -1.475338,-0.28719 -0.357033,0.24093 -0.533437,0.67346 -0.446605,1.09535 -0.563087,0.39568 -0.784964,0.21121 -0.9763,0.0615 -0.191323,-0.14971 -0.358838,-0.31968 -0.890736,-0.51901 -0.531912,-0.19935 -3.058419,0.91873 -3.338962,1.04798 -0.280533,0.12924 -0.334129,0.63423 0.215331,0.47366 0.549402,-0.16055 2.301354,-1.01934 2.673568,-0.99106 0.372239,0.0282 0.377595,0.30625 0.186418,0.43508 -0.191211,0.12891 -7.588568,3.57523 -7.976903,3.77382 -0.526366,0.26916 -0.0078,0.8635 0.341327,0.7045 0,0 4.606177,-2.39681 5.033308,-1.72344 0.426883,0.67352 -3.660828,3.52205 -3.660828,3.52205 -0.282345,0.20249 -0.01939,1.00928 0.457761,0.67918 0.477125,-0.33012 6.798677,-5.23997 6.98015,-5.37152 0.181459,-0.13157 0.42616,0.085 0.280981,0.29387 -0.207276,0.29818 -1.793078,2.02607 -2.00656,2.21536 -0.213481,0.18929 -0.234022,0.76657 0.299774,0.44484 0.533814,-0.32174 2.329689,-2.51872 2.430032,-2.73368 0.100351,-0.21497 0.106184,-0.46859 -0.0062,-0.77172 -0.112296,-0.30314 0.0622,-0.50943 0.482826,-0.82633 0.349467,0.19393 0.7782,0.17545 1.109648,-0.0478 0.486858,-0.32805 0.615535,-0.98867 0.287404,-1.47546 z' style='opacity:1;fill:%23666666;fill-opacity:1;stroke:none;stroke-width:0.0702962;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1' /%3E%3Cpath inkscape:transform-center-y='-5.614549' inkscape:transform-center-x='-0.0082634955' sodipodi:nodetypes='ccczzzzzzsccczzszzzzcccc' inkscape:connector-curvature='0' id='path982-2' d='m 77.234937,231.56871 c 0.586684,-0.018 1.04766,-0.50826 1.029634,-1.09496 -0.01344,-0.43051 -0.285287,-0.81038 -0.688494,-0.96188 -0.03449,-0.68735 0.239877,-0.77668 0.468568,-0.85871 0.228691,-0.082 0.461779,-0.13311 0.91403,-0.4768 0.452252,-0.34371 0.853577,-3.07724 0.893825,-3.38349 0.04025,-0.30624 -0.358387,-0.62084 -0.51552,-0.0704 -0.157133,0.5504 -0.364789,2.49042 -0.587186,2.79024 -0.222396,0.29982 -0.460414,0.15614 -0.467473,-0.0743 -0.0071,-0.2305 1.021799,-8.32614 1.060869,-8.76054 0.05296,-0.58882 -0.726356,-0.46702 -0.777992,-0.0869 0,0 -0.428448,5.17474 -1.22586,5.17703 -0.797412,0.002 -1.027556,-4.97499 -1.027556,-4.97499 -0.02075,-0.34684 -0.84349,-0.55458 -0.818657,0.0251 0.02486,0.57966 0.807718,8.54558 0.822238,8.76924 0.01455,0.22367 -0.29917,0.31517 -0.398431,0.081 -0.141731,-0.33434 -0.757909,-2.59723 -0.804207,-2.87876 -0.0463,-0.28154 -0.523716,-0.60673 -0.536169,0.0164 -0.01246,0.62315 0.888546,3.31389 1.016891,3.5134 0.128346,0.19952 0.339802,0.33969 0.65616,0.40625 0.316357,0.0666 0.397806,0.32426 0.441609,0.84907 -0.350435,0.1922 -0.563413,0.56476 -0.551235,0.96424 0.01792,0.58679 0.50818,1.0479 1.094959,1.02988 z' style='opacity:1;fill:%23666666;fill-opacity:1;stroke:none;stroke-width:0.0702962;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1' /%3E%3C/g%3E%3C/g%3E%3C/svg%3E">
<meta charset="utf-8">
<meta name="language" content="english">
<meta http-equiv="content-type" content="text/html">
<meta name="author" content="Lumorti">
<meta name="designer" content="Lumorti">
<meta name="publisher" content="Lumorti">
<title>the hive mind</title>
<meta name="description" content="Speak to the hive mind">
<meta name="keywords" content="hive, mind, information, open, source">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
</head>
<style>
body {
background-color: #f1f1f1;
font-family: Arial, sans-serif;
}
#centered {
position: absolute;
left: 50%;
top: 50%;
width: 75%;
max-width: 600px;
-webkit-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
text-align: center;
}
#mainTitle {
margin-bottom: 3%;
width: 70%;
}
#mainInput {
width: 100%;
padding: 10px;
border-radius: 5px;
font-size: 1.3em;
box-sizing: border-box;
text-align: center;
}
#mainOutput {
margin-top: 1.2em;
margin-bottom: 1.3em;
margin-left: 5%;
width: 90%;
text-align: center;
font-size: 1.2em;
overflow-wrap: break-word;
}
#editHelp {
margin-bottom: 0.1em;
width: 100%;
font-size: 1.2em;
}
button {
font-size: 1.1em;
display: inline-flex;
align-items: center;
padding-left: 0.9em;
padding-right: 0.8em;
}
#submitButton {
margin-top: 0.8em;
margin-left: 1.5em;
}
#editBox {
width: 100%;
font-size: 1.2em;
box-sizing: border-box;
margin-top: 1.2em;
margin-bottom: 0.2em;
text-align: center;
font-size: 1.2em;
font-family: Arial, sans-serif;
resize: vertical;
}
#errorText {
color: red;
font-family: Arial, sans-serif;
display: none;
width: 100%;
}
#editDiv {
display: none;
}
#editButton {
display: none;
}
</style>
<script>
// Global DOM elements
var mainInput = null;
var mainOutput = null;
var editBox = null;
var editButton = null;
var editDiv = null;
var responseDiv = null;
var editHelp = null;
var errorText = null;
// Keep track of whether the last response was a default one
var wasDefault = false;
var question = "";
// Called whenever the site is resized
function whenResized() {
// Get the size of the page
var body = document.body;
var html = document.documentElement;
var height = Math.max( body.scrollHeight, body.offsetHeight,
html.clientHeight, html.scrollHeight, html.offsetHeight );
}
// Called once the body has loaded
function init() {
// Save various references to DOM elements
mainInput = document.getElementById("mainInput");
mainOutput = document.getElementById("mainOutput");
editBox = document.getElementById("editBox");
editButton = document.getElementById("editButton");
editDiv = document.getElementById("editDiv");
responseDiv = document.getElementById("responseDiv");
editHelp = document.getElementById("editHelp");
errorText = document.getElementById("errorText");
// If there's a hash, treat it as the input
if (window.location.hash.length > 0) {
mainInput.value = decodeURIComponent(window.location.hash.substr(1));
askQuestion();
}
}
// Triggered either on pressing enter or if page loaded with hash
function askQuestion() {
// When a response is received, change the output text
var req = new XMLHttpRequest();
req.onreadystatechange = function() {
if (req.readyState == 4 && req.status == 200) {
if (req.responseText.length == 0) {
wasDefault = true;
mainOutput.innerText = "I don't know how to respond to that, press edit to tell me";
} else {
wasDefault = false;
mainOutput.innerText = req.responseText;
}
editButton.style.display = "inline-flex";
}
}
// Get the user's question
question = mainInput.value.trim();
var encodedQuestion = encodeURIComponent(question);
// Ensure it's a non-trivial request
if (question.length > 0) {
// Send this question as an async GET request
req.open("GET", encodedQuestion, true);
req.send(null);
// Now aren't sure whether they've editted already
errorText.style.display = "none";
}
}
// When a key is pressed in the main input box
function onKeyPress(e) {
// When the user presses enter
if (e.key == "Enter") {
// Ask the question to the server
askQuestion();
// Set the url so they can share the page
window.location.hash = encodeURIComponent(mainInput.value);
}
}
// Called when the edit button is pressed
function startEdit() {
// Start the edit box with the response text
if (wasDefault) {
editBox.value = "";
} else {
editBox.value = mainOutput.innerHTML;
}
// Add the question to the help text
editHelp.innerHTML = "If someone said \"<i>" + question + "</i>\", how would you answer?";
// Switch to edit mode
responseDiv.style.display = "none";
editDiv.style.display = "block";
}
// Called when the cancel button is pressed
function cancelEdit() {
// Switch to normal mode
responseDiv.style.display = "block";
editDiv.style.display = "none";
}
// Called when the submit button is pressed
function submitEdit() {
// Create a new request object
var req = new XMLHttpRequest();
req.onreadystatechange = function() {
if (req.readyState == 4 && req.status == 200) {
if (req.responseText == "no") {
errorText.style.display = "inline-block";
} else {
errorText.style.display = "none";
mainOutput.innerText = editBox.value;
wasDefault = false;
cancelEdit();
}
}
}
// Ensure it's a non-trivial request
if (mainInput.value.length > 0 && editBox.value.length > 0) {
// Send the question and response
var editReq = question + "~#~#~" + editBox.value;
// Send this question as an async POST request
req.open("POST", "/edit", true);
req.send(editReq);
}
}
</script>
<body onresize="whenResized();" onload="init();">
<div id="centered">
<a href="http://thehivemind.xyz"><img id="mainTitle" src="logo.svg"/></a>
<div id="responseDiv">
<input maxlength="40" id="mainInput" type="text" placeholder="ask a question to the hive mind" onkeydown="onKeyPress(event)"></input>
<p id="mainOutput">Here anyone can edit the responses, but only once per day per IP address. For more details, see the <a href="https://github.com/Lumorti/thehivemind">GitHub page</a>.</p>
<button id="editButton" onclick="startEdit()">edit response</p>
</div>
<div id="editDiv">
<p id="editHelp"></p>
<textarea maxlength="250" type="text" id="editBox"></textarea>
<p id="errorText">sorry, you've already editted this response today</p>
<button id="cancelButton" onclick="cancelEdit()">cancel</p>
<button id="submitButton" onclick="submitEdit()">submit</p>
</div>
</div>
</body>
</html>