-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.template.html
163 lines (138 loc) · 3.32 KB
/
index.template.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
<!DOCTYPE html>
<html lang="en" >
<head>
<meta charset="UTF-8">
<title>CodePen - Weight Converter</title>
</head>
<body>
<!-- partial:index.partial.html -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<link rel="stylesheet" href="styles.css">
<title>Weight Converstion Tool</title>
</head>
<style>
form {
font-family: 'Brush Script MT', cursive;
background-color: #78909C;
color: #263238;
margin: 20px auto;
padding: 25px;
width: 600px;
height: 550px;
line-height: 40px;
border-radius: 40px;
font-weight: 800;
font-size: 20px;
}
body {
background-color: #fff;
}
input{
background-color: #fff;
border: 0;
color: #000;
padding: 0px 15;
cursor: pointer;
margin-top: 35px;
text-align: right;
font-weight: 800;
border-radius: 5px;
font-size: 20px;
}
input:hover {
border: 0;
padding: 5px 21px;
cursor: pointer;
margin-top: 35px;
text-align: center;
font-weight: 800;
border-radius: 5px;
}
#error {
list-style: none;
text-align: center;
line-height: 35px;
color: #000;
font-weight: 550;
margin: 40px auto;
font-size: 30px;
}
.no-error{
width: 470px;
height: 30px;
margin: 10px;
border-radius: 5px;
color: #B71C1C;
font-weight: 700;
}
h1 {
color: #fff;
margin:50px auto;
font-size: 30px;
font-weight: 600;
text-align: center;
line-height: 60px;
}
img {
margin-right: 150px;
float: right;
}
h6 {
color: #263238;
text-align: center;
float:center;
}
h6:hover {
color: #455A64;
}
</style>
<body>
<div>
<form>
<h6>Power by: Meow.Nalini98</h6>
<h1>Weight Converter<br><i>(pounds to kg)</i></h1>
<p>Enter weight value in pounds:</p>
<label>Pounds</label>
<input type="number" step=".1">
<p>Your weight in Kilograms is: <span id="result"></span></p>
<img src="https://3.bp.blogspot.com/-ApGaPred2AY/XHnYZMauQ-I/AAAAAABEfo8/cQtFa2VX4v8aTNJoiCNIKx-jPtNeYlZlQCLcBGAs/s1600/AW3594167_00.gif" style="width: 200px"/>
</form>
</div>
<script>
const form = document.querySelector('form');
//add an event listener to the form
form.addEventListener('submit', function(e){
e.preventDefault();
const input = document.querySelector('input');
let results = document.querySelector('span');
let poundsToKG;
if ((input.value <= 0) || (isNaN(input.value))){
results.classList.add('error');
results.innerHTML = "<p>Please enter a value number!</p>"
setTimeout(function(){
results.innerHTML = '';
results.classList.remove('error');
}, 2000)
input.value = '';
} else {
poundsToKG = Number(input.value) / 2.2;
results.classList.add('no-error');
results.innerHTML = `${poundsToKG.toFixed(2)}`;
setTimeout(function(){
results.innerHTML = '';
input.value = '';
results.classList.remove('no-error');
}, 10000)
}
})
</script>
</body>
</html>
<!-- partial -->
</body>
</html>