downloadPageFolder.html 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  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. <link rel="icon" type="image/png" href="../../img/public/share/share.png" />
  12. <style>
  13. body{
  14. padding-bottom: 100px;
  15. }
  16. .bar{
  17. height: 12px;
  18. background-color: #1a1a1a;
  19. width: 100%;
  20. }
  21. .footer{
  22. position: fixed;
  23. bottom: 0px;
  24. height: 50px;
  25. width: 100%;
  26. background-color: #1a1a1a;
  27. padding: 20px;
  28. color: white;
  29. }
  30. .fileobject{
  31. cursor: pointer;
  32. }
  33. .fileobject:hover{
  34. background-color: #f5f5f5;
  35. }
  36. .fileobject.active{
  37. background-color: #f5f5f5ee;
  38. }
  39. .noselect{
  40. -webkit-touch-callout: none; /* iOS Safari */
  41. -webkit-user-select: none; /* Safari */
  42. -khtml-user-select: none; /* Konqueror HTML */
  43. -moz-user-select: none; /* Old versions of Firefox */
  44. -ms-user-select: none; /* Internet Explorer/Edge */
  45. user-select: none;
  46. }
  47. #filelistWrapper{
  48. position: relative;
  49. padding: 12px;
  50. border-top: 4px solid #ffe46c;
  51. -webkit-box-shadow: 11px 9px 23px 0px rgba(54,54,54,0.31);
  52. box-shadow: 11px 9px 23px 0px rgba(54,54,54,0.31);
  53. }
  54. td{
  55. word-break: break-all;
  56. }
  57. </style>
  58. </head>
  59. <body>
  60. <div class="bar"></div>
  61. <br>
  62. <div class="container">
  63. <h5>{{hostname}} File Sharing</h5>
  64. <h3>{{filename}}</h3>
  65. <div class="row">
  66. <div class="one-half column">
  67. <table class="u-full-width">
  68. <thead>
  69. <tr>
  70. <th>Property</th>
  71. <th>Value</th>
  72. </tr>
  73. </thead>
  74. <tbody>
  75. <tr>
  76. <td>MIME Type</td>
  77. <td>{{mime}}</td>
  78. </tr>
  79. <tr>
  80. <td>Folder Size</td>
  81. <td>{{size}}</td>
  82. </tr>
  83. <tr>
  84. <td>File Counts</td>
  85. <td>{{filecount}}</td>
  86. </tr>
  87. <tr>
  88. <td>Last Modification Time</td>
  89. <td>{{modtime}}</td>
  90. </tr>
  91. </tbody>
  92. </table>
  93. <a href="{{downloadurl}}"><button class="button-primary">Download All</button></a>
  94. <p style="font-size: 80%;"><b>Depending on folder size, zipping might take a while to complete.</b></p>
  95. <p>Request File ID: {{reqid}}<br>
  96. Request Timestamp: {{reqtime}}</p>
  97. <small>📂 Double click any item in the list to open or download</small>
  98. </div>
  99. <div class="one-half column" id="filelistWrapper" style="overflow-y: auto; padding-right: 0.5em; min-height: 400px;">
  100. <table class="u-full-width">
  101. <thead>
  102. <tr>
  103. <th>Filename</th>
  104. <th>Type</th>
  105. <th>Size</th>
  106. </tr>
  107. </thead>
  108. <tbody id="folderList">
  109. </tbody>
  110. </table>
  111. </div>
  112. </div>
  113. </div>
  114. <div class="footer">
  115. <div class="container">
  116. Cloud File Sharing Interface, Powered by <a style="color: white;" href="http://arozos.com">arozos</a>
  117. </div>
  118. </div>
  119. <script>
  120. var treeFileList = {{treelist}};
  121. var downloadUUID = `{{downloaduuid}}`;
  122. var currentViewingRoot = ".";
  123. var selectedFile = null;
  124. renderFileList(treeFileList["."]);
  125. handleWindowResize();
  126. $(window).on("resize", function(e){
  127. handleWindowResize();
  128. });
  129. function handleWindowResize(){
  130. if (window.innerWidth < 550){
  131. //Assume mobile
  132. $(".footer").css("height", "20px");
  133. }else{
  134. $(".footer").css("height", "50px");
  135. }
  136. }
  137. function renderFileList(filelist){
  138. $("#folderList").html("");
  139. if (currentViewingRoot != "."){
  140. $("#folderList").append(`<tr class="fileobject noselect" ondblclick="event.preventDefault(); parentdir();">
  141. <td style="padding-left: 8px;" colspan="3" > ↩ Back</td>
  142. </tr>`);
  143. }
  144. filelist.forEach(file => {
  145. var filetype = "File";
  146. var displayName = "";
  147. if (file.IsDir == true){
  148. //Folder
  149. filetype = "Folder";
  150. displayName = "📁 " + file.Filename;
  151. }else{
  152. //File
  153. var ext = file.Filename.split(".").pop();
  154. var icon = "📄"
  155. ext = ext.toLowerCase();
  156. if (ext == "mp3" || ext == "wav" || ext == "flac" || ext == "aac" || ext == "ogg" || ext == ""){
  157. icon = "🎵";
  158. }else if (ext == "mp4" || ext == "avi" || ext == "webm" || ext == "mkv" || ext == "mov" || ext == "rvmb"){
  159. icon = "🎞️";
  160. }else if (ext == "png" || ext == "jpeg" || ext == "jpg" || ext == "bmp" || ext == "gif"){
  161. icon = "🖼️";
  162. }
  163. displayName = icon + " " + file.Filename;
  164. }
  165. var filenameLinker = `<a href="../../share/download/${downloadUUID}/${file.RelPath}">${displayName}</a>`;
  166. if (file.IsDir == true){
  167. filenameLinker = `${displayName}`;
  168. }
  169. $("#folderList").append(`<tr class="fileobject noselect" onclick="highlightThis(this);" filename="${file.Filename}" relpath="${file.RelPath}" type="${filetype.toLocaleLowerCase()}" ondblclick="event.preventDefault(); openThis(this);">
  170. <td style="padding-left: 8px;">${filenameLinker}</td>
  171. <td>${filetype}</td>
  172. <td>${file.Filesize}</td>
  173. </tr>`);
  174. });
  175. }
  176. //Went up one level
  177. function parentdir(){
  178. if (currentViewingRoot == "."){
  179. //Root dir. Do nothing
  180. }else{
  181. //Subdirs. travel up
  182. var dirinfo = currentViewingRoot.split("/");
  183. var nextDir = ".";
  184. if (currentViewingRoot.indexOf("/") < 0){
  185. //Parent dir will be root
  186. }else{
  187. dirinfo.pop();
  188. nextDir = dirinfo.join("/");
  189. }
  190. //Load the filelist
  191. if (treeFileList[nextDir] != undefined){
  192. currentViewingRoot = nextDir;
  193. renderFileList(treeFileList[nextDir]);
  194. }else{
  195. //Back to root on error
  196. currentViewingRoot = ".";
  197. renderFileList(treeFileList["."]);
  198. }
  199. }
  200. }
  201. function openThis(object){
  202. var targetFilename = $(object).attr("filename");
  203. var targetType = $(object).attr("type");
  204. var targetRelPath = $(object).attr("relpath");
  205. if (targetType == "folder"){
  206. //Folder. Build a new root file list for this
  207. var targetRenderList = treeFileList[targetRelPath];
  208. if (targetRenderList != undefined){
  209. currentViewingRoot = targetRelPath;
  210. renderFileList(targetRenderList);
  211. }
  212. }else{
  213. //File. Download it
  214. window.open("../../share/download/" + downloadUUID + "/" + targetRelPath)
  215. }
  216. }
  217. resizeDOMElement();
  218. function resizeDOMElement(){
  219. $("#filelistWrapper").css({
  220. height: window.innerHeight - $("#filelistWrapper").offset().top - 100,
  221. })
  222. }
  223. function highlightThis(object){
  224. $(".fileobject.active").removeClass("active");
  225. $(object).addClass("active");
  226. $("#activeFilename").text(" (" + $(object).attr("filename") +")");
  227. //Update the properties values
  228. selectedFile = $(object);
  229. }
  230. $(window).on("resize", function(){
  231. resizeDOMElement();
  232. })
  233. </script>
  234. </body>
  235. </html>