-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinterfaceSettings.js
More file actions
114 lines (97 loc) · 3.34 KB
/
interfaceSettings.js
File metadata and controls
114 lines (97 loc) · 3.34 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
// interfaceSettings.js
document.addEventListener("DOMContentLoaded", async () => {
const container = document.getElementById("helpContainer");
// 1. Load the Help Menu from helpMenu.html
if (container) {
try {
const response = await fetch("helpMenu.html");
const html = await response.text();
container.innerHTML = html;
initializeHelpMenu();
initializeEditorSettings();
} catch (err) {
console.error("Error loading helpMenu.html:", err);
}
}
// 2. Keyboard shortcut: Shift + Enter to evaluate
document.addEventListener("keydown", function (e) {
if (e.shiftKey && e.key === "Enter") {
e.preventDefault();
window.doEval?.();
}
});
});
// 3. Help Menu navigation logic
function initializeHelpMenu() {
const helpBtn = document.getElementById('helpButton');
const helpPopup = document.getElementById('helpPopup');
const closeHelp = document.getElementById('closeHelp');
const navButtons = document.querySelectorAll('.helpNav button');
const helpPages = document.querySelectorAll('.helpPage');
navButtons.forEach(btn => {
btn.addEventListener('click', () => {
const targetId = btn.getAttribute('data-page');
helpPages.forEach(page => page.classList.add('hidden'));
document.getElementById(targetId)?.classList.remove('hidden');
});
});
helpBtn?.addEventListener('click', () => {
helpPopup?.classList.toggle('hidden');
});
closeHelp?.addEventListener('click', () => {
helpPopup?.classList.add('hidden');
});
}
// 4. Editor settings: font, alignment, color, etc.
function initializeEditorSettings() {
const root = document.documentElement;
document.getElementById("fontSelect")?.addEventListener("change", (e) => {
const font = e.target.value;
const fontMap = {
default: "monospace, 'Inconsolata'",
acuarela: "'Acuarela'",
acuarelX: "'acuarelX'",
alargada: "'Alargada'",
alargadX: "'AlargadX'",
anarquia: "'Anarquia'",
anarquiX: "'AnarquiX'",
brillante: "'Brillante'",
brillantX: "'BrillantX'",
cinematica: "'Cinematica'",
cinematicX: "'CinematicX'",
escolar: "'Escolar'",
escolXr: "'EscolXr'",
estampa: "'Estampa'",
estampX: "'EstampX'",
molde: "'Molde'",
moldX: "'MoldX'",
nitida: "'Nitida'",
nitidX: "'NitidX'",
nocturna: "'Nocturna'",
nocturnX: "'NocturnX'",
plumon: "'Plumon'",
plumXn: "'PlumXn'",
salpicon: "'Salpicon'",
salpicXn: "'SalpicXn'",
treintas: "'Treintas'",
treintXs: "'TreintXs'",
voyeur: "'Voyeur'",
voyeXr: "'VoyeXr'"
};
const cssFont = fontMap[font] || "Inconsolata, monospace";
root.style.setProperty('--editor-font', cssFont);
});
document.getElementById("fontSizeSelect")?.addEventListener("change", (e) => {
const size = e.target.value;
root.style.setProperty('--editor-size', size);
});
document.getElementById("alignSelect")?.addEventListener("change", (e) => {
root.style.setProperty('--editor-align', e.target.value);
});
document.getElementById("bgColorSelect")?.addEventListener("change", (e) => {
root.style.setProperty('--editor-bg', e.target.value);
});
document.getElementById("fontColorSelect")?.addEventListener("change", (e) => {
root.style.setProperty('--editor-color', e.target.value);
});
}