From 4716656e007cd469e0bee8e983c7e91351a9a4d3 Mon Sep 17 00:00:00 2001 From: atteggiani Date: Fri, 3 May 2024 09:11:04 +1000 Subject: [PATCH 1/4] Added function to change links in development-website and pr-previews --- docs/js/miscellaneous.js | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/docs/js/miscellaneous.js b/docs/js/miscellaneous.js index 64fcfc1f8..595a24f02 100644 --- a/docs/js/miscellaneous.js +++ b/docs/js/miscellaneous.js @@ -1,5 +1,30 @@ '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') + ) { + 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])"); @@ -215,6 +240,7 @@ function makeCitationLinks() { // Join all functions function main() { + changeAbsoluteUrls(); adjustScrollingToId(); tabFunctionality(); sortTables(); From 385877854e426de55a585e92b55b2d1dfab604da Mon Sep 17 00:00:00 2001 From: atteggiani Date: Fri, 3 May 2024 09:15:30 +1000 Subject: [PATCH 2/4] Minor edit to function to change URLs --- docs/js/miscellaneous.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/js/miscellaneous.js b/docs/js/miscellaneous.js index 595a24f02..fa33b36f4 100644 --- a/docs/js/miscellaneous.js +++ b/docs/js/miscellaneous.js @@ -6,8 +6,8 @@ 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') + url.startsWith('https://access-hive.org.au/development-website/') || + url.startsWith('https://access-hive.org.au/pr-preview/') ) { links=document.querySelectorAll('a[href^="/"],img[src^="/"]'); links.forEach(link => { From bfe2df1a0e9834b3f29a8b2e0fcd6e82703929ab Mon Sep 17 00:00:00 2001 From: atteggiani Date: Fri, 3 May 2024 09:35:27 +1000 Subject: [PATCH 3/4] Fix to function to change URLs --- docs/js/miscellaneous.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/js/miscellaneous.js b/docs/js/miscellaneous.js index fa33b36f4..2a8cfc435 100644 --- a/docs/js/miscellaneous.js +++ b/docs/js/miscellaneous.js @@ -9,7 +9,7 @@ function changeAbsoluteUrls() { url.startsWith('https://access-hive.org.au/development-website/') || url.startsWith('https://access-hive.org.au/pr-preview/') ) { - links=document.querySelectorAll('a[href^="/"],img[src^="/"]'); + let links = document.querySelectorAll('a[href^="/"],img[src^="/"]'); links.forEach(link => { let href = link.getAttribute('href'); let src = link.getAttribute('src'); From 01be0705283e5e12d5d6a0d72792a1b5a5ac2e2c Mon Sep 17 00:00:00 2001 From: atteggiani Date: Fri, 3 May 2024 09:53:06 +1000 Subject: [PATCH 4/4] Fix to function to change URLs --- docs/js/miscellaneous.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/js/miscellaneous.js b/docs/js/miscellaneous.js index 2a8cfc435..bb265ab11 100644 --- a/docs/js/miscellaneous.js +++ b/docs/js/miscellaneous.js @@ -6,7 +6,8 @@ function changeAbsoluteUrls() { let url = window.location.href; if ( - url.startsWith('https://access-hive.org.au/development-website/') || + 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^="/"]');