From a4726dad554c692f1a38efa30b09d3fea3af16b7 Mon Sep 17 00:00:00 2001 From: Adam Bem Date: Mon, 8 May 2023 15:22:17 +0200 Subject: [PATCH] Refined code --- Frontend/assets/scripts/dyn_host.js | 10 ---------- Frontend/assets/scripts/frame.js | 30 ++++++++++++++++++++++++++++- Frontend/index.html | 9 ++------- 3 files changed, 31 insertions(+), 18 deletions(-) delete mode 100644 Frontend/assets/scripts/dyn_host.js diff --git a/Frontend/assets/scripts/dyn_host.js b/Frontend/assets/scripts/dyn_host.js deleted file mode 100644 index dbb3655..0000000 --- a/Frontend/assets/scripts/dyn_host.js +++ /dev/null @@ -1,10 +0,0 @@ -$(document).ready( function() { - document.getElementById("rest-mock").href = - window.location.protocol + "//" + window.location.hostname + ":8097"; - -}); - - -function getMockHost() { - return window.location.protocol + "//" + window.location.hostname + ":8097"; -} \ No newline at end of file diff --git a/Frontend/assets/scripts/frame.js b/Frontend/assets/scripts/frame.js index 16e6b1f..22d0a39 100644 --- a/Frontend/assets/scripts/frame.js +++ b/Frontend/assets/scripts/frame.js @@ -15,6 +15,18 @@ function importScript(url) { document.head.appendChild(script); } +/** + * Get address of Mock Services + * + * @function + * @name getMockHost + * @kind function + * @returns {string} + */ +function getMockHost() { + return window.location.protocol + "//" + window.location.hostname + ":8097"; +} + /** * Function called after page is loaded * @@ -24,7 +36,6 @@ function importScript(url) { * @returns {void} */ function init() { - importScript("/assets/scripts/dyn_host.js"); tools.set("xpath", "tools/xpath.html"); tools.set("xsd", "tools/xsd.html"); @@ -70,12 +81,29 @@ function changeActiveTools(activeClass, activeCategoryButton) { } } +/** + * Function that changes active tool + * + * @function + * @name changeTool + * @kind function + * @param {any} tool + * @returns {void} + */ function changeTool(tool) { const url = tools.get(tool); localStorage.setItem("lastPage", tool); document.getElementById("iframe").src = url; } +/** + * Function that loads last used tool and sets active category accordingly + * + * @function + * @name loadLastPage + * @kind function + * @returns {void} + */ function loadLastPage() { const lastPage = localStorage.getItem("lastPage"); switch (lastPage) { diff --git a/Frontend/index.html b/Frontend/index.html index 0002e0f..fb39a02 100644 --- a/Frontend/index.html +++ b/Frontend/index.html @@ -5,7 +5,6 @@ - @@ -34,16 +33,12 @@