refactor(js): use const instead of let
This commit is contained in:
parent
78dab48732
commit
f192034a2b
@ -44,27 +44,27 @@ MODAL_STATES = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function showModal(state_name, parameters) {
|
function showModal(state_name, parameters) {
|
||||||
let state = MODAL_STATES[state_name];
|
const state = MODAL_STATES[state_name];
|
||||||
|
|
||||||
let message = document.getElementById("message");
|
const message = document.getElementById("message");
|
||||||
|
|
||||||
let img = message.childNodes[0];
|
const img = message.childNodes[0];
|
||||||
img.src = state.icon_url;
|
img.src = state.icon_url;
|
||||||
|
|
||||||
let text = message.childNodes[1];
|
const text = message.childNodes[1];
|
||||||
text.textContent = " " + (state.message instanceof Function
|
text.textContent = " " + (state.message instanceof Function
|
||||||
? state.message(parameters)
|
? state.message(parameters)
|
||||||
: state.message);
|
: state.message);
|
||||||
|
|
||||||
let button = document.getElementById("close_button");
|
const button = document.getElementById("close_button");
|
||||||
button.disabled = state.button_disabled;
|
button.disabled = state.button_disabled;
|
||||||
|
|
||||||
let modal = document.getElementById("modal");
|
const modal = document.getElementById("modal");
|
||||||
modal.style.display = 'flex';
|
modal.style.display = 'flex';
|
||||||
}
|
}
|
||||||
|
|
||||||
function hideModal() {
|
function hideModal() {
|
||||||
let modal = document.getElementById("modal");
|
const modal = document.getElementById("modal");
|
||||||
modal.style.display = 'none';
|
modal.style.display = 'none';
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -72,8 +72,8 @@ FIELDS = ['username', 'old_password', 'new_password']
|
|||||||
|
|
||||||
function mapFields(thunk) {
|
function mapFields(thunk) {
|
||||||
for (fieldIndex in FIELDS) {
|
for (fieldIndex in FIELDS) {
|
||||||
let fieldName = FIELDS[fieldIndex]
|
const fieldName = FIELDS[fieldIndex]
|
||||||
let field = document.querySelectorAll(`input[name=${fieldName}]`)[0];
|
const field = document.querySelectorAll(`input[name=${fieldName}]`)[0];
|
||||||
thunk(field, fieldName);
|
thunk(field, fieldName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -85,7 +85,7 @@ function clearFields() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function changePasswords() {
|
function changePasswords() {
|
||||||
let query = {};
|
const query = {};
|
||||||
|
|
||||||
mapFields((field, fieldName) => {
|
mapFields((field, fieldName) => {
|
||||||
query[fieldName] = field.value;
|
query[fieldName] = field.value;
|
||||||
|
Loading…
Reference in New Issue
Block a user