diff options
author | Prabhu Ramachandran | 2017-08-24 12:03:56 +0530 |
---|---|---|
committer | Prabhu Ramachandran | 2017-08-24 12:03:56 +0530 |
commit | 7e159fff8d802f49d01b3e83bb220f3844271a11 (patch) | |
tree | bb57de0a5c2d7f8013189a58adba7d14ac977e19 /yaksh/static | |
parent | 6bc86acb799e8ac43f94eb293214f45a549731a8 (diff) | |
parent | 055d0d1c51f90b4496a096a13bab5e4978fe9b92 (diff) | |
download | online_test-7e159fff8d802f49d01b3e83bb220f3844271a11.tar.gz online_test-7e159fff8d802f49d01b3e83bb220f3844271a11.tar.bz2 online_test-7e159fff8d802f49d01b3e83bb220f3844271a11.zip |
Merge branch 'improve-code-server' of github.com:prathamesh920/online_test into improve-code-server
Diffstat (limited to 'yaksh/static')
-rw-r--r-- | yaksh/static/yaksh/js/requesthandler.js | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/yaksh/static/yaksh/js/requesthandler.js b/yaksh/static/yaksh/js/requesthandler.js index f653da1..c5629ab 100644 --- a/yaksh/static/yaksh/js/requesthandler.js +++ b/yaksh/static/yaksh/js/requesthandler.js @@ -1,22 +1,25 @@ request_status = "initial" count = 0; +checker = null function submitRequest(){ document.forms["code"].submit(); } function check_state(state, uid) { - if ((state == "running" || state == "not started") && count < 15) { + if ((state == "running" || state == "not started") && count < 7) { count++; setTimeout(function() {get_result(uid);}, 2000); } else if (state == "unknown") { request_status = "initial"; count = 0; notify("You are requesting for a wrong data"); + clearInterval(checker); unlock_screen(); } else { request_status = "initial"; count = 0; notify("Please try after few minutes"); + clearInterval(checker); unlock_screen(); } } @@ -36,6 +39,13 @@ function unlock_screen() { document.getElementById("ontop").style.display = "none"; } +function check_lock_screen() { + var $ontop_div = document.getElementById("ontop"); + if ($ontop_div.style.display == "block") { + $ontop_div.style.display = "none"; + } +} + function get_result(uid){ $.ajax({ method: "GET", @@ -44,6 +54,7 @@ function get_result(uid){ success: function(data, status, xhr) { content_type = xhr.getResponseHeader("content-type"); if(content_type.includes("text/html")) { + clearInterval(checker); unlock_screen(); document.open(); document.write(data); @@ -55,12 +66,14 @@ function get_result(uid){ } else { request_status = "initial"; count = 0; + clearInterval(checker); unlock_screen(); } }, error: function(xhr, text_status, error_thrown ) { request_status = "initial"; count = 0; + clearInterval(checker); unlock_screen(); notify("There is some problem. Try later.") } @@ -103,6 +116,7 @@ $(document).ready(function(){ global_editor.editor.clearHistory(); } $('#code').submit(function(e) { + checker = setInterval(check_lock_screen, 30000); lock_screen(); $.ajax({ type: 'POST', @@ -114,6 +128,7 @@ $(document).ready(function(){ if(content_type.includes("text/html")) { request_status = "initial" count = 0; + clearInterval(checker); unlock_screen(); document.open(); document.write(data); @@ -126,12 +141,14 @@ $(document).ready(function(){ } else { request_status = "initial"; count = 0; + clearInterval(checker); unlock_screen(); } }, error: function(xhr, text_status, error_thrown ) { request_status = "initial"; count = 0; + clearInterval(checker); unlock_screen(); notify("There is some problem. Try later.") } |