start QA_2_11

This commit is contained in:
Marc Delisle
2007-07-18 15:54:09 +00:00
parent 6147b3565e
commit e2599e32c5
689 changed files with 0 additions and 212947 deletions

View File

@@ -1,121 +0,0 @@
/**************************************************
* dom-drag.js
* 09.25.2001
* www.youngpup.net
**************************************************
* 10.28.2001 - fixed minor bug where events
* sometimes fired off the handle, not the root.
**************************************************/
var Drag = {
obj : null,
init : function(o, oRoot, minX, maxX, minY, maxY, bSwapHorzRef, bSwapVertRef, fXMapper, fYMapper)
{
o.onmousedown = Drag.start;
o.hmode = bSwapHorzRef ? false : true ;
o.vmode = bSwapVertRef ? false : true ;
o.root = oRoot && oRoot != null ? oRoot : o ;
if (o.hmode && isNaN(parseInt(o.root.style.left ))) o.root.style.left = "0px";
if (o.vmode && isNaN(parseInt(o.root.style.top ))) o.root.style.top = "0px";
if (!o.hmode && isNaN(parseInt(o.root.style.right ))) o.root.style.right = "0px";
if (!o.vmode && isNaN(parseInt(o.root.style.bottom))) o.root.style.bottom = "0px";
o.minX = typeof minX != 'undefined' ? minX : null;
o.minY = typeof minY != 'undefined' ? minY : null;
o.maxX = typeof maxX != 'undefined' ? maxX : null;
o.maxY = typeof maxY != 'undefined' ? maxY : null;
o.xMapper = fXMapper ? fXMapper : null;
o.yMapper = fYMapper ? fYMapper : null;
o.root.onDragStart = new Function();
o.root.onDragEnd = new Function();
o.root.onDrag = new Function();
},
start : function(e)
{
var o = Drag.obj = this;
e = Drag.fixE(e);
var y = parseInt(o.vmode ? o.root.style.top : o.root.style.bottom);
var x = parseInt(o.hmode ? o.root.style.left : o.root.style.right );
o.root.onDragStart(x, y);
o.lastMouseX = e.clientX;
o.lastMouseY = e.clientY;
if (o.hmode) {
if (o.minX != null) o.minMouseX = e.clientX - x + o.minX;
if (o.maxX != null) o.maxMouseX = o.minMouseX + o.maxX - o.minX;
} else {
if (o.minX != null) o.maxMouseX = -o.minX + e.clientX + x;
if (o.maxX != null) o.minMouseX = -o.maxX + e.clientX + x;
}
if (o.vmode) {
if (o.minY != null) o.minMouseY = e.clientY - y + o.minY;
if (o.maxY != null) o.maxMouseY = o.minMouseY + o.maxY - o.minY;
} else {
if (o.minY != null) o.maxMouseY = -o.minY + e.clientY + y;
if (o.maxY != null) o.minMouseY = -o.maxY + e.clientY + y;
}
document.onmousemove = Drag.drag;
document.onmouseup = Drag.end;
return false;
},
drag : function(e)
{
e = Drag.fixE(e);
var o = Drag.obj;
var ey = e.clientY;
var ex = e.clientX;
var y = parseInt(o.vmode ? o.root.style.top : o.root.style.bottom);
var x = parseInt(o.hmode ? o.root.style.left : o.root.style.right );
var nx, ny;
if (o.minX != null) ex = o.hmode ? Math.max(ex, o.minMouseX) : Math.min(ex, o.maxMouseX);
if (o.maxX != null) ex = o.hmode ? Math.min(ex, o.maxMouseX) : Math.max(ex, o.minMouseX);
if (o.minY != null) ey = o.vmode ? Math.max(ey, o.minMouseY) : Math.min(ey, o.maxMouseY);
if (o.maxY != null) ey = o.vmode ? Math.min(ey, o.maxMouseY) : Math.max(ey, o.minMouseY);
nx = x + ((ex - o.lastMouseX) * (o.hmode ? 1 : -1));
ny = y + ((ey - o.lastMouseY) * (o.vmode ? 1 : -1));
if (o.xMapper) nx = o.xMapper(y)
else if (o.yMapper) ny = o.yMapper(x)
Drag.obj.root.style[o.hmode ? "left" : "right"] = nx + "px";
Drag.obj.root.style[o.vmode ? "top" : "bottom"] = ny + "px";
Drag.obj.lastMouseX = ex;
Drag.obj.lastMouseY = ey;
Drag.obj.root.onDrag(nx, ny);
return false;
},
end : function()
{
document.onmousemove = null;
document.onmouseup = null;
Drag.obj.root.onDragEnd( parseInt(Drag.obj.root.style[Drag.obj.hmode ? "left" : "right"]),
parseInt(Drag.obj.root.style[Drag.obj.vmode ? "top" : "bottom"]));
Drag.obj = null;
},
fixE : function(e)
{
if (typeof e == 'undefined') e = window.event;
if (typeof e.layerX == 'undefined') e.layerX = e.offsetX;
if (typeof e.layerY == 'undefined') e.layerY = e.offsetY;
return e;
}
};

