Made more elegant solution to tools URLs
This commit is contained in:
		| @@ -32,7 +32,7 @@ function init() { | ||||
|     changeActiveTools('XML'); | ||||
|     var toolUrl = window.location.search.substring(1); | ||||
|     if (tools.has(toolUrl)) | ||||
|         changeTool(toolUrl); | ||||
|         changeTool(toolUrl, false); | ||||
|     else | ||||
|         loadLastPage(); | ||||
|      | ||||
| @@ -73,19 +73,23 @@ function changeActiveTools(activeCategoryButton) { | ||||
|     } | ||||
| } | ||||
|  | ||||
|  | ||||
| /** | ||||
|  * Function that changes active tool | ||||
|  * This function changes active tool. | ||||
|  * Optional updateURL can be set to false to stop changing URL.  | ||||
|  * This helps avoiding endless reload loop when loading page. | ||||
|  *  | ||||
|  * @function | ||||
|  * @name changeTool | ||||
|  * @kind function | ||||
|  * @param {any} tool | ||||
|  * @param {boolean} updateURL? | ||||
|  * @returns {void} | ||||
|  */ | ||||
| function changeTool(tool) { | ||||
| function changeTool(tool, updateURL = true) { | ||||
|     if (tools.has(tool)) { | ||||
|         const url = tools.get(tool); | ||||
|         document.location.search = tool + "/"; | ||||
|         if (updateURL) document.location.search = tool; | ||||
|         localStorage.setItem("lastPage", tool); | ||||
|         document.getElementById("iframe").src = url; | ||||
|     } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user