-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathlocalhost.html
181 lines (171 loc) · 10.1 KB
/
localhost.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
<script>
//this is what would run in localhost:8082
//................................................................................................................................
var gggg; //this is for the interval that asks your local listener for messages it recieved
if(\\===0){for(let item in localStorage){delete(localStorage[item])}} //reset if localhost.html called first time
//the server puts a proper number there by that double backslash(a count of how many times localhost.html was called)
if(localStorage.opened){while(true){ alert("Slate is ALREADY opened in another browser\nPlease close this one 0_0");window.close() }}
localStorage.opened="yes"
window.onbeforeunload = function(){
delete(localStorage.opened)
var xhd = new XMLHttpRequest();
xhd.open('POST', window.location.href, true);
xhd.setRequestHeader("off", "yes");
xhd.send();
}
var myUname = "";
function signStruct(key, Uname) {
var xhd = new XMLHttpRequest();
xhd.open('POST', window.location.href, true); ///main server eventually
xhd.setRequestHeader("s", "yes");
xhd.setRequestHeader("p", key);
xhd.setRequestHeader("n", Uname);
xhd.send();
xhd.onload = function() {
document.getElementById("info").innerHTML = xhd.response;
}
}
let pec=()=>{var toSend = prompt('Enter Chat Room Name(that you want PEC file for)'); if(!toSend){return alert("ACTION CANCELLED");} var xhd = new XMLHttpRequest(); xhd.open('POST', window.location.href, true); xhd.setRequestHeader('s', 'makeJSON'); xhd.setRequestHeader('m', toSend); xhd.send(); xhd.onload = function () {alert(xhd.responseText);}}
function getMessages () {
//interval
//var aio = 0;
var unReadable='<i style="color:yellow">THIS USER MODIFIED THEIR Slate CLIENT TO SEND A MESSAGE IN A FORMAT THE STANDARD Slate CLIENT DOES NOT READ >:{</i></b>'
var unReadable1='<i style="color:red">YOU MODIFIED YOUR Slate CLIENT TO SEND A MESSAGE IN A FORMAT THE STANDARD Slate CLIENT DOES NOT READ >:{</i></b>'
function prepareElem(text){
var i=text.indexOf("</b>")+4
var text0=text.substr(0,i)
var text1=text.substr(i)
var toReturn=document.createElement('div')
if(i==3){toReturn.innerHTML=unReadable; return toReturn}
toReturn.innerHTML=text0
var textVar=document.createElement('span')
textVar.innerText=text1
textVar.style='display: block; max-width: 500px; word-wrap: break-word;'
toReturn.appendChild(textVar)
return toReturn
}
function notYou(text){
toReturn=prepareElem(text)
toReturn.style='width: 500px; min-height: 70px; background-color: red; margin: 5px;'
return(toReturn)
}
function you(text){
toReturn=prepareElem(text)
if(toReturn.innerHTML==unReadable){toReturn.innerHTML=unReadable1}
toReturn.style='width: 500px; min-height: 70px; background-color: lightgreen; margin: 5px; margin-left: 200px;'
return(toReturn)
}
function parse(resp){
var response=JSON.parse(resp)
return response.map(a=>{ if(a.you){return(you(a.text))}return(notYou(a.text)) })
}
gggg = setInterval(function () {
var xhd = new XMLHttpRequest();
xhd.open('POST', window.location.href, true); ///should be localhost when separate user systems are in place
xhd.setRequestHeader("s", "either");
//xhd.setRequestHeader("num", aio.toString());
xhd.send(); var abcde = setTimeout(()=>{if(xhd.status === 0){alert("Batch/Shell operation on your device isn't running anymore. Please CLOSE this page");window.close()}}, 500);
xhd.onload = function() {
if (xhd.responseText != "") {
if(xhd.getResponseHeader("oi") === "yes"){if(xhd.responseText.length>2){document.getElementById("myInput").value="";parse(xhd.responseText).forEach(a=>{document.getElementById("toChange").appendChild(a)})}}
}
}
}, 200);
//interval
}
function logStruct(key, Uname) {
var xhd = new XMLHttpRequest();
xhd.open('POST', window.location.href, true); ///main server eventually
xhd.setRequestHeader("s", "no");
xhd.setRequestHeader("p", key);
xhd.setRequestHeader("n", Uname);
xhd.send();
xhd.onload = function() {
var xl = xhd.response;
if (xl === Uname) {
document.getElementById("info").innerHTML = "Log In Successful";
loginScreen(Uname);
myUname = Uname;
}
else {document.getElementById("info").innerHTML = xl;}
}
}
//................;;
function loginScreen (user) {
var welcome = ("Welcome, " + user);
var theText = `<kbd><div id="info" style="min-height: 30px; width: 200px; padding: 20px; color: red; background-color: blue;">` + welcome + `</div><button onclick="logOut();">Logout</button></kbd><br><br /><input id="sName" placeholder="Room Name"><input id="sKey" placeholder="Room Password" type="Password"><button onclick="createRoom(document.getElementById('sName').value, document.getElementById('sKey').value);">Create Room</button><button onclick="joinRoom(document.getElementById('sName').value, document.getElementById('sKey').value);">Join Room</button>
<span style="color: lightgreen; background-color: teal" title="PEC, or Private Encryption Configuration" innerText="no" id="z">With PEC?</span><select id="za" innerTEXT="no" name="PEC">
<option id="dc1" >no</option>
<option id="dc2" >yes</option>
</select>
<button onclick="pec()" title="PEC, or Private Encryption Configuration">Create Config File for PEC</button>`;
document.getElementById("toChange").innerHTML = theText; getMessages();
}
function loginScreenn (user) {
var welcome = ("Welcome to Room '" + user + "'");
var theText = `<kbd><div id="info" style="min-height: 30px; width: 200px; padding: 20px; color: red; background-color: blue;">` + welcome + `</div><button onclick="logOut();">Logout</button></kbd><br><input id="myInput" title="say something" placeholder="say something"><button onclick="sendMessage(document.getElementById('myInput').value);">Send Message</button><br /><input id="sName" placeholder="Room Name"><input id="sKey" placeholder="Room Password" type="Password"><button onclick="createRoom(document.getElementById('sName').value, document.getElementById('sKey').value);">Create Room</button><button onclick="joinRoom(document.getElementById('sName').value, document.getElementById('sKey').value);">Join Room</button>
<span style="color: lightgreen; background-color: teal" title="PEC, or Private Encryption Configuration" innerText="no" id="z">With PEC?</span><select id="za" innerTEXT="no" name="PEC">
<option id="dc1" >no</option>
<option id="dc2" >yes</option>
</select>
<button onclick="pec()" title="PEC, or Private Encryption Configuration">Create Config File for PEC</button>`;
document.getElementById("toChange").innerHTML = theText;
}
//................;;
function logoutScreen () {
var theText = `<kbd><div id="info" style="min-height: 30px; width: 200px; padding: 20px; color: red; background-color: blue;">ENTRY PAGE</div></kbd><br><input id="keys" style="align: left;" title="Username" placeholder="Username"></br><br><input id="logs" style="align: left;" title="Password" type="Password" placeholder="Password"></br><br><button onclick="logStruct(document.getElementById('logs').value, document.getElementById('keys').value);"><kbd>Login</kbd></button><button onclick="signStruct(document.getElementById('logs').value, document.getElementById('keys').value);"><kbd>Sign Up</kbd></button></br>`;
document.getElementById("toChange").innerHTML = theText;
}
//]]]]]]]]
function logOut () {
var xhd = new XMLHttpRequest();
xhd.open('POST', window.location.href, true);
xhd.setRequestHeader("s", "logout");
xhd.send();
xhd.onload = function () {clearInterval(gggg); logoutScreen();}
}
//'''''''''''''
function createRoom (name, code) {
var xhd = new XMLHttpRequest();
xhd.open('POST', window.location.href, true);
xhd.setRequestHeader("s", "createRoom");
xhd.setRequestHeader("n", name);
xhd.setRequestHeader("p", code);
xhd.setRequestHeader("z", document.getElementById('za').value);
xhd.send();
xhd.onload = function () {if (xhd.responseText === "Success") {document.getElementById("info").innerHTML = xhd.responseText + " in Creating Room " + name;} else {document.getElementById("info").innerHTML = xhd.responseText;}}
}
//'''''''''''''
function joinRoom (name, code) {
var xhd = new XMLHttpRequest();
xhd.open('POST', window.location.href, true);
xhd.setRequestHeader("s", "joinRoom");
xhd.setRequestHeader("n", name);
xhd.setRequestHeader("p", code);
xhd.setRequestHeader("z", document.getElementById('za').value);
xhd.send();
xhd.onload = function () {if (xhd.responseText === "Success") {loginScreenn(name);} else {document.getElementById("info").innerHTML = xhd.responseText;}}
}
//'''''''''''''
//]]]]]]]]
setInterval(function(){var x=document.getElementById('myInput');if(x){if(!x.onkeypress){x.onkeypress=function(ev){if(ev.keyCode==13){sendMessage(x.value)}}}}},30)
function sendMessage (theMessage) {
document.getElementById('myInput').value=""
var xhd = new XMLHttpRequest();
xhd.open('POST', window.location.href, true); ///should be localhost when separate user systems are in place
xhd.setRequestHeader("s", "neither");
xhd.setRequestHeader("m", theMessage);
xhd.send();
}
</script>
<link rel="shortcut icon" href="https://cdn.pixabay.com/photo/2014/04/03/10/52/circle-311551_960_720.png" type="image/x-icon"/>
<title>Slate</title>
<body id = "toChange" style="background-color:green">
<kbd><div id="info" style="position: right; min-height: 30px; width: 200px; padding: 20px; color: red; background-color: blue;">ENTRY PAGE</div></kbd>
<br><input id="keys" style="align: left;" title="Username" placeholder="Username"></br>
<br><input id="logs" style="align: left;" title="Password" type="Password" placeholder="Password"></br>
<br>
<button onclick="logStruct(document.getElementById('logs').value, document.getElementById('keys').value);"><kbd>Login</kbd></button>
<button onclick="signStruct(document.getElementById('logs').value, document.getElementById('keys').value);"><kbd>Sign Up</kbd></button>
</br>
</body>