File diff suppressed because it is too large Load Diff

View File

@@ -1,91 +0,0 @@
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* function used for index manipulation pages
*
* @version $Id$
*/
/**
* 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(errorMsg1);
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'
*
* @return boolean false if there is no index form, true else
*/
function checkIndexName()
{
if (typeof(document.forms['index_frm']) == 'undefined') {
return false;
}
// Gets the elements pointers
var the_idx_name = document.forms['index_frm'].elements['index'];
var the_idx_type = document.forms['index_frm'].elements['index_type'];
// Index is a primary key
if (the_idx_type.options[0].value == 'PRIMARY' && the_idx_type.options[0].selected) {
document.forms['index_frm'].elements['index'].value = 'PRIMARY';
if (typeof(the_idx_name.disabled) != 'undefined') {
document.forms['index_frm'].elements['index'].disabled = true;
}
}
// Other cases
else {
if (the_idx_name.value == 'PRIMARY') {
document.forms['index_frm'].elements['index'].value = '';
}
if (typeof(the_idx_name.disabled) != 'undefined') {
document.forms['index_frm'].elements['index'].disabled = false;
}
}
return true;
} // end of the 'checkIndexName()' function
onload = checkIndexName;

View File

@@ -1,59 +0,0 @@
/**
* Allows moving around inputs/select by Ctrl+arrows
*
* @param object event data
*/
function onKeyDownArrowsHandler(e) {
e = e||window.event;
var o = (e.srcElement||e.target);
if (!o) return;
if (o.tagName != "TEXTAREA" && o.tagName != "INPUT" && o.tagName != "SELECT") return;
if (navigator.userAgent.toLowerCase().indexOf('applewebkit/') != -1) {
if (e.ctrlKey || e.shiftKey || !e.altKey) return;
} else {
if (!e.ctrlKey || e.shiftKey || e.altKey) return;
}
if (!o.id) return;
var pos = o.id.split("_");
if (pos[0] != "field" || typeof pos[2] == "undefined") return;
var x = pos[2], y=pos[1];
// skip non existent fields
for (i=0; i<10; i++)
{
if (switch_movement) {
switch(e.keyCode) {
case 38: x--; break; // up
case 40: x++; break; // down
case 37: y--; break; // left
case 39: y++; break; // right
default: return;
}
} else {
switch(e.keyCode) {
case 38: y--; break; // up
case 40: y++; break; // down
case 37: x--; break; // left
case 39: x++; break; // right
default: return;
}
}
var id = "field_" + y + "_" + x;
var nO = document.getElementById(id);
if (!nO) {
var id = "field_" + y + "_" + x + "_0";
var nO = document.getElementById(id);
}
if (nO) break;
}
if (!nO) return;
nO.focus();
if (nO.tagName != 'SELECT') {
nO.select();
}
e.returnValue = false;
}

View File

@@ -1,137 +0,0 @@
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* function used in or for navigation frame
*/
/**
* init
*/
var today = new Date();
var expires = new Date(today.getTime() + (56 * 86400000));
var pma_navi_width;
var pma_saveframesize_timeout = null;
/**
* opens/closes (hides/shows) tree elements
*
* @param string id id of the element in the DOM
* @param boolean only_open do not close/hide element
*/
function toggle(id, only_open) {
var el = document.getElementById('subel' + id);
if (! el) {
return false;
}
var img = document.getElementById('el' + id + 'Img');
if (el.style.display == 'none' || only_open) {
el.style.display = '';
if (img) {
img.src = image_minus;
img.alt = '-';
}
} else {
el.style.display = 'none';
if (img) {
img.src = image_plus;
img.alt = '+';
}
}
return true;
}
function PMA_callFunctionDelayed(myfunction, delay)
{
if (typeof pma_saveframesize_timeout == "number") {
window.clearTimeout(pma_saveframesize_timeout);
pma_saveframesize_timeout = null;
}
}
/**
* saves current navigation frame width in a cookie
* usally called on resize of the navigation frame
*/
function PMA_saveFrameSizeReal()
{
pma_navi_width = document.getElementById('body_leftFrame').offsetWidth
//alert('from DOM: ' + typeof(pma_navi_width) + ' : ' + pma_navi_width);
if (pma_navi_width > 0) {
PMA_setCookie('pma_navi_width', pma_navi_width, expires);
//alert('framesize saved');
}
}
/**
* calls PMA_saveFrameSizeReal with delay
*/
function PMA_saveFrameSize()
{
//alert(typeof(pma_saveframesize_timeout) + ' : ' + pma_saveframesize_timeout);
if (typeof pma_saveframesize_timeout == "number") {
window.clearTimeout(pma_saveframesize_timeout);
pma_saveframesize_timeout = null;
}
pma_saveframesize_timeout = window.setTimeout(PMA_saveFrameSizeReal, 2000);
}
/**
* sets navigation frame width to the value stored in the cookie
* usally called on document load
*/
function PMA_setFrameSize()
{
pma_navi_width = PMA_getCookie('pma_navi_width');
//alert('from cookie: ' + typeof(pma_navi_width) + ' : ' + pma_navi_width);
if (pma_navi_width != null) {
if (parent.text_dir == 'ltr') {
parent.document.getElementById('mainFrameset').cols = pma_navi_width + ',*';
} else {
parent.document.getElementById('mainFrameset').cols = '*,' + pma_navi_width;
}
//alert('framesize set');
}
}
/**
* retrieves a named value from cookie
*
* @param string name name of the value to retrieve
* @return string value value for the given name from cookie
*/
function PMA_getCookie(name) {
var start = document.cookie.indexOf(name + "=");
var len = start + name.length + 1;
if ((!start) && (name != document.cookie.substring(0, name.length))) {
return null;
}
if (start == -1) {
return null;
}
var end = document.cookie.indexOf(";", len);
if (end == -1) {
end = document.cookie.length;
}
return unescape(document.cookie.substring(len,end));
}
/**
* stores a named value into cookie
*
* @param string name name of value
* @param string value value to be stored
* @param Date expires expire time
* @param string path
* @param string domain
* @param boolean secure
*/
function PMA_setCookie(name, value, expires, path, domain, secure) {
document.cookie = name + "=" + escape(value) +
( (expires) ? ";expires=" + expires.toGMTString() : "") +
( (path) ? ";path=" + path : "") +
( (domain) ? ";domain=" + domain : "") +
( (secure) ? ";secure" : "");
}

