1 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 * general function, usally for data manipulation pages
9 * @var sql_box_locked lock for the sqlbox textarea in the querybox/querywindow
11 var sql_box_locked = false;
14 * @var array holds elements which content should only selected once
16 var only_once_elements = new Array();
19 * selects the content of a given object, f.e. a textarea
21 * @param object element element of which the content will be selected
22 * @param var lock variable which holds the lock for this element
23 * or true, if no lock exists
24 * @param boolean only_once if true this is only done once
25 * f.e. only on first focus
27 function selectContent( element, lock, only_once ) {
28 if ( only_once && only_once_elements[element.name] ) {
32 only_once_elements[element.name] = true;
42 * Displays an confirmation box before to submit a "DROP DATABASE" query.
43 * This function is called while clicking links
45 * @param object the link
46 * @param object the sql query to submit
48 * @return boolean whether to run the query or not
50 function confirmLinkDropDB(theLink, theSqlQuery)
52 // Confirmation is not required in the configuration file
53 // or browser is Opera (crappy js implementation)
54 if (PMA_messages['strDoYouReally'] == '' || typeof(window.opera) != 'undefined') {
58 var is_confirmed = confirm(PMA_messages['strDropDatabaseStrongWarning'] + '\n' + PMA_messages['strDoYouReally'] + ' :\n' + theSqlQuery);
60 theLink.href += '&is_js_confirmed=1';
64 } // end of the 'confirmLinkDropDB()' function
67 * Displays an confirmation box before to submit a "DROP/DELETE/ALTER" query.
68 * This function is called while clicking links
70 * @param object the link
71 * @param object the sql query to submit
73 * @return boolean whether to run the query or not
75 function confirmLink(theLink, theSqlQuery)
77 // Confirmation is not required in the configuration file
78 // or browser is Opera (crappy js implementation)
79 if (PMA_messages['strDoYouReally'] == '' || typeof(window.opera) != 'undefined') {
83 var is_confirmed = confirm(PMA_messages['strDoYouReally'] + ' :\n' + theSqlQuery);
85 if ( typeof(theLink.href) != 'undefined' ) {
86 theLink.href += '&is_js_confirmed=1';
87 } else if ( typeof(theLink.form) != 'undefined' ) {
88 theLink.form.action += '?is_js_confirmed=1';
93 } // end of the 'confirmLink()' function
97 * Displays an confirmation box before doing some action
99 * @param object the message to display
101 * @return boolean whether to run the query or not
103 function confirmAction(theMessage)
105 // TODO: Confirmation is not required in the configuration file
106 // or browser is Opera (crappy js implementation)
107 if (typeof(window.opera) != 'undefined') {
111 var is_confirmed = confirm(theMessage);
114 } // end of the 'confirmAction()' function
118 * Displays an error message if a "DROP DATABASE" statement is submitted
119 * while it isn't allowed, else confirms a "DROP/DELETE/ALTER" query before
120 * sumitting it if required.
121 * This function is called by the 'checkSqlQuery()' js function.
123 * @param object the form
124 * @param object the sql query textarea
126 * @return boolean whether to run the query or not
128 * @see checkSqlQuery()
130 function confirmQuery(theForm1, sqlQuery1)
132 // Confirmation is not required in the configuration file
133 if (PMA_messages['strDoYouReally'] == '') {
137 // The replace function (js1.2) isn't supported
138 else if (typeof(sqlQuery1.value.replace) == 'undefined') {
142 // js1.2+ -> validation with regular expressions
144 // "DROP DATABASE" statement isn't allowed
145 if (PMA_messages['strNoDropDatabases'] != '') {
146 var drop_re = new RegExp('(^|;)\\s*DROP\\s+(IF EXISTS\\s+)?DATABASE\\s', 'i');
147 if (drop_re.test(sqlQuery1.value)) {
148 alert(PMA_messages['strNoDropDatabases']);
155 // Confirms a "DROP/DELETE/ALTER" statement
157 // TODO: find a way (if possible) to use the parser-analyser
158 // for this kind of verification
159 // For now, I just added a ^ to check for the statement at
160 // beginning of expression
162 var do_confirm_re_0 = new RegExp('^\\s*DROP\\s+(IF EXISTS\\s+)?(TABLE|DATABASE|PROCEDURE)\\s', 'i');
163 var do_confirm_re_1 = new RegExp('^\\s*ALTER\\s+TABLE\\s+((`[^`]+`)|([A-Za-z0-9_$]+))\\s+DROP\\s', 'i');
164 var do_confirm_re_2 = new RegExp('^\\s*DELETE\\s+FROM\\s', 'i');
165 if (do_confirm_re_0.test(sqlQuery1.value)
166 || do_confirm_re_1.test(sqlQuery1.value)
167 || do_confirm_re_2.test(sqlQuery1.value)) {
168 var message = (sqlQuery1.value.length > 100)
169 ? sqlQuery1.value.substr(0, 100) + '\n ...'
171 var is_confirmed = confirm(PMA_messages['strDoYouReally'] + ' :\n' + message);
172 // drop/delete/alter statement is confirmed -> update the
173 // "is_js_confirmed" form field so the confirm test won't be
174 // run on the server side and allows to submit the form
176 theForm1.elements['is_js_confirmed'].value = 1;
179 // "DROP/DELETE/ALTER" statement is rejected -> do not submit
185 } // end if (handle confirm box result)
186 } // end if (display confirm box)
187 } // end confirmation stuff
190 } // end of the 'confirmQuery()' function
194 * Displays a confirmation box before disabling the BLOB repository for a given database.
195 * This function is called while clicking links
197 * @param object the database
199 * @return boolean whether to disable the repository or not
201 function confirmDisableRepository(theDB)
203 // Confirmation is not required in the configuration file
204 // or browser is Opera (crappy js implementation)
205 if (PMA_messages['strDoYouReally'] == '' || typeof(window.opera) != 'undefined') {
209 var is_confirmed = confirm(PMA_messages['strBLOBRepositoryDisableStrongWarning'] + '\n' + PMA_messages['strBLOBRepositoryDisableAreYouSure']);
212 } // end of the 'confirmDisableBLOBRepository()' function
216 * Displays an error message if the user submitted the sql query form with no
217 * sql query, else checks for "DROP/DELETE/ALTER" statements
219 * @param object the form
221 * @return boolean always false
223 * @see confirmQuery()
225 function checkSqlQuery(theForm)
227 var sqlQuery = theForm.elements['sql_query'];
230 // The replace function (js1.2) isn't supported -> basic tests
231 if (typeof(sqlQuery.value.replace) == 'undefined') {
232 isEmpty = (sqlQuery.value == '') ? 1 : 0;
233 if (isEmpty && typeof(theForm.elements['sql_file']) != 'undefined') {
234 isEmpty = (theForm.elements['sql_file'].value == '') ? 1 : 0;
236 if (isEmpty && typeof(theForm.elements['sql_localfile']) != 'undefined') {
237 isEmpty = (theForm.elements['sql_localfile'].value == '') ? 1 : 0;
239 if (isEmpty && typeof(theForm.elements['id_bookmark']) != 'undefined') {
240 isEmpty = (theForm.elements['id_bookmark'].value == null || theForm.elements['id_bookmark'].value == '');
243 // js1.2+ -> validation with regular expressions
245 var space_re = new RegExp('\\s+');
246 if (typeof(theForm.elements['sql_file']) != 'undefined' &&
247 theForm.elements['sql_file'].value.replace(space_re, '') != '') {
250 if (typeof(theForm.elements['sql_localfile']) != 'undefined' &&
251 theForm.elements['sql_localfile'].value.replace(space_re, '') != '') {
254 if (isEmpty && typeof(theForm.elements['id_bookmark']) != 'undefined' &&
255 (theForm.elements['id_bookmark'].value != null || theForm.elements['id_bookmark'].value != '') &&
256 theForm.elements['id_bookmark'].selectedIndex != 0
260 // Checks for "DROP/DELETE/ALTER" statements
261 if (sqlQuery.value.replace(space_re, '') != '') {
262 if (confirmQuery(theForm, sqlQuery)) {
274 alert(PMA_messages['strFormEmpty']);
280 } // end of the 'checkSqlQuery()' function
284 * Check if a form's element is empty
287 * @param object the form
288 * @param string the name of the form field to put the focus on
290 * @return boolean whether the form field is empty or not
292 function emptyCheckTheField(theForm, theFieldName)
295 var theField = theForm.elements[theFieldName];
296 // Whether the replace function (js1.2) is supported or not
297 var isRegExp = (typeof(theField.value.replace) != 'undefined');
300 isEmpty = (theField.value == '') ? 1 : 0;
302 var space_re = new RegExp('\\s+');
303 isEmpty = (theField.value.replace(space_re, '') == '') ? 1 : 0;
307 } // end of the 'emptyCheckTheField()' function
311 * Displays an error message if an element of a form hasn't been completed and
314 * @param object the form
315 * @param string the name of the form field to put the focus on
317 * @return boolean whether the form field is empty or not
319 function emptyFormElements(theForm, theFieldName)
321 var theField = theForm.elements[theFieldName];
322 var isEmpty = emptyCheckTheField(theForm, theFieldName);
327 alert(PMA_messages['strFormEmpty']);
333 } // end of the 'emptyFormElements()' function
337 * Ensures a value submitted in a form is numeric and is in a range
339 * @param object the form
340 * @param string the name of the form field to check
341 * @param integer the minimum authorized value
342 * @param integer the maximum authorized value
344 * @return boolean whether a valid number has been submitted or not
346 function checkFormElementInRange(theForm, theFieldName, message, min, max)
348 var theField = theForm.elements[theFieldName];
349 var val = parseInt(theField.value);
351 if (typeof(min) == 'undefined') {
354 if (typeof(max) == 'undefined') {
355 max = Number.MAX_VALUE;
361 alert(PMA_messages['strNotNumber']);
365 // It's a number but it is not between min and max
366 else if (val < min || val > max) {
368 alert(message.replace('%d', val));
372 // It's a valid number
374 theField.value = val;
378 } // end of the 'checkFormElementInRange()' function
381 function checkTableEditForm(theForm, fieldsCnt)
383 // TODO: avoid sending a message if user just wants to add a line
384 // on the form but has not completed at least one field name
386 var atLeastOneField = 0;
387 var i, elm, elm2, elm3, val, id;
389 for (i=0; i<fieldsCnt; i++)
391 id = "field_" + i + "_2";
392 elm = getElement(id);
393 if (elm.value == 'VARCHAR' || elm.value == 'CHAR' || elm.value == 'BIT') {
394 elm2 = getElement("field_" + i + "_3");
395 val = parseInt(elm2.value);
396 elm3 = getElement("field_" + i + "_1");
397 if (isNaN(val) && elm3.value != "") {
399 alert(PMA_messages['strNotNumber']);
405 if (atLeastOneField == 0) {
406 id = "field_" + i + "_1";
407 if (!emptyCheckTheField(theForm, id)) {
412 if (atLeastOneField == 0) {
413 var theField = theForm.elements["field_0_1"];
414 alert(PMA_messages['strFormEmpty']);
420 } // enf of the 'checkTableEditForm()' function
424 * Ensures the choice between 'transmit', 'zipped', 'gzipped' and 'bzipped'
425 * checkboxes is consistant
427 * @param object the form
428 * @param string a code for the action that causes this function to be run
430 * @return boolean always true
432 function checkTransmitDump(theForm, theAction)
434 var formElts = theForm.elements;
436 // 'zipped' option has been checked
437 if (theAction == 'zip' && formElts['zip'].checked) {
438 if (!formElts['asfile'].checked) {
439 theForm.elements['asfile'].checked = true;
441 if (typeof(formElts['gzip']) != 'undefined' && formElts['gzip'].checked) {
442 theForm.elements['gzip'].checked = false;
444 if (typeof(formElts['bzip']) != 'undefined' && formElts['bzip'].checked) {
445 theForm.elements['bzip'].checked = false;
448 // 'gzipped' option has been checked
449 else if (theAction == 'gzip' && formElts['gzip'].checked) {
450 if (!formElts['asfile'].checked) {
451 theForm.elements['asfile'].checked = true;
453 if (typeof(formElts['zip']) != 'undefined' && formElts['zip'].checked) {
454 theForm.elements['zip'].checked = false;
456 if (typeof(formElts['bzip']) != 'undefined' && formElts['bzip'].checked) {
457 theForm.elements['bzip'].checked = false;
460 // 'bzipped' option has been checked
461 else if (theAction == 'bzip' && formElts['bzip'].checked) {
462 if (!formElts['asfile'].checked) {
463 theForm.elements['asfile'].checked = true;
465 if (typeof(formElts['zip']) != 'undefined' && formElts['zip'].checked) {
466 theForm.elements['zip'].checked = false;
468 if (typeof(formElts['gzip']) != 'undefined' && formElts['gzip'].checked) {
469 theForm.elements['gzip'].checked = false;
472 // 'transmit' option has been unchecked
473 else if (theAction == 'transmit' && !formElts['asfile'].checked) {
474 if (typeof(formElts['zip']) != 'undefined' && formElts['zip'].checked) {
475 theForm.elements['zip'].checked = false;
477 if ((typeof(formElts['gzip']) != 'undefined' && formElts['gzip'].checked)) {
478 theForm.elements['gzip'].checked = false;
480 if ((typeof(formElts['bzip']) != 'undefined' && formElts['bzip'].checked)) {
481 theForm.elements['bzip'].checked = false;
486 } // end of the 'checkTransmitDump()' function
490 * This array is used to remember mark status of rows in browse mode
492 var marked_row = new Array;
495 * enables highlight and marking of rows in data tables
498 function PMA_markRowsInit() {
499 // for every table row ...
500 var rows = document.getElementsByTagName('tr');
501 for ( var i = 0; i < rows.length; i++ ) {
502 // ... with the class 'odd' or 'even' ...
503 if ( 'odd' != rows[i].className.substr(0,3) && 'even' != rows[i].className.substr(0,4) ) {
506 // ... add event listeners ...
507 // ... to highlight the row on mouseover ...
508 if ( navigator.appName == 'Microsoft Internet Explorer' ) {
509 // but only for IE, other browsers are handled by :hover in css
510 rows[i].onmouseover = function() {
511 this.className += ' hover';
513 rows[i].onmouseout = function() {
514 this.className = this.className.replace( ' hover', '' );
517 // Do not set click events if not wanted
518 if (rows[i].className.search(/noclick/) != -1) {
521 // ... and to mark the row on click ...
522 rows[i].onmousedown = function() {
526 checkbox = this.getElementsByTagName( 'input' )[0];
527 if ( checkbox && checkbox.type == 'checkbox' ) {
528 unique_id = checkbox.name + checkbox.value;
529 } else if ( this.id.length > 0 ) {
535 if ( typeof(marked_row[unique_id]) == 'undefined' || !marked_row[unique_id] ) {
536 marked_row[unique_id] = true;
538 marked_row[unique_id] = false;
541 if ( marked_row[unique_id] ) {
542 this.className += ' marked';
544 this.className = this.className.replace(' marked', '');
547 if ( checkbox && checkbox.disabled == false ) {
548 checkbox.checked = marked_row[unique_id];
552 // ... and disable label ...
553 var labeltag = rows[i].getElementsByTagName('label')[0];
555 labeltag.onclick = function() {
559 // .. and checkbox clicks
560 var checkbox = rows[i].getElementsByTagName('input')[0];
562 checkbox.onclick = function() {
563 // opera does not recognize return false;
564 this.checked = ! this.checked;
569 window.onload=PMA_markRowsInit;
572 * marks all rows and selects its first checkbox inside the given element
573 * the given element is usaly a table or a div containing the table or tables
575 * @param container DOM element
577 function markAllRows( container_id ) {
578 var rows = document.getElementById(container_id).getElementsByTagName('tr');
582 for ( var i = 0; i < rows.length; i++ ) {
584 checkbox = rows[i].getElementsByTagName( 'input' )[0];
586 if ( checkbox && checkbox.type == 'checkbox' ) {
587 unique_id = checkbox.name + checkbox.value;
588 if ( checkbox.disabled == false ) {
589 checkbox.checked = true;
590 if ( typeof(marked_row[unique_id]) == 'undefined' || !marked_row[unique_id] ) {
591 rows[i].className += ' marked';
592 marked_row[unique_id] = true;
602 * marks all rows and selects its first checkbox inside the given element
603 * the given element is usaly a table or a div containing the table or tables
605 * @param container DOM element
607 function unMarkAllRows( container_id ) {
608 var rows = document.getElementById(container_id).getElementsByTagName('tr');
612 for ( var i = 0; i < rows.length; i++ ) {
614 checkbox = rows[i].getElementsByTagName( 'input' )[0];
616 if ( checkbox && checkbox.type == 'checkbox' ) {
617 unique_id = checkbox.name + checkbox.value;
618 checkbox.checked = false;
619 rows[i].className = rows[i].className.replace(' marked', '');
620 marked_row[unique_id] = false;
628 * Sets/unsets the pointer and marker in browse mode
630 * @param object the table row
631 * @param integer the row number
632 * @param string the action calling this script (over, out or click)
633 * @param string the default background color
634 * @param string the color to use for mouseover
635 * @param string the color to use for marking a row
637 * @return boolean whether pointer is set or not
639 function setPointer(theRow, theRowNum, theAction, theDefaultColor, thePointerColor, theMarkColor)
643 // 1. Pointer and mark feature are disabled or the browser can't get the
645 if ((thePointerColor == '' && theMarkColor == '')
646 || typeof(theRow.style) == 'undefined') {
650 // 1.1 Sets the mouse pointer to pointer on mouseover and back to normal otherwise.
651 if (theAction == "over" || theAction == "click") {
652 theRow.style.cursor='pointer';
654 theRow.style.cursor='default';
657 // 2. Gets the current row and exits if the browser can't get it
658 if (typeof(document.getElementsByTagName) != 'undefined') {
659 theCells = theRow.getElementsByTagName('td');
661 else if (typeof(theRow.cells) != 'undefined') {
662 theCells = theRow.cells;
668 // 3. Gets the current color...
669 var rowCellsCnt = theCells.length;
670 var domDetect = null;
671 var currentColor = null;
673 // 3.1 ... with DOM compatible browsers except Opera that does not return
674 // valid values with "getAttribute"
675 if (typeof(window.opera) == 'undefined'
676 && typeof(theCells[0].getAttribute) != 'undefined') {
677 currentColor = theCells[0].getAttribute('bgcolor');
680 // 3.2 ... with other browsers
682 currentColor = theCells[0].style.backgroundColor;
686 // 3.3 ... Opera changes colors set via HTML to rgb(r,g,b) format so fix it
687 if (currentColor.indexOf("rgb") >= 0)
689 var rgbStr = currentColor.slice(currentColor.indexOf('(') + 1,
690 currentColor.indexOf(')'));
691 var rgbValues = rgbStr.split(",");
693 var hexChars = "0123456789ABCDEF";
694 for (var i = 0; i < 3; i++)
696 var v = rgbValues[i].valueOf();
697 currentColor += hexChars.charAt(v/16) + hexChars.charAt(v%16);
701 // 4. Defines the new color
702 // 4.1 Current color is the default one
703 if (currentColor == ''
704 || currentColor.toLowerCase() == theDefaultColor.toLowerCase()) {
705 if (theAction == 'over' && thePointerColor != '') {
706 newColor = thePointerColor;
708 else if (theAction == 'click' && theMarkColor != '') {
709 newColor = theMarkColor;
710 marked_row[theRowNum] = true;
711 // Garvin: deactivated onclick marking of the checkbox because it's also executed
712 // when an action (like edit/delete) on a single item is performed. Then the checkbox
713 // would get deactived, even though we need it activated. Maybe there is a way
714 // to detect if the row was clicked, and not an item therein...
715 // document.getElementById('id_rows_to_delete' + theRowNum).checked = true;
718 // 4.1.2 Current color is the pointer one
719 else if (currentColor.toLowerCase() == thePointerColor.toLowerCase()
720 && (typeof(marked_row[theRowNum]) == 'undefined' || !marked_row[theRowNum])) {
721 if (theAction == 'out') {
722 newColor = theDefaultColor;
724 else if (theAction == 'click' && theMarkColor != '') {
725 newColor = theMarkColor;
726 marked_row[theRowNum] = true;
727 // document.getElementById('id_rows_to_delete' + theRowNum).checked = true;
730 // 4.1.3 Current color is the marker one
731 else if (currentColor.toLowerCase() == theMarkColor.toLowerCase()) {
732 if (theAction == 'click') {
733 newColor = (thePointerColor != '')
736 marked_row[theRowNum] = (typeof(marked_row[theRowNum]) == 'undefined' || !marked_row[theRowNum])
739 // document.getElementById('id_rows_to_delete' + theRowNum).checked = false;
743 // 5. Sets the new color...
746 // 5.1 ... with DOM compatible browsers except Opera
748 for (c = 0; c < rowCellsCnt; c++) {
749 theCells[c].setAttribute('bgcolor', newColor, 0);
752 // 5.2 ... with other browsers
754 for (c = 0; c < rowCellsCnt; c++) {
755 theCells[c].style.backgroundColor = newColor;
761 } // end of the 'setPointer()' function
764 * Sets/unsets the pointer and marker in vertical browse mode
766 * @param object the table row
767 * @param integer the column number
768 * @param string the action calling this script (over, out or click)
769 * @param string the default background Class
770 * @param string the Class to use for mouseover
771 * @param string the Class to use for marking a row
773 * @return boolean whether pointer is set or not
775 * @author Garvin Hicking <me@supergarv.de> (rewrite of setPointer.)
777 function setVerticalPointer(theRow, theColNum, theAction, theDefaultClass1, theDefaultClass2, thePointerClass, theMarkClass) {
778 // 1. Pointer and mark feature are disabled or the browser can't get the
780 if ((thePointerClass == '' && theMarkClass == '')
781 || typeof(theRow.style) == 'undefined') {
785 var tagSwitch = null;
787 // 2. Gets the current row and exits if the browser can't get it
788 if (typeof(document.getElementsByTagName) != 'undefined') {
790 } else if (typeof(document.getElementById('table_results')) != 'undefined') {
798 if (tagSwitch == 'tag') {
799 theRows = document.getElementById('table_results').getElementsByTagName('tr');
800 theCells = theRows[1].getElementsByTagName('td');
801 } else if (tagSwitch == 'cells') {
802 theRows = document.getElementById('table_results').rows;
803 theCells = theRows[1].cells;
806 // 3. Gets the current Class...
807 var currentClass = null;
810 // 3.1 ... with DOM compatible browsers except Opera that does not return
811 // valid values with "getAttribute"
812 if (typeof(window.opera) == 'undefined'
813 && typeof(theCells[theColNum].getAttribute) != 'undefined') {
814 currentClass = theCells[theColNum].className;
817 // 4. Defines the new Class
818 // 4.1 Current Class is the default one
819 if (currentClass == ''
820 || currentClass.toLowerCase() == theDefaultClass1.toLowerCase()
821 || currentClass.toLowerCase() == theDefaultClass2.toLowerCase()) {
822 if (theAction == 'over' && thePointerClass != '') {
823 newClass = thePointerClass;
824 } else if (theAction == 'click' && theMarkClass != '') {
825 newClass = theMarkClass;
826 marked_row[theColNum] = true;
829 // 4.1.2 Current Class is the pointer one
830 else if (currentClass.toLowerCase() == thePointerClass.toLowerCase() &&
831 (typeof(marked_row[theColNum]) == 'undefined' || !marked_row[theColNum]) || marked_row[theColNum] == false) {
832 if (theAction == 'out') {
834 newClass = theDefaultClass1;
836 newClass = theDefaultClass2;
839 else if (theAction == 'click' && theMarkClass != '') {
840 newClass = theMarkClass;
841 marked_row[theColNum] = true;
844 // 4.1.3 Current Class is the marker one
845 else if (currentClass.toLowerCase() == theMarkClass.toLowerCase()) {
846 if (theAction == 'click') {
847 newClass = (thePointerClass != '')
849 : ((theColNum % 2) ? theDefaultClass2 : theDefaultClass1);
850 marked_row[theColNum] = false;
854 // 5 ... with DOM compatible browsers except Opera
858 var rowCnt = theRows.length;
859 for (c = 0; c < rowCnt; c++) {
860 if (tagSwitch == 'tag') {
861 Cells = theRows[c].getElementsByTagName('td');
862 } else if (tagSwitch == 'cells') {
863 Cells = theRows[c].cells;
866 Cell = Cells[theColNum];
868 // 5.1 Sets the new Class...
869 Cell.className = Cell.className.replace(currentClass, newClass);
874 } // end of the 'setVerticalPointer()' function
877 * Checks/unchecks all checkbox in given conainer (f.e. a form, fieldset or div)
879 * @param string container_id the container id
880 * @param boolean state new value for checkbox (true or false)
881 * @return boolean always true
883 function setCheckboxes( container_id, state ) {
884 var checkboxes = document.getElementById(container_id).getElementsByTagName('input');
886 for ( var i = 0; i < checkboxes.length; i++ ) {
887 if ( checkboxes[i].type == 'checkbox' ) {
888 checkboxes[i].checked = state;
893 } // end of the 'setCheckboxes()' function
896 // added 2004-05-08 by Michael Keck <mail_at_michaelkeck_dot_de>
897 // copy the checked from left to right or from right to left
898 // so it's easier for users to see, if $cfg['ModifyAtRight']=true, what they've checked ;)
899 function copyCheckboxesRange(the_form, the_name, the_clicked)
901 if (typeof(document.forms[the_form].elements[the_name]) != 'undefined' && typeof(document.forms[the_form].elements[the_name + 'r']) != 'undefined') {
902 if (the_clicked !== 'r') {
903 if (document.forms[the_form].elements[the_name].checked == true) {
904 document.forms[the_form].elements[the_name + 'r'].checked = true;
906 document.forms[the_form].elements[the_name + 'r'].checked = false;
908 } else if (the_clicked == 'r') {
909 if (document.forms[the_form].elements[the_name + 'r'].checked == true) {
910 document.forms[the_form].elements[the_name].checked = true;
912 document.forms[the_form].elements[the_name].checked = false;
919 // added 2004-05-08 by Michael Keck <mail_at_michaelkeck_dot_de>
920 // - this was directly written to each td, so why not a function ;)
921 // setCheckboxColumn(\'id_rows_to_delete' . $row_no . ''\');
922 function setCheckboxColumn(theCheckbox){
923 if (document.getElementById(theCheckbox)) {
924 document.getElementById(theCheckbox).checked = (document.getElementById(theCheckbox).checked ? false : true);
925 if (document.getElementById(theCheckbox + 'r')) {
926 document.getElementById(theCheckbox + 'r').checked = document.getElementById(theCheckbox).checked;
929 if (document.getElementById(theCheckbox + 'r')) {
930 document.getElementById(theCheckbox + 'r').checked = (document.getElementById(theCheckbox +'r').checked ? false : true);
931 if (document.getElementById(theCheckbox)) {
932 document.getElementById(theCheckbox).checked = document.getElementById(theCheckbox + 'r').checked;
940 * Checks/unchecks all options of a <select> element
942 * @param string the form name
943 * @param string the element name
944 * @param boolean whether to check or to uncheck the element
946 * @return boolean always true
948 function setSelectOptions(the_form, the_select, do_check)
950 var selectObject = document.forms[the_form].elements[the_select];
951 var selectCount = selectObject.length;
953 for (var i = 0; i < selectCount; i++) {
954 selectObject.options[i].selected = do_check;
958 } // end of the 'setSelectOptions()' function
961 * Inserts multiple fields.
964 function insertValueQuery() {
965 var myQuery = document.sqlform.sql_query;
966 var myListBox = document.sqlform.dummy;
968 if(myListBox.options.length > 0) {
969 sql_box_locked = true;
972 for(var i=0; i<myListBox.options.length; i++) {
973 if (myListBox.options[i].selected){
977 chaineAj += myListBox.options[i].value;
982 if (document.selection) {
984 sel = document.selection.createRange();
986 document.sqlform.insert.focus();
988 //MOZILLA/NETSCAPE support
989 else if (document.sqlform.sql_query.selectionStart || document.sqlform.sql_query.selectionStart == "0") {
990 var startPos = document.sqlform.sql_query.selectionStart;
991 var endPos = document.sqlform.sql_query.selectionEnd;
992 var chaineSql = document.sqlform.sql_query.value;
994 myQuery.value = chaineSql.substring(0, startPos) + chaineAj + chaineSql.substring(endPos, chaineSql.length);
996 myQuery.value += chaineAj;
998 sql_box_locked = false;
1003 * listbox redirection
1005 function goToUrl(selObj, goToLocation) {
1006 eval("document.location.href = '" + goToLocation + "pos=" + selObj.options[selObj.selectedIndex].value + "'");
1012 function getElement(e,f){
1013 if(document.layers){
1015 if(f.document.layers[e]) {
1016 return f.document.layers[e];
1018 for(W=0;W<f.document.layers.length;W++) {
1019 return(getElement(e,f.document.layers[W]));
1023 return document.all[e];
1025 return document.getElementById(e);
1029 * Refresh the WYSIWYG-PDF scratchboard after changes have been made
1031 function refreshDragOption(e) {
1032 myid = getElement(e);
1033 if (myid.style.visibility == 'visible') {
1039 * Refresh/resize the WYSIWYG-PDF scratchboard
1041 function refreshLayout() {
1042 myid = getElement('pdflayout');
1044 if (document.pdfoptions.orientation.value == 'P') {
1052 myid.style.width = pdfPaperSize(document.pdfoptions.paper.value, posa) + 'px';
1053 myid.style.height = pdfPaperSize(document.pdfoptions.paper.value, posb) + 'px';
1057 * Show/hide the WYSIWYG-PDF scratchboard
1059 function ToggleDragDrop(e) {
1060 myid = getElement(e);
1062 if (myid.style.visibility == 'hidden') {
1064 myid.style.visibility = 'visible';
1065 myid.style.display = 'block';
1066 document.edcoord.showwysiwyg.value = '1';
1068 myid.style.visibility = 'hidden';
1069 myid.style.display = 'none';
1070 document.edcoord.showwysiwyg.value = '0';
1075 * PDF scratchboard: When a position is entered manually, update
1076 * the fields inside the scratchboard.
1078 function dragPlace(no, axis, value) {
1080 getElement("table_" + no).style.left = value + 'px';
1082 getElement("table_" + no).style.top = value + 'px';
1087 * Returns paper sizes for a given format
1089 function pdfPaperSize(format, axis) {
1090 switch (format.toUpperCase()) {
1092 if (axis == 'x') return 4767.87; else return 6740.79;
1095 if (axis == 'x') return 3370.39; else return 4767.87;
1098 if (axis == 'x') return 2383.94; else return 3370.39;
1101 if (axis == 'x') return 1683.78; else return 2383.94;
1104 if (axis == 'x') return 1190.55; else return 1683.78;
1107 if (axis == 'x') return 841.89; else return 1190.55;
1110 if (axis == 'x') return 595.28; else return 841.89;
1113 if (axis == 'x') return 419.53; else return 595.28;
1116 if (axis == 'x') return 297.64; else return 419.53;
1119 if (axis == 'x') return 209.76; else return 297.64;
1122 if (axis == 'x') return 147.40; else return 209.76;
1125 if (axis == 'x') return 104.88; else return 147.40;
1128 if (axis == 'x') return 73.70; else return 104.88;
1131 if (axis == 'x') return 2834.65; else return 4008.19;
1134 if (axis == 'x') return 2004.09; else return 2834.65;
1137 if (axis == 'x') return 1417.32; else return 2004.09;
1140 if (axis == 'x') return 1000.63; else return 1417.32;
1143 if (axis == 'x') return 708.66; else return 1000.63;
1146 if (axis == 'x') return 498.90; else return 708.66;
1149 if (axis == 'x') return 354.33; else return 498.90;
1152 if (axis == 'x') return 249.45; else return 354.33;
1155 if (axis == 'x') return 175.75; else return 249.45;
1158 if (axis == 'x') return 124.72; else return 175.75;
1161 if (axis == 'x') return 87.87; else return 124.72;
1164 if (axis == 'x') return 2599.37; else return 3676.54;
1167 if (axis == 'x') return 1836.85; else return 2599.37;
1170 if (axis == 'x') return 1298.27; else return 1836.85;
1173 if (axis == 'x') return 918.43; else return 1298.27;
1176 if (axis == 'x') return 649.13; else return 918.43;
1179 if (axis == 'x') return 459.21; else return 649.13;
1182 if (axis == 'x') return 323.15; else return 459.21;
1185 if (axis == 'x') return 229.61; else return 323.15;
1188 if (axis == 'x') return 161.57; else return 229.61;
1191 if (axis == 'x') return 113.39; else return 161.57;
1194 if (axis == 'x') return 79.37; else return 113.39;
1197 if (axis == 'x') return 2437.80; else return 3458.27;
1200 if (axis == 'x') return 1729.13; else return 2437.80;
1203 if (axis == 'x') return 1218.90; else return 1729.13;
1206 if (axis == 'x') return 864.57; else return 1218.90;
1209 if (axis == 'x') return 609.45; else return 864.57;
1212 if (axis == 'x') return 2551.18; else return 3628.35;
1215 if (axis == 'x') return 1814.17; else return 2551.18;
1218 if (axis == 'x') return 1275.59; else return 1814.17;
1221 if (axis == 'x') return 907.09; else return 1275.59;
1224 if (axis == 'x') return 637.80; else return 907.09;
1227 if (axis == 'x') return 612.00; else return 792.00;
1230 if (axis == 'x') return 612.00; else return 1008.00;
1233 if (axis == 'x') return 521.86; else return 756.00;
1236 if (axis == 'x') return 612.00; else return 936.00;
1244 * rajk - for playing media from the BLOB repository
1247 * @param var url_params main purpose is to pass the token
1248 * @param var bs_ref BLOB repository reference
1249 * @param var m_type type of BLOB repository media
1250 * @param var w_width width of popup window
1251 * @param var w_height height of popup window
1253 function popupBSMedia(url_params, bs_ref, m_type, is_cust_type, w_width, w_height)
1255 // if width not specified, use default
1256 if (w_width == undefined)
1259 // if height not specified, use default
1260 if (w_height == undefined)
1263 // open popup window (for displaying video/playing audio)
1264 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');
1268 * rajk - popups a request for changing MIME types for files in the BLOB repository
1270 * @param var db database name
1271 * @param var table table name
1272 * @param var reference BLOB repository reference
1273 * @param var current_mime_type current MIME type associated with BLOB repository reference
1275 function requestMIMETypeChange(db, table, reference, current_mime_type)
1277 // no mime type specified, set to default (nothing)
1278 if (undefined == current_mime_type)
1279 current_mime_type == "";
1281 // prompt user for new mime type
1282 var new_mime_type = prompt("Enter custom MIME type", current_mime_type);
1284 // if new mime_type is specified and is not the same as the previous type, request for mime type change
1285 if (new_mime_type && new_mime_type != current_mime_type)
1286 changeMIMEType(db, table, reference, new_mime_type);
1290 * rajk - changes MIME types for files in the BLOB repository
1292 * @param var db database name
1293 * @param var table table name
1294 * @param var reference BLOB repository reference
1295 * @param var mime_type new MIME type to be associated with BLOB repository reference
1297 function changeMIMEType(db, table, reference, mime_type)
1299 // specify url and parameters for mootools AJAx request
1300 var mime_chg_url = 'bs_change_mime_type.php';
1301 var params = { bs_db: db, bs_table: table, bs_reference: reference, bs_new_mime_type: mime_type };
1303 // create AJAX object with above options and execute request
1304 var chgRequest = new Request({ method: 'post', url: mime_chg_url, data: params, evalScripts: true });