You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
function updateSplitBlocks(num, selectors) {
|
|
|
|
const numStr = numberPad(num, selectors.length, true)
|
|
|
|
for (let index in numStr) {
|
|
|
|
document.querySelector(selectors[index]).innerText = numStr[index].toString()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function numberPad(num, length, abs = false) {
|
|
|
|
// if (isNaN(num)) {
|
|
|
|
// num = 0
|
|
|
|
// }
|
|
|
|
|
|
|
|
const negative = num < 0 && !abs
|
|
|
|
// const outStr = Math.abs(num).toString().padStart(length, '0')
|
|
|
|
if (isNaN(num)) {
|
|
|
|
var outStr = num.toString().padStart(length, '-')
|
|
|
|
} else {
|
|
|
|
var outStr = num.toString().padStart(length, '0')
|
|
|
|
}
|
|
|
|
// const outStr = num.toString().padStart(length, '0')
|
|
|
|
if (negative) {
|
|
|
|
return '-' + outStr
|
|
|
|
}
|
|
|
|
|
|
|
|
return outStr
|
|
|
|
}
|