diff --git a/wwwroot/js/site.js b/wwwroot/js/site.js index 5f38933..f5b9dc8 100644 --- a/wwwroot/js/site.js +++ b/wwwroot/js/site.js @@ -4,6 +4,18 @@ // Write your JavaScript code. $(function () { if ($("#login_card").length == 0) { + runAjaxTimer(); + } +}); + +$(window).focus(function() { + if ($("#login_card").length == 0) { + runAjax(); + } + }); + +function runAjax() { + if (window.document.hasFocus()) { $.ajax({ type: "GET", url: "/Index?handler=JsonData", @@ -17,7 +29,13 @@ $(function () { } }); } -}); +} + +function runAjaxTimer() { + runAjax(); + setTimeout(runAjaxTimer, 150000); +} + $("#json_data").change(function () { var jsonData = JSON.parse($("#json_data").val());