Browse Source

Add timer for updating json

master
Gregory Rudolph 3 years ago
parent
commit
ebca665afa
Signed by: rudi
GPG Key ID: EF64F3CBD1A1EBDD
  1. 20
      wwwroot/js/site.js

20
wwwroot/js/site.js

@ -4,6 +4,18 @@ @@ -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 () { @@ -17,7 +29,13 @@ $(function () {
}
});
}
});
}
function runAjaxTimer() {
runAjax();
setTimeout(runAjaxTimer, 150000);
}
$("#json_data").change(function () {
var jsonData = JSON.parse($("#json_data").val());

Loading…
Cancel
Save