MainUI.php 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279
  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. <div class="ts contextmenu">
  82. <div class="item" onclick="contextmenu_extract()">
  83. Open
  84. <span class="description">Enter</span>
  85. </div>
  86. <div class="item" onclick="functionbar_extract()">
  87. Extract
  88. <span class="description">F5</span>
  89. </div>
  90. <div class="item" onclick="functionbar_info()">
  91. Properties
  92. <span class="description">Alt-Enter</span>
  93. </div>
  94. </div>
  95. </body>
  96. <script>
  97. //Global variable
  98. var random = Math.floor((Math.random() * 10000) + 1000);
  99. var file = "<?php echo $_GET["file"] ?>";
  100. ts('*').contextmenu({
  101. menu: '.ts.contextmenu'
  102. });
  103. $('body').on('click', function(e) {
  104. if (e.target !== this)
  105. return;
  106. $("tr").removeAttr("style");
  107. });
  108. document.onkeydown = function(e) {
  109. if($("[style='background-color: #e9e9e9;']").length > 0){
  110. var htmlelement = $("[style='background-color: #e9e9e9;']");
  111. }else{
  112. var htmlelement = $("#tbody tr:first");
  113. }
  114. switch (e.keyCode) {
  115. case 9:
  116. if(htmlelement.prev().length > 0){
  117. var next = htmlelement.prev();
  118. $("tr").removeAttr("style");
  119. $(next).attr("style","background-color: #e9e9e9;");
  120. }
  121. case 13:
  122. var htmlelement = $("[style='background-color: #e9e9e9;']");
  123. load(htmlelement);
  124. break;
  125. case 38:
  126. if(htmlelement.prev().length > 0){
  127. var next = htmlelement.prev();
  128. $("tr").removeAttr("style");
  129. $(next).attr("style","background-color: #e9e9e9;");
  130. }else{
  131. $("tr").removeAttr("style");
  132. $(htmlelement).attr("style","background-color: #e9e9e9;");
  133. }
  134. break;
  135. case 40:
  136. if(htmlelement.next().length > 0){
  137. var next = htmlelement.next();
  138. $("tr").removeAttr("style");
  139. $(next).attr("style","background-color: #e9e9e9;");
  140. }else{
  141. $("tr").removeAttr("style");
  142. $(htmlelement).attr("style","background-color: #e9e9e9;");
  143. }
  144. break;
  145. }
  146. };
  147. //for load data into table
  148. load($(returnBtn));
  149. function onsingleclick(htmlelement){
  150. $("tr").removeAttr("style");
  151. $(htmlelement).attr("style","background-color: #e9e9e9;");
  152. }
  153. function load(htmlelement){
  154. if($(htmlelement).attr("attr") == "Dir"){
  155. $("#breadcrumb").html('<button class="ts icon mini basic button" disabled><i class="level up icon"></i></button> <p class="section"><i class="loading circle notched icon"></i>Fetching..</p>');
  156. //for load data into table
  157. $.get("opr.php?method=l&rand=" + random + "&file=" + file + "&dir=" + $(htmlelement).attr("path"), function( raw ) {
  158. //clear table for pepare load data into table
  159. $("#thead").html("");
  160. $("#tbody").html("");
  161. var data = JSON.parse(raw); //parse it
  162. var header = data["Header"];
  163. //create thead
  164. $(data["Header"]).each(function( key, value ) {
  165. $("#thead").append("<th>" + value + "</th>");//create header (thead) first
  166. });
  167. //create tbody
  168. $(data["Information"]).each(function( a, value ) {
  169. //to check if attr not exists. if not exists, assume it is an file.
  170. if(typeof value["Attributes"] === 'undefined'){
  171. var attr = "File";
  172. }else{
  173. if(value["Attributes"].includes("D")){
  174. var attr = "Dir";
  175. }else{
  176. var attr = "File";
  177. }
  178. }
  179. //create HTML structure
  180. var tmp = "";
  181. tmp = tmp + '<tr path="' + value["Path"] + '" attr="' + attr + '" ondblclick="load(this)" onclick="onsingleclick(this)" oncontextmenu="onsingleclick(this)">'
  182. $.each(data["Header"], function( a, key ) {
  183. if(typeof value[key] !== 'undefined'){
  184. if(key == "Path"){
  185. //create fanastic icon to user
  186. if(attr == "Dir"){
  187. var tdicon = '<i class="folder outline icon"></i>';
  188. }else{
  189. var tdicon = '<i class="file outline icon"></i>';
  190. }
  191. var tdpath = value[key].replace(new RegExp($(htmlelement).attr("path") + "/"),"");
  192. if(tdpath.includes("?")){
  193. var tdicon = '<i class="exclamation triangle icon"></i>';
  194. }
  195. tmp = tmp + "<td>" + tdicon + tdpath + "</td>";
  196. }else{
  197. tmp = tmp + "<td>" + value[key] + "</td>";
  198. }
  199. }else{
  200. tmp = tmp + "<td></td>";
  201. }
  202. });
  203. $("#tbody").append(tmp + "</tr>");
  204. });
  205. //process for Prev button
  206. var path = $(htmlelement).attr("path").split("/");
  207. var previousPath = $(htmlelement).attr("path").replace(/([^\/]+)$/, '').slice(0, -1);
  208. if(previousPath == $(htmlelement).attr("path")){
  209. previousPath = "";
  210. }
  211. console.log(previousPath);
  212. $("#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> <p href="#!" class="section">' + file.replace(/^.*[\\\/]/, '') +'</p><div class="divider">/</div>');
  213. if($(htmlelement).attr("path").length > 1){
  214. $.each(path, function( a, key ) {
  215. $("#breadcrumb").append('<p href="#!" class="section"><i class="folder icon"></i>' + key + '</p><div class="divider">/</div>');
  216. });
  217. }
  218. });
  219. }else{
  220. //if it was file, show it.
  221. showDialog("ProgressUI.php?method=e&rand=" + random + "&file=" + file + "&dir=" + $(htmlelement).attr("path"),720,250);
  222. random = Math.floor((Math.random() * 10000) + 1000);
  223. }
  224. }
  225. function contextmenu_extract(){
  226. showDialog("ProgressUI.php?method=e&rand=" + random + "&file=" + file + "&dir=" + $("[style='background-color: #e9e9e9;']").attr("path"),720,250);
  227. random = Math.floor((Math.random() * 10000) + 1000);
  228. }
  229. function functionbar_extract(){
  230. //extract files or dir , if file then pass method=e , if dir then pass method=x
  231. if($("[style='background-color: #e9e9e9;']").attr("attr") == "Dir"){
  232. showDialog("CopyNMoveUI.php?method=x&rand=" + random + "&file=" + file + "&dir=" + $($("[style='background-color: #e9e9e9;']")).attr("path"),720,250);
  233. }else if($("[style='background-color: #e9e9e9;']").attr("attr") == "File"){
  234. showDialog("CopyNMoveUI.php?method=e&rand=" + random + "&file=" + file + "&dir=" + $("[style='background-color: #e9e9e9;']").attr("path"),720,250);
  235. }else{
  236. showDialog("CopyNMoveUI.php?method=x&rand=" + random + "&file=" + file + "&dir=" + $("#returnBtn").attr("currPath"),720,250);
  237. }
  238. //generate new number for next extraction
  239. random = Math.floor((Math.random() * 10000) + 1000);
  240. }
  241. function functionbar_info(){
  242. showDialog("infoUI.php?file=" + file,340,250);
  243. }
  244. function showDialog(href,x,y){
  245. if(ao_module_virtualDesktop){
  246. ao_module_newfw('7-Zip File Manager/' + href,'7-Zip','file outline','7-ZipProgressUI' + Math.floor(Math.random()*100),x,y);
  247. }else{
  248. $.get( href, function( data ) {
  249. $( "#modaldata" ).html( data );
  250. ts('#modal').modal("show");
  251. });
  252. }
  253. }
  254. function msgbox(content,bgcolor,fontcolor){
  255. $(".snackbar").attr("style",'background-color: ' + bgcolor + ';color:' + fontcolor);
  256. ts('.snackbar').snackbar({
  257. content: content,
  258. onAction: () => {
  259. $(".snackbar").removeAttr("style");
  260. }
  261. });
  262. }
  263. </script>
  264. </html>