diff --git a/popup.html b/popup.html index 8c86dff..a8c8035 100644 --- a/popup.html +++ b/popup.html @@ -57,4 +57,5 @@ + diff --git a/popup.js b/popup.js index 3f3c53d..9f816b6 100644 --- a/popup.js +++ b/popup.js @@ -2,46 +2,6 @@ let psshs=chrome.extension.getBackgroundPage().getPsshs(); let requests=chrome.extension.getBackgroundPage().getRequests(); let userInputs={}; -function drawList(arr,_searchBox,_list,_userInputs){ - const elements = arr; - const searchBox = document.getElementById(_searchBox); - const list = document.getElementById(_list); - - elements.forEach((element, index) => { - const li = document.createElement('li'); - li.textContent = element; - li.addEventListener('click', () => { - userInputs[_userInputs]=index; - document.getElementById(_userInputs).value=element; - document.getElementById(_userInputs+'Index').value=index; - document.getElementById('selectPssh').style.display='none'; - document.getElementById('selectRequest').style.display='none'; - document.getElementById('home').style.display='block'; - }); - list.appendChild(li); - }); - - searchBox.addEventListener('input', (event) => { - const searchValue = event.target.value.toLowerCase(); - list.innerHTML = ''; - elements.forEach((element, index) => { - if (element.toLowerCase().includes(searchValue)) { - const li = document.createElement('li'); - li.textContent = element; - li.addEventListener('click', () => { - userInputs[_userInputs]=index; - document.getElementById(_userInputs).value=element; - document.getElementById(_userInputs+'Index').value=index; - document.getElementById('selectPssh').style.display='none'; - document.getElementById('selectRequest').style.display='none'; - document.getElementById('home').style.display='block'; - }); - list.appendChild(li); - } - }); - }); -} - function selectPssh(){ document.getElementById('home').style.display='none'; document.getElementById('selectPssh').style.display='block'; diff --git a/popup_drawList.js b/popup_drawList.js new file mode 100644 index 0000000..6038ead --- /dev/null +++ b/popup_drawList.js @@ -0,0 +1,39 @@ +function drawList(arr,_searchBox,_list,_userInputs){ + const elements = arr; + const searchBox = document.getElementById(_searchBox); + const list = document.getElementById(_list); + + elements.forEach((element, index) => { + const li = document.createElement('li'); + li.textContent = element; + li.addEventListener('click', () => { + userInputs[_userInputs]=index; + document.getElementById(_userInputs).value=element; + document.getElementById(_userInputs+'Index').value=index; + document.getElementById('selectPssh').style.display='none'; + document.getElementById('selectRequest').style.display='none'; + document.getElementById('home').style.display='block'; + }); + list.appendChild(li); + }); + + searchBox.addEventListener('input', (event) => { + const searchValue = event.target.value.toLowerCase(); + list.innerHTML = ''; + elements.forEach((element, index) => { + if (element.toLowerCase().includes(searchValue)) { + const li = document.createElement('li'); + li.textContent = element; + li.addEventListener('click', () => { + userInputs[_userInputs]=index; + document.getElementById(_userInputs).value=element; + document.getElementById(_userInputs+'Index').value=index; + document.getElementById('selectPssh').style.display='none'; + document.getElementById('selectRequest').style.display='none'; + document.getElementById('home').style.display='block'; + }); + list.appendChild(li); + } + }); + }); +}