1 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 * for server_replication.php
7 var random_server_id = Math.floor(Math.random() * 10000000);
8 var conf_prefix = 'server-id=' + random_server_id + '\nlog_bin=mysql-bin\nlog_error=mysql-bin.err\n';
10 function update_config () {
11 var conf_ignore = 'binlog_ignore_db=';
12 var conf_do = 'binlog_do_db=';
13 var database_list = '';
15 if ($('#db_select option:selected').size() === 0) {
16 $('#rep').text(conf_prefix);
17 } else if ($('#db_type option:selected').val() === 'all') {
18 $('#db_select option:selected').each(function () {
19 database_list += conf_ignore + $(this).val() + '\n';
21 $('#rep').text(conf_prefix + database_list);
23 $('#db_select option:selected').each(function () {
24 database_list += conf_do + $(this).val() + '\n';
26 $('#rep').text(conf_prefix + database_list);
31 * Unbind all event handlers before tearing down a page
33 AJAX.registerTeardown('replication.js', function () {
34 $('#db_type').off('change');
35 $('#db_select').off('change');
36 $('#master_status_href').off('click');
37 $('#master_slaves_href').off('click');
38 $('#slave_status_href').off('click');
39 $('#slave_control_href').off('click');
40 $('#slave_errormanagement_href').off('click');
41 $('#slave_synchronization_href').off('click');
42 $('#db_reset_href').off('click');
43 $('#db_select_href').off('click');
44 $('#reset_slave').off('click');
47 AJAX.registerOnload('replication.js', function () {
48 $('#rep').text(conf_prefix);
49 $('#db_type').change(update_config);
50 $('#db_select').change(update_config);
52 $('#master_status_href').click(function () {
53 $('#replication_master_section').toggle();
55 $('#master_slaves_href').click(function () {
56 $('#replication_slaves_section').toggle();
58 $('#slave_status_href').click(function () {
59 $('#replication_slave_section').toggle();
61 $('#slave_control_href').click(function () {
62 $('#slave_control_gui').toggle();
64 $('#slave_errormanagement_href').click(function () {
65 $('#slave_errormanagement_gui').toggle();
67 $('#slave_synchronization_href').click(function () {
68 $('#slave_synchronization_gui').toggle();
70 $('#db_reset_href').click(function () {
71 $('#db_select option:selected').prop('selected', false);
72 $('#db_select').trigger('change');
74 $('#db_select_href').click(function () {
75 $('#db_select option').prop('selected', true);
76 $('#db_select').trigger('change');
78 $('#reset_slave').click(function (e) {
80 var $anchor = $(this);
81 var question = PMA_messages.strResetSlaveWarning;
82 $anchor.PMA_confirm(question, $anchor.attr('href'), function (url) {
83 PMA_ajaxShowMessage();
84 AJAX.source = $anchor;
85 var params = getJSConfirmCommonParam({
86 'ajax_page_request': true,
88 }, $anchor.getPostData());
89 $.post(url, params, AJAX.responseHandler);