|
18 | 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
19 | 19 | // SOFTWARE. |
20 | 20 | (function initUploader() { |
| 21 | + var uploadInProgress = false; |
21 | 22 | var notifyUploadSocketError = false; |
22 | 23 | uploadSocket = io(Pterodactyl.node.scheme + '://' + Pterodactyl.node.fqdn + ':' + Pterodactyl.node.daemonListen + '/upload/' + Pterodactyl.server.uuid, { |
23 | 24 | 'query': 'token=' + Pterodactyl.server.daemonSecret, |
24 | 25 | }); |
25 | 26 |
|
| 27 | + window.onbeforeunload = function () { |
| 28 | + if (uploadInProgress) { |
| 29 | + return "An upload is in progress. Navigating away will abort this upload, are you sure you want to continue?"; |
| 30 | + } |
| 31 | + } |
| 32 | + |
26 | 33 | uploadSocket.io.on('connect_error', function (err) { |
27 | 34 | if(typeof notifyUploadSocketError !== 'object') { |
28 | 35 | notifyUploadSocketError = $.notify({ |
|
77 | 84 | }); |
78 | 85 |
|
79 | 86 | siofu.addEventListener('start', function (event) { |
| 87 | + uploadInProgress = true; |
80 | 88 | event.file.meta.path = $('#headerTableRow').attr('data-currentdir'); |
81 | 89 | event.file.meta.identifier = Math.random().toString(36).slice(2); |
82 | 90 |
|
|
85 | 93 | <td>' + event.file.name + '</td> \ |
86 | 94 | <td colspan=2"> </td> \ |
87 | 95 | </tr><tr> \ |
88 | | - <td colspan="4" class="has-progress"> \ |
| 96 | + <td colspan="5" class="has-progress"> \ |
89 | 97 | <div class="progress progress-table-bottom active"> \ |
90 | 98 | <div class="progress-bar progress-bar-info prog-bar-' + event.file.meta.identifier +'" style="width: 0%"></div> \ |
91 | 99 | </div> \ |
|
104 | 112 | }); |
105 | 113 |
|
106 | 114 | // Do something when a file is uploaded: |
107 | | - siofu.addEventListener('complete', function(event){ |
| 115 | + siofu.addEventListener('complete', function(event) { |
| 116 | + uploadInProgress = false; |
108 | 117 | if (!event.success) { |
109 | 118 | $('.prog-bar-' + event.file.meta.identifier).css('width', '100%').removeClass('progress-bar-info').addClass('progress-bar-danger'); |
110 | 119 | $.notify({ |
|
116 | 125 | } |
117 | 126 | }); |
118 | 127 |
|
119 | | - siofu.addEventListener('error', function(event){ |
| 128 | + siofu.addEventListener('error', function(event) { |
| 129 | + uploadInProgress = false; |
120 | 130 | console.error(event); |
121 | 131 | $('.prog-bar-' + event.file.meta.identifier).css('width', '100%').removeClass('progress-bar-info').addClass('progress-bar-danger'); |
122 | 132 | $.notify({ |
|
0 commit comments