mirror of
https://github.com/9001/copyparty.git
synced 2025-08-18 01:22:13 -06:00
prevent non-spa navigation while uploading
This commit is contained in:
parent
b14b86990f
commit
fa656577d1
|
@ -980,9 +980,11 @@ function apply_perms(perms) {
|
||||||
}
|
}
|
||||||
|
|
||||||
var act = document.querySelector('#ops>a.act');
|
var act = document.querySelector('#ops>a.act');
|
||||||
|
if (act) {
|
||||||
var areq = act.getAttribute('data-perm');
|
var areq = act.getAttribute('data-perm');
|
||||||
if (areq && !has(perms, areq))
|
if (areq && !has(perms, areq))
|
||||||
goto();
|
goto();
|
||||||
|
}
|
||||||
|
|
||||||
var have_write = has(perms, "write");
|
var have_write = has(perms, "write");
|
||||||
var tds = document.querySelectorAll('#u2conf td');
|
var tds = document.querySelectorAll('#u2conf td');
|
||||||
|
|
|
@ -424,6 +424,7 @@ function up2k_init(have_crypto) {
|
||||||
|
|
||||||
var tasker = (function () {
|
var tasker = (function () {
|
||||||
var mutex = false;
|
var mutex = false;
|
||||||
|
var was_busy = false;
|
||||||
|
|
||||||
function taskerd() {
|
function taskerd() {
|
||||||
if (mutex)
|
if (mutex)
|
||||||
|
@ -442,8 +443,7 @@ function up2k_init(have_crypto) {
|
||||||
st.busy.upload.length;
|
st.busy.upload.length;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (flag) {
|
var is_busy = 0 !=
|
||||||
var need_flag = 0 !=
|
|
||||||
st.todo.hash.length +
|
st.todo.hash.length +
|
||||||
st.todo.handshake.length +
|
st.todo.handshake.length +
|
||||||
st.todo.upload.length +
|
st.todo.upload.length +
|
||||||
|
@ -451,7 +451,17 @@ function up2k_init(have_crypto) {
|
||||||
st.busy.handshake.length +
|
st.busy.handshake.length +
|
||||||
st.busy.upload.length;
|
st.busy.upload.length;
|
||||||
|
|
||||||
if (need_flag) {
|
if (was_busy != is_busy) {
|
||||||
|
was_busy = is_busy;
|
||||||
|
|
||||||
|
if (is_busy)
|
||||||
|
window.addEventListener("beforeunload", warn_uploader_busy);
|
||||||
|
else
|
||||||
|
window.removeEventListener("beforeunload", warn_uploader_busy);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (flag) {
|
||||||
|
if (is_busy) {
|
||||||
var now = new Date().getTime();
|
var now = new Date().getTime();
|
||||||
flag.take(now);
|
flag.take(now);
|
||||||
if (!flag.ours) {
|
if (!flag.ours) {
|
||||||
|
@ -1108,5 +1118,12 @@ function up2k_init(have_crypto) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function warn_uploader_busy(e) {
|
||||||
|
e.preventDefault();
|
||||||
|
e.returnValue = '';
|
||||||
|
return "upload in progress, click abort and use the file-tree to navigate instead";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (document.querySelector('#op_up2k.act'))
|
if (document.querySelector('#op_up2k.act'))
|
||||||
goto_up2k();
|
goto_up2k();
|
||||||
|
|
Loading…
Reference in a new issue