Upload
This commit is contained in:
54
js/settings.js
Normal file
54
js/settings.js
Normal file
@ -0,0 +1,54 @@
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
const youtubeIdInput = document.getElementById('youtube-id');
|
||||
const youtubePlayer = document.getElementById('youtubePlayer');
|
||||
const loopToggle = document.getElementById('loop-toggle');
|
||||
|
||||
// Betöltjük a mentett beállításokat
|
||||
const savedYoutubeId = localStorage.getItem('youtubeId');
|
||||
const savedLoop = localStorage.getItem('loop');
|
||||
|
||||
if (savedYoutubeId) {
|
||||
youtubeIdInput.value = savedYoutubeId;
|
||||
let url = `https://www.youtube.com/embed/${savedYoutubeId}?autoplay=1`;
|
||||
if (savedLoop === 'true') {
|
||||
url += '&loop=1';
|
||||
loopToggle.checked = true;
|
||||
} else {
|
||||
loopToggle.checked = false;
|
||||
}
|
||||
youtubePlayer.src = url;
|
||||
}
|
||||
document.getElementById('reset-music').addEventListener('click', () => {
|
||||
localStorage.setItem('youtubeId', '');
|
||||
youtubePlayer.src = '';
|
||||
youtubeIdInput.value = '';
|
||||
//alert('YouTube ID törölve!');
|
||||
});
|
||||
document.getElementById('save-music').addEventListener('click', () => {
|
||||
const youtubeId = youtubeIdInput.value.trim();
|
||||
if (youtubeId) {
|
||||
let url = `https://www.youtube.com/embed/${youtubeId}?autoplay=1`;
|
||||
if (loopToggle.checked) {
|
||||
url += '&loop=1';
|
||||
}
|
||||
youtubePlayer.src = url;
|
||||
localStorage.setItem('youtubeId', youtubeId);
|
||||
localStorage.setItem('loop', loopToggle.checked);
|
||||
//alert('YouTube ID elmentve!');
|
||||
} else {
|
||||
//alert('Kérlek, add meg a YouTube ID-t!');
|
||||
}
|
||||
});
|
||||
|
||||
loopToggle.addEventListener('change', () => {
|
||||
const youtubeId = youtubeIdInput.value.trim();
|
||||
if (youtubeId) {
|
||||
let url = `https://www.youtube.com/embed/${youtubeId}?autoplay=1`;
|
||||
if (loopToggle.checked) {
|
||||
url += '&loop=1';
|
||||
}
|
||||
youtubePlayer.src = url;
|
||||
localStorage.setItem('loop', loopToggle.checked);
|
||||
}
|
||||
});
|
||||
});
|
Reference in New Issue
Block a user