Allow to submit the password change form by pressing enter in the second input field. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
70 lines
2.4 KiB
HTML
70 lines
2.4 KiB
HTML
<%+header%>
|
||
|
||
<script type="application/javascript">//<![CDATA[
|
||
function submitPassword(ev) {
|
||
var pw1 = document.body.querySelector('[name="pw1"]'),
|
||
pw2 = document.body.querySelector('[name="pw2"]');
|
||
|
||
if (!pw1.value.length || !pw2.value.length)
|
||
return;
|
||
|
||
if (pw1.value === pw2.value) {
|
||
showModal('<%:Change login password%>',
|
||
E('p', { class: 'spinning' }, '<%:Changing password…%>'));
|
||
|
||
(new XHR()).post('<%=url("admin/system/admin/password/json")%>',
|
||
{ token: '<%=token%>', password: pw1.value },
|
||
function() {
|
||
showModal('<%:Change login password%>', [
|
||
E('div', _('The system password has been successfully changed.')),
|
||
E('div', { 'class': 'right' },
|
||
E('div', { class: 'btn', click: hideModal }, '<%:Dismiss%>'))
|
||
]);
|
||
|
||
pw1.value = pw2.value = '';
|
||
});
|
||
}
|
||
else {
|
||
showModal('<%:Change login password%>', [
|
||
E('div', { class: 'alert-message warning' },
|
||
_('Given password confirmation did not match, password not changed!')),
|
||
E('div', { 'class': 'right' },
|
||
E('div', { class: 'btn', click: hideModal }, '<%:Dismiss%>'))
|
||
]);
|
||
}
|
||
}
|
||
//]]></script>
|
||
|
||
<input type="password" aria-hidden="true" style="position:absolute; left:-10000px" />
|
||
|
||
<div class="cbi-map">
|
||
<h2><%:Router Password%></h2>
|
||
|
||
<div class="cbi-section-descr">
|
||
<%:Changes the administrator password for accessing the device%>
|
||
</div>
|
||
|
||
<div class="cbi-section-node">
|
||
<div class="cbi-value">
|
||
<label class="cbi-value-title" for="image"><%:Password%></label>
|
||
<div class="cbi-value-field">
|
||
<input type="password" name="pw1" /><!--
|
||
--><button class="cbi-button cbi-button-neutral" title="<%:Reveal/hide password%>" aria-label="<%:Reveal/hide password%>" onclick="var e = this.previousElementSibling; e.type = (e.type === 'password') ? 'text' : 'password'">∗</button>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="cbi-value">
|
||
<label class="cbi-value-title" for="image"><%:Confirmation%></label>
|
||
<div class="cbi-value-field">
|
||
<input type="password" name="pw2" onkeydown="if (event.keyCode === 13) submitPassword(event)" /><!--
|
||
--><button class="cbi-button cbi-button-neutral" title="<%:Reveal/hide password%>" aria-label="<%:Reveal/hide password%>" onclick="var e = this.previousElementSibling; e.type = (e.type === 'password') ? 'text' : 'password'">∗</button>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="cbi-page-actions">
|
||
<button class="btn cbi-button-apply" onclick="submitPassword(event)"><%:Save%></button>
|
||
</div>
|
||
|
||
<%+footer%>
|