ProgressUI.php 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  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. }
  14. .ts.form .inline.field label {
  15. min-width: 50%;
  16. }
  17. .ts.basic.dropdown, .ts.form select {
  18. max-width: 50%;
  19. }
  20. </style>
  21. </head>
  22. <body>
  23. <br>
  24. <div class="ts container">
  25. <div class="ts grid">
  26. <div class="eight wide column">
  27. <span style="text-align:left">Elasped time:</span>
  28. <span style="text-align:right" id="time">00:00:00</span>
  29. </div>
  30. <div class="eight wide column">
  31. <span style="text-align:left">Total size:</span>
  32. <span style="text-align:right" id="totalsize">0 b</span>
  33. </div>
  34. <div class="eight wide column">
  35. <span style="text-align:left">Remaining time:</span>
  36. <span style="text-align:right" id="remaining">00:00:00</span>
  37. </div>
  38. <div class="eight wide column">
  39. <span style="text-align:left">Speed:</span>
  40. <span style="text-align:right" id="speed">0 b/s</span>
  41. </div>
  42. <div class="sixteen wide column">
  43. <span style="text-align:left">Loading...</span>
  44. <div class="ts progress">
  45. <div class="bar" id="bar" style="width: 0%"></div>
  46. </div>
  47. </div>
  48. <div class="eight wide column"></div>
  49. <div class="eight wide column">
  50. <button class="ts basic button" style="width:100%" onclick="f_close();f_cancel = true;">Cancel</button>
  51. </div>
  52. </div>
  53. </div>
  54. <div class="ts bottom right snackbar">
  55. <div class="content"></div>
  56. </div>
  57. </body>
  58. <script>
  59. var f_method = "<?php echo $_GET["method"] ?>";
  60. var f_rand = "<?php echo $_GET["rand"] ?>";
  61. var f_file = "<?php echo $_GET["file"] ?>";
  62. var f_dir = "<?php echo $_GET["dir"] ?>";
  63. var f_size = "<?php echo filesize($_GET["file"]); ?>";
  64. var f_destdir = "<?php echo $_GET["destdir"]; ?>";
  65. var f_time = 1;
  66. var f_totaltime = 1;
  67. var f_cancel = false;
  68. var f_load = setInterval(function(){
  69. $.get( "./tmp/" + f_rand + "messages", function( data ) {
  70. var progress = data.match(/ ([0-9]{0,2}%)/gim);
  71. console.log(progress[progress.length - 1]);
  72. f_totaltime = Math.floor(f_time / (parseInt(progress[progress.length - 1])/100));
  73. $("#bar").attr("style","width: " + progress[progress.length - 1]);
  74. $("#time").text(f_convert(f_time));
  75. $("#remaining").text(f_convert(f_totaltime - f_time));
  76. $("#speed").text(f_filesize(Math.floor(f_size / f_totaltime)) + "/s");
  77. $("#totalsize").text(f_filesize(f_size));
  78. f_time += 1;
  79. });
  80. }, 1000);
  81. f_load;
  82. $.get("opr.php?method=" + f_method + "&rand=" + f_rand + "&file=" + f_file + "&dir=" + f_dir , function( raw ) {
  83. clearInterval(f_load);
  84. if(!f_cancel){
  85. if(f_destdir.length >0){
  86. $.get( '../SystemAOB/functions/file_system/copy_folder.php?from=../../../7-Zip%20File%20Manager/tmp/' + f_rand +'/&target=../../' + f_destdir + f_rand + "/", function(data) {
  87. if(data !== "DONE"){
  88. msgbox(data,"","");
  89. if(ao_module_virtualDesktop){
  90. parent.msgbox(data,"","");
  91. ao_module_close();
  92. }else{
  93. msgbox(data,"","");
  94. setTimeout(function(){ts('#modal').modal('hide')},1500);
  95. }
  96. }
  97. $.get( '../SystemAOB/functions/file_system/rename.php?file=../../' + f_destdir + f_rand + '&newFileName=../../' + f_destdir + f_file.replace(/^.*[\\\/]/, '').replace(/\./,"") + '/&hex=false', function(data) {
  98. if(data !== "DONE"){
  99. $.get( '../SystemAOB/functions/file_system/delete.php?filename=../../' + f_destdir + f_rand, function(data) {
  100. });
  101. if(ao_module_virtualDesktop){
  102. parent.msgbox(data,"","");
  103. ao_module_close();
  104. }else{
  105. msgbox(data,"","");
  106. setTimeout(function(){ts('#modal').modal('hide')},1500);
  107. }
  108. }else{
  109. f_openFile(true);
  110. }
  111. });
  112. });
  113. }else{
  114. f_openFile(false);
  115. }
  116. }
  117. });
  118. function f_openFile(bool){
  119. var Folder = "";
  120. // bool = true then it have destdir
  121. // bool = false then it dont have destdir
  122. if(bool == true){
  123. //f_method = e then it is only single file
  124. //f_method = x then it is a folder
  125. if(f_method == "e"){
  126. Folder = f_destdir.substring(3) + f_file.replace(/^.*[\\\/]/, '').replace(/\./,"") + "/" + f_dir.replace(/^.*[\\\/]/, '');
  127. }else if(f_method == "x"){
  128. Folder = f_destdir.substring(3) + f_file.replace(/^.*[\\\/]/, '').replace(/\./,"");
  129. }
  130. }else{
  131. //f_method = e then it is only single file
  132. //f_method = x then it is a folder
  133. if(f_method == "e"){
  134. Folder = "7-Zip File Manager/tmp/" + f_rand + "/" + f_dir.replace(/^.*[\\\/]/, '');
  135. }else if(f_method == "x"){
  136. Folder = "7-Zip File Manager/tmp/" + f_rand + "/";
  137. }
  138. }
  139. console.log(f_rand + Folder);
  140. if(ao_module_virtualDesktop){
  141. if(f_method == "e"){
  142. ao_module_openFile(Folder,"7-Zip Preview");
  143. }else if(f_method == "x"){
  144. ao_module_openPath(Folder);
  145. }
  146. ao_module_close();
  147. }else{
  148. if(f_method == "e"){
  149. window.open("../" + Folder);
  150. }else if(f_method == "x"){
  151. window.open("../SystemAOB/functions/file_system/index.php?controlLv=2#../../../" + Folder);
  152. }
  153. setTimeout(function(){ts('#modal').modal('hide')},1500);
  154. }
  155. }
  156. function f_convert(time){
  157. var hours = Math.floor(time / 3600);
  158. var minutes = Math.floor((time - (hours * 3600)) / 60);
  159. var seconds = time - (hours * 3600) - (minutes * 60);
  160. if(hours < 10){
  161. var dhour = "0" + hours;
  162. }else{
  163. var dhour = hours;
  164. }
  165. if(minutes < 10){
  166. var dminutes = "0" + minutes;
  167. }else{
  168. var dminutes = minutes;
  169. }
  170. if(seconds < 10){
  171. var dseconds = "0" + seconds;
  172. }else{
  173. var dseconds = seconds;
  174. }
  175. if(!isNaN(hours) && !isNaN(minutes) && !isNaN(seconds)){
  176. var formatted = dhour + ":" + dminutes + ":" + dseconds;
  177. }else{
  178. var formatted = "00:00:00";
  179. }
  180. return formatted;
  181. }
  182. function f_filesize(size){
  183. if(size >= 1073741824){
  184. return Math.floor(size/1073741824*100)/100 + "GB";
  185. }else if(size >= 1048576){
  186. return Math.floor(size/1048576*100)/100 + "MB";
  187. }else if(size >= 1024){
  188. return Math.floor(size/1024*100)/100 + "KB";
  189. }else{
  190. return size + "Bytes";
  191. }
  192. }
  193. function msgbox(content,bgcolor,fontcolor){
  194. $(".snackbar").attr("style",'background-color: ' + bgcolor + ';color:' + fontcolor);
  195. ts('.snackbar').snackbar({
  196. content: content,
  197. onAction: () => {
  198. $(".snackbar").removeAttr("style");
  199. }
  200. });
  201. }
  202. function f_close(){
  203. if(ao_module_virtualDesktop){
  204. ao_module_close();
  205. }else{
  206. setTimeout(function(){ts('#modal').modal('hide')},1500);
  207. }
  208. }
  209. </script>
  210. </html>