Rewrite generating master configuration.
- Avoid code duplication. - Fix case when user unselected all databases.
This commit is contained in:
@@ -3,30 +3,31 @@
|
|||||||
* for server_replication.php
|
* for server_replication.php
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
$(document).ready(function() {
|
|
||||||
var conf_database_list = "";
|
var random_server_id = Math.floor(Math.random() * 10000000);
|
||||||
var random_server_id = Math.floor(Math.random() * 10000000);
|
var conf_prefix = "server-id=" + random_server_id + "<br />log-bin=mysql-bin<br />log-error=mysql-bin.err<br />";
|
||||||
var conf_prefix = "server-id=" + random_server_id + "<br />log-bin=mysql-bin<br />log-error=mysql-bin.err<br />";
|
|
||||||
|
function update_config() {
|
||||||
var conf_ignore = "binlog_ignore_db=";
|
var conf_ignore = "binlog_ignore_db=";
|
||||||
var conf_do = "binlog_do_db=";
|
var conf_do = "binlog_do_db=";
|
||||||
|
var database_list = $('#db_select option:selected:first').val();
|
||||||
|
$('#db_select option:selected:not(:first)').each(function() {
|
||||||
|
database_list += ',' + $(this).val();
|
||||||
|
});
|
||||||
|
|
||||||
|
if ($('#db_select option:selected').size() == 0) {
|
||||||
|
$('#rep').html(conf_prefix);
|
||||||
|
} else if ($('#db_type option:selected').val() == 'all') {
|
||||||
|
$('#rep').html(conf_prefix + conf_ignore + database_list);
|
||||||
|
} else {
|
||||||
|
$('#rep').html(conf_prefix + conf_do + database_list);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$(document).ready(function() {
|
||||||
$('#rep').html(conf_prefix);
|
$('#rep').html(conf_prefix);
|
||||||
$('#db_type').change(function() {
|
$('#db_type').change(update_config);
|
||||||
if ($('#db_type option:selected').val() == 'all')
|
$('#db_select').change(update_config);
|
||||||
$('#rep').html(conf_prefix + conf_ignore + conf_database_list);
|
|
||||||
else
|
|
||||||
$('#rep').html(conf_prefix + conf_do + conf_database_list);
|
|
||||||
});
|
|
||||||
$('#db_select').change(function() {
|
|
||||||
conf_database_list = $('#db_select option:selected:first').val();
|
|
||||||
$('#db_select option:selected:not(:first)').each(function() {
|
|
||||||
conf_database_list += ',' + $(this).val();
|
|
||||||
});
|
|
||||||
// todo: avoid repeating these 5 lines:
|
|
||||||
if ($('#db_type option:selected').val() == 'all')
|
|
||||||
$('#rep').html(conf_prefix + conf_ignore + conf_database_list);
|
|
||||||
else
|
|
||||||
$('#rep').html(conf_prefix + conf_do + conf_database_list);
|
|
||||||
});
|
|
||||||
|
|
||||||
$('#master_status_href').click(function() {
|
$('#master_status_href').click(function() {
|
||||||
$('#replication_master_section').toggle();
|
$('#replication_master_section').toggle();
|
||||||
|
Reference in New Issue
Block a user