-
Notifications
You must be signed in to change notification settings - Fork 4
/
index.html
102 lines (92 loc) · 3.42 KB
/
index.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
<head>
<title>Yo</title>
<link rel="shortcut icon" href="https://yoapp.s3.amazonaws.com/yo/favicon.ico">
<link rel="stylesheet" type="text/css" href="//cdnjs.cloudflare.com/ajax/libs/font-awesome/4.1.0/css/font-awesome.min.css">
<link rel="stylesheet" type="text/css" href="//cdnjs.cloudflare.com/ajax/libs/animate.css/3.1.1/animate.min.css">
<link rel="stylesheet" type="text/css" href="/static/fireworks.css">
<link rel="stylesheet" type="text/css" href="/static/styles.css">
<script type="text/javascript" src="/static/fireworks.js"></script>
</head>
<body {{if .Winner}}onload="createWinnerFireworks()"{{end}}>
<div class="container">
<div id="fireworks-template">
<div id="fw" class="firework"></div>
<div id="fp" class="fireworkParticle">
<img src="static/image/particles.gif" alt="particle"/>
</div>
</div>
<div id="fireContainer"></div>
<div class="stats">
<p>Yo's sent</p>
<p id="counter">{{.Count}}</p>
<p>Last Yo from</p>
<div id="last-user-wrapper">
<p id="last-user" {{if .Winner}}class="animated infinite pulse"{{end}}>
{{.Username}}
</p>
</div>
</div>
<footer class="footer" >
<a target="_blank" href="https://github.com/YoApp/counter">Source Code</a> | <a target="_blank" href="http://jobs.justyo.co/">We're Hiring!</a><br><br><br>
</footer>
</div>
<script>
function startWs(uri) {
var socket = new WebSocket(constructWsURI());
socket.onmessage = function (event) {
var msg = JSON.parse(event.data);
user.innerHTML = msg.username;
counter.innerHTML = msg.count.toLocaleString();
if (msg.winner) {
user.setAttribute('class', 'animated infinite pulse');
createWinnerFireworks();
socket.close();
}
}
socket.onclose = function () {
setTimeout(startWs(constructWsURI()), 5000);
};
}
function createWinnerFireworks() {
setTimeout(function() {
var r = 8+parseInt(Math.random()*8);
var p = 14+parseInt(Math.random()*14);
createFirework(r,p,2,null,null,null,null,null,Math.random()>0.5,false);
createWinnerFireworks();
},1+parseInt(Math.random()*1000));
}
function constructWsURI() {
var loc = window.location, new_uri;
if (loc.protocol === "https:") {
new_uri = "wss:";
} else {
new_uri = "ws:";
}
new_uri += "//" + loc.host;
new_uri += loc.pathname + "connect";
return new_uri;
}
var user = document.getElementById('last-user');
var counter = document.getElementById('counter');
startWs(constructWsURI());
</script>
<!-- TODO: Don't hardcode this -->
<!-- Start of StatCounter Code for Default Guide -->
<script type="text/javascript">
var sc_project=10006800;
var sc_invisible=1;
var sc_security="8f2734c6";
var sc_https=1;
var scJsHost = (("https:" == document.location.protocol) ?
"https://secure." : "http://www.");
document.write("<sc"+"ript type='text/javascript' src='" +
scJsHost+
"statcounter.com/counter/counter.js'></"+"script>");
</script>
<noscript><div class="statcounter"><a title="hits counter"
href="http://statcounter.com/free-hit-counter/"
target="_blank"><img class="statcounter"
src="http://c.statcounter.com/10006800/0/8f2734c6/1/"
alt="hits counter"></a></div></noscript>
<!-- End of StatCounter Code for Default Guide -->
</body>