Left pad card number for code

This commit is contained in:
Adam Goldsmith 2021-09-08 17:12:58 -04:00
parent abc474c993
commit 6ce8f04f42

View File

@ -1,5 +1,5 @@
// TODO: should be defined in strange eons somewhere
const pack_code = "420";
const pack_code = "42";
function renameSlot(slot) {
if (slot.startsWith('1 ')) {
@ -76,6 +76,10 @@ function int_or_null(inp) {
}
}
function leftPad(str, len, fill) {
return fill.repeat(Math.max(len - str.length, 0)) + str;
}
function build_card(component) {
function substitute_tags(str) {
str = str.replace("<fullname>", String(component.getName()));
@ -86,7 +90,7 @@ function build_card(component) {
return str;
}
var code = pack_code + component.settings.get('CollectionNumber');
var code = pack_code + leftPad(String(component.settings.get('CollectionNumber')), 3, '0');
var card_data = {
code: String(code),