Advertisement
Guest User

My JS weird shit

a guest
Aug 20th, 2018
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. window.onload = Initialize;
  2. var Input;
  3. var Output;
  4. function Initialize()
  5. {
  6.     Input = document.getElementById("Input");
  7.     Output = document.getElementById("Output");
  8.     Input.oninput = GetEmotes;
  9. }
  10. function GetEmotes()
  11. {
  12.     var TempResults = [];
  13.     for (var i = Output.children.length - 1; i >= 0; i--)
  14.     {
  15.         if (!Output.children[i].value.includes(Input.value) || Input.value == "")
  16.         {
  17.             console.log(Output.children[i]);
  18.             console.log(Output.children.length);
  19.             Output.remove(Output.children[i]);
  20.         }
  21.         else
  22.         {
  23.             TempResults.push(Output.children[i].value);
  24.         }
  25.     }
  26.     if (Input.value != "")
  27.     {
  28.         for (var key in emotes)
  29.         {
  30.             if (key.includes(Input.value.toLowerCase()) && TempResults.indexOf(key) === -1)
  31.             {
  32.                 var NewButton = document.createElement("button");
  33.                 NewButton.value = key;
  34.                 NewButton.innerText = emotes[key];
  35.                 NewButton.onclick = Paste;
  36.                 Output.appendChild(NewButton);
  37.             }
  38.         }
  39.     }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement