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) {
|
||||
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;
|
||||
|
||||
let text = message.childNodes[1];
|
||||
const text = message.childNodes[1];
|
||||
text.textContent = " " + (state.message instanceof Function
|
||||
? state.message(parameters)
|
||||
: state.message);
|
||||
|
||||
let button = document.getElementById("close_button");
|
||||
const button = document.getElementById("close_button");
|
||||
button.disabled = state.button_disabled;
|
||||
|
||||
let modal = document.getElementById("modal");
|
||||
const modal = document.getElementById("modal");
|
||||
modal.style.display = 'flex';
|
||||
}
|
||||
|
||||
function hideModal() {
|
||||
let modal = document.getElementById("modal");
|
||||
const modal = document.getElementById("modal");
|
||||
modal.style.display = 'none';
|
||||
}
|
||||
|
||||
@ -72,8 +72,8 @@ FIELDS = ['username', 'old_password', 'new_password']
|
||||
|
||||
function mapFields(thunk) {
|
||||
for (fieldIndex in FIELDS) {
|
||||
let fieldName = FIELDS[fieldIndex]
|
||||
let field = document.querySelectorAll(`input[name=${fieldName}]`)[0];
|
||||
const fieldName = FIELDS[fieldIndex]
|
||||
const field = document.querySelectorAll(`input[name=${fieldName}]`)[0];
|
||||
thunk(field, fieldName);
|
||||
}
|
||||
}
|
||||
@ -85,7 +85,7 @@ function clearFields() {
|
||||
}
|
||||
|
||||
function changePasswords() {
|
||||
let query = {};
|
||||
const query = {};
|
||||
|
||||
mapFields((field, fieldName) => {
|
||||
query[fieldName] = field.value;
|
||||
|
Loading…
Reference in New Issue
Block a user