diff --git a/src/static/webldappasswd.js b/src/static/webldappasswd.js index 36d07af..5d8003f 100644 --- a/src/static/webldappasswd.js +++ b/src/static/webldappasswd.js @@ -67,15 +67,14 @@ function hideModal() { FIELDS = ['username', 'old_password', 'new_password'] -function mapFields(thunk) { - for (fieldIndex in FIELDS) { - const fieldName = FIELDS[fieldIndex] - thunk(document.querySelector(`input[name=${fieldName}]`)) - } +function fields() { + return FIELDS.map( + fieldName => document.querySelector(`input[name=${fieldName}]`) + ); } function clearFields() { - mapFields(field => { + fields().forEach(field => { field.value = ""; }); } @@ -83,7 +82,7 @@ function clearFields() { function changePasswords() { const query = {}; - mapFields(field => { + fields().forEach(field => { query[field.name] = field.value; });