-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
182 lines (151 loc) · 5.1 KB
/
Copy pathindex.html
File metadata and controls
182 lines (151 loc) · 5.1 KB
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
<!DOCTYPE html>
<html lang="he">
<head>
<meta charset="UTF-8">
<title>מחשבון זמן שעבר</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- קישור ל־PWA manifest -->
<link rel="manifest" href="manifest.json">
<style>
body {
font-family: 'Arial', sans-serif;
direction: rtl;
text-align: right;
background: linear-gradient(135deg, #4facfe, #00f2fe);
margin: 0;
padding: 20px;
color: #fff;
}
h1 {
text-align: center;
margin-bottom: 25px;
text-shadow: 1px 1px 3px #000;
}
.container {
background: rgba(255, 255, 255, 0.15);
padding: 25px;
border-radius: 12px;
max-width: 480px;
margin: auto;
box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}
label {
display: block;
margin-top: 15px;
font-size: 1.1em;
}
.row {
display: flex;
gap: 10px;
margin-top: 5px;
}
input {
flex: 1;
padding: 10px;
border-radius: 8px;
border: none;
font-size: 1em;
}
.select-btn {
padding: 10px 15px;
background: #ffca28;
border: none;
border-radius: 8px;
cursor: pointer;
color: #000;
font-weight: bold;
box-shadow: 0 3px 8px rgba(0,0,0,0.3);
white-space: nowrap;
}
.select-btn:hover {
background: #ffe066;
}
button.calculate {
width: 100%;
padding: 12px;
margin-top: 20px;
background: #ff5722;
border: none;
border-radius: 8px;
font-size: 1.2em;
cursor: pointer;
color: #fff;
font-weight: bold;
box-shadow: 0 3px 8px rgba(0,0,0,0.3);
}
button.calculate:hover {
background: #ff784e;
}
#result {
margin-top: 25px;
font-size: 1.2em;
background: rgba(0,0,0,0.25);
padding: 15px;
border-radius: 10px;
}
.confirmed {
border: 2px solid #00ff88;
}
.version {
margin-top: 15px;
font-size: 0.9em;
text-align: left;
opacity: 0.8;
}
</style>
</head>
<body>
<h1>מחשבון זמן שעבר בין שני תאריכים</h1>
<div class="container">
<label>תאריך ושעה התחלתיים:</label>
<div class="row">
<input type="datetime-local" id="start">
<button class="select-btn" onclick="confirmSelection('start')">בחר</button>
</div>
<label>תאריך ושעה סופיים:</label>
<div class="row">
<input type="datetime-local" id="end">
<button class="select-btn" onclick="confirmSelection('end')">בחר</button>
</div>
<button class="calculate" onclick="calculateDiff()">חשב</button>
<div id="result"></div>
<div class="version">גרסה 1.0.0</div>
</div>
<script>
function confirmSelection(id) {
const field = document.getElementById(id);
if (!field.value) {
alert("נא לבחור תאריך ושעה קודם");
return;
}
field.classList.add("confirmed");
}
function calculateDiff() {
const startInput = document.getElementById('start').value;
const endInput = document.getElementById('end').value;
const resultDiv = document.getElementById('result');
if (!startInput || !endInput) {
resultDiv.textContent = 'נא למלא את שני התאריכים.';
return;
}
const startDate = new Date(startInput);
const endDate = new Date(endInput);
if (endDate < startDate) {
resultDiv.textContent = 'התאריך הסופי חייב להיות אחרי התאריך ההתחלתי.';
return;
}
const diffMs = endDate - startDate;
const diffMinutes = Math.floor(diffMs / 1000 / 60);
const diffHours = Math.floor(diffMinutes / 60);
const diffDays = Math.floor(diffHours / 24);
const remainingHours = diffHours % 24;
const remainingMinutes = diffMinutes % 60;
resultDiv.textContent =
`עברו ${diffDays} ימים, ${remainingHours} שעות ו-${remainingMinutes} דקות.`;
}
if ("serviceWorker" in navigator) {
navigator.serviceWorker.register("service-worker.js");
}
</script>
</body>
</html>