| 86 | } |
| 87 | |
| 88 | const updateHashState = () => { |
| 89 | let c = 0 |
| 90 | const u8 = new Uint8Array(ntiles * ntiles) |
| 91 | for (let i = 0; i < ntiles; i++) { |
| 92 | for (let j = 0; j < ntiles; j++) { |
| 93 | u8[c++] = map[i][j][0] * texWidth + map[i][j][1] |
| 94 | } |
| 95 | } |
| 96 | const state = ToBase64(u8) |
| 97 | if (!previousState || previousState != state) { |
| 98 | history.pushState(undefined, undefined, `#${state}`) |
| 99 | previousState = state |
| 100 | } |
| 101 | } |
| 102 | |
| 103 | window.addEventListener('popstate', function () { |
| 104 | loadHashState(document.location.hash.substring(1)) |