View File

@@ -1,370 +0,0 @@
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* functions used by and for querywindow
*
* @version $Id$
*/
/**
* holds the browser query window
*/
var querywindow = '';
/**
* holds the query to be load from a new query window
*/
var query_to_load = '';
/**
* sets current selected db
*
* @param string db name
*/
function setDb(new_db) {
//alert('setDb(' + new_db + ')');
if (new_db != db) {
// db has changed
//alert( new_db + '(' + new_db.length + ') : ' + db );
var old_db = db;
db = new_db;
if (window.frame_navigation.document.getElementById(db) == null) {
// db is unknown, reload complete left frame
refreshNavigation();
} else {
unmarkDbTable(old_db);
markDbTable(db);
}
// TODO: add code to expand db in lightview mode
// refresh querywindow
refreshQuerywindow();
}
}
/**
* sets current selected table (called from navigation.php)
*
* @param string table name
*/
function setTable(new_table) {
//alert('setTable(' + new_table + ')');
if (new_table != table) {
// table has changed
//alert( new_table + '(' + new_table.length + ') : ' + table );
table = new_table;
if (window.frame_navigation.document.getElementById(db + '.' + table) == null
&& table != '') {
// table is unknown, reload complete left frame
refreshNavigation();
}
// TODO: add code to expand table in lightview mode
// refresh querywindow
refreshQuerywindow();
}
}
/**
* reloads mian frame
*
* @uses goTo()
* @uses opendb_url
* @uses db
* @uses server
* @uses table
* @uses lang
* @uses collation_connection
* @uses encodeURIComponent()
* @param string url name of page to be loaded
*/
function refreshMain(url) {
if (! url) {
if (db) {
url = opendb_url;
} else {
url = 'main.php';
}
}
goTo(url + '?server=' + encodeURIComponent(server) +
'&db=' + encodeURIComponent(db) +
'&table=' + encodeURIComponent(table) +
'&lang=' + encodeURIComponent(lang) +
'&collation_connection=' + encodeURIComponent(collation_connection),
'main');
}
/**
* reloads navigation frame
*
* @uses goTo()
* @uses db
* @uses server
* @uses table
* @uses lang
* @uses collation_connection
* @uses encodeURIComponent()
*/
function refreshNavigation() {
goTo('navigation.php?server=' + encodeURIComponent(server) +
'&db=' + encodeURIComponent(db) +
'&table=' + encodeURIComponent(table) +
'&lang=' + encodeURIComponent(lang) +
'&collation_connection=' + encodeURIComponent(collation_connection)
);
}
/**
* adds class to element
*/
function addClass(element, classname)
{
if (element != null) {
element.className += ' ' + classname;
//alert('set class: ' + classname + ', now: ' + element.className);
}
}
/**
* removes class from element
*/
function removeClass(element, classname)
{
if (element != null) {
element.className = element.className.replace(' ' + classname, '');
// if there is no other class anem there is no leading space
element.className = element.className.replace(classname, '');
//alert('removed class: ' + classname + ', now: ' + element.className);
}
}
function unmarkDbTable(db, table)
{
var element_reference = window.frame_navigation.document.getElementById(db);
if (element_reference != null) {
//alert('remove from: ' + db);
removeClass(element_reference.parentNode, 'marked');
}
element_reference = window.frame_navigation.document.getElementById(db + '.' + table);
if (element_reference != null) {
//alert('remove from: ' + db + '.' + table);
removeClass(element_reference.parentNode, 'marked');
}
}
function markDbTable(db, table)
{
var element_reference = window.frame_navigation.document.getElementById(db);
if (element_reference != null) {
addClass(element_reference.parentNode, 'marked');
// scrolldown
element_reference.focus();
// opera marks the text, we dont want this ...
element_reference.blur();
}
element_reference = window.frame_navigation.document.getElementById(db + '.' + table);
if (element_reference != null) {
addClass(element_reference.parentNode, 'marked');
// scrolldown
element_reference.focus();
// opera marks the text, we dont want this ...
element_reference.blur();
}
// return to main frame ...
window.frame_content.focus();
}
/**
* sets current selected server, table and db (called from libraries/footer.inc.php)
*/
function setAll( new_lang, new_collation_connection, new_server, new_db, new_table ) {
//alert('setAll( ' + new_lang + ', ' + new_collation_connection + ', ' + new_server + ', ' + new_db + ', ' + new_table + ' )');
if (new_server != server || new_lang != lang
|| new_collation_connection != collation_connection) {
// something important has changed
server = new_server;
db = new_db;
table = new_table;
collation_connection = new_collation_connection;
lang = new_lang;
refreshNavigation();
} else if (new_db != db || new_table != table) {
// save new db and table
var old_db = db;
var old_table = table;
db = new_db;
table = new_table;
if (window.frame_navigation.document.getElementById(db) == null
&& window.frame_navigation.document.getElementById(db + '.' + table) == null ) {
// table or db is unknown, reload complete left frame
refreshNavigation();
} else {
unmarkDbTable(old_db, old_table);
markDbTable(db, table);
}
// TODO: add code to expand db in lightview mode
// refresh querywindow
refreshQuerywindow();
}
}
function reload_querywindow(db, table, sql_query)
{
if ( ! querywindow.closed && querywindow.location ) {
if ( ! querywindow.document.sqlform.LockFromUpdate
|| ! querywindow.document.sqlform.LockFromUpdate.checked ) {
querywindow.document.getElementById('hiddenqueryform').db.value = db;
querywindow.document.getElementById('hiddenqueryform').table.value = table;
if (sql_query) {
querywindow.document.getElementById('hiddenqueryform').sql_query.value = sql_query;
}
querywindow.document.getElementById('hiddenqueryform').submit();
}
}
}
/**
* brings query window to front and inserts query to be edited
*/
function focus_querywindow(sql_query)
{
/* if ( querywindow && !querywindow.closed && querywindow.location) { */
if ( !querywindow || querywindow.closed || !querywindow.location) {
// we need first to open the window and cannot pass the query with it
// as we dont know if the query exceeds max url length
/* url = 'querywindow.php?' + common_query + '&db=' + db + '&table=' + table + '&sql_query=SELECT * FROM'; */
query_to_load = sql_query;
open_querywindow();
insertQuery(0);
} else {
//var querywindow = querywindow;
if ( querywindow.document.getElementById('hiddenqueryform').querydisplay_tab != 'sql' ) {
querywindow.document.getElementById('hiddenqueryform').querydisplay_tab.value = "sql";
querywindow.document.getElementById('hiddenqueryform').sql_query.value = sql_query;
querywindow.document.getElementById('hiddenqueryform').submit();
querywindow.focus();
} else {
querywindow.focus();
}
}
return true;
}
/**
* inserts query string into query window textarea
* called from script tag in querywindow
*/
function insertQuery() {
if (query_to_load != '' && querywindow.document && querywindow.document.getElementById && querywindow.document.getElementById('sqlquery')) {
querywindow.document.getElementById('sqlquery').value = query_to_load;
query_to_load = '';
return true;
}
return false;
}
function open_querywindow( url ) {
if ( ! url ) {
url = 'querywindow.php?' + common_query + '&db=' + encodeURIComponent(db) + '&table=' + encodeURIComponent(table);
}
if (!querywindow.closed && querywindow.location) {
goTo( url, 'query' );
querywindow.focus();
} else {
querywindow = window.open( url + '&init=1', '',
'toolbar=0,location=0,directories=0,status=1,menubar=0,' +
'scrollbars=yes,resizable=yes,' +
'width=' + querywindow_width + ',' +
'height=' + querywindow_height );
}
if ( ! querywindow.opener ) {
querywindow.opener = window.window;
}
if ( window.focus ) {
querywindow.focus();
}
return true;
}
function refreshQuerywindow( url ) {
if ( ! querywindow.closed && querywindow.location ) {
if ( ! querywindow.document.sqlform.LockFromUpdate
|| ! querywindow.document.sqlform.LockFromUpdate.checked ) {
open_querywindow( url )
}
}
}
/**
* opens new url in target frame, with default beeing left frame
* valid is 'main' and 'querywindow' all others leads to 'left'
*
* @param string targeturl new url to load
* @param string target frame where to load the new url
*/
function goTo(targeturl, target) {
if ( target == 'main' ) {
target = window.frame_content;
} else if ( target == 'query' ) {
target = querywindow;
//return open_querywindow( targeturl );
} else if ( ! target ) {
target = window.frame_navigation;
}
if ( target ) {
if ( target.location.href == targeturl ) {
return true;
} else if ( target.location.href == pma_absolute_uri + targeturl ) {
return true;
}
if ( safari_browser ) {
target.location.href = targeturl;
} else {
target.location.replace(targeturl);
}
}
return true;
}
// opens selected db in main frame
function openDb(new_db) {
//alert('opendb(' + new_db + ')');
setDb(new_db);
setTable('');
refreshMain(opendb_url);
return true;
}
function updateTableTitle( table_link_id, new_title ) {
//alert('updateTableTitle');
if ( window.parent.frame_navigation.document.getElementById(table_link_id) ) {
var left = window.parent.frame_navigation.document;
left.getElementById(table_link_id).title = new_title;
new_title = left.getElementById('icon_' + table_link_id).alt + ': ' + new_title;
left.getElementById('browse_' + table_link_id).title = new_title;
return true;
}
return false;
}

