-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
117 lines (103 loc) · 5.43 KB
/
Copy pathscript.js
File metadata and controls
117 lines (103 loc) · 5.43 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
document.addEventListener('DOMContentLoaded', () => {
const toggleDarkModeBtn = document.getElementById('toggle-dark-mode');
const increaseFontBtn = document.getElementById('increase-font');
const decreaseFontBtn = document.getElementById('decrease-font');
const resetFontBtn = document.getElementById('reset-font'); // כפתור חדש
const body = document.body;
const paragraphs = document.querySelectorAll('p'); // בחר את כל הפסקאות
// אלמנטים של תהילים
const tehilimTitle = document.getElementById('tehilim-title');
const toggleTehilimBtn = document.getElementById('toggle-tehilim-btn');
const psalm137Content = document.getElementById('psalm137-content');
const psalm126Content = document.getElementById('psalm126-content');
// קביעת שנת זכויות היוצרים הנוכחית
document.getElementById('current-year').textContent = new Date().getFullYear();
// קביעת גודל הגופן המקורי של הפסקאות (נחשב רק פעם אחת בטעינה)
// הערה: נניח שכל הפסקאות מתחילות באותו גודל גופן מ-CSS
let initialFontSize = parseFloat(getComputedStyle(paragraphs[0]).fontSize);
let currentFontSize = initialFontSize; // הגדרת גודל הגופן ההתחלתי לשימוש בפונקציות
// פונקציה לשינוי מצב כהה/בהיר
toggleDarkModeBtn.addEventListener('click', () => {
body.classList.toggle('dark-mode');
// שמירת ההעדפה של המשתמש ב-localStorage
if (body.classList.contains('dark-mode')) {
localStorage.setItem('theme', 'dark');
toggleDarkModeBtn.textContent = 'מצב בהיר'; // שינוי טקסט הכפתור
} else {
localStorage.setItem('theme', 'light');
toggleDarkModeBtn.textContent = 'מצב כהה'; // שינוי טקסט הכפתור
}
});
// טעינת העדפת המצב הכהה מ-localStorage בעת טעינת הדף
const savedTheme = localStorage.getItem('theme');
if (savedTheme === 'dark') {
body.classList.add('dark-mode');
toggleDarkModeBtn.textContent = 'מצב בהיר';
} else {
toggleDarkModeBtn.textContent = 'מצב כהה';
}
// פונקציות לשינוי גודל הגופן
const FONT_SIZE_STEP = 1.5; // כמה פיקסלים לשנות בכל לחיצה
const MIN_FONT_SIZE = 14; // גודל גופן מינימלי
const MAX_FONT_SIZE = 30; // גודל גופן מקסימלי
function applyFontSize(size) {
paragraphs.forEach(p => {
p.style.fontSize = `${size}px`;
});
localStorage.setItem('fontSize', size); // שמירת גודל הגופן
}
increaseFontBtn.addEventListener('click', () => {
if (currentFontSize < MAX_FONT_SIZE) {
currentFontSize += FONT_SIZE_STEP;
applyFontSize(currentFontSize);
}
});
decreaseFontBtn.addEventListener('click', () => {
if (currentFontSize > MIN_FONT_SIZE) {
currentFontSize -= FONT_SIZE_STEP;
applyFontSize(currentFontSize);
}
});
// כפתור איפוס גודל גופן
resetFontBtn.addEventListener('click', () => {
currentFontSize = initialFontSize; // חזרה לגודל המקורי שנקבע ב-CSS
applyFontSize(currentFontSize);
});
// טעינת גודל הגופן מ-localStorage בעת טעינת הדף
const savedFontSize = localStorage.getItem('fontSize');
if (savedFontSize) {
currentFontSize = parseFloat(savedFontSize);
applyFontSize(currentFontSize);
}
// לוגיקה של החלפת תהילים
toggleTehilimBtn.addEventListener('click', () => {
const isShowingPsalm137 = !psalm137Content.classList.contains('hidden');
if (isShowingPsalm137) {
psalm137Content.classList.add('hidden');
psalm126Content.classList.remove('hidden');
tehilimTitle.textContent = 'תהלים קכ"ו';
toggleTehilimBtn.textContent = 'אם יש תחנון לחץ כאן (תהילים קלז)';
localStorage.setItem('currentTehilim', '126');
} else {
psalm137Content.classList.remove('hidden');
psalm126Content.classList.add('hidden');
tehilimTitle.textContent = 'תהלים קלז';
toggleTehilimBtn.textContent = 'אם אין תחנון לחץ כאן (תהילים קכ"ו)';
localStorage.setItem('currentTehilim', '137');
}
});
// טעינת מצב התהילים האחרון מ-localStorage
const savedTehilim = localStorage.getItem('currentTehilim');
if (savedTehilim === '126') {
psalm137Content.classList.add('hidden');
psalm126Content.classList.remove('hidden');
tehilimTitle.textContent = 'תהלים קכ"ו';
toggleTehilimBtn.textContent = 'אם יש תחנון לחץ כאן (תהילים קלז)';
} else {
// ברירת מחדל או אם נשמר 137
psalm137Content.classList.remove('hidden');
psalm126Content.classList.add('hidden');
tehilimTitle.textContent = 'תהלים קלז';
toggleTehilimBtn.textContent = 'אם אין תחנון לחץ כאן (תהילים קכ"ו)';
}
});