forked from ReKindleOS/ReKindle
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhistory.html
More file actions
415 lines (349 loc) · 13.2 KB
/
Copy pathhistory.html
File metadata and controls
415 lines (349 loc) · 13.2 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
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
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
<!DOCTYPE html>
<html lang="en">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no, shrink-to-fit=no">
<meta charset="UTF-8">
<title>On This Day</title>
<style>
/* SYSTEM 7 AESTHETICS */
:root {
--bg-color: #ffffff;
--text-color: #000000;
--border: 2px solid #000000;
--shadow: 4px 4px 0px #000000;
--stripe-pattern: repeating-linear-gradient(0deg, transparent, transparent 2px, #000 3px, #000 4px);
}
body {
image-rendering: -webkit-crisp-edges;
image-rendering: -moz-crisp-edges;
image-rendering: -o-crisp-edges;
image-rendering: pixelated;
image-rendering: crisp-edges;
-ms-interpolation-mode: nearest-neighbor;
background-repeat: repeat;
background-position: top left;
image-rendering: -webkit-optimize-contrast;
image-rendering: pixelated;
image-rendering: crisp-edges;
background-repeat: repeat;
background-position: top left;
image-rendering: pixelated;
image-rendering: crisp-edges;
background-repeat: repeat;
background-position: top left;
font-family: "Geneva", "Verdana", sans-serif;
margin: 0;
padding: 20px;
height: 100vh;
overflow: hidden;
background-color: #e5e5e5;
/* Default Background (Overridden by JS) */
/* Background managed by settings */
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
/* FIX: Centers vertically */
user-select: none;
box-sizing: border-box;
}
/* WINDOW FRAME */
.window {
background: white;
border: 2px solid black;
box-shadow: var(--shadow);
display: flex;
flex-direction: column;
height: 90vh;
width: 90%;
max-width: 800px;
position: relative;
}
/* TITLE BAR */
.title-bar {
height: 35px;
border-bottom: 2px solid black;
display: flex;
align-items: center;
justify-content: center;
background: white;
padding: 0 10px;
position: relative;
flex-shrink: 0;
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
}
.title-stripes {
position: absolute;
top: 4px;
bottom: 4px;
left: 4px;
right: 4px;
background-image: var(--stripe-pattern);
z-index: 0;
}
.title-text {
background: white;
padding: 0 15px;
font-weight: bold;
z-index: 1;
font-size: 1.1rem;
}
/* CLOSE BUTTON (HOME) */
.close-box {
position: absolute;
left: 10px;
width: 18px;
height: 18px;
border: 2px solid black;
background: white;
z-index: 2;
cursor: pointer;
display: flex;
align-items: center;
justify-content: center;
font-weight: bold;
font-family: sans-serif;
font-size: 0.9rem;
line-height: 1;
box-shadow: 2px 2px 0 black;
}
.close-box:active {
background: black;
color: white;
transform: translate(1px, 1px);
box-shadow: none;
}
/* WINDOW CONTENT */
.window-content {
flex-grow: 1;
overflow-y: auto;
padding: 20px;
background: white;
}
/* HEADER INSIDE WINDOW */
.app-header {
text-align: center;
border-bottom: 4px double black;
padding-bottom: 10px;
margin-bottom: 20px;
}
.app-title {
font-family: "Georgia", serif;
font-size: 2rem;
text-transform: uppercase;
letter-spacing: 2px;
font-weight: 900;
margin: 0;
}
#date-display {
font-style: italic;
margin-top: 5px;
font-size: 1.1rem;
}
/* TABS */
.tabs {
display: flex;
width: 100%;
border: 2px solid black;
margin-bottom: 20px;
}
.tab-btn {
flex: 1;
padding: 10px;
text-align: center;
font-weight: bold;
text-transform: uppercase;
cursor: pointer;
border-right: 2px solid black;
background: white;
color: black;
font-size: 0.9rem;
}
.tab-btn:last-child {
border-right: none;
}
.tab-btn.active {
background: black;
color: white;
}
/* LIST */
#list-area {
width: 100%;
}
.entry {
display: flex;
align-items: baseline;
padding: 15px 0;
border-bottom: 1px solid #ccc;
}
.year-badge {
font-weight: 900;
font-size: 1.1rem;
min-width: 60px;
margin-right: 15px;
text-align: right;
font-family: "Helvetica Neue", sans-serif;
}
.entry-text {
font-family: "Georgia", serif;
font-size: 1rem;
line-height: 1.4;
}
#loading {
font-family: sans-serif;
font-style: italic;
text-align: center;
margin-top: 40px;
}
</style>
<script src="theme.js"></script>
<script src="js/i18n.js"></script>
<script src="time.js"></script>
</head>
<body>
<div class="window">
<div class="title-bar">
<div class="title-stripes"></div>
<!-- Home Button -->
<div class="close-box" onclick="window.location.href='index'">X</div>
<span class="title-text" data-i18n="history.title">On This Day</span>
</div>
<div class="window-content">
<div class="app-header">
<h1 class="app-title" data-i18n="history.header">History</h1>
<div id="date-display">Loading Date...</div>
</div>
<div class="tabs">
<div class="tab-btn active" onclick="switchTab('selected')" data-tab="selected"
data-i18n="history.tab.events">Events</div>
<div class="tab-btn" onclick="switchTab('births')" data-tab="births" data-i18n="history.tab.births">
Births</div>
<div class="tab-btn" onclick="switchTab('deaths')" data-tab="deaths" data-i18n="history.tab.deaths">
Deaths</div>
</div>
<div id="list-area">
<div id="loading" data-i18n="history.msg.consulting">Consulting the archives...</div>
</div>
</div>
</div>
<script>
// --- STATE ---
let historyData = null;
let currentTab = 'selected'; // 'selected' (Events), 'births', 'deaths'
// --- INIT ---
window.onload = () => {
if (window.rekindleApplyWallpaper) window.rekindleApplyWallpaper();
updateDateHeader();
};
// Re-update when translations are ready (in case they load after window.onload)
document.addEventListener('rekindle:i18n:ready', () => {
updateDateHeader();
});
function updateDateHeader() {
// Use timezone-aware date
const date = window.rekindleGetZonedDate ? window.rekindleGetZonedDate() : new Date();
const lang = document.documentElement.lang || 'en';
// Robust Month Name (Kindle totoLocaleString fallback)
let month;
try {
month = window.rekindleFormatWallDate ? window.rekindleFormatWallDate(date, { month: 'long' }) : (window.rekindleFormatTime ? window.rekindleFormatTime(date, { month: 'long' }) : date.toLocaleString(lang, { month: 'long' }));
// If it returns something numerical or fails to be a string on ancient browsers
if (!month || /^\d/.test(month)) throw new Error("Fallback needed");
} catch (e) {
const months = {
'en': ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],
'es': ['enero', 'febrero', 'marzo', 'abril', 'mayo', 'junio', 'julio', 'agosto', 'septiembre', 'octubre', 'noviembre', 'diciembre'],
'fr': ['janvier', 'février', 'mars', 'avril', 'mai', 'juin', 'juillet', 'août', 'septembre', 'octobre', 'novembre', 'décembre'],
'de': ['Januar', 'Februar', 'März', 'April', 'Mai', 'Juni', 'Juli', 'August', 'September', 'Oktober', 'November', 'Dezember']
// Add more if needed, but these cover the major Kindle markets
};
const list = months[lang] || months['en'];
month = list[date.getMonth()];
}
const day = date.getDate();
// Use window.t with fallback
const t = window.t || ((key, def) => def);
const title = t('history.title', 'On This Day');
const display = document.getElementById('date-display');
if (display) {
display.innerText = `${title}: ${month} ${day}`;
}
// Only fetch if we haven't already
if (!historyData) {
fetchHistory(date.getMonth() + 1, day);
}
}
// --- WALLPAPER LOADER ---
// --- API ---
async function fetchHistory(month, day) {
// Ensure formatting (01 instead of 1)
const m = String(month).padStart(2, '0');
const d = String(day).padStart(2, '0');
// Wikipedia API URL - Wikipedia's REST API now supports CORS directly
const wikiUrl = `https://en.wikipedia.org/api/rest_v1/feed/onthisday/all/${m}/${d}`;
try {
// Try direct fetch first (Wikipedia API supports CORS)
let res = await fetch(wikiUrl, {
headers: {
'Api-User-Agent': 'ReKindle/1.0 (https://rekindle.app; contact@rekindle.app)'
}
});
if (!res.ok) throw new Error("Network response was not ok");
historyData = await res.json();
renderList();
} catch (e) {
console.error('Direct fetch failed, trying proxy...', e);
// Fallback to allorigins proxy
const proxyUrl = `https://api.allorigins.win/get?url=${encodeURIComponent(wikiUrl)}`;
try {
const proxyRes = await fetch(proxyUrl);
if (!proxyRes.ok) throw new Error("Proxy response was not ok");
const proxyData = await proxyRes.json();
historyData = JSON.parse(proxyData.contents);
renderList();
} catch (e2) {
console.error('Proxy fetch also failed:', e2);
document.getElementById('list-area').innerHTML = `<div style="text-align:center; padding:20px;">${window.t('history.msg.error')}</div>`;
}
}
}
// --- RENDER ---
function renderList() {
const container = document.getElementById('list-area');
container.innerHTML = '';
if (!historyData) return;
let items = historyData[currentTab] || [];
if (items.length === 0) {
container.innerHTML = `<div style="text-align:center">${window.t('history.msg.empty')}</div>`;
return;
}
items.forEach(item => {
const div = document.createElement('div');
div.className = 'entry';
div.innerHTML = `
<div class="year-badge">${item.year}</div>
<div class="entry-text">${item.text}</div>
`;
container.appendChild(div);
});
}
// --- INTERACTIONS ---
function switchTab(tabName) {
document.querySelectorAll('.tab-btn').forEach(btn => {
btn.classList.remove('active');
if (btn.getAttribute('data-tab') === tabName) {
btn.classList.add('active');
}
});
currentTab = tabName;
// Scroll list area to top, not the window
document.querySelector('.window-content').scrollTop = 0;
renderList();
}
</script>
<script>
</script>
<script src="https://cdn.counter.dev/script.js" data-id="4e551911-0e5d-4c48-91a6-b828c3301675"
data-utcoffset="11"></script>
</body>
</html>