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
|
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* @fileoverview functions used on the server databases list page
* @name Server Databases
*
* @requires jQuery
* @requires jQueryUI
* @required js/functions.js
*/
/**
* AJAX scripts for server_databases.php
*
* Actions ajaxified here:
* Drop Databases
*
*/
$(function() {
/**
* Attach Event Handler for 'Drop Databases'
*
* (see $GLOBALS['cfg']['AjaxEnable'])
*/
$("button[name=drop_selected_dbs].ajax").live('click', function(event) {
event.preventDefault();
var $form = $(this.form);
/**
* @var selected_dbs Array containing the names of the checked databases
*/
var selected_dbs = [];
$form.find('input:checkbox:checked').each(function () {
$(this).closest('tr').addClass('removeMe');
selected_dbs[selected_dbs.length] = 'DROP DATABASE `' + escapeHtml($(this).val()) + '`;';
});
if (! selected_dbs.length) {
PMA_ajaxShowMessage(PMA_messages.strNoDatabasesSelected, 2000);
return;
}
/**
* @var question String containing the question to be asked for confirmation
*/
var question =
PMA_messages.strDropDatabaseStrongWarning + ' '
+ $.sprintf(PMA_messages.strDoYouReally, selected_dbs.join('<br />'));
$(this).PMA_confirm(
question,
$form.prop('action')
+ '?' + $(this.form).serialize()
+ '&drop_selected_dbs=1&is_js_confirmed=1&ajax_request=true',
function(url) {
PMA_ajaxShowMessage(PMA_messages.strProcessingRequest, false);
$.post(url, function(data) {
if(data.success == true) {
PMA_ajaxShowMessage(data.message);
var $rowsToRemove = $form.find('tr.removeMe');
var $databasesCount = $('#databases_count');
var newCount = parseInt($databasesCount.text()) - $rowsToRemove.length;
$databasesCount.text(newCount);
$rowsToRemove.remove();
$form.find('tbody').PMA_sort_table('.name');
if (window.parent && window.parent.frame_navigation) {
window.parent.frame_navigation.location.reload();
}
} else {
$form.find('tr.removeMe').removeClass('removeMe');
PMA_ajaxShowMessage(data.error, false);
}
}); // end $.post()
}); // end $.PMA_confirm()
}) ; //end of Drop Database action
/**
* Attach Ajax event handlers for 'Create Database'.
*
* @see $cfg['AjaxEnable']
*/
$('#create_database_form.ajax').live('submit', function(event) {
event.preventDefault();
$form = $(this);
var newDbNameInput = $form.find('input[name=new_db]');
if (newDbNameInput.val() === '') {
newDbNameInput.focus();
alert(PMA_messages['strFormEmpty']);
return;
}
PMA_ajaxShowMessage(PMA_messages['strProcessingRequest']);
PMA_prepareForAjaxRequest($form);
$.post($form.attr('action'), $form.serialize(), function(data) {
if (data.success == true) {
PMA_ajaxShowMessage(data.message);
//Append database's row to table
$("#tabledatabases")
.find('tbody')
.append(data.new_db_string)
.PMA_sort_table('.name');
var $databases_count_object = $('#databases_count');
var databases_count = parseInt($databases_count_object.text()) + 1;
$databases_count_object.text(databases_count);
//Refresh navigation frame as a new database has been added
if (window.parent && window.parent.frame_navigation) {
window.parent.frame_navigation.location.reload();
}
} else {
PMA_ajaxShowMessage(data.error, false);
}
}); // end $.post()
}); // end $().live()
}); // end $()
|