Files
@ 3be168914a12
Branch filter:
Location: DistRen/htdocs/sql/js/user_password.js - annotation
3be168914a12
5.7 KiB
text/javascript
Added web interface fileshg commit -h
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 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 | 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 3be168914a12 | /* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* function used for password change form
*
* @version $Id: user_password.js 10142 2007-03-20 10:32:13Z cybot_tm $
*/
/**
* Validates the password field in a form
*
* @param object the form
*
* @return boolean whether the field value is valid or not
*/
function checkPassword(the_form)
{
// Gets the elements pointers
if (the_form.name == 'addUserForm' || the_form.name == 'chgPassword') {
var pswd_index = 1;
var pswd1_name = 'pma_pw';
var pswd2_name = 'pma_pw2';
} else {
pswd_index = 2;
pswd1_name = 'new_pw';
pswd2_name = 'new_pw2';
}
// Validates
if (the_form.elements['nopass'][pswd_index].checked) {
if (the_form.elements[pswd1_name].value == '') {
alert(jsPasswordEmpty);
the_form.elements[pswd2_name].value = '';
the_form.elements[pswd1_name].focus();
return false;
} else if (the_form.elements[pswd1_name].value != the_form.elements[pswd2_name].value) {
alert(jsPasswordNotSame);
the_form.elements[pswd1_name].value = '';
the_form.elements[pswd2_name].value = '';
the_form.elements[pswd1_name].focus();
return false;
} // end if...else if
} // end if
return true;
} // end of the 'checkPassword()' function
/**
* Validates the "add an user" form
*
* @return boolean whether the form is validated or not
*/
function checkAddUser()
{
var the_form = document.forms['addUserForm'];
if (the_form.elements['anyhost'][1].checked && the_form.elements['host'].value == '') {
alert(jsHostEmpty);
the_form.elements['host'].focus();
return false;
}
if (the_form.elements['anyuser'][1].checked && the_form.elements['pma_user'].value == '') {
alert(jsUserEmpty);
the_form.elements['pma_user'].focus();
return false;
}
return checkPassword(the_form);
} // end of the 'checkAddUser()' function
/**
* Validates the "update a profile" form
*
* @return boolean whether the form is validated or not
*/
function checkUpdProfile()
{
var the_form = document.forms['updUserForm'];
if (the_form.elements['anyhost'][1].checked && the_form.elements['new_server'].value == '') {
alert(jsHostEmpty);
the_form.elements['new_server'].focus();
return false;
}
if (the_form.elements['anyuser'][1].checked && the_form.elements['new_user'].value == '') {
alert(jsUserEmpty);
the_form.elements['new_user'].focus();
return false;
}
return checkPassword(the_form);
} // end of the 'checkUpdProfile()' function
/**
* Gets the list of selected options in combo
*
* @param object the form to check
*
* @return string the list of selected options
*/
function getSelected(the_field) {
var the_list = '';
var opts = the_field.options;
var opts_cnt = opts.length;
for (var i = 0; i < opts_cnt; i++) {
if (opts[i].selected) {
the_list += opts[i].text + ', ';
}
} // end for
return the_list.substring(0, the_list.length - 2);
} // end of the 'getSelected()' function
/**
* Reloads the page to get tables names in a database or fields names in a
* table
*
* @param object the input text box to build the query from
*/
function change(the_field) {
var l = location.href;
var lpos = l.indexOf('?lang');
var box_name = the_field.name;
var the_form = the_field.form.elements;
var sel_idx = null;
if (box_name == 'newdb') {
the_form['anydb'][0].checked = true;
the_form['anytable'][0].checked = true;
the_form['anycolumn'][0].checked = true;
if (typeof(the_form['dbgrant']) != 'undefined') {
the_form['dbgrant'].selectedIndex = -1;
}
if (typeof(the_form['tablegrant']) != 'undefined') {
the_form['tablegrant'].selectedIndex = -1;
}
if (typeof(the_form['colgrant']) != 'undefined') {
the_form['colgrant'].selectedIndex = -1;
}
}
else {
if (lpos <= 0) {
l += '?lang=' + the_form['lang'].value
+ '&convcharset=' . the_form['convcharset'].value
+ '&server=' + the_form['server'].value
+ '&grants=1'
+ '&host=' + escape(the_form['host'].value)
+ '&pma_user=' + escape(the_form['pma_user'].value);
sel_idx = the_form['dbgrant'].selectedIndex;
if (sel_idx > 0) {
l += '&dbgrant=' + escape(the_form['dbgrant'].options[sel_idx].text);
}
sel_idx = the_form['tablegrant'].selectedIndex;
if (sel_idx > 0) {
l += '&tablegrant=' + escape(the_form['tablegrant'].options[sel_idx].text);
}
}
var lpos = l.indexOf('&' + box_name);
if (lpos > 0) {
l = l.substring(0, lpos);
} // end if
location.href = l + '&' + box_name + '=' + escape(getSelected(the_field));
}
} // end of the 'change()' function
/**
* Checks/unchecks all privileges
*
* @param string the form name
* @param boolean whether to check or to uncheck the element
*
* @return boolean always true
*/
function checkForm(the_form, do_check) {
var elts = document.forms[the_form].elements;
var elts_cnt = elts.length;
for (var i = 0; i < elts_cnt; i++) {
var whichElt = elts[i].name;
if (whichElt.indexOf('_priv') >= 0) {
document.forms[the_form].elements[whichElt].checked = do_check;
} // end if
} // end for
return true;
} // end of the 'checkForm()' function
|