View File

@@ -1,97 +0,0 @@
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* function used in server privilege pages
*
* @version $Id$
*/
/**
* 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)
{
// Did the user select 'no password'?
if (typeof(the_form.elements['nopass']) != 'undefined' && the_form.elements['nopass'][0].checked) {
return true;
} else if (typeof(the_form.elements['pred_password']) != 'undefined' && (the_form.elements['pred_password'].value == 'none' || the_form.elements['pred_password'].value == 'keep')) {
return true;
}
// Validates
if (the_form.elements['pma_pw'].value == '') {
alert(jsPasswordEmpty);
the_form.elements['pma_pw2'].value = '';
the_form.elements['pma_pw'].focus();
return false;
} else if (the_form.elements['pma_pw'].value != the_form.elements['pma_pw2'].value) {
alert(jsPasswordNotSame);
the_form.elements['pma_pw'].value = '';
the_form.elements['pma_pw2'].value = '';
the_form.elements['pma_pw'].focus();
return false;
} // end if...else if
return true;
} // end of the 'checkPassword()' function
/**
* Validates the "add a user" form
*
* @return boolean whether the form is validated or not
*/
function checkAddUser(the_form)
{
if (the_form.elements['pred_hostname'].value == 'userdefined' && the_form.elements['hostname'].value == '') {
alert(jsHostEmpty);
the_form.elements['hostname'].focus();
return false;
}
if (the_form.elements['pred_username'].value == 'userdefined' && the_form.elements['username'].value == '') {
alert(jsUserEmpty);
the_form.elements['username'].focus();
return false;
}
return checkPassword(the_form);
} // end of the 'checkAddUser()' function
/**
* Generate a new password, which may then be copied to the form
* with suggestPasswordCopy().
*
* @param string the form name
*
* @return boolean always true
*/
function suggestPassword() {
var pwchars = "abcdefhjmnpqrstuvwxyz23456789ABCDEFGHJKLMNPQRSTUVWYXZ.,:";
var passwordlength = 16; // do we want that to be dynamic? no, keep it simple :)
var passwd = document.getElementById('generated_pw');
passwd.value = '';
for ( i = 0; i < passwordlength; i++ ) {
passwd.value += pwchars.charAt( Math.floor( Math.random() * pwchars.length ) )
}
return passwd.value;
}
/**
* Copy the generated password (or anything in the field) to the form
*
* @param string the form name
*
* @return boolean always true
*/
function suggestPasswordCopy() {
document.getElementById('text_pma_pw').value = document.getElementById('generated_pw').value;
document.getElementById('text_pma_pw2').value = document.getElementById('generated_pw').value;
return true;
}

