diff --git a/copyparty/web/browser.js b/copyparty/web/browser.js index 6c9e6b58..aec7ea0e 100644 --- a/copyparty/web/browser.js +++ b/copyparty/web/browser.js @@ -311,6 +311,7 @@ var Ls = { "u_hashdone": 'hashing done', "u_hashing": 'hash', "u_upping": 'uploading', + "u_fixed": "OK!  Fixed it 👍", "u_cuerr": "failed to upload chunk {0} of {1};\nprobably harmless, continuing\n\nfile: {2}", "u_cuerr2": "server rejected upload (chunk {0} of {1});\nwill retry later\n\nfile: {2}\n\nerror ", "u_ehstmp": "will retry; see bottom-right", @@ -653,8 +654,9 @@ var Ls = { "u_hashdone": 'befaring ferdig', "u_hashing": 'les', "u_upping": 'sender', + "u_fixed": "OK!  Løste seg 👍", "u_cuerr": "kunne ikke laste opp del {0} av {1};\nsikkert harmløst, fortsetter\n\nfil: {2}", - "u_cuerr2": "server nektet opplastningen (del {0} av {1});\nprøver igjen senere\n\nfile: {2}\n\nerror ", + "u_cuerr2": "server nektet opplastningen (del {0} av {1});\nprøver igjen senere\n\nfil: {2}\n\nerror ", "u_ehstmp": "prøver igjen; se mld nederst", "u_ehsfin": "server nektet forespørselen om å ferdigstille filen; prøver igjen...", "u_ehssrch": "server nektet forespørselen om å utføre søk; prøver igjen...", diff --git a/copyparty/web/up2k.js b/copyparty/web/up2k.js index 1887490d..f772d529 100644 --- a/copyparty/web/up2k.js +++ b/copyparty/web/up2k.js @@ -2005,6 +2005,9 @@ function up2k_init(subtle) { return; } + if (toast.tag === t) + toast.ok(5, L.u_fixed); + var response = JSON.parse(xhr.responseText); if (!response.name) { var msg = '', @@ -2127,7 +2130,7 @@ function up2k_init(subtle) { } else { pvis.seth(t.n, 1, "ERROR"); - pvis.seth(t.n, 2, L.u_ehstmp); + pvis.seth(t.n, 2, L.u_ehstmp, t); var err = "", rsp = (xhr.responseText + ''), @@ -2176,7 +2179,7 @@ function up2k_init(subtle) { return; } err = t.t_uploading ? L.u_ehsfin : t.srch ? L.u_ehssrch : L.u_ehsinit; - xhrchk(xhr, err + "\n\nfile: " + t.name + "\n\nerror ", "404, target folder not found", "warn"); + xhrchk(xhr, err + "\n\nfile: " + t.name + "\n\nerror ", "404, target folder not found", "warn", t); } } xhr.onload = function (e) { @@ -2250,7 +2253,7 @@ function up2k_init(subtle) { console.log("ignoring dupe-segment error", t); } else { - xhrchk(xhr, L.u_cuerr2.format(npart, Math.ceil(t.size / chunksize), t.name), "404, target folder not found (???)", "warn"); + xhrchk(xhr, L.u_cuerr2.format(npart, Math.ceil(t.size / chunksize), t.name), "404, target folder not found (???)", "warn", t); chill(t); } @@ -2282,7 +2285,7 @@ function up2k_init(subtle) { return; if (!toast.visible) - toast.warn(9.98, L.u_cuerr.format(npart, Math.ceil(t.size / chunksize), t.name)); + toast.warn(9.98, L.u_cuerr.format(npart, Math.ceil(t.size / chunksize), t.name), t); console.log('chunkpit onerror,', ++tries, t); orz2(xhr); diff --git a/copyparty/web/util.js b/copyparty/web/util.js index 1ed69a9e..147606d6 100644 --- a/copyparty/web/util.js +++ b/copyparty/web/util.js @@ -1124,6 +1124,7 @@ var toast = (function () { document.body.appendChild(obj); r.visible = false; r.txt = null; + r.tag = obj; // filler value (null is scary) function scrollchk() { if (scrolling) @@ -1152,9 +1153,10 @@ var toast = (function () { clearTimeout(te); clmod(obj, 'vis'); r.visible = false; + r.tag = obj; }; - r.show = function (cl, sec, txt) { + r.show = function (cl, sec, txt, tag) { clearTimeout(te); if (sec) te = setTimeout(r.hide, sec * 1000); @@ -1170,19 +1172,20 @@ var toast = (function () { timer.add(scrollchk); r.visible = true; r.txt = txt; + r.tag = tag; }; - r.ok = function (sec, txt) { - r.show('ok', sec, txt); + r.ok = function (sec, txt, tag) { + r.show('ok', sec, txt, tag); }; - r.inf = function (sec, txt) { - r.show('inf', sec, txt); + r.inf = function (sec, txt, tag) { + r.show('inf', sec, txt, tag); }; - r.warn = function (sec, txt) { - r.show('warn', sec, txt); + r.warn = function (sec, txt, tag) { + r.show('warn', sec, txt, tag); }; - r.err = function (sec, txt) { - r.show('err', sec, txt); + r.err = function (sec, txt, tag) { + r.show('err', sec, txt, tag); }; return r; @@ -1548,15 +1551,15 @@ var favico = (function () { var cf_cha_t = 0; -function xhrchk(xhr, prefix, e404, lvl) { +function xhrchk(xhr, prefix, e404, lvl, tag) { if (xhr.status < 400 && xhr.status >= 200) return true; if (xhr.status == 403) - return toast.err(0, prefix + (window.L && L.xhr403 || "403: access denied\n\ntry pressing F5, maybe you got logged out")); + return toast.err(0, prefix + (window.L && L.xhr403 || "403: access denied\n\ntry pressing F5, maybe you got logged out"), tag); if (xhr.status == 404) - return toast.err(0, prefix + e404); + return toast.err(0, prefix + e404, tag); var errtxt = (xhr.response && xhr.response.err) || xhr.responseText, fun = toast[lvl || 'err']; @@ -1576,5 +1579,5 @@ function xhrchk(xhr, prefix, e404, lvl) { document.body.appendChild(fr); } - return fun(0, prefix + xhr.status + ": " + errtxt); + return fun(0, prefix + xhr.status + ": " + errtxt, tag); }