Last page is now saved
This commit is contained in:
		| @@ -1,11 +1,5 @@ | |||||||
|  |  | ||||||
|  |  | ||||||
|  |  | ||||||
| const tools = new Map(); | const tools = new Map(); | ||||||
|  |  | ||||||
|  |  | ||||||
|  |  | ||||||
|  |  | ||||||
| /** | /** | ||||||
|  * This functions imports other js file. I hate this solution, but other didn't work. |  * 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("jsonform", "tools/jsonFormatter.html"); | ||||||
|     tools.set("mock", getMockHost()); |     tools.set("mock", getMockHost()); | ||||||
|  |  | ||||||
|     loadLastPage(); |  | ||||||
|     changeActiveTools('xmlTool', 'XML'); |     changeActiveTools('xmlTool', 'XML'); | ||||||
|  |     loadLastPage(); | ||||||
| } | } | ||||||
|  |  | ||||||
| /** | /** | ||||||
| @@ -79,10 +73,19 @@ function changeActiveTools(activeClass, activeCategoryButton) { | |||||||
| function changeTool(tool) { | function changeTool(tool) { | ||||||
|     const url = tools.get(tool); |     const url = tools.get(tool); | ||||||
|     localStorage.setItem("lastPage", tool); |     localStorage.setItem("lastPage", tool); | ||||||
|     document.getElementById("iframe").src = tools.get(lastPage); |     document.getElementById("iframe").src = url; | ||||||
| } | } | ||||||
|  |  | ||||||
| function loadLastPage() { | function loadLastPage() { | ||||||
|     const lastPage = localStorage.getItem("lastPage"); |     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); |     document.getElementById("iframe").src = tools.get(lastPage); | ||||||
| } | } | ||||||
| @@ -35,13 +35,15 @@ | |||||||
|         <div id="leftBar"> |         <div id="leftBar"> | ||||||
|             <ul id="toolList"> |             <ul id="toolList"> | ||||||
|                 <li class="dynamic restTool toolListRow" style="display: none;"> |                 <li class="dynamic restTool toolListRow" style="display: none;"> | ||||||
|                     <a id="rest-mock" href="http://tools.zipper.release11.com:8097/" target="iframe">REST Mock</a> |                     <a id="rest-mock" href="#" onclick="changeTool('mock');">REST Mock</a> | ||||||
|  |                 </li> | ||||||
|  |                 <li class="toolListRow xmlTool"><a href="#" onclick="changeTool('xpath');">XPath</a></li> | ||||||
|  |                 <li class="toolListRow xmlTool"><a href="#" onclick="changeTool('xslt');">XSLT</a></li> | ||||||
|  |                 <li class="toolListRow xmlTool"><a href="#" onclick="changeTool('xsd');">XSD</a></li> | ||||||
|  |                 <li class="toolListRow xmlTool"><a href="#" onclick="changeTool('xmlform');">XML Formatter</a></li> | ||||||
|  |                 <li class="toolListRow jsonTool" style="display: none;"> | ||||||
|  |                     <a href="#" onclick="changeTool('jsonform');">JSON Formatter</a> | ||||||
|                 </li> |                 </li> | ||||||
|                 <li class="toolListRow xmlTool"><a href="./tools/xpath.html" target="iframe">XPath</a></li> |  | ||||||
|                 <li class="toolListRow xmlTool"><a href="./tools/xslt.html" target="iframe">XSLT</a></li> |  | ||||||
|                 <li class="toolListRow xmlTool"><a href="./tools/xsd.html" target="iframe">XSD</a></li> |  | ||||||
|                 <li class="toolListRow xmlTool"><a href="tools/xmlFormatter.html" target="iframe">XML Formatter</a></li> |  | ||||||
|                 <li class="toolListRow jsonTool" style="display: none;"><a href="tools/jsonFormatter.html" target="iframe">JSON Formatter</a></li> |  | ||||||
|             </ul> |             </ul> | ||||||
|             <div id="copyright"> |             <div id="copyright"> | ||||||
|                 Build: [:VERSION:]<br> |                 Build: [:VERSION:]<br> | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user