Skip to content

Commit

Permalink
Merge branch 'development' into davide/link_checker
Browse files Browse the repository at this point in the history
  • Loading branch information
atteggiani committed May 3, 2024
2 parents 8008d5f + 01be070 commit 442c2ff
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions docs/js/miscellaneous.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,31 @@
'use strict';

/*
Change absolute URLs for development-website and PR-previews (Move to build script)
*/
function changeAbsoluteUrls() {
let url = window.location.href;
if (
url.startsWith('https://access-hive.org.au/development-website/')
||
url.startsWith('https://access-hive.org.au/pr-preview/')
) {
let links = document.querySelectorAll('a[href^="/"],img[src^="/"]');
links.forEach(link => {
let href = link.getAttribute('href');
let src = link.getAttribute('src');
let base = url.startsWith('https://access-hive.org.au/development-website') ?
url.split('/').slice(3,4) : url.split('/').slice(3,5);
if (href) {
link.setAttribute('href',`/${base}${href}`);
}
if (src) {
link.setAttribute('src',`/${base}${src}`);
}
})
}
}

// Add buttons at the top of each table column (when hovered) to sort it
function sortTables() {
let tables = document.querySelectorAll("article table:not([class])");
Expand Down Expand Up @@ -214,6 +240,7 @@ function makeCitationLinks() {

// Join all functions
function main() {
changeAbsoluteUrls();
adjustScrollingToId();
tabFunctionality();
sortTables();
Expand Down

0 comments on commit 442c2ff

Please sign in to comment.