-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.html
251 lines (235 loc) · 7.39 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
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8' />
<title>臺大資訊起薪破 10 萬!</title>
<meta property="og:title" content="臺大資訊起薪破 10 萬!" />
<meta property="og:description" content="「三年內,台大資工畢業起薪將破台幣 10 萬」,AppsWork 創始合夥人林之晨在 2015 年 5 月 20 日於其網誌表示。" />
<meta property="og:image" content="//qcl.github.io/ntucsie100k2018/ntucsie100k.png" />
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/png" href="//qcl.github.io/ntucsie100k2018/male-technologist.png" sizes="32x32">
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-3607701-14"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-3607701-14');
</script>
<script>
let btnDidClick = () => {
let plus = document.querySelector('.btn-g #plus');
plus.classList.remove('up');
void plus.offsetWidth; // what the magic...
plus.classList.add('up');
gtag('event', 'click', {
'event_category': 'button',
'event_label': '🚀',
'value': 1
});
};
let deadlineDate = new Date('2018-05-20T12:28:00+08:00');
let exchangeRates = {};
let currencies = {
'TWD': '新臺幣🇹🇼',
'CNY': '人民幣🇨🇳',
'HKD': '港幣🇭🇰',
'USD': '美元🇺🇸',
'JPY': '日圓🇯🇵',
'EUR': '歐元🇪🇺',
'SGD': '新加坡元🇸🇬',
'GBP': '英鎊🇬🇧',
};
let diffTimeString = (startDate, endDate) => {
let diffTime = endDate - startDate;
if (diffTime <= 0) {
return '0秒';
}
let restSeconds = Math.round(diffTime / 1000);
let days = Math.round(restSeconds / 86400);
restSeconds %= 86400;
let hours = Math.round(restSeconds / 3600);
restSeconds %= 3600;
let minutes = Math.round(restSeconds / 60);
restSeconds %= 60;
let seconds = restSeconds;
return ` ${days} 天 ${hours} 小時 ${minutes} 分 ${seconds} 秒`;
};
let updateCountdownTime = () => {
let countdownSpan = document.querySelector('span#countdown');
let countPrefixSpan = document.querySelector('span#prefix');
let now = Date.now();
let countdownText = '同位素定年中';
if (now > deadlineDate) {
countdownText = diffTimeString(deadlineDate, now);
countPrefixSpan.innerHTML = '已經';
} else {
countdownText = diffTimeString(now, deadlineDate);
countPrefixSpan.innerHTML = '還剩';
}
countdownSpan.innerHTML = countdownText;
};
let sec = 0;
let currentCurrency = 'TWD';
let update = setInterval(function(){
sec++;
updateCountdownTime();
if (sec % 3 == 0 ) {
updateSalary();
}
if (sec % (60 * 5) == 0) {
updateExchangeRates();
}
}, 1000);
let updateExchangeRates = () => {
fetch('https://qcurrency-exchange-rates.appspot.com/api/latest').then(response => { return response.json(); }).then(jsonObj => {
exchangeRates = jsonObj.rates;
// append TWD manually
exchangeRates['TWD'] = 1;
console.log('exchange rates updated');
});
};
updateExchangeRates();
let updateSalary = () => {
let currencyNames = Object.keys(currencies);
let c = currencyNames.length;
let rate = 1;
let baseSalary = 100000;
let currencyName = '新臺幣🇹🇼';
while(true) {
c = Math.round(Math.random() * currencyNames.length);
if ( c >= currencyNames.length ) {
continue;
} else {
let currency = currencyNames[c];
if (currency != currentCurrency && exchangeRates[currency] != undefined) {
currentCurrency = currency;
currencyName = currencies[currency];
rate = exchangeRates[currency];
break;
}
}
}
let salaryUnit = (Math.round(Math.random() * 2) % 2 == 0) ? 1 : 12;
let salaryUnitStr = (salaryUnit == 1) ? '月薪' : '年薪';
let salary = Math.round(salaryUnit * baseSalary / rate);
salaryStr = `你的${salaryUnitStr}破 ${salary} ${currencyName}了嗎?`;
let salaryH1 = document.querySelector('h1#salary');
salaryH1.innerHTML = salaryStr;
};
</script>
<style>
body {
margin: 0;
}
.countdown-area {
padding-top: 10vh;
text-align: center;
}
.countdown-area #countdown {
font-size: 2em;
}
@media only screen and (max-width: 600px) {
.countdown-area #countdown {
font-size: 1em;
}
h1#salary {
font-size: 1em;
}
}
.are-you-100k {
text-align: center;
}
footer {
width: 100%;
position: fixed;
bottom: 0px;
text-align: center;
}
footer p {
font-size: 10px;
}
.countdown {
height: 80vh;
}
.btn {
border: solid 1vw lightgray;
width: 20vw;
height: 20vw;
font-size: 10vw;
border-radius: 50%;
cursor: pointer;
user-select: none;
vertical-align: middle;
line-height: 20vw;
text-align: center;
background: white;
z-index: 100;
position: absolute;
top: 0;
left: 0;
}
.btn:hover {
border: solid 1vw green;
}
.btns {
padding-top: 100px;
width: 20vw;
margin: auto;
}
@keyframes up {
0% {top: -10vw; opacity: 0;}
10% {top: -15vw; opacity: 1;}
50% {top:-15vw; opacity: 1;}
100% {top: -25vw; opacity: 0;}
}
.plus {
font-size:5vw;
color: white;
background: green;
vertical-align: middle;
line-height: 10vw;
width: 10vw;
height: 10vw;
border-radius: 50%;
text-align: center;
position: absolute;
top: 0;
left: 6vw;
}
.up {
animation-name: up;
animation-duration: 2s;
}
.btn-g {
position: relative;
width: 20vw;
height: 20vw;
}
</style>
</head>
<body>
<div class='countdown'>
<div class='countdown-area'>
<p><span id='prefix'></span><span id='countdown'>同位素定年中...<span></p>
</div>
<div class='are-you-100k'>
<h1 id='salary'>你的月薪破 100000 新臺幣🇹🇼了嗎?</h1>
<p><a href='http://mrjamie.cc/2015/05/20/cs-crunch/'>「三年內,台大資工畢業起薪將破台幣 10 萬」</a>(<a href='https://web.archive.org/web/20150522223407/http://mrjamie.cc/2015/05/20/cs-crunch/'>2015.05.20</a>)</p>
<p><!--📈<a href=''>還需要加薪多少才夠?</a>🔎<a href=''>大家都領多少?</a>-->📝<a href='https://www.goodjob.life/share/time-and-salary'>想要貢獻薪資資料?</a></p>
</div>
<div class='btns'>
<div class='options'>
<!-- 意味不明的按鈕呀,寫到一半想睡了,計數什麼的好麻煩 -->
<div class='btn-g'>
<div class='btn' onclick='btnDidClick();'>🚀</div>
<div id='plus' class='plus'>+1</div>
</div>
</div>
</div>
</div>
<footer>
<p>Favicon 圖示來自 <a href="https://www.emojione.com/">EmojiOne</a>,匯率資料來自 <a href="https://github.com/qcl/QCurrency">QCurrency API</a>,本網頁置於<a href='https://github.com/qcl/ntucsie100k2018'>宅埠</a>,歡迎<a href='https://github.com/qcl/ntucsie100k2018/pull/new/gh-pages'>合併請求</a>與<a href='https://github.com/qcl/ntucsie100k2018/issues/new'>許願</a>。</p>
</footer>
</body>
</html>