forked from FoxRefire/wvg
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpopup_drawList.js
49 lines (43 loc) · 2.02 KB
/
popup_drawList.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
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';
}
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';
}
document.getElementById('psshButton').addEventListener("click", selectPssh);
document.getElementById('licenseButton').addEventListener("click", selectRequest);
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);
}
});
}
var userInputs={};
function drawList(arrElements,searchBoxElmId,listElmId,outputVar) {
const searchBox = document.getElementById(searchBoxElmId);
const list = document.getElementById(listElmId);
writeListElement(arrElements, list, outputVar, null)
searchBox.addEventListener('input', (event) => {
const searchValue = event.target.value.toLowerCase();
writeListElement(arrElements, list, outputVar, searchValue)
});
}