diff --git a/server/static/index.html b/server/static/index.html index 14ba491..b8677db 100644 --- a/server/static/index.html +++ b/server/static/index.html @@ -40,8 +40,14 @@ - - + +
+
+
+
+
+ + diff --git a/server/static/worker.js b/server/static/worker.js index 3360e68..11ccb17 100644 --- a/server/static/worker.js +++ b/server/static/worker.js @@ -16,6 +16,34 @@ function unlockform() { $body.removeClass("loading"); } +function deletecard(jobid) { + if ( $("#" + jobid).length ) { + $("#" + jobid).remove(); + }; +} + + +function addcard(jobid) { + var text = '
Creating Image
'; + $('#cards').append(text); + $('#' + jobid).show(); +} + +function failcard(jobid) { + deletecard(jobid); + + var text = '
Export failed.
'; + $('#cards').append(text); +} + + +function finishcard(jobid) { + deletecard(jobid); + + var text = '
Final Image
'; + $('#cards').append(text); +} + $('#theform').submit(function(event){ event.preventDefault(); if(this.checkValidity()) { @@ -24,9 +52,10 @@ $('#theform').submit(function(event){ url: "/addjob", data: $('#theform').serialize(), success: function(msg){ - lockform(); - interval = setInterval(checkServerForFile,3000,msg); + var interval = setInterval(checkServerForFile,3000,msg); window.panaxworking = false; + addcard(msg); + function checkServerForFile(jobid) { if (!window.panaxworking) { window.panaxworking = true; @@ -37,17 +66,18 @@ $('#theform').submit(function(event){ statusCode: { 404: function() { clearInterval(interval); - unlockform(); + failcard(jobid); + return; }, 200: function() { clearInterval(interval); - unlockform(); - window.location.href = "/getjob/" + jobid; + finishcard(jobid); + return; }, 500: function() { clearInterval(interval); - window.alert("Failed to process request. The URL may be incorrect or unsupported.") - unlockform(); + failcard(jobid); + return; } } });