1
$(function(){$("#pma_open_querywindow").click(function(a){a.preventDefault();PMA_querywindow.focus()})});var PMA_commonParams=(function(){var a={};return{setAll:function(d){var c=false;for(var b in d){if(a[b]!==undefined&&a[b]!==d[b]){c=true}a[b]=d[b]}if(c){PMA_querywindow.refresh()}},get:function(b){return a[b]||""},set:function(b,c){if(a[b]!==undefined&&a[b]!==c){PMA_querywindow.refresh();PMA_reloadNavigation()}a[b]=c;return this},getUrlQuery:function(){return $.sprintf("?%s&server=%s&db=%s&table=%s",this.get("common_query"),encodeURIComponent(this.get("server")),encodeURIComponent(this.get("db")),encodeURIComponent(this.get("table")))}}})();var PMA_commonActions={setDb:function(a){if(a!=PMA_commonParams.get("db")){PMA_commonParams.set("db",a);PMA_querywindow.refresh()}},openDb:function(a){PMA_commonParams.set("db",a).set("table","");PMA_querywindow.refresh();this.refreshMain(PMA_commonParams.get("opendb_url"))},refreshMain:function(a,b){if(!a){a=$("#selflink a").attr("href");a=a.substring(0,a.indexOf("?"))}a+=PMA_commonParams.getUrlQuery();$("<a />",{href:a}).appendTo("body").click().remove();AJAX._callback=b}};var PMA_querywindow=(function(d,c){var b={};var a="";return{open:function(f,g){if(!f){f="querywindow.php"+PMA_commonParams.getUrlQuery()}if(g){f+="&sql_query="+encodeURIComponent(g)}if(!b.closed&&b.location){var e=b.location.href;if(e!=f&&e!=PMA_commonParams.get("pma_absolute_uri")+f){if(PMA_commonParams.get("safari_browser")){b.location.href=targeturl}else{b.location.replace(targeturl)}b.focus()}}else{b=c.open(f+"&init=1","","toolbar=0,location=0,directories=0,status=1,menubar=0,scrollbars=yes,resizable=yes,width="+PMA_commonParams.get("querywindow_width")+",height="+PMA_commonParams.get("querywindow_height"))}if(!b.opener){b.opener=c.window}if(c.focus){b.focus()}},focus:function(f){if(!b||b.closed||!b.location){a=f;this.open(false,f)}else{var e=b.document.getElementById("hiddenqueryform");if(e.querydisplay_tab!="sql"){e.querydisplay_tab.value="sql";e.sql_query.value=f;d(e).addClass("disableAjax");e.submit();b.focus()}else{b.focus()}}},refresh:function(f){if(!b.closed&&b.location){var e=d(b.document).find("#sqlqueryform");if(e.find("#checkbox_lock:checked").length==0){PMA_querywindow.open(f)}}},reload:function(f,g,i){if(!b.closed&&b.location){var e=d(b.document).find("#sqlqueryform");if(e.find("#checkbox_lock:checked").length==0){var h=d(b.document).find("#hiddenqueryform");h.find("input[name=db]").val(f);h.find("input[name=table]").val(g);if(i){h.find("input[name=sql_query]").val(i)}h.addClass("disableAjax").submit()}}}}})(jQuery,window);
b'\\ No newline at end of file'
1
/* vim: set expandtab sw=4 ts=4 sts=4: */
3
* Functionality for communicating with the querywindow
7
* Event handler for click on the open query window link
8
* in the top menu of the navigation panel
10
$('#pma_open_querywindow').click(function (event) {
11
event.preventDefault();
12
PMA_querywindow.focus();
17
* Holds common parameters such as server, db, table, etc
19
* The content for this is normally loaded from Header.class.php or
20
* Response.class.php and executed by ajax.js
22
var PMA_commonParams = (function () {
24
* @var hash params An associative array of key value pairs
28
// The returned object is the public part of the module
31
* Saves all the key value pair that
32
* are provided in the input array
34
* @param hash obj The input array
38
setAll: function (obj) {
41
if (params[i] !== undefined && params[i] !== obj[i]) {
47
PMA_querywindow.refresh();
51
* Retrieves a value given its key
52
* Returns empty string for undefined values
54
* @param string name The key
58
get: function (name) {
59
return params[name] || '';
62
* Saves a single key value pair
64
* @param string name The key
65
* @param string value The value
67
* @return self For chainability
69
set: function (name, value) {
70
if (params[name] !== undefined && params[name] !== value) {
71
PMA_querywindow.refresh();
72
PMA_reloadNavigation();
78
* Returns the url query string using the saved parameters
82
getUrlQuery: function () {
84
'?%s&server=%s&db=%s&table=%s',
85
this.get('common_query'),
86
encodeURIComponent(this.get('server')),
87
encodeURIComponent(this.get('db')),
88
encodeURIComponent(this.get('table'))
95
* Holds common parameters such as server, db, table, etc
97
* The content for this is normally loaded from Header.class.php or
98
* Response.class.php and executed by ajax.js
100
var PMA_commonActions = {
102
* Saves the database name when it's changed
103
* and reloads the query window, if necessary
105
* @param string new_db The name of the new database
109
setDb: function (new_db) {
110
if (new_db != PMA_commonParams.get('db')) {
111
PMA_commonParams.set('db', new_db);
112
PMA_querywindow.refresh();
116
* Opens a database in the main part of the page
118
* @param string new_db The name of the new database
122
openDb: function (new_db) {
126
PMA_querywindow.refresh();
128
PMA_commonParams.get('opendb_url')
132
* Refreshes the main frame
134
* @param mixed url Undefined to refresh to the same page
135
* String to go to a different page, e.g: 'index.php'
139
refreshMain: function (url, callback) {
141
url = $('#selflink a').attr('href');
142
url = url.substring(0, url.indexOf('?'));
144
url += PMA_commonParams.getUrlQuery();
145
$('<a />', {href: url})
149
AJAX._callback = callback;
154
* Common functions used for communicating with the querywindow
156
var PMA_querywindow = (function ($, window) {
158
* @var Object querywindow Reference to the window
159
* object of the querywindow
162
var querywindow = {};
164
* @var string queryToLoad Stores the SQL query that is to be displayed
165
* in the querywindow when it is ready
168
var queryToLoad = '';
169
// The returned object is the public part of the module
172
* Opens the query window
174
* @param mixed url Undefined to open the default page
175
* String to go to a different
179
open: function (url, sql_query) {
181
url = 'querywindow.php' + PMA_commonParams.getUrlQuery();
184
url += '&sql_query=' + encodeURIComponent(sql_query);
187
if (! querywindow.closed && querywindow.location) {
188
var href = querywindow.location.href;
190
&& href != PMA_commonParams.get('pma_absolute_uri') + url
192
if (PMA_commonParams.get('safari_browser')) {
193
querywindow.location.href = targeturl;
195
querywindow.location.replace(targeturl);
200
querywindow = window.open(
203
'toolbar=0,location=0,directories=0,status=1,'
204
+ 'menubar=0,scrollbars=yes,resizable=yes,'
205
+ 'width=' + PMA_commonParams.get('querywindow_width') + ','
206
+ 'height=' + PMA_commonParams.get('querywindow_height')
209
if (! querywindow.opener) {
210
querywindow.opener = window.window;
217
* Opens, if necessary, focuses the query window
218
* and displays an SQL query.
220
* @param string sql_query The SQL query to display in
225
focus: function (sql_query) {
226
if (! querywindow || querywindow.closed || ! querywindow.location) {
227
// we need first to open the window and cannot pass the query with it
228
// as we dont know if the query exceeds max url length
229
queryToLoad = sql_query;
230
this.open(false, sql_query);
232
//var querywindow = querywindow;
233
var hiddenqueryform = querywindow
235
.getElementById('hiddenqueryform');
236
if (hiddenqueryform.querydisplay_tab != 'sql' ) {
237
hiddenqueryform.querydisplay_tab.value = "sql";
238
hiddenqueryform.sql_query.value = sql_query;
239
$(hiddenqueryform).addClass('disableAjax');
240
hiddenqueryform.submit();
248
* Refreshes the query window given a url
250
* @param string url Where to go to
254
refresh: function (url) {
255
if (! querywindow.closed && querywindow.location) {
256
var $form = $(querywindow.document).find('#sqlqueryform');
257
if ($form.find('#checkbox_lock:checked').length == 0) {
258
PMA_querywindow.open(url);
263
* Reloads the query window given the details
264
* of a db, a table and an sql_query
266
* @param string db The name of the database
267
* @param string table The name of the table
268
* @param string sql_query The SQL query to be displayed
272
reload: function (db, table, sql_query) {
273
if (! querywindow.closed && querywindow.location) {
274
var $form = $(querywindow.document).find('#sqlqueryform');
275
if ($form.find('#checkbox_lock:checked').length == 0) {
276
var $hiddenform = $(querywindow.document)
277
.find('#hiddenqueryform');
278
$hiddenform.find('input[name=db]').val(db);
279
$hiddenform.find('input[name=table]').val(table);
281
$hiddenform.find('input[name=sql_query]').val(sql_query);
283
$hiddenform.addClass('disableAjax').submit();