57 lines
2.1 KiB
JavaScript
57 lines
2.1 KiB
JavaScript
// function showPopup(movie_name) {
|
|
// var alert = "Sending download request for " + movie_name + "\n\n" + "Press OK to continue."
|
|
// window.alert(alert);
|
|
// }
|
|
|
|
document.addEventListener("DOMContentLoaded", function() {
|
|
var inputField = document.getElementById("searchDropdown");
|
|
var searchButton = document.getElementById("searchButton");
|
|
var matches = document.getElementById("matches");
|
|
var dropSearch = document.getElementById("dropSearch");
|
|
|
|
// window.addEventListener('scroll', () => {
|
|
// dropSearch.style.display = 'none';
|
|
// });
|
|
|
|
// Add a click event listener to the element
|
|
searchButton.addEventListener("click", function() {
|
|
// Toggle the 'display' style property
|
|
if (dropSearch.style.display === "none") {
|
|
dropSearch.style.display = "unset";
|
|
matches.style.display = "none";
|
|
} else {
|
|
dropSearch.style.display = "none";
|
|
matches.style.display = "unset";
|
|
}
|
|
});
|
|
|
|
searchButton.addEventListener("click", function() {
|
|
inputField.focus(); // Activate the input field
|
|
});
|
|
});
|
|
|
|
$(document).ready(function () {
|
|
$('.download-link').click(function (event) {
|
|
event.preventDefault(); // Prevent the default link behavior
|
|
|
|
var url = $(this).data('url');
|
|
var filename = $(this).data('filename');
|
|
var clickedLink = $(this);
|
|
|
|
// Use AJAX to download the file and save it with the provided filename
|
|
$.ajax({
|
|
type: 'GET',
|
|
url: '/download',
|
|
data: { url: url, filename: filename },
|
|
success: function (response) {
|
|
alert(response); // Display a message indicating success or failure
|
|
clickedLink.addClass('resolution_exists');
|
|
clickedLink.removeClass('resolution_available');
|
|
clickedLink.removeClass('download-link');
|
|
},
|
|
error: function () {
|
|
alert('Error downloading the file.');
|
|
}
|
|
});
|
|
});
|
|
}); |