ProgressUI.php 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  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"><?php echo filesize($_GET["file"]); ?> 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(Math.floor(f_size / f_totaltime) + " b/s");
  77. f_time += 1;
  78. });
  79. }, 1000);
  80. f_load;
  81. $.get("opr.php?method=" + f_method + "&rand=" + f_rand + "&file=" + f_file + "&dir=" + f_dir , function( raw ) {
  82. clearInterval(f_load);
  83. if(!f_cancel){
  84. if(f_destdir.length >0){
  85. $.get( '../SystemAOB/functions/file_system/copy_folder.php?from=../../../7-Zip%20File%20Manager/tmp/' + f_rand +'/&target=../../' + f_destdir + f_rand + "/", function(data) {
  86. if(data !== "DONE"){
  87. msgbox(data,"","");
  88. if(ao_module_virtualDesktop){
  89. parent.msgbox(data,"","");
  90. ao_module_close();
  91. }else{
  92. msgbox(data,"","");
  93. setTimeout(function(){ts('#modal').modal('hide')},1500);
  94. }
  95. }
  96. $.get( '../SystemAOB/functions/file_system/rename.php?file=../../' + f_destdir + f_rand + '&newFileName=../../' + f_destdir + f_file.replace(/^.*[\\\/]/, '').replace(/\./,"") + '/&hex=false', function(data) {
  97. if(data !== "DONE"){
  98. $.get( '../SystemAOB/functions/file_system/delete.php?filename=../../' + f_destdir + f_rand, function(data) {
  99. });
  100. if(ao_module_virtualDesktop){
  101. parent.msgbox(data,"","");
  102. ao_module_close();
  103. }else{
  104. msgbox(data,"","");
  105. setTimeout(function(){ts('#modal').modal('hide')},1500);
  106. }
  107. }else{
  108. f_openFile(true);
  109. }
  110. });
  111. });
  112. }else{
  113. f_openFile(false);
  114. }
  115. }
  116. });
  117. function f_openFile(bool){
  118. var Folder = "";
  119. // bool = true then it have destdir
  120. // bool = false then it dont have destdir
  121. if(bool == true){
  122. //f_method = e then it is only single file
  123. //f_method = x then it is a folder
  124. if(f_method == "e"){
  125. Folder = f_destdir.substring(3) + f_file.replace(/^.*[\\\/]/, '').replace(/\./,"") + "/" + f_dir.replace(/^.*[\\\/]/, '');
  126. }else if(f_method == "x"){
  127. Folder = f_destdir.substring(3) + f_file.replace(/^.*[\\\/]/, '').replace(/\./,"");
  128. }
  129. }else{
  130. //f_method = e then it is only single file
  131. //f_method = x then it is a folder
  132. if(f_method == "e"){
  133. Folder = "7-Zip File Manager/tmp/" + f_rand + "/" + f_dir.replace(/^.*[\\\/]/, '');
  134. }else if(f_method == "x"){
  135. Folder = "7-Zip File Manager/tmp/" + f_rand + "/";
  136. }
  137. }
  138. console.log(f_rand + Folder);
  139. if(ao_module_virtualDesktop){
  140. if(f_method == "e"){
  141. ao_module_openFile(Folder,"7-Zip Preview");
  142. }else if(f_method == "x"){
  143. ao_module_openPath(Folder);
  144. }
  145. ao_module_close();
  146. }else{
  147. if(f_method == "e"){
  148. window.open("../" + Folder);
  149. }else if(f_method == "x"){
  150. window.open("../SystemAOB/functions/file_system/index.php?controlLv=2#../../../" + Folder);
  151. }
  152. setTimeout(function(){ts('#modal').modal('hide')},1500);
  153. }
  154. }
  155. function f_convert(time){
  156. var hours = Math.floor(time / 3600);
  157. var minutes = Math.floor((time - (hours * 3600)) / 60);
  158. var seconds = time - (hours * 3600) - (minutes * 60);
  159. if(hours < 10){
  160. var dhour = "0" + hours;
  161. }else{
  162. var dhour = hours;
  163. }
  164. if(minutes < 10){
  165. var dminutes = "0" + minutes;
  166. }else{
  167. var dminutes = minutes;
  168. }
  169. if(seconds < 10){
  170. var dseconds = "0" + seconds;
  171. }else{
  172. var dseconds = seconds;
  173. }
  174. if(!isNaN(hours) && !isNaN(minutes) && !isNaN(seconds)){
  175. var formatted = dhour + ":" + dminutes + ":" + dseconds;
  176. }else{
  177. var formatted = "00:00:00";
  178. }
  179. return formatted;
  180. }
  181. function msgbox(content,bgcolor,fontcolor){
  182. $(".snackbar").attr("style",'background-color: ' + bgcolor + ';color:' + fontcolor);
  183. ts('.snackbar').snackbar({
  184. content: content,
  185. onAction: () => {
  186. $(".snackbar").removeAttr("style");
  187. }
  188. });
  189. }
  190. function f_close(){
  191. if(ao_module_virtualDesktop){
  192. ao_module_close();
  193. }else{
  194. setTimeout(function(){ts('#modal').modal('hide')},1500);
  195. }
  196. }
  197. </script>
  198. </html>