1 | "use strict";
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 | Object.defineProperty(exports, "__esModule", { value: true });
|
18 | exports.padWithZeroes = exports.measureTextWidth = void 0;
|
19 |
|
20 |
|
21 |
|
22 |
|
23 | function measureTextWidth(text, className, containerElement) {
|
24 | if (className === void 0) { className = ""; }
|
25 | if (containerElement === void 0) { containerElement = document.body; }
|
26 | if (containerElement == null) {
|
27 | return 0;
|
28 | }
|
29 | var span = document.createElement("span");
|
30 | span.classList.add(className);
|
31 | span.textContent = text;
|
32 | containerElement.appendChild(span);
|
33 | var spanWidth = span.offsetWidth;
|
34 | span.remove();
|
35 | return spanWidth;
|
36 | }
|
37 | exports.measureTextWidth = measureTextWidth;
|
38 | function padWithZeroes(str, minLength) {
|
39 | if (str.length < minLength) {
|
40 | return "".concat(stringRepeat("0", minLength - str.length)).concat(str);
|
41 | }
|
42 | else {
|
43 | return str;
|
44 | }
|
45 | }
|
46 | exports.padWithZeroes = padWithZeroes;
|
47 | function stringRepeat(str, numTimes) {
|
48 | return new Array(numTimes + 1).join(str);
|
49 | }
|
50 |
|
\ | No newline at end of file |