Merge remote branch 'origin/master'

This commit is contained in:
Pootle server
2010-09-25 16:40:38 +02:00
6 changed files with 41 additions and 84 deletions

View File

@@ -20,6 +20,42 @@ var only_once_elements = new Array();
*/
var ajax_message_init = false;
/**
* Generate a new password and copy it to the password input areas
*
* @param object the form that holds the password fields
*
* @return boolean always true
*/
function suggestPassword(passwd_form) {
// restrict the password to just letters and numbers to avoid problems:
// "editors and viewers regard the password as multiple words and
// things like double click no longer work"
var pwchars = "abcdefhjmnpqrstuvwxyz23456789ABCDEFGHJKLMNPQRSTUVWYXZ";
var passwordlength = 16; // do we want that to be dynamic? no, keep it simple :)
var passwd = passwd_form.generated_pw;
passwd.value = '';
for ( i = 0; i < passwordlength; i++ ) {
passwd.value += pwchars.charAt( Math.floor( Math.random() * pwchars.length ) )
}
passwd_form.text_pma_pw.value = passwd.value;
passwd_form.text_pma_pw2.value = passwd.value;
return true;
}
/**
* for libraries/display_change_password.lib.php
* libraries/user_password.php
*
*/
function displayPasswordGenerateButton() {
$('#tr_element_before_generate_password').parent().append('<tr><td>' + PMA_messages['strGeneratePassword'] + '</td><td><input type="button" id="button_generate_password" value="' + PMA_messages['strGenerate'] + '" onclick="suggestPassword(this.form)" /><input type="text" name="generated_pw" id="generated_pw" /></td></tr>');
$('#div_element_before_generate_password').parent().append('<div class="item"><label for="button_generate_password">' + PMA_messages['strGeneratePassword'] + ':</label><span class="options"><input type="button" id="button_generate_password" value="' + PMA_messages['strGenerate'] + '" onclick="suggestPassword(this.form)" /></span><input type="text" name="generated_pw" id="generated_pw" /></div>');
}
/**
* selects the content of a given object, f.e. a textarea
*
@@ -2281,6 +2317,7 @@ $(document).ready(function() {
buttons : button_options
})
.append(data);
displayPasswordGenerateButton();
}) // end $.get()
}) // end handler for change password anchor

View File

@@ -4,51 +4,6 @@
*
*/
/**
* Ensures a value submitted in a form is numeric and is in a range
*
* @param object the form
* @param string the name of the form field to check
* @param integer the minimum authorized value
* @param integer the maximum authorized value
*
* @return boolean whether a valid number has been submitted or not
*/
function checkFormElementInRange(theForm, theFieldName, message, min, max)
{
var theField = theForm.elements[theFieldName];
var val = parseInt(theField.value);
if (typeof(min) == 'undefined') {
min = 0;
}
if (typeof(max) == 'undefined') {
max = Number.MAX_VALUE;
}
// It's not a number
if (isNaN(val)) {
theField.select();
alert(PMA_messages['strNotNumber']);
theField.focus();
return false;
}
// It's a number but it is not between min and max
else if (val < min || val > max) {
theField.select();
alert(message.replace('%d', val));
theField.focus();
return false;
}
// It's a valid number
else {
theField.value = val;
}
return true;
} // end of the 'checkFormElementInRange()' function
/**
* Ensures indexes names are valid according to their type and, for a primary
* key, lock index name to 'PRIMARY'

View File

@@ -1,10 +0,0 @@
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* for libraries/display_change_password.lib.php
*
*/
$(document).ready(function() {
$('#tr_element_before_generate_password').parent().append('<tr><td>' + PMA_messages['strGeneratePassword'] + '</td><td><input type="button" id="button_generate_password" value="' + PMA_messages['strGenerate'] + '" onclick="suggestPassword(this.form)" /><input type="text" name="generated_pw" id="generated_pw" /></td></tr>');
$('#div_element_before_generate_password').parent().append('<div class="item"><label for="button_generate_password">' + PMA_messages['strGeneratePassword'] + ':</label><span class="options"><input type="button" id="button_generate_password" value="' + PMA_messages['strGenerate'] + '" onclick="suggestPassword(this.form)" /></span><input type="text" name="generated_pw" id="generated_pw" /></div>');
});

View File

@@ -73,31 +73,6 @@ function checkAddUser(the_form)
return checkPassword(the_form);
} // end of the 'checkAddUser()' function
/**
* Generate a new password and copy it to the password input areas
*
* @param object the form that holds the password fields
*
* @return boolean always true
*/
function suggestPassword(passwd_form) {
// restrict the password to just letters and numbers to avoid problems:
// "editors and viewers regard the password as multiple words and
// things like double click no longer work"
var pwchars = "abcdefhjmnpqrstuvwxyz23456789ABCDEFGHJKLMNPQRSTUVWYXZ";
var passwordlength = 16; // do we want that to be dynamic? no, keep it simple :)
var passwd = passwd_form.generated_pw;
passwd.value = '';
for ( i = 0; i < passwordlength; i++ ) {
passwd.value += pwchars.charAt( Math.floor( Math.random() * pwchars.length ) )
}
passwd_form.text_pma_pw.value = passwd.value;
passwd_form.text_pma_pw2.value = passwd.value;
return true;
}
/**
* When a new user is created and retrieved over Ajax, append the user's row to
* the user's table
@@ -238,6 +213,7 @@ $(document).ready(function() {
modal: true,
buttons: button_options
}); //dialog options end
displayPasswordGenerateButton();
}); // end $.get()
});//end of Add New User AJAX event handler
@@ -339,7 +315,8 @@ $(document).ready(function() {
.dialog({
width: 900,
buttons: button_options
})
}); //dialog options end
displayPasswordGenerateButton();
}) // end $.get()
})

View File

@@ -17,7 +17,6 @@ $GLOBALS['js_include'][] = 'server_privileges.js';
$GLOBALS['js_include'][] = 'functions.js';
$GLOBALS['js_include'][] = 'jquery/jquery-ui-1.8.custom.js';
$GLOBALS['js_include'][] = 'password_generation.js';
require './libraries/server_common.inc.php';
/**

View File

@@ -35,7 +35,6 @@ if (! defined('PMA_NO_VARIABLES_IMPORT')) {
require_once './libraries/common.inc.php';
$GLOBALS['js_include'][] = 'server_privileges.js';
$GLOBALS['js_include'][] = 'password_generation.js';
/**
* Displays an error message and exits if the user isn't allowed to use this