Updated index page + Added about and result pages

This commit is contained in:
2023-12-05 15:26:57 +01:00
parent 6d504394ef
commit e71d656d0e
11 changed files with 616 additions and 148 deletions
+52
View File
@@ -0,0 +1,52 @@
function addOrUpdateUrlParameter(url, key, value) {
var urlObject = new URL(url);
urlObject.searchParams.set(key, value);
return urlObject.href;
}
function getUrlParameters() {
var searchParams = new URLSearchParams(window.location.search);
var params = {};
// Iterate over each parameter and add to the 'params' object
searchParams.forEach(function(value, key) {
params[key] = value;
});
return params;
}
$(document).ready(function() {
var params = getUrlParameters();
// Make table rows clickable
$(".table-wrapper tbody tr").click(function() {
var url = $(this).data("href");
if (url) {
window.location.href = url;
}
});
$(".th-desc").hide();
$(".th-asc").hide();
if ('order_by' in params) {
if ('order_type' in params && params.order_type == 'desc') {
$('th:contains(' + params.order_by + ') .th-desc').show();
} else {
$('th:contains(' + params.order_by + ') .th-asc').show();
}
}
// Make table rows clickable
$(".table-wrapper thead th").click(function(e) {
var column_name = $(this).find('span:first').text();
var newUrl = addOrUpdateUrlParameter(window.location.href, 'order_by', column_name);
if ('order_by' in params && 'order_type' in params && params.order_by == column_name && params.order_type == 'desc') {
newUrl = addOrUpdateUrlParameter(newUrl, 'order_type', 'asc');
} else {
newUrl = addOrUpdateUrlParameter(newUrl, 'order_type', 'desc');
}
// Redirect to the modified URL
window.location.href = newUrl;
});
});