MainUI.php 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="UTF-8">
  5. <script src="../script/jquery.min.js"></script>
  6. <link rel="stylesheet" href="../script/tocas/tocas.css">
  7. <script type='text/javascript' src="../script/tocas/tocas.js"></script>
  8. <script type='text/javascript' src="../script/ao_module.js"></script>
  9. <title>7z File Manager</title>
  10. <style>
  11. body{
  12. background-color:white;
  13. -webkit-user-select: none; /* Safari */
  14. -moz-user-select: none; /* Firefox */
  15. -ms-user-select: none; /* IE10+/Edge */
  16. user-select: none; /* Standard */
  17. }
  18. tr:hover {
  19. background-color: #fafafa;
  20. }
  21. @media (max-width: 767px){
  22. .ts.bottom.right.snackbar.active{
  23. width: 100% !important;
  24. bottom: 0px !important;
  25. right: 0px !important;
  26. }
  27. .ts.snackbar:not(.inline) .content {
  28. margin-bottom: 7px;
  29. }
  30. }
  31. </style>
  32. </head>
  33. <body>
  34. <div class="ts labeled icon menu" style="box-shadow: 0px 0px 0px 0 #000000 !important;">
  35. <a class="item" onclick="msgbox('Error: Operation is not supported','red','white')">
  36. <i class="plus icon"></i> Add
  37. </a>
  38. <a class="item" onclick="functionbar_extract();">
  39. <i class="minus icon"></i> Extract
  40. </a>
  41. <a class="item" onclick="msgbox('Warning: Not implemented','yellow','Black')">
  42. <i class="chevron down icon"></i> Test
  43. </a>
  44. <a class="item" onclick="functionbar_extract();">
  45. <i class="copy icon"></i> Copy
  46. </a>
  47. <a class="item" onclick="functionbar_extract();">
  48. <i class="move icon"></i> Move
  49. </a>
  50. <a class="item" onclick="msgbox('Error: Operation is not supported','red','white')">
  51. <i class="remove icon"></i> Delete
  52. </a>
  53. <a class="item" onclick="functionbar_info();">
  54. <i class="notice icon"></i> Info
  55. </a>
  56. </div>
  57. <div class="ts breadcrumb" style="left: 20px;" id="breadcrumb">
  58. <button class="ts icon mini basic button" path="" attr="Dir" id="returnBtn" onclick="load(this)">
  59. <i class="level up icon"></i>
  60. </button>
  61. <p href="#!" class="section"><?php echo $_GET["file"] ?></p>
  62. </div>
  63. <table class="ts borderless table">
  64. <thead>
  65. <tr id="thead">
  66. </tr>
  67. </thead>
  68. <tbody id="tbody">
  69. </tbody>
  70. </table>
  71. <!-- use for displaying dialog , for VDI user , use VDI module instead -->
  72. <div class="ts modals dimmer">
  73. <dialog id="modal" class="ts basic modal" style="background-color: white;color: black!important" open>
  74. <div class="content" id="modaldata">
  75. </div>
  76. </dialog>
  77. </div>
  78. <div class="ts bottom right snackbar">
  79. <div class="content"></div>
  80. </div>
  81. </body>
  82. <script>
  83. //Global variable
  84. var random = Math.floor((Math.random() * 10000) + 1000);
  85. var file = "<?php echo $_GET["file"] ?>";
  86. //for load data into table
  87. load($(returnBtn));
  88. function onsingleclick(htmlelement){
  89. $("tr").removeAttr("style");
  90. $(htmlelement).attr("style","background-color: #e9e9e9;");
  91. }
  92. function load(htmlelement){
  93. if($(htmlelement).attr("attr") == "Dir"){
  94. $("#breadcrumb").html('<button class="ts icon mini basic button" disabled><i class="level up icon"></i></button>&nbsp;<p class="section"><i class="loading circle notched icon"></i>Fetching..</p>');
  95. //for load data into table
  96. $.get("opr.php?method=l&rand=" + random + "&file=" + file + "&dir=" + $(htmlelement).attr("path"), function( raw ) {
  97. //clear table for pepare load data into table
  98. $("#thead").html("");
  99. $("#tbody").html("");
  100. var data = JSON.parse(raw); //parse it
  101. var header = data["Header"];
  102. //create thead
  103. $(data["Header"]).each(function( key, value ) {
  104. $("#thead").append("<th>" + value + "</th>");//create header (thead) first
  105. });
  106. //create tbody
  107. $(data["Information"]).each(function( a, value ) {
  108. //to check if attr not exists, if not exists, assume it is an file.
  109. if(typeof value["Attributes"] === 'undefined'){
  110. var attr = "File";
  111. }else{
  112. if(value["Attributes"].includes("D")){
  113. var attr = "Dir";
  114. }else{
  115. var attr = "File";
  116. }
  117. }
  118. //create HTML structure
  119. var tmp = "";
  120. tmp = tmp + '<tr path="' + value["Path"] + '" attr="' + attr + '" ondblclick="load(this)" onclick="onsingleclick(this)">'
  121. $.each(data["Header"], function( a, key ) {
  122. if(typeof value[key] !== 'undefined'){
  123. tmp = tmp + "<td>" + value[key].replace(new RegExp($(htmlelement).attr("path") + "/"),"") + "</td>";
  124. }else{
  125. tmp = tmp + "<td></td>";
  126. }
  127. });
  128. $("#tbody").append(tmp + "</tr>");
  129. });
  130. //process for Prev button
  131. var path = $(htmlelement).attr("path").split("/");
  132. var previousPath = $(htmlelement).attr("path").replace(/([^\/]+)$/, '').slice(0, -1);
  133. if(previousPath == $(htmlelement).attr("path")){
  134. previousPath = "";
  135. }
  136. console.log(previousPath);
  137. $("#breadcrumb").html('<button class="ts icon mini basic button" currPath="' + $(htmlelement).attr("path") + '" path="' + previousPath + '" attr="Dir" id="returnBtn" onclick="load(this)"><i class="level up icon"></i></button>&nbsp;<p href="#!" class="section">' + file +'</p><div class="divider">/</div>');
  138. if($(htmlelement).attr("path").length > 1){
  139. $.each(path, function( a, key ) {
  140. $("#breadcrumb").append('<p href="#!" class="section"><i class="folder icon"></i>' + key + '</p><div class="divider">/</div>');
  141. });
  142. }
  143. });
  144. }else{
  145. //if it was file, show it.
  146. showDialog("ProgressUI.php?method=e&rand=" + random + "&file=" + file + "&dir=" + $(htmlelement).attr("path"));
  147. random = Math.floor((Math.random() * 10000) + 1000);
  148. }
  149. }
  150. function functionbar_extract(){
  151. //extract files or dir , if file then pass method=e , if dir then pass method=x
  152. if($("[style='background-color: #e9e9e9;']").attr("attr") == "Dir"){
  153. showDialog("CopyNMoveUI.php?method=x&rand=" + random + "&file=" + file + "&dir=" + $($("[style='background-color: #e9e9e9;']")).attr("path"));
  154. }else if($("[style='background-color: #e9e9e9;']").attr("attr") == "File"){
  155. showDialog("CopyNMoveUI.php?method=e&rand=" + random + "&file=" + file + "&dir=" + $("[style='background-color: #e9e9e9;']").attr("path"));
  156. }else{
  157. showDialog("CopyNMoveUI.php?method=x&rand=" + random + "&file=" + file + "&dir=" + $("#returnBtn").attr("currPath"));
  158. }
  159. //generate new number for next extraction
  160. random = Math.floor((Math.random() * 10000) + 1000);
  161. }
  162. function functionbar_info(){
  163. showDialog("infoUI.php?file=" + file);
  164. }
  165. function showDialog(href){
  166. if(ao_module_virtualDesktop){
  167. ao_module_newfw('7-Zip File Manager/' + href,'7-Zip','file outline','7-ZipProgressUI');
  168. }else{
  169. $.get( href, function( data ) {
  170. $( "#modaldata" ).html( data );
  171. ts('#modal').modal("show");
  172. });
  173. }
  174. }
  175. function msgbox(content,bgcolor,fontcolor){
  176. $(".snackbar").attr("style",'background-color: ' + bgcolor + ';color:' + fontcolor);
  177. ts('.snackbar').snackbar({
  178. content: content,
  179. onAction: () => {
  180. $(".snackbar").removeAttr("style");
  181. }
  182. });
  183. }
  184. </script>
  185. </html>