downloadPageFolder.html 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  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. .fileobject.active{
  36. background-color: #f5f5f5ee;
  37. }
  38. .noselect{
  39. -webkit-touch-callout: none; /* iOS Safari */
  40. -webkit-user-select: none; /* Safari */
  41. -khtml-user-select: none; /* Konqueror HTML */
  42. -moz-user-select: none; /* Old versions of Firefox */
  43. -ms-user-select: none; /* Internet Explorer/Edge */
  44. user-select: none;
  45. }
  46. </style>
  47. </head>
  48. <body>
  49. <div class="bar"></div>
  50. <br>
  51. <div class="container">
  52. <h5>{{hostname}} File Sharing</h5>
  53. <h3>{{filename}}</h3>
  54. <div class="row">
  55. <div class="one-half column">
  56. <table class="u-full-width">
  57. <thead>
  58. <tr>
  59. <th>Property</th>
  60. <th>Value</th>
  61. </tr>
  62. </thead>
  63. <tbody>
  64. <tr>
  65. <td>MIME Type</td>
  66. <td>{{mime}}</td>
  67. </tr>
  68. <tr>
  69. <td>Folder Size</td>
  70. <td>{{size}}</td>
  71. </tr>
  72. <tr>
  73. <td>File Counts</td>
  74. <td>{{filecount}}</td>
  75. </tr>
  76. <tr>
  77. <td>Last Modification Time</td>
  78. <td>{{modtime}}</td>
  79. </tr>
  80. </tbody>
  81. </table>
  82. <a href="{{downloadurl}}"><button class="button-primary">Download All</button></a>
  83. <p style="font-size: 80%;"><b>Depending on folder size, zipping might take a while to complete.</b></p>
  84. <br>
  85. <p>Request File ID: {{reqid}}</p>
  86. <p>Request Timestamp: {{reqtime}}</p>
  87. </div>
  88. <div class="one-half column" id="filelistWrapper" style="overflow-y: auto; padding-right: 0.5em;">
  89. <table class="u-full-width">
  90. <thead>
  91. <tr>
  92. <th>Filename</th>
  93. <th>Type</th>
  94. <th>Size</th>
  95. </tr>
  96. </thead>
  97. <tbody id="folderList">
  98. </tbody>
  99. </table>
  100. </div>
  101. </div>
  102. </div>
  103. <div class="footer">
  104. <div class="container">
  105. Cloud File Sharing Interface, Powered by <a style="color: white;" href="http://arozos.com">arozos</a>
  106. </div>
  107. </div>
  108. <script>
  109. var treeFileList = {{treelist}};
  110. var downloadUUID = `{{downloaduuid}}`;
  111. var currentViewingRoot = ".";
  112. var selectedFile = null;
  113. renderFileList(treeFileList["."]);
  114. console.log(treeFileList);
  115. function renderFileList(filelist){
  116. $("#folderList").html("");
  117. if (currentViewingRoot != "."){
  118. $("#folderList").append(`<tr class="fileobject noselect" ondblclick="event.preventDefault(); parentdir();">
  119. <td style="padding-left: 8px;" colspan="3" > ↩ Back</td>
  120. </tr>`);
  121. }
  122. filelist.forEach(file => {
  123. var filetype = "File";
  124. var displayName = "";
  125. if (file.IsDir == true){
  126. filetype = "Folder";
  127. displayName = "📁 " + file.Filename;
  128. }else{
  129. displayName = "📄 " + file.Filename;
  130. }
  131. $("#folderList").append(`<tr class="fileobject noselect" onclick="highlightThis(this);" filename="${file.Filename}" relpath="${file.RelPath}" type="${filetype.toLocaleLowerCase()}" ondblclick="event.preventDefault(); openThis(this);">
  132. <td style="padding-left: 8px;">${displayName}</td>
  133. <td>${filetype}</td>
  134. <td>${file.Filesize}</td>
  135. </tr>`);
  136. });
  137. }
  138. //Went up one level
  139. function parentdir(){
  140. if (currentViewingRoot == "."){
  141. //Root dir. Do nothing
  142. }else{
  143. //Subdirs. travel up
  144. var dirinfo = currentViewingRoot.split("/");
  145. var nextDir = ".";
  146. if (currentViewingRoot.indexOf("/") < 0){
  147. //Parent dir will be root
  148. }else{
  149. dirinfo.pop();
  150. nextDir = dirinfo.join("/");
  151. }
  152. //Load the filelist
  153. if (treeFileList[nextDir] != undefined){
  154. currentViewingRoot = nextDir;
  155. renderFileList(treeFileList[nextDir]);
  156. }else{
  157. //Back to root on error
  158. currentViewingRoot = ".";
  159. renderFileList(treeFileList["."]);
  160. }
  161. }
  162. }
  163. function openThis(object){
  164. var targetFilename = $(object).attr("filename");
  165. var targetType = $(object).attr("type");
  166. var targetRelPath = $(object).attr("relpath");
  167. if (targetType == "folder"){
  168. //Folder. Build a new root file list for this
  169. var targetRenderList = treeFileList[targetRelPath];
  170. if (targetRenderList != undefined){
  171. currentViewingRoot = targetRelPath;
  172. renderFileList(targetRenderList);
  173. }
  174. }else{
  175. //File. Download it
  176. window.open("./share?id=" + downloadUUID + "&download=true&rel=" + targetRelPath)
  177. }
  178. }
  179. resizeDOMElement();
  180. function resizeDOMElement(){
  181. $("#filelistWrapper").css({
  182. height: window.innerHeight - $("#filelistWrapper").offset().top - 100,
  183. })
  184. }
  185. function highlightThis(object){
  186. $(".fileobject.active").removeClass("active");
  187. $(object).addClass("active");
  188. $("#activeFilename").text(" (" + $(object).attr("filename") +")");
  189. //Update the properties values
  190. selectedFile = $(object);
  191. }
  192. $(window).on("resize", function(){
  193. resizeDOMElement();
  194. })
  195. </script>
  196. </body>
  197. </html>