From 74f1f6f1c296bd3ad18c09ed790ee0f1792733e5 Mon Sep 17 00:00:00 2001 From: Adam Bem Date: Fri, 3 Feb 2023 14:45:39 +0100 Subject: [PATCH] Implemented dynamic host for links in mock.html --- .../src/main/resources/static/html/mock.html | 1 + .../src/main/resources/static/js/dyn_host.js | 25 +++++++++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 Backend/mocked-services/src/main/resources/static/js/dyn_host.js diff --git a/Backend/mocked-services/src/main/resources/static/html/mock.html b/Backend/mocked-services/src/main/resources/static/html/mock.html index 79f52b4..f597720 100644 --- a/Backend/mocked-services/src/main/resources/static/html/mock.html +++ b/Backend/mocked-services/src/main/resources/static/html/mock.html @@ -8,6 +8,7 @@ +
diff --git a/Backend/mocked-services/src/main/resources/static/js/dyn_host.js b/Backend/mocked-services/src/main/resources/static/js/dyn_host.js new file mode 100644 index 0000000..14f19ae --- /dev/null +++ b/Backend/mocked-services/src/main/resources/static/js/dyn_host.js @@ -0,0 +1,25 @@ +// $(document).ready( function() { +// console.log("Here") +// let links = document.getElementsByTagName("link") +// for (let e in links) { +// let oldStr = links[e].href.split("/") +// console.log(oldStr) +// let endpoint = oldStr.slice(3).join() +// console.log(endpoint) +// e.href = window.location.protocol + "//" + window.location.hostname + "/" + endpoint +// } +// }); + +$(document).ready( function() { + console.log("Here") + let links = document.getElementsByTagName("link") + for (let i = 0; i < links.length; i++) { + let oldStr = links[i].href.split("/") + console.log(oldStr) + let endpoint = oldStr.slice(3).join("/") + console.log(endpoint) + links[i].href = window.location.protocol + "//" + window.location.hostname + ":8086/" + endpoint + } + +}); +