downloadPageFolder.html 8.7 KB

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