diff --git a/js/replication.js b/js/replication.js
index c3e77e83f..1a7c785b0 100644
--- a/js/replication.js
+++ b/js/replication.js
@@ -3,30 +3,31 @@
* for server_replication.php
*
*/
-$(document).ready(function() {
- var conf_database_list = "";
- var random_server_id = Math.floor(Math.random() * 10000000);
- var conf_prefix = "server-id=" + random_server_id + "
log-bin=mysql-bin
log-error=mysql-bin.err
";
+
+var random_server_id = Math.floor(Math.random() * 10000000);
+var conf_prefix = "server-id=" + random_server_id + "
log-bin=mysql-bin
log-error=mysql-bin.err
";
+
+function update_config() {
var conf_ignore = "binlog_ignore_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);
- $('#db_type').change(function() {
- 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);
- });
- $('#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);
- });
+ $('#db_type').change(update_config);
+ $('#db_select').change(update_config);
$('#master_status_href').click(function() {
$('#replication_master_section').toggle();