-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
58 lines (50 loc) · 1.98 KB
/
index.html
File metadata and controls
58 lines (50 loc) · 1.98 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
57
58
<!doctype html>
<html>
<head>
<meta name='viewport' content='width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0' >
<title>Sync Counter</title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.5.3/dist/css/bootstrap.min.css" integrity="sha384-TX8t27EcRE3e/ihU7zmQxVncDAy5uIKz4rEkgIXeMed4M0jlfIDPvg6uqKI2xXr2" crossorigin="anonymous">
<style>
.vertical-center {
min-height: 100%; /* Fallback for browsers do NOT support vh unit */
min-height: 100vh; /* These two lines are counted as one :-) */
display: flex;
align-items: center;
}
.btn{
min-height: 30%;
min-height: 30vh;
font-size: 5em;
}
.jumbotron{
background-color: aliceblue;
}
</style>
</head>
<body>
<div class="jumbotron vertical-center">
<div class="container">
<p class="text-center" style="font-size: 1em;">Made by <span style="background-color: #ECF0F1;">Antariksh</span><a href="https://github.com/aapatre/Socket.io-Controllable-and-Synced-Counter">(GitHub)</a></p>
<button onclick="incNum()" class="btn btn-success btn-lg btn-block">☝️</button>
<p id='syncnum' class="text-center" style="font-size: 5em;">Getting the count from the server...</p>
<button onclick="decNum()" class="btn btn-danger btn-lg btn-block">👇</button>
</div>
</div>
<script src="/socket.io/socket.io.js"></script>
<script>
var socket = io();
document.addEventListener("DOMContentLoaded", function(event) {
socket.on('what num', function (syncnum){
document.getElementById('syncnum').innerHTML = syncnum;
console.log("I've received the number!");
});
});
function incNum(){
socket.emit('inc num');
}
function decNum(){
socket.emit('dec num');
}
</script>
</body>
</html>