/
index.html
88 lines (75 loc) · 2.4 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>hour-to-day-or-night</title>
<meta name="description" content="Convert hour to day or night: 8 → 'day'">
<link rel="icon" type="image/png" sizes="32x32" href="public/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="public/favicon-16x16.png">
<link rel="apple-touch-icon" sizes="180x180" href="public/apple-touch-icon.png">
<link rel="mask-icon" href="public/safari-pinned-tab.svg" color="#009688">
<meta name="msapplication-TileColor" content="#ffffff">
<meta name="msapplication-config" content="public/browserconfig.xml" />
<meta name="theme-color" content="#ffffff">
<link rel="manifest" href="public/manifest.json">
<link rel="stylesheet" href="style.css">
<link rel="stylesheet" href="style_day.css">
<link rel="stylesheet" href="style_night.css">
</head>
<body class="converter">
<div class="converter__input">
<input
class="converter__control converter__control_name_input"
value=""
min="0"
max="23"
type="number"
placeholder="hour"
/>
</div>
<div class="converter__output">
<input
class="converter__control converter__control_name_result"
value=""
readonly
type="text"
placeholder="result"
/>
</div>
<a
class="copyright"
href="https://github.com/vovanr/hour-to-day-or-night"
target="_blank"
rel="noopener noreferrer"
>
<span class="copyright__license">MIT ©</span> <span class="copyright__author">Vladimir Rodkin</span>
</a>
<script>window.module = {}</script>
<script src="index.js"></script>
<script>
(function (hourToDayOrNight) {
'use strict'
var converterBlock = document.querySelector('.converter')
var inputControl = document.querySelector('.converter__control_name_input')
var resultControl = document.querySelector('.converter__control_name_result')
var previousTheme
inputControl.valueAsNumber = new Date().getHours()
inputControl.addEventListener('input', renderResult)
function renderResult() {
var val = hourToDayOrNight(inputControl.valueAsNumber)
resultControl.value = val
if (!converterBlock.classList.contains(val)) {
converterBlock.classList.add(val)
}
if (previousTheme !== val) {
converterBlock.classList.remove(previousTheme)
previousTheme = val
}
}
renderResult()
})(window.module.exports)
</script>
</body>
</html>