Repository navigation
Expand file tree
/
Copy pathscript.js
More file actions
108 lines (94 loc) · 3.33 KB
/
Copy pathscript.js
File metadata and controls
108 lines (94 loc) · 3.33 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
/**
* PANISOFT - Under Construction Interaction & Theme Controller
* Adheres to Modern Web Guidance: meta[name="color-scheme"], light-dark(), storage sync
*/
(function () {
'use strict';
// --- Theme Controller ---
const metaColorScheme = document.querySelector('meta[name="color-scheme"]');
const themeButtons = document.querySelectorAll('[data-theme-value]');
function getStoredScheme() {
try {
return localStorage.getItem('color-scheme');
} catch (e) {
return null;
}
}
function applyTheme(targetScheme) {
if (targetScheme === 'light' || targetScheme === 'dark') {
try {
localStorage.setItem('color-scheme', targetScheme);
} catch (e) {}
if (metaColorScheme) {
metaColorScheme.content = targetScheme;
}
} else {
// System default
try {
localStorage.removeItem('color-scheme');
} catch (e) {}
if (metaColorScheme) {
metaColorScheme.content = 'light dark';
}
targetScheme = 'system';
}
// Update active button state
themeButtons.forEach((btn) => {
const isSelected = btn.getAttribute('data-theme-value') === targetScheme;
btn.setAttribute('aria-pressed', isSelected ? 'true' : 'false');
});
}
// Initialize theme button states on load
const initialSetting = getStoredScheme() || 'system';
applyTheme(initialSetting);
// Bind clicks
themeButtons.forEach((btn) => {
btn.addEventListener('click', () => {
const selected = btn.getAttribute('data-theme-value');
applyTheme(selected);
});
});
// Keep across tabs in sync
window.addEventListener('storage', (event) => {
if (event.key === 'color-scheme') {
const newScheme = event.newValue || 'system';
applyTheme(newScheme);
}
});
// --- Email Notification Form Handler ---
const notifyForm = document.getElementById('notify-form');
const notifyInput = document.getElementById('notify-email');
const notifyFeedback = document.getElementById('form-feedback');
if (notifyForm && notifyInput && notifyFeedback) {
notifyForm.addEventListener('submit', (e) => {
e.preventDefault();
const email = notifyInput.value.trim();
if (!email || !email.includes('@') || !email.includes('.')) {
notifyFeedback.textContent = 'Please enter a valid email address.';
notifyFeedback.className = 'form-feedback error';
notifyInput.focus();
return;
}
try {
// Persist to local list
const raw = localStorage.getItem('panisoft_subscribers');
const subscribers = raw ? JSON.parse(raw) : [];
if (!subscribers.includes(email)) {
subscribers.push(email);
localStorage.setItem('panisoft_subscribers', JSON.stringify(subscribers));
}
notifyFeedback.textContent = `✓ Thank you! We've noted ${email} and will notify you when Panisoft launches.`;
notifyFeedback.className = 'form-feedback success';
notifyForm.reset();
} catch (err) {
notifyFeedback.textContent = '✓ Interest registered! We look forward to sharing our launch with you.';
notifyFeedback.className = 'form-feedback success';
}
});
}
// Set current year
const yearEl = document.getElementById('current-year');
if (yearEl) {
yearEl.textContent = new Date().getFullYear();
}
})();