Подсказка с городами не работает в модальном окне в profile.ejs: <!DOCTYPE html> <html>…
- User
Подсказка с городами не работает в модальном окне в profile.ejs:
<script>const modal = document.getElementById("edit-profile-modal"); const btn = document.getElementsByTagName("a")[0]; const span = document.getElementsByClassName("close")[0];
btn.onclick = function() { modal.style.display = "block"; } span.onclick = function() { modal.style.display = "none"; } window.onclick = function(event) { if (event.target == modal) { modal.style.display = "none"; } } //скрыть плеер, если ссылка не внесена const song1Input = document.getElementById("soundcloud");const song2Input = document.getElementById("soundcloud1"); const player1 = document.getElementsByTagName('iframe')[0]; const player2 = document.getElementsByTagName('iframe')[1]; let songs = { song: "", song1: "" }
function hidePlayer(player) { player.src = ""; player.style.display = "none"; }
function updateSongs() { songs.song = song1Input.value.trim(); songs.song1 = song2Input.value.trim(); }
function updatePlayers() { if (songs.song !== "") { player1.src =
https://w.soundcloud.com/player/?url=${songs.song}&color=%23ff5500&auto_play=false&hide_related=false&show_comments=true&show_user=true&show_reposts=false&show_teaser=true&visual=true; player1.style.display = "block"; } else { hidePlayer(player1); }if (songs.song1 !== "") { player2.src =
https://w.soundcloud.com/player/?url=${songs.song1}&color=%23ff5500&auto_play=false&hide_related=false&show_comments=true&show_user=true&show_reposts=false&show_teaser=true&visual=true; player2.style.display = "block"; } else { hidePlayer(player2); } }song1Input.addEventListener("input", function() { updateSongs(); updatePlayers(); });
song2Input.addEventListener("input", function() { updateSongs(); updatePlayers(); });
updateSongs(); updatePlayers(); //Валидация ссылок с soundcloud function updatePlayers() { if (isValidSoundcloudUrl(songs.song)) { player1.src =
https://w.soundcloud.com/player/?url=${songs.song}&color=%23ff5500&auto_play=false&hide_related=false&show_comments=true&show_user=true&show_reposts=false&show_teaser=true&visual=true; player1.style.display = "block"; } else { hidePlayer(player1); }if (isValidSoundcloudUrl(songs.song1)) { player2.src =
https://w.soundcloud.com/player/?url=${songs.song1}&color=%23ff5500&auto_play=false&hide_related=false&show_comments=true&show_user=true&show_reposts=false&show_teaser=true&visual=true; player2.style.display = "block"; } else { hidePlayer(player2); } }function isValidSoundcloudUrl(url) { const regex = /^https?://(soundcloud.com|snd.sc)/(.*)/; return regex.test(url); } </script> <script> btn.onclick = function() { modal.style.display = "block"; initAutocomplete(); } function initAutocomplete() { ("input[name='city']").autocomplete({ source: '/autocomplete/cities', minLength: 1, }); } const queryInput = document.querySelector("#query"); const roleInput = document.querySelector("#role"); const cityInput = document.querySelector("input[name='city']");
queryInput.value = "<%= query %>"; roleInput.value = "<%= role %>"; cityInput.value = cityInput.getAttribute('data-value');
const query = queryInput.value; const role = roleInput.value; const city = cityInput.value;
- Assistant
Вы забыли добавить ссылку на jQuery UI в раздел :
<script src="https://code.jquery.com/jquery-1.12.4.js"></script> <link rel="stylesheet" href="https://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css"> <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>Добавьте этот блок вместо существующего блока
<link rel="stylesheet" href="/jquery-ui/themes/base/all.css" />и<script src="/jquery-ui/dist/jquery-ui.min.js"></script>и попробуйте еще раз.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.