소스 검색

Added Web Share API to share interface

Toby Chui 3 년 전
부모
커밋
1ea6d9bbb3
2개의 변경된 파일39개의 추가작업 그리고 1개의 파일을 삭제
  1. 19 1
      system/share/downloadPage.html
  2. 20 0
      system/share/downloadPageFolder.html

+ 19 - 1
system/share/downloadPage.html

@@ -89,6 +89,7 @@
                         </tbody>
                       </table>
                     <a href="{{downloadurl}}"><button class="button-primary">Download</button></a>
+                    <button onclick="share();">Share</button>
                     <br><br>
                     <p>Request File ID: {{reqid}}</p>
                     <p>Request Timestamp: {{reqtime}}</p>
@@ -109,7 +110,24 @@
 
         
     <script>
-     
+      function share(){
+        let shareData = {
+          title: "{{filename}}",
+          text: '{{filename}} - File Share from {{hostname}}',
+          url: window.location.href,
+        }
+
+        navigator.share(shareData).then(() =>
+          function(){
+            //Share succ
+          }
+        ).catch((e) =>
+          function(){
+              //Share failed
+          }
+        )
+      }
+      
     </script>
     </body>
 </html>

+ 20 - 0
system/share/downloadPageFolder.html

@@ -115,6 +115,7 @@
                         </tbody>
                       </table>
                     <a href="{{downloadurl}}"><button class="button-primary">Download All</button></a>
+                    <button onclick="share();">Share</button>
                     <p style="font-size: 80%;"><b>Depending on folder size, zipping might take a while to complete.</b></p>
                     <p>Request File ID: {{reqid}}<br>
                     Request Timestamp: {{reqtime}}</p>
@@ -155,6 +156,25 @@
         handleWindowResize();
       });
 
+      function share(){
+        let shareData = {
+          title: "{{filename}}",
+          text: '{{filename}} - File Share from {{hostname}}',
+          url: window.location.href,
+        }
+
+        navigator.share(shareData).then(() =>
+          function(){
+            //Share succ
+          }
+        ).catch((e) =>
+          function(){
+              //Share failed
+          }
+        )
+      }
+
+
       function handleWindowResize(){
         if (window.innerWidth < 550){
           //Assume mobile