This repository was archived by the owner on Aug 31, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsearch.js
More file actions
54 lines (49 loc) · 2.06 KB
/
search.js
File metadata and controls
54 lines (49 loc) · 2.06 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
function search() {
let position = document.getElementById("pos").value;
let frame = document.getElementById("frame").value;
let stick = document.getElementById("stick").value;
let selected = document.getElementById("zvalue").checked
console.log(position, frame, stick, selected);
let file = selected ? "./dictionary-z.txt" : "./dictionary.txt";
fetch(file)
.then(response => response.text())
.then(matches => {
if (frame !== "any") {
let frameregex;
if (frame == 1 && selected) {
frameregex = /^.*JONESZ_[^B].*$/gm;
} else if (frame == 1 && !selected) {
frameregex = /^.*JONES_[^B].*$/gm;
} else {
frameregex = new RegExp("^.*[^B]" + "B".repeat(Number(frame - 1)) + "[^B].*$", "gm");
}
matches = matches.match(frameregex)
if (matches === null) {
matches = ["No setup found."];
}
matches = matches.join("\n");
}
if (stick !== "any") {
let stickregex = new RegExp("^.*__" + stick + "_.*$", "gm");
matches = matches.match(stickregex);
if (matches === null) {
matches = ["No setup found."];
}
matches = matches.join("\n");
}
if (position !== "any") {
let posregex = new RegExp("^.*_" + position + ".*$", "gm");
matches = matches.match(posregex);
if (matches === null) {
matches = ["No setup found."];
}
matches = matches.join("\n");
}
document.getElementById("setups").innerHTML = matches;
document.getElementById("setups").rows = matches.split("\n").length
})
.catch(() => {
document.getElementById("setups").innerHTML = "Something went wrong :(";
document.getElementById("setups").rows = 1;
})
}