View File

@@ -1,345 +0,0 @@
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* function used in table data manipulation pages
*
* @version $Id$
*/
/**
* Modify from controls when the "NULL" checkbox is selected
*
* @param string the MySQL field type
* @param string the urlencoded field name
* @param string the md5 hashed field name
*
* @return boolean always true
*/
function nullify(theType, urlField, md5Field, multi_edit)
{
var rowForm = document.forms['insertForm'];
if (typeof(rowForm.elements['funcs' + multi_edit + '[' + urlField + ']']) != 'undefined') {
rowForm.elements['funcs' + multi_edit + '[' + urlField + ']'].selectedIndex = -1;
}
// "SET" field , "ENUM" field with more than 20 characters
// or foreign key field
if (theType == 1 || theType == 3 || theType == 4) {
rowForm.elements['field_' + md5Field + multi_edit + '[]'].selectedIndex = -1;
}
// Other "ENUM" field
else if (theType == 2) {
var elts = rowForm.elements['field_' + md5Field + multi_edit + '[]'];
// when there is just one option in ENUM:
if (elts.checked) {
elts.checked = false;
} else {
var elts_cnt = elts.length;
for (var i = 0; i < elts_cnt; i++ ) {
elts[i].checked = false;
} // end for
} // end if
}
// Other field types
else /*if (theType == 5)*/ {
rowForm.elements['fields' + multi_edit + '[' + urlField + ']'].value = '';
} // end if... else if... else
return true;
} // end of the 'nullify()' function
/**
* Unchecks the "NULL" control when a function has been selected or a value
* entered
*
* @param string the urlencoded field name
*
* @return boolean always true
*/
function unNullify(urlField, multi_edit)
{
var rowForm = document.forms['insertForm'];
if (typeof(rowForm.elements['fields_null[multi_edit][' + multi_edit + '][' + urlField + ']']) != 'undefined') {
rowForm.elements['fields_null[multi_edit][' + multi_edit + '][' + urlField + ']'].checked = false
} // end if
if (typeof(rowForm.elements['insert_ignore_' + multi_edit]) != 'undefined') {
rowForm.elements['insert_ignore_' + multi_edit].checked = false
} // end if
return true;
} // end of the 'unNullify()' function
var day;
var month;
var year;
var hour;
var minute;
var second;
var clock_set = 0;
/**
* Opens calendar window.
*
* @param string calendar.php parameters
* @param string form name
* @param string field name
* @param string edit type - date/timestamp
*/
function openCalendar(params, form, field, type) {
window.open("./calendar.php?" + params, "calendar", "width=400,height=200,status=yes");
dateField = eval("document." + form + "." + field);
dateType = type;
}
/**
* Formats number to two digits.
*
* @param int number to format.
* @param string type of number
*/
function formatNum2(i, valtype) {
f = (i < 10 ? '0' : '') + i;
if (valtype && valtype != '') {
switch(valtype) {
case 'month':
f = (f > 12 ? 12 : f);
break;
case 'day':
f = (f > 31 ? 31 : f);
break;
case 'hour':
f = (f > 24 ? 24 : f);
break;
default:
case 'second':
case 'minute':
f = (f > 59 ? 59 : f);
break;
}
}
return f;
}
/**
* Formats number to two digits.
*
* @param int number to format.
* @param int default value
* @param string type of number
*/
function formatNum2d(i, default_v, valtype) {
i = parseInt(i, 10);
if (isNaN(i)) return default_v;
return formatNum2(i, valtype)
}
/**
* Formats number to four digits.
*
* @param int number to format.
*/
function formatNum4(i) {
i = parseInt(i, 10)
return (i < 1000 ? i < 100 ? i < 10 ? '000' : '00' : '0' : '') + i;
}
/**
* Initializes calendar window.
*/
function initCalendar() {
if (!year && !month && !day) {
/* Called for first time */
if (window.opener.dateField.value) {
value = window.opener.dateField.value;
if (window.opener.dateType == 'datetime' || window.opener.dateType == 'date') {
if (window.opener.dateType == 'datetime') {
parts = value.split(' ');
value = parts[0];
if (parts[1]) {
time = parts[1].split(':');
hour = parseInt(time[0],10);
minute = parseInt(time[1],10);
second = parseInt(time[2],10);
}
}
date = value.split("-");
day = parseInt(date[2],10);
month = parseInt(date[1],10) - 1;
year = parseInt(date[0],10);
} else {
year = parseInt(value.substr(0,4),10);
month = parseInt(value.substr(4,2),10) - 1;
day = parseInt(value.substr(6,2),10);
hour = parseInt(value.substr(8,2),10);
minute = parseInt(value.substr(10,2),10);
second = parseInt(value.substr(12,2),10);
}
}
if (isNaN(year) || isNaN(month) || isNaN(day) || day == 0) {
dt = new Date();
year = dt.getFullYear();
month = dt.getMonth();
day = dt.getDate();
}
if (isNaN(hour) || isNaN(minute) || isNaN(second)) {
dt = new Date();
hour = dt.getHours();
minute = dt.getMinutes();
second = dt.getSeconds();
}
} else {
/* Moving in calendar */
if (month > 11) {
month = 0;
year++;
}
if (month < 0) {
month = 11;
year--;
}
}
if (document.getElementById) {
cnt = document.getElementById("calendar_data");
} else if (document.all) {
cnt = document.all["calendar_data"];
}
cnt.innerHTML = "";
str = ""
//heading table
str += '<table class="calendar"><tr><th width="50%">';
str += '<form method="NONE" onsubmit="return 0">';
str += '<a href="javascript:month--; initCalendar();">&laquo;</a> ';
str += '<select id="select_month" name="monthsel" onchange="month = parseInt(document.getElementById(\'select_month\').value); initCalendar();">';
for (i =0; i < 12; i++) {
if (i == month) selected = ' selected="selected"';
else selected = '';
str += '<option value="' + i + '" ' + selected + '>' + month_names[i] + '</option>';
}
str += '</select>';
str += ' <a href="javascript:month++; initCalendar();">&raquo;</a>';
str += '</form>';
str += '</th><th width="50%">';
str += '<form method="NONE" onsubmit="return 0">';
str += '<a href="javascript:year--; initCalendar();">&laquo;</a> ';
str += '<select id="select_year" name="yearsel" onchange="year = parseInt(document.getElementById(\'select_year\').value); initCalendar();">';
for (i = year - 25; i < year + 25; i++) {
if (i == year) selected = ' selected="selected"';
else selected = '';
str += '<option value="' + i + '" ' + selected + '>' + i + '</option>';
}
str += '</select>';
str += ' <a href="javascript:year++; initCalendar();">&raquo;</a>';
str += '</form>';
str += '</th></tr></table>';
str += '<table class="calendar"><tr>';
for (i = 0; i < 7; i++) {
str += "<th>" + day_names[i] + "</th>";
}
str += "</tr>";
var firstDay = new Date(year, month, 1).getDay();
var lastDay = new Date(year, month + 1, 0).getDate();
str += "<tr>";
dayInWeek = 0;
for (i = 0; i < firstDay; i++) {
str += "<td>&nbsp;</td>";
dayInWeek++;
}
for (i = 1; i <= lastDay; i++) {
if (dayInWeek == 7) {
str += "</tr><tr>";
dayInWeek = 0;
}
dispmonth = 1 + month;
if (window.opener.dateType == 'datetime' || window.opener.dateType == 'date') {
actVal = "" + formatNum4(year) + "-" + formatNum2(dispmonth, 'month') + "-" + formatNum2(i, 'day');
} else {
actVal = "" + formatNum4(year) + formatNum2(dispmonth, 'month') + formatNum2(i, 'day');
}
if (i == day) {
style = ' class="selected"';
current_date = actVal;
} else {
style = '';
}
str += "<td" + style + "><a href=\"javascript:returnDate('" + actVal + "');\">" + i + "</a></td>"
dayInWeek++;
}
for (i = dayInWeek; i < 7; i++) {
str += "<td>&nbsp;</td>";
}
str += "</tr></table>";
cnt.innerHTML = str;
// Should we handle time also?
if (window.opener.dateType != 'date' && !clock_set) {
if (document.getElementById) {
cnt = document.getElementById("clock_data");
} else if (document.all) {
cnt = document.all["clock_data"];
}
str = '';
init_hour = hour;
init_minute = minute;
init_second = second;
str += '<fieldset>';
str += '<form method="NONE" class="clock" onsubmit="returnDate(\'' + current_date + '\')">';
str += '<input id="hour" type="text" size="2" maxlength="2" onblur="this.value=formatNum2d(this.value, init_hour, \'hour\'); init_hour = this.value;" value="' + formatNum2(hour, 'hour') + '" />:';
str += '<input id="minute" type="text" size="2" maxlength="2" onblur="this.value=formatNum2d(this.value, init_minute, \'minute\'); init_minute = this.value;" value="' + formatNum2(minute, 'minute') + '" />:';
str += '<input id="second" type="text" size="2" maxlength="2" onblur="this.value=formatNum2d(this.value, init_second, \'second\'); init_second = this.value;" value="' + formatNum2(second, 'second') + '" />';
str += '&nbsp;&nbsp;';
str += '<input type="submit" value="' + submit_text + '"/>';
str += '</form>';
str += '</fieldset>';
cnt.innerHTML = str;
clock_set = 1;
}
}
/**
* Returns date from calendar.
*
* @param string date text
*/
function returnDate(d) {
txt = d;
if (window.opener.dateType != 'date') {
// need to get time
h = parseInt(document.getElementById('hour').value,10);
m = parseInt(document.getElementById('minute').value,10);
s = parseInt(document.getElementById('second').value,10);
if (window.opener.dateType == 'datetime') {
txt += ' ' + formatNum2(h, 'hour') + ':' + formatNum2(m, 'minute') + ':' + formatNum2(s, 'second');
} else {
// timestamp
txt += formatNum2(h, 'hour') + formatNum2(m, 'minute') + formatNum2(s, 'second');
}
}
window.opener.dateField.value = txt;
window.close();
}

