Skip to content

Commit

Permalink
Made the homepage use pagination headers
Browse files Browse the repository at this point in the history
  • Loading branch information
Hunter19823 committed Apr 29, 2024
1 parent 199ee3f commit 6f0b51e
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,19 +40,18 @@ function createHomePage() {
let table = null;
for (let i = 0; i < keys.length; i++) {
const key = keys[i];
span = document.createElement('span');
span.innerHTML = key;
let period = key?.lastIndexOf('.');
const period = key.lastIndexOf('.');
const title = period === -1 ? key : `${key.substring(period + 1)} (${key.substring(0, period)})`;
if (DATA._events[key].length === 0)
continue;
table = createTableWithHeaders(createSortableTable(period === -1 ? key : key.substring(period + 1)), 'Link', span);
for (let j = 0; j < DATA._events[key].length; j++) {
const addToTable = (table, event) => {
try {
let row = addRow(table, createFullSignature(DATA._events[key][j]));
appendAttributesToClassTableRow(row, DATA._events[key][j]);
let row = addRow(table, createFullSignature(event));
appendAttributesToClassTableRow(row, event)
} catch (e) {
console.error("Failed to create homepage entry for ", key, " Class: ", DATA._events[key][j], " Error: ", e);
console.error("Failed to create homepage entry for ", key, " Class: ", event, " Error: ", e);
}
}
};
createPagedTable(title, key, DATA._events[key], addToTable, 'Link', 'Class');
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ function onHashChange() {
// Now that we have our re-routing logic out of the way, we can rely on the page decoder to do the rest.
let decoded = DecodeURL();

console.log(`Decoded URL created in hash change. Raw Hash: '${window.location.hash}' Decoded Hash: '${decoded.hash}' Params: '${decoded.params.toString()}' Href: '${decoded.href()}' Is Homepage: '${decoded.isHome()}' Is Class: '${decoded.isClass()}' Is Search: '${decoded.isSearch()}' Has Focus: '${decoded.hasFocus()}' Focus: '${decoded.getFocusOrDefaultHeader()}' Parameter Size: '${decoded.getParamSize()}' Safe Parameter Size: '${decoded.getParamSizeSafe()}'`);
console.log(`Decoded URL created in hash change. Raw Hash: '${window.location.hash}' Decoded Hash: '${decoded.hash}' Hash Length: '${decoded.hash.length}' Params: '${decoded.params.toString()}' Href: '${decoded.href()}' Is Homepage: '${decoded.isHome()}' Is Class: '${decoded.isClass()}' Is Search: '${decoded.isSearch()}' Has Focus: '${decoded.hasFocus()}' Focus: '${decoded.getFocusOrDefaultHeader()}' Parameter Size: '${decoded.getParamSize()}' Safe Parameter Size: '${decoded.getParamSizeSafe()}'`);
if (!decoded) {
console.error("Failed to decode URL.");
return;
Expand Down Expand Up @@ -380,7 +380,28 @@ function DecodeURL() {

output.isSearch = function () {
// If thee is no focus, then it's a search as the only parameter must be the search term.
return !this.hash && this.getParamSizeSafe() > 0;
if (this.hash?.length !== 0)
return false;
if (this.getParamSizeSafe() === 0)
return false;
// Check if the parameters contain any search terms.
// Check if params is shorter than NEW_QUERY_TERMS.
if (this.getParamSizeSafe() < Object.keys(NEW_QUERY_TERMS).length) {
// Check if the parameters contain any of the search terms.
for (let key of this.params.keys()) {
if (Object.keys(NEW_QUERY_TERMS).includes(key)) {
return true;
}
}
} else {
// Check if new query terms contain any of the parameters.
for (let key of Object.keys(NEW_QUERY_TERMS)) {
if (this.params.has(key)) {
return true;
}
}
}
return false;
}

output.isClass = function () {
Expand Down

0 comments on commit 6f0b51e

Please sign in to comment.