Simplify session's get function
This commit is contained in:
parent
52a6d8fc91
commit
cc2079050b
3 changed files with 6 additions and 16 deletions
|
@ -13,7 +13,7 @@ function Buttons(session) {
|
|||
};
|
||||
|
||||
document.addEventListener('keydown', function(event) {
|
||||
var button = session.get('options').layout[event.key];
|
||||
var button = session.get().options.layout[event.key];
|
||||
if(button != undefined && mapping != undefined && mapping[button] != undefined) {
|
||||
event.preventDefault();
|
||||
mapping[button]();
|
||||
|
@ -30,7 +30,7 @@ function Buttons(session) {
|
|||
|
||||
function assign(key, button) {
|
||||
var layoutDiff = {};
|
||||
var layout = session.get('options').layout;
|
||||
var layout = session.get().options.layout;
|
||||
for(var currentKey in layout) {
|
||||
if(layout[currentKey] == button) {
|
||||
layoutDiff[currentKey] = undefined;
|
||||
|
|
|
@ -30,18 +30,8 @@ function Session(async, messaging) {
|
|||
return o;
|
||||
}
|
||||
|
||||
function get(path, obj) {
|
||||
obj = obj == undefined ? session : obj;
|
||||
if(Array.isArray(path)) {
|
||||
if(path.length == 0) {
|
||||
return obj;
|
||||
} else {
|
||||
var key = path.shift();
|
||||
return get(path, obj[key]);
|
||||
}
|
||||
} else {
|
||||
return obj[path];
|
||||
}
|
||||
function get() {
|
||||
return session;
|
||||
}
|
||||
|
||||
function save(key, value) {
|
||||
|
|
|
@ -5,7 +5,7 @@ function UI(async, buttons, cache, dom, messaging, screen, session) {
|
|||
medium: 50,
|
||||
fast: 20
|
||||
};
|
||||
var textSpeed = session.get('options').textSpeed;
|
||||
var textSpeed = session.get().options.textSpeed;
|
||||
|
||||
return {
|
||||
animation: animation,
|
||||
|
@ -212,7 +212,7 @@ function UI(async, buttons, cache, dom, messaging, screen, session) {
|
|||
}
|
||||
|
||||
function setLayout() {
|
||||
var layout = session.get('options').layout
|
||||
var layout = session.get().options.layout;
|
||||
var buttonsMenu = {
|
||||
cancel: function() {},
|
||||
entries: [],
|
||||
|
|
Loading…
Reference in a new issue