diff --git a/server/static/index.html b/server/static/index.html index 21a46bb..19a295d 100644 --- a/server/static/index.html +++ b/server/static/index.html @@ -35,58 +35,16 @@ + + + diff --git a/server/static/spinner.gif b/server/static/spinner.gif new file mode 100644 index 0000000..9eb867e Binary files /dev/null and b/server/static/spinner.gif differ diff --git a/server/static/theme.css b/server/static/theme.css index 78d43e0..a715d1c 100644 --- a/server/static/theme.css +++ b/server/static/theme.css @@ -6431,3 +6431,25 @@ html, body { height: 100%; content: ' '; background: linear-gradient(white, rgba(255, 255, 255, 0.8), rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0)); } + +.modal { + display: none; + position: fixed; + z-index: 1000; + top: 0; + left: 0; + height: 100%; + width: 100%; + background: rgba( 255, 255, 255, .8 ) + url('/spinner.gif') + 50% 50% + no-repeat; +} + +body.loading .modal { + overflow: hidden; +} + +body.loading .modal { + display: block; +} diff --git a/server/static/worker.js b/server/static/worker.js new file mode 100644 index 0000000..f28b197 --- /dev/null +++ b/server/static/worker.js @@ -0,0 +1,50 @@ +$body = $("body"); + +function lockform() { + $("#theform :input").prop("disabled", true); + $body.addClass("loading"); +} + +function unlockform() { + $("#theform :input").prop("disabled", false); + $body.removeClass("loading"); +} + +$('#theform').submit(function(event){ + event.preventDefault(); + if(this.checkValidity()) { + $.ajax({ + type: "POST", + url: "/addjob", + data: $('#theform').serialize(), + success: function(msg){ + lockform(); + interval = setInterval(checkServerForFile,3000,msg); + function checkServerForFile(jobid) { + $.ajax({ + type: "GET", + cache: false, + url: "/getjob/" + jobid, + statusCode: { + 404: function() { + clearInterval(interval); + unlockform(); + }, + 200: function() { + clearInterval(interval); + unlockform(); + window.location.href = "/getjob/" + jobid + }, + 500: function() { + clearInterval(interval); + window.alert("Failed to process request.") + unlockform(); + } + } + }); + } + + } + });} +}); +