widget/reply: redirect to created comment
[minimedit.git] / progress.js
index e59422de841e879c2c176475e2896796c6d3c7c8..575b98e83cf8ef74a833a471815fbf5132ded202 100644 (file)
@@ -3,6 +3,10 @@ function showsize(bytes) {
 }
 
 function trackupload(input) {
+       if (!input.value) {
+               return true; // default form action
+       }
+
        var progress = document.getElementById('progress');
        if (!progress) {
                progress = document.createElement('DIV');
@@ -26,7 +30,7 @@ function trackupload(input) {
                if (e.target.status == 200) {
                        progress.textContent = 'voltooid';
                        progress.innerHTML += ' <small>(' + showsize(input.files[0].size) + ' MB)</small>';
-                       input.value = '';
+                       window.location.assign(e.target.response);
                }
                else {
                        progress.textContent = 'fout';
@@ -53,14 +57,14 @@ function trackupload(input) {
        cancel.onclick = function () { ajax.abort() };
        cancel.style.float = 'left';
        input.parentNode.insertBefore(cancel, progress.parentNode);
+       return false;
 }
 
 document.addEventListener('DOMContentLoaded', e => {
        for (let row of document.forms[0].elements) {
                if (row.type == 'file') {
                        row.form.onsubmit = () => {
-                               trackupload(row);
-                               return false;
+                               return trackupload(row);
                        };
                }
        }