2019-12-11 22:03:16 +01:00
|
|
|
Screen.Login = function(modules) {
|
|
|
|
var root = document.getElementById('login');
|
|
|
|
var submit = root.submitButton;
|
|
|
|
|
|
|
|
init();
|
|
|
|
|
|
|
|
return {};
|
|
|
|
|
|
|
|
function init() {
|
|
|
|
initDOMEvents();
|
|
|
|
initMessageHandlers();
|
|
|
|
var name = modules.save.get('player.name');
|
|
|
|
if(name != undefined && name.length > 0) {
|
|
|
|
root.you.value = name;
|
|
|
|
formDisable(false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function initDOMEvents() {
|
|
|
|
root.addEventListener('submit', function(e) {
|
|
|
|
e.preventDefault();
|
|
|
|
modules.session.start(root.you.value);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function initMessageHandlers() {
|
|
|
|
modules.messaging.addEventListener(["LogIn"], function(o) {
|
|
|
|
if(modules.session.is(o.from)) {
|
|
|
|
modules.screen.select('hall');
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
modules.messaging.addEventListener('open', function() {formDisable(false);});
|
|
|
|
modules.messaging.addEventListener('close', function() {formDisable(true);});
|
|
|
|
}
|
|
|
|
|
|
|
|
function formDisable(disabled) {
|
2019-12-12 22:16:49 +01:00
|
|
|
[submit, root.join].forEach(function(button) {
|
2019-12-11 22:03:16 +01:00
|
|
|
button.disabled = disabled || !modules.messaging.isOn();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|