server/www/main.js

31 lines
1.3 KiB
JavaScript
Raw Normal View History

window.addEventListener('load', function() {
var dom = Dom();
var async = Async();
var translations = Translations();
var i18n = I18n({translations: translations});
var fun = Fun();
var screen = Screen({dom: dom, i18n: i18n});
var messaging = Messaging();
var session = Session({messaging: messaging});
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 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 domElems = {
join: document.getElementById('login').join,
invite: document.getElementById('login').invite,
leave: document.getElementById('login').leave,
pickName: document.getElementById('join').getElementsByTagName('label')[0],
startGameWith: document.getElementById('invite').getElementsByTagName('label')[0]
};
for(var key in domElems) {
switch(domElems[key].tagName.toLowerCase()) {
case 'input': domElems[key].value = i18n.get(key); break;
default: domElems[key].textContent = i18n.get(key);
}
}
messaging.start();
});