- added js:markAllRows(), js:unMarkAllRows()

- check/uncheck all rows now sets mark color for this rows
This commit is contained in:
Sebastian Mendel
2005-11-09 16:59:11 +00:00
parent 9a1a9e7237
commit 9fde856f09
6 changed files with 102 additions and 48 deletions

View File

@@ -23,6 +23,10 @@ $Source$
- db with only table specific rights where not displayed if there was not - db with only table specific rights where not displayed if there was not
at least one db with db specfic rights at least one db with db specfic rights
- javascript errors - javascript errors
* function.js, db_details_structure.php, tbl_properties_structure.php,
display_tbl.lib.php, server_databases.php:
- added js:markAllRows(), js:unMarkAllRows()
- check/uncheck all rows now sets mark color for this rows
2005-11-08 Sebastian Mendel <cybot_tm@users.sourceforge.net> 2005-11-08 Sebastian Mendel <cybot_tm@users.sourceforge.net>
* Documentation.html, browse_foreigners.php, error.php, * Documentation.html, browse_foreigners.php, error.php,

View File

@@ -134,7 +134,7 @@ if ( true == $cfg['PropertiesIconic'] ) {
* Displays the tables list * Displays the tables list
*/ */
?> ?>
<form method="post" action="db_details_structure.php" name="tablesForm"> <form method="post" action="db_details_structure.php" name="tablesForm" id="tablesForm">
<?php <?php
echo PMA_generate_common_hidden_inputs( $db ); echo PMA_generate_common_hidden_inputs( $db );
@@ -399,11 +399,11 @@ $checkall_url = 'db_details_structure.php?' . PMA_generate_common_url($db);
<img class="selectallarrow" src="<?php echo $pmaThemeImage .'arrow_'.$text_dir.'.png'; ?>" <img class="selectallarrow" src="<?php echo $pmaThemeImage .'arrow_'.$text_dir.'.png'; ?>"
width="38" height="22" alt="<?php echo $strWithChecked; ?>" /> width="38" height="22" alt="<?php echo $strWithChecked; ?>" />
<a href="<?php echo $checkall_url; ?>&amp;checkall=1" <a href="<?php echo $checkall_url; ?>&amp;checkall=1"
onclick="setCheckboxes('tablesForm', true); return false;"> onclick="if ( markAllRows('tablesForm') ) return false;">
<?php echo $strCheckAll; ?></a> <?php echo $strCheckAll; ?></a>
/ /
<a href="<?php echo $checkall_url; ?>" <a href="<?php echo $checkall_url; ?>"
onclick="setCheckboxes('tablesForm', false); return false;"> onclick="if ( unMarkAllRows('tablesForm') ) return false;">
<?php echo $strUncheckAll; ?></a> <?php echo $strUncheckAll; ?></a>
<?php if ($overhead_check != '') { ?> <?php if ($overhead_check != '') { ?>
/ /

View File

@@ -454,7 +454,7 @@ function PMA_displayTableHeaders(&$is_display, &$fields_meta, $fields_cnt = 0, $
global $db, $table, $goto, $dontlimitchars; global $db, $table, $goto, $dontlimitchars;
global $sql_query, $num_rows, $pos, $session_max_rows; global $sql_query, $num_rows, $pos, $session_max_rows;
global $vertical_display, $disp_direction, $repeat_cells, $highlight_columns; global $vertical_display, $disp_direction, $repeat_cells, $highlight_columns;
if ($analyzed_sql == '') { if ($analyzed_sql == '') {
$analyzed_sql = array(); $analyzed_sql = array();
} }
@@ -573,7 +573,7 @@ function PMA_displayTableHeaders(&$is_display, &$fields_meta, $fields_cnt = 0, $
// Start of form for multi-rows delete // Start of form for multi-rows delete
if ($is_display['del_lnk'] == 'dr' || $is_display['del_lnk'] == 'kp' ) { if ($is_display['del_lnk'] == 'dr' || $is_display['del_lnk'] == 'kp' ) {
echo '<form method="post" action="tbl_row_action.php" name="rowsDeleteForm">' . "\n"; echo '<form method="post" action="tbl_row_action.php" name="rowsDeleteForm" id="rowsDeleteForm">' . "\n";
echo PMA_generate_common_hidden_inputs($db, $table, 1); echo PMA_generate_common_hidden_inputs($db, $table, 1);
echo '<input type="hidden" name="disp_direction" value="' . $disp_direction . '" />' . "\n"; echo '<input type="hidden" name="disp_direction" value="' . $disp_direction . '" />' . "\n";
echo '<input type="hidden" name="repeat_cells" value="' . $repeat_cells . '" />' . "\n"; echo '<input type="hidden" name="repeat_cells" value="' . $repeat_cells . '" />' . "\n";
@@ -584,7 +584,7 @@ function PMA_displayTableHeaders(&$is_display, &$fields_meta, $fields_cnt = 0, $
} }
echo '<!-- Results table -->' . "\n" echo '<!-- Results table -->' . "\n"
. '<table id="table_results" '; . '<table id="table_results" class="data" ';
if (isset($GLOBALS['printview']) && $GLOBALS['printview'] == '1') { if (isset($GLOBALS['printview']) && $GLOBALS['printview'] == '1') {
echo 'border="1" cellpadding="2" cellspacing="0"'; echo 'border="1" cellpadding="2" cellspacing="0"';
} else { } else {
@@ -1066,7 +1066,7 @@ function PMA_displayTableBody(&$dt_result, &$is_display, $map, $analyzed_sql)
<?php <?php
echo "\n"; echo "\n";
} }
// 1. Prepares the row (gets primary keys to use) // 1. Prepares the row (gets primary keys to use)
// 1.1 Results from a "SELECT" statement -> builds the // 1.1 Results from a "SELECT" statement -> builds the
// "primary" key to use in links // "primary" key to use in links
@@ -1844,7 +1844,7 @@ function PMA_displayTable(&$dt_result, &$the_disp_mode, $analyzed_sql)
$delete_text = $is_display['del_lnk'] == 'dr' ? $GLOBALS['strDelete'] : $GLOBALS['strKill']; $delete_text = $is_display['del_lnk'] == 'dr' ? $GLOBALS['strDelete'] : $GLOBALS['strKill'];
$propicon = (string)$GLOBALS['cfg']['PropertiesIconic']; $propicon = (string)$GLOBALS['cfg']['PropertiesIconic'];
$uncheckall_url = 'sql.php?' $uncheckall_url = 'sql.php?'
. PMA_generate_common_url($db, $table) . PMA_generate_common_url($db, $table)
. '&amp;sql_query=' . urlencode($sql_query) . '&amp;sql_query=' . urlencode($sql_query)
@@ -1856,8 +1856,8 @@ function PMA_displayTable(&$dt_result, &$the_disp_mode, $analyzed_sql)
. '&amp;goto=' . $goto . '&amp;goto=' . $goto
. '&amp;dontlimitchars=' . $dontlimitchars; . '&amp;dontlimitchars=' . $dontlimitchars;
$checkall_url = $uncheckall_url . '&amp;checkall=1'; $checkall_url = $uncheckall_url . '&amp;checkall=1';
$checkall_params['onclick'] = 'setCheckboxesRange(\'rowsDeleteForm\', true, \'id_rows_to_delete\', 0, ' . $num_rows . '); return false;'; $checkall_params['onclick'] = 'if ( markAllRows(\'rowsDeleteForm\') ) return false;';
$uncheckall_params['onclick'] = 'setCheckboxesRange(\'rowsDeleteForm\', false, \'id_rows_to_delete\', 0, ' . $num_rows . '); return false;'; $uncheckall_params['onclick'] = 'if ( unMarkAllRows(\'rowsDeleteForm\') ) return false;';
$checkall_link = PMA_linkOrButton( $checkall_url, $GLOBALS['strCheckAll'], $checkall_params, false ); $checkall_link = PMA_linkOrButton( $checkall_url, $GLOBALS['strCheckAll'], $checkall_params, false );
$uncheckall_link = PMA_linkOrButton( $uncheckall_url, $GLOBALS['strUncheckAll'], $uncheckall_params, false ); $uncheckall_link = PMA_linkOrButton( $uncheckall_url, $GLOBALS['strUncheckAll'], $uncheckall_params, false );
?> ?>

View File

@@ -23,13 +23,13 @@ function selectContent( element, lock, only_once ) {
if ( only_once && only_once_elements[element.name] ) { if ( only_once && only_once_elements[element.name] ) {
return; return;
} }
only_once_elements[element.name] = true; only_once_elements[element.name] = true;
if ( lock ) { if ( lock ) {
return; return;
} }
element.select(); element.select();
} }
@@ -89,9 +89,9 @@ function confirmLink(theLink, theSqlQuery)
/** /**
* Displays an confirmation box before doing some action * Displays an confirmation box before doing some action
* *
* @param object the message to display * @param object the message to display
* *
* @return boolean whether to run the query or not * @return boolean whether to run the query or not
*/ */
@@ -254,7 +254,7 @@ function checkSqlQuery(theForm)
/** /**
* Check if a form's element is empty * Check if a form's element is empty
* should be * should be
* *
* @param object the form * @param object the form
@@ -379,7 +379,7 @@ function checkTableEditForm(theForm, fieldsCnt)
if (!emptyCheckTheField(theForm, id)) { if (!emptyCheckTheField(theForm, id)) {
atLeastOneField = 1; atLeastOneField = 1;
} }
} }
} }
if (atLeastOneField == 0) { if (atLeastOneField == 0) {
var theField = theForm.elements["field_0_1"]; var theField = theForm.elements["field_0_1"];
@@ -490,8 +490,8 @@ function PMA_markRowsInit() {
rows[i].onmousedown = function() { rows[i].onmousedown = function() {
var unique_id; var unique_id;
var checkbox; var checkbox;
var checkbox = this.getElementsByTagName( 'input' )[0]; checkbox = this.getElementsByTagName( 'input' )[0];
if ( checkbox && checkbox.type == 'checkbox' ) { if ( checkbox && checkbox.type == 'checkbox' ) {
unique_id = checkbox.name + checkbox.value; unique_id = checkbox.name + checkbox.value;
} else if ( this.id.length > 0 ) { } else if ( this.id.length > 0 ) {
@@ -499,24 +499,24 @@ function PMA_markRowsInit() {
} else { } else {
return; return;
} }
if ( typeof(marked_row[unique_id]) == 'undefined' || !marked_row[unique_id] ) { if ( typeof(marked_row[unique_id]) == 'undefined' || !marked_row[unique_id] ) {
marked_row[unique_id] = true; marked_row[unique_id] = true;
} else { } else {
marked_row[unique_id] = false; marked_row[unique_id] = false;
} }
if ( marked_row[unique_id] ) { if ( marked_row[unique_id] ) {
this.className += ' marked'; this.className += ' marked';
} else { } else {
this.className = this.className.replace(' marked', ''); this.className = this.className.replace(' marked', '');
} }
if ( checkbox && checkbox.disabled == false ) { if ( checkbox && checkbox.disabled == false ) {
checkbox.checked = marked_row[unique_id]; checkbox.checked = marked_row[unique_id];
} }
} }
// ... and disable label ... // ... and disable label ...
var labeltag = rows[i].getElementsByTagName('label')[0]; var labeltag = rows[i].getElementsByTagName('label')[0];
if ( labeltag ) { if ( labeltag ) {
@@ -536,6 +536,62 @@ function PMA_markRowsInit() {
} }
window.onload=PMA_markRowsInit; window.onload=PMA_markRowsInit;
/**
* marks all rows and selects its first checkbox inside the given element
* the given element is usaly a table or a div containing the table or tables
*
* @param container DOM element
*/
function markAllRows( container_id ) {
var rows = document.getElementById(container_id).getElementsByTagName('tr');
var unique_id;
var checkbox;
for ( var i = 0; i < rows.length; i++ ) {
checkbox = rows[i].getElementsByTagName( 'input' )[0];
if ( checkbox && checkbox.type == 'checkbox' ) {
unique_id = checkbox.name + checkbox.value;
if ( checkbox.disabled == false ) {
checkbox.checked = true;
if ( typeof(marked_row[unique_id]) == 'undefined' || !marked_row[unique_id] ) {
rows[i].className += ' marked';
marked_row[unique_id] = true;
}
}
}
}
return true;
}
/**
* marks all rows and selects its first checkbox inside the given element
* the given element is usaly a table or a div containing the table or tables
*
* @param container DOM element
*/
function unMarkAllRows( container_id ) {
var rows = document.getElementById(container_id).getElementsByTagName('tr');
var unique_id;
var checkbox;
for ( var i = 0; i < rows.length; i++ ) {
checkbox = rows[i].getElementsByTagName( 'input' )[0];
if ( checkbox && checkbox.type == 'checkbox' ) {
unique_id = checkbox.name + checkbox.value;
checkbox.checked = false;
rows[i].className = rows[i].className.replace(' marked', '');
marked_row[unique_id] = false;
}
}
return true;
}
/** /**
* Sets/unsets the pointer and marker in browse mode * Sets/unsets the pointer and marker in browse mode
* *
@@ -609,7 +665,7 @@ function setPointer(theRow, theRowNum, theAction, theDefaultColor, thePointerCol
currentColor += hexChars.charAt(v/16) + hexChars.charAt(v%16); currentColor += hexChars.charAt(v/16) + hexChars.charAt(v%16);
} }
} }
// 4. Defines the new color // 4. Defines the new color
// 4.1 Current color is the default one // 4.1 Current color is the default one
if (currentColor == '' if (currentColor == ''

View File

@@ -164,7 +164,7 @@ if ( count($databases) > 0 ) {
'footer' => 0, 'footer' => 0,
); );
echo '<form action="./server_databases.php" method="post" name="dbStatsForm">' . "\n" echo '<form action="./server_databases.php" method="post" name="dbStatsForm" id="dbStatsForm">' . "\n"
. PMA_generate_common_hidden_inputs('', '', 1) . PMA_generate_common_hidden_inputs('', '', 1)
. '<input type="hidden" name="dbstats" value="' . $dbstats . '" />' . "\n" . '<input type="hidden" name="dbstats" value="' . $dbstats . '" />' . "\n"
. '<input type="hidden" name="sort_by" value="' . $sort_by . '" />' . "\n" . '<input type="hidden" name="sort_by" value="' . $sort_by . '" />' . "\n"
@@ -292,26 +292,20 @@ if ( count($databases) > 0 ) {
echo ' <th>&nbsp;</th>' . "\n"; echo ' <th>&nbsp;</th>' . "\n";
} }
echo '</tr>' . "\n"; echo '</tr>' . "\n";
unset( $column_order, $stat_name, $stat, $databases ); echo '</tbody>' . "\n"
.'</table>' . "\n";
unset( $column_order, $stat_name, $stat, $databases, $table_columns );
if ($is_superuser || $cfg['AllowUserDropDatabase']) { if ($is_superuser || $cfg['AllowUserDropDatabase']) {
$common_url_query = PMA_generate_common_url() . '&amp;sort_by=' . $sort_by . '&amp;sort_order=' . $sort_order . '&amp;dbstats=' . $dbstats; $common_url_query = PMA_generate_common_url() . '&amp;sort_by=' . $sort_by . '&amp;sort_order=' . $sort_order . '&amp;dbstats=' . $dbstats;
echo '<tr><td colspan="' . $table_columns . '">' . "\n" echo '<img class="selectallarrow" src="' . $pmaThemeImage . 'arrow_' . $text_dir . '.png" width="38" height="22" alt="' . $strWithChecked . '" />' . "\n"
. ' <img class="icon" src="' . $pmaThemeImage . 'arrow_' . $text_dir . '.png" width="38" height="22" alt="' . $strWithChecked . '" />' . "\n" . '<a href="./server_databases.php?' . $common_url_query . '&amp;checkall=1" onclick="if ( markAllRows(\'tabledatabases\') ) return false;">' . "\n"
. ' <a href="./server_databases.php?' . $common_url_query . '&amp;checkall=1" onclick="setCheckboxes(\'dbStatsForm\', true); return false;">' . "\n" . ' ' . $strCheckAll . '</a> / ' . "\n"
. ' ' . $strCheckAll . '<a href="./server_databases.php?' . $common_url_query . '" onclick="if ( unMarkAllRows(\'tabledatabases\') ) return false;">' . "\n"
. ' </a> / ' . "\n" . ' ' . $strUncheckAll . '</a>' . "\n"
. ' <a href="./server_databases.php?' . $common_url_query . '" onclick="setCheckboxes(\'dbStatsForm\', false); return false;">' . "\n" . '<i>' . $strWithChecked . '</i>' . "\n";
. ' ' . $strUncheckAll
. ' </a>' . "\n"
. ' <i>' . $strWithChecked . '</i>' . "\n";
PMA_buttonOrImage( 'drop_selected_dbs', 'mult_submit', 'drop_selected_dbs', $strDrop, 'b_deltbl.png' ); PMA_buttonOrImage( 'drop_selected_dbs', 'mult_submit', 'drop_selected_dbs', $strDrop, 'b_deltbl.png' );
echo ' </td>' . "\n"
. '</tr>' . "\n";
} }
echo '</tbody>' . "\n"
.'</table>' . "\n";
unset( $table_columns );
if ( $GLOBALS['cfg']['PropertiesIconic'] ) { if ( $GLOBALS['cfg']['PropertiesIconic'] ) {
// iconic view // iconic view

View File

@@ -85,7 +85,7 @@ $fields_cnt = PMA_DBI_num_rows($fields_rs);
// the info given by SHOW FULL FIELDS FROM. // the info given by SHOW FULL FIELDS FROM.
// //
// We also need this to correctly learn if a TIMESTAMP is NOT NULL, since // We also need this to correctly learn if a TIMESTAMP is NOT NULL, since
// SHOW FULL FIELDS says NULL and SHOW CREATE TABLE says NOT NULL (tested // SHOW FULL FIELDS says NULL and SHOW CREATE TABLE says NOT NULL (tested
// in MySQL 4.0.25). // in MySQL 4.0.25).
$show_create_table = PMA_DBI_fetch_value( $show_create_table = PMA_DBI_fetch_value(
@@ -155,7 +155,7 @@ if ( $cfg['PropertiesIconic'] == true ) {
// table header // table header
$i = 0; $i = 0;
?> ?>
<form method="post" action="tbl_properties_structure.php" name="fieldsForm"> <form method="post" action="tbl_properties_structure.php" name="fieldsForm" id="fieldsForm">
<?php echo PMA_generate_common_hidden_inputs($db, $table); ?> <?php echo PMA_generate_common_hidden_inputs($db, $table); ?>
<table id="tablestructure" class="data"> <table id="tablestructure" class="data">
<thead> <thead>
@@ -220,7 +220,7 @@ while ($row = PMA_DBI_fetch_assoc($fields_rs)) {
// for the case ENUM('&#8211;','&ldquo;') // for the case ENUM('&#8211;','&ldquo;')
$type = htmlspecialchars($type); $type = htmlspecialchars($type);
$type_nowrap = ''; $type_nowrap = '';
$binary = 0; $binary = 0;
@@ -291,14 +291,14 @@ while ($row = PMA_DBI_fetch_assoc($fields_rs)) {
if ($zerofill) { if ($zerofill) {
$attribute = 'UNSIGNED ZEROFILL'; $attribute = 'UNSIGNED ZEROFILL';
} }
// MySQL 4.1.2+ TIMESTAMP options // MySQL 4.1.2+ TIMESTAMP options
// (if on_update_current_timestamp is set, then it's TRUE) // (if on_update_current_timestamp is set, then it's TRUE)
if (isset($analyzed_sql[0]['create_table_fields'][$row['Field']]['on_update_current_timestamp'])) { if (isset($analyzed_sql[0]['create_table_fields'][$row['Field']]['on_update_current_timestamp'])) {
$attribute = 'ON UPDATE CURRENT_TIMESTAMP'; $attribute = 'ON UPDATE CURRENT_TIMESTAMP';
} }
// here, we have a TIMESTAMP that SHOW FULL FIELDS reports as having the // here, we have a TIMESTAMP that SHOW FULL FIELDS reports as having the
// NULL attribute, but SHOW CREATE TABLE says the contrary. Believe // NULL attribute, but SHOW CREATE TABLE says the contrary. Believe
// the latter. // the latter.
if (!empty($analyzed_sql[0]['create_table_fields'][$row['Field']]['type']) && $analyzed_sql[0]['create_table_fields'][$row['Field']]['type'] == 'TIMESTAMP' && $analyzed_sql[0]['create_table_fields'][$row['Field']]['timestamp_not_null']) { if (!empty($analyzed_sql[0]['create_table_fields'][$row['Field']]['type']) && $analyzed_sql[0]['create_table_fields'][$row['Field']]['type'] == 'TIMESTAMP' && $analyzed_sql[0]['create_table_fields'][$row['Field']]['timestamp_not_null']) {
@@ -443,11 +443,11 @@ $checkall_url = 'tbl_properties_structure.php?' . PMA_generate_common_url($db,$t
<img class="selectallarrow" src="<?php echo $pmaThemeImage . 'arrow_' . $text_dir . '.png'; ?>" <img class="selectallarrow" src="<?php echo $pmaThemeImage . 'arrow_' . $text_dir . '.png'; ?>"
width="38" height="22" alt="<?php echo $strWithChecked; ?>" /> width="38" height="22" alt="<?php echo $strWithChecked; ?>" />
<a href="<?php echo $checkall_url; ?>&amp;checkall=1" <a href="<?php echo $checkall_url; ?>&amp;checkall=1"
onclick="setCheckboxes('fieldsForm', true); return false;"> onclick="if ( markAllRows('fieldsForm') ) return false;">
<?php echo $strCheckAll; ?></a> <?php echo $strCheckAll; ?></a>
/ /
<a href="<?php echo $checkall_url; ?>" <a href="<?php echo $checkall_url; ?>"
onclick="setCheckboxes('fieldsForm', false); return false;"> onclick="if ( unMarkAllRows('fieldsForm') ) return false;">
<?php echo $strUncheckAll; ?></a> <?php echo $strUncheckAll; ?></a>
<i><?php echo $strWithChecked; ?></i> <i><?php echo $strWithChecked; ?></i>