-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9782181
commit 7ad7955
Showing
5 changed files
with
134 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
function search(term) { | ||
results = []; | ||
for (const page of search_index) { | ||
score = 0; | ||
page_name = page[0]; | ||
page_keywords = page[1]; | ||
|
||
for (var rank = 0; rank < page_keywords.length; rank++) { | ||
for (const keyword of page_keywords[rank]) { | ||
if (!keyword.includes(term)) { | ||
continue; | ||
} | ||
score += (page_keywords.length - rank); | ||
} | ||
} | ||
|
||
if (score <= 0) { | ||
continue; | ||
} | ||
|
||
for (var i = 0; i < results.length; i++) { | ||
if (results[i][1] < score) { | ||
break; | ||
} | ||
} | ||
|
||
results.splice(i, 0, [page_name, score]); | ||
} | ||
|
||
return results; | ||
} | ||
|
||
function do_search() { | ||
term = document.getElementById('searchbox').value; | ||
console.log(term); | ||
results = search(term); | ||
div = document.getElementById("search-results"); | ||
div.innerHTML = ""; | ||
|
||
for (const page of results) { | ||
div.innerHTML += `<a href="${page[0]}">${page[0]}</a><br>`; | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<link rel="stylesheet" href="{{webroot}}css/root.css"> | ||
<link rel="stylesheet" href="{{webroot}}pyg.css"> | ||
|
||
<script src="{{webroot}}search_index.js"></script> | ||
<script src="{{webroot}}js/search.js"></script> | ||
|
||
<link href="{{webroot}}fontawesome/css/fontawesome.css" rel="stylesheet" /> | ||
<link href="{{webroot}}fontawesome/css/brands.css" rel="stylesheet" /> | ||
<link href="{{webroot}}fontawesome/css/solid.css" rel="stylesheet" /> | ||
</head> | ||
<body> | ||
<div id="page"> | ||
<header> | ||
<h1>RAIDOC</h1> | ||
<a href="{{webroot}}index.html">HOME</a> | ||
<a href="{{webroot}}map.html">ALL PAGES</a> | ||
<a href="{{webroot}}search.html">SEARCH</a> | ||
</header> | ||
|
||
<div id="content"> | ||
<input type="text" id="searchbox"> | ||
<button id="searchbutton" onclick="do_search();"> | ||
Search | ||
</button> | ||
<div id="search-results"> | ||
</div> | ||
</div> | ||
</div> | ||
</body> | ||
</html> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters