[ Index ] |
|
Code source de phpMyAdmin 2.10.3 |
1 /** 2 * holds the browser query window 3 */ 4 var querywindow = ''; 5 6 /** 7 * holds the query to be load from a new query window 8 */ 9 var query_to_load = ''; 10 11 /** 12 * sets current selected db 13 * 14 * @param string db name 15 */ 16 function setDb(new_db) { 17 //alert('setDb(' + new_db + ')'); 18 if (new_db != db) { 19 // db has changed 20 //alert( new_db + '(' + new_db.length + ') : ' + db ); 21 22 var old_db = db; 23 db = new_db; 24 25 if (window.frame_navigation.document.getElementById(db) == null) { 26 // db is unknown, reload complete left frame 27 refreshNavigation(); 28 } else { 29 unmarkDbTable(old_db); 30 markDbTable(db); 31 } 32 33 // TODO: add code to expand db in lightview mode 34 35 // refresh querywindow 36 refreshQuerywindow(); 37 } 38 } 39 40 /** 41 * sets current selected table (called from navigation.php) 42 * 43 * @param string table name 44 */ 45 function setTable(new_table) { 46 //alert('setTable(' + new_table + ')'); 47 if (new_table != table) { 48 // table has changed 49 //alert( new_table + '(' + new_table.length + ') : ' + table ); 50 51 table = new_table; 52 53 if (window.frame_navigation.document.getElementById(db + '.' + table) == null 54 && table != '') { 55 // table is unknown, reload complete left frame 56 refreshNavigation(); 57 58 } 59 // TODO: add code to expand table in lightview mode 60 61 // refresh querywindow 62 refreshQuerywindow(); 63 } 64 } 65 66 function refreshMain(url) { 67 if (! url) { 68 if (db) { 69 url = opendb_url; 70 } else { 71 url = 'main.php'; 72 } 73 } 74 goTo(url + '?server=' + encodeURIComponent(server) + 75 '&db=' + encodeURIComponent(db) + 76 '&table=' + encodeURIComponent(table) + 77 '&lang=' + encodeURIComponent(lang) + 78 '&collation_connection=' + encodeURIComponent(collation_connection), 79 'main' ); 80 } 81 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) 88 ); 89 } 90 91 /** 92 * adds class to element 93 */ 94 function addClass(element, classname) 95 { 96 if (element != null) { 97 element.className += ' ' + classname; 98 //alert('set class: ' + classname + ', now: ' + element.className); 99 } 100 } 101 102 /** 103 * removes class from element 104 */ 105 function removeClass(element, classname) 106 { 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); 112 } 113 } 114 115 function unmarkDbTable(db, table) 116 { 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'); 121 } 122 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'); 127 } 128 } 129 130 function markDbTable(db, table) 131 { 132 var element_reference = window.frame_navigation.document.getElementById(db); 133 if (element_reference != null) { 134 addClass(element_reference.parentNode, 'marked'); 135 // scrolldown 136 element_reference.focus(); 137 // opera marks the text, we dont want this ... 138 element_reference.blur(); 139 } 140 141 element_reference = window.frame_navigation.document.getElementById(db + '.' + table); 142 if (element_reference != null) { 143 addClass(element_reference.parentNode, 'marked'); 144 // scrolldown 145 element_reference.focus(); 146 // opera marks the text, we dont want this ... 147 element_reference.blur(); 148 } 149 150 // return to main frame ... 151 window.frame_content.focus(); 152 } 153 154 /** 155 * sets current selected server, table and db (called from libraries/footer.inc.php) 156 */ 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 162 server = new_server; 163 db = new_db; 164 table = new_table; 165 collation_connection = new_collation_connection; 166 lang = new_lang; 167 refreshNavigation(); 168 } else if (new_db != db || new_table != table) { 169 // save new db and table 170 var old_db = db; 171 var old_table = table; 172 db = new_db; 173 table = new_table; 174 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 178 refreshNavigation(); 179 } else { 180 unmarkDbTable(old_db, old_table); 181 markDbTable(db, table); 182 } 183 184 // TODO: add code to expand db in lightview mode 185 186 // refresh querywindow 187 refreshQuerywindow(); 188 } 189 } 190 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; 199 200 if ( sql_query ) { 201 querywindow.document.querywindow.query_history_latest.value = sql_query; 202 } 203 204 querywindow.document.querywindow.submit(); 205 } 206 } 207 } 208 209 /** 210 * brings query window to front and inserts query to be edited 211 */ 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; 219 open_querywindow(); 220 insertQuery(0); 221 } else { 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(); 227 querywindow.focus(); 228 } else { 229 querywindow.focus(); 230 } 231 } 232 return true; 233 } 234 235 /** 236 * inserts query string into query window textarea 237 * called from script tag in querywindow 238 */ 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; 242 query_to_load = ''; 243 return true; 244 } 245 return false; 246 } 247 248 function open_querywindow( url ) { 249 if ( ! url ) { 250 url = 'querywindow.php?' + common_query + '&db=' + encodeURIComponent(db) + '&table=' + encodeURIComponent(table); 251 } 252 253 if (!querywindow.closed && querywindow.location) { 254 goTo( url, 'query' ); 255 querywindow.focus(); 256 } else { 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 ); 262 } 263 264 if ( ! querywindow.opener ) { 265 querywindow.opener = window.window; 266 } 267 268 if ( window.focus ) { 269 querywindow.focus(); 270 } 271 272 return true; 273 } 274 275 function refreshQuerywindow( url ) { 276 277 if ( ! querywindow.closed && querywindow.location ) { 278 if ( ! querywindow.document.sqlform.LockFromUpdate 279 || ! querywindow.document.sqlform.LockFromUpdate.checked ) { 280 open_querywindow( url ) 281 } 282 } 283 } 284 285 /** 286 * opens new url in target frame, with default beeing left frame 287 * valid is 'main' and 'querywindow' all others leads to 'left' 288 * 289 * @param string targeturl new url to load 290 * @param string target frame where to load the new url 291 */ 292 function goTo(targeturl, target) { 293 //alert('goto'); 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; 301 } 302 303 if ( target ) { 304 if ( target.location.href == targeturl ) { 305 return true; 306 } else if ( target.location.href == pma_absolute_uri + targeturl ) { 307 return true; 308 } 309 310 if ( safari_browser ) { 311 target.location.href = targeturl; 312 } else { 313 target.location.replace(targeturl); 314 } 315 } 316 317 return true; 318 } 319 320 // opens selected db in main frame 321 function openDb(new_db) { 322 //alert('opendb(' + new_db + ')'); 323 setDb(new_db); 324 setTable(''); 325 refreshMain(opendb_url); 326 return true; 327 } 328 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; 336 return true; 337 } 338 339 return false; 340 }
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Mon Nov 26 15:18:20 2007 | par Balluche grâce à PHPXref 0.7 |
![]() |