Skip to content
TheChatArchiveThe Chat Archive
gpt-4-0314· OpenAIAi2 WildChat-4.8M (AI2)

Подсказки с городами не работают (автокомплит): <!DOCTYPE html> <html> <head> <title><%=…

  1. User

    Подсказки с городами не работают (автокомплит):

     <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>
    

    $("#city").autocomplete({ source: '/autocomplete/cities', minLength: 1, });

    const queryInput = document.querySelector("#query"); const roleInput = document.querySelector("#role"); const cityInput = document.querySelector("#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;

  2. Assistant

    It seems like there might be an issue with the path of the JavaScript and CSS files for the jQuery UI. Try using the jQuery UI files from a CDN instead. Replace these lines:

    <!-- jQuery UI CSS -->
    <link rel="stylesheet" href="/jquery-ui/themes/base/all.css" />
    <!-- jQuery UI JS -->
    <script src="/jquery-ui/dist/jquery-ui.min.js"></script>
    

    With these lines:

    <!-- jQuery UI CSS -->
    <link rel="stylesheet" href="https://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css" />
    <!-- jQuery UI JS -->
    <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.min.js"></script>
    

    Your updated <head> section will look like this:

    <head>
      <title><%= musician.name %> - Musician Profile</title>
      <!-- Bootstrap CSS -->
      <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
      <!-- jQuery -->
      <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
      <!-- Popper.js -->
      <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js"></script>
      <!-- Bootstrap JS -->
      <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
      <!-- jQuery UI CSS -->
      <link rel="stylesheet" href="https://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css" />
      <!-- Custom CSS -->
      <link rel="stylesheet" href="/css/main.css" />
      <!-- jQuery UI JS -->
      <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.min.js"></script>
    </head>
    

    After making these changes, the autocomplete functionality should work correctly.

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.