import I18n; import GUI.ConnectedForm; import select from GUI.Screen; import Messaging; import Session; import Save; var login; var form; return { init: init }; function init() { login = GUI.ConnectedForm.get('login'); form = login.root; initDOM(); initMessageHandlers(); var name = Save.get('player.name'); if(name != undefined && name.length > 0) { form.you.value = name; login.enable(); } } function initDOM() { form.getElementsByTagName('label')[0].textContent = I18n.get('pickName'); form.join.value = I18n.get('join'); form.addEventListener('submit', function(e) { e.preventDefault(); Session.start(form.you.value); }); form.you.addEventListener("input", validate); } function initMessageHandlers() { Messaging.addEventListener(["LogIn"], function(o) { if(Session.is(o.from)) { select('hall'); } }); } function validate(e) { login.enable(e.target.value != ""); }