-
Notifications
You must be signed in to change notification settings - Fork 0
/
dmr.html
146 lines (130 loc) · 3.93 KB
/
dmr.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Time Input</title>
<style>
.checkbox-container {
display: flex;
flex-direction: column;
gap: 10px;
}
.checkbox-label {
display: flex;
align-items: center;
}
.checkbox-label input[type="radio"] {
display: none;
}
.checkbox-label .checkbox-custom {
width: 20px;
height: 20px;
border: 2px solid #aaa;
border-radius: 5px;
cursor: pointer;
margin-right: 10px;
}
.checkbox-label .checkbox-custom.checked {
background-color: #007bff;
}
.container {
display: flex;
flex-direction: column;
gap: 10px;
width: 200px;
}
.time-input {
width: 100%;
}
</style>
</head>
<body>
<h1> Distance Medley Relay</h1>
<div class="container">
<div>
<h3> 1200M: </h3>
<input type="text" id="time1" class="time-input" placeholder="00:00:000" />
</div>
<div>
<h3> 400M: </h3>
<input type="text" id="time2" class="time-input" placeholder="00:00:000" />
</div>
<div>
<h3> 800M: </h3>
<input type="text" id="time3" class="time-input" placeholder="00:00:000" />
</div>
<div>
<h3> 1600M: </h3>
<input type="text" id="time4" class="time-input" placeholder="00:00:000" />
</div>
<div class="checkbox-container">
<label class="checkbox-label" for="checkbox1">
<div class="checkbox-custom" id="checkbox1"></div>
MALE BANKED
</label>
<label class="checkbox-label" for="checkbox2">
<div class="checkbox-custom" id="checkbox2"></div>
FEMALE BANKED
</label>
</div>
<div>
<h1> Total Time: </h1>
<input type="text" id="totalTime" readonly />
</div>
</div>
<script>
const timeInputs = document.querySelectorAll('.time-input');
const totalTimeInput = document.getElementById('totalTime');
const checkbox1 = document.getElementById('checkbox1');
const checkbox2 = document.getElementById('checkbox2');
timeInputs.forEach(input => {
input.addEventListener('input', updateTotalTime);
});
let checkbox1Checked = false;
let checkbox2Checked = false;
checkbox1.addEventListener('click', () => {
checkbox1Checked = !checkbox1Checked;
checkbox1.classList.toggle('checked', checkbox1Checked);
if (checkbox1Checked) {
checkbox2Checked = false;
checkbox2.classList.remove('checked');
}
updateTotalTime();
});
checkbox2.addEventListener('click', () => {
checkbox2Checked = !checkbox2Checked;
checkbox2.classList.toggle('checked', checkbox2Checked);
if (checkbox2Checked) {
checkbox1Checked = false;
checkbox1.classList.remove('checked');
}
updateTotalTime();
});
function updateTotalTime() {
let totalMilliseconds = 0;
timeInputs.forEach(input => {
const [minutes, seconds, milliseconds] = input.value.split(':').map(num => parseInt(num));
totalMilliseconds += (minutes * 60 * 1000) + (seconds * 1000) + milliseconds;
});
let multiplier = 1;
if (checkbox1Checked) {
multiplier = 0.9866;
}
if (checkbox2Checked) {
multiplier = 0.9894;
}
totalMilliseconds *= multiplier;
const formattedTotalTime = formatMilliseconds(totalMilliseconds);
totalTimeInput.value = formattedTotalTime;
}
function formatMilliseconds(milliseconds) {
const totalSeconds = Math.floor(milliseconds / 1000);
const totalMinutes = Math.floor(totalSeconds / 60);
const remainingSeconds = totalSeconds % 60;
const remainingMilliseconds = milliseconds % 1000;
return `${totalMinutes.toString().padStart(2, '0')}:${remainingSeconds.toString().padStart(2, '0')}:${remainingMilliseconds.toString().padStart(3, '0')}`;
}
</script>
</body>
</html>