diff options
| author | 2016-02-21 02:51:27 +0100 | |
|---|---|---|
| committer | 2016-02-21 02:51:27 +0100 | |
| commit | 64ec0708a1404e1f39a5fdc0131c89b2e4038bee (patch) | |
| tree | 712117769d5e82652aa3c6583c41a6ab41b8af66 /p/scripts/install.js | |
| parent | e3105f2135552701a4986873491a964b4e44c82e (diff) | |
More work for CSP, in particular install
Install needs testing.
https://github.com/FreshRSS/FreshRSS/issues/1075
Diffstat (limited to 'p/scripts/install.js')
| -rw-r--r-- | p/scripts/install.js | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/p/scripts/install.js b/p/scripts/install.js new file mode 100644 index 000000000..52d8bf8e0 --- /dev/null +++ b/p/scripts/install.js @@ -0,0 +1,76 @@ +"use strict"; + +function show_password() { + var button = this; + var passwordField = document.getElementById(button.getAttribute('data-toggle')); + passwordField.setAttribute('type', 'text'); + button.className += ' active'; + return false; +} +function hide_password() { + var button = this; + var passwordField = document.getElementById(button.getAttribute('data-toggle')); + passwordField.setAttribute('type', 'password'); + button.className = button.className.replace(/(?:^|\s)active(?!\S)/g , ''); + return false; +} +var toggles = document.getElementsByClassName('toggle-password'); +for (var i = 0 ; i < toggles.length ; i++) { + toggles[i].addEventListener('mousedown', show_password); + toggles[i].addEventListener('mouseup', hide_password); +} + +function auth_type_change() { + var auth_type = document.getElementById('auth_type'); + if (auth_type) { + var auth_value = auth_type.value, + password_input = document.getElementById('passwordPlain'), + mail_input = document.getElementById('mail_login'); + + if (auth_value === 'form') { + password_input.required = true; + mail_input.required = false; + } else if (auth_value === 'persona') { + password_input.required = false; + mail_input.required = true; + } else { + password_input.required = false; + mail_input.required = false; + } + } +} +var auth_type = document.getElementById('auth_type'); +if (auth_type) { + auth_type_change(); + auth_type_change.addEventListener('change', auth_type_change); +} + +function mySqlShowHide() { + var mysql = document.getElementById('mysql'); + if (mysql) { + mysql.style.display = document.getElementById('type').value === 'mysql' ? 'block' : 'none'; + if (document.getElementById('type').value !== 'mysql') { + document.getElementById('host').value = ''; + document.getElementById('user').value = ''; + document.getElementById('pass').value = ''; + document.getElementById('base').value = ''; + document.getElementById('prefix').value = ''; + } + } +} +var bd_type = document.getElementById('type'); +if (bd_type) { + mySqlShowHide(); + bd_type.addEventListener('change', mySqlShowHide); +} + +function ask_confirmation(e) { + var str_confirmation = this.getAttribute('data-str-confirm'); + if (!confirm(str_confirmation)) { + e.preventDefault(); + } +} +var confirms = document.getElementsByClassName('confirm'); +for (var i = 0 ; i < confirms.length ; i++) { + confirms[i].addEventListener('click', ask_confirmation); +} |
