mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-27 07:44:04 +02:00
parent
2715e8ed2b
commit
1e9337846a
@ -577,70 +577,60 @@
|
|||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Refresh partial time counters
|
||||||
|
*
|
||||||
|
* This function runs every second.
|
||||||
|
*/
|
||||||
refreshTimeSince: function () {
|
refreshTimeSince: function () {
|
||||||
|
$('.time-ago, .time-since').each(function (idx, el) {
|
||||||
$('.timesince').each(function (idx, el) {
|
var partialTime = /(\d{1,2})m (\d{1,2})s/.exec(el.innerHTML);
|
||||||
return;
|
if (partialTime !== null) {
|
||||||
// todo remove after replace timeSince
|
var minute = parseInt(partialTime[1], 10),
|
||||||
var mp = el.innerHTML.match(/^(.*?)(-?\d+)d\s(-?\d+)h/);
|
second = parseInt(partialTime[2], 10);
|
||||||
if (mp !== null) {
|
if (second < 59) {
|
||||||
return true;
|
++second;
|
||||||
}
|
|
||||||
|
|
||||||
var m = el.innerHTML.match(/^(.*?)(-?\d+)(.+\s)(-?\d+)(.+)/);
|
|
||||||
if (m !== null) {
|
|
||||||
var nm = parseInt(m[2]);
|
|
||||||
var ns = parseInt(m[4]);
|
|
||||||
if (ns < 59) {
|
|
||||||
ns++;
|
|
||||||
} else {
|
} else {
|
||||||
ns = 0;
|
++minute;
|
||||||
nm++;
|
second = 0;
|
||||||
}
|
}
|
||||||
$(el).html(m[1] + nm + m[3] + ns + m[5]);
|
el.innerHTML = el.innerHTML.substr(0, partialTime.index) + minute.toString() + 'm '
|
||||||
|
+ second.toString() + 's' + el.innerHTML.substr(partialTime.index + partialTime[0].length);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$('.timeuntil').each(function (idx, el) {
|
$('.time-until').each(function (idx, el) {
|
||||||
return;
|
var partialTime = /(-?)(\d{1,2})m (\d{1,2})s/.exec(el.innerHTML);
|
||||||
// todo remove after replace timeUntil
|
if (partialTime !== null) {
|
||||||
var mp = el.innerHTML.match(/^(.*?)(-?\d+)d\s(-?\d+)h/);
|
var minute = parseInt(partialTime[2], 10),
|
||||||
if (mp !== null) {
|
second = parseInt(partialTime[3], 10),
|
||||||
return true;
|
invert = partialTime[1];
|
||||||
}
|
if (invert.length) {
|
||||||
|
// Count up because partial time is negative
|
||||||
var m = el.innerHTML.match(/^(.*?)(-?\d+)(.+\s)(-?\d+)(.+)/);
|
if (second < 59) {
|
||||||
if (m !== null) {
|
++second;
|
||||||
var nm = parseInt(m[2]);
|
|
||||||
var ns = parseInt(m[4]);
|
|
||||||
var signed = '';
|
|
||||||
var sec = 0;
|
|
||||||
|
|
||||||
if (nm < 0) {
|
|
||||||
signed = '-';
|
|
||||||
nm = nm * -1;
|
|
||||||
sec = nm * 60 + ns;
|
|
||||||
sec++;
|
|
||||||
} else if (nm == 0 && ns == 0) {
|
|
||||||
signed = '-';
|
|
||||||
sec = 1;
|
|
||||||
} else if (nm == 0 && m[2][0] == '-') {
|
|
||||||
signed = '-';
|
|
||||||
sec = ns;
|
|
||||||
sec++;
|
|
||||||
} else if (nm == 0 && m[2][0] != '-') {
|
|
||||||
sec = ns;
|
|
||||||
sec--;
|
|
||||||
} else {
|
} else {
|
||||||
signed = '';
|
++minute;
|
||||||
sec = nm * 60 + ns;
|
second = 0;
|
||||||
sec--;
|
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
nm = Math.floor(sec/60);
|
// Count down because partial time is positive
|
||||||
ns = sec - nm * 60;
|
if (second === 0) {
|
||||||
|
if (minute === 0) {
|
||||||
$(el).html(m[1] + signed + nm + m[3] + ns + m[5]);
|
// Invert counter
|
||||||
|
minute = 0;
|
||||||
|
second = 1;
|
||||||
|
invert = '-';
|
||||||
|
} else {
|
||||||
|
--minute;
|
||||||
|
second = 59;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
--second;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
el.innerHTML = el.innerHTML.substr(0, partialTime.index) + invert + minute.toString() + 'm '
|
||||||
|
+ second.toString() + 's' + el.innerHTML.substr(partialTime.index + partialTime[0].length);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user