Use static methods instead of properties

Fixes #6.
This commit is contained in:
Florine W. Dekker 2020-01-04 00:10:38 +01:00
parent 69fef87cd9
commit 92b1d30409
Signed by: FWDekker
GPG Key ID: B1B567AF58D6EE0F
1 changed files with 10 additions and 4 deletions

View File

@ -128,12 +128,18 @@
}
class Base64NumeralSystemInput extends NumeralSystemInput {
static defaultAlphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
static dropdownOptions = {"Standard": ['+', '/'], "Filename": ['-', '_'], "IMAP": ['+', ',']};
// TODO Convert static methods to static properties once supported by Firefox
static defaultAlphabet() {
return "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
}
static dropdownOptions() {
return {"Standard": ['+', '/'], "Filename": ['-', '_'], "IMAP": ['+', ',']};
}
constructor(name) {
super(name, new NumeralSystem(64, Base64NumeralSystemInput.defaultAlphabet, true));
super(name, new NumeralSystem(64, Base64NumeralSystemInput.defaultAlphabet(), true));
this.dropdownLabel = document.createElement("label");
this.dropdownLabel.setAttribute("for", `${this.name}Dropdown`);
@ -143,7 +149,7 @@
this.dropdown = document.createElement("select");
this.dropdown.id = `${this.name}Dropdown`;
this.dropdown.onchange = () => {
const selectedOption = Base64NumeralSystemInput.dropdownOptions[this.dropdown.value];
const selectedOption = Base64NumeralSystemInput.dropdownOptions()[this.dropdown.value];
this.setLastDigits(selectedOption[0], selectedOption[1]);
};