-
Notifications
You must be signed in to change notification settings - Fork 3
/
advanced-search.js
71 lines (56 loc) · 1.81 KB
/
advanced-search.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
//window.location =
const COLORS = ["white", "purple", "blue", "green", "orange", "red"];
function search(mode){
let queryString = "search-result.html?q=";
if (mode == "metabingo"){
queryString = "metabingo.html?q=";
}
let colorString = "";
for (let c of COLORS){
if (document.getElementById("color-" + c).checked){
colorString += c.charAt(0);
}
}
if (colorString.length != COLORS.length){
queryString += `c:${colorString}+`;
}
let playerCount = parseInt(document.getElementById("player-count").value)
if (playerCount > 0){
if (document.getElementById("allow-unbalanced").checked){
queryString += `playersun:${playerCount}+`;
}
else {
queryString += `players:${playerCount}+`;
}
}
let teamCount = parseInt(document.getElementById("team-count").value)
if (teamCount > 0){
queryString += `teams:${teamCount}+`;
}
if (document.getElementById("only-blackout").checked) {
queryString += `is:blackout+`;
}
if (document.getElementById("only-lockout").checked) {
queryString += `is:lockout+`;
}
if (document.getElementById("no-unplayable").checked) {
queryString += `not:unplayable+`;
}
if (document.getElementById("no-cursed").checked) {
queryString += `not:cursed+`;
}
let name = document.getElementById("name-search").value.toLowerCase().trim();
if (name != "") {
let words = name.split(' ');
for(let word of words){
queryString += `n:${word}+`;
}
}
if (mode == 'random') {
queryString += `random:true+`;
}
if (queryString.charAt(queryString.length-1) == "+"){
queryString = queryString.slice(0, -1);
}
window.location = queryString
}