MainUI.php 9.9 KB

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