1 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 * general function, usally for data manipulation pages
8 * @var sql_box_locked lock for the sqlbox textarea in the querybox/querywindow
10 var sql_box_locked = false;
13 * @var array holds elements which content should only selected once
15 var only_once_elements = new Array();
18 * @var ajax_message_init boolean boolean that stores status of
19 * notification for PMA_ajaxShowNotification
21 var ajax_message_init = false;
24 * Generate a new password and copy it to the password input areas
26 * @param object the form that holds the password fields
28 * @return boolean always true
30 function suggestPassword(passwd_form) {
31 // restrict the password to just letters and numbers to avoid problems:
32 // "editors and viewers regard the password as multiple words and
33 // things like double click no longer work"
34 var pwchars = "abcdefhjmnpqrstuvwxyz23456789ABCDEFGHJKLMNPQRSTUVWYXZ";
35 var passwordlength = 16; // do we want that to be dynamic? no, keep it simple :)
36 var passwd = passwd_form.generated_pw;
39 for ( i = 0; i < passwordlength; i++ ) {
40 passwd.value += pwchars.charAt( Math.floor( Math.random() * pwchars.length ) )
42 passwd_form.text_pma_pw.value = passwd.value;
43 passwd_form.text_pma_pw2.value = passwd.value;
48 * Version string to integer conversion.
50 function parseVersionString (str) {
51 if (typeof(str) != 'string') { return false; }
53 // Parse possible alpha/beta/rc/
54 var state = str.split('-');
55 if (state.length >= 2) {
56 if (state[1].substr(0, 2) == 'rc') {
57 add = - 20 - parseInt(state[1].substr(2));
58 } else if (state[1].substr(0, 4) == 'beta') {
59 add = - 40 - parseInt(state[1].substr(4));
60 } else if (state[1].substr(0, 5) == 'alpha') {
61 add = - 60 - parseInt(state[1].substr(5));
62 } else if (state[1].substr(0, 3) == 'dev') {
63 /* We don't handle dev, it's git snapshot */
68 var x = str.split('.');
69 // Use 0 for non existing parts
70 var maj = parseInt(x[0]) || 0;
71 var min = parseInt(x[1]) || 0;
72 var pat = parseInt(x[2]) || 0;
73 var hotfix = parseInt(x[3]) || 0;
74 return maj * 100000000 + min * 1000000 + pat * 10000 + hotfix * 100 + add;
78 * Indicates current available version on main page.
80 function PMA_current_version() {
81 var current = parseVersionString('3.4.0'/*pmaversion*/);
82 var latest = parseVersionString(PMA_latest_version);
83 $('#li_pma_version').append(PMA_messages['strLatestAvailable'] + ' ' + PMA_latest_version);
84 if (latest > current) {
85 var message = $.sprintf(PMA_messages['strNewerVersion'], PMA_latest_version, PMA_latest_date);
86 if (Math.floor(latest / 10000) == Math.floor(current / 10000)) {
92 $('#maincontainer').after('<div class="' + klass + '">' + message + '</div>');
97 * for libraries/display_change_password.lib.php
98 * libraries/user_password.php
102 function displayPasswordGenerateButton() {
103 $('#tr_element_before_generate_password').parent().append('<tr><td>' + PMA_messages['strGeneratePassword'] + '</td><td><input type="button" id="button_generate_password" value="' + PMA_messages['strGenerate'] + '" onclick="suggestPassword(this.form)" /><input type="text" name="generated_pw" id="generated_pw" /></td></tr>');
104 $('#div_element_before_generate_password').parent().append('<div class="item"><label for="button_generate_password">' + PMA_messages['strGeneratePassword'] + ':</label><span class="options"><input type="button" id="button_generate_password" value="' + PMA_messages['strGenerate'] + '" onclick="suggestPassword(this.form)" /></span><input type="text" name="generated_pw" id="generated_pw" /></div>');
108 * Adds a date/time picker to an element
110 * @param object $this_element a jQuery object pointing to the element
112 function PMA_addDatepicker($this_element) {
113 var showTimeOption = false;
114 if ($this_element.is('.datetimefield')) {
115 showTimeOption = true;
121 buttonImage: themeCalendarImage, // defined in js/messages.php
122 buttonImageOnly: true,
127 showTime: showTimeOption,
128 dateFormat: 'yy-mm-dd', // yy means year with four digits
130 beforeShow: function(input, inst) {
131 // Remember that we came from the datepicker; this is used
132 // in tbl_change.js by verificationsAfterFieldChange()
133 $this_element.data('comes_from', 'datepicker');
135 constrainInput: false
140 * selects the content of a given object, f.e. a textarea
142 * @param object element element of which the content will be selected
143 * @param var lock variable which holds the lock for this element
144 * or true, if no lock exists
145 * @param boolean only_once if true this is only done once
146 * f.e. only on first focus
148 function selectContent( element, lock, only_once ) {
149 if ( only_once && only_once_elements[element.name] ) {
153 only_once_elements[element.name] = true;
163 * Displays a confirmation box before to submit a "DROP/DELETE/ALTER" query.
164 * This function is called while clicking links
166 * @param object the link
167 * @param object the sql query to submit
169 * @return boolean whether to run the query or not
171 function confirmLink(theLink, theSqlQuery)
173 // Confirmation is not required in the configuration file
174 // or browser is Opera (crappy js implementation)
175 if (PMA_messages['strDoYouReally'] == '' || typeof(window.opera) != 'undefined') {
179 var is_confirmed = confirm(PMA_messages['strDoYouReally'] + ' :\n' + theSqlQuery);
181 if ( typeof(theLink.href) != 'undefined' ) {
182 theLink.href += '&is_js_confirmed=1';
183 } else if ( typeof(theLink.form) != 'undefined' ) {
184 theLink.form.action += '?is_js_confirmed=1';
189 } // end of the 'confirmLink()' function
193 * Displays a confirmation box before doing some action
195 * @param object the message to display
197 * @return boolean whether to run the query or not
199 * @todo used only by libraries/display_tbl.lib.php. figure out how it is used
200 * and replace with a jQuery equivalent
202 function confirmAction(theMessage)
204 // TODO: Confirmation is not required in the configuration file
205 // or browser is Opera (crappy js implementation)
206 if (typeof(window.opera) != 'undefined') {
210 var is_confirmed = confirm(theMessage);
213 } // end of the 'confirmAction()' function
217 * Displays an error message if a "DROP DATABASE" statement is submitted
218 * while it isn't allowed, else confirms a "DROP/DELETE/ALTER" query before
219 * sumitting it if required.
220 * This function is called by the 'checkSqlQuery()' js function.
222 * @param object the form
223 * @param object the sql query textarea
225 * @return boolean whether to run the query or not
227 * @see checkSqlQuery()
229 function confirmQuery(theForm1, sqlQuery1)
231 // Confirmation is not required in the configuration file
232 if (PMA_messages['strDoYouReally'] == '') {
236 // The replace function (js1.2) isn't supported
237 else if (typeof(sqlQuery1.value.replace) == 'undefined') {
241 // js1.2+ -> validation with regular expressions
243 // "DROP DATABASE" statement isn't allowed
244 if (PMA_messages['strNoDropDatabases'] != '') {
245 var drop_re = new RegExp('(^|;)\\s*DROP\\s+(IF EXISTS\\s+)?DATABASE\\s', 'i');
246 if (drop_re.test(sqlQuery1.value)) {
247 alert(PMA_messages['strNoDropDatabases']);
254 // Confirms a "DROP/DELETE/ALTER/TRUNCATE" statement
256 // TODO: find a way (if possible) to use the parser-analyser
257 // for this kind of verification
258 // For now, I just added a ^ to check for the statement at
259 // beginning of expression
261 var do_confirm_re_0 = new RegExp('^\\s*DROP\\s+(IF EXISTS\\s+)?(TABLE|DATABASE|PROCEDURE)\\s', 'i');
262 var do_confirm_re_1 = new RegExp('^\\s*ALTER\\s+TABLE\\s+((`[^`]+`)|([A-Za-z0-9_$]+))\\s+DROP\\s', 'i');
263 var do_confirm_re_2 = new RegExp('^\\s*DELETE\\s+FROM\\s', 'i');
264 var do_confirm_re_3 = new RegExp('^\\s*TRUNCATE\\s', 'i');
266 if (do_confirm_re_0.test(sqlQuery1.value)
267 || do_confirm_re_1.test(sqlQuery1.value)
268 || do_confirm_re_2.test(sqlQuery1.value)
269 || do_confirm_re_3.test(sqlQuery1.value)) {
270 var message = (sqlQuery1.value.length > 100)
271 ? sqlQuery1.value.substr(0, 100) + '\n ...'
273 var is_confirmed = confirm(PMA_messages['strDoYouReally'] + ' :\n' + message);
274 // statement is confirmed -> update the
275 // "is_js_confirmed" form field so the confirm test won't be
276 // run on the server side and allows to submit the form
278 theForm1.elements['is_js_confirmed'].value = 1;
281 // statement is rejected -> do not submit the form
286 } // end if (handle confirm box result)
287 } // end if (display confirm box)
288 } // end confirmation stuff
291 } // end of the 'confirmQuery()' function
295 * Displays a confirmation box before disabling the BLOB repository for a given database.
296 * This function is called while clicking links
298 * @param object the database
300 * @return boolean whether to disable the repository or not
302 function confirmDisableRepository(theDB)
304 // Confirmation is not required in the configuration file
305 // or browser is Opera (crappy js implementation)
306 if (PMA_messages['strDoYouReally'] == '' || typeof(window.opera) != 'undefined') {
310 var is_confirmed = confirm(PMA_messages['strBLOBRepositoryDisableStrongWarning'] + '\n' + PMA_messages['strBLOBRepositoryDisableAreYouSure']);
313 } // end of the 'confirmDisableBLOBRepository()' function
317 * Displays an error message if the user submitted the sql query form with no
318 * sql query, else checks for "DROP/DELETE/ALTER" statements
320 * @param object the form
322 * @return boolean always false
324 * @see confirmQuery()
326 function checkSqlQuery(theForm)
328 var sqlQuery = theForm.elements['sql_query'];
331 // The replace function (js1.2) isn't supported -> basic tests
332 if (typeof(sqlQuery.value.replace) == 'undefined') {
333 isEmpty = (sqlQuery.value == '') ? 1 : 0;
334 if (isEmpty && typeof(theForm.elements['sql_file']) != 'undefined') {
335 isEmpty = (theForm.elements['sql_file'].value == '') ? 1 : 0;
337 if (isEmpty && typeof(theForm.elements['sql_localfile']) != 'undefined') {
338 isEmpty = (theForm.elements['sql_localfile'].value == '') ? 1 : 0;
340 if (isEmpty && typeof(theForm.elements['id_bookmark']) != 'undefined') {
341 isEmpty = (theForm.elements['id_bookmark'].value == null || theForm.elements['id_bookmark'].value == '');
344 // js1.2+ -> validation with regular expressions
346 var space_re = new RegExp('\\s+');
347 if (typeof(theForm.elements['sql_file']) != 'undefined' &&
348 theForm.elements['sql_file'].value.replace(space_re, '') != '') {
351 if (typeof(theForm.elements['sql_localfile']) != 'undefined' &&
352 theForm.elements['sql_localfile'].value.replace(space_re, '') != '') {
355 if (isEmpty && typeof(theForm.elements['id_bookmark']) != 'undefined' &&
356 (theForm.elements['id_bookmark'].value != null || theForm.elements['id_bookmark'].value != '') &&
357 theForm.elements['id_bookmark'].selectedIndex != 0
361 // Checks for "DROP/DELETE/ALTER" statements
362 if (sqlQuery.value.replace(space_re, '') != '') {
363 if (confirmQuery(theForm, sqlQuery)) {
375 alert(PMA_messages['strFormEmpty']);
381 } // end of the 'checkSqlQuery()' function
383 // Global variable row_class is set to even
384 var row_class = 'even';
387 * Generates a row dynamically in the differences table displaying
388 * the complete statistics of difference in table like number of
389 * rows to be updated, number of rows to be inserted, number of
390 * columns to be added, number of columns to be removed, etc.
392 * @param index index of matching table
393 * @param update_size number of rows/column to be updated
394 * @param insert_size number of rows/coulmns to be inserted
395 * @param remove_size number of columns to be removed
396 * @param insert_index number of indexes to be inserted
397 * @param remove_index number of indexes to be removed
398 * @param img_obj image object
399 * @param table_name name of the table
402 function showDetails(i, update_size, insert_size, remove_size, insert_index, remove_index, img_obj, table_name)
404 // The path of the image is split to facilitate comparison
405 var relative_path = (img_obj.src).split("themes/");
407 // The image source is changed when the showDetails function is called.
408 if (relative_path[1] == 'original/img/new_data_hovered.jpg') {
409 img_obj.src = "./themes/original/img/new_data_selected_hovered.jpg";
410 img_obj.alt = PMA_messages['strClickToUnselect']; //only for IE browser
411 } else if (relative_path[1] == 'original/img/new_struct_hovered.jpg') {
412 img_obj.src = "./themes/original/img/new_struct_selected_hovered.jpg";
413 img_obj.alt = PMA_messages['strClickToUnselect'];
414 } else if (relative_path[1] == 'original/img/new_struct_selected_hovered.jpg') {
415 img_obj.src = "./themes/original/img/new_struct_hovered.jpg";
416 img_obj.alt = PMA_messages['strClickToSelect'];
417 } else if (relative_path[1] == 'original/img/new_data_selected_hovered.jpg') {
418 img_obj.src = "./themes/original/img/new_data_hovered.jpg";
419 img_obj.alt = PMA_messages['strClickToSelect'];
422 var div = document.getElementById("list");
423 var table = div.getElementsByTagName("table")[0];
424 var table_body = table.getElementsByTagName("tbody")[0];
426 //Global variable row_class is being used
427 if (row_class == 'even') {
432 // If the red or green button against a table name is pressed then append a new row to show the details of differences of this table.
433 if ((relative_path[1] != 'original/img/new_struct_selected_hovered.jpg') && (relative_path[1] != 'original/img/new_data_selected_hovered.jpg')) {
435 var newRow = document.createElement("tr");
436 newRow.setAttribute("class", row_class);
437 newRow.className = row_class;
438 // Id assigned to this row element is same as the index of this table name in the matching_tables/source_tables_uncommon array
439 newRow.setAttribute("id" , i);
441 var table_name_cell = document.createElement("td");
442 table_name_cell.align = "center";
443 table_name_cell.innerHTML = table_name ;
445 newRow.appendChild(table_name_cell);
447 var create_table = document.createElement("td");
448 create_table.align = "center";
450 var add_cols = document.createElement("td");
451 add_cols.align = "center";
453 var remove_cols = document.createElement("td");
454 remove_cols.align = "center";
456 var alter_cols = document.createElement("td");
457 alter_cols.align = "center";
459 var add_index = document.createElement("td");
460 add_index.align = "center";
462 var delete_index = document.createElement("td");
463 delete_index.align = "center";
465 var update_rows = document.createElement("td");
466 update_rows.align = "center";
468 var insert_rows = document.createElement("td");
469 insert_rows.align = "center";
471 var tick_image = document.createElement("img");
472 tick_image.src = "./themes/original/img/s_success.png";
474 if (update_size == '' && insert_size == '' && remove_size == '') {
476 This is the case when the table needs to be created in target database.
478 create_table.appendChild(tick_image);
479 add_cols.innerHTML = "--";
480 remove_cols.innerHTML = "--";
481 alter_cols.innerHTML = "--";
482 delete_index.innerHTML = "--";
483 add_index.innerHTML = "--";
484 update_rows.innerHTML = "--";
485 insert_rows.innerHTML = "--";
487 newRow.appendChild(create_table);
488 newRow.appendChild(add_cols);
489 newRow.appendChild(remove_cols);
490 newRow.appendChild(alter_cols);
491 newRow.appendChild(delete_index);
492 newRow.appendChild(add_index);
493 newRow.appendChild(update_rows);
494 newRow.appendChild(insert_rows);
496 } else if (update_size == '' && remove_size == '') {
498 This is the case when data difference is displayed in the
499 table which is present in source but absent from target database
501 create_table.innerHTML = "--";
502 add_cols.innerHTML = "--";
503 remove_cols.innerHTML = "--";
504 alter_cols.innerHTML = "--";
505 add_index.innerHTML = "--";
506 delete_index.innerHTML = "--";
507 update_rows.innerHTML = "--";
508 insert_rows.innerHTML = insert_size;
510 newRow.appendChild(create_table);
511 newRow.appendChild(add_cols);
512 newRow.appendChild(remove_cols);
513 newRow.appendChild(alter_cols);
514 newRow.appendChild(delete_index);
515 newRow.appendChild(add_index);
516 newRow.appendChild(update_rows);
517 newRow.appendChild(insert_rows);
519 } else if (remove_size == '') {
521 This is the case when data difference between matching_tables is displayed.
523 create_table.innerHTML = "--";
524 add_cols.innerHTML = "--";
525 remove_cols.innerHTML = "--";
526 alter_cols.innerHTML = "--";
527 add_index.innerHTML = "--";
528 delete_index.innerHTML = "--";
529 update_rows.innerHTML = update_size;
530 insert_rows.innerHTML = insert_size;
532 newRow.appendChild(create_table);
533 newRow.appendChild(add_cols);
534 newRow.appendChild(remove_cols);
535 newRow.appendChild(alter_cols);
536 newRow.appendChild(delete_index);
537 newRow.appendChild(add_index);
538 newRow.appendChild(update_rows);
539 newRow.appendChild(insert_rows);
543 This is the case when structure difference between matching_tables id displayed
545 create_table.innerHTML = "--";
546 add_cols.innerHTML = insert_size;
547 remove_cols.innerHTML = remove_size;
548 alter_cols.innerHTML = update_size;
549 delete_index.innerHTML = remove_index;
550 add_index.innerHTML = insert_index;
551 update_rows.innerHTML = "--";
552 insert_rows.innerHTML = "--";
554 newRow.appendChild(create_table);
555 newRow.appendChild(add_cols);
556 newRow.appendChild(remove_cols);
557 newRow.appendChild(alter_cols);
558 newRow.appendChild(delete_index);
559 newRow.appendChild(add_index);
560 newRow.appendChild(update_rows);
561 newRow.appendChild(insert_rows);
563 table_body.appendChild(newRow);
565 } else if ((relative_path[1] != 'original/img/new_struct_hovered.jpg') && (relative_path[1] != 'original/img/new_data_hovered.jpg')) {
566 //The case when the row showing the details need to be removed from the table i.e. the difference button is deselected now.
567 var table_rows = table_body.getElementsByTagName("tr");
570 for (j=0; j < table_rows.length; j++)
572 if (table_rows[j].id == i) {
574 table_rows[j].parentNode.removeChild(table_rows[j]);
577 //The table row css is being adjusted. Class "odd" for odd rows and "even" for even rows should be maintained.
578 for(index = 0; index < table_rows.length; index++)
580 row_class_element = table_rows[index].getAttribute('class');
581 if (row_class_element == "even") {
582 table_rows[index].setAttribute("class","odd"); // for Mozilla firefox
583 table_rows[index].className = "odd"; // for IE browser
585 table_rows[index].setAttribute("class","even"); // for Mozilla firefox
586 table_rows[index].className = "even"; // for IE browser
593 * Changes the image on hover effects
595 * @param img_obj the image object whose source needs to be changed
598 function change_Image(img_obj)
600 var relative_path = (img_obj.src).split("themes/");
602 if (relative_path[1] == 'original/img/new_data.jpg') {
603 img_obj.src = "./themes/original/img/new_data_hovered.jpg";
604 } else if (relative_path[1] == 'original/img/new_struct.jpg') {
605 img_obj.src = "./themes/original/img/new_struct_hovered.jpg";
606 } else if (relative_path[1] == 'original/img/new_struct_hovered.jpg') {
607 img_obj.src = "./themes/original/img/new_struct.jpg";
608 } else if (relative_path[1] == 'original/img/new_data_hovered.jpg') {
609 img_obj.src = "./themes/original/img/new_data.jpg";
610 } else if (relative_path[1] == 'original/img/new_data_selected.jpg') {
611 img_obj.src = "./themes/original/img/new_data_selected_hovered.jpg";
612 } else if(relative_path[1] == 'original/img/new_struct_selected.jpg') {
613 img_obj.src = "./themes/original/img/new_struct_selected_hovered.jpg";
614 } else if (relative_path[1] == 'original/img/new_struct_selected_hovered.jpg') {
615 img_obj.src = "./themes/original/img/new_struct_selected.jpg";
616 } else if (relative_path[1] == 'original/img/new_data_selected_hovered.jpg') {
617 img_obj.src = "./themes/original/img/new_data_selected.jpg";
622 * Generates the URL containing the list of selected table ids for synchronization and
623 * a variable checked for confirmation of deleting previous rows from target tables
625 * @param token the token generated for each PMA form
628 function ApplySelectedChanges(token)
630 var div = document.getElementById("list");
631 var table = div.getElementsByTagName('table')[0];
632 var table_body = table.getElementsByTagName('tbody')[0];
633 // Get all the rows from the details table
634 var table_rows = table_body.getElementsByTagName('tr');
635 var x = table_rows.length;
638 Append the token at the beginning of the query string followed by
639 Table_ids that shows that "Apply Selected Changes" button is pressed
641 var append_string = "?token="+token+"&Table_ids="+1;
643 append_string += "&";
644 append_string += i+"="+table_rows[i].id;
647 // Getting the value of checkbox delete_rows
648 var checkbox = document.getElementById("delete_rows");
649 if (checkbox.checked){
650 append_string += "&checked=true";
652 append_string += "&checked=false";
654 //Appending the token and list of table ids in the URL
655 location.href += token;
656 location.href += append_string;
660 * Displays an error message if any text field
661 * is left empty other than the port field.
663 * @param string the form name
664 * @param object the form
666 * @return boolean whether the form field is empty or not
668 function validateConnection(form_name, form_obj)
671 var src_hostfilled = true;
672 var trg_hostfilled = true;
674 for (var i=1; i<form_name.elements.length; i++)
676 // All the text fields are checked excluding the port field because the default port can be used.
677 if ((form_name.elements[i].type == 'text') && (form_name.elements[i].name != 'src_port') && (form_name.elements[i].name != 'trg_port')) {
678 check = emptyFormElements(form_obj, form_name.elements[i].name);
680 element = form_name.elements[i].name;
681 if (form_name.elements[i].name == 'src_host') {
682 src_hostfilled = false;
685 if (form_name.elements[i].name == 'trg_host') {
686 trg_hostfilled = false;
689 if ((form_name.elements[i].name == 'src_socket' && src_hostfilled==false) || (form_name.elements[i].name == 'trg_socket' && trg_hostfilled==false))
699 alert(PMA_messages['strFormEmpty']);
706 * Check if a form's element is empty.
707 * An element containing only spaces is also considered empty
709 * @param object the form
710 * @param string the name of the form field to put the focus on
712 * @return boolean whether the form field is empty or not
714 function emptyCheckTheField(theForm, theFieldName)
717 var theField = theForm.elements[theFieldName];
718 // Whether the replace function (js1.2) is supported or not
719 var isRegExp = (typeof(theField.value.replace) != 'undefined');
722 isEmpty = (theField.value == '') ? 1 : 0;
724 var space_re = new RegExp('\\s+');
725 isEmpty = (theField.value.replace(space_re, '') == '') ? 1 : 0;
729 } // end of the 'emptyCheckTheField()' function
733 * Check whether a form field is empty or not
735 * @param object the form
736 * @param string the name of the form field to put the focus on
738 * @return boolean whether the form field is empty or not
740 function emptyFormElements(theForm, theFieldName)
742 var theField = theForm.elements[theFieldName];
743 var isEmpty = emptyCheckTheField(theForm, theFieldName);
747 } // end of the 'emptyFormElements()' function
751 * Ensures a value submitted in a form is numeric and is in a range
753 * @param object the form
754 * @param string the name of the form field to check
755 * @param integer the minimum authorized value
756 * @param integer the maximum authorized value
758 * @return boolean whether a valid number has been submitted or not
760 function checkFormElementInRange(theForm, theFieldName, message, min, max)
762 var theField = theForm.elements[theFieldName];
763 var val = parseInt(theField.value);
765 if (typeof(min) == 'undefined') {
768 if (typeof(max) == 'undefined') {
769 max = Number.MAX_VALUE;
775 alert(PMA_messages['strNotNumber']);
779 // It's a number but it is not between min and max
780 else if (val < min || val > max) {
782 alert(message.replace('%d', val));
786 // It's a valid number
788 theField.value = val;
792 } // end of the 'checkFormElementInRange()' function
795 function checkTableEditForm(theForm, fieldsCnt)
797 // TODO: avoid sending a message if user just wants to add a line
798 // on the form but has not completed at least one field name
800 var atLeastOneField = 0;
801 var i, elm, elm2, elm3, val, id;
803 for (i=0; i<fieldsCnt; i++)
805 id = "#field_" + i + "_2";
808 if (val == 'VARCHAR' || val == 'CHAR' || val == 'BIT' || val == 'VARBINARY' || val == 'BINARY') {
809 elm2 = $("#field_" + i + "_3");
810 val = parseInt(elm2.val());
811 elm3 = $("#field_" + i + "_1");
812 if (isNaN(val) && elm3.val() != "") {
814 alert(PMA_messages['strNotNumber']);
820 if (atLeastOneField == 0) {
821 id = "field_" + i + "_1";
822 if (!emptyCheckTheField(theForm, id)) {
827 if (atLeastOneField == 0) {
828 var theField = theForm.elements["field_0_1"];
829 alert(PMA_messages['strFormEmpty']);
835 } // enf of the 'checkTableEditForm()' function
839 * Ensures the choice between 'transmit', 'zipped', 'gzipped' and 'bzipped'
840 * checkboxes is consistant
842 * @param object the form
843 * @param string a code for the action that causes this function to be run
845 * @return boolean always true
847 function checkTransmitDump(theForm, theAction)
849 var formElts = theForm.elements;
851 // 'zipped' option has been checked
852 if (theAction == 'zip' && formElts['zip'].checked) {
853 if (!formElts['asfile'].checked) {
854 theForm.elements['asfile'].checked = true;
856 if (typeof(formElts['gzip']) != 'undefined' && formElts['gzip'].checked) {
857 theForm.elements['gzip'].checked = false;
859 if (typeof(formElts['bzip']) != 'undefined' && formElts['bzip'].checked) {
860 theForm.elements['bzip'].checked = false;
863 // 'gzipped' option has been checked
864 else if (theAction == 'gzip' && formElts['gzip'].checked) {
865 if (!formElts['asfile'].checked) {
866 theForm.elements['asfile'].checked = true;
868 if (typeof(formElts['zip']) != 'undefined' && formElts['zip'].checked) {
869 theForm.elements['zip'].checked = false;
871 if (typeof(formElts['bzip']) != 'undefined' && formElts['bzip'].checked) {
872 theForm.elements['bzip'].checked = false;
875 // 'bzipped' option has been checked
876 else if (theAction == 'bzip' && formElts['bzip'].checked) {
877 if (!formElts['asfile'].checked) {
878 theForm.elements['asfile'].checked = true;
880 if (typeof(formElts['zip']) != 'undefined' && formElts['zip'].checked) {
881 theForm.elements['zip'].checked = false;
883 if (typeof(formElts['gzip']) != 'undefined' && formElts['gzip'].checked) {
884 theForm.elements['gzip'].checked = false;
887 // 'transmit' option has been unchecked
888 else if (theAction == 'transmit' && !formElts['asfile'].checked) {
889 if (typeof(formElts['zip']) != 'undefined' && formElts['zip'].checked) {
890 theForm.elements['zip'].checked = false;
892 if ((typeof(formElts['gzip']) != 'undefined' && formElts['gzip'].checked)) {
893 theForm.elements['gzip'].checked = false;
895 if ((typeof(formElts['bzip']) != 'undefined' && formElts['bzip'].checked)) {
896 theForm.elements['bzip'].checked = false;
901 } // end of the 'checkTransmitDump()' function
903 $(document).ready(function() {
905 * Row marking in horizontal mode (use "live" so that it works also for
906 * next pages reached via AJAX); a tr may have the class noclick to remove
909 $('tr.odd:not(.noclick), tr.even:not(.noclick)').live('click',function(e) {
910 //do not trigger when clicked on anchor or inside input element (in inline editing mode) with exception of the first checkbox
911 if (!jQuery(e.target).is('a, a *, :input:not([name^="rows_to_delete"])')) {
913 $tr.toggleClass('marked');
914 $tr.children().toggleClass('marked');
919 * Add a date/time picker to each element that needs it
921 $('.datefield, .datetimefield').each(function() {
922 PMA_addDatepicker($(this));
927 * Row highlighting in horizontal mode (use "live"
928 * so that it works also for pages reached via AJAX)
930 $(document).ready(function() {
931 $('tr.odd, tr.even').live('hover',function() {
933 $tr.toggleClass('hover');
934 $tr.children().toggleClass('hover');
939 * This array is used to remember mark status of rows in browse mode
941 var marked_row = new Array;
944 * marks all rows and selects its first checkbox inside the given element
945 * the given element is usaly a table or a div containing the table or tables
947 * @param container DOM element
949 function markAllRows( container_id ) {
951 $("#"+container_id).find("input:checkbox:enabled").attr('checked', 'checked')
952 .parents("tr").addClass("marked");
957 * marks all rows and selects its first checkbox inside the given element
958 * the given element is usaly a table or a div containing the table or tables
960 * @param container DOM element
962 function unMarkAllRows( container_id ) {
964 $("#"+container_id).find("input:checkbox:enabled").removeAttr('checked')
965 .parents("tr").removeClass("marked");
970 * Checks/unchecks all checkbox in given conainer (f.e. a form, fieldset or div)
972 * @param string container_id the container id
973 * @param boolean state new value for checkbox (true or false)
974 * @return boolean always true
976 function setCheckboxes( container_id, state ) {
979 $("#"+container_id).find("input:checkbox").attr('checked', 'checked');
982 $("#"+container_id).find("input:checkbox").removeAttr('checked');
986 } // end of the 'setCheckboxes()' function
989 * Checks/unchecks all options of a <select> element
991 * @param string the form name
992 * @param string the element name
993 * @param boolean whether to check or to uncheck the element
995 * @return boolean always true
997 function setSelectOptions(the_form, the_select, do_check)
1001 $("form[name='"+ the_form +"']").find("select[name='"+the_select+"']").find("option").attr('selected', 'selected');
1004 $("form[name='"+ the_form +"']").find("select[name="+the_select+"]").find("option").removeAttr('selected');
1007 } // end of the 'setSelectOptions()' function
1011 * Create quick sql statements.
1014 function insertQuery(queryType) {
1015 var myQuery = document.sqlform.sql_query;
1016 var myListBox = document.sqlform.dummy;
1018 var table = document.sqlform.table.value;
1020 if (myListBox.options.length > 0) {
1021 sql_box_locked = true;
1026 for (var i=0; i < myListBox.options.length; i++) {
1033 chaineAj += myListBox.options[i].value;
1034 valDis += "[value-" + NbSelect + "]";
1035 editDis += myListBox.options[i].value + "=[value-" + NbSelect + "]";
1037 if (queryType == "selectall") {
1038 query = "SELECT * FROM `" + table + "` WHERE 1";
1039 } else if (queryType == "select") {
1040 query = "SELECT " + chaineAj + " FROM `" + table + "` WHERE 1";
1041 } else if (queryType == "insert") {
1042 query = "INSERT INTO `" + table + "`(" + chaineAj + ") VALUES (" + valDis + ")";
1043 } else if (queryType == "update") {
1044 query = "UPDATE `" + table + "` SET " + editDis + " WHERE 1";
1045 } else if(queryType == "delete") {
1046 query = "DELETE FROM `" + table + "` WHERE 1";
1048 document.sqlform.sql_query.value = query;
1049 sql_box_locked = false;
1055 * Inserts multiple fields.
1058 function insertValueQuery() {
1059 var myQuery = document.sqlform.sql_query;
1060 var myListBox = document.sqlform.dummy;
1062 if(myListBox.options.length > 0) {
1063 sql_box_locked = true;
1066 for(var i=0; i<myListBox.options.length; i++) {
1067 if (myListBox.options[i].selected){
1071 chaineAj += myListBox.options[i].value;
1076 if (document.selection) {
1078 sel = document.selection.createRange();
1079 sel.text = chaineAj;
1080 document.sqlform.insert.focus();
1082 //MOZILLA/NETSCAPE support
1083 else if (document.sqlform.sql_query.selectionStart || document.sqlform.sql_query.selectionStart == "0") {
1084 var startPos = document.sqlform.sql_query.selectionStart;
1085 var endPos = document.sqlform.sql_query.selectionEnd;
1086 var chaineSql = document.sqlform.sql_query.value;
1088 myQuery.value = chaineSql.substring(0, startPos) + chaineAj + chaineSql.substring(endPos, chaineSql.length);
1090 myQuery.value += chaineAj;
1092 sql_box_locked = false;
1097 * listbox redirection
1099 function goToUrl(selObj, goToLocation) {
1100 eval("document.location.href = '" + goToLocation + "pos=" + selObj.options[selObj.selectedIndex].value + "'");
1106 function getElement(e,f){
1107 if(document.layers){
1109 if(f.document.layers[e]) {
1110 return f.document.layers[e];
1112 for(W=0;W<f.document.layers.length;W++) {
1113 return(getElement(e,f.document.layers[W]));
1117 return document.all[e];
1119 return document.getElementById(e);
1123 * Refresh the WYSIWYG scratchboard after changes have been made
1125 function refreshDragOption(e) {
1126 var elm = $('#' + e);
1127 if (elm.css('visibility') == 'visible') {
1134 * Refresh/resize the WYSIWYG scratchboard
1136 function refreshLayout() {
1137 var elm = $('#pdflayout')
1138 var orientation = $('#orientation_opt').val();
1139 if($('#paper_opt').length==1){
1140 var paper = $('#paper_opt').val();
1144 if (orientation == 'P') {
1151 elm.css('width', pdfPaperSize(paper, posa) + 'px');
1152 elm.css('height', pdfPaperSize(paper, posb) + 'px');
1156 * Show/hide the WYSIWYG scratchboard
1158 function ToggleDragDrop(e) {
1159 var elm = $('#' + e);
1160 if (elm.css('visibility') == 'hidden') {
1161 PDFinit(); /* Defined in pdf_pages.php */
1162 elm.css('visibility', 'visible');
1163 elm.css('display', 'block');
1164 $('#showwysiwyg').val('1')
1166 elm.css('visibility', 'hidden');
1167 elm.css('display', 'none');
1168 $('#showwysiwyg').val('0')
1173 * PDF scratchboard: When a position is entered manually, update
1174 * the fields inside the scratchboard.
1176 function dragPlace(no, axis, value) {
1177 var elm = $('#table_' + no);
1179 elm.css('left', value + 'px');
1181 elm.css('top', value + 'px');
1186 * Returns paper sizes for a given format
1188 function pdfPaperSize(format, axis) {
1189 switch (format.toUpperCase()) {
1191 if (axis == 'x') return 4767.87; else return 6740.79;
1194 if (axis == 'x') return 3370.39; else return 4767.87;
1197 if (axis == 'x') return 2383.94; else return 3370.39;
1200 if (axis == 'x') return 1683.78; else return 2383.94;
1203 if (axis == 'x') return 1190.55; else return 1683.78;
1206 if (axis == 'x') return 841.89; else return 1190.55;
1209 if (axis == 'x') return 595.28; else return 841.89;
1212 if (axis == 'x') return 419.53; else return 595.28;
1215 if (axis == 'x') return 297.64; else return 419.53;
1218 if (axis == 'x') return 209.76; else return 297.64;
1221 if (axis == 'x') return 147.40; else return 209.76;
1224 if (axis == 'x') return 104.88; else return 147.40;
1227 if (axis == 'x') return 73.70; else return 104.88;
1230 if (axis == 'x') return 2834.65; else return 4008.19;
1233 if (axis == 'x') return 2004.09; else return 2834.65;
1236 if (axis == 'x') return 1417.32; else return 2004.09;
1239 if (axis == 'x') return 1000.63; else return 1417.32;
1242 if (axis == 'x') return 708.66; else return 1000.63;
1245 if (axis == 'x') return 498.90; else return 708.66;
1248 if (axis == 'x') return 354.33; else return 498.90;
1251 if (axis == 'x') return 249.45; else return 354.33;
1254 if (axis == 'x') return 175.75; else return 249.45;
1257 if (axis == 'x') return 124.72; else return 175.75;
1260 if (axis == 'x') return 87.87; else return 124.72;
1263 if (axis == 'x') return 2599.37; else return 3676.54;
1266 if (axis == 'x') return 1836.85; else return 2599.37;
1269 if (axis == 'x') return 1298.27; else return 1836.85;
1272 if (axis == 'x') return 918.43; else return 1298.27;
1275 if (axis == 'x') return 649.13; else return 918.43;
1278 if (axis == 'x') return 459.21; else return 649.13;
1281 if (axis == 'x') return 323.15; else return 459.21;
1284 if (axis == 'x') return 229.61; else return 323.15;
1287 if (axis == 'x') return 161.57; else return 229.61;
1290 if (axis == 'x') return 113.39; else return 161.57;
1293 if (axis == 'x') return 79.37; else return 113.39;
1296 if (axis == 'x') return 2437.80; else return 3458.27;
1299 if (axis == 'x') return 1729.13; else return 2437.80;
1302 if (axis == 'x') return 1218.90; else return 1729.13;
1305 if (axis == 'x') return 864.57; else return 1218.90;
1308 if (axis == 'x') return 609.45; else return 864.57;
1311 if (axis == 'x') return 2551.18; else return 3628.35;
1314 if (axis == 'x') return 1814.17; else return 2551.18;
1317 if (axis == 'x') return 1275.59; else return 1814.17;
1320 if (axis == 'x') return 907.09; else return 1275.59;
1323 if (axis == 'x') return 637.80; else return 907.09;
1326 if (axis == 'x') return 612.00; else return 792.00;
1329 if (axis == 'x') return 612.00; else return 1008.00;
1332 if (axis == 'x') return 521.86; else return 756.00;
1335 if (axis == 'x') return 612.00; else return 936.00;
1343 * for playing media from the BLOB repository
1346 * @param var url_params main purpose is to pass the token
1347 * @param var bs_ref BLOB repository reference
1348 * @param var m_type type of BLOB repository media
1349 * @param var w_width width of popup window
1350 * @param var w_height height of popup window
1352 function popupBSMedia(url_params, bs_ref, m_type, is_cust_type, w_width, w_height)
1354 // if width not specified, use default
1355 if (w_width == undefined)
1358 // if height not specified, use default
1359 if (w_height == undefined)
1362 // open popup window (for displaying video/playing audio)
1363 var mediaWin = window.open('bs_play_media.php?' + url_params + '&bs_reference=' + bs_ref + '&media_type=' + m_type + '&custom_type=' + is_cust_type, 'viewBSMedia', 'width=' + w_width + ', height=' + w_height + ', resizable=1, scrollbars=1, status=0');
1367 * popups a request for changing MIME types for files in the BLOB repository
1369 * @param var db database name
1370 * @param var table table name
1371 * @param var reference BLOB repository reference
1372 * @param var current_mime_type current MIME type associated with BLOB repository reference
1374 function requestMIMETypeChange(db, table, reference, current_mime_type)
1376 // no mime type specified, set to default (nothing)
1377 if (undefined == current_mime_type)
1378 current_mime_type = "";
1380 // prompt user for new mime type
1381 var new_mime_type = prompt("Enter custom MIME type", current_mime_type);
1383 // if new mime_type is specified and is not the same as the previous type, request for mime type change
1384 if (new_mime_type && new_mime_type != current_mime_type)
1385 changeMIMEType(db, table, reference, new_mime_type);
1389 * changes MIME types for files in the BLOB repository
1391 * @param var db database name
1392 * @param var table table name
1393 * @param var reference BLOB repository reference
1394 * @param var mime_type new MIME type to be associated with BLOB repository reference
1396 function changeMIMEType(db, table, reference, mime_type)
1398 // specify url and parameters for jQuery POST
1399 var mime_chg_url = 'bs_change_mime_type.php';
1400 var params = {bs_db: db, bs_table: table, bs_reference: reference, bs_new_mime_type: mime_type};
1403 jQuery.post(mime_chg_url, params);
1407 * Jquery Coding for inline editing SQL_QUERY
1409 $(document).ready(function(){
1410 var oldText,db,table,token,sql_query;
1411 oldText=$(".inner_sql").html();
1412 $("#inline_edit").click(function(){
1413 db=$("input[name='db']").val();
1414 table=$("input[name='table']").val();
1415 token=$("input[name='token']").val();
1416 sql_query=$("input[name='sql_query']").val();
1417 $(".inner_sql").replaceWith("<textarea name=\"sql_query_edit\" id=\"sql_query_edit\">"+ sql_query +"</textarea><input type=\"button\" id=\"btnSave\" value=\"" + PMA_messages['strGo'] + "\"><input type=\"button\" id=\"btnDiscard\" value=\"" + PMA_messages['strCancel'] + "\">");
1421 $("#btnSave").live("click",function(){
1422 window.location.replace("import.php?db=" + db +"&table=" + table + "&sql_query=" + $("#sql_query_edit").val()+"&show_query=1&token=" + token + "");
1425 $("#btnDiscard").live("click",function(){
1426 $(".sql").html("<span class=\"syntax\"><span class=\"inner_sql\">" + oldText + "</span></span>");
1429 $('.sqlbutton').click(function(evt){
1430 insertQuery(evt.target.id);
1434 $("#export_type").change(function(){
1435 if($("#export_type").val()=='svg'){
1436 $("#show_grid_opt").attr("disabled","disabled");
1437 $("#orientation_opt").attr("disabled","disabled");
1438 $("#with_doc").attr("disabled","disabled");
1439 $("#show_table_dim_opt").removeAttr("disabled");
1440 $("#all_table_same_wide").removeAttr("disabled");
1441 $("#paper_opt").removeAttr("disabled","disabled");
1442 $("#show_color_opt").removeAttr("disabled","disabled");
1443 //$(this).css("background-color","yellow");
1444 }else if($("#export_type").val()=='dia'){
1445 $("#show_grid_opt").attr("disabled","disabled");
1446 $("#with_doc").attr("disabled","disabled");
1447 $("#show_table_dim_opt").attr("disabled","disabled");
1448 $("#all_table_same_wide").attr("disabled","disabled");
1449 $("#paper_opt").removeAttr("disabled","disabled");
1450 $("#show_color_opt").removeAttr("disabled","disabled");
1451 $("#orientation_opt").removeAttr("disabled","disabled");
1452 }else if($("#export_type").val()=='eps'){
1453 $("#show_grid_opt").attr("disabled","disabled");
1454 $("#orientation_opt").removeAttr("disabled");
1455 $("#with_doc").attr("disabled","disabled");
1456 $("#show_table_dim_opt").attr("disabled","disabled");
1457 $("#all_table_same_wide").attr("disabled","disabled");
1458 $("#paper_opt").attr("disabled","disabled");
1459 $("#show_color_opt").attr("disabled","disabled");
1461 }else if($("#export_type").val()=='pdf'){
1462 $("#show_grid_opt").removeAttr("disabled");
1463 $("#orientation_opt").removeAttr("disabled");
1464 $("#with_doc").removeAttr("disabled","disabled");
1465 $("#show_table_dim_opt").removeAttr("disabled","disabled");
1466 $("#all_table_same_wide").removeAttr("disabled","disabled");
1467 $("#paper_opt").removeAttr("disabled","disabled");
1468 $("#show_color_opt").removeAttr("disabled","disabled");
1474 $('#sqlquery').focus();
1475 if ($('#input_username')) {
1476 if ($('#input_username').val() == '') {
1477 $('#input_username').focus();
1479 $('#input_password').focus();
1485 * Function to process the plain HTML response from an Ajax request. Inserts
1486 * the various HTML divisions from the response at the proper locations. The
1487 * array relates the divisions to be inserted to their placeholders.
1489 * @param var divisions_map an associative array of id names
1492 * PMA_ajaxInsertResponse({'resultsTable':'resultsTable_response',
1493 * 'profilingData':'profilingData_response'});
1498 function PMA_ajaxInsertResponse(divisions_map) {
1499 $.each(divisions_map, function(key, value) {
1500 var content_div = '#'+value;
1501 var target_div = '#'+key;
1502 var content = $(content_div).html();
1504 //replace content of target_div with that from the response
1505 $(target_div).html(content);
1510 * Show a message on the top of the page for an Ajax request
1512 * @param var message string containing the message to be shown.
1513 * optional, defaults to 'Loading...'
1514 * @param var timeout number of milliseconds for the message to be visible
1515 * optional, defaults to 5000
1518 function PMA_ajaxShowMessage(message, timeout) {
1520 //Handle the case when a empty data.message is passed. We don't want the empty message
1526 * @var msg String containing the message that has to be displayed
1527 * @default PMA_messages['strLoading']
1530 var msg = PMA_messages['strLoading'];
1537 * @var timeout Number of milliseconds for which {@link msg} will be visible
1547 if( !ajax_message_init) {
1548 //For the first time this function is called, append a new div
1550 $('<div id="loading_parent"></div>')
1551 .insertBefore("#serverinfo");
1553 $('<span id="loading" class="ajax_notification"></span>')
1554 .appendTo("#loading_parent")
1556 .slideDown('medium')
1558 .slideUp('medium', function(){
1560 .html("") //Clear the message
1563 }, 'top.frame_content');
1564 ajax_message_init = true;
1567 //Otherwise, just show the div again after inserting the message
1571 .slideDown('medium')
1573 .slideUp('medium', function() {
1582 * Hides/shows the "Open in ENUM/SET editor" message, depending on the data type of the column currently selected
1584 function toggle_enum_notice(selectElement) {
1585 var enum_notice_id = selectElement.attr("id").split("_")[1];
1586 enum_notice_id += "_" + (parseInt(selectElement.attr("id").split("_")[2]) + 1);
1587 var selectedType = selectElement.attr("value");
1588 if (selectedType == "ENUM" || selectedType == "SET") {
1589 $("p[id='enum_notice_" + enum_notice_id + "']").show();
1591 $("p[id='enum_notice_" + enum_notice_id + "']").hide();
1596 * jQuery function that uses jQueryUI's dialogs to confirm with user. Does not
1597 * return a jQuery object yet and hence cannot be chained
1599 * @param string question
1600 * @param string url URL to be passed to the callbackFn to make
1602 * @param function callbackFn callback to execute after user clicks on OK
1605 jQuery.fn.PMA_confirm = function(question, url, callbackFn) {
1606 if (PMA_messages['strDoYouReally'] == '') {
1611 * @var button_options Object that stores the options passed to jQueryUI
1614 var button_options = {};
1615 button_options[PMA_messages['strOK']] = function(){
1616 $(this).dialog("close").remove();
1618 if($.isFunction(callbackFn)) {
1619 callbackFn.call(this, url);
1622 button_options[PMA_messages['strCancel']] = function() {$(this).dialog("close").remove();}
1624 $('<div id="confirm_dialog"></div>')
1626 .dialog({buttons: button_options});
1630 * jQuery function to sort a table's body after a new row has been appended to it.
1631 * Also fixes the even/odd classes of the table rows at the end.
1633 * @param string text_selector string to select the sortKey's text
1635 * @return jQuery Object for chaining purposes
1637 jQuery.fn.PMA_sort_table = function(text_selector) {
1638 return this.each(function() {
1641 * @var table_body Object referring to the table's <tbody> element
1643 var table_body = $(this);
1645 * @var rows Object referring to the collection of rows in {@link table_body}
1647 var rows = $(this).find('tr').get();
1649 //get the text of the field that we will sort by
1650 $.each(rows, function(index, row) {
1651 row.sortKey = $.trim($(row).find(text_selector).text().toLowerCase());
1654 //get the sorted order
1655 rows.sort(function(a,b) {
1656 if(a.sortKey < b.sortKey) {
1659 if(a.sortKey > b.sortKey) {
1665 //pull out each row from the table and then append it according to it's order
1666 $.each(rows, function(index, row) {
1667 $(table_body).append(row);
1671 //Re-check the classes of each row
1672 $(this).find('tr:odd')
1673 .removeClass('even').addClass('odd')
1676 .removeClass('odd').addClass('even');
1681 * jQuery coding for 'Create Table'. Used on db_operations.php,
1682 * db_structure.php and db_tracking.php (i.e., wherever
1683 * libraries/display_create_table.lib.php is used)
1685 * Attach Ajax Event handlers for Create Table
1687 $(document).ready(function() {
1690 * Attach event handler to the submit action of the create table minimal form
1691 * and retrieve the full table form and display it in a dialog
1693 * @uses PMA_ajaxShowMessage()
1695 $("#create_table_form_minimal.ajax").live('submit', function(event) {
1696 event.preventDefault();
1699 /* @todo Validate this form! */
1702 * @var button_options Object that stores the options passed to jQueryUI
1705 var button_options = {};
1706 // in the following function we need to use $(this)
1707 button_options[PMA_messages['strCancel']] = function() {$(this).dialog('close').remove();}
1709 var button_options_error = {};
1710 button_options_error[PMA_messages['strOK']] = function() {$(this).dialog('close').remove();}
1712 PMA_ajaxShowMessage();
1713 if (! $form.find('input:hidden').is('#ajax_request_hidden')) {
1714 $form.append('<input type="hidden" id="ajax_request_hidden" name="ajax_request" value="true" />');
1717 $.get($form.attr('action'), $form.serialize(), function(data) {
1718 //in the case of an error, show the error message returned.
1719 if (data.success != undefined && data.success == false) {
1720 $('<div id="create_table_dialog"></div>')
1723 title: PMA_messages['strCreateTable'],
1726 open: PMA_verifyTypeOfAllColumns,
1727 buttons : button_options_error
1728 })// end dialog options
1729 //remove the redundant [Back] link in the error message.
1730 .find('fieldset').remove();
1732 $('<div id="create_table_dialog"></div>')
1735 title: PMA_messages['strCreateTable'],
1738 open: PMA_verifyTypeOfAllColumns,
1739 buttons : button_options
1740 }); // end dialog options
1744 // empty table name and number of columns from the minimal form
1745 $form.find('input[name=table],input[name=num_fields]').val('');
1749 * Attach event handler for submission of create table form (save)
1751 * @uses PMA_ajaxShowMessage()
1752 * @uses $.PMA_sort_table()
1755 // .live() must be called after a selector, see http://api.jquery.com/live
1756 $("#create_table_form.ajax input[name=do_save_data]").live('click', function(event) {
1757 event.preventDefault();
1760 * @var the_form object referring to the create table form
1762 var $form = $("#create_table_form");
1764 PMA_ajaxShowMessage(PMA_messages['strProcessingRequest']);
1765 if (! $form.find('input:hidden').is('#ajax_request_hidden')) {
1766 $form.append('<input type="hidden" id="ajax_request_hidden" name="ajax_request" value="true" />');
1768 //User wants to submit the form
1769 $.post($form.attr('action'), $form.serialize() + "&do_save_data=" + $(this).val(), function(data) {
1770 if(data.success == true) {
1771 PMA_ajaxShowMessage(data.message);
1772 $("#create_table_dialog").dialog("close").remove();
1775 * @var tables_table Object referring to the <tbody> element that holds the list of tables
1777 var tables_table = $("#tablesForm").find("tbody").not("#tbl_summary_row");
1778 // this is the first table created in this db
1779 if (tables_table.length == 0) {
1780 if (window.parent && window.parent.frame_content) {
1781 window.parent.frame_content.location.reload();
1785 * @var curr_last_row Object referring to the last <tr> element in {@link tables_table}
1787 var curr_last_row = $(tables_table).find('tr:last');
1789 * @var curr_last_row_index_string String containing the index of {@link curr_last_row}
1791 var curr_last_row_index_string = $(curr_last_row).find('input:checkbox').attr('id').match(/\d+/)[0];
1793 * @var curr_last_row_index Index of {@link curr_last_row}
1795 var curr_last_row_index = parseFloat(curr_last_row_index_string);
1797 * @var new_last_row_index Index of the new row to be appended to {@link tables_table}
1799 var new_last_row_index = curr_last_row_index + 1;
1801 * @var new_last_row_id String containing the id of the row to be appended to {@link tables_table}
1803 var new_last_row_id = 'checkbox_tbl_' + new_last_row_index;
1806 $(data.new_table_string)
1807 .find('input:checkbox')
1808 .val(new_last_row_id)
1810 .appendTo(tables_table);
1813 $(tables_table).PMA_sort_table('th');
1816 //Refresh navigation frame as a new table has been added
1817 if (window.parent && window.parent.frame_navigation) {
1818 window.parent.frame_navigation.location.reload();
1822 PMA_ajaxShowMessage(data.error);
1825 }) // end create table form (save)
1828 * Attach event handler for create table form (add fields)
1830 * @uses PMA_ajaxShowMessage()
1831 * @uses $.PMA_sort_table()
1832 * @uses window.parent.refreshNavigation()
1835 // .live() must be called after a selector, see http://api.jquery.com/live
1836 $("#create_table_form.ajax input[name=submit_num_fields]").live('click', function(event) {
1837 event.preventDefault();
1840 * @var the_form object referring to the create table form
1842 var $form = $("#create_table_form");
1844 PMA_ajaxShowMessage(PMA_messages['strProcessingRequest']);
1845 if (! $form.find('input:hidden').is('#ajax_request_hidden')) {
1846 $form.append('<input type="hidden" id="ajax_request_hidden" name="ajax_request" value="true" />');
1849 //User wants to add more fields to the table
1850 $.post($form.attr('action'), $form.serialize() + "&submit_num_fields=" + $(this).val(), function(data) {
1851 // if 'create_table_dialog' exists
1852 if ($("#create_table_dialog").length > 0) {
1853 $("#create_table_dialog").html(data);
1855 // if 'create_table_div' exists
1856 if ($("#create_table_div").length > 0) {
1857 $("#create_table_div").html(data);
1861 }) // end create table form (add fields)
1863 }, 'top.frame_content'); //end $(document).ready for 'Create Table'
1866 * Attach Ajax event handlers for Drop Trigger. Used on tbl_structure.php
1867 * @see $cfg['AjaxEnable']
1869 $(document).ready(function() {
1871 $(".drop_trigger_anchor").live('click', function(event) {
1872 event.preventDefault();
1876 * @var curr_row Object reference to the current trigger's <tr>
1878 var $curr_row = $anchor.parents('tr');
1880 * @var question String containing the question to be asked for confirmation
1882 var question = 'DROP TRIGGER IF EXISTS `' + $curr_row.children('td:first').text() + '`';
1884 $anchor.PMA_confirm(question, $anchor.attr('href'), function(url) {
1886 PMA_ajaxShowMessage(PMA_messages['strProcessingRequest']);
1887 $.get(url, {'is_js_confirmed': 1, 'ajax_request': true}, function(data) {
1888 if(data.success == true) {
1889 PMA_ajaxShowMessage(data.message);
1890 $("#topmenucontainer")
1894 .after(data.sql_query);
1895 $curr_row.hide("medium").remove();
1898 PMA_ajaxShowMessage(data.error);
1901 }) // end $.PMA_confirm()
1902 }) // end $().live()
1903 }, 'top.frame_content'); //end $(document).ready() for Drop Trigger
1906 * Attach Ajax event handlers for Drop Database. Moved here from db_structure.js
1907 * as it was also required on db_create.php
1909 * @uses $.PMA_confirm()
1910 * @uses PMA_ajaxShowMessage()
1911 * @uses window.parent.refreshNavigation()
1912 * @uses window.parent.refreshMain()
1913 * @see $cfg['AjaxEnable']
1915 $(document).ready(function() {
1916 $("#drop_db_anchor").live('click', function(event) {
1917 event.preventDefault();
1919 //context is top.frame_content, so we need to use window.parent.db to access the db var
1921 * @var question String containing the question to be asked for confirmation
1923 var question = PMA_messages['strDropDatabaseStrongWarning'] + '\n' + PMA_messages['strDoYouReally'] + ' :\n' + 'DROP DATABASE ' + window.parent.db;
1925 $(this).PMA_confirm(question, $(this).attr('href') ,function(url) {
1927 PMA_ajaxShowMessage(PMA_messages['strProcessingRequest']);
1928 $.get(url, {'is_js_confirmed': '1', 'ajax_request': true}, function(data) {
1929 //Database deleted successfully, refresh both the frames
1930 window.parent.refreshNavigation();
1931 window.parent.refreshMain();
1933 }); // end $.PMA_confirm()
1934 }); //end of Drop Database Ajax action
1935 }) // end of $(document).ready() for Drop Database
1938 * Attach Ajax event handlers for 'Create Database'. Used wherever libraries/
1939 * display_create_database.lib.php is used, ie main.php and server_databases.php
1941 * @uses PMA_ajaxShowMessage()
1942 * @see $cfg['AjaxEnable']
1944 $(document).ready(function() {
1946 $('#create_database_form.ajax').live('submit', function(event) {
1947 event.preventDefault();
1951 PMA_ajaxShowMessage(PMA_messages['strProcessingRequest']);
1953 if (! $form.find('input:hidden').is('#ajax_request_hidden')) {
1954 $form.append('<input type="hidden" id="ajax_request_hidden" name="ajax_request" value="true" />');
1957 $.post($form.attr('action'), $form.serialize(), function(data) {
1958 if(data.success == true) {
1959 PMA_ajaxShowMessage(data.message);
1961 //Append database's row to table
1962 $("#tabledatabases")
1964 .append(data.new_db_string)
1965 .PMA_sort_table('.name')
1966 .find('#db_summary_row')
1967 .appendTo('#tabledatabases tbody')
1968 .removeClass('odd even');
1970 var $databases_count_object = $('#databases_count');
1971 var databases_count = parseInt($databases_count_object.text());
1972 $databases_count_object.text(++databases_count);
1973 //Refresh navigation frame as a new database has been added
1974 if (window.parent && window.parent.frame_navigation) {
1975 window.parent.frame_navigation.location.reload();
1979 PMA_ajaxShowMessage(data.error);
1982 }) // end $().live()
1983 }) // end $(document).ready() for Create Database
1986 * Attach Ajax event handlers for 'Change Password' on main.php
1988 $(document).ready(function() {
1991 * Attach Ajax event handler on the change password anchor
1992 * @see $cfg['AjaxEnable']
1994 $('#change_password_anchor.ajax').live('click', function(event) {
1995 event.preventDefault();
1998 * @var button_options Object containing options to be passed to jQueryUI's dialog
2000 var button_options = {};
2002 button_options[PMA_messages['strCancel']] = function() {$(this).dialog('close').remove();}
2004 $.get($(this).attr('href'), {'ajax_request': true}, function(data) {
2005 $('<div id="change_password_dialog"></div>')
2007 title: PMA_messages['strChangePassword'],
2009 buttons : button_options
2012 displayPasswordGenerateButton();
2014 }) // end handler for change password anchor
2017 * Attach Ajax event handler for Change Password form submission
2019 * @uses PMA_ajaxShowMessage()
2020 * @see $cfg['AjaxEnable']
2022 $("#change_password_form.ajax").find('input[name=change_pw]').live('click', function(event) {
2023 event.preventDefault();
2026 * @var the_form Object referring to the change password form
2028 var the_form = $("#change_password_form");
2031 * @var this_value String containing the value of the submit button.
2032 * Need to append this for the change password form on Server Privileges
2035 var this_value = $(this).val();
2037 PMA_ajaxShowMessage(PMA_messages['strProcessingRequest']);
2038 $(the_form).append('<input type="hidden" name="ajax_request" value="true" />');
2040 $.post($(the_form).attr('action'), $(the_form).serialize() + '&change_pw='+ this_value, function(data) {
2041 if(data.success == true) {
2043 PMA_ajaxShowMessage(data.message);
2045 $("#topmenucontainer").after(data.sql_query);
2047 $("#change_password_dialog").hide().remove();
2048 $("#edit_user_dialog").dialog("close").remove();
2051 PMA_ajaxShowMessage(data.error);
2054 }) // end handler for Change Password form submission
2055 }) // end $(document).ready() for Change Password
2058 * Toggle the hiding/showing of the "Open in ENUM/SET editor" message when
2059 * the page loads and when the selected data type changes
2061 $(document).ready(function() {
2062 // is called here for normal page loads and also when opening
2063 // the Create table dialog
2064 PMA_verifyTypeOfAllColumns();
2066 // needs live() to work also in the Create Table dialog
2067 $("select[class='column_type']").live('change', function() {
2068 toggle_enum_notice($(this));
2072 function PMA_verifyTypeOfAllColumns() {
2073 $("select[class='column_type']").each(function() {
2074 toggle_enum_notice($(this));
2079 * Closes the ENUM/SET editor and removes the data in it
2081 function disable_popup() {
2082 $("#popup_background").fadeOut("fast");
2083 $("#enum_editor").fadeOut("fast");
2084 // clear the data from the text boxes
2085 $("#enum_editor #values input").remove();
2086 $("#enum_editor input[type='hidden']").remove();
2090 * Opens the ENUM/SET editor and controls its functions
2092 $(document).ready(function() {
2093 // Needs live() to work also in the Create table dialog
2094 $("a[class='open_enum_editor']").live('click', function() {
2096 var windowWidth = document.documentElement.clientWidth;
2097 var windowHeight = document.documentElement.clientHeight;
2098 var popupWidth = windowWidth/2;
2099 var popupHeight = windowHeight*0.8;
2100 var popupOffsetTop = windowHeight/2 - popupHeight/2;
2101 var popupOffsetLeft = windowWidth/2 - popupWidth/2;
2102 $("#enum_editor").css({"position":"absolute", "top": popupOffsetTop, "left": popupOffsetLeft, "width": popupWidth, "height": popupHeight});
2105 $("#popup_background").css({"opacity":"0.7"});
2106 $("#popup_background").fadeIn("fast");
2107 $("#enum_editor").fadeIn("fast");
2110 var values = $(this).parent().prev("input").attr("value").split(",");
2111 $.each(values, function(index, val) {
2112 if(jQuery.trim(val) != "") {
2113 // enclose the string in single quotes if it's not already
2114 if(val.substr(0, 1) != "'") {
2117 if(val.substr(val.length-1, val.length) != "'") {
2120 // escape the single quotes, except the mandatory ones enclosing the entire string
2121 val = val.substr(1, val.length-2).replace(/''/g, "'").replace(/\\\\/g, '\\').replace(/\\'/g, "'").replace(/'/g, "'");
2122 // escape the greater-than symbol
2123 val = val.replace(/>/g, ">");
2124 $("#enum_editor #values").append("<input type='text' value=" + val + " />");
2127 // So we know which column's data is being edited
2128 $("#enum_editor").append("<input type='hidden' value='" + $(this).parent().prev("input").attr("id") + "' />");
2132 // If the "close" link is clicked, close the enum editor
2133 // Needs live() to work also in the Create table dialog
2134 $("a[class='close_enum_editor']").live('click', function() {
2138 // If the "cancel" link is clicked, close the enum editor
2139 // Needs live() to work also in the Create table dialog
2140 $("a[class='cancel_enum_editor']").live('click', function() {
2144 // When "add a new value" is clicked, append an empty text field
2145 // Needs live() to work also in the Create table dialog
2146 $("a[class='add_value']").live('click', function() {
2147 $("#enum_editor #values").append("<input type='text' />");
2150 // When the submit button is clicked, put the data back into the original form
2151 // Needs live() to work also in the Create table dialog
2152 $("#enum_editor input[type='submit']").live('click', function() {
2153 var value_array = new Array();
2154 $.each($("#enum_editor #values input"), function(index, input_element) {
2155 val = jQuery.trim(input_element.value);
2157 value_array.push("'" + val.replace(/\\/g, '\\\\').replace(/'/g, "''") + "'");
2160 // get the Length/Values text field where this value belongs
2161 var values_id = $("#enum_editor input[type='hidden']").attr("value");
2162 $("input[id='" + values_id + "']").attr("value", value_array.join(","));
2167 * Hides certain table structure actions, replacing them with the word "More". They are displayed
2168 * in a dropdown menu when the user hovers over the word "More."
2170 // Remove the actions from the table cells (they are available by default for JavaScript-disabled browsers)
2171 // if the table is not a view or information_schema (otherwise there is only one action to hide and there's no point)
2172 if($("input[type='hidden'][name='table_type']").val() == "table") {
2173 var $table = $("table[id='tablestructure']");
2174 $table.find("td[class='browse']").remove();
2175 $table.find("td[class='primary']").remove();
2176 $table.find("td[class='unique']").remove();
2177 $table.find("td[class='index']").remove();
2178 $table.find("td[class='fulltext']").remove();
2179 $table.find("th[class='action']").attr("colspan", 3);
2181 // Display the "more" text
2182 $table.find("td[class='more_opts']").show();
2184 // Position the dropdown
2185 $(".structure_actions_dropdown").each(function() {
2186 // Optimize DOM querying
2187 var $this_dropdown = $(this);
2188 // The top offset must be set for IE even if it didn't change
2189 var cell_right_edge_offset = $this_dropdown.parent().offset().left + $this_dropdown.parent().innerWidth();
2190 var left_offset = cell_right_edge_offset - $this_dropdown.innerWidth();
2191 var top_offset = $this_dropdown.parent().offset().top + $this_dropdown.parent().innerHeight();
2192 $this_dropdown.offset({ top: top_offset, left: left_offset });
2195 // A hack for IE6 to prevent the after_field select element from being displayed on top of the dropdown by
2196 // positioning an iframe directly on top of it
2197 var $after_field = $("select[name='after_field']");
2198 $("iframe[class='IE_hack']")
2199 .width($after_field.width())
2200 .height($after_field.height())
2202 top: $after_field.offset().top,
2203 left: $after_field.offset().left
2206 // When "more" is hovered over, show the hidden actions
2207 $table.find("td[class='more_opts']")
2208 .mouseenter(function() {
2209 if($.browser.msie && $.browser.version == "6.0") {
2210 $("iframe[class='IE_hack']")
2212 .width($after_field.width()+4)
2213 .height($after_field.height()+4)
2215 top: $after_field.offset().top,
2216 left: $after_field.offset().left
2219 $(".structure_actions_dropdown").hide(); // Hide all the other ones that may be open
2220 $(this).children(".structure_actions_dropdown").show();
2221 // Need to do this again for IE otherwise the offset is wrong
2222 if($.browser.msie) {
2223 var left_offset_IE = $(this).offset().left + $(this).innerWidth() - $(this).children(".structure_actions_dropdown").innerWidth();
2224 var top_offset_IE = $(this).offset().top + $(this).innerHeight();
2225 $(this).children(".structure_actions_dropdown").offset({
2227 left: left_offset_IE });
2230 .mouseleave(function() {
2231 $(this).children(".structure_actions_dropdown").hide();
2232 if($.browser.msie && $.browser.version == "6.0") {
2233 $("iframe[class='IE_hack']").hide();
2239 /* Displays tooltips */
2240 $(document).ready(function() {
2241 // Hide the footnotes from the footer (which are displayed for
2242 // JavaScript-disabled browsers) since the tooltip is sufficient
2243 $(".footnotes").hide();
2244 $(".footnotes span").each(function() {
2245 $(this).children("sup").remove();
2247 // The border and padding must be removed otherwise a thin yellow box remains visible
2248 $(".footnotes").css("border", "none");
2249 $(".footnotes").css("padding", "0px");
2251 // Replace the superscripts with the help icon
2252 $("sup[class='footnotemarker']").hide();
2253 $("img[class='footnotemarker']").show();
2255 $("img[class='footnotemarker']").each(function() {
2256 var span_id = $(this).attr("id");
2257 span_id = span_id.split("_")[1];
2258 var tooltip_text = $(".footnotes span[id='footnote_" + span_id + "']").html();
2260 content: tooltip_text,
2262 hide: { when: 'unfocus', delay: 0 },
2263 style: { background: '#ffffcc' }
2268 function menuResize()
2270 var cnt = $('#topmenu');
2271 var wmax = cnt.innerWidth() - 5; // 5 px margin for jumping menu in Chrome
2272 var submenu = cnt.find('.submenu');
2273 var submenu_w = submenu.outerWidth(true);
2274 var submenu_ul = submenu.find('ul');
2275 var li = cnt.find('> li');
2276 var li2 = submenu_ul.find('li');
2277 var more_shown = li2.length > 0;
2278 var w = more_shown ? submenu_w : 0;
2282 for (var i = 0; i < li.length-1; i++) { // li.length-1: skip .submenu element
2284 var el_width = el.outerWidth(true);
2285 el.data('width', el_width);
2289 if (w + submenu_w < wmax) {
2293 w -= $(li[i-1]).data('width');
2299 if (hide_start > 0) {
2300 for (var i = hide_start; i < li.length-1; i++) {
2301 $(li[i])[more_shown ? 'prependTo' : 'appendTo'](submenu_ul);
2303 submenu.addClass('shown');
2304 } else if (more_shown) {
2306 // nothing hidden, maybe something can be restored
2307 for (var i = 0; i < li2.length; i++) {
2308 //console.log(li2[i], submenu_w);
2309 w += $(li2[i]).data('width');
2310 // item fits or (it is the last item and it would fit if More got removed)
2311 if (w+submenu_w < wmax || (i == li2.length-1 && w < wmax)) {
2312 $(li2[i]).insertBefore(submenu);
2313 if (i == li2.length-1) {
2314 submenu.removeClass('shown');
2321 if (submenu.find('.tabactive').length) {
2322 submenu.addClass('active').find('> a').removeClass('tab').addClass('tabactive');
2324 submenu.removeClass('active').find('> a').addClass('tab').removeClass('tabactive');
2329 var topmenu = $('#topmenu');
2330 if (topmenu.length == 0) {
2333 // create submenu container
2334 var link = $('<a />', {href: '#', 'class': 'tab'})
2335 .text(PMA_messages['strMore'])
2336 .click(function(e) {
2339 var img = topmenu.find('li:first-child img');
2341 img.clone().attr('src', img.attr('src').replace(/\/[^\/]+$/, '/b_more.png')).prependTo(link);
2343 var submenu = $('<li />', {'class': 'submenu'})
2345 .append($('<ul />'))
2346 .mouseenter(function() {
2347 if ($(this).find('ul .tabactive').length == 0) {
2348 $(this).addClass('submenuhover').find('> a').addClass('tabactive');
2351 .mouseleave(function() {
2352 if ($(this).find('ul .tabactive').length == 0) {
2353 $(this).removeClass('submenuhover').find('> a').removeClass('tabactive');
2356 topmenu.append(submenu);
2358 // populate submenu and register resize event
2359 $(window).resize(menuResize);
2364 * For the checkboxes in browse mode, handles the shift/click (only works
2365 * in horizontal mode) and propagates the click to the "companion" checkbox
2366 * (in both horizontal and vertical). Works also for pages reached via AJAX.
2368 $(document).ready(function() {
2369 $('.multi_checkbox').live('click',function(e) {
2370 var current_checkbox_id = this.id;
2371 var left_checkbox_id = current_checkbox_id.replace('_right', '_left');
2372 var right_checkbox_id = current_checkbox_id.replace('_left', '_right');
2373 var other_checkbox_id = '';
2374 if (current_checkbox_id == left_checkbox_id) {
2375 other_checkbox_id = right_checkbox_id;
2377 other_checkbox_id = left_checkbox_id;
2380 var $current_checkbox = $('#' + current_checkbox_id);
2381 var $other_checkbox = $('#' + other_checkbox_id);
2384 var index_of_current_checkbox = $('.multi_checkbox').index($current_checkbox);
2385 var $last_checkbox = $('.multi_checkbox').filter('.last_clicked');
2386 var index_of_last_click = $('.multi_checkbox').index($last_checkbox);
2387 $('.multi_checkbox')
2388 .filter(function(index) {
2389 // the first clicked row can be on a row above or below the
2390 // shift-clicked row
2391 return (index_of_current_checkbox > index_of_last_click && index > index_of_last_click && index < index_of_current_checkbox)
2392 || (index_of_last_click > index_of_current_checkbox && index < index_of_last_click && index > index_of_current_checkbox);
2394 .each(function(index) {
2395 var $intermediate_checkbox = $(this);
2396 if ($current_checkbox.is(':checked')) {
2397 $intermediate_checkbox.attr('checked', true);
2399 $intermediate_checkbox.attr('checked', false);
2404 $('.multi_checkbox').removeClass('last_clicked');
2405 $current_checkbox.addClass('last_clicked');
2407 // When there is a checkbox on both ends of the row, propagate the
2408 // click on one of them to the other one.
2409 // (the default action has not been prevented so if we have
2410 // just clicked, this "if" is true)
2411 if ($current_checkbox.is(':checked')) {
2412 $other_checkbox.attr('checked', true);
2414 $other_checkbox.attr('checked', false);
2417 }) // end of $(document).ready() for multi checkbox
2420 * Get the row number from the classlist (for example, row_1)
2422 function PMA_getRowNumber(classlist) {
2423 return parseInt(classlist.split(/row_/)[1]);
2427 * Changes status of slider
2429 function PMA_set_status_label(id) {
2430 if ($('#' + id).css('display') == 'none') {
2431 $('#anchor_status_' + id).text('+ ');
2433 $('#anchor_status_' + id).text('- ');
2440 $(document).ready(function() {
2441 $('.vpointer').live('hover',
2444 var $this_td = $(this);
2445 var row_num = PMA_getRowNumber($this_td.attr('class'));
2446 // for all td of the same vertical row, toggle hover
2447 $('.vpointer').filter('.row_' + row_num).toggleClass('hover');
2450 }) // end of $(document).ready() for vertical pointer
2452 $(document).ready(function() {
2456 $('.vmarker').live('click', function(e) {
2457 var $this_td = $(this);
2458 var row_num = PMA_getRowNumber($this_td.attr('class'));
2459 // for all td of the same vertical row, toggle the marked class
2460 $('.vmarker').filter('.row_' + row_num).toggleClass('marked');
2464 * Reveal visual builder anchor
2467 $('#visual_builder_anchor').show();
2470 * Page selector in db Structure (non-AJAX)
2472 $('#tableslistcontainer').find('#pageselector').live('change', function() {
2473 $(this).parent("form").submit();
2477 * Page selector in navi panel (non-AJAX)
2479 $('#navidbpageselector').find('#pageselector').live('change', function() {
2480 $(this).parent("form").submit();
2484 * Page selector in browse_foreigners windows (non-AJAX)
2486 $('#body_browse_foreigners').find('#pageselector').live('change', function() {
2487 $(this).closest("form").submit();
2491 * Load version information asynchronously.
2493 if ($('.jsversioncheck').length > 0) {
2495 var s = document.createElement('script');
2496 s.type = 'text/javascript';
2498 s.src = 'http://www.phpmyadmin.net/home_page/version.js';
2499 s.onload = PMA_current_version;
2500 var x = document.getElementsByTagName('script')[0];
2501 x.parentNode.insertBefore(s, x);
2508 $('.pma_auto_slider').each(function(idx, e) {
2509 $('<span id="anchor_status_' + e.id + '"><span>')
2511 PMA_set_status_label(e.id);
2513 $('<a href="#' + e.id + '" id="anchor_' + e.id + '">' + e.title + '</a>')
2516 $('#' + e.id).toggle('clip');
2517 PMA_set_status_label(e.id);
2522 }) // end of $(document).ready()