forked from mattgodbolt/jsbeeb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.js
46 lines (39 loc) · 1.29 KB
/
config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
"use strict";
import $ from "jquery";
import { findModel } from "./models.js";
export function Config(onClose) {
let changed = {};
this.model = null;
const $configuration = document.getElementById("configuration");
$configuration.addEventListener("show.bs.modal", () => {
changed = {};
setDropdownText(this.model.name);
});
$configuration.addEventListener("hide.bs.modal", () => onClose(changed));
this.setModel = function (modelName) {
this.model = findModel(modelName);
$(".bbc-model").text(this.model.name);
};
this.setKeyLayout = function (keyLayout) {
$(".keyboard-layout").text(keyLayout[0].toUpperCase() + keyLayout.substr(1));
};
function setDropdownText(modelName) {
$("#bbc-model-dropdown .bbc-model").text(modelName);
}
$(".model-menu a").on(
"click",
function (e) {
const modelName = $(e.target).attr("data-target");
changed.model = modelName;
setDropdownText(modelName);
}.bind(this)
);
$(".keyboard-menu a").on(
"click",
function (e) {
const keyLayout = $(e.target).attr("data-target");
changed.keyLayout = keyLayout;
this.setKeyLayout(keyLayout);
}.bind(this)
);
}