-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
695 lines (649 loc) · 24.8 KB
/
Copy pathindex.html
File metadata and controls
695 lines (649 loc) · 24.8 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
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Finance & Family</title>
<!-- PWA -->
<link rel="manifest" href="/manifest.json">
<meta name="theme-color" content="#0a0c10">
<link rel="icon" type="image/png" sizes="32x32" href="/icons/favicon-32.png">
<link rel="icon" type="image/png" sizes="16x16" href="/icons/favicon-16.png">
<link rel="apple-touch-icon" href="/icons/apple-touch-icon.png">
<meta name="mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
<meta name="apple-mobile-web-app-title" content="Fin & Family">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=DM+Serif+Display:ital@0;1&family=DM+Mono:wght@400;500&family=Be+Vietnam+Pro:ital,wght@0,300;0,400;0,500;0,600;0,700;1,400&display=swap" rel="stylesheet">
<style>
/* ── Design tokens ── */
:root {
--bg: #0a0c10;
--surface: #111318;
--card: #141720;
--border: #1e2330;
--border-hi:#2a3040;
--accent: #c8a96e; /* gold — personal / hub */
--blue: #5c9eff; /* asset calculators */
--green: #4ecb8a; /* family registry */
--red: #e06b6b; /* tax & legal */
--purple: #b67fff; /* nation state / macro */
--orange: #ff9f43; /* global economy / business */
--text: #e8e3d8;
--muted: #6a7080;
--font-display: 'DM Serif Display', Georgia, serif;
--font-body: 'Be Vietnam Pro', system-ui, sans-serif;
--font-mono: 'DM Mono', 'Courier New', monospace;
--r: 10px;
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
background: var(--bg);
color: var(--text);
font-family: var(--font-body);
font-size: 14px;
line-height: 1.65;
min-height: 100vh;
}
/* Subtle grain */
body::before {
content: '';
position: fixed; inset: 0; z-index: 0; pointer-events: none;
background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.025'/%3E%3C/svg%3E");
opacity: .5;
}
.shell {
position: relative; z-index: 1;
max-width: 860px;
margin: 0 auto;
padding: 56px 24px 96px;
}
/* ── Header ── */
.site-header {
display: flex;
justify-content: space-between;
align-items: flex-start;
gap: 20px;
margin-bottom: 56px;
flex-wrap: wrap;
}
.brand-title {
font-family: var(--font-display);
font-style: italic;
font-weight: 400;
font-size: clamp(28px, 4vw, 38px);
color: var(--accent);
line-height: 1.1;
margin-bottom: 8px;
}
.brand-sub {
color: var(--muted);
font-size: 13px;
max-width: 380px;
line-height: 1.55;
}
.lang-btn {
background: var(--surface);
border: 1px solid var(--border-hi);
color: var(--muted);
font-family: var(--font-body);
font-size: 12px;
font-weight: 500;
padding: 8px 14px;
border-radius: 6px;
cursor: pointer;
transition: border-color .15s, color .15s;
white-space: nowrap;
flex-shrink: 0;
margin-top: 6px;
}
.lang-btn:hover { border-color: var(--accent); color: var(--accent); }
/* ── Section labels ── */
.section-label {
font-family: var(--font-mono);
font-size: 10px;
font-weight: 500;
letter-spacing: .12em;
text-transform: uppercase;
color: var(--muted);
margin-bottom: 16px;
padding-bottom: 10px;
border-bottom: 1px solid var(--border);
display: flex;
align-items: center;
gap: 10px;
}
.section-label::before {
content: '';
display: inline-block;
width: 20px; height: 1px;
background: var(--accent);
opacity: .6;
}
/* ── Project group ── */
.project-group { margin-bottom: 48px; }
/* ── Section label with carousel nav ── */
.section-label { justify-content: space-between; }
.section-label-text { display: flex; align-items: center; gap: 10px; }
.section-label-text::before {
content: '';
display: inline-block;
width: 20px; height: 1px;
background: var(--accent);
opacity: .6;
}
.section-label::before { display: none; }
.carousel-nav { display: flex; gap: 6px; }
.nav-btn {
width: 26px; height: 26px;
border-radius: 50%;
background: var(--surface);
border: 1px solid var(--border-hi);
color: var(--muted);
display: flex; align-items: center; justify-content: center;
cursor: pointer;
font-size: 12px;
line-height: 1;
transition: color .15s, border-color .15s;
}
.nav-btn:hover { color: var(--accent); border-color: var(--accent); }
.nav-btn:active { transform: scale(.94); }
/* ── Horizontal carousel track ── */
.carousel-track {
display: flex;
gap: 14px;
overflow-x: auto;
scroll-snap-type: x proximity;
scroll-behavior: smooth;
padding: 4px 4px 14px;
margin: 0 -4px;
-webkit-overflow-scrolling: touch;
}
.carousel-track::-webkit-scrollbar { height: 5px; }
.carousel-track::-webkit-scrollbar-track { background: transparent; }
.carousel-track::-webkit-scrollbar-thumb { background: var(--border-hi); border-radius: 3px; }
/* ── Project card (carousel item) ── */
.project-card {
flex: 0 0 252px;
scroll-snap-align: start;
display: flex;
flex-direction: column;
text-decoration: none;
color: inherit;
background: var(--card);
border: 1px solid var(--border);
border-radius: var(--r);
overflow: hidden;
padding: 18px 18px 16px;
transition: border-color .18s, transform .18s, box-shadow .18s;
position: relative;
}
.project-card:hover {
border-color: var(--border-hi);
transform: translateY(-4px);
box-shadow: 0 10px 26px rgba(0,0,0,.4);
}
/* Coloured top bar — the signature element */
.project-card::before {
content: '';
position: absolute;
top: 0; left: 0; right: 0;
height: 3px;
background: var(--c, var(--accent));
opacity: .7;
transition: opacity .18s;
}
.project-card:hover::before { opacity: 1; }
.card-icon {
width: 46px; height: 46px;
border-radius: 11px;
display: flex; align-items: center; justify-content: center;
font-size: 22px;
line-height: 1;
background: color-mix(in srgb, var(--c, var(--accent)) 16%, transparent);
margin-bottom: 14px;
flex-shrink: 0;
}
.card-body { min-width: 0; flex: 1; display: flex; flex-direction: column; }
.card-name {
font-size: 14px;
font-weight: 600;
color: var(--text);
line-height: 1.3;
display: flex;
align-items: center;
gap: 7px;
flex-wrap: wrap;
margin-bottom: 6px;
}
.card-tag {
font-family: var(--font-mono);
font-size: 9.5px;
letter-spacing: .06em;
padding: 2px 6px;
border-radius: 3px;
border: 1px solid;
opacity: .75;
font-weight: 400;
}
.card-desc {
font-size: 12px;
color: var(--muted);
line-height: 1.5;
margin-bottom: 12px;
}
.card-features {
list-style: none;
display: flex;
flex-direction: column;
gap: 6px;
margin-top: auto;
padding-top: 12px;
border-top: 1px solid var(--border);
}
.card-features li {
font-size: 10.5px;
color: var(--muted);
display: flex;
gap: 6px;
align-items: flex-start;
line-height: 1.4;
}
.card-features li::before {
content: '✓';
color: var(--c, var(--accent));
flex-shrink: 0;
font-weight: 600;
opacity: .85;
}
.card-arrow {
margin-top: 12px;
font-size: 11.5px;
font-weight: 600;
color: var(--c, var(--accent));
display: flex;
align-items: center;
gap: 5px;
opacity: .85;
transition: gap .18s;
}
.project-card:hover .card-arrow { gap: 8px; opacity: 1; }
/* ── Asset calculator carousel ── */
.asset-tile {
flex: 0 0 108px;
scroll-snap-align: start;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
gap: 9px;
text-align: center;
text-decoration: none;
color: inherit;
background: var(--card);
border: 1px solid var(--border);
border-radius: var(--r);
padding: 18px 10px 14px;
transition: border-color .18s, transform .18s;
}
.asset-tile:hover {
border-color: var(--blue);
transform: translateY(-3px);
}
.asset-icon {
width: 40px; height: 40px;
border-radius: 10px;
display: flex; align-items: center; justify-content: center;
font-size: 20px;
line-height: 1;
background: color-mix(in srgb, var(--blue) 16%, transparent);
}
.asset-name {
font-size: 11px;
font-weight: 500;
color: var(--muted);
line-height: 1.3;
transition: color .18s;
}
.asset-tile:hover .asset-name { color: var(--blue); }
/* ── Footer ── */
.site-footer {
border-top: 1px solid var(--border);
padding-top: 24px;
margin-top: 16px;
display: flex;
justify-content: space-between;
align-items: center;
gap: 16px;
flex-wrap: wrap;
}
.footer-note {
font-size: 11px;
color: var(--muted);
font-family: var(--font-mono);
}
.footer-count {
font-family: var(--font-mono);
font-size: 11px;
color: var(--muted);
}
.footer-count span { color: var(--accent); }
/* ── Responsive ── */
@media (max-width: 600px) {
.shell { padding: 36px 16px 72px; }
.site-header { margin-bottom: 40px; }
.project-card { flex-basis: 220px; }
.carousel-nav { display: none; }
}
</style>
</head>
<body>
<div class="shell">
<!-- HEADER -->
<header class="site-header">
<div>
<h1 class="brand-title" data-i18n="title">Finance & Family</h1>
<p class="brand-sub" data-i18n="sub">A personal suite of financial tools and family records. Select a project to open it.</p>
</div>
<button class="lang-btn" onclick="toggleLang()" data-i18n="langBtn">🌐 Tiếng Việt</button>
</header>
<!-- SECTION 1 — MAIN APPS -->
<div class="project-group" id="group-apps">
<div class="section-label">
<span class="section-label-text" data-i18n="labelApps">Applications</span>
<span class="carousel-nav">
<button class="nav-btn" onclick="scrollCarousel('list-apps', -1)" aria-label="Scroll left">‹</button>
<button class="nav-btn" onclick="scrollCarousel('list-apps', 1)" aria-label="Scroll right">›</button>
</span>
</div>
<div class="carousel-track" id="list-apps"></div>
</div>
<!-- SECTION 2 — ASSET CALCULATORS -->
<div class="project-group" id="group-assets">
<div class="section-label">
<span class="section-label-text" data-i18n="labelAssets">Asset Class Calculators</span>
<span class="carousel-nav">
<button class="nav-btn" onclick="scrollCarousel('grid-assets', -1)" aria-label="Scroll left">‹</button>
<button class="nav-btn" onclick="scrollCarousel('grid-assets', 1)" aria-label="Scroll right">›</button>
</span>
</div>
<div class="carousel-track" id="grid-assets"></div>
</div>
<!-- FOOTER -->
<footer class="site-footer">
<span class="footer-note" data-i18n="footerNote">All tools run locally · No data leaves your browser</span>
<span class="footer-count" id="footer-count"></span>
</footer>
</div>
<script>
/* ── i18n ── */
let lang = 'en';
const T = {
en: {
title: 'Finance & Family',
sub: 'A personal suite of financial tools and family records. Select a project to open it.',
langBtn: '🌐 Tiếng Việt',
labelApps: 'Applications',
labelAssets: 'Asset Class Calculators',
footerNote: 'All tools run locally · No data leaves your browser',
footerCount: (n, m) => `${n} apps · ${m} calculators`,
},
vi: {
title: 'Tài Chính & Gia Đình',
sub: 'Bộ công cụ tài chính đơn giản cho cá nhân và gia đình. Chọn một dự án để mở.',
langBtn: '🌐 English',
labelApps: 'Ứng Dụng',
labelAssets: 'Máy Tính Cho Từng Loại Tài Sản',
footerNote: 'Tất cả công cụ chạy cục bộ · Không có dữ liệu rời khỏi trình duyệt',
footerCount: (n, m) => `${n} ứng dụng · ${m} máy tính`,
}
};
/* ── Project data ── */
const APPS = [
{
icon: '💼',
color: '#c8a96e',
href: 'wealth-builder',
tag: { en: 'Personal', vi: 'Cá Nhân' },
name: { en: 'Personal Wealth Builder', vi: 'Quản Lý Tài Sản Cá Nhân' },
desc: { en: 'Cashflow, budget, tax, debt & net worth tracker',
vi: 'Theo dõi dòng tiền, ngân sách, thuế, nợ & giá trị tài sản ròng' },
features: {
en: ['Net worth & cashflow dashboard', 'Debt payoff & budget planner', 'Automated tax estimate'],
vi: ['Bảng theo dõi tài sản ròng & dòng tiền', 'Kế hoạch trả nợ & ngân sách', 'Ước tính thuế tự động'],
},
tagColor: '#c8a96e',
},
{
icon: '🧭',
color: '#c8a96e',
href: 'Strategic_Life_Portfolio_Tool',
tag: { en: 'Life Plan', vi: 'Kế Hoạch Đời' },
name: { en: 'Personal Life Plan', vi: 'Quản Lý Cuộc Đời' },
desc: { en: 'Strategic life-stage roadmap linking goals, finances & timing',
vi: 'Lộ trình chiến lược theo giai đoạn cuộc đời, gắn mục tiêu với tài chính' },
features: {
en: ['Life-stage goal roadmap', 'Scenario & what-if modeling', 'Milestone progress tracking'],
vi: ['Lộ trình mục tiêu theo giai đoạn', 'Mô phỏng kịch bản giả định', 'Theo dõi tiến độ cột mốc'],
},
tagColor: '#c8a96e',
},
{
icon: '🏛️',
color: '#4ecb8a',
href: 'family/vi.html',
tag: { en: 'Genealogy', vi: 'Gia Phả' },
name: { en: 'Lã House', vi: 'Họ Lã' },
desc: { en: 'Family tree, demographics, kinship records & statistics across generations',
vi: 'Cây gia phả, nhân khẩu học, hồ sơ thân tộc & thống kê qua các thế hệ' },
features: {
en: ['Interactive multi-generation tree', 'Birth, marriage & lineage records', 'Demographic stats by branch'],
vi: ['Cây gia phả nhiều thế hệ tương tác', 'Hồ sơ sinh, kết hôn & huyết thống', 'Thống kê theo chi họ'],
},
tagColor: '#4ecb8a',
},
{
icon: '📊',
color: '#ff9f43',
href: 'smes',
tag: { en: 'Business', vi: 'Doanh Nghiệp' },
name: { en: 'Small Business Finance', vi: 'Tài Chính Doanh Nghiệp Nhỏ' },
desc: { en: 'Cashflow, tax planning & financial statements for SMEs',
vi: 'Dòng tiền, kế hoạch thuế & báo cáo tài chính cho doanh nghiệp vừa và nhỏ' },
features: {
en: ['13-week cashflow forecast', 'P&L / balance sheet builder', 'Tax provisioning calculator'],
vi: ['Dự báo dòng tiền 13 tuần', 'Lập báo cáo lãi lỗ / cân đối', 'Tính trích lập thuế'],
},
tagColor: '#ff9f43',
},
{
icon: '🏦',
color: '#c8a96e',
href: 'smsf',
tag: { en: 'Pension fund', vi: 'Quỹ Nghỉ Hưu' },
name: { en: 'Pension fund Dashboard', vi: 'Bảng chỉ sỗ Quỹ Nghỉ Hưu' },
desc: { en: 'Self-managed super fund compliance, contributions & performance',
vi: 'Tuân thủ, đóng góp & hiệu suất quỹ hưu bổng tự quản' },
features: {
en: ['Contribution caps tracker', 'Investment strategy monitor', 'Pension phase drawdown calc'],
vi: ['Theo dõi hạn mức đóng góp', 'Giám sát chiến lược đầu tư', 'Tính rút giai đoạn hưu'],
},
tagColor: '#c8a96e',
},
{
icon: '🌐',
color: '#b67fff',
href: 'nation-state',
tag: { en: 'Macro', vi: 'Vĩ Mô' },
name: { en: 'Nation State Economy', vi: 'Kinh tế và tài chính Quốc Gia' },
desc: { en: 'Fiscal & monetary policy simulator — budgets, rates & economic levers',
vi: 'Trình giả lập chính sách tài khóa & tiền tệ — ngân sách, lãi suất & đòn bẩy kinh tế' },
features: {
en: ['Fiscal & monetary policy levers', 'Interest rate & inflation modeling', 'GDP growth scenario engine'],
vi: ['Đòn bẩy chính sách tài khóa & tiền tệ', 'Mô hình lãi suất & lạm phát', 'Kịch bản tăng trưởng GDP'],
},
tagColor: '#b67fff',
},
{
icon: '🌍',
color: '#ff9f43',
href: 'earth-economy',
tag: { en: 'Global', vi: 'Toàn Cầu' },
name: { en: 'Global Economy', vi: 'Kinh Tế Toàn Cầu' },
desc: { en: 'Macroeconomic map — GDP, trade flows & inflation by region',
vi: 'Bản đồ kinh tế vĩ mô — GDP, dòng thương mại & lạm phát theo khu vực' },
features: {
en: ['Regional GDP comparison map', 'Trade flow visualization', 'Inflation & rate heatmaps'],
vi: ['Bản đồ so sánh GDP theo khu vực', 'Trực quan hóa dòng thương mại', 'Bản đồ nhiệt lạm phát & lãi suất'],
},
tagColor: '#ff9f43',
},
{
icon: '⚖️',
color: '#e06b6b',
href: 'international_tax_framework',
tag: { en: 'Tax', vi: 'Thuế' },
name: { en: 'International Tax', vi: 'Thuế Quốc Tế' },
desc: { en: 'Tax issues: residency, PE risk, WHT, transfer pricing, post-acquisition structure',
vi: 'Vấn đề thuế: cư trú thuế, rủi ro PE, WHT, định giá chuyển nhượng, cơ cấu hậu thâu tóm' },
features: {
en: ['Tax residency & PE risk test', 'Transfer pricing analysis', 'Withholding tax & structure planner'],
vi: ['Kiểm tra cư trú thuế & rủi ro PE', 'Phân tích định giá chuyển nhượng', 'Hoạch định thuế khấu trừ'],
},
tagColor: '#e06b6b',
},
/* === NEW PROJECTS ADDED === */
{
icon: '📉',
color: '#ff9f43',
href: 'credit_cycle_explorer.html',
tag: { en: 'Macro', vi: 'Vĩ Mô' },
name: { en: 'Credit Cycle Explorer', vi: 'Khám Phá Chu Kỳ Tín Dụng' },
desc: { en: 'Interactive analysis of credit cycle phases with 100+ years of empirical data, charts & simulator',
vi: 'Phân tích tương tác các giai đoạn chu kỳ tín dụng với dữ liệu thực nghiệm 100+ năm, biểu đồ & mô phỏng' },
features: {
en: ['4-phase interactive explorer', 'Historical default clustering & sector rotation', 'Policy & leverage simulator'],
vi: ['Khám phá 4 giai đoạn tương tác', 'Lịch sử cụm vỡ nợ & xoay vòng ngành', 'Mô phỏng chính sách & đòn bẩy'],
},
tagColor: '#ff9f43',
},
{
icon: '💧',
color: '#5c9eff',
href: 'liquidity-framework.html',
tag: { en: 'Macro', vi: 'Vĩ Mô' },
name: { en: 'Global Liquidity Framework', vi: 'Khung Thanh Khoản Toàn Cầu' },
desc: { en: 'Michael Howell liquidity cycle analysis — metrics, cycle simulator & policy transmission',
vi: 'Phân tích chu kỳ thanh khoản Michael Howell — chỉ số, mô phỏng chu kỳ & truyền dẫn chính sách' },
features: {
en: ['Global liquidity metrics dashboard', '65-month cycle & asset rotation simulator', 'Policy transmission analysis'],
vi: ['Bảng chỉ số thanh khoản toàn cầu', 'Mô phỏng chu kỳ 65 tháng & xoay vòng tài sản', 'Phân tích truyền dẫn chính sách'],
},
tagColor: '#5c9eff',
},
];
const ASSETS = [
{ icon: '💵', href: 'assets-cash', name: { en: 'Cash', vi: 'Tiền Mặt' } },
{ icon: '🏦', href: 'assets-term-deposit', name: { en: 'Term Deposit', vi: 'Tiền Kỳ Hạn' } },
{ icon: '📜', href: 'assets-bonds', name: { en: 'Bonds', vi: 'Trái Phiếu' } },
{ icon: '📈', href: 'assets-shares', name: { en: 'Shares', vi: 'Cổ Phiếu' } },
{ icon: '🔀', href: 'assets-derivatives', name: { en: 'Derivatives', vi: 'Phái Sinh' } },
{ icon: '🧺', href: 'assets-managed-funds', name: { en: 'Managed Funds',vi: 'Quỹ Quản Lý' } },
{ icon: '🏡', href: 'assets-property', name: { en: 'Property', vi: 'Bất Động Sản' } },
{ icon: '🧱', href: 'assets-metals', name: { en: 'Metals', vi: 'Kim Loại' } },
{ icon: '🪙', href: 'assets-crypto', name: { en: 'Crypto', vi: 'Tiền Mã Hóa' } },
];
/* ── Render ── */
function render() {
// i18n static elements
document.querySelectorAll('[data-i18n]').forEach(el => {
const key = el.getAttribute('data-i18n');
if (T[lang][key]) el.textContent = T[lang][key];
});
// App carousel
const listEl = document.getElementById('list-apps');
listEl.innerHTML = '';
APPS.forEach(app => {
const a = document.createElement('a');
a.href = app.href;
a.className = 'project-card';
a.style.setProperty('--c', app.color);
const featureItems = app.features[lang].map(f => `<li>${f}</li>`).join('');
a.innerHTML = `
<span class="card-icon">${app.icon}</span>
<div class="card-body">
<div class="card-name">
${app.name[lang]}
</div>
<div class="card-desc">${app.desc[lang]}</div>
<ul class="card-features">${featureItems}</ul>
<span class="card-arrow">${lang === 'en' ? 'Open' : 'Mở'} →</span>
</div>
`;
listEl.appendChild(a);
});
// Asset carousel
const gridEl = document.getElementById('grid-assets');
gridEl.innerHTML = '';
ASSETS.forEach(asset => {
const a = document.createElement('a');
a.href = asset.href;
a.className = 'asset-tile';
a.innerHTML = `
<span class="asset-icon">${asset.icon}</span>
<span class="asset-name">${asset.name[lang]}</span>
`;
gridEl.appendChild(a);
});
// Footer count
const fc = document.getElementById('footer-count');
fc.textContent = T[lang].footerCount(APPS.length, ASSETS.length);
}
function scrollCarousel(id, dir) {
const el = document.getElementById(id);
el.scrollBy({ left: dir * el.clientWidth * 0.85, behavior: 'smooth' });
}
function toggleLang() {
lang = lang === 'en' ? 'vi' : 'en';
render();
}
render();
/* ── PWA: register service worker ── */
if ('serviceWorker' in navigator) {
window.addEventListener('load', () => {
navigator.serviceWorker.register('/sw.js', { scope: '/' })
.then((registration) => {
// A tab open when the service worker first installs is NOT
// controlled by it — this page and its sub-resources (fonts,
// icons) would bypass the cache for this whole session. If
// someone goes offline right after first install, before ever
// reloading, nothing was cached in time. So: on the very first
// install, reload once (guarded by sessionStorage) after the new
// worker activates, so this visit gets fully captured offline.
if (!navigator.serviceWorker.controller) {
registration.addEventListener('updatefound', () => {
const newWorker = registration.installing;
if (!newWorker) return;
newWorker.addEventListener('statechange', () => {
if (
newWorker.state === 'activated' &&
!sessionStorage.getItem('ffSwReloaded')
) {
sessionStorage.setItem('ffSwReloaded', '1');
window.location.reload();
}
});
});
}
})
.catch((err) => {
console.warn('Service worker registration failed:', err);
});
});
}
</script>
</body>
</html>