com.databasesandlife.util.wicket.CountingUpThenAutoRefreshingLabel.js Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of java-common Show documentation
Show all versions of java-common Show documentation
Utility classes developed at Adrian Smith Software (A.S.S.)
function addThousandSeparators(thousandSeparator, number)
{
number += '';
x = number.split('.');
x1 = x[0];
var rgx = /(\d+)(\d{3})/;
while (rgx.test(x1)) {
x1 = x1.replace(rgx, '$1' + thousandSeparator + '$2');
}
return x1;
}
function CountingUpThenAutoRefreshLabel_continueCounting(countingUpDurationSeconds, countingUpRefreshIntervalSeconds, tendencyThreshold,
thousandSeparator, spanTag, currentDiffToTarget, targetValue) {
spanTag.innerHTML = addThousandSeparators(thousandSeparator, targetValue - currentDiffToTarget);
var m = Math.pow(tendencyThreshold, 1.0 / (countingUpDurationSeconds / countingUpRefreshIntervalSeconds));
setTimeout(
function() { CountingUpThenAutoRefreshLabel_continueCounting(
countingUpDurationSeconds, countingUpRefreshIntervalSeconds, tendencyThreshold,
thousandSeparator, spanTag, m*currentDiffToTarget, targetValue); },
1000*countingUpRefreshIntervalSeconds
);
}