add thousands separator

This commit is contained in:
Stewart Allen 2022-01-12 11:07:49 -05:00
commit ad361ec626
2 changed files with 10 additions and 3 deletions

View file

@ -346,9 +346,9 @@ function ui_build() {
h.div({ _: "" }),
h.div({ _: "count", class: "top" }),
h.div({ _: "vertex", class: "side" }),
h.label({ _: t_vert }),
h.label({ _: util.comma(t_vert) }),
h.div({ _: "face", class: "side" }),
h.label({ _: t_face }),
h.label({ _: util.comma(t_face) }),
])
])];
// bind elements to selectlist div

View file

@ -27,6 +27,13 @@ let util = mesh.util = {
return uid.join('-');
},
// add comma separator to 1000s
comma(val) {
let str = val.toString().split(".");
str[0] = str[0].replace(/\B(?=(\d{3})+(?!\d))/g, ",");
return str.join(".");
},
// merge repeated function calls like updates
// that importantly take no arguments
defer(fn, time = 50) {
@ -150,4 +157,4 @@ let util = mesh.util = {
}
};
})();
})();