index.html 13 KB

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