2 * @fileoverview functions used on the database structure page
3 * @name Database Structure
7 * @required js/functions.js
11 * AJAX scripts for db_structure.php
13 * Actions ajaxified here:
19 $(document).ready(function() {
22 * Ajax Event handler for 'Truncate Table'
24 * @uses $.PMA_confirm()
25 * @uses PMA_ajaxShowMessage()
27 $(".truncate_table_anchor").live('click', function(event) {
28 event.preventDefault();
30 //extract current table name and build the question string
32 * @var curr_table_name String containing the name of the table to be truncated
34 var curr_table_name = $(this).parents('tr').children('th').children('a').text();
36 * @var question String containing the question to be asked for confirmation
38 var question = 'TRUNCATE ' + curr_table_name;
40 * @var this_anchor Object referring to the anchor clicked
42 var this_anchor = $(this);
44 $(this).PMA_confirm(question, $(this).attr('href'), function(url) {
46 PMA_ajaxShowMessage(PMA_messages['strProcessingRequest']);
48 $.get(url, {'is_js_confirmed' : 1, 'ajax_request' : true}, function(data) {
49 if(data.success == true) {
50 PMA_ajaxShowMessage(data.message);
51 //Remove the action's href and class, so as to disable further attempts to truncate the table
52 // @todo: How to replace the icon with the disabled version?
55 .removeClass('.truncate_table_anchor');
58 PMA_ajaxShowMessage(PMA_messages['strErrorProcessingRequest'] + " : " + data.error);
61 }) //end $.PMA_confirm()
62 }); //end of Truncate Table Ajax action
65 * Ajax Event handler for 'Drop Table'
67 * @uses $.PMA_confirm()
68 * @uses PMA_ajaxShowMessage()
70 $(".drop_table_anchor").live('click', function(event) {
71 event.preventDefault();
73 //extract current table name and build the question string
75 * @var curr_row Object containing reference to the current row
77 var curr_row = $(this).parents('tr');
79 * @var curr_table_name String containing the name of the table to be truncated
81 var curr_table_name = $(curr_row).children('th').children('a').text();
83 * @var question String containing the question to be asked for confirmation
85 var question = 'DROP TABLE ' + curr_table_name;
87 $(this).PMA_confirm(question, $(this).attr('href'), function(url) {
89 PMA_ajaxShowMessage(PMA_messages['strProcessingRequest']);
91 $.get(url, {'is_js_confirmed' : 1, 'ajax_request' : true}, function(data) {
92 if(data.success == true) {
93 PMA_ajaxShowMessage(data.message);
94 //need to find a better solution here. The icon should be replaced
95 $(curr_row).hide("medium").remove();
98 PMA_ajaxShowMessage(PMA_messages['strErrorProcessingRequest'] + " : " + data.error);
101 }); // end $.PMA_confirm()
102 }); //end of Drop Table Ajax action
105 * Ajax Event handler for 'Drop Event'
107 * @uses $.PMA_confirm()
108 * @uses PMA_ajaxShowMessage()
110 $('.drop_event_anchor').live('click', function(event) {
111 event.preventDefault();
114 * @var curr_event_row Object reference to current event's row
116 var curr_event_row = $(this).parents('tr');
118 * @var curr_event_name String containing the name of {@link curr_event_row}
120 var curr_event_name = $(curr_event_row).children('td:first').text();
122 * @var question String containing the question to be asked for confirmation
124 var question = 'DROP EVENT ' + curr_event_name;
126 $(this).PMA_confirm(question, $(this).attr('href') , function(url) {
128 PMA_ajaxShowMessage(PMA_messages['strDroppingEvent']);
130 $.get(url, {'is_js_confirmed': 1, 'ajax_request': true}, function(data) {
131 if(data.success == true) {
132 PMA_ajaxShowMessage(data.message);
133 $(curr_event_row).hide("medium").remove();
136 PMA_ajaxShowMessage(PMA_messages['strErrorProcessingRequest'] + " : " + data.error);
139 }) // end $.PMA_confirm()
143 * Ajax Event handler for 'Drop Procedure'
145 * @uses $.PMA_confirm()
146 * @uses PMA_ajaxShowMessage()
148 $('.drop_procedure_anchor').live('click', function(event) {
149 event.preventDefault();
152 * @var curr_proc_row Object containing reference to the current procedure's row
154 var curr_proc_row = $(this).parents('tr');
156 * @var question String containing the question to be asked for confirmation
158 var question = $(curr_proc_row).children('.drop_procedure_sql').val();
160 $(this).PMA_confirm(question, $(this).attr('href'), function(url) {
162 PMA_ajaxShowMessage(PMA_messages['strDroppingProcedure']);
164 $.get(url, {'is_js_confirmed': 1, 'ajax_request': true}, function(data) {
165 if(data.success == true) {
166 PMA_ajaxShowMessage(data.message);
167 $(curr_event_row).hide("medium").remove();
170 PMA_ajaxShowMessage(PMA_messages['strErrorProcessingRequest'] + " : " + data.error);
173 }) // end $.PMA_confirm()
174 }) //end Drop Procedure
176 $('.drop_tracking_anchor').live('click', function(event) {
177 event.preventDefault();
180 * @var curr_tracking_row Object containing reference to the current tracked table's row
182 var curr_tracking_row = $(this).parents('tr');
184 * @var question String containing the question to be asked for confirmation
186 var question = PMA_messages['strDeleteTrackingData'];
188 $(this).PMA_confirm(question, $(this).attr('href'), function(url) {
190 PMA_ajaxShowMessage(PMA_messages['strDeletingTrackingData']);
192 $.get(url, {'is_js_confirmed': 1, 'ajax_request': true}, function(data) {
193 if(data.success == true) {
194 PMA_ajaxShowMessage(data.message);
195 $(curr_tracking_row).hide("medium").remove();
198 PMA_ajaxShowMessage(PMA_messages['strErrorProcessingRequest'] + " : " + data.error);
201 }) // end $.PMA_confirm()
202 }) //end Drop Tracking
204 //Calculate Real End for InnoDB
206 * Ajax Event handler for calculatig the real end for a InnoDB table
208 * @uses $.PMA_confirm
210 $('#real_end_input').live('click', function(event) {
211 event.preventDefault();
214 * @var question String containing the question to be asked for confirmation
216 var question = PMA_messages['strOperationTakesLongTime'];
218 $(this).PMA_confirm(question, '', function() {
222 }) //end Calculate Real End for InnoDB
224 }, 'top.frame_content'); // end $(document).ready()