-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
201 lines (162 loc) · 4.28 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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
<!doctype html>
<head>
<title>Kindle Counter</title>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<style type="text/css">
html, body {
margin:0;
padding:0;
}
body {
text-align:center;
overflow:hidden;
}
.outer {
position:relative;
z-index:1;
}
.outer div {
display:inline-block;
background:#eee;
color:#000;
overflow:hidden;
text-align:center;
font-family: Impact, Haettenschweiler, "Franklin Gothic Bold", Charcoal, "Helvetica Inserat", "Bitstream Vera Sans Bold", "Arial Black", "sans serif";
position:relative;
pointer-events:none;
}
.outer div > h1 {
padding:0;
margin:0;
pointer-events:none;
}
.outer div.inverted {
background-image:url('skull.png');
background-repeat:no-repeat;
background-color: #000;
background-position:50% 10%;
background-size:auto 50%;
color:#fff;
}
.outer div > span {
display:block;
position:absolute;
text-align:center;
font-weight:bold;
z-index:100;
pointer-events:all;
}
.reset {
position:absolute;
z-index:2;
width:100px;
height:100px;
left:50%;
top:50%;
margin-top:-50px;
margin-left:-50px;
overflow:hidden;
border-radius:50px;
}
.reset a {
left:-2px;
top:-2px;
position:absolute;
width:50px;
height:100px;
font-size:30px;
line-height:100px;
background:#333;
color:#fff;
border:2px solid #fff;
}
.reset a:nth-of-type(2) { left: 50px; background:#777;}
.outer div:nth-of-type(1), .outer div:nth-of-type(2) {
-webkit-transform: rotate(-180deg);
/* Firefox */
-moz-transform: rotate(-180deg);
/* IE */
-ms-transform: rotate(-180deg);
/* Opera */
-o-transform: rotate(-180deg);
/* Internet Explorer */
filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=2);
}
</style>
<script type="text/javascript">
var p = {
"one": [40, null],
"two": [40, null],
"three": [40, null],
"four": [40, null],
}
var outer = document.createElement("div");
outer.className = "outer"
var update = function (name, v) {
var o = p[name][0]
var n = o + v
var el = p[name][1]
if ((v < 0 && n < 1 && o > 0)||(v > 0 && n > 0 && o < 1)) { el.parentNode.classList.toggle("inverted") }
p[name][0] = n;
el.innerHTML = n
}
var reset = function(value) {
for (key in p) {
p[key][0] = value
p[key][1].parentNode.className = ''
p[key][1].innerHTML = value
}
}
for (key in p) {
var div = document.createElement("div");
var h1 = document.createElement("h1");
h1.innerHTML = p[key][0];
var span1 = document.createElement("span");
span1.innerHTML = "+1";
span1.setAttribute("style", "left:0; top:0;");
span1.setAttribute("onClick", "update('"+key+"', 1)");
var span2 = document.createElement("span");
span2.innerHTML = "+5";
span2.setAttribute("style", "left:50%; top:0;");
span2.setAttribute("onClick", "update('"+key+"', 5)");
var span3 = document.createElement("span");
span3.innerHTML = "-1";
span3.setAttribute("style", "left:0; top:50%; line-height:480px;");
span3.setAttribute("onClick", "update('"+key+"', -1)");
var span4 = document.createElement("span");
span4.innerHTML = "-5";
span4.setAttribute("style", "left:50%; top:50%; line-height:480px;");
span4.setAttribute("onClick", "update('"+key+"', -5)");
p[key][1] = h1;
div.appendChild(h1);
div.appendChild(span1);
div.appendChild(span2);
div.appendChild(span3);
div.appendChild(span4);
outer.appendChild(div);
}
var vw = document.documentElement.clientWidth;
var vh = document.documentElement.clientHeight;
var cmargin = 5;
var cwidth = vw / 2 - cmargin * 2;
var cheight = vh / 2 - cmargin * 2;
var st = document.createElement("style");
st.type = "text/css";
var sizing = ""
sizing += "\n" + ".outer div { width: "+ cwidth +"px; height: "+ cheight +"px; margin: "+ cmargin +"px;}"
sizing += "\n" + ".outer div > h1 { line-height: "+ cheight +"px; font-size: "+ cheight*0.6 +"px;}";
sizing += "\n" + ".outer div > span { width: "+ cwidth/2 +"px; height: "+ cheight/2 +"px; font-size: "+ cheight/20 +"px; line-height: "+ cheight/5 +"px;}";
sizing += "\n" + ".outer div.inverted h1 { line-height: "+ cheight*1.3 +"px; font-size: "+ cheight*0.3 +"px;}";
st.innerHTML = sizing;
var init = function() {
document.head.appendChild(st);
document.body.appendChild(outer);
}
</script>
</head>
<body onload="init()">
<div class="reset">
<a onclick="reset(20)">20</a>
<a onclick="reset(40)">40</a>
</div>
</body>