Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Accessibility, SEO, and some script execute fixes #3

Merged
merged 1 commit into from
Nov 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions hashsearch.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ function searchhashlist(index) {
data: JSON.stringify(reqJson),
dataType: "json",
error: function () {
ajaxlert("Error occurred during search.");
console.error("Error occurred during search.");
},
success: function (res) {
let mainTableBody = document.getElementById("main_table_body");
while (mainTableBody.firstChild) {
mainTableBody.firstChild.remove()
headerArrows.innerHTML = ""
}

$("#js-tree").jstree("delete_node",($("#js-tree").jstree("get_node", "#").children));

let results = res["results"]
Expand All @@ -44,7 +44,7 @@ function searchhashlist(index) {
let type = results[i].type
let string = results[i].string

if (view_type == 'list') {
if (view_type === 'list') {
document.getElementById("main_table").style.visibility='visible';
document.getElementById("tree_node_selected").style.visibility="hidden";
document.getElementById("js-tree").style.visibility="hidden";
Expand All @@ -65,7 +65,7 @@ function searchhashlist(index) {

mainTableBody.appendChild(tableRow)

if (i == results.length - 1) {
if (i === results.length - 1) {
let results_per_page_num = res.number_of_results
let results_per_page_index_num = res.page_number
if (!isNaN(results_per_page_num) && !isNaN(results_per_page_index_num)) {
Expand All @@ -92,12 +92,12 @@ function searchhashlist(index) {
}
}

if(view_type == 'tree'){
if(view_type === 'tree'){
document.getElementById("main_table").style.visibility='hidden';
document.getElementById("tree_node_selected").style.visibility="visible";
document.getElementById("js-tree").style.visibility="visible";

if (string != "" && !string.includes("*") && string.includes("[")) {
if (string !== "" && !string.includes("*") && string.includes("[")) {
let newPath = string.split("]")[0].replaceAll("[", "") + " (" + type.toLowerCase() + ")";
addToTree(newPath, string);
}
Expand All @@ -113,4 +113,4 @@ function searchhashlist(index) {
}
$("#js-tree").delete_node($("#js-tree").get_node("#").children);
}
};
};
44 changes: 12 additions & 32 deletions index.html
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
<html>
<!DOCTYPE html>
<html lang="en">

<head>
<meta http-equiv="content-type" content="text/html; charset=windows-1252">
<meta charset=utf-8>
<meta name="description" content="Hitman database to search game file hashes effectively.">
<meta name=viewport content='width=device-width, initial-scale=1'>
<link rel='shortcut icon' href='/favicon.ico' />
<link rel="stylesheet" href="main.css" />
<link rel="stylesheet" href="3rd party/jstree/themes/notex-app/style.min.css" />
<link rel="stylesheet" href="3rd party/jstree/themes/notex-app/style.min.css" media="print" onload="this.media='all'; this.onload=null;">
<link rel="stylesheet" href="https://rsms.me/inter/inter.css" media="print" onload="this.media='all'; this.onload=null;">

<script type="text/javascript" src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
<script type="text/javascript" src="3rd party/jstree/jstree.min.js"></script>
<script type="text/javascript" src="https://code.jquery.com/jquery-3.6.0.min.js" defer></script>
<script type="text/javascript" src="3rd party/jstree/jstree.min.js" defer></script>

<script type="text/javascript" src="hashsearch.js"></script>
<script type="text/javascript" src="tree_utils.js"></script>
<script type="text/javascript" src="hashsearch.js" defer></script>
<script type="text/javascript" src="tree_utils.js" defer></script>

<title>HitmanDB</title>
</head>
Expand Down Expand Up @@ -146,31 +150,7 @@
</div>

<div id="js-tree"></div> <!-- js-tree div to potentially be filled during runtime -->

<script>
//init empty tree
$('#js-tree').jstree({
'core': {
'data': [],
check_callback: true
}
});

//tree node onclick
$('#js-tree').on("changed.jstree", function (e, data) {
var selectedPath = $("#js-tree").jstree("get_node", data.selected).data;
document.getElementById("tree_node_selected_input").innerHTML = selectedPath;
});

//copy button onclick function
function copy_selected(){
var text = document.getElementById("tree_node_selected_input").innerHTML;
navigator.clipboard.writeText(text).then(function () {
}, function (err) {
console.error('Async: Could not copy text: ', err);
});
};
</script>
<script src="tree_utils.js" defer></script>

</body>

Expand Down
10 changes: 4 additions & 6 deletions main.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
@import url('https://rsms.me/inter/inter.css');

body {
background-color: #232425;
color: #fff;
Expand Down Expand Up @@ -54,7 +52,7 @@ a:visited {
box-shadow: 0 5px 0 #920404;
color: white;
padding: 0.1em 0.5em;
}
}

#apidocs:hover {
background-color: #b10606;
Expand All @@ -72,7 +70,7 @@ a:visited {
background-color: #525252;
}

#copy_text_box {
#copy_text_box {
position: relative;
padding-bottom: 100px;
z-index: index -10;
Expand Down Expand Up @@ -116,7 +114,7 @@ a:visited {
}

#underline{
padding-top: 1%;
padding-top: 0.1vh;
border-bottom: 2px solid #05be99;
display:block;
}
Expand All @@ -125,4 +123,4 @@ a:visited {
visibility: hidden;
background-color: rgba(25, 26, 27, 0.596);
padding: 15px;
}
}
40 changes: 31 additions & 9 deletions tree_utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@ function addToTree(path, fullPath) {
}
else {
//set properties for node
var node_data = "_";
var icon_path = "icons/opened-folder-24.png";
let node_data = "_";
let icon_path = "icons/opened-folder-24.png";
if(endsWith(pathSegments[i], "?")) icon_path = "icons/block-chain-24.png";
if(i == pathSegments.length - 1){
if(i === pathSegments.length - 1){
icon_path = "icons/document-24.png";
node_data = fullPath;
}
}

//define and add node
var newNode = {
const newNode = {
id: CreateGuid(),
data: node_data,
text: pathSegments[i],
Expand All @@ -32,8 +32,8 @@ function addToTree(path, fullPath) {
$("#js-tree").jstree('create_node', currentNode.id, newNode);
currentNode = newNode;
}
};
};
}
}

function findNode(root, search_string) {

Expand All @@ -43,7 +43,7 @@ function findNode(root, search_string) {
if (children) {
for (let i = 0; i < children.length; i++) {
let node = $("#js-tree").jstree("get_node", children[i]);
if (node.text == search_string) {
if (node.text === search_string) {
return node;
}
else {
Expand All @@ -64,8 +64,30 @@ function endsWith(str, suffix) {
//creates a random Guid string
function CreateGuid() {
function _p8(s) {
var p = (Math.random().toString(16) + "000000000").substr(2, 8);
const p = (Math.random().toString(16) + "000000000").substr(2, 8);
return s ? "-" + p.substr(0, 4) + "-" + p.substr(4, 4) : p;
}
return _p8() + _p8(true) + _p8(true) + _p8();
}

//init empty tree
$('#js-tree').jstree({
'core': {
'data': [],
check_callback: true
}
});

//tree node onclick
$('#js-tree').on("changed.jstree", function (e, data) {
document.getElementById("tree_node_selected_input").innerHTML = $("#js-tree").jstree("get_node", data.selected).data;
});

//copy button onclick function
function copy_selected(){
const text = document.getElementById("tree_node_selected_input").innerHTML;
navigator.clipboard.writeText(text).then(function () {
}, function (err) {
console.error('Async: Could not copy text: ', err);
});
}