forked from jmoss20/HackCU
-
Notifications
You must be signed in to change notification settings - Fork 0
/
popup.html
121 lines (104 loc) · 2.71 KB
/
popup.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
<!DOCTYPE html>
<html>
<head>
<style>
body {
background-color: #d0e4f2;
margin: 0;
padding: 0;
}
.cont2 {
margin-top: 120px;
}
ul {
list-style: none;
width: 100%;
height: 100%;
position: absolute;
margin: 0;
padding: 0;
text-align: center;
}
li {
display: inline-block;
width: 24%;
text-align: center;
margin: 0;
font-size: 5rem;
padding-top: 28px;
text-shadow: 0px 1px 1px #444;
height: 300px;
-webkit-transition: font-size 0.5s;
}
li:hover {
font-size: 5.5rem;
cursor: default;
}
li div {
color: #363636;
font-size: 0.75rem !important;
font-family: "Cabin", sans-serif;
text-shadow: none !important;
}
</style>
</head>
<body>
<ul class="cont" id="faces"></ul>
<ul class="cont2" id="names"></ul>
<script src="socket.io/socket.io.js"></script>
<script>
var socket = io().connect('http://localhost:3000');
var people = {}
function createEmojiPane(obj) {
var cont = document.createElement("li");
cont.id = obj.user_id + "_emoji";
cont.innerHTML = getEmoji(obj.emoji);
document.getElementById("faces").appendChild(cont);
return cont;
}
function createNamePane(obj) {
var cont2 = document.createElement("li")
cont2.id = obj.user_id + "_name";
cont2.innerHTML = "<div>" + obj.user_id + "</div>";
document.getElementById("names").appendChild(cont2);
return cont2;
}
function updatePane(obj) {
obj.emo.innerHTML = getEmoji(obj.emoji);
obj.person.innerHTML = "<div>" + obj.user_id + "</div>";
}
function getEmoji (index) {
if (index == 0) { return '😡'}
else if (index == 1) { return '😷'}
else if (index == 2) { return '😨'}
else if (index == 3) { return '😄'}
else if (index == 4) { return '😢'}
else if (index == 5) { return '🙉'}
else if (index == 6) { return '😑'}
}
socket.on('emojis', function (obj) {
if (obj.emoji >= 0) {
if (obj.user_id in people) {
people[obj.user_id].emoji = obj.emoji;
people[obj.user_id].confidence = obj.confidence;
updatePane(people[obj.user_id]);
}
else {
var emoElem = createEmojiPane(obj);
var nameElem = createNamePane(obj);
people[obj.user_id] = obj;
people[obj.user_id].emo = emoElem;
people[obj.user_id].person = nameElem;
}
}
else {
delete people[obj.user_id];
var emoChild = document.getElementById(obj.user_id + "_emoji");
var nameChild = document.getElementById(obj.user_id + "_name");
emoChild.parentNode.removeChild(emoChild);
nameChild.parentNode.removeChild(nameChild);
}
});
</script>
</body>
</html>