Implement status handling to provide visual clue about the game state
This commit is contained in:
parent
70e8981eb4
commit
66d2926635
5 changed files with 26 additions and 2 deletions
|
@ -16,6 +16,7 @@ function Game(modules) {
|
||||||
if(document.hasFocus()) {
|
if(document.hasFocus()) {
|
||||||
modules.async.run(handleGameMessage(o));
|
modules.async.run(handleGameMessage(o));
|
||||||
} else {
|
} else {
|
||||||
|
modules.statusHandler.set("♪");
|
||||||
queue.push(handleGameMessage(o));
|
queue.push(handleGameMessage(o));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
<script src="messaging.js"></script>
|
<script src="messaging.js"></script>
|
||||||
<script src="session.js"></script>
|
<script src="session.js"></script>
|
||||||
<script src="room.js"></script>
|
<script src="room.js"></script>
|
||||||
|
<script src="statusHandler.js"></script>
|
||||||
<script src="login.js"></script>
|
<script src="login.js"></script>
|
||||||
<script src="hanafuda.js"></script>
|
<script src="hanafuda.js"></script>
|
||||||
<script src="game.js"></script>
|
<script src="game.js"></script>
|
||||||
|
|
|
@ -56,6 +56,7 @@ function Login(modules) {
|
||||||
var name = modules.room.name(o.from);
|
var name = modules.room.name(o.from);
|
||||||
// invitations should come only from known players, in doubt say «no»
|
// invitations should come only from known players, in doubt say «no»
|
||||||
if(name) {
|
if(name) {
|
||||||
|
modules.statusHandler.set("🎴");
|
||||||
modules.screen.dialog({
|
modules.screen.dialog({
|
||||||
text: modules.i18n.get('invited')(name),
|
text: modules.i18n.get('invited')(name),
|
||||||
answers: invitationAnswers
|
answers: invitationAnswers
|
||||||
|
|
|
@ -8,9 +8,10 @@ window.addEventListener('load', function() {
|
||||||
var messaging = Messaging();
|
var messaging = Messaging();
|
||||||
var session = Session({messaging: messaging});
|
var session = Session({messaging: messaging});
|
||||||
var room = Room({dom: dom, messaging: messaging, session: session, fun: fun});
|
var room = Room({dom: dom, messaging: messaging, session: session, fun: fun});
|
||||||
var login = Login({dom: dom, i18n: i18n, messaging: messaging, room: room, screen: screen, session: session});
|
var statusHandler = StatusHandler();
|
||||||
|
var login = Login({dom: dom, i18n: i18n, messaging: messaging, room: room, screen: screen, session: session, statusHandler: statusHandler});
|
||||||
var hanafuda = Hanafuda({fun: fun});
|
var hanafuda = Hanafuda({fun: fun});
|
||||||
var game = Game({async: async, dom: dom, i18n: i18n, fun: fun, hanafuda: hanafuda, messaging: messaging, room: room, screen: screen, session: session});
|
var game = Game({async: async, dom: dom, i18n: i18n, fun: fun, hanafuda: hanafuda, messaging: messaging, room: room, screen: screen, session: session, statusHandler: statusHandler});
|
||||||
|
|
||||||
var domElems = {
|
var domElems = {
|
||||||
join: document.getElementById('login').join,
|
join: document.getElementById('login').join,
|
||||||
|
|
20
www/statusHandler.js
Normal file
20
www/statusHandler.js
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
function StatusHandler() {
|
||||||
|
var baseTitle = document.title;
|
||||||
|
window.addEventListener('focus', reset);
|
||||||
|
|
||||||
|
return {
|
||||||
|
reset: reset,
|
||||||
|
set: set
|
||||||
|
};
|
||||||
|
|
||||||
|
function reset() {
|
||||||
|
document.title = baseTitle;
|
||||||
|
}
|
||||||
|
|
||||||
|
function set(newStatus) {
|
||||||
|
if(!document.hasFocus()) {
|
||||||
|
document.title = newStatus + " - " + baseTitle;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in a new issue