-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathquestion.html
340 lines (262 loc) · 8.97 KB
/
question.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
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
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
<!DOCTYPE html>
<html>
<link rel="stylesheet" type="text/css" href="question.css">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css">
<link href="https://fonts.googleapis.com/css?family=Oswald" rel="stylesheet">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<head>
<title>Question View</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
</head>
<body background="background.jpg">
<main>
<div id='app_header'></div>
<div id = 'grupollImage'>
<center>
<img id='logo_img' src='logo.png'>
</center>
</div>
<div id="question_statement">
<div id = "qbar">
<div id="bar"></div>
<div id="bar"></div>
<div id="bar"></div>
</div>
</div>
<!-- Here is our menu on the right side -->
<div id='rightMenu'>
<div class="area"></div>
<nav class="main-menu" style="text-align:center">
<!-- back button here -->
<ul style="inline-block">
<li>
<a href="#">
<div class='back_button'>
<i id = 'back_button' class="material-icons fa-2x" style="font-size:3vw;color:red;float:left; margin-left:15%;margin-top:-20%;margin-bottom:100%;margin-right:15%;position:relative">arrow_back</i>
</div>
<span class="nav-text">
</span>
</a>
</li>
<li>
<a href="#">
<div class='polls'>
<i id='polls' class="material-icons fa-2x" style="font-size:3vw;color:red;margin-top:100%;margin-left:15%;margin-right:15%;margin-bottom:100%;position:relative">create</i>
</div>
<span class="nav-text">
</span>
</a>
</li>
<li>
<a href="#">
<div class='notifs'>
<i id='notifs' class="material-icons fa-2x" style="font-size:3vw;color:red;margin-top:100%;margin-left:15%;margin-right:15%;margin-bottom:100%;position:relative">notifications_active</i>
</div>
<span class="nav-text">
</span>
</a>
</li>
<li>
<a href="#">
<div class='settings'>
<i id="settings" class="material-icons fa-2x" style="font-size:3vw;color:red;margin-top:100%;margin-left:15%;margin-right:15%;margin-bottom:100%;position:relative">settings</i>
</div>
<span class="nav-text">
</span>
</a>
</li>
<li>
<a href="#">
<div class = 'power'>
<i id="power" class="material-icons fa-2x" style="font-size:3vw;color:red;margin-top:100%;margin-left:15%;margin-right:15%;margin-bottom:100%;position:relative" >power_settings_new</i>
</div>
<span class="nav-text">
</span>
</a>
</li>
</ul>
</nav>
</div>
<!-- right menu div ends -->
<!-- <nav>
<div class="nav-right hidden-xs">
<div class="button" id="btn">
<div class="bar top"></div>
<div class="bar middle"></div>
<div class="bar bottom"></div>
</div>
</div>
nav-right
</nav> -->
<!-- <a href="https://codepen.io/tonkec/" class="ua" target="_blank">
<i class="fa fa-user"></i>
</a> -->
<center>
<div>
<button onclick="vote1()" id="option_1" onCLick>...</button>
</div>
<span style="10px"></span>
<div>
<button onclick="vote2()" id="option_2">...</button>
</div>
<div>
<button onclick="vote3()" id="option_3">...</button>
</div>
</center>
<div id='footer'></div>
</main>
<!-- <div id='profileBar'>
<div class="nav-right visible-xs">
<div class="button" id="btn">
<div class="bar top"></div>
<div class="bar middle"></div>
<div class="bar bottom"></div>
</div>
</div>
nav-right
<div class="sidebar">
<ul class="sidebar-list">
<li class="sidebar-item"><a href="#" class="sidebar-anchor">Item 1</a></li>
<li class="sidebar-item"><a href="#" class="sidebar-anchor">Item 2</a></li>
<li class="sidebar-item"><a href="#" class="sidebar-anchor">Item 3</a></li>
<li class="sidebar-item"><a href="#" class="sidebar-anchor">Item 4</a></li>
</ul>
</div>
</div> -->
<!-- <a href="#">
<div id='backButton'>
<i id="back" class="material-icons" style="font-size:55px; color:red;"> arrow_back</i>
</div>
</a> -->
</body>
<script src="/socket.io/socket.io.js"></script>
<script src="/browserfs.min.js"></script>
<script type="text/javascript">
BrowserFS.install(window);
BrowserFS.configure({
fs : "LocalStorage"
}, e => {
if (e) {
throw e;
}
});
const fs = require('fs');
const socket = io();
const postHandle = () => {
window.open("http://52.170.186.150:3000/postQuestion", "_self");
}
const handleBack = () => {
window.open("http://52.170.186.150:3000/newsfeed", "_self");
}
const handleLogout = () => {
window.open("http://52.170.186.150:3000/splash", "_self");
};
const handleSettings = () => {
window.open("http://52.170.186.150:3000/settings", "_self");
};
const handleNotifs = () => {
window.open("http://52.170.186.150:3000/notifications", "_self");
};
const addQuestionStatement = statement => {
document.getElementById('question_statement').innerHTML = '<center>'+'<h2 id= question >' + statement + '</h2>' + '</center>';
document.getElementById('option_1').style.visibility = 'visible';
document.getElementById('option_2').style.visibility = 'visible';
document.getElementById('option_3').style.visibility = 'visible';
};
const addAnswerOptions = (o1, o2, o3) => {
document.getElementById('option_1').innerHTML = o1;
document.getElementById('option_2').innerHTML = o2;
document.getElementById('option_3').innerHTML = o3;
};
let click = 0;
const conductVote = opt => {
socket.emit('msgQuestionVoteRequest', { userID : myUserID, questionID : myQuestionID, value : opt });
}
function vote1() {
if(!click) {
document.getElementById("option_1").style.background = "red";
conductVote(0);
}
click=click+1;
}
function vote2() {
if(!click) {
document.getElementById("option_2").style.background = "red";
conductVote(1);
}
click=click+1;
}
function vote3() {
if(!click) {
document.getElementById("option_3").style.background = "red";
conductVote(2);
}
click=click+1;
}
let myUserID = "";
fs.readFile('/current_user.txt', (err, contents) => {
myUserID = contents.toString();
});
let myQuestionID = "";
fs.readFile('/current_question.txt', (err, contents) => {
myQuestionID = contents.toString();
});
// socket.emit('msgUserInitialization', { userID : myUserID }); // we don't need this one here at all, we could do this else where
socket.on('msgQuestionRetrieveRequestConfirmed', msg => {
console.log("yay we got something", msg)
addQuestionStatement(msg.statement);
});
socket.on('msgAnswerRetrieveRequestConfirmed', msg => {
console.log("yay we got something", msg)
addAnswerOptions(msg.option_1, msg.option_2, msg.option_3);
});
socket.on('msgQuestionVoteRequestConfirmed', msg => {
window.open("http://52.170.186.150:3000/result", "_self");
});
socket.emit('msgQuestionRetrieveRequest', { questionID : myQuestionID });
socket.emit('msgAnswerRetrieveRequest', { questionID : myQuestionID });
// side bar right
let open = 0;
function toggleLeftBar() {
$("main").toggleClass("move-to-right");
}
function toggleSidebar() {
$(".button").toggleClass("active");
$("main").toggleClass("move-to-left");
$(".sidebar-item").toggleClass("active");
}
$(".main-menu").on("mouseover",()=>{
toggleLeftBar();
})
$(".button").on("click tap", function() {
//$('.sidebar').css({'opacity','100'});
if(open==0){
$('.sidebar').css('opacity','100');
open=1;
}
else if(open == 1){
$('.sidebar').css('opacity','0');
open=0;
}
toggleSidebar();
});
// on click for buttons on the left
$(".back_button").on("click tap", function(){
handleBack()
});
$(".polls").on("click tap", function(){
postHandle()
});
$(".notifs").on("click tap", function(){
handleNotifs();
});
$(".settings").on("click tap", function() {
handleSettings();
});
$(".power").on("click tap", function(){
handleLogout()
});
</script>
</html>