Last page is now saved

This commit is contained in:
2023-05-08 15:02:28 +02:00
parent ccefc944b8
commit 5ef4c83ca5
2 changed files with 19 additions and 14 deletions

View File

@@ -1,11 +1,5 @@
const tools = new Map();
/**
* This functions imports other js file. I hate this solution, but other didn't work.
*
@@ -39,8 +33,8 @@ function init() {
tools.set("jsonform", "tools/jsonFormatter.html");
tools.set("mock", getMockHost());
loadLastPage();
changeActiveTools('xmlTool', 'XML');
loadLastPage();
}
/**
@@ -79,10 +73,19 @@ function changeActiveTools(activeClass, activeCategoryButton) {
function changeTool(tool) {
const url = tools.get(tool);
localStorage.setItem("lastPage", tool);
document.getElementById("iframe").src = tools.get(lastPage);
document.getElementById("iframe").src = url;
}
function loadLastPage() {
const lastPage = localStorage.getItem("lastPage");
switch (lastPage) {
case "jsonform":
changeActiveTools('jsonTool', 'JSON');
break;
case "mock":
changeActiveTools('restTool', 'REST');
break;
}
document.getElementById("iframe").src = tools.get(lastPage);
}