From 64ec0708a1404e1f39a5fdc0131c89b2e4038bee Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Sun, 21 Feb 2016 02:51:27 +0100 Subject: More work for CSP, in particular install Install needs testing. https://github.com/FreshRSS/FreshRSS/issues/1075 --- p/scripts/install.js | 76 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 p/scripts/install.js (limited to 'p/scripts/install.js') 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); +} -- cgit v1.2.3 From 995cf58d249c6a2ddfd042cc5b509914295c882f Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Sun, 28 Feb 2016 00:08:57 +0100 Subject: CSP bug in install script https://github.com/FreshRSS/FreshRSS/issues/1075 --- app/install.php | 2 +- p/scripts/install.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'p/scripts/install.js') diff --git a/app/install.php b/app/install.php index a4a888af2..80e85354d 100644 --- a/app/install.php +++ b/app/install.php @@ -829,7 +829,6 @@ case 5: <?php echo _t('install.title'); ?> - @@ -877,5 +876,6 @@ case 5: ?> + diff --git a/p/scripts/install.js b/p/scripts/install.js index 52d8bf8e0..9a49e6031 100644 --- a/p/scripts/install.js +++ b/p/scripts/install.js @@ -42,7 +42,7 @@ function auth_type_change() { var auth_type = document.getElementById('auth_type'); if (auth_type) { auth_type_change(); - auth_type_change.addEventListener('change', auth_type_change); + auth_type.addEventListener('change', auth_type_change); } function mySqlShowHide() { -- cgit v1.2.3