1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
|
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* @fileoverview function used in server privilege pages
* @name Database Operations
*
* @requires jQuery
* @requires jQueryUI
* @requires js/functions.js
*
*/
/**
* Ajax event handlers here for db_operations.php
*
* Actions Ajaxified here:
* Rename Database
* Copy Database
* Change charset
*/
$(function() {
/**
* Ajax event handlers for 'Rename Database'
*
* @see $cfg['AjaxEnable']
*/
$("#rename_db_form.ajax").live('submit', function(event) {
event.preventDefault();
var $form = $(this);
var question = escapeHtml('CREATE DATABASE ' + $('#new_db_name').val() + ' / DROP DATABASE ' + window.parent.db);
PMA_prepareForAjaxRequest($form);
/**
* @var button_options Object containing options for jQueryUI dialog buttons
*/
var button_options = {};
button_options[PMA_messages['strYes']] = function() {
$(this).dialog("close").remove();
window.parent.refreshMain();
window.parent.refreshNavigation();
};
button_options[PMA_messages['strNo']] = function() { $(this).dialog("close").remove(); }
$form.PMA_confirm(question, $form.attr('action'), function(url) {
PMA_ajaxShowMessage(PMA_messages['strRenamingDatabases']);
$.get(url, $("#rename_db_form").serialize() + '&is_js_confirmed=1', function(data) {
if(data.success == true) {
PMA_ajaxShowMessage(data.message);
window.parent.db = data.newname;
$("#floating_menubar")
.next('div')
.remove()
.end()
.after(data.sql_query);
//Remove the empty notice div generated due to a NULL query passed to CommonFunctions::getMessage()
var $notice_class = $("#floating_menubar").next("div").find('.notice');
if ($notice_class.text() == '') {
$notice_class.remove();
}
$("<span>" + PMA_messages['strReloadDatabase'] + "?</span>").dialog({
buttons: button_options
}) //end dialog options
} else {
PMA_ajaxShowMessage(data.error, false);
}
}) // end $.get()
})
}); // end Rename Database
/**
* Ajax Event Handler for 'Copy Database'
*
* @see $cfg['AjaxEnable']
*/
$("#copy_db_form.ajax").live('submit', function(event) {
event.preventDefault();
var $msgbox = PMA_ajaxShowMessage(PMA_messages['strCopyingDatabase']);
var $form = $(this);
PMA_prepareForAjaxRequest($form);
$.get($form.attr('action'), $form.serialize(), function(data) {
// use messages that stay on screen
$('div.success, div.error').fadeOut();
if(data.success == true) {
$('#floating_menubar').after(data.message);
if( $("#checkbox_switch").is(":checked")) {
window.parent.db = data.newname;
window.parent.refreshMain();
window.parent.refreshNavigation();
} else {
// Here we force a refresh because the navigation
// frame url is not changing so this function would
// not refresh it
window.parent.refreshNavigation(true);
}
} else {
$('#floating_menubar').after(data.error);
}
PMA_ajaxRemoveMessage($msgbox);
}) // end $.get
}) // end copy database
/**
* Ajax Event handler for 'Change Charset' of the database
*
* @see $cfg['AjaxEnable']
*/
$("#change_db_charset_form.ajax").live('submit', function(event) {
event.preventDefault();
var $form = $(this);
PMA_prepareForAjaxRequest($form);
PMA_ajaxShowMessage(PMA_messages['strChangingCharset']);
$.get($form.attr('action'), $form.serialize() + "&submitcollation=" + $form.find("input[name=submitcollation]").val(), function(data) {
if(data.success == true) {
PMA_ajaxShowMessage(data.message);
} else {
PMA_ajaxShowMessage(data.error, false);
}
}) // end $.get()
}) // end change charset
}, 'top.frame_content');
|