-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadmin.html
More file actions
421 lines (400 loc) · 13.4 KB
/
admin.html
File metadata and controls
421 lines (400 loc) · 13.4 KB
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
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
<!DOCTYPE html>
<html>
<head>
<title>SHEP AI</title>
<link rel="stylesheet" type="text/css" href="style.css">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<link rel="shortcut icon" href="assets/test1.ico" type="favicon/ico">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/jpswalsh/academicons@1/css/academicons.min.css">
</head>
<body class="backgroundC">
<div class="topnav">
<p class="title" align="center">Dexter Shepherd</p>
<a align="left" class="topnavlogo"><img src="assets/eyeT.png" width="50px" height="50px"></a>
<a class="topnavleft" href="index.html">Home</a>
<a class="topnavleft" href="index.html#about">About</a>
<a class="topnavleft" href="downloads.html">Downloads</a>
<a class="topnavleft" href="contact.html">Contact</a>
<br>
<!-- <a align="right" href="https://www.facebook.com/SHEP-AI-101118428133298/" class="fa fa-facebook"></a>
<a align="right" href="https://twitter.com/ai_shep" class="fa fa-twitter"></a>
<a align="right" href="https://www.instagram.com/shep.ai/" class="fa fa-instagram"></a>
<a align="right" href="https://www.youtube.com/channel/UCQr_MHaJ53feVK19lDKDxCQ?view_as=subscriber" class="fa fa-youtube"></a> -->
<a align="right" href="https://www.linkedin.com/in/dexter-shepherd-1a4a991b8/" class="fa fa-linkedin"></a>
<a align="right" href="https://scholar.google.com/citations?hl=en&user=hJSy6CYAAAAJ" class="ai ai-google-scholar ai-2x"></a>
<a align="right" href="https://github.com/shepai" class="fa fa-github"></a>
<a class="topnavright" class="search-container"><input id="searchbar" type="text" placeholder="Search.." name="search"></a>
<a href="#" class="topnavright"><i onclick="search()" class="icon fa fa-search"></i></a>
<script src="jquery.js">
</script>
<script src="search.js">
</script>
</div>
<!-- the main content -->
<br>
<div class="main">
<div align="center" class="iconPage">
<img class="imageCircle" src="assets/eye.png">
</div>
<h1 class="headerText">SHEP Admin mode</h1>
<hr class="break">
<h3 class="contentText">This application is for the developers of SHEP to make changes to the SHEP bot running. Left click on
a question to add a response and right click to delete</h3>
<div id="mainContent" class="messageActivate">
</div>
<div align="center" id="alertAdd" style="display: none;">
<h4>Add</h4>
<h5>Question</h5>
<input class="messageBox" type="text" id="inputQ1" style="outline-color:black;outline-width=1px;outline-style: dotted;" />
<h5>Answer</h5>
<input class="messageBox" type="text" id="inputQ2" style="outline-color:black;outline-width=1px;outline-style: dotted;" />
<br><br>
<button onclick="saveQuestionAnswer()" class="" >Submit</button>
</div>
<div align="center" id="alertDelete" style="display: none;">
<h4>Delete</h4>
<h5>Question</h5>
<input class="messageBox" type="text" id="inputD1" style="outline-color:black;outline-width=1px;outline-style: dotted;" />
<br><br>
<button onclick="delQuestionAnswer()" class="" >Submit</button>
</div>
<div id="signIn" align="center">
<h5>Sign in name</h5>
<input type="text" id="uname" class="messageBox" style="outline-color:black;outline-width=1px;outline-style: dotted;" name="fname">
<br>
<h5>Password</h5>
<input type="text" id="paswo" class="messageBox" style="outline-color:black;outline-width=1px;outline-style: dotted;" name="fname">
<br>
<!--<h5>Decrypt</h5>
<input type="text" id="decryptKey" class="messageBox" style="outline-color:black;outline-width=1px;outline-style: dotted;" name="fname">
-->
<br><br>
<button onclick="signIn()" class="" >Sign in</button>
</div>
<div style="display: none;" id="View">
<!--This area remains hidden until the user -->
<h3>To add</h3>
</div>
<br><br>
<div align="center" class="sendMessage">
<br>
<button onClick="viewAll()" class="" >View to add</button>
<button onClick="viewFeedback()" class="" >View Feedback</button>
<button onClick="addOwn()" class="" >Add own</button>
<button onClick="deleteOwn()" class="" >Delete</button>
<button onClick="viewReport()" class="" >View reports</button>
</div>
</div>
</body>
<script type="text/javascript">
class Stack {
constructor()
{
this.size=10;
this.items=[];
}
push(element)
{
if(this.items.length<=this.size){
this.items.push(element);
}else{
this.items.shift();
this.items.push(element);
}
}
pop(element)
{
if(this.items.length==0){
return "overflow";
}else{
return this.items.pop();
}
}
isEmpty()
{
if(this.items.length==0){return true;}else{return false;}
}
}
var loadedQs=[]; //store the questions
var stack= new Stack();
var startNumA=0;
var numA=0;
var typeOfDisplay="";
var con=new WebSocket("ws://80.5.202.205:8080") //ws://echo.websocket.org
var letIn=false; //start false
/**/
con.onopen=function(){con.send("Connect");};
con.onerror=function(error){console.log("error"+error);};
con.onmessage=function(e){
console.log("message:"+e.data);
var output=e.data;
if(output=="signInRequestGranted"){
letIn=true;
var x=document.getElementById("signIn");
x.style.display="none"; //do not show once signed in
}else if(output=="ERROR"){
//encountered an error
alert("there was a problem doing what you just did");
}else{
loadedQs=output.split(":::"); //seperate data with colons
//show in div
document.getElementById("View").innerHTML='<a onClick="undo()"><p style="cursor: pointer;"><u> Undo Deletion </u></p></a>';
for(var i=0;i<loadedQs.length;i++){
if (loadedQs[0]!=""){
var add;
console.log(typeOfDisplay);
if(typeOfDisplay=="V"){
add='<br id="'+numA+'"><button oncontextmenu="Delete('+"'"+numA+"'"+')" onClick="addQ('+"'"+numA+"'"+')" id="'+numA+'" class="userMessage">'+loadedQs[i]+'</button><div id="'+numA+'" class="msgBrk"></div>';
}else if(typeOfDisplay=="R"){
add='<br id="'+numA+'"><button oncontextmenu="DeleteR('+"'"+numA+"'"+')" onClick="addR('+"'"+numA+"'"+')" id="'+numA+'" class="userMessage">'+loadedQs[i]+'</button><div id="'+numA+'" class="msgBrk"></div>';
}else{
add='<br id="'+numA+'"><button oncontextmenu="DeleteF('+"'"+numA+"'"+')" id="'+numA+'" class="userMessage">'+loadedQs[i]+'</button><div id="'+numA+'" class="msgBrk"></div>';
}
numA=numA+1;
document.getElementById("View").innerHTML+=add;
}
}
removeTopA(); //remove the top item/s when too big
}
};
function viewReport(){
if(letIn==true){
typeOfDisplay="R";
document.getElementById("View").innerHTML="";
var x=document.getElementById("View");
x.style.display="block";
x=document.getElementById("alertAdd");
x.style.display="none";
x=document.getElementById("alertDelete");
x.style.display="none";
con.send("REPORT");
}else{alert("Sign in to do this");}
}
function viewAll(){
//view the data
console.log("view");
if(letIn==true){
//do
startNumA=0;
numA=0;
typeOfDisplay="V";
document.getElementById("View").innerHTML="";
var x=document.getElementById("View");
x.style.display="block";
x=document.getElementById("alertAdd");
x.style.display="none";
x=document.getElementById("alertDelete");
x.style.display="none";
con.send("VIEWDATA");
}else{alert("Sign in to do this");}
}
function viewFeedback(){
//get feedback from user via statistical analyses
stack= new Stack();
stack= new Stack();
console.log("view");
if(letIn==true){
//do
startNumA=0;
numA=0;
typeOfDisplay="FB";
document.getElementById("View").innerHTML="";
var x=document.getElementById("View");
x.style.display="block";
x=document.getElementById("alertAdd");
x.style.display="none";
x=document.getElementById("alertDelete");
x.style.display="none";
con.send("VIEWFEEDBACK");
}else{alert("Sign in to do this");}
}
function addQ(idNum){
console.log("add");
if(letIn){
//do
//validate string
//add to server
document.getElementById(idNum).remove(); //remove from page once added
var question=document.getElementById(idNum).textContent; //get main
console.log(question);
var text = prompt("Please enter Your response", "");
text=text.replace("---","");
text=text.replace(":::","");
text=text.replace("signInRequest:","");
text=text.replace("DELETE","delete");
if(text.length<500){
if (text == null || text == "") {
alert("cancelled");
} else {
con.send("ADD"+question+"---"+text);
document.getElementById(idNum).remove();
document.getElementById(idNum).remove();
}
}else{
alert("Please decrease your message size");
}
}else{alert("Sign in to do this");}
}
function addR(idNum){
//delete the item in the report and add new information
if(letIn){
document.getElementById(idNum).remove(); //remove from page once added
var question=document.getElementById(idNum).textContent; //get main
console.log(question);
var text = prompt("Please enter Your response", "");
text=text.replace("---","");
text=text.replace(":::","");
text=text.replace("signInRequest:","");
text=text.replace("DELETE","delete");
if(text.length<500){
if (text == null || text == "") {
alert("cancelled");
} else {
con.send("RADD"+question+"---"+text);
document.getElementById(idNum).remove();
document.getElementById(idNum).remove();
}
}else{
alert("Please decrease your message size");
}
}else{alert("Sign in to do this");}
}
function Delete(idNum){
console.log("delete"); //used to delete responses which will not be added
if(letIn){
//do
document.getElementById(idNum).remove();
var question=document.getElementById(idNum).textContent; //get main
con.send("DELETE"+question);
document.getElementById(idNum).remove();
document.getElementById(idNum).remove();
stack.push(question);
}else{alert("Sign in to do this");}
}
function undo(){
//undo button
if(!(stack.isEmpty())){
var item=stack.pop();
if(typeOfDisplay=="V"){
con.send("QADD"+item);
viewAll();}
else{
con.send("FADD"+item);
viewFeedback();}
}
}
function DeleteR(idNum){
console.log("delete reported"); //used to delete responses which will not be added
if(letIn){
//do
document.getElementById(idNum).remove();
var question=document.getElementById(idNum).textContent; //get main
con.send("DELETER"+question);
document.getElementById(idNum).remove();
document.getElementById(idNum).remove();
}else{alert("Sign in to do this");}
}
function DeleteF(idNum){
console.log("delete reported"); //used to delete feedback which will not be added
if(letIn){
//do
document.getElementById(idNum).remove();
var question=document.getElementById(idNum).textContent; //get main
con.send("DELETEF"+question);
document.getElementById(idNum).remove();
document.getElementById(idNum).remove();
stack.push(question);
}else{alert("Sign in to do this");}
}
function signIn(){
//submit sign in
var usname=document.getElementById("uname").value;
var psw_d=document.getElementById("paswo").value;
con.send("signInRequest:"+usname+"--"+psw_d);
}
function addOwn(){
if(letIn){
var x=document.getElementById("alertAdd");
x.style.display="block";
x=document.getElementById("View");
x.style.display="none";
x=document.getElementById("alertDelete");
x.style.display="none";
}else{alert("Sign in to do this");}
}
function deleteOwn(){
if(letIn){
var x=document.getElementById("alertAdd");
x.style.display="none";
x=document.getElementById("View");
x.style.display="none";
x=document.getElementById("alertDelete");
x.style.display="block";
}else{alert("Sign in to do this");}
}
function saveQuestionAnswer() {
//save the question and answer
if(letIn){
var q=document.getElementById("inputQ1").value;
var a=document.getElementById("inputQ2").value;
q=q.replace("---","");
q=q.replace(":","");
q=q.toLowerCase();//convert to lower case
q=q.replace("?","");
q=q.replace(".","");
q=q.replace(",","");
q=q.replace("DELETE","delete");
a=a.replace("---","");
a=a.replace(":::","");
a=a.replace("DELETE","delete");
if(a.length+q.length<530){
if(q!="" && a!=""){
con.send("ADD"+q+"---"+a);
document.getElementById("inputQ1").value="";
document.getElementById("inputQ2").value="";
}else{
alert("You cannot add that");
}
}else{
alert("Please decrease your message size");
}
}else{alert("Sign in to do this");}
}
function delQuestionAnswer() {
//delete a current question
if(letIn){
var a=document.getElementById("inputD1").value;
a=a.replace("---","");
a=a.replace(":::","");
a=a.replace("DELETE","delete");
a=a.toLowerCase();
if(a.length<500){
if(a!=""){
con.send("DELQUE"+a);
document.getElementById("inputD1").value="";
}else{
alert("You cannot delete that");
}
}else{
alert("Please decrease your message size");
}
}else{
alert("Sign in to do this");
}
}
function removeTopA()
{
if(numA+startNumA > 10)
{
document.getElementById(startNumA.toString()).remove();
document.getElementById((startNumA+1).toString()).remove();
document.getElementById(startNumA.toString()).remove();
document.getElementById((startNumA+1).toString()).remove();
document.getElementById(startNumA.toString()).remove();
document.getElementById((startNumA+1).toString()).remove();
startNumA+=2;
}
}
</script>
</html>