Fixed the TickerWidget making repeated calls

This commit is contained in:
djbadders 2019-04-16 22:20:08 +01:00
parent 6e3da89ab7
commit 8f02ab2bef
1 changed files with 10 additions and 1 deletions

View File

@ -172,6 +172,13 @@
var errCount = [];
var interval;
var loadWidgets = function () {
// Clear exisitng interval to stop multiple attempts to load at the same time.
if (interval != null)
{
clearInterval(interval);
}
// Load widgets
$('[data-toggle="tooltip"]').tooltip();
$("#ticker-widgets").load('@Html.Raw(Model.PTMagicConfiguration.GeneralSettings.Monitor.RootUrl)_get/TickerWidgets', '', function (responseText, textStatus, XMLHttpRequest) {
if (textStatus == 'error') {
@ -184,13 +191,15 @@
} else {
errCount["TickerWidgets"] = 0;
}
// Reinstate the interval.
interval = setInterval(function () { loadWidgets(); }, 5000);
});
};
$(document).ready(function () {
errCount["TickerWidgets"] = 0;
loadWidgets();
interval = setInterval(function () { loadWidgets(); }, 5 * 1000);
$('[data-toggle="tooltip"]').tooltip()
$('.text-autocolor').autocolor(false);