-
Notifications
You must be signed in to change notification settings - Fork 1
/
backend.js
56 lines (49 loc) · 2.36 KB
/
backend.js
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
(() => {
"use strict";
const incomingMessages = [
/* {content, sender, img} */
{content: "Hey, what's up", sender: "Alberto", img: "assets/ewok.jpg"},
{content: "hellooooo", sender: "Ariel", img: "assets/boba.jpeg"},
{content: "Hey there", sender: "John", img: "assets/tarkin.jpeg"},
{content: "Hey trrrrhere", sender: "John", img: "assets/tarkin.jpeg"},
{content: "Hey jhvjuoyf there", sender: "John", img: "assets/tarkin.jpeg"},
{content: "Hey bbg there", sender: "John", img: "assets/tarkin.jpeg"},
{content: "Whassupbhv dude", sender: "Kelly", img: "assets/mothma.jpg"},
{content: "chill buyvitvf dudet", sender: "John", img: "assets/tarkin.jpeg"},
{content: "das great", sender: "Kelly", img: "assets/mothma.jpg"},
{content: "wasabi bvjfti", sender: "Sherwino", img: "assets/lando.jpg"},
{content: "chill dudet", sender: "John", img: "assets/tarkin.jpeg"},
{content: "das great", sender: "Kelly", img: "assets/mothma.jpg"},
{content: "wasabi", sender: "Sherwino", img: "assets/lando.jpg"},
{content: "Hey, what's up", sender: "Alberto", img: "assets/ewok.jpg"},
{content: "Hey there", sender: "John", img: "assets/tarkin.jpeg"},
{content: "Hey there", sender: "John", img: "assets/tarkin.jpeg"},
{content: "Hey there", sender: "John", img: "assets/tarkin.jpeg"},
{content: "Hey there", sender: "John", img: "assets/tarkin.jpeg"},
{content: "Whassup dude", sender: "Kelly", img: "assets/mothma.jpg"},
{content: "chill dudet", sender: "John", img: "assets/tarkin.jpeg"},
{content: "das great", sender: "Kelly", img: "assets/mothma.jpg"},
{content: "wasabi", sender: "Sherwino", img: "assets/lando.jpg"},
{content: "chill dudet", sender: "John", img: "assets/tarkin.jpeg"},
{content: "das great", sender: "Kelly", img: "assets/mothma.jpg"},
{content: "wasabi", sender: "Sherwino", img: "assets/lando.jpg"}
]
const subs = [];
function getTime() {
const date = new Date();
return date.getHours() + ":" + date.getMinutes();
}
setInterval(() => {
if (incomingMessages.length) {
const {sender, content, img} = incomingMessages.shift();
const time = getTime();
const read = false;
subs.forEach(sub => {
sub({sender, content, time, img, read})
}
);
// console.log(subs);
}
}, 3000);
window.connect = func => { subs.push(func) }
})()