Add support for "visible password" checkbox

- make redundant password and country optional in create account.
- fix appearance of form items
- remove unused code
This commit is contained in:
David Anderson 2018-01-08 00:35:53 -08:00
parent 1ac3828563
commit 5d37578ecc
5 changed files with 28 additions and 18 deletions

View File

@ -29,6 +29,25 @@ function make_login_token($user) {
return $token;
}
// return HTML string for a checkbox for toggling password visibility
//
function passwd_visible_checkbox($name) {
return sprintf('
<script>
function toggle_passwd() {
var x = document.getElementById("%s");
if (x.type === "password") {
x.type = "text";
} else {
x.type = "password";
}
}
</script>
<input type="checkbox" onclick="toggle_passwd()"><small> Show password</small>
', $name
);
}
function create_account_form($teamid, $next_url) {
global $recaptcha_public_key;
form_input_hidden('next_url', $next_url);

View File

@ -402,7 +402,7 @@ function form_checkboxes($label, $items) {
} else {
echo "<br>\n";
}
echo sprintf('<input type="checkbox" name="%s" %s> %s <br>
echo sprintf('<input type="checkbox" name="%s" %s> %s
',
$i[0], $i[2]?"checked":"", $i[1]
);

View File

@ -175,8 +175,8 @@ function validate_post_make_user() {
}
$passwd = post_str("passwd");
$passwd2 = post_str("passwd2");
if ($passwd != $passwd2) {
$passwd2 = post_str("passwd2", true);
if ($passwd2 && $passwd != $passwd2) {
show_error(tra("New passwords are different"));
}
@ -195,8 +195,8 @@ function validate_post_make_user() {
$passwd_hash = md5($passwd.$new_email_addr);
$country = post_str("country");
if ($country == "") {
$country = post_str("country", true);
if (!$country) {
$country = "None";
}
if (!is_valid_country($country)) {

View File

@ -864,19 +864,6 @@ function show_button_small($url, $text, $desc=null) {
echo button_text($url, $text, $desc, "btn-primary btn-xs");
}
// When multiple buttons (or actions) are presented in a list you can
// use this convenience method to avoid having to wrap each button in <li></li> elements
// @param url The destination URL of the button
// @param text The text to display on the button
// @param desc The title of the destination - typically used as a popup
// @param class The optional CSS class of the button. Defaults to a standard button
//
function show_actionlist_button($url, $text, $desc, $class="btn btn-default"){
echo "<li>";
echo show_button($url, $text, $desc, $class);
echo "</li>";
}
// used for showing icons
//
function show_image($src, $title, $alt, $height=null) {

View File

@ -16,3 +16,7 @@ blockquote {
color: white;
text-decoration: underline;
}
.form-horizontal .control-label {
padding-top: 0px;
}