-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.html
116 lines (96 loc) · 3.48 KB
/
index.html
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
112
113
114
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>The AGS Module Index</title>
<meta name="description" content="AGS Module Index">
<meta name="author" content="ericoporto">
<script src="__js/lunr.js"></script>
<script src="__js/agsmodules.js"></script>
<script src="__js/main.js"></script>
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.6.3/css/all.css" integrity="sha384-UHRtZLI+pbxtHCWp1t77Bi1L4ZtiqrqD80Kn4Z8NTSRyMA2Fd33n5dQ8lWUE00s/" crossorigin="anonymous">
<link rel="stylesheet" type="text/css" href="__css/base_style.css">
</head>
<body>
<h1>Beta List of AGS Modules</h1>
<div class="wrap">
<div class="search">
<input type="search" class="searchTerm" id="mySearch" placeholder="Type what you need..">
<button id="mySearchBtn" class="searchButton" onclick="searchModules()">
<i class="fa fa-search"></i>
</button>
</div>
</div>
<div class="searchResults">
<p id="searchResults"></p>
</div>
<script>
var input = document.getElementById("mySearch");
input.addEventListener("keyup", function(event) {
event.preventDefault();
// Number 13 is the "Enter" key on the keyboard
if (event.keyCode === 13) {
document.getElementById("mySearchBtn").click();
}
});
function getDependIfDefined( depend){
if (typeof depend === 'undefined') {
return "";
} else {
return "depends: " + depend + "<br>";
}
}
function getDemoIfDefined( demo){
if (typeof demo === 'undefined') {
return "";
} else {
return "<a href=\""+demo+"\">demo</a> " + "<br>";
}
}
function resultIDtoHTML( id ) {
var obj = agsModules.find(item => item.id === id)
return "<b>" + obj.name + "</b> <br>" +
"<a href=\"pkgs/"+ obj.id+ "/"+ obj.id+ ".scm" +"\">download "+ obj.id+ ".scm </a> "+ "<br>" +
"description: " + obj.text + "<br>" +
"author: " + obj.author + "<br>" +
"version: " + obj.version + "<br>" +
"<a href=\""+obj.forum+"\">forum page</a> "+ "<br>" +
getDependIfDefined(obj.depends) +
getDemoIfDefined(obj.demo) + "<br>";
}
function getAllResults() {
var i;
var text_results = ""
for (i = 0; i < agsModules.length; i++) {
text_results += resultIDtoHTML(agsModules[i].id) + "<br>";
}
return text_results;
}
function searchModules() {
var search_input = document.getElementById("mySearch").value;
var search_results = idx.search(search_input);
var i;
var text_results = ""
for (i = 0; i < search_results.length; i++) {
text_results += resultIDtoHTML(search_results[i].ref) + "<br>";
}
if(text_results.length < 2){
document.getElementById("searchResults").innerHTML = getAllResults();
}
document.getElementById("searchResults").innerHTML = text_results;
}
document.getElementById("searchResults").innerHTML = getAllResults();
const urlParams = new URLSearchParams(window.location.search);
if(urlParams.has('search')){
document.getElementById("mySearch").value = urlParams.get('search');
document.getElementById("mySearchBtn").click();
} else if(urlParams.has('query')){
document.getElementById("mySearch").value = urlParams.get('query');
document.getElementById("mySearchBtn").click();
} else if(urlParams.has('q')){
document.getElementById("mySearch").value = urlParams.get('q');
document.getElementById("mySearchBtn").click();
}
</script>
</body>
</html>