2
* holds the browser query window
7
* holds the query to be load from a new query window
9
var query_to_load = '';
12
* sets current selected db
14
* @param string db name
16
function setDb(new_db) {
17
//alert('setDb(' + new_db + ')');
20
//alert( new_db + '(' + new_db.length + ') : ' + db );
25
if (window.frame_navigation.document.getElementById(db) == null) {
26
// db is unknown, reload complete left frame
29
unmarkDbTable(old_db);
33
// TODO: add code to expand db in lightview mode
35
// refresh querywindow
41
* sets current selected table (called from navigation.php)
43
* @param string table name
45
function setTable(new_table) {
46
//alert('setTable(' + new_table + ')');
47
if (new_table != table) {
49
//alert( new_table + '(' + new_table.length + ') : ' + table );
53
if (window.frame_navigation.document.getElementById(db + '.' + table) == null
55
// table is unknown, reload complete left frame
59
// TODO: add code to expand table in lightview mode
61
// refresh querywindow
66
function refreshMain(url) {
74
goTo(url + '?server=' + encodeURIComponent(server) +
75
'&db=' + encodeURIComponent(db) +
76
'&table=' + encodeURIComponent(table) +
77
'&lang=' + encodeURIComponent(lang) +
78
'&collation_connection=' + encodeURIComponent(collation_connection),
82
function refreshNavigation() {
83
goTo('navigation.php?server=' + encodeURIComponent(server) +
84
'&db=' + encodeURIComponent(db) +
85
'&table=' + encodeURIComponent(table) +
86
'&lang=' + encodeURIComponent(lang) +
87
'&collation_connection=' + encodeURIComponent(collation_connection)
92
* adds class to element
94
function addClass(element, classname)
96
if (element != null) {
97
element.className += ' ' + classname;
98
//alert('set class: ' + classname + ', now: ' + element.className);
103
* removes class from element
105
function removeClass(element, classname)
107
if (element != null) {
108
element.className = element.className.replace(' ' + classname, '');
109
// if there is no other class anem there is no leading space
110
element.className = element.className.replace(classname, '');
111
//alert('removed class: ' + classname + ', now: ' + element.className);
115
function unmarkDbTable(db, table)
117
var element_reference = window.frame_navigation.document.getElementById(db);
118
if (element_reference != null) {
119
//alert('remove from: ' + db);
120
removeClass(element_reference.parentNode, 'marked');
123
element_reference = window.frame_navigation.document.getElementById(db + '.' + table);
124
if (element_reference != null) {
125
//alert('remove from: ' + db + '.' + table);
126
removeClass(element_reference.parentNode, 'marked');
130
function markDbTable(db, table)
132
var element_reference = window.frame_navigation.document.getElementById(db);
133
if (element_reference != null) {
134
addClass(element_reference.parentNode, 'marked');
136
element_reference.focus();
137
// opera marks the text, we dont want this ...
138
element_reference.blur();
141
element_reference = window.frame_navigation.document.getElementById(db + '.' + table);
142
if (element_reference != null) {
143
addClass(element_reference.parentNode, 'marked');
145
element_reference.focus();
146
// opera marks the text, we dont want this ...
147
element_reference.blur();
150
// return to main frame ...
151
window.frame_content.focus();
155
* sets current selected server, table and db (called from libraries/footer.inc.php)
157
function setAll( new_lang, new_collation_connection, new_server, new_db, new_table ) {
158
//alert('setAll( ' + new_lang + ', ' + new_collation_connection + ', ' + new_server + ', ' + new_db + ', ' + new_table + ' )');
159
if (new_server != server || new_lang != lang
160
|| new_collation_connection != collation_connection) {
161
// something important has changed
165
collation_connection = new_collation_connection;
168
} else if (new_db != db || new_table != table) {
169
// save new db and table
171
var old_table = table;
175
if (window.frame_navigation.document.getElementById(db) == null
176
&& window.frame_navigation.document.getElementById(db + '.' + table) == null ) {
177
// table or db is unknown, reload complete left frame
180
unmarkDbTable(old_db, old_table);
181
markDbTable(db, table);
184
// TODO: add code to expand db in lightview mode
186
// refresh querywindow
187
refreshQuerywindow();
191
function reload_querywindow( db, table, sql_query ) {
192
if ( ! querywindow.closed && querywindow.location ) {
193
if ( ! querywindow.document.sqlform.LockFromUpdate
194
|| ! querywindow.document.sqlform.LockFromUpdate.checked ) {
195
querywindow.document.querywindow.db.value = db;
196
querywindow.document.querywindow.query_history_latest_db.value = db;
197
querywindow.document.querywindow.table.value = table;
198
querywindow.document.querywindow.query_history_latest_table.value = table;
201
querywindow.document.querywindow.query_history_latest.value = sql_query;
204
querywindow.document.querywindow.submit();
210
* brings query window to front and inserts query to be edited
212
function focus_querywindow( sql_query ) {
213
/* if ( querywindow && !querywindow.closed && querywindow.location) { */
214
if ( !querywindow || querywindow.closed || !querywindow.location) {
215
// we need first to open the window and cannot pass the query with it
216
// as we dont know if the query exceeds max url length
217
/* url = 'querywindow.php?' + common_query + '&db=' + db + '&table=' + table + '&sql_query=SELECT * FROM'; */
218
query_to_load = sql_query;
222
//var querywindow = querywindow;
223
if ( querywindow.document.querywindow.querydisplay_tab != 'sql' ) {
224
querywindow.document.querywindow.querydisplay_tab.value = "sql";
225
querywindow.document.querywindow.query_history_latest.value = sql_query;
226
querywindow.document.querywindow.submit();
236
* inserts query string into query window textarea
237
* called from script tag in querywindow
239
function insertQuery() {
240
if (query_to_load != '' && querywindow.document && querywindow.document.getElementById && querywindow.document.getElementById('sqlquery')) {
241
querywindow.document.getElementById('sqlquery').value = query_to_load;
248
function open_querywindow( url ) {
250
url = 'querywindow.php?' + common_query + '&db=' + encodeURIComponent(db) + '&table=' + encodeURIComponent(table);
253
if (!querywindow.closed && querywindow.location) {
254
goTo( url, 'query' );
257
querywindow=window.open( url, '',
258
'toolbar=0,location=0,directories=0,status=1,menubar=0,' +
259
'scrollbars=yes,resizable=yes,' +
260
'width=' + querywindow_width + ',' +
261
'height=' + querywindow_height );
264
if ( ! querywindow.opener ) {
265
querywindow.opener = window.window;
268
if ( window.focus ) {
275
function refreshQuerywindow( url ) {
277
if ( ! querywindow.closed && querywindow.location ) {
278
if ( ! querywindow.document.sqlform.LockFromUpdate
279
|| ! querywindow.document.sqlform.LockFromUpdate.checked ) {
280
open_querywindow( url )
286
* opens new url in target frame, with default beeing left frame
287
* valid is 'main' and 'querywindow' all others leads to 'left'
289
* @param string targeturl new url to load
290
* @param string target frame where to load the new url
292
function goTo(targeturl, target) {
294
if ( target == 'main' ) {
295
target = window.frame_content;
296
} else if ( target == 'query' ) {
297
target = querywindow;
298
//return open_querywindow( targeturl );
299
} else if ( ! target ) {
300
target = window.frame_navigation;
304
if ( target.location.href == targeturl ) {
306
} else if ( target.location.href == pma_absolute_uri + targeturl ) {
310
if ( safari_browser ) {
311
target.location.href = targeturl;
313
target.location.replace(targeturl);
320
// opens selected db in main frame
321
function openDb(new_db) {
322
//alert('opendb(' + new_db + ')');
325
refreshMain(opendb_url);
329
function updateTableTitle( table_link_id, new_title ) {
330
//alert('updateTableTitle');
331
if ( window.parent.frame_navigation.document.getElementById(table_link_id) ) {
332
var left = window.parent.frame_navigation.document;
333
left.getElementById(table_link_id).title = new_title;
334
new_title = left.getElementById('icon_' + table_link_id).alt + ': ' + new_title;
335
left.getElementById('browse_' + table_link_id).title = new_title;