| 1 | // TODO: general methods to access/retrieve from storage, to be generalized |
| 2 | // https://developer.mozilla.org/fr/docs/Web/API/API_IndexedDB |
| 3 | // https://dexie.org/ |
| 4 | setStorage: function(myid, oppid, gameId, variant, mycolor, fenStart) { |
| 5 | localStorage.setItem("myid", myid); |
| 6 | localStorage.setItem("oppid", oppid); |
| 7 | localStorage.setItem("gameId", gameId); |
| 8 | localStorage.setItem("variant", variant); |
| 9 | localStorage.setItem("mycolor", mycolor); |
| 10 | localStorage.setItem("fenStart", fenStart); |
| 11 | localStorage.setItem("moves", []); |
| 12 | }, |
| 13 | updateStorage: function(move) { |
| 14 | let moves = JSON.parse(localStorage.getItem("moves")); |
| 15 | moves.push(move); |
| 16 | localStorage.setItem("moves", JSON.stringify(moves)); |
| 17 | }, |
| 18 | // "computer mode" clearing is done through the menu |
| 19 | clearStorage: function() { |
| 20 | delete localStorage["myid"]; |
| 21 | delete localStorage["oppid"]; |
| 22 | delete localStorage["gameId"]; |
| 23 | delete localStorage["variant"]; |
| 24 | delete localStorage["mycolor"]; |
| 25 | delete localStorage["fenStart"]; |
| 26 | delete localStorage["moves"]; |
| 27 | }, |