-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbackground1script.js
More file actions
56 lines (56 loc) · 2.14 KB
/
background1script.js
File metadata and controls
56 lines (56 loc) · 2.14 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
const api = "https://script.google.com/macros/s/AKfycbxtMmcub_LtEMkJgcfH_8YTZn-be9_u9KEe2TpJfEtCIMqSMILfMrkTDLYANDscl21o/exec";
const name1 = localStorage.getItem("hfuhiduhsfahidlhihuasfilhaushifuhdshcuhahiuy83e87w8e7r98we7yf8");
const id1 = Math.floor(Math.random()*100000);
function startUp(){
if (name1 == null || name1 == "anon" || name1 == "" || name1 == " "){
let newName = prompt("username");
if (newName == null || newName == NaN || newName == "" || newName == " "){
localStorage.setItem("hfuhiduhsfahidlhihuasfilhaushifuhdshcuhahiuy83e87w8e7r98we7yf8", "anon");
}else{
localStorage.setItem("hfuhiduhsfahidlhihuasfilhaushifuhdshcuhahiuy83e87w8e7r98we7yf8", newName);
location.reload();
}
}
load();
}
function load(){
fetch(api)
.then(res => res.json())
.then(data => {
data.forEach(msg => {
let check = checkDup(msg.id, msg.message, msg.timestamp);
if (check != true){
if (msg.id != id1){
let info = document.getElementById("infoBox");
let h1 = document.createElement("h1");
h1.textContent = msg.name+": "+msg.message;
h1.id = "info";
info.appendChild(h1);
}else{
let qbox = document.getElementById("userQBox");
let q1 = document.createElement("h1");
q1.textContent = msg.message;
q1.id = "userQ";
qbox.appendChild(q1);
}
}
});
});
}
function send(){
let message = document.getElementById("userInput").value;
let name = name1;
let id = id1;
console.log(name)
console.log(id)
console.log(message)
if (message != null){
fetch(api, {
method: 'POST',
body: new URLSearchParams({ name, message, id }),
}).then(() => {
load();
});
}
}
//setInterval(load(), 2000);