summaryrefslogtreecommitdiff
path: root/assets/js/settings.js
diff options
context:
space:
mode:
Diffstat (limited to 'assets/js/settings.js')
-rw-r--r--assets/js/settings.js79
1 files changed, 0 insertions, 79 deletions
diff --git a/assets/js/settings.js b/assets/js/settings.js
deleted file mode 100644
index 6dcbdfa9..00000000
--- a/assets/js/settings.js
+++ /dev/null
@@ -1,79 +0,0 @@
-(() => {
- /**
- * ===========================
- * Initialize Settings Page
- * ===========================
- */
-
- // return if this is not the settings page
- if (!document.getElementById('settings')) return;
-
- const initializeSettingsPage = () => {
- // initialize text altering buttons
- function initTextAlterButtons() {
- const textAlterButtons = document.querySelectorAll('#text-alter-buttons button');
- textAlterButtons.forEach(button => {
- // highlight selected button
- if (button.dataset.textSize === localStorage.getItem('geedeapro.ui.fontSize')) {
- button.classList.add('bg-neutral-200/50', 'dark:bg-neutral-700/50');
- }
-
- // switch font size when clicked
- button.addEventListener('click', () => {
- setFontSize(button.dataset.textSize);
- // highlight selected button
- textAlterButtons.forEach(btn => btn.classList.remove('bg-neutral-200/50', 'dark:bg-neutral-700/50'));
- button.classList.add('bg-neutral-200/50', 'dark:bg-neutral-700/50');
- });
- });
- }
- initTextAlterButtons()
-
- // initialize checkbox options
- function initCheckboxes() {
- const checkboxOptions = [
- {
- id: 'hideBatrick',
- label: '隐藏 Batrick(返回顶部按钮)',
- storage: 'geedeapro.ui.hideBatrick',
- default: 'false'
- }
- ]
-
- checkboxOptions.forEach(checkboxOption => {
- // create checkbox
- const element = document.createElement('input');
- element.type = 'checkbox';
- element.id = checkboxOption.id;
- element.checked = localStorage.getItem(checkboxOption.storage) ||
- checkboxOption.default === 'true';
-
- // add event listener to checkbox
- element.addEventListener('change', () => {
- if (element.checked)
- localStorage.setItem(checkboxOption.storage, 1);
- else
- localStorage.removeItem(checkboxOption.storage);
- });
-
- // create label
- const label = document.createElement('label');
- label.htmlFor = element.id;
- label.textContent = checkboxOption.label;
-
- // wrap checkbox and label in a div
- const wrapper = document.createElement('div');
- wrapper.classList.add('flex', 'items-center', 'mb-2', 'gap-2');
- wrapper.appendChild(element);
- wrapper.appendChild(label);
-
- // append checkbox and label to container
- const container = document.getElementById('checkbox-options');
- container.appendChild(wrapper);
- });
- }
- initCheckboxes();
- };
-
- initializeSettingsPage();
-})();