index.html 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410
  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; padding-right: 0.4em;">
  29. <button class="ui basic white icon button" onclick="logout();"><i class="sign-out icon"></i></button>
  30. </div>
  31. <!-- <div class="ui right floated buttons" style="padding-top: 2px;">
  32. <button id="themeColorButton" class="ui icon button" onclick="toggleTheme();"><i class="sun icon"></i></button>
  33. </div> -->
  34. </div>
  35. <div class="wrapper">
  36. <div class="toolbar">
  37. <div id="mainmenu" class="ui secondary vertical menu">
  38. <a class="item active" tag="status">
  39. <i class="simplistic info circle icon"></i>Status
  40. </a>
  41. <a class="item" tag="setroot">
  42. <i class="simplistic home icon"></i> Default Site
  43. </a>
  44. <div class="ui divider menudivider">Reverse Proxy</div>
  45. <a class="item" tag="httprp">
  46. <i class="simplistic sitemap icon"></i> HTTP Proxy
  47. </a>
  48. <a class="item" tag="vdir">
  49. <i class="simplistic folder icon"></i> Virtual Directory
  50. </a>
  51. <a class="item" tag="rules">
  52. <i class="simplistic plus square icon"></i> Create Proxy Rules
  53. </a>
  54. <a class="item" tag="tcpprox">
  55. <i class="simplistic exchange icon"></i> TCP Proxy
  56. </a>
  57. <div class="ui divider menudivider">Access & Connections</div>
  58. <a class="item" tag="cert">
  59. <i class="simplistic lock icon"></i> TLS / SSL certificates
  60. </a>
  61. <a class="item" tag="redirectset">
  62. <i class="simplistic level up alternate icon"></i> Redirection
  63. </a>
  64. <a class="item" tag="access">
  65. <i class="simplistic ban icon"></i> Access Control
  66. </a>
  67. <div class="ui divider menudivider">Bridging</div>
  68. <a class="item" tag="gan">
  69. <i class="simplistic globe icon"></i> Global Area Network
  70. </a>
  71. <a class="item" tag="zgrok">
  72. <i class="simplistic podcast icon"></i> Service Expose Proxy
  73. </a>
  74. <div class="ui divider menudivider">Others</div>
  75. <a class="item" tag="webserv">
  76. <i class="simplistic globe icon"></i> Static Web Server
  77. </a>
  78. <a class="item" tag="utm">
  79. <i class="simplistic time icon"></i> Uptime Monitor
  80. </a>
  81. <a class="item" tag="networktool">
  82. <i class="simplistic terminal icon"></i> Network Tools
  83. </a>
  84. <a class="item" tag="stats">
  85. <i class="simplistic database icon"></i> Statistical Analysis
  86. </a>
  87. <a class="item" tag="utils">
  88. <i class="simplistic paperclip icon"></i> Utilities
  89. </a>
  90. <!-- Add more components here -->
  91. </div>
  92. </div>
  93. <div class="contentWindow">
  94. <!-- Status Tab -->
  95. <div id="status" class="functiontab" target="status.html" style="display: block ;">
  96. <br><br><div class="ui active centered inline loader"></div>
  97. </div>
  98. <!-- Virtual Directory Tab -->
  99. <div id="vdir" class="functiontab" target="vdir.html"></div>
  100. <!-- Subdomain Proxy -->
  101. <div id="httprp" class="functiontab" target="httprp.html"></div>
  102. <!-- Create Rules -->
  103. <div id="rules" class="functiontab" target="rules.html"></div>
  104. <!-- Set proxy root -->
  105. <div id="setroot" class="functiontab" target="rproot.html"></div>
  106. <!-- Set TLS cert -->
  107. <div id="cert" class="functiontab" target="cert.html"></div>
  108. <!-- Redirections -->
  109. <div id="redirectset" class="functiontab" target="redirection.html"></div>
  110. <!-- Blacklist -->
  111. <div id="access" class="functiontab" target="access.html"></div>
  112. <!-- Global Area Networking -->
  113. <div id="gan" class="functiontab" target="gan.html"></div>
  114. <!-- Service Expose Proxy -->
  115. <div id="zgrok" class="functiontab" target="zgrok.html"></div>
  116. <!-- TCP Proxy -->
  117. <div id="tcpprox" class="functiontab" target="tcpprox.html"></div>
  118. <!-- Web Server -->
  119. <div id="webserv" class="functiontab" target="webserv.html"></div>
  120. <!-- Up Time Monitor -->
  121. <div id="utm" class="functiontab" target="uptime.html"></div>
  122. <!-- Network Tools -->
  123. <div id="networktool" class="functiontab" target="networktools.html"></div>
  124. <!-- Statistic Tools -->
  125. <div id="stats" class="functiontab" target="stats.html"></div>
  126. <!-- Utilities -->
  127. <div id="utils" class="functiontab" target="utils.html"></div>
  128. </div>
  129. </div>
  130. </div>
  131. <div class="sideWrapper" style="display:none;">
  132. <div class="fadingBackground" onclick="hideSideWrapper();"></div>
  133. <div class="content">
  134. <div class="sideWrapperMenu"></div>
  135. <iframe src="snippet/placeholder.html"></iframe>
  136. </div>
  137. </div>
  138. <br><br>
  139. <div class="ui divider"></div>
  140. <div class="ui container" style="color: grey; font-size: 90%">
  141. <p>CopyRight Zoraxy Project and its authors © 2021 - <span class="year"></span></p>
  142. </div>
  143. <div id="messageBox" class="ui green floating big compact message">
  144. <p><i class="green check circle icon"></i> There are no messages</p>
  145. </div>
  146. <div id="confirmBox" style="display:none;">
  147. <div class="ui top attached progress">
  148. <div class="bar" style="width: 100%; min-width: 0px;"></div>
  149. </div>
  150. <div class="confirmBoxBody">
  151. <button class="ui red basic mini circular icon right floated button" style="margin-left: 0.4em;"><i class="ui times icon"></i></button>
  152. <button class="ui green basic mini circular icon right floated button"><i class="ui check icon"></i></button>
  153. <div class="questionToConfirm">Confirm Exit?</div>
  154. </div>
  155. </div>
  156. <br><br>
  157. <script>
  158. $(".year").text(new Date().getFullYear());
  159. /*
  160. Loader function
  161. Load all the components view from the
  162. components/ directory into their corrisponding divs
  163. */
  164. let loadingComponents = 0;
  165. function initTabs(callback=undefined){
  166. $('.functiontab').each(function(){
  167. let loadTarget = $(this).attr("target");
  168. if (loadTarget != undefined){
  169. $(this).load("./components/" + loadTarget, function(){
  170. loadingComponents--;
  171. });
  172. loadingComponents++;
  173. }else{
  174. $(this).html(`<p>Unable to load components for this tab</p>`);
  175. }
  176. })
  177. if (callback != undefined){
  178. waitInit(callback);
  179. }
  180. }
  181. function waitInit(callback = undefined, retryCount = 0){
  182. if (loadingComponents > 0 && retryCount < 5){
  183. setTimeout(function(){
  184. waitInit(callback, retryCount++);
  185. }, 300);
  186. }else if (loadingComponents == 0){
  187. callback();
  188. }else{
  189. alert("Missing component. Please check if your installation is complete.")
  190. }
  191. }
  192. initTabs(function(){
  193. initRPStaste();
  194. if (window.location.hash.length > 1){
  195. let tabID = window.location.hash.substr(1);
  196. openTabById(tabID);
  197. }else{
  198. openTabById("status");
  199. }
  200. $(".ui.dropdown").dropdown();
  201. $(".ui.checkbox").checkbox();
  202. //Click on the current tab
  203. $("#mainmenu").find(".item").each(function(){
  204. $(this).on("click", function(event){
  205. let tabid = $(this).attr("tag");
  206. openTabById(tabid);
  207. });
  208. });
  209. //Initialize all table that is sortable
  210. $('table').tablesort();
  211. });
  212. function logout() {
  213. $.get("/api/auth/logout", function(response) {
  214. if (response === "OK") {
  215. setTimeout(function(){
  216. window.location.href = "/login.html";
  217. }, 300);
  218. }
  219. });
  220. }
  221. function toggleTheme(){
  222. if ($("body").hasClass("darkTheme")){
  223. $("body").removeClass("darkTheme")
  224. $("#themeColorButton").html(`<i class="ui moon icon"></i>`);
  225. }else{
  226. $("body").addClass("darkTheme");
  227. $("#themeColorButton").html(`<i class="ui sun icon"></i>`);
  228. }
  229. }
  230. function getTabButtonById(targetTabId){
  231. let targetTabBtn = undefined;
  232. $("#mainmenu").find(".item").each(function(){
  233. let tabid = $(this).attr("tag");
  234. if (tabid == targetTabId){
  235. targetTabBtn = $(this);
  236. }
  237. });
  238. return targetTabBtn;
  239. }
  240. //Select and open a tab by its tag id
  241. let tabSwitchEventBind = {}; //Bind event to tab switch by tabid
  242. function openTabById(tabID){
  243. let targetBtn = getTabButtonById(tabID);
  244. if (targetBtn == undefined){
  245. alert("Invalid tabid given");
  246. return;
  247. }
  248. if (window.innerWidth < 750){
  249. //RWD mode, hide toolbar
  250. $(".toolbar").fadeOut('fast');
  251. }
  252. $("#mainmenu").find(".item").removeClass("active");
  253. $(targetBtn).addClass("active");
  254. $(".functiontab").hide();
  255. $("#" + tabID).fadeIn('fast', function(){
  256. setTimeout(function(){
  257. if (tabSwitchEventBind[tabID]){
  258. tabSwitchEventBind[tabID]();
  259. }
  260. },100)
  261. });
  262. $('html,body').animate({scrollTop: 0}, 'fast');
  263. window.location.hash = tabID;
  264. }
  265. $(window).on("resize", function(){
  266. if (window.innerWidth >= 750 && $(".toolbar").is(":visible") == false){
  267. $(".toolbar").show();
  268. }
  269. });
  270. function msgbox(message, succ=true, delayDuration=3000){
  271. let icon = `<i class="ui info circle icon"></i>`;
  272. if (succ){
  273. $("#messageBox").attr("class", "ui green floating compact message")
  274. icon = `<i class="ui green circle check icon"></i>`;
  275. }else{
  276. message = message.capitalize();
  277. $("#messageBox").attr("class", "ui red floating compact message")
  278. icon = `<i class="ui red circle times icon"></i>`;
  279. }
  280. $("#messageBox").html(`${icon} ${message}`);
  281. $("#messageBox").stop().finish().fadeIn("fast").delay(delayDuration).fadeOut("fast");
  282. }
  283. function confirmBox(question_to_confirm, callback, delaytime=15) {
  284. var progressBar = $("#confirmBox .bar");
  285. var questionElement = $("#confirmBox .questionToConfirm");
  286. //Just to make sure there are no animation runnings
  287. progressBar.stop();
  288. // Update the question to confirm
  289. questionElement.text(question_to_confirm);
  290. // Start the progress bar animation
  291. progressBar.css("width", "100%");
  292. progressBar.animate({ width: "0%", easing: "linear" }, delaytime * 1000, function() {
  293. // Animation complete, invoke the callback with undefined
  294. callback(undefined);
  295. //Unset the event listener
  296. $("#confirmBox .ui.green.button").off("click");
  297. // Hide the confirm box
  298. $("#confirmBox").hide();
  299. });
  300. // Bind click event to "Yes" button
  301. $("#confirmBox .ui.green.button").on("click", function() {
  302. // Stop the progress bar animation
  303. progressBar.stop();
  304. // Invoke the callback with true
  305. callback(true);
  306. // Hide the confirm box
  307. $("#confirmBox").hide();
  308. //Unset the event listener
  309. $("#confirmBox .ui.green.button").off("click");
  310. });
  311. // Bind click event to "No" button
  312. $("#confirmBox .ui.red.button").on("click", function() {
  313. // Stop the progress bar animation
  314. progressBar.stop();
  315. // Invoke the callback with false
  316. callback(false);
  317. // Hide the confirm box
  318. $("#confirmBox").hide();
  319. //Unset the event listener
  320. $("#confirmBox .ui.red.button").off("click");
  321. });
  322. // Show the confirm box
  323. $("#confirmBox").show().transition('jiggle');
  324. }
  325. /*
  326. Toggles for side wrapper
  327. */
  328. function showSideWrapper(scriptpath=""){
  329. if (scriptpath != ""){
  330. $(".sideWrapper iframe").attr("src", scriptpath);
  331. }
  332. if ($(".sideWrapper .content").transition("is animating") || $(".sideWrapper .content").transition("is visible")){
  333. return
  334. }
  335. $(".sideWrapper").show();
  336. $(".sideWrapper .fadingBackground").fadeIn("fast");
  337. $(".sideWrapper .content").transition('slide left in', 300);
  338. $("body").css("overflow", "hidden");
  339. }
  340. function hideSideWrapper(discardFrameContent = false){
  341. if (discardFrameContent){
  342. $(".sideWrapper iframe").attr("src", "snippet/placeholder.html");
  343. }
  344. if ($(".sideWrapper .content").transition("is animating") || !$(".sideWrapper .content").transition("is visible")){
  345. return
  346. }
  347. $(".sideWrapper .content").transition('slide left out', 300, function(){
  348. $(".sideWrapper .fadingBackground").fadeOut("fast", function(){
  349. $(".sideWrapper").hide();
  350. });
  351. });
  352. $("body").css("overflow", "auto");
  353. }
  354. </script>
  355. </body>
  356. </html>