wvg/popup_drawList.js

50 lines
2.0 KiB
JavaScript
Raw Normal View History

2024-04-24 18:41:58 +00:00
function selectPssh(){
document.getElementById('home').style.display='none';
document.getElementById('selectPssh').style.display='grid';
document.getElementById('psshList').style.display='grid';
document.getElementById('toggleHistory').style.display='none';
2024-04-24 18:41:58 +00:00
}
function selectRequest(){
document.getElementById('home').style.display='none';
document.getElementById('selectRequest').style.display='grid';
document.getElementById('requestList').style.display='grid';
document.getElementById('toggleHistory').style.display='none';
2024-04-24 18:41:58 +00:00
}
document.getElementById('psshButton').addEventListener("click", selectPssh);
document.getElementById('licenseButton').addEventListener("click", selectRequest);
2024-06-25 01:43:09 +00:00
function writeListElement(arrElements, list, outputVar, search) {
list.innerHTML = '';
arrElements.forEach((element, index) => {
if (!search || element.includes(searchValue)) {
const li = document.createElement('li');
li.textContent = element;
li.addEventListener('click', () => {
userInputs[outputVar]=index;
document.getElementById(outputVar).value=element;
document.getElementById(outputVar+'Index').value=index;
document.getElementById('selectPssh').style.display='none';
document.getElementById('selectRequest').style.display='none';
document.getElementById('home').style.display='grid';
document.getElementById('toggleHistory').style.display='grid';
});
list.appendChild(li);
}
});
}
2024-04-12 21:05:09 +00:00
var userInputs={};
2024-06-25 01:43:09 +00:00
function drawList(arrElements,searchBoxElmId,listElmId,outputVar) {
const searchBox = document.getElementById(searchBoxElmId);
const list = document.getElementById(listElmId);
2024-06-25 01:43:09 +00:00
writeListElement(arrElements, list, outputVar, null)
searchBox.addEventListener('input', (event) => {
const searchValue = event.target.value.toLowerCase();
2024-06-25 01:43:09 +00:00
writeListElement(arrElements, list, outputVar, searchValue)
});
}