From 48a95cb47936f0bb06b9b7d1728045889af19889 Mon Sep 17 00:00:00 2001 From: Thilanka Kaushalya Date: Sun, 7 Aug 2011 16:19:14 +0530 Subject: [PATCH 1/4] Ajaxify table maintenance in table operations --- js/functions.js | 41 +++++++++++++++++++++++++++++++++++------ sql.php | 7 +++++++ tbl_operations.php | 2 +- 3 files changed, 43 insertions(+), 7 deletions(-) diff --git a/js/functions.js b/js/functions.js index bc94a89610..84181567ba 100644 --- a/js/functions.js +++ b/js/functions.js @@ -1964,7 +1964,7 @@ $(document).ready(function() { **/ $("#alterTableOrderby.ajax").live('submit', function(event) { event.preventDefault(); - $form = $(this); + var $form = $(this); PMA_prepareForAjaxRequest($form); /*variables which stores the common attributes*/ @@ -1982,9 +1982,9 @@ $(document).ready(function() { $("#result_query .notice").remove(); $("#result_query").prepend((data.message)); } else { - $temp_div = $("
") + var $temp_div = $("
") $temp_div.html(data.error); - $error = $temp_div.find("code").addClass("error"); + var $error = $temp_div.find("code").addClass("error"); PMA_ajaxShowMessage($error); } }) // end $.post() @@ -1995,7 +1995,7 @@ $(document).ready(function() { **/ $("#copyTable.ajax input[name='submit_copy']").live('click', function(event) { event.preventDefault(); - $form = $("#copyTable"); + var $form = $("#copyTable"); if($form.find("input[name='switch_to_new']").attr('checked')) { $form.append(''); $form.removeClass('ajax'); @@ -2024,15 +2024,44 @@ $(document).ready(function() { window.parent.frame_navigation.location.reload(); } } else { - $temp_div = $("
") + var $temp_div = $("
"); $temp_div.html(data.error); - $error = $temp_div.find("code").addClass("error"); + var $error = $temp_div.find("code").addClass("error"); PMA_ajaxShowMessage($error); } }) // end $.post() } });//end of copyTable ajax submit + /** + *Ajax events for actions in the "Table maintenance" + **/ + $("#tbl_maintenance.ajax li").live('click', function(event) { + event.preventDefault(); + var $link = $(this); + var href = $link.find("a").first().attr("href"); + href = href.split('?'); + //variables which stores the common attributes + $.post(href[0], href[1]+"&ajax_request=true", function(data) { + if ($("#sqlqueryresults").length != 0) { + $("#sqlqueryresults").remove(); + } + if ($("#result_query").length != 0) { + $("#result_query").remove(); + } + if (data.success == true) { + PMA_ajaxShowMessage(data.message); + $("
").insertAfter("#topmenucontainer"); + $("#sqlqueryresults").html(data.sql_query); + } else { + var $temp_div = $("
") + $temp_div.html(data.error); + var $error = $temp_div.find("code").addClass("error"); + PMA_ajaxShowMessage($error); + } + }) // end $.post() + });//end of table maintanance ajax click + }, 'top.frame_content'); //end $(document).ready for 'Table operations' diff --git a/sql.php b/sql.php index 94a0b0d1e5..5af92914df 100644 --- a/sql.php +++ b/sql.php @@ -866,6 +866,13 @@ else { PMA_ajaxResponse(NULL, true, $extra_data); } + if (isset($_REQUEST['ajax_request']) && isset($_REQUEST['table_maintenance'])) { + echo $show_query; + $message = PMA_Message::success($message); + $extra_data['sql_query'] = PMA_showMessage($message, $GLOBALS['sql_query'], 'success'); + PMA_ajaxResponse($message,$message->isSuccess(),$extra_data); + } + // Displays the headers if (isset($show_query)) { unset($show_query); diff --git a/tbl_operations.php b/tbl_operations.php index 3e9bdebc4d..90e2fd4ca4 100644 --- a/tbl_operations.php +++ b/tbl_operations.php @@ -598,7 +598,7 @@ if (isset($possible_row_formats[$tbl_type])) {
-