sorry, wrong version checked in
[phpmyadmin/arisferyanto.git] / libraries / querywindow.js
blobaa5667191cb79d10e9777e5ebe3175b280d6334f
1 var querywindow = '';
3 /**
4 * sets current selected server, table and db (called from footer.inc.php)
5 */
6 function setDb( new_db ) {
7 //alert('setDb(' + new_db + ')');
8 if ( new_db != db ) {
9 // db has changed
10 //alert( new_db + '(' + new_db.length + ') : ' + db );
12 db = new_db;
14 if ( window.frames[0].document.getElementById( db ) == null ) {
15 // db is unknown, reload complete left frame
16 refreshLeft();
19 // TODO: add code to expand db in lightview mode
21 // refresh querywindow
22 refreshQuerywindow();
26 function refreshMain( url ) {
27 if ( ! url ) {
28 if ( db ) {
29 url = opendb_url;
30 } else {
31 url = 'main.php';
34 goTo( url + '?&server=' + server +
35 '&db=' + db +
36 '&table=' + table +
37 '&lang=' + lang +
38 '&collation_connection=' + collation_connection,
39 'main' );
42 function refreshLeft() {
43 goTo('left.php?&server=' + server +
44 '&db=' + db +
45 '&table=' + table +
46 '&lang=' + lang +
47 '&collation_connection=' + collation_connection
51 /**
52 * sets current selected server, table and db (called from footer.inc.php)
54 function setAll( new_lang, new_collation_connection, new_server, new_db, new_table ) {
55 //alert('setAll( ' + new_lang + ', ' + new_collation_connection + ', ' + new_server + ', ' + new_db + ', ' + new_table + ' )');
56 if ( new_server != server || new_lang != lang
57 || new_collation_connection != collation_connection ) {
58 // something important has changed
59 server = new_server;
60 db = new_db;
61 table = new_table;
62 collation_connection = new_collation_connection;
63 lang = new_lang;
64 refreshLeft();
66 else if ( new_db != db || new_table != table ) {
67 // save new db and table
68 db = new_db;
69 table = new_table;
71 if ( window.frames[0].document.getElementById( db ) == null
72 && window.frames[0].document.getElementById( db + '.' + table ) == null ) {
73 // table or db is unknown, reload complete left frame
74 refreshLeft();
77 // TODO: add code to expand db in lightview mode
79 // refresh querywindow
80 refreshQuerywindow();
84 function reload_querywindow( db, table, sql_query ) {
85 if ( ! querywindow.closed && querywindow.location ) {
86 if ( ! querywindow.document.sqlform.LockFromUpdate
87 || ! querywindow.document.sqlform.LockFromUpdate.checked ) {
88 querywindow.document.querywindow.db.value = db;
89 querywindow.document.querywindow.query_history_latest_db.value = db;
90 querywindow.document.querywindow.table.value = table;
91 querywindow.document.querywindow.query_history_latest_table.value = table;
93 if ( sql_query ) {
94 querywindow.document.querywindow.query_history_latest.value = sql_query;
97 querywindow.document.querywindow.submit();
102 function focus_querywindow( sql_query ) {
103 if ( querywindow && !querywindow.closed && querywindow.location) {
104 var querywindow = querywindow;
105 if ( querywindow.document.querywindow.querydisplay_tab != 'sql' ) {
106 querywindow.document.querywindow.querydisplay_tab.value = "sql";
107 querywindow.document.querywindow.query_history_latest.value = sql_query;
108 querywindow.document.querywindow.submit();
109 querywindow.focus();
110 } else {
111 querywindow.focus();
113 } else {
114 url = 'querywindow.php?' + common_query + '&db=' + db + '&table=' + table + '&sql_query=' + sql_query;
115 open_querywindow( url );
119 function open_querywindow( url ) {
120 if ( ! url ) {
121 url = 'querywindow.php?' + common_query + '&db=' + db + '&table=' + table;
124 if (!querywindow.closed && querywindow.location) {
125 goTo( url, 'query' );
126 querywindow.focus();
127 } else {
128 querywindow=window.open( url, '',
129 'toolbar=0,location=0,directories=0,status=1,menubar=0,' +
130 'scrollbars=yes,resizable=yes,' +
131 'width=' + querywindow_width + ',' +
132 'height=' + querywindow_height );
135 if ( ! querywindow.opener ) {
136 querywindow.opener = window.window;
139 if ( window.focus ) {
140 querywindow.focus();
143 return true;
146 function refreshQuerywindow( url ) {
147 if ( ! querywindow.closed && querywindow.location ) {
148 open_querywindow( url )
153 * opens new url in target frame, with default beeing left frame
154 * valid is 'main' and 'querywindow' all others leads to 'left'
156 * @param string targeturl new url to load
157 * @param string target frame where to load the new url
159 function goTo( targeturl, target ) {
160 //alert('goto');
161 if ( target == 'main' ) {
162 target = window.frames[1];
163 } else if ( target == 'query' ) {
164 target = querywindow;
165 //return open_querywindow( targeturl );
166 } else if ( ! target ) {
167 target = window.frames[0];
170 if ( target ) {
171 if ( target.location.href == targeturl ) {
172 return true;
173 } else if ( target.location.href == pma_absolute_uri + targeturl ) {
174 return true;
177 if ( safari_browser ) {
178 target.location.href = targeturl;
179 } else {
180 target.location.replace(targeturl);
184 return true;
187 // opens selected db in main frame
188 function openDb( new_db ) {
189 //alert('opendb(' + new_db + ')');
190 setDb( new_db );
191 refreshMain( opendb_url );
192 return true;
195 function updateTableTitle( table_link_id, new_title ) {
196 //alert('updateTableTitle');
197 if ( window.parent.frames[0].document.getElementById(table_link_id) ) {
198 var left = window.parent.frames[0].document;
199 left.getElementById(table_link_id).title = new_title;
200 new_title = left.getElementById('icon_' + table_link_id).alt + ': ' + new_title;
201 left.getElementById('browse_' + table_link_id).title = new_title;
202 return true;
205 return false;