index.html 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta name="apple-mobile-web-app-capable" content="yes" />
  5. <meta name="viewport" content="user-scalable=no, width=device-width, initial-scale=1, maximum-scale=1"/>
  6. <meta charset="UTF-8">
  7. <meta name="theme-color" content="#4b75ff">
  8. <link rel="icon" type="image/png" href="./favicon.png" />
  9. <title>Control Panel | Zoraxy</title>
  10. <link rel="stylesheet" href="script/semantic/semantic.min.css">
  11. <script src="script/jquery-3.6.0.min.js"></script>
  12. <script src="../script/ao_module.js"></script>
  13. <script src="script/semantic/semantic.min.js"></script>
  14. <script src="script/tablesort.js"></script>
  15. <link rel="stylesheet" href="main.css">
  16. </head>
  17. <body>
  18. <div class="menubar">
  19. <div class="item">
  20. <img class="logo" src="img/logo.svg">
  21. </div>
  22. <div class="ui right floated buttons menutoggle" style="padding-top: 2px;">
  23. <button class="ui basic icon button" onclick="$('.toolbar').fadeToggle('fast');"><i class="content icon"></i></button>
  24. </div>
  25. <div class="ui right floated buttons" style="padding-top: 2px;">
  26. <button class="ui basic icon button" onclick="logout();"><i class="sign-out icon"></i></button>
  27. </div>
  28. </div>
  29. <div class="wrapper">
  30. <div class="toolbar">
  31. <div id="mainmenu" class="ui secondary vertical pointing menu">
  32. <a class="item active" tag="status">
  33. <i class="blue info circle icon"></i>Status
  34. </a>
  35. <a class="item" tag="vdir">
  36. <i class="yellow folder icon"></i> Virtual Directory
  37. </a>
  38. <a class="item" tag="subd">
  39. <i class="teal sitemap icon"></i> Subdomain Proxy
  40. </a>
  41. <a class="item" tag="rules">
  42. <i class="brown plus square icon"></i> Create Proxy Rules
  43. </a>
  44. <a class="item" tag="setroot">
  45. <i class="home icon"></i> Set Proxy Root
  46. </a>
  47. <div class="ui divider menudivider">Access & Connections</div>
  48. <a class="item" tag="cert">
  49. <i class="orange lock icon"></i> TLS / SSL certificate
  50. </a>
  51. <a class="item" tag="redirectset">
  52. <i class="violet level up alternate icon"></i> Redirection
  53. </a>
  54. <a class="item" tag="blacklist">
  55. <i class="red ban icon"></i> Blacklist
  56. </a>
  57. <a class="item" tag="upnp">
  58. <i class="blue exchange icon"></i> Port Forward
  59. </a>
  60. <div class="ui divider menudivider">Bridging</div>
  61. <a class="item" tag="">
  62. <i class="remove icon"></i> TCP Proxy
  63. </a>
  64. <a class="item" tag="">
  65. <i class="remove icon"></i> HTTP over Websocket
  66. </a>
  67. <div class="ui divider menudivider">Others</div>
  68. <a class="item" tag="">
  69. <i class="remove icon"></i> Uptime Monitor
  70. </a>
  71. <a class="item" tag="">
  72. <i class="remove icon"></i> Network Tools
  73. </a>
  74. <a class="item" tag="utils">
  75. <i class="grey paperclip icon"></i> Utilities
  76. </a>
  77. <!-- Add more components here -->
  78. </div>
  79. </div>
  80. <div class="contentWindow">
  81. <!-- Status Tab -->
  82. <div id="status" class="functiontab" target="status.html" style="display: block ;">
  83. <br><br><div class="ui active centered inline loader"></div>
  84. </div>
  85. <!-- Virtual Directory Tab -->
  86. <div id="vdir" class="functiontab" target="vdir.html"></div>
  87. <!-- Subdomain Proxy -->
  88. <div id="subd" class="functiontab" target="subd.html"></div>
  89. <!-- Create Rules -->
  90. <div id="rules" class="functiontab" target="rules.html"></div>
  91. <!-- Set proxy root -->
  92. <div id="setroot" class="functiontab" target="rproot.html"></div>
  93. <!-- Set TLS cert -->
  94. <div id="cert" class="functiontab" target="cert.html"></div>
  95. <!-- Redirections -->
  96. <div id="redirectset" class="functiontab" target="redirection.html"></div>
  97. <!-- Blacklist -->
  98. <div id="blacklist" class="functiontab" target="blacklist.html"></div>
  99. <!-- UPnP based port fowarding -->
  100. <div id="upnp" class="functiontab" target="upnp.html"></div>
  101. <!-- Utilities -->
  102. <div id="utils" class="functiontab" target="utils.html"></div>
  103. </div>
  104. </div>
  105. </div>
  106. <br><br>
  107. <div class="ui divider"></div>
  108. <div class="ui container" style="color: grey; font-size: 90%">
  109. <p>CopyRight Zoraxy project and its author, 2022 - <span class="year"></span></p>
  110. </div>
  111. <br><br>
  112. <script>
  113. $(".year").text(new Date().getFullYear());
  114. /*
  115. Loader function
  116. Load all the components view from the
  117. components/ directory into their corrisponding divs
  118. */
  119. let loadingComponents = 0;
  120. function initTabs(callback=undefined){
  121. $('.functiontab').each(function(){
  122. let loadTarget = $(this).attr("target");
  123. if (loadTarget != undefined){
  124. $(this).load("./components/" + loadTarget, function(){
  125. loadingComponents--;
  126. });
  127. loadingComponents++;
  128. }else{
  129. $(this).html(`<p>Unable to load components for this tab</p>`);
  130. }
  131. })
  132. if (callback != undefined){
  133. waitInit(callback);
  134. }
  135. }
  136. function waitInit(callback = undefined, retryCount = 0){
  137. if (loadingComponents > 0 && retryCount < 5){
  138. setTimeout(function(){
  139. waitInit(callback, retryCount++);
  140. }, 300);
  141. }else if (loadingComponents == 0){
  142. callback();
  143. }else{
  144. alert("Missing component. Please check if your installation is complete.")
  145. }
  146. }
  147. initTabs(function(){
  148. initRPStaste();
  149. if (window.location.hash.length > 1){
  150. let tabID = window.location.hash.substr(1);
  151. openTabById(tabID);
  152. }else{
  153. openTabById("status");
  154. }
  155. $(".ui.dropdown").dropdown();
  156. $(".ui.checkbox").checkbox();
  157. //Click on the current tab
  158. $("#mainmenu").find(".item").each(function(){
  159. $(this).on("click", function(event){
  160. let tabid = $(this).attr("tag");
  161. openTabById(tabid);
  162. });
  163. });
  164. //Initialize all table that is sortable
  165. $('table').tablesort();
  166. });
  167. function logout() {
  168. $.get("/api/auth/logout", function(response) {
  169. if (response === "OK") {
  170. window.location.href = "/";
  171. }
  172. });
  173. }
  174. function getTabButtonById(targetTabId){
  175. let targetTabBtn = undefined;
  176. $("#mainmenu").find(".item").each(function(){
  177. let tabid = $(this).attr("tag");
  178. if (tabid == targetTabId){
  179. targetTabBtn = $(this);
  180. }
  181. });
  182. return targetTabBtn;
  183. }
  184. //Select and open a tab by its tag id
  185. function openTabById(tabID){
  186. let targetBtn = getTabButtonById(tabID);
  187. if (targetBtn == undefined){
  188. alert("Invalid tabid given");
  189. return;
  190. }
  191. if (window.innerWidth < 750){
  192. //RWD mode, hide toolbar
  193. $(".toolbar").fadeOut('fast');
  194. }
  195. $("#mainmenu").find(".item").removeClass("active");
  196. $(targetBtn).addClass("active");
  197. $(".functiontab").hide();
  198. $("#" + tabID).fadeIn('fast');
  199. $('html,body').animate({scrollTop: 0}, 'fast');
  200. window.location.hash = tabID;
  201. }
  202. $(window).on("resize", function(){
  203. if (window.innerWidth >= 750 && $(".toolbar").is(":visible") == false){
  204. $(".toolbar").show();
  205. }else if (window.innerWidth < 750 && $(".toolbar").is(":visible") == true){
  206. $(".toolbar").hide();
  207. }
  208. });
  209. </script>
  210. </body>
  211. </html>