projects
/
vchess.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Convert all remaining tabs by 2spaces
[vchess.git]
/
client
/
src
/
utils
/
gameStorage.js
diff --git
a/client/src/utils/gameStorage.js
b/client/src/utils/gameStorage.js
index
0284763
..
630d1c7
100644
(file)
--- a/
client/src/utils/gameStorage.js
+++ b/
client/src/utils/gameStorage.js
@@
-1,6
+1,6
@@
// Game object: {
// // Static informations:
// Game object: {
// // Static informations:
-//
gameI
d: string
+//
i
d: string
// vname: string,
// fenStart: string,
// players: array of sid+id+name,
// vname: string,
// fenStart: string,
// players: array of sid+id+name,
@@
-39,7
+39,7
@@
function dbOperation(callback)
alert("Error while loading database: " + event.target.errorCode);
};
// Create objectStore for vchess->games
alert("Error while loading database: " + event.target.errorCode);
};
// Create objectStore for vchess->games
- let objectStore = db.createObjectStore("games", { keyPath: "
gameI
d" });
+ let objectStore = db.createObjectStore("games", { keyPath: "
i
d" });
objectStore.createIndex("score", "score"); //to search by game result
}
}
objectStore.createIndex("score", "score"); //to search by game result
}
}
@@
-67,7
+67,8
@@
export const GameStorage =
},
// TODO: also option to takeback a move ?
},
// TODO: also option to takeback a move ?
- update: function(gameId, obj) //move, fen, clocks, score, initime, ...
+ // obj: chat, move, fen, clocks, score[Msg], initime, ...
+ update: function(gameId, obj)
{
if (Number.isInteger(gameId) || !isNaN(parseInt(gameId)))
{
{
if (Number.isInteger(gameId) || !isNaN(parseInt(gameId)))
{
@@
-79,10
+80,12
@@
export const GameStorage =
gid: gameId,
newObj:
{
gid: gameId,
newObj:
{
- // TODO: I think stringify isn't requuired here (see ajax() )
- move:
JSON.stringify(obj.move)
, //may be undefined...
+ chat: obj.chat,
+ move:
obj.move
, //may be undefined...
fen: obj.fen,
score: obj.score,
fen: obj.fen,
score: obj.score,
+ scoreMsg: obj.scoreMsg,
+ drawOffer: obj.drawOffer,
}
}
);
}
}
);
@@
-134,7
+137,11
@@
export const GameStorage =
if (Number.isInteger(gameId) || !isNaN(parseInt(gameId)))
{
ajax("/games", "GET", {gid:gameId}, res => {
if (Number.isInteger(gameId) || !isNaN(parseInt(gameId)))
{
ajax("/games", "GET", {gid:gameId}, res => {
- callback(res.game);
+ let game = res.game;
+ game.moves.forEach(m => {
+ m.squares = JSON.parse(m.squares);
+ });
+ callback(game);
});
}
else //local game
});
}
else //local game