-
Notifications
You must be signed in to change notification settings - Fork 5
/
index.html
112 lines (106 loc) · 2.54 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
103
104
105
106
107
108
109
110
111
112
<!doctype html>
<html lang="en">
<head>
<title>Tally Counter</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<meta name="description" content="Fast and simple tally counter">
<meta name="keywords" content="tally-counter, tally, counter">
<meta property="og:title" content="Tally Counter">
<meta property="og:description" content="Fast and simple tally counter">
<meta property="og:url" content="https://rioastamal.net/tally-counter/">
<meta property="og:image" content="https://s3.amazonaws.com/rioastamal-assets/tally-counter/favicon-1024.png">
<meta name="google" content="notranslate">
<style>
html,
body {
width: 100%;
height: 100%;
box-sizing: border-box;
}
html {
display: table;
}
body {
background-color: #222;
color: #a9a9a9;
display: table-cell;
box-sizing: border-box;
vertical-align: middle;
font-family: "Lucida Console", "Monaco", "Monospace", "Sans-serif";
}
#counter {
margin: 0 auto;
font-size: 8em;
width: 99%;
text-align: center;
overflow: hidden;
}
#reset {
position: absolute;
right: 0;
top: 0;
font-size: 1em;
color: inherit;
text-decoration: none;
padding: 0.2em 0.5em;
background-color: #333;
z-index: 1000;
}
#reset:visited {
color: inherit;
}
</style>
</head>
<body>
<div id="counter">0</div>
<a id="reset" href="#">Reset</a></div>
<script>
/**
* Write cookie and set the expiration to forever. It will only write once.
*
* @param String name
* @param String value
* @param Boolean checkWithValue
* @return void
*/
function writePermanentCookie(name, value)
{
var currentYear = (new Date()).getFullYear() + 3;
var expires = (new Date(currentYear, 12, 12)).toUTCString();
document.cookie = name + '=' + value + ';path=/;expires=' + expires;
}
var counter = document.getElementById('counter');
function increment()
{
counter.innerHTML = parseInt(counter.innerHTML) + 1;
writePermanentCookie('lastCounter', counter.innerHTML);
}
document.onmousedown = function(e)
{
e.preventDefault();
return false;
}
document.onkeypress = function(e)
{
increment();
}
document.onclick = function(e)
{
increment();
}
document.getElementById('reset').onclick = function(e)
{
e.preventDefault();
counter.innerHTML = -1;
}
window.onload = function(e)
{
var lastValue = document.cookie.replace(/(?:(?:^|.*;\s*)lastCounter\s*\=\s*([^;]*).*$)|^.*$/, "$1");
if (lastValue) {
counter.innerHTML = lastValue;
}
}
</script>
</body>
</html>