index.html 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274
  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. <script src="script/countryCode.js"></script>
  16. <script src="script/chart.js"></script>
  17. <link rel="stylesheet" href="main.css">
  18. </head>
  19. <body>
  20. <div class="menubar">
  21. <div class="item">
  22. <img class="logo" src="img/logo.svg">
  23. </div>
  24. <div class="ui right floated buttons menutoggle" style="padding-top: 2px;">
  25. <button class="ui basic icon button" onclick="$('.toolbar').fadeToggle('fast');"><i class="content icon"></i></button>
  26. </div>
  27. <div class="ui right floated buttons" style="padding-top: 2px;">
  28. <button class="ui basic icon button" onclick="logout();"><i class="sign-out icon"></i></button>
  29. </div>
  30. </div>
  31. <div class="wrapper">
  32. <div class="toolbar">
  33. <div id="mainmenu" class="ui secondary vertical menu">
  34. <a class="item active" tag="status">
  35. <i class="simplistic info circle icon"></i>Status
  36. </a>
  37. <a class="item" tag="vdir">
  38. <i class="simplistic folder icon"></i> Virtual Directory
  39. </a>
  40. <a class="item" tag="subd">
  41. <i class="simplistic sitemap icon"></i> Subdomain Proxy
  42. </a>
  43. <a class="item" tag="rules">
  44. <i class="simplistic plus square icon"></i> Create Proxy Rules
  45. </a>
  46. <a class="item" tag="setroot">
  47. <i class="simplistic home icon"></i> Set Proxy Root
  48. </a>
  49. <div class="ui divider menudivider">Access & Connections</div>
  50. <a class="item" tag="cert">
  51. <i class="simplistic lock icon"></i> TLS / SSL certificate
  52. </a>
  53. <a class="item" tag="redirectset">
  54. <i class="simplistic level up alternate icon"></i> Redirection
  55. </a>
  56. <a class="item" tag="blacklist">
  57. <i class="simplistic ban icon"></i> Blacklist
  58. </a>
  59. <div class="ui divider menudivider">Bridging</div>
  60. <a class="item" tag="gan">
  61. <i class="simplistic exchange icon"></i> Global Area Network
  62. </a>
  63. <a class="item" tag="">
  64. <i class="simplistic remove icon"></i> HTTP over Websocket
  65. </a>
  66. <a class="item" tag="">
  67. <i class="simplistic remove icon"></i> TCP Proxy
  68. </a>
  69. <div class="ui divider menudivider">Others</div>
  70. <a class="item" tag="utm">
  71. <i class="simplistic time icon"></i> Uptime Monitor
  72. </a>
  73. <a class="item" tag="networktool">
  74. <i class="simplistic terminal icon"></i> Network Tools
  75. </a>
  76. <a class="item" tag="stats">
  77. <i class="simplistic database icon"></i> Statistical Analysis
  78. </a>
  79. <a class="item" tag="utils">
  80. <i class="simplistic paperclip icon"></i> Utilities
  81. </a>
  82. <!-- Add more components here -->
  83. </div>
  84. </div>
  85. <div class="contentWindow">
  86. <!-- Status Tab -->
  87. <div id="status" class="functiontab" target="status.html" style="display: block ;">
  88. <br><br><div class="ui active centered inline loader"></div>
  89. </div>
  90. <!-- Virtual Directory Tab -->
  91. <div id="vdir" class="functiontab" target="vdir.html"></div>
  92. <!-- Subdomain Proxy -->
  93. <div id="subd" class="functiontab" target="subd.html"></div>
  94. <!-- Create Rules -->
  95. <div id="rules" class="functiontab" target="rules.html"></div>
  96. <!-- Set proxy root -->
  97. <div id="setroot" class="functiontab" target="rproot.html"></div>
  98. <!-- Set TLS cert -->
  99. <div id="cert" class="functiontab" target="cert.html"></div>
  100. <!-- Redirections -->
  101. <div id="redirectset" class="functiontab" target="redirection.html"></div>
  102. <!-- Blacklist -->
  103. <div id="blacklist" class="functiontab" target="blacklist.html"></div>
  104. <!-- Global Area Networking -->
  105. <div id="gan" class="functiontab" target="gan.html"></div>
  106. <!-- Up Time Monitor -->
  107. <div id="utm" class="functiontab" target="uptime.html"></div>
  108. <!-- Network Tools -->
  109. <div id="networktool" class="functiontab" target="networktools.html"></div>
  110. <!-- Statistic Tools -->
  111. <div id="stats" class="functiontab" target="stats.html"></div>
  112. <!-- Utilities -->
  113. <div id="utils" class="functiontab" target="utils.html"></div>
  114. </div>
  115. </div>
  116. </div>
  117. <br><br>
  118. <div class="ui divider"></div>
  119. <div class="ui container" style="color: grey; font-size: 90%">
  120. <p>CopyRight Zoraxy project and its author, 2022 - <span class="year"></span></p>
  121. </div>
  122. <div id="messageBox" class="ui green floating big compact message">
  123. <p><i class="green check circle icon"></i> There are no message</p>
  124. </div>
  125. <br><br>
  126. <script>
  127. $(".year").text(new Date().getFullYear());
  128. /*
  129. Loader function
  130. Load all the components view from the
  131. components/ directory into their corrisponding divs
  132. */
  133. let loadingComponents = 0;
  134. function initTabs(callback=undefined){
  135. $('.functiontab').each(function(){
  136. let loadTarget = $(this).attr("target");
  137. if (loadTarget != undefined){
  138. $(this).load("./components/" + loadTarget, function(){
  139. loadingComponents--;
  140. });
  141. loadingComponents++;
  142. }else{
  143. $(this).html(`<p>Unable to load components for this tab</p>`);
  144. }
  145. })
  146. if (callback != undefined){
  147. waitInit(callback);
  148. }
  149. }
  150. function waitInit(callback = undefined, retryCount = 0){
  151. if (loadingComponents > 0 && retryCount < 5){
  152. setTimeout(function(){
  153. waitInit(callback, retryCount++);
  154. }, 300);
  155. }else if (loadingComponents == 0){
  156. callback();
  157. }else{
  158. alert("Missing component. Please check if your installation is complete.")
  159. }
  160. }
  161. initTabs(function(){
  162. initRPStaste();
  163. if (window.location.hash.length > 1){
  164. let tabID = window.location.hash.substr(1);
  165. openTabById(tabID);
  166. }else{
  167. openTabById("status");
  168. }
  169. $(".ui.dropdown").dropdown();
  170. $(".ui.checkbox").checkbox();
  171. //Click on the current tab
  172. $("#mainmenu").find(".item").each(function(){
  173. $(this).on("click", function(event){
  174. let tabid = $(this).attr("tag");
  175. openTabById(tabid);
  176. });
  177. });
  178. //Initialize all table that is sortable
  179. $('table').tablesort();
  180. });
  181. function logout() {
  182. $.get("/api/auth/logout", function(response) {
  183. if (response === "OK") {
  184. setTimeout(function(){
  185. window.location.href = "/";
  186. }, 300);
  187. }
  188. });
  189. }
  190. function getTabButtonById(targetTabId){
  191. let targetTabBtn = undefined;
  192. $("#mainmenu").find(".item").each(function(){
  193. let tabid = $(this).attr("tag");
  194. if (tabid == targetTabId){
  195. targetTabBtn = $(this);
  196. }
  197. });
  198. return targetTabBtn;
  199. }
  200. //Select and open a tab by its tag id
  201. let tabSwitchEventBind = {}; //Bind event to tab switch by tabid
  202. function openTabById(tabID){
  203. let targetBtn = getTabButtonById(tabID);
  204. if (targetBtn == undefined){
  205. alert("Invalid tabid given");
  206. return;
  207. }
  208. if (window.innerWidth < 750){
  209. //RWD mode, hide toolbar
  210. $(".toolbar").fadeOut('fast');
  211. }
  212. $("#mainmenu").find(".item").removeClass("active");
  213. $(targetBtn).addClass("active");
  214. $(".functiontab").hide();
  215. $("#" + tabID).fadeIn('fast', function(){
  216. if (tabSwitchEventBind[tabID]){
  217. tabSwitchEventBind[tabID]();
  218. }
  219. });
  220. $('html,body').animate({scrollTop: 0}, 'fast');
  221. window.location.hash = tabID;
  222. }
  223. $(window).on("resize", function(){
  224. if (window.innerWidth >= 750 && $(".toolbar").is(":visible") == false){
  225. $(".toolbar").show();
  226. }
  227. });
  228. function msgbox(message, succ=true, delayDuration=3000){
  229. let icon = `<i class="ui info circle icon"></i>`;
  230. if (succ){
  231. $("#messageBox").attr("class", "ui green floating compact message")
  232. icon = `<i class="ui green circle check icon"></i>`;
  233. }else{
  234. $("#messageBox").attr("class", "ui red floating compact message")
  235. icon = `<i class="ui red circle times icon"></i>`;
  236. }
  237. $("#messageBox").html(`${icon} ${message}`);
  238. $("#messageBox").stop().finish().fadeIn("fast").delay(delayDuration).fadeOut("fast");
  239. }
  240. </script>
  241. </body>
  242. </html>