-
Notifications
You must be signed in to change notification settings - Fork 0
/
notifications.html
214 lines (166 loc) · 6.38 KB
/
notifications.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
<!DOCTYPE html>
<html>
<link rel="stylesheet" type="text/css" href="postQuestion.css">
<link rel="stylesheet" type="text/css" href="newsfeed.css">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="https://fonts.googleapis.com/css?family=Oswald" rel="stylesheet">
<link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css">
<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>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
</head>
<body background="background.jpg">
<main>
<header class="app_header"></header>
<center>
<img src="logo.png" class="logo"></img>
<div class='notifs'>
<i id='notifs' class="material-icons fa-2x" style="font-size:7vw;color:#416262;margin-top:2%;margin-left:15%;margin-right:15%;position:relative">notifications_active</i>
</div>
<div class="title1" style="font-size:3em">Notifications</div>
<ul id="notificationsList" >
</ul>
<!--LEFT MENU-->
<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:grey;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>
<div class="footer"></div>
</center>
</div>
</main>
</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();
let userID = "";
fs.readFile('/current_user.txt', (err, contents) => {
userID = contents.toString();
});
const switchToQuestion = (questionID) => {
fs.writeFile('/current_question.txt', questionID, err => {
console.log(questionID);
fs.readFile('/current_active_question.txt', (err, contents) => {
if (contents.toString() === questionID) {
window.open("http://52.170.186.150:3000/result", "_self");
} else {
window.open("http://52.170.186.150:3000/question", "_self");
}
})
});
};
const addQuestionNotificationEntry = (userID, statement, questionID) => {
const addElem = "<button id=\"option_2\" onclick=\"switchToQuestion('" + questionID + "');\">" + statement + "</button>";
document.getElementById('notificationsList').innerHTML += "<li>" + addElem + "</li>";
};
const addStaticNotificationEntry = (userID, statement) => {
const addElem = statement;
document.getElementById('notificationsList').innerHTML += "<li>" + addElem + "</li>";
};
socket.on('msgNotificationPullRequestConfirmed', msg => {
console.log(msg)
msg.forEach(val => {
if (val.notif_type === 2) {
addQuestionNotificationEntry(val.notif_user_id, val.notif_content, val.notif_question_id);
} else {
addStaticNotificationEntry(val.notif_user_id, val.notif_content);
}
});
});
// console.log('World');
socket.on('msgNotificationPullRequestRejected', msg => {
alert('Notification Pull Request: Something messed up!');
});
socket.emit('msgNotificationPullRequest', { notificationUserID: userID });
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");
};
$(".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>