diff --git a/copyparty/web/mde.html b/copyparty/web/mde.html index 77f0cb50..5170865f 100644 --- a/copyparty/web/mde.html +++ b/copyparty/web/mde.html @@ -3,6 +3,7 @@
/, "")); + return toast.err(0, 'Error! The file was NOT saved.\n\n' + this.status + ": " + (this.responseText + '').replace(/^/, "")); var r; try { r = JSON.parse(this.responseText); } catch (ex) { - return alert('Failed to parse reply from server:\n\n' + this.responseText); + return toast.err(0, 'Failed to parse reply from server:\n\n' + this.responseText); } if (!r.ok) { @@ -158,12 +164,10 @@ function save_cb() { r.lastmod + ' lastmod on the server now,', r.now + ' server time now,\n', ]; - alert(msg.join('\n')); + return toast.err(0, msg.join('\n')); } - else { - alert('Error! Save failed. Maybe this JSON explains why:\n\n' + this.responseText); - } - return; + else + return toast.err(0, 'Error! Save failed. Maybe this JSON explains why:\n\n' + this.responseText); } this.btn.classList.remove('force-save'); @@ -186,35 +190,23 @@ function save_chk() { if (this.readyState != XMLHttpRequest.DONE) return; - if (this.status !== 200) { - alert('Error! The file was NOT saved.\n\n' + this.status + ": " + (this.responseText + '').replace(/^/, "")); - return; - } + if (this.status !== 200) + return toast.err(0, 'Error! The file was NOT saved.\n\n' + this.status + ": " + (this.responseText + '').replace(/^/, "")); var doc1 = this.txt.replace(/\r\n/g, "\n"); var doc2 = this.responseText.replace(/\r\n/g, "\n"); if (doc1 != doc2) { - alert( + modal.alert( 'Error! The document on the server does not appear to have saved correctly (your editor contents and the server copy is not identical). Place the document on your clipboard for now and check the server logs for hints\n\n' + 'Length: yours=' + doc1.length + ', server=' + doc2.length ); - alert('yours, ' + doc1.length + ' byte:\n[' + doc1 + ']'); - alert('server, ' + doc2.length + ' byte:\n[' + doc2 + ']'); + modal.alert('yours, ' + doc1.length + ' byte:\n[' + doc1 + ']'); + modal.alert('server, ' + doc2.length + ' byte:\n[' + doc2 + ']'); return; } last_modified = this.lastmod; md_changed(this.mde, true); - var ok = mknod('div'); - ok.setAttribute('style', 'font-size:6em;font-family:serif;font-weight:bold;color:#cf6;background:#444;border-radius:.3em;padding:.6em 0;position:fixed;top:30%;left:calc(50% - 2em);width:4em;text-align:center;z-index:9001;transition:opacity 0.2s ease-in-out;opacity:1'); - ok.innerHTML = 'OK✔️'; - var parent = ebi('m'); - document.documentElement.appendChild(ok); - setTimeout(function () { - ok.style.opacity = 0; - }, 500); - setTimeout(function () { - ok.parentNode.removeChild(ok); - }, 750); + toast.ok(2, 'save OK' + (this.ntry ? '\nattempt ' + this.ntry : '')); } diff --git a/copyparty/web/ui.css b/copyparty/web/ui.css index c9ac2f67..56fc3d02 100644 --- a/copyparty/web/ui.css +++ b/copyparty/web/ui.css @@ -66,7 +66,7 @@ background: #0be; } #toast.ok { - background: #4a0; + background: #380; border-color: #8e4; } #toast.ok #toastc {