diff --git a/App/Public/js/addArtist.js b/App/Public/js/addArtist.js index bd4d96ca720feba3bb0704e83aeecc4421a5d02f..88abb11354a8df1313fe5185127efbbb16dd01e5 100644 --- a/App/Public/js/addArtist.js +++ b/App/Public/js/addArtist.js @@ -15,6 +15,11 @@ function openAddModal(e) { function addArtist(e) { e.preventDefault(); // closeAddModal(e); + var confirmation = confirm("Do you want to add this artist?"); + + if (!confirmation) { + return; + } artistName = document.getElementById('add-artistName').value; description = document.getElementById('add-description').value; console.log(description) @@ -26,7 +31,7 @@ function addArtist(e) { if (artistName === "") { document.getElementById('info-add').textContent = "Artist name must not empty."; - return + return; } if (description === "") { @@ -64,6 +69,7 @@ function addArtist(e) { function addNewArtist (data) { console.log(data); + const container = document.createElement("div"); container.className = "artist-container"; container.id = "container-" + data['artistID']; diff --git a/App/Public/js/addMusic.js b/App/Public/js/addMusic.js index 801239a2c9769ff4038f9e4252db561e52e2c115..401462c7d1d02e5d577eeed18dc35f28dfbe4780 100644 --- a/App/Public/js/addMusic.js +++ b/App/Public/js/addMusic.js @@ -11,7 +11,7 @@ function openAddModal(e) { function addMusic(e) { e.preventDefault(); - + title = document.getElementById('m-title').value; genre = document.getElementById('m-filter-genre').value; artist = document.getElementById('m-filter-artist').value; @@ -30,37 +30,40 @@ function addMusic(e) { console.log(audio) if (title !== "" && genre !== "" && coverImage !== "" && audio !== "" && artist !== "") { - console.log("send!") - const xhr = new XMLHttpRequest(); - xhr.open('POST', 'http://localhost/MusicControl/addMusic'); - - const data = new FormData(); - data.append('title', title); - data.append('genre', genre); - data.append('coverImage', coverImage); - data.append('audio', audio); - data.append('artist', artist); + var confirmation = confirm("Do you want to add the new song?"); + + if (confirmation) { + const xhr = new XMLHttpRequest(); + xhr.open('POST', 'http://localhost/MusicControl/addMusic'); + + const data = new FormData(); + data.append('title', title); + data.append('genre', genre); + data.append('coverImage', coverImage); + data.append('audio', audio); + data.append('artist', artist); - console.log(data) - xhr.send(data); - // closeAddModal(e); - xhr.onreadystatechange = () => { - if (xhr.readyState === XMLHttpRequest.DONE) { - if (xhr.status === 400){ - var response = JSON.parse(xhr.responseText); - document.getElementById('m-info').textContent = response['message']; - } else if (xhr.status === 200){ - var response = JSON.parse(xhr.responseText); - addNewSong(response); - document.getElementById('add-modal').style.visibility = "hidden"; + console.log(data) + xhr.send(data); + // closeAddModal(e); + xhr.onreadystatechange = () => { + if (xhr.readyState === XMLHttpRequest.DONE) { + if (xhr.status === 400){ + var response = JSON.parse(xhr.responseText); + document.getElementById('m-info').textContent = response['message']; + } else if (xhr.status === 200){ + var response = JSON.parse(xhr.responseText); + addNewSong(response); + document.getElementById('add-modal').style.visibility = "hidden"; - document.getElementById('m-title').value = ""; - document.getElementById('m-filter-genre').value = ""; - document.getElementById('m-filter-artist').value = ""; - document.getElementById('m-coverImage').value = ""; - document.getElementById('m-audio').value = ""; - - + document.getElementById('m-title').value = ""; + document.getElementById('m-filter-genre').value = ""; + document.getElementById('m-filter-artist').value = ""; + document.getElementById('m-coverImage').value = ""; + document.getElementById('m-audio').value = ""; + + + } } } } diff --git a/App/Public/js/deleteUser.js b/App/Public/js/deleteUser.js index 0518ae51477f55a4b5bd24b0dcc10e111d3b7f7f..027fcea45e7be9f435142f33fefb045e112867c8 100644 --- a/App/Public/js/deleteUser.js +++ b/App/Public/js/deleteUser.js @@ -1,26 +1,32 @@ function closeModalDelete (event) { event.preventDefault(); - document.getElementById('delete-modal').style.visibility = "hidden"; - console.log("test"); + document.getElementById('delete-modal').style.visibility = "hidden" } function openModalDelete(event) { event.preventDefault(); document.getElementById('delete-modal').style.visibility = "visible"; + const submitButton = document.getElementById("delete-btn"); + submitButton.style.backgroundColor = "grey"; + const inputField = document.getElementById("confirm-delete"); + inputField.value=""; } -// Get references to the input field and the button +// Get to the input field and the button const inputField = document.getElementById("confirm-delete"); const submitButton = document.getElementById("delete-btn"); -// Add an input event listener to the input field -inputField.addEventListener("input", function() { - - // Check if the input value is "DELETE" and enable/disable the button accordingly +// update button style +function updateButtonStyle() { if (inputField.value === "DELETE") { submitButton.disabled = false; submitButton.style.backgroundColor = "#E85555"; } else { submitButton.disabled = true; + submitButton.style.backgroundColor = "grey"; } -}); \ No newline at end of file +} + + +inputField.addEventListener("input", updateButtonStyle); +inputField.addEventListener("blur", updateButtonStyle); \ No newline at end of file diff --git a/App/Public/js/editArtist.js b/App/Public/js/editArtist.js index 11df57785b4cd6fecf0c091a060ff13e3a436f45..d8b684ae13c22bba53f73abfe8f89db6e782dd1b 100644 --- a/App/Public/js/editArtist.js +++ b/App/Public/js/editArtist.js @@ -22,6 +22,13 @@ function openEditModal(e, id) { function save(e) { e.preventDefault(); + + var confirmation = confirm("Do you want to change it?"); + + if (!confirmation) { + return; + } + info = document.getElementById('info-edit'); artistName = document.getElementById('artistName').value; if (artistName === "") { diff --git a/App/Public/js/editMusic.js b/App/Public/js/editMusic.js index 5bfa571e980ec14178232f29d15decf7cfdcc556..a4eea31998e967615f3542a59ca22a2cfe39311d 100644 --- a/App/Public/js/editMusic.js +++ b/App/Public/js/editMusic.js @@ -18,6 +18,11 @@ function closeEditModal(e) { function save(e) { e.preventDefault(); + var confirmation = confirm("Do you want to change it?"); + + if (!confirmation) { + return; + } title = document.getElementById('title').value; songID = document.getElementById('song-id').textContent; genre = document.getElementById('filter-genre').value; diff --git a/App/Public/js/editProfile.js b/App/Public/js/editProfile.js index 80b7b5c6de43af154ad5f9ce4d88ba3407d21cd5..53414ecc74319b71dec1912706e5424daa94e36f 100644 --- a/App/Public/js/editProfile.js +++ b/App/Public/js/editProfile.js @@ -14,6 +14,12 @@ function editProfile(event, username) { console.log(bio) console.log(username) + var confirmation = confirm("Do you want to change your profile?"); + + if (!confirmation) { + return; + } + const xhr = new XMLHttpRequest(); xhr.open('POST', 'http://localhost/Profile/editProfile'); @@ -25,6 +31,7 @@ function editProfile(event, username) { xhr.send(data); + xhr.onreadystatechange = () => { if (xhr.readyState === 4) { const response = JSON.parse(xhr.responseText); @@ -32,9 +39,8 @@ function editProfile(event, username) { $msg.textContent = response['message']; if (xhr.status === 200) { + $msg.style.color = "white"; - console.log("http://localhost/App/Public/image/profile/" + image); - console.log(document.getElementsByClassName('nav-profile').src) if (image) { document.getElementById('profile-img-1').src = "http://localhost/App/Public/image/profile/" + image; document.getElementById('profile-img-2').src = "http://localhost/App/Public/image/profile/" + image;