* Class representing one cell/char
| 25 | * Class representing one cell/char |
| 26 | */ |
| 27 | class Cell { |
| 28 | // DOM elements |
| 29 | DOM = { |
| 30 | // the char element (<span>) |
| 31 | el: null, |
| 32 | }; |
| 33 | // cell position |
| 34 | position = -1; |
| 35 | // previous cell position |
| 36 | previousCellPosition = -1; |
| 37 | // original innerHTML |
| 38 | original; |
| 39 | // current state/innerHTML |
| 40 | state; |
| 41 | color; |
| 42 | originalColor; |
| 43 | // cached values |
| 44 | cache; |
| 45 | |
| 46 | /** |
| 47 | * Constructor. |
| 48 | * @param {Element} DOM_el - the char element (<span>) |
| 49 | */ |
| 50 | constructor(DOM_el, { |
| 51 | position, |
| 52 | previousCellPosition |
| 53 | } = {}) { |
| 54 | this.DOM.el = DOM_el; |
| 55 | this.original = this.DOM.el.innerHTML; |
| 56 | this.state = this.original; |
| 57 | this.color = this.originalColor = getComputedStyle(document.documentElement).getPropertyValue('--color-text'); |
| 58 | this.position = position; |
| 59 | this.previousCellPosition = previousCellPosition; |
| 60 | } |
| 61 | /** |
| 62 | * @param {string} value |
| 63 | */ |
| 64 | set(value) { |
| 65 | this.state = value; |
| 66 | this.DOM.el.innerHTML = this.state; |
| 67 | } |
| 68 | } |
| 69 | |
| 70 | /** |
| 71 | * Class representing the TypeShuffle object |
nothing calls this directly
no outgoing calls
no test coverage detected