server/www/main.js

30 lines
1.4 KiB
JavaScript

window.addEventListener('load', function() {
var dom = Dom();
var async = Async();
var translations = Translations();
var i18n = I18n({translations: translations});
var fun = Fun();
var save = Save();
var screen = Screen({dom: dom, i18n: i18n});
var messaging = Messaging({screen: screen});
var session = Session({messaging: messaging, save: save});
var room = Room({dom: dom, messaging: messaging, session: session, fun: fun});
var statusHandler = StatusHandler();
var login = Login({dom: dom, i18n: i18n, messaging: messaging, room: room, save: save, screen: screen, session: session, statusHandler: statusHandler});
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, statusHandler: statusHandler});
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);
}
}
});