-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathSpigotSearchEngine.js
More file actions
111 lines (70 loc) · 2.93 KB
/
SpigotSearchEngine.js
File metadata and controls
111 lines (70 loc) · 2.93 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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
/*
The SpigotSearchEngine.js is used to setup The SSE GUI, it will use the SSEGuiManager.js to set up the Gui Checkboxes
*/
let firstClick = true;
let divActionFilterRow = document.getElementsByClassName("actionFilterRow")[0];
/* SSEStatusLoadStatus */
SSEStatus.loadStatus();
/* InputSearchResources */
let inpSearchResources = document.createElement("input");
inpSearchResources.classList.add('InputSearchResources');
inpSearchResources.setAttribute("type", "text");
inpSearchResources.setAttribute("name", "SpigotSearchEngine");
inpSearchResources.setAttribute("placeholder", "Search...");
inpSearchResources.setAttribute("title", "Enter your search and hit enter");
inpSearchResources.setAttribute("value", "");
inpSearchResources.addEventListener("keyup", function(event) {
event.preventDefault();
if (event.keyCode === 13) {
bntSearchResources.click();
}
});
divActionFilterRow.appendChild(inpSearchResources);
/* ButtonSearchResources */
let bntSearchResources = document.createElement("button");
bntSearchResources.classList.add('ButtonSearchResources');
bntSearchResources.onclick = function() {
/* Check if the String is not empty */
if (inpSearchResources.value.replace(/\s/g, '').length != 0) {
if (!bntSearchResources.disabled) {
bntSearchResources.disabled = true;
inpSearchResources.readOnly = true;
/* On FirstClick */
if (firstClick) {
ResourceListener.loadRandomResources();
/* Cosmetic remove */
document.getElementsByClassName("PageNav")[0].remove();
document.getElementsByClassName("extraLinks")[0].remove();
firstClick = false;
}
/* Read the imput from the created Search_Resources_Input. */
let inpSearchResourcesText = inpSearchResources.value;
bntSearchResources.style.backgroundColor = '#ed8106';
inpSearchResources.style.backgroundColor = '#f0f0f0';
inpSearchResources.style.borderColor = '#ed8106';
ResourceListener.loadResources(inpSearchResourcesText);
}
}
};
let tnSearchResources = document.createTextNode("Search Resources");
bntSearchResources.appendChild(tnSearchResources);
divActionFilterRow.appendChild(bntSearchResources);
/* ResourcesFround */
let divResourcesFround = document.createElement("div");
divResourcesFround.classList.add('divResourcesFround');
divResourcesFround.id = 'divResourcesFround';
let tnResourcesFround = document.createTextNode("Resources Found: 0");
divResourcesFround.appendChild(tnResourcesFround);
divActionFilterRow.appendChild(divResourcesFround);
/* Gui Checkboxes */
let divSortBox = document.createElement("div");
divSortBox.id = 'divSortBox';
divActionFilterRow.appendChild(divSortBox);
SSEGuiManager.showSearchOn();
SSEGuiManager.showCategories();
SSEGuiManager.showVersions();
SSEGuiManager.showSearchType();
//SSEGuiManager.showExtras();
SSEGuiManager.showSortByBox();
/* Cosmetic remove */
//document.getElementsByClassName("extraLinks")[0].remove();