-function getGameFromStorage(gameId)
-{
- const gid = this.gameRef.id;
- const rid = this.gameRef.rid; //may be blank
- let game = {};
- if (localStorage.getItem("gameId") === gameId)
- {
- // Retrieve running game from localStorage
- game.score = localStorage.getItem("score");
- game.oppid = localStorage.getItem("oppid");
- game.oppname = localStorage.getItem("oppname");
- game.mycolor = localStorage.getItem("mycolor");
- game.fenStart = localStorage.getItem("fenStart");
- game.moves = localStorage.getItem("moves");
- }
- else
- {
- // Find the game in indexedDB: TODO
- }
-}
+ get: function(gameRef)
+ {
+ const gid = gameRef.id;
+ const rid = gameRef.rid; //may be blank
+ let game = {};
+ if (localStorage.getItem("gameId") === gid)
+ {
+ // Retrieve running game from localStorage
+ game.score = localStorage.getItem("score");
+ game.mycolor = localStorage.getItem("mycolor");
+ game.fenStart = localStorage.getItem("fenStart");
+ game.fen = localStorage.getItem("fen");
+ game.moves = JSON.parse(localStorage.getItem("moves"));
+ game.players = JSON.parse(localStorage.getItem("players"));
+ game.started = JSON.parse(localStorage.getItem("started"));
+ game.clocks = JSON.parse(localStorage.getItem("clocks"));
+ game.timeControl = localStorage.getItem("timeControl");
+ game.increment = localStorage.getItem("increment");
+ game.mode = "live";
+ }
+ else
+ {
+ // Find the game in indexedDB, on server or remotely: TODO
+ }
+ return game;
+ },
+};