瀏覽代碼

WiFi uploader now requires confirmation before user navigates away from page with a transfer is in progress

Signed-off-by: Felix Paul Kühne <fkuehne@videolan.org>
Riccardo Angius 11 年之前
父節點
當前提交
4c22c69b41
共有 1 個文件被更改,包括 10 次插入0 次删除
  1. 10 0
      Resources/web/main.js

+ 10 - 0
Resources/web/main.js

@@ -21,6 +21,16 @@ $(function(){
     fileupload.bind('fileuploadfail', fail);
     fileupload.bind('fileuploadprogress', progress);
 
+    $(window).bind('beforeunload', function (e) {
+        var confirmationMessage = "";
+
+        if ($('.progress').not('.done').not('.fail').length > 0) {
+            confirmationMessage = 'There are transfers in progress, navigating away will abort them.';
+        }
+        (e || window.event).returnValue = confirmationMessage;     // Gecko + IE
+        return confirmationMessage;                                // Webkit, Safari, Chrome etc.
+    }
+
     var xhrCache = [];
     function add (e, data) {
         $('.message').hide();