This repository was archived by the owner on Mar 17, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
68 lines (61 loc) · 2.47 KB
/
Copy pathscript.js
File metadata and controls
68 lines (61 loc) · 2.47 KB
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
function copyElement(a) {
navigator.clipboard.writeText(a.innerHTML);
a.style.backgroundColor = "green";
}
function mouseut(a) {
a.style.backgroundColor = rgb(216, 216, 216);
}
var oldsearches = [];
function search() {
var thediv = document.getElementById('tableBox');
var found = 0;
let req = new XMLHttpRequest();
var IB, firstname, lastname, email, email_reversed;
nameKey = String(document.getElementById("IB").value);
if (!(/[I,B]{2}\d{6}/.test(nameKey))){document.getElementById("IB").value = "Krivi format";}
else{
if (oldsearches.includes(nameKey)){document.getElementById("IB").value = "Vec ste pretrazili to";}
else{
document.getElementById('submit').innerText = "Searching...";
req.onreadystatechange = () => {
if (req.readyState == XMLHttpRequest.DONE) {
array = JSON.parse(req.responseText)["record"];
for (var i = 0; i < array.length; i++) {
if (array[i]["IB"] === nameKey) {
IB = array[i]["IB"];
firstname = array[i]["normal"]["name"];
lastname = array[i]["normal"]["lastname"];
email = array[i]["normal"]["email"];
email_reversed = array[i]["reversed"]["email"];
found = 1;
oldsearches.push(nameKey);
document.getElementById('submit').innerText = "Search";
document.getElementById("IB").value = "";
break;
}
}
if (found){
var toaddshitto = document.getElementById("pleaseaddtheshithere");
toaddshitto.innerHTML+= `<tr>
<td><p onclick="copyElement(this)" onmouseout="mouseut(this)">${IB}</p></td>
<td><p onclick="copyElement(this)" onmouseout="mouseut(this)">${firstname}</p></td>
<td><p onclick="copyElement(this)" onmouseout="mouseut(this)">${lastname}</p></td>
<td><p onclick="copyElement(this)" onmouseout="mouseut(this)">${email}</p></td>
<td><p onclick="copyElement(this)" onmouseout="mouseut(this)">${email_reversed}</p></td>
</tr>`
thediv.style.display = "block";
}
else {
document.getElementById("IB").value = "IB nije pronađen";
}
}
}
}
};
req.open(
"GET",
"https://api.jsonbin.io/v3/b/60c0b1c992164b68bec73052/latest",
true
);
req.send();
}