From 2883fa0bd0bf948a2f94ba41122962d72cb56780 Mon Sep 17 00:00:00 2001 From: Michael Friedrich Date: Sun, 9 Mar 2014 19:23:49 +0100 Subject: [PATCH] Fix JS Time unless counter. There is still a small glitch with the global refresh of 10s sometimes setting an empty string for next_check. Try check_interval = 5s with Icinga 2. --- public/js/icinga/ui.js | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/public/js/icinga/ui.js b/public/js/icinga/ui.js index dd097e9cb..5d37b8f7f 100644 --- a/public/js/icinga/ui.js +++ b/public/js/icinga/ui.js @@ -266,21 +266,24 @@ if (m !== null) { var nm = parseInt(m[1]); var ns = parseInt(m[2]); - if (nm >= 0) { + if (nm > 0) { if (ns > 0) { ns--; - } else { + } else if (ns == 0) { ns = 59; nm--; - } - } else { - if (ns < 59) { - ns++; + } else { //negative means recalculate against 1m + ns = (60 - ns - 1); + nm--; + } + } else if (nm <= 0) { + if (ns == -59) { + ns = 0; + nm--; } else { - ns = 0; - nm--; - } - } + ns--; + } + } $(el).html(nm + 'm ' + ns + 's'); } });