summaryrefslogtreecommitdiffhomepage
path: root/themes/luci-theme-bootstrap/htdocs/luci-static/resources/view/bootstrap/sysauth.js
blob: fd936c9b1037a75356f65226a7e97864c0d6d390 (plain)
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
31
32
33
34
'use strict';
'require ui';
'require view';

return view.extend({
	render: function() {
		var form = document.querySelector('form'),
		    btn = document.querySelector('button');

		var dlg = ui.showModal(
			_('Authorization Required'),
			[].slice.call(document.querySelectorAll('section > *')),
			'login'
		);

		form.addEventListener('keypress', function(ev) {
			if (ev.key == 'Enter')
				btn.click();
		});

		btn.addEventListener('click', function() {
			dlg.querySelectorAll('*').forEach(function(node) { node.style.display = 'none' });
			dlg.appendChild(E('div', { 'class': 'spinning' }, _('Logging in…')));

			form.submit()
		});

		document.querySelector('input[type="password"]').focus();

		return '';
	},

	addFooter: function() {}
});