-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
91 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
document.addEventListener("DOMContentLoaded", function () { | ||
// Get elements | ||
const textColorInput = document.getElementById("text-color"); | ||
const weatherWidget = document.getElementById("weather-widget"); | ||
const weatherDetails = weatherWidget ? weatherWidget.querySelectorAll("*") : []; // All nested elements in weather widget | ||
const quickLinksDiv = document.getElementById("quick-links-section"); | ||
const quickLinks = quickLinksDiv ? quickLinksDiv.querySelectorAll("a") : []; | ||
const clock = document.getElementById("clock"); | ||
const searchInput = document.getElementById("search-query"); | ||
|
||
// Get settings and quicklinks icons | ||
const settingsIcon = document.getElementById("settings-icon"); | ||
const quicklinksIcon = document.getElementById("quicklinks-icon"); | ||
|
||
// Get Save button | ||
const saveSettingsButton = document.getElementById("save-settings"); | ||
|
||
// Load existing text color from localStorage | ||
const existingTextColor = localStorage.getItem("textColor") || "#FFFFFF"; | ||
|
||
// Apply the existing text color on page load | ||
applyTextColor(existingTextColor); | ||
textColorInput.value = existingTextColor; | ||
|
||
// Listen for Save button click to apply and save the color | ||
saveSettingsButton.addEventListener("click", () => { | ||
const newColor = textColorInput.value.trim(); | ||
if (newColor) { | ||
applyTextColor(newColor); | ||
localStorage.setItem("textColor", newColor); // Save to localStorage | ||
} | ||
}); | ||
|
||
/** | ||
* Function to apply text color to specific elements on the page | ||
* @param {string} color | ||
*/ | ||
function applyTextColor(color) { | ||
if (weatherWidget) { | ||
weatherWidget.style.setProperty("color", color, "important"); | ||
weatherDetails.forEach(el => el.style.setProperty("color", color, "important")); | ||
} | ||
|
||
// Apply color to clock (time) | ||
if (clock) { | ||
clock.style.setProperty("color", color, "important"); | ||
} | ||
|
||
// Apply color to search bar text | ||
if (searchInput) { | ||
searchInput.style.setProperty("color", color, "important"); | ||
} | ||
|
||
// Apply color to quick links (individual links within the section) | ||
quickLinks.forEach(link => { | ||
link.style.color = color; | ||
}); | ||
|
||
// Apply color to all H1 elements | ||
const h1Elements = document.querySelectorAll("h1"); | ||
h1Elements.forEach(h1 => { | ||
h1.style.setProperty("color", color, "important"); | ||
}); | ||
|
||
// Apply color to Settings and QuickLinks icons | ||
if (settingsIcon) { | ||
settingsIcon.style.setProperty("color", color, "important"); | ||
} | ||
if (quicklinksIcon) { | ||
quicklinksIcon.style.setProperty("color", color, "important"); | ||
} | ||
} | ||
}); |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters