-
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
10 changed files
with
545 additions
and
285 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
// modal.js | ||
function initializeModal() { | ||
const elements = { | ||
settingsIcon: document.getElementById('settingsIcon'), | ||
settingsModal: document.getElementById('settingsModal'), | ||
closeModal: document.getElementById('closeModal'), | ||
categoryLinks: document.querySelectorAll('.modal-sidebar li'), | ||
categories: document.querySelectorAll('.settings-category') | ||
}; | ||
|
||
// Open the modal when the settings icon is clicked | ||
elements.settingsIcon.addEventListener('click', () => { | ||
elements.settingsModal.style.display = 'block'; | ||
}); | ||
|
||
// Close the modal when the close button is clicked | ||
elements.closeModal.addEventListener('click', () => { | ||
elements.settingsModal.style.display = 'none'; | ||
}); | ||
|
||
// Close the modal when clicking outside of the modal content | ||
window.addEventListener('click', (event) => { | ||
// Check if the click was outside the modal content | ||
if (event.target === elements.settingsModal) { | ||
elements.settingsModal.style.display = 'none'; | ||
} | ||
}); | ||
|
||
// Handle category link clicks | ||
elements.categoryLinks.forEach(link => { | ||
link.addEventListener('click', () => { | ||
const category = link.getAttribute('data-category'); | ||
elements.categories.forEach(cat => { | ||
cat.style.display = 'none'; | ||
}); | ||
document.getElementById(category).style.display = 'block'; | ||
}); | ||
}); | ||
|
||
// Set default category | ||
document.querySelector('.modal-sidebar li[data-category="pomodoro"]').click(); | ||
} | ||
|
||
// Function to change background image (if needed) | ||
function changeBackgroundImage(imageName) { | ||
const backgroundImage = `url('bg/${imageName}')`; | ||
document.body.style.backgroundImage = backgroundImage; | ||
} | ||
|
||
// Initialize the modal when the DOM is fully loaded | ||
document.addEventListener('DOMContentLoaded', initializeModal); | ||
|
||
// Fullscreen functionality | ||
const fullscreenIcon = document.getElementById('fullscreenIcon'); | ||
|
||
fullscreenIcon.addEventListener('click', () => { | ||
if (!document.fullscreenElement) { | ||
document.documentElement.requestFullscreen().catch(err => { | ||
console.error(`Error attempting to enable full-screen mode: ${err.message} (${err.name})`); | ||
}); | ||
} else { | ||
document.exitFullscreen(); | ||
} | ||
}); |
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,32 @@ | ||
// spotify.js | ||
function initializeSpotify() { | ||
const spotifyIframe = document.querySelector('.spotify-widget iframe'); | ||
const playlistLinkInput = document.getElementById('playlistLink'); | ||
const updatePlaylistButton = document.getElementById('updatePlaylist'); | ||
|
||
// Add event listener to the update button | ||
updatePlaylistButton.addEventListener('click', () => { | ||
updateSpotifyPlaylist(spotifyIframe, playlistLinkInput); | ||
}); | ||
} | ||
|
||
// Function to update the Spotify playlist | ||
function updateSpotifyPlaylist(spotifyIframe, playlistLinkInput) { | ||
const playlistLink = playlistLinkInput.value.trim(); | ||
if (playlistLink) { | ||
// Extract the playlist ID from the link | ||
const playlistIdMatch = playlistLink.match(/playlist\/([a-zA-Z0-9]+)/); | ||
if (playlistIdMatch) { | ||
const playlistId = playlistIdMatch[1]; | ||
// Update the iframe source | ||
spotifyIframe.src = `https://open.spotify.com/embed/playlist/${playlistId}?utm_source=generator&theme=black`; | ||
} else { | ||
alert('Please enter a valid Spotify playlist link.'); | ||
} | ||
} else { | ||
alert('Please enter a playlist link.'); | ||
} | ||
} | ||
|
||
// Initialize Spotify functionality on DOMContentLoaded | ||
document.addEventListener('DOMContentLoaded', initializeSpotify); |
Oops, something went wrong.