downloadPageFolder.html 10 KB

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