-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
46 lines (41 loc) · 1.36 KB
/
script.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
document.addEventListener("DOMContentLoaded", function() {
const searchInput = document.getElementById("searchInput");
const searchButton = document.getElementById("searchButton");
const resultsBody = document.getElementById("resultsBody");
const loader = document.getElementById("loader");
function showLoader() {
loader.style.display = "block";
}
function hideLoader() {
loader.style.display = "none";
}
function fetchData(searchTerm) {
showLoader();
fetch(`https://api.proxynova.com/comb?query=${searchTerm}`)
.then(response => response.json())
.then(data => {
resultsBody.innerHTML = "";
data.lines.forEach(line => {
const [email, password] = line.split(":");
const tr = document.createElement("tr");
tr.innerHTML = `<td>${email}</td><td>${password}</td>`;
resultsBody.appendChild(tr);
});
hideLoader();
})
.catch(error => {
console.error('Error fetching data:', error);
hideLoader();
});
}
searchButton.addEventListener("click", function() {
const searchTerm = searchInput.value.toLowerCase();
fetchData(searchTerm);
});
searchInput.addEventListener("keypress", function(event) {
if (event.key === "Enter") {
const searchTerm = searchInput.value.toLowerCase();
fetchData(searchTerm);
}
});
});