()
| 8 | #winChangeCallback; |
| 9 | |
| 10 | constructor () |
| 11 | { |
| 12 | let that = this; |
| 13 | |
| 14 | // event listener for when localStorage is changed from another window |
| 15 | addEventListener("storage", (event) => |
| 16 | { |
| 17 | if (event.key == "windows") |
| 18 | { |
| 19 | let newWindows = JSON.parse(event.newValue); |
| 20 | let winChange = that.#didWindowsChange(that.#windows, newWindows); |
| 21 | |
| 22 | that.#windows = newWindows; |
| 23 | |
| 24 | if (winChange) |
| 25 | { |
| 26 | if (that.#winChangeCallback) that.#winChangeCallback(); |
| 27 | } |
| 28 | } |
| 29 | }); |
| 30 | |
| 31 | // event listener for when current window is about to ble closed |
| 32 | window.addEventListener('beforeunload', function (e) |
| 33 | { |
| 34 | let index = that.getWindowIndexFromId(that.#id); |
| 35 | |
| 36 | //remove this window from the list and update local storage |
| 37 | that.#windows.splice(index, 1); |
| 38 | that.updateWindowsLocalStorage(); |
| 39 | }); |
| 40 | } |
| 41 | |
| 42 | // check if theres any changes to the window list |
| 43 | #didWindowsChange (pWins, nWins) |
nothing calls this directly
no test coverage detected