-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscripts.js
97 lines (90 loc) · 2.8 KB
/
scripts.js
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
// dark-mode.js
(function() {
if (!window.darkModeInitialized) {
document.addEventListener('DOMContentLoaded', function() {
chrome.storage.local.get(['darkMode'], function(result) {
if (result.darkMode) {
document.body.classList.add('dark-mode');
}
});
});
window.darkModeInitialized = true;
}
})();
// default-page.js
(function() {
if (!window.defaultPageInitialized) {
document.addEventListener('DOMContentLoaded', function() {
const currentPath = window.location.pathname;
if (currentPath === '/popup.html') {
const urlParams = new URLSearchParams(window.location.search);
const fromDash = urlParams.get('fromDash');
if (window.SidePanelAPI) {
document.body.classList.add('panel-open');
}
chrome.storage.local.get(['defaultPage'], function(result) {
if (result.defaultPage && !fromDash) {
window.location.replace(result.defaultPage);
}
});
}
});
window.defaultPageInitialized = true;
}
})();
// include-links.js
(function() {
if (!window.includeLinksInitialized) {
document.addEventListener('DOMContentLoaded', function() {
const navContainer = document.getElementById('nav-container');
if (navContainer) {
fetch('links.html')
.then(response => response.text())
.then(data => {
navContainer.innerHTML = data;
const links = navContainer.querySelectorAll('.nav-list-item');
const currentUrl = window.location.href;
links.forEach(link => {
if (link.href === currentUrl) {
link.classList.add('current-page');
}
});
})
.catch(error => console.error('Error loading navigation:', error));
} else {
console.error('Navigation container not found.');
}
});
window.includeLinksInitialized = true;
}
})();
// header.js
(function() {
document.addEventListener('DOMContentLoaded', function() {
fetch('header.html')
.then(response => response.text())
.then(data => {
const headerContainer = document.getElementById('header-container');
headerContainer.innerHTML = data;
})
.catch(error => console.error('Error loading header:', error));
function checkSidePanel() {
if (window.innerHeight >= 601) {
document.body.classList.add('panel-open');
} else {
document.body.classList.remove('panel-open');
}
}
checkSidePanel();
if (!window.listenerAdded) {
window.addEventListener('resize', checkSidePanel);
window.listenerAdded = true;
}
});
})();
// translate.js
(function() {
document.addEventListener('DOMContentLoaded', function() {
initializeTranslations();
});
})();