-
Notifications
You must be signed in to change notification settings - Fork 68
/
config.js
127 lines (106 loc) · 3.9 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
"use strict";
import $ from "jquery";
import { findModel } from "./models.js";
export class Config {
constructor(onClose) {
this.changed = {};
this.model = null;
this.coProcessor = null;
const $configuration = document.getElementById("configuration");
$configuration.addEventListener("show.bs.modal", () => {
this.changed = {};
this.setDropdownText(this.model.name);
this.set65c02(this.model.tube);
this.setTeletext(this.model.hasTeletextAdaptor);
this.setMusic5000(this.model.hasMusic5000);
this.setEconet(this.model.hasEconet);
});
$configuration.addEventListener("hide.bs.modal", () => onClose(this.changed));
$(".model-menu a").on("click", (e) => {
this.changed.model = $(e.target).attr("data-target");
this.setDropdownText($(e.target).text());
});
$("#65c02").on("click", () => {
this.changed.coProcessor = $("#65c02").prop("checked");
});
$("#hasTeletextAdaptor").on("click", () => {
this.changed.hasTeletextAdaptor = $("#hasTeletextAdaptor").prop("checked");
});
$("#hasEconet").on("click", () => {
this.changed.hasEconet = $("#hasEconet").prop("checked");
});
$("#hasMusic5000").on("click", () => {
this.changed.hasMusic5000 = $("#hasMusic5000").prop("checked");
});
$(".keyboard-menu a").on("click", (e) => {
const keyLayout = $(e.target).attr("data-target");
this.changed.keyLayout = keyLayout;
this.setKeyLayout(keyLayout);
});
}
setModel(modelName) {
this.model = findModel(modelName);
$(".bbc-model").text(this.model.name);
}
setKeyLayout(keyLayout) {
$(".keyboard-layout").text(keyLayout[0].toUpperCase() + keyLayout.substring(1));
}
set65c02(enabled) {
enabled = !!enabled;
$("#65c02").prop("checked", enabled);
this.model.tube = enabled ? findModel("Tube65c02") : null;
}
setEconet(enabled) {
enabled = !!enabled;
$("#hasEconet").prop("checked", enabled);
this.model.hasEconet = enabled;
if (enabled && this.model.isMaster) {
this.addRemoveROM("master/anfs-4.25.rom", true);
}
}
setMusic5000(enabled) {
enabled = !!enabled;
$("#hasMusic5000").prop("checked", enabled);
this.model.hasMusic5000 = enabled;
this.addRemoveROM("ample.rom", enabled);
}
setTeletext(enabled) {
enabled = !!enabled;
$("#hasTeletextAdaptor").prop("checked", enabled);
this.model.hasTeletextAdaptor = enabled;
this.addRemoveROM("ats-3.0.rom", enabled);
}
setDropdownText(modelName) {
$("#bbc-model-dropdown .bbc-model").text(modelName);
}
addRemoveROM(romName, required) {
if (required && !this.model.os.includes(romName)) {
this.model.os.push(romName);
} else {
let pos = this.model.os.indexOf(romName);
if (pos !== -1) {
this.model.os.splice(pos, 1);
}
}
}
mapLegacyModels(parsedQuery) {
if (!parsedQuery.model) {
return;
}
// "MasterTurbo" = Master + 6502 second processor
if (parsedQuery.model.toLowerCase() === "masterturbo") {
parsedQuery.model = "Master";
parsedQuery.coProcessor = true;
}
// "BMusic5000" = BBC DFS 1.2 + Music 5000
if (parsedQuery.model.toLowerCase() === "bmusic5000") {
parsedQuery.model = "B-DFS1.2";
parsedQuery.hasMusic5000 = true;
}
// "BTeletext" = BBC DFS 1.2 + Teletext adaptor
if (parsedQuery.model.toLowerCase() === "bteletext") {
parsedQuery.model = "B-DFS1.2";
parsedQuery.hasTeletextAdaptor = true;
}
}
}