-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathoptions.js
30 lines (27 loc) · 943 Bytes
/
options.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
// import Options.js
let options;
const updateAccessibility = () => {
const company = options.getCompany();
if (company) {
updateLink(document.querySelector("#mobileSite"), options.getMobileSite(company));
updateLink(document.querySelector("#desktopSite"), options.getDesktopSite(company));
}
document.querySelector("#accessibility").className = company ? "visible" : "hidden";
}
const updateLink = (link, site) => {
link.href = site;
link.textContent = site;
};
window.addEventListener("load", () => {
options = new Options(window.localStorage);
updateAccessibility();
document.querySelector("#companyForm").addEventListener("submit", saveCompanyName);
}, false);
const saveCompanyName = event => {
event.preventDefault();
const companyElement = document.querySelector("#company");
const company = companyElement.value;
options.setCompany(company.toLowerCase());
companyElement.value = '';
updateAccessibility();
};