View File

@@ -1,197 +0,0 @@
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* Displays the Tooltips (hints), if we have some
* 2005-01-20 added by Michael Keck (mkkeck)
*
* @version $Id$
*/
/**
*
*/
var ttXpos = 0, ttYpos = 0;
var ttXadd = 10, ttYadd = -10;
var ttDisplay = 0, ttHoldIt = 0;
// Check if browser does support dynamic content and dhtml
var ttNS4 = (document.layers) ? 1 : 0; // the old Netscape 4
var ttIE4 = (document.all) ? 1 : 0; // browser wich uses document.all
var ttDOM = (document.getElementById) ? 1 : 0; // DOM-compatible browsers
if (ttDOM) { // if DOM-compatible, set the others to false
ttNS4 = 0;
ttIE4 = 0;
}
var myTooltipContainer = null;
if ( (ttDOM) || (ttIE4) || (ttNS4) ) {
// mouse-event
if ( ttNS4 ) {
document.captureEvents(Event.MOUSEMOVE);
} else {
document.onmousemove = mouseMove;
}
}
/**
* init the tooltip and write the text into it
*
* @param string theText tooltip content
*/
function textTooltip(theText) {
if (ttDOM || ttIE4) { // document.getEelementById || document.all
myTooltipContainer.innerHTML = ""; // we should empty it first
myTooltipContainer.innerHTML = theText;
} else if (ttNS4) { // document.layers
var layerNS4 = myTooltipContainer.document;
layerNS4.write(theText);
layerNS4.close();
}
}
/**
* @var integer
*/
var ttTimerID = 0;
/**
* swap the Tooltip // show and hide
*
* @param boolean stat view status
*/
function swapTooltip(stat) {
if (ttHoldIt!=1) {
if (stat!='default') {
if (stat=='true')
showTooltip(true);
else if (stat=='false')
showTooltip(false);
} else {
if (ttDisplay)
ttTimerID = setTimeout("showTooltip(false);",500);
else
showTooltip(true);
}
} else {
if (ttTimerID) {
clearTimeout(ttTimerID);
ttTimerID = 0;
}
showTooltip(true);
}
}
/**
* show / hide the Tooltip
*
* @param boolean stat view status
*/
function showTooltip(stat) {
if (stat==false) {
if (ttNS4)
myTooltipContainer.visibility = "hide";
else
myTooltipContainer.style.visibility = "hidden";
ttDisplay = 0;
} else {
if (ttNS4)
myTooltipContainer.visibility = "show";
else
myTooltipContainer.style.visibility = "visible";
ttDisplay = 1;
}
}
/**
* hold it, if we create or move the mouse over the tooltip
*/
function holdTooltip() {
ttHoldIt = 1;
swapTooltip('true');
ttHoldIt = 0;
}
/**
* move the tooltip to mouse position
*
* @param integer posX horiz. position
* @param integer posY vert. position
*/
function moveTooltip(posX, posY) {
if (ttDOM || ttIE4) {
myTooltipContainer.style.left = posX + "px";
myTooltipContainer.style.top = posY + "px";
} else if (ttNS4) {
myTooltipContainer.left = posX;
myTooltipContainer.top = posY;
}
}
/**
* build the tooltip
*
* @param string theText tooltip content
*/
function pmaTooltip( theText ) {
// reference to TooltipContainer
if ( null == myTooltipContainer ) {
if (ttNS4) {
myTooltipContainer = document.TooltipContainer;
} else if (ttIE4) {
myTooltipContainer = document.all('TooltipContainer');
} else if (ttDOM) {
myTooltipContainer = document.getElementById('TooltipContainer');
} else {
return;
}
if ( typeof( myTooltipContainer ) == 'undefined' ) {
return;
}
}
var plusX=0, plusY=0, docX=0, docY=0;
var divHeight = myTooltipContainer.clientHeight;
var divWidth = myTooltipContainer.clientWidth;
if (navigator.appName.indexOf("Explorer")!=-1) {
if (document.documentElement && document.documentElement.scrollTop) {
plusX = document.documentElement.scrollLeft;
plusY = document.documentElement.scrollTop;
docX = document.documentElement.offsetWidth + plusX;
docY = document.documentElement.offsetHeight + plusY;
} else {
plusX = document.body.scrollLeft;
plusY = document.body.scrollTop;
docX = document.body.offsetWidth + plusX;
docY = document.body.offsetHeight + plusY;
}
} else {
docX = document.body.clientWidth;
docY = document.body.clientHeight;
}
ttXpos = ttXpos + plusX;
ttYpos = ttYpos + plusY;
if ((ttXpos + divWidth) > docX)
ttXpos = ttXpos - (divWidth + (ttXadd * 2));
if ((ttYpos + divHeight) > docY)
ttYpos = ttYpos - (divHeight + (ttYadd * 2));
textTooltip(theText);
moveTooltip((ttXpos + ttXadd), (ttYpos + ttYadd));
holdTooltip();
}
/**
* register mouse moves
*
* @param event e
*/
function mouseMove(e) {
if ( typeof( event ) != 'undefined' ) {
ttXpos = event.x;
ttYpos = event.y;
} else {
ttXpos = e.pageX;
ttYpos = e.pageY;
}
}

View File

@@ -1,196 +0,0 @@
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* function used for password change form
*
* @version $Id$
*/
/**
* 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