+ this.focus = (document.visibilityState == "visible");
+ if (!this.focus && !!this.rematchOffer) {
+ this.rematchOffer = "";
+ this.send("rematchoffer", { data: false });
+ // Do not remove rematch offer from (local) storage
+ }
+ this.send(this.focus ? "getfocus" : "losefocus");
+ },
+ onFocus: function() {
+ this.focus = true;
+ this.send("getfocus");
+ },
+ onBlur: function() {
+ this.focus = false;
+ if (!!this.rematchOffer) {
+ this.rematchOffer = "";
+ this.send("rematchoffer", { data: false });
+ }
+ this.send("losefocus");
+ },
+ isLargeScreen: function() {
+ return window.innerWidth >= 500;
+ },
+ gotoRules: function() {
+ this.$router.push("/variants/" + this.game.vname);
+ },
+ participateInChat: function(p) {
+ return Object.keys(p.tmpIds).some(x => p.tmpIds[x].focus) && !!p.name;
+ },
+ someAnonymousPresent: function() {
+ return (
+ Object.values(this.people).some(p =>
+ !p.name && Object.keys(p.tmpIds).some(x => p.tmpIds[x].focus)
+ )