projects
/
vchess.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
User-friendly vchess presentation on index + some code cleaning
[vchess.git]
/
public
/
javascripts
/
components
/
game.js
diff --git
a/public/javascripts/components/game.js
b/public/javascripts/components/game.js
index
1178b64
..
0720255
100644
(file)
--- a/
public/javascripts/components/game.js
+++ b/
public/javascripts/components/game.js
@@
-16,7
+16,7
@@
Vue.component('my-game', {
fenStart: "",
incheck: [],
pgnTxt: "",
fenStart: "",
incheck: [],
pgnTxt: "",
- expert:
document.cookie.length>0 ? document.cookie.substr(-1)=="1"
: false,
+ expert:
getCookie("expert") === "1" ? true
: false,
gameId: "", //used to limit computer moves' time
};
},
gameId: "", //used to limit computer moves' time
};
},
@@
-484,10
+484,7
@@
Vue.component('my-game', {
created: function() {
const url = socketUrl;
const continuation = (localStorage.getItem("variant") === variant);
created: function() {
const url = socketUrl;
const continuation = (localStorage.getItem("variant") === variant);
- this.myid = continuation
- ? localStorage.getItem("myid")
- // random enough (TODO: function)
- : (Date.now().toString(36) + Math.random().toString(36).substr(2, 7)).toUpperCase();
+ this.myid = continuation ? localStorage.getItem("myid") : getRandString();
if (!continuation)
{
// HACK: play a small silent sound to allow "new game" sound later if tab not focused
if (!continuation)
{
// HACK: play a small silent sound to allow "new game" sound later if tab not focused
@@
-667,6
+664,7
@@
Vue.component('my-game', {
return; //no newgame while playing
if (this.seek)
{
return; //no newgame while playing
if (this.seek)
{
+ this.conn.send(JSON.stringify({code:"cancelnewgame"}));
delete localStorage["newgame"]; //cancel game seek
this.seek = false;
}
delete localStorage["newgame"]; //cancel game seek
this.seek = false;
}
@@
-682,7
+680,7
@@
Vue.component('my-game', {
toggleExpertMode: function(e) {
this.getRidOfTooltip(e.currentTarget);
this.expert = !this.expert;
toggleExpertMode: function(e) {
this.getRidOfTooltip(e.currentTarget);
this.expert = !this.expert;
-
document.cookie = "expert=" + (
this.expert ? "1" : "0");
+
setCookie("expert",
this.expert ? "1" : "0");
},
resign: function() {
if (this.mode == "human" && this.oppConnected)
},
resign: function() {
if (this.mode == "human" && this.oppConnected)
@@
-723,8
+721,7
@@
Vue.component('my-game', {
}
return;
}
}
return;
}
- // random enough (TODO: function)
- this.gameId = (Date.now().toString(36) + Math.random().toString(36).substr(2, 7)).toUpperCase();
+ this.gameId = getRandString();
this.vr = new VariantRules(fen, moves || []);
this.score = "*";
this.pgnTxt = ""; //redundant with this.score = "*", but cleaner
this.vr = new VariantRules(fen, moves || []);
this.score = "*";
this.pgnTxt = ""; //redundant with this.score = "*", but cleaner