downloadPageFolder.html 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. <!DOCTYPE HTML>
  2. <html>
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
  6. <title>{{hostname}} File Share</title>
  7. <link rel="stylesheet" href="script/skeleton/offline.css">
  8. <link rel="stylesheet" href="script/skeleton/normalize.css">
  9. <link rel="stylesheet" href="script/skeleton/skeleton.css">
  10. <script type="application/javascript" src="script/jquery.min.js"></script>
  11. <style>
  12. body{
  13. padding-bottom: 100px;
  14. }
  15. .bar{
  16. height: 12px;
  17. background-color: #1a1a1a;
  18. width: 100%;
  19. }
  20. .footer{
  21. position: fixed;
  22. bottom: 0px;
  23. height: 50px;
  24. width: 100%;
  25. background-color: #1a1a1a;
  26. padding: 20px;
  27. color: white;
  28. }
  29. .fileobject{
  30. cursor: pointer;
  31. }
  32. .fileobject:hover{
  33. background-color: #f5f5f5;
  34. }
  35. </style>
  36. </head>
  37. <body>
  38. <div class="bar"></div>
  39. <br>
  40. <div class="container">
  41. <h5>{{hostname}} File Sharing</h5>
  42. <h3>{{filename}}</h3>
  43. <div class="row">
  44. <div class="one-half column">
  45. <table class="u-full-width">
  46. <thead>
  47. <tr>
  48. <th>Property</th>
  49. <th>Value</th>
  50. </tr>
  51. </thead>
  52. <tbody>
  53. <tr>
  54. <td>MIME Type</td>
  55. <td>{{mime}}</td>
  56. </tr>
  57. <tr>
  58. <td>Folder Size</td>
  59. <td>{{size}}</td>
  60. </tr>
  61. <tr>
  62. <td>File Counts</td>
  63. <td>{{filecount}}</td>
  64. </tr>
  65. <tr>
  66. <td>Last Modification Time</td>
  67. <td>{{modtime}}</td>
  68. </tr>
  69. </tbody>
  70. </table>
  71. <a href="{{downloadurl}}"><button class="button-primary">Download</button></a>
  72. <p style="font-size: 80%;"><b>Depending on folder size, zipping might take a while to complete.</b></p>
  73. <br>
  74. <p>Request File ID: {{reqid}}</p>
  75. <p>Request Timestamp: {{reqtime}}</p>
  76. </div>
  77. <div class="one-half column" id="filelistWrapper" style="overflow-y: auto; padding-right: 0.5em;">
  78. <table class="u-full-width">
  79. <thead>
  80. <tr>
  81. <th>Filename</th>
  82. <th>Type</th>
  83. <th>Size</th>
  84. </tr>
  85. </thead>
  86. <tbody id="folderList">
  87. </tbody>
  88. </table>
  89. </div>
  90. </div>
  91. </div>
  92. <div class="footer">
  93. <div class="container">
  94. Cloud File Sharing Interface, Powered by <a style="color: white;" href="http://arozos.com">arozos</a>
  95. </div>
  96. </div>
  97. <script>
  98. var treeFileList = {{treelist}};
  99. var currentViewingRoot = ".";
  100. renderFileList(treeFileList["."]);
  101. console.log(treeFileList);
  102. function renderFileList(filelist){
  103. $("#folderList").html("");
  104. if (currentViewingRoot != "."){
  105. $("#folderList").append(`<tr class="fileobject" ondblclick="event.preventDefault(); parentdir();">
  106. <td style="padding-left: 8px;" colspan="3" > ↩ Back</td>
  107. </tr>`);
  108. }
  109. filelist.forEach(file => {
  110. var filetype = "File";
  111. var displayName = "";
  112. if (file.IsDir == true){
  113. filetype = "Folder";
  114. displayName = "📁 " + file.Filename;
  115. }else{
  116. displayName = "📄 " + file.Filename;
  117. }
  118. $("#folderList").append(`<tr class="fileobject" filename="${file.Filename}" relpath="${file.RelPath}" type="${filetype.toLocaleLowerCase()}" ondblclick="event.preventDefault(); openThis(this);">
  119. <td style="padding-left: 8px;">${displayName}</td>
  120. <td>${filetype}</td>
  121. <td>${file.Filesize}</td>
  122. </tr>`);
  123. });
  124. }
  125. //Went up one level
  126. function parentdir(){
  127. if (currentViewingRoot == "."){
  128. //Root dir. Do nothing
  129. }else{
  130. //Subdirs. travel up
  131. var dirinfo = currentViewingRoot.split("/");
  132. var nextDir = ".";
  133. if (currentViewingRoot.indexOf("/") < 0){
  134. //Parent dir will be root
  135. }else{
  136. dirinfo.pop();
  137. nextDir = dirinfo.join("/");
  138. }
  139. //Load the filelist
  140. if (treeFileList[nextDir] != undefined){
  141. currentViewingRoot = nextDir;
  142. renderFileList(treeFileList[nextDir]);
  143. }else{
  144. //Back to root on error
  145. currentViewingRoot = ".";
  146. renderFileList(treeFileList["."]);
  147. }
  148. }
  149. }
  150. function openThis(object){
  151. var targetFilename = $(object).attr("filename");
  152. var targetType = $(object).attr("type");
  153. var targetRelPath = $(object).attr("relpath");
  154. if (targetType == "folder"){
  155. //Folder. Build a new root file list for this
  156. var targetRenderList = treeFileList[targetRelPath];
  157. if (targetRenderList != undefined){
  158. currentViewingRoot = targetRelPath;
  159. renderFileList(targetRenderList);
  160. }
  161. }else{
  162. //File. Download it
  163. }
  164. }
  165. resizeDOMElement();
  166. function resizeDOMElement(){
  167. $("#filelistWrapper").css({
  168. height: window.innerHeight - $("#filelistWrapper").offset().top - 100,
  169. })
  170. }
  171. $(window).on("resize", function(){
  172. resizeDOMElement();
  173. })
  174. </script>
  175. </body>
  176. </html>