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 (confirmMsg
== '' || typeof(window
.opera
) != 'undefined') {
58 var is_confirmed
= confirm(confirmMsgDropDB
+ '\n' + confirmMsg
+ ' :\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 (confirmMsg
== '' || typeof(window
.opera
) != 'undefined') {
83 var is_confirmed
= confirm(confirmMsg
+ ' :\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 (confirmMsg
== '') {
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 (noDropDbMsg
!= '') {
146 var drop_re
= new RegExp('(^|;)\\s*DROP\\s+(IF EXISTS\\s+)?DATABASE\\s', 'i');
147 if (drop_re
.test(sqlQuery1
.value
)) {
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(confirmMsg
+ ' :\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 an error message if the user submitted the sql query form with no
195 * sql query, else checks for "DROP/DELETE/ALTER" statements
197 * @param object the form
199 * @return boolean always false
201 * @see confirmQuery()
203 function checkSqlQuery(theForm
)
205 var sqlQuery
= theForm
.elements
['sql_query'];
208 // The replace function (js1.2) isn't supported -> basic tests
209 if (typeof(sqlQuery
.value
.replace
) == 'undefined') {
210 isEmpty
= (sqlQuery
.value
== '') ? 1 : 0;
211 if (isEmpty
&& typeof(theForm
.elements
['sql_file']) != 'undefined') {
212 isEmpty
= (theForm
.elements
['sql_file'].value
== '') ? 1 : 0;
214 if (isEmpty
&& typeof(theForm
.elements
['sql_localfile']) != 'undefined') {
215 isEmpty
= (theForm
.elements
['sql_localfile'].value
== '') ? 1 : 0;
217 if (isEmpty
&& typeof(theForm
.elements
['id_bookmark']) != 'undefined') {
218 isEmpty
= (theForm
.elements
['id_bookmark'].value
== null || theForm
.elements
['id_bookmark'].value
== '');
221 // js1.2+ -> validation with regular expressions
223 var space_re
= new RegExp('\\s+');
224 if (typeof(theForm
.elements
['sql_file']) != 'undefined' &&
225 theForm
.elements
['sql_file'].value
.replace(space_re
, '') != '') {
228 if (typeof(theForm
.elements
['sql_localfile']) != 'undefined' &&
229 theForm
.elements
['sql_localfile'].value
.replace(space_re
, '') != '') {
232 if (isEmpty
&& typeof(theForm
.elements
['id_bookmark']) != 'undefined' &&
233 (theForm
.elements
['id_bookmark'].value
!= null || theForm
.elements
['id_bookmark'].value
!= '') &&
234 theForm
.elements
['id_bookmark'].selectedIndex
!= 0
238 // Checks for "DROP/DELETE/ALTER" statements
239 if (sqlQuery
.value
.replace(space_re
, '') != '') {
240 if (confirmQuery(theForm
, sqlQuery
)) {
258 } // end of the 'checkSqlQuery()' function
262 * Check if a form's element is empty
265 * @param object the form
266 * @param string the name of the form field to put the focus on
268 * @return boolean whether the form field is empty or not
270 function emptyCheckTheField(theForm
, theFieldName
)
273 var theField
= theForm
.elements
[theFieldName
];
274 // Whether the replace function (js1.2) is supported or not
275 var isRegExp
= (typeof(theField
.value
.replace
) != 'undefined');
278 isEmpty
= (theField
.value
== '') ? 1 : 0;
280 var space_re
= new RegExp('\\s+');
281 isEmpty
= (theField
.value
.replace(space_re
, '') == '') ? 1 : 0;
285 } // end of the 'emptyCheckTheField()' function
289 * Displays an error message if an element of a form hasn't been completed and
292 * @param object the form
293 * @param string the name of the form field to put the focus on
295 * @return boolean whether the form field is empty or not
297 function emptyFormElements(theForm
, theFieldName
)
299 var theField
= theForm
.elements
[theFieldName
];
300 var isEmpty
= emptyCheckTheField(theForm
, theFieldName
);
311 } // end of the 'emptyFormElements()' function
315 * Ensures a value submitted in a form is numeric and is in a range
317 * @param object the form
318 * @param string the name of the form field to check
319 * @param integer the minimum authorized value
320 * @param integer the maximum authorized value
322 * @return boolean whether a valid number has been submitted or not
324 function checkFormElementInRange(theForm
, theFieldName
, message
, min
, max
)
326 var theField
= theForm
.elements
[theFieldName
];
327 var val
= parseInt(theField
.value
);
329 if (typeof(min
) == 'undefined') {
332 if (typeof(max
) == 'undefined') {
333 max
= Number
.MAX_VALUE
;
343 // It's a number but it is not between min and max
344 else if (val
< min
|| val
> max
) {
346 alert(message
.replace('%d', val
));
350 // It's a valid number
352 theField
.value
= val
;
356 } // end of the 'checkFormElementInRange()' function
359 function checkTableEditForm(theForm
, fieldsCnt
)
361 // TODO: avoid sending a message if user just wants to add a line
362 // on the form but has not completed at least one field name
364 var atLeastOneField
= 0;
365 var i
, elm
, elm2
, elm3
, val
, id
;
367 for (i
=0; i
<fieldsCnt
; i
++)
369 id
= "field_" + i
+ "_2";
370 elm
= getElement(id
);
371 if (elm
.value
== 'VARCHAR' || elm
.value
== 'CHAR' || elm
.value
== 'BIT') {
372 elm2
= getElement("field_" + i
+ "_3");
373 val
= parseInt(elm2
.value
);
374 elm3
= getElement("field_" + i
+ "_1");
375 if (isNaN(val
) && elm3
.value
!= "") {
383 if (atLeastOneField
== 0) {
384 id
= "field_" + i
+ "_1";
385 if (!emptyCheckTheField(theForm
, id
)) {
390 if (atLeastOneField
== 0) {
391 var theField
= theForm
.elements
["field_0_1"];
398 } // enf of the 'checkTableEditForm()' function
402 * Ensures the choice between 'transmit', 'zipped', 'gzipped' and 'bzipped'
403 * checkboxes is consistant
405 * @param object the form
406 * @param string a code for the action that causes this function to be run
408 * @return boolean always true
410 function checkTransmitDump(theForm
, theAction
)
412 var formElts
= theForm
.elements
;
414 // 'zipped' option has been checked
415 if (theAction
== 'zip' && formElts
['zip'].checked
) {
416 if (!formElts
['asfile'].checked
) {
417 theForm
.elements
['asfile'].checked
= true;
419 if (typeof(formElts
['gzip']) != 'undefined' && formElts
['gzip'].checked
) {
420 theForm
.elements
['gzip'].checked
= false;
422 if (typeof(formElts
['bzip']) != 'undefined' && formElts
['bzip'].checked
) {
423 theForm
.elements
['bzip'].checked
= false;
426 // 'gzipped' option has been checked
427 else if (theAction
== 'gzip' && formElts
['gzip'].checked
) {
428 if (!formElts
['asfile'].checked
) {
429 theForm
.elements
['asfile'].checked
= true;
431 if (typeof(formElts
['zip']) != 'undefined' && formElts
['zip'].checked
) {
432 theForm
.elements
['zip'].checked
= false;
434 if (typeof(formElts
['bzip']) != 'undefined' && formElts
['bzip'].checked
) {
435 theForm
.elements
['bzip'].checked
= false;
438 // 'bzipped' option has been checked
439 else if (theAction
== 'bzip' && formElts
['bzip'].checked
) {
440 if (!formElts
['asfile'].checked
) {
441 theForm
.elements
['asfile'].checked
= true;
443 if (typeof(formElts
['zip']) != 'undefined' && formElts
['zip'].checked
) {
444 theForm
.elements
['zip'].checked
= false;
446 if (typeof(formElts
['gzip']) != 'undefined' && formElts
['gzip'].checked
) {
447 theForm
.elements
['gzip'].checked
= false;
450 // 'transmit' option has been unchecked
451 else if (theAction
== 'transmit' && !formElts
['asfile'].checked
) {
452 if (typeof(formElts
['zip']) != 'undefined' && formElts
['zip'].checked
) {
453 theForm
.elements
['zip'].checked
= false;
455 if ((typeof(formElts
['gzip']) != 'undefined' && formElts
['gzip'].checked
)) {
456 theForm
.elements
['gzip'].checked
= false;
458 if ((typeof(formElts
['bzip']) != 'undefined' && formElts
['bzip'].checked
)) {
459 theForm
.elements
['bzip'].checked
= false;
464 } // end of the 'checkTransmitDump()' function
468 * This array is used to remember mark status of rows in browse mode
470 var marked_row
= new Array
;
473 * enables highlight and marking of rows in data tables
476 function PMA_markRowsInit() {
477 // for every table row ...
478 var rows
= document
.getElementsByTagName('tr');
479 for ( var i
= 0; i
< rows
.length
; i
++ ) {
480 // ... with the class 'odd' or 'even' ...
481 if ( 'odd' != rows
[i
].className
.substr(0,3) && 'even' != rows
[i
].className
.substr(0,4) ) {
484 // ... add event listeners ...
485 // ... to highlight the row on mouseover ...
486 if ( navigator
.appName
== 'Microsoft Internet Explorer' ) {
487 // but only for IE, other browsers are handled by :hover in css
488 rows
[i
].onmouseover = function() {
489 this.className
+= ' hover';
491 rows
[i
].onmouseout = function() {
492 this.className
= this.className
.replace( ' hover', '' );
495 // Do not set click events if not wanted
496 if (rows
[i
].className
.search(/noclick/) != -1) {
499 // ... and to mark the row on click ...
500 rows
[i
].onmousedown = function() {
504 checkbox
= this.getElementsByTagName( 'input' )[0];
505 if ( checkbox
&& checkbox
.type
== 'checkbox' ) {
506 unique_id
= checkbox
.name
+ checkbox
.value
;
507 } else if ( this.id
.length
> 0 ) {
513 if ( typeof(marked_row
[unique_id
]) == 'undefined' || !marked_row
[unique_id
] ) {
514 marked_row
[unique_id
] = true;
516 marked_row
[unique_id
] = false;
519 if ( marked_row
[unique_id
] ) {
520 this.className
+= ' marked';
522 this.className
= this.className
.replace(' marked', '');
525 if ( checkbox
&& checkbox
.disabled
== false ) {
526 checkbox
.checked
= marked_row
[unique_id
];
530 // ... and disable label ...
531 var labeltag
= rows
[i
].getElementsByTagName('label')[0];
533 labeltag
.onclick = function() {
537 // .. and checkbox clicks
538 var checkbox
= rows
[i
].getElementsByTagName('input')[0];
540 checkbox
.onclick = function() {
541 // opera does not recognize return false;
542 this.checked
= ! this.checked
;
547 window
.onload
=PMA_markRowsInit
;
550 * marks all rows and selects its first checkbox inside the given element
551 * the given element is usaly a table or a div containing the table or tables
553 * @param container DOM element
555 function markAllRows( container_id
) {
556 var rows
= document
.getElementById(container_id
).getElementsByTagName('tr');
560 for ( var i
= 0; i
< rows
.length
; i
++ ) {
562 checkbox
= rows
[i
].getElementsByTagName( 'input' )[0];
564 if ( checkbox
&& checkbox
.type
== 'checkbox' ) {
565 unique_id
= checkbox
.name
+ checkbox
.value
;
566 if ( checkbox
.disabled
== false ) {
567 checkbox
.checked
= true;
568 if ( typeof(marked_row
[unique_id
]) == 'undefined' || !marked_row
[unique_id
] ) {
569 rows
[i
].className
+= ' marked';
570 marked_row
[unique_id
] = true;
580 * marks all rows and selects its first checkbox inside the given element
581 * the given element is usaly a table or a div containing the table or tables
583 * @param container DOM element
585 function unMarkAllRows( container_id
) {
586 var rows
= document
.getElementById(container_id
).getElementsByTagName('tr');
590 for ( var i
= 0; i
< rows
.length
; i
++ ) {
592 checkbox
= rows
[i
].getElementsByTagName( 'input' )[0];
594 if ( checkbox
&& checkbox
.type
== 'checkbox' ) {
595 unique_id
= checkbox
.name
+ checkbox
.value
;
596 checkbox
.checked
= false;
597 rows
[i
].className
= rows
[i
].className
.replace(' marked', '');
598 marked_row
[unique_id
] = false;
606 * Sets/unsets the pointer and marker in browse mode
608 * @param object the table row
609 * @param integer the row number
610 * @param string the action calling this script (over, out or click)
611 * @param string the default background color
612 * @param string the color to use for mouseover
613 * @param string the color to use for marking a row
615 * @return boolean whether pointer is set or not
617 function setPointer(theRow
, theRowNum
, theAction
, theDefaultColor
, thePointerColor
, theMarkColor
)
621 // 1. Pointer and mark feature are disabled or the browser can't get the
623 if ((thePointerColor
== '' && theMarkColor
== '')
624 || typeof(theRow
.style
) == 'undefined') {
628 // 1.1 Sets the mouse pointer to pointer on mouseover and back to normal otherwise.
629 if (theAction
== "over" || theAction
== "click") {
630 theRow
.style
.cursor
='pointer';
632 theRow
.style
.cursor
='default';
635 // 2. Gets the current row and exits if the browser can't get it
636 if (typeof(document
.getElementsByTagName
) != 'undefined') {
637 theCells
= theRow
.getElementsByTagName('td');
639 else if (typeof(theRow
.cells
) != 'undefined') {
640 theCells
= theRow
.cells
;
646 // 3. Gets the current color...
647 var rowCellsCnt
= theCells
.length
;
648 var domDetect
= null;
649 var currentColor
= null;
651 // 3.1 ... with DOM compatible browsers except Opera that does not return
652 // valid values with "getAttribute"
653 if (typeof(window
.opera
) == 'undefined'
654 && typeof(theCells
[0].getAttribute
) != 'undefined') {
655 currentColor
= theCells
[0].getAttribute('bgcolor');
658 // 3.2 ... with other browsers
660 currentColor
= theCells
[0].style
.backgroundColor
;
664 // 3.3 ... Opera changes colors set via HTML to rgb(r,g,b) format so fix it
665 if (currentColor
.indexOf("rgb") >= 0)
667 var rgbStr
= currentColor
.slice(currentColor
.indexOf('(') + 1,
668 currentColor
.indexOf(')'));
669 var rgbValues
= rgbStr
.split(",");
671 var hexChars
= "0123456789ABCDEF";
672 for (var i
= 0; i
< 3; i
++)
674 var v
= rgbValues
[i
].valueOf();
675 currentColor
+= hexChars
.charAt(v
/16) + hexChars
.charAt(v
%16);
679 // 4. Defines the new color
680 // 4.1 Current color is the default one
681 if (currentColor
== ''
682 || currentColor
.toLowerCase() == theDefaultColor
.toLowerCase()) {
683 if (theAction
== 'over' && thePointerColor
!= '') {
684 newColor
= thePointerColor
;
686 else if (theAction
== 'click' && theMarkColor
!= '') {
687 newColor
= theMarkColor
;
688 marked_row
[theRowNum
] = true;
689 // Garvin: deactivated onclick marking of the checkbox because it's also executed
690 // when an action (like edit/delete) on a single item is performed. Then the checkbox
691 // would get deactived, even though we need it activated. Maybe there is a way
692 // to detect if the row was clicked, and not an item therein...
693 // document.getElementById('id_rows_to_delete' + theRowNum).checked = true;
696 // 4.1.2 Current color is the pointer one
697 else if (currentColor
.toLowerCase() == thePointerColor
.toLowerCase()
698 && (typeof(marked_row
[theRowNum
]) == 'undefined' || !marked_row
[theRowNum
])) {
699 if (theAction
== 'out') {
700 newColor
= theDefaultColor
;
702 else if (theAction
== 'click' && theMarkColor
!= '') {
703 newColor
= theMarkColor
;
704 marked_row
[theRowNum
] = true;
705 // document.getElementById('id_rows_to_delete' + theRowNum).checked = true;
708 // 4.1.3 Current color is the marker one
709 else if (currentColor
.toLowerCase() == theMarkColor
.toLowerCase()) {
710 if (theAction
== 'click') {
711 newColor
= (thePointerColor
!= '')
714 marked_row
[theRowNum
] = (typeof(marked_row
[theRowNum
]) == 'undefined' || !marked_row
[theRowNum
])
717 // document.getElementById('id_rows_to_delete' + theRowNum).checked = false;
721 // 5. Sets the new color...
724 // 5.1 ... with DOM compatible browsers except Opera
726 for (c
= 0; c
< rowCellsCnt
; c
++) {
727 theCells
[c
].setAttribute('bgcolor', newColor
, 0);
730 // 5.2 ... with other browsers
732 for (c
= 0; c
< rowCellsCnt
; c
++) {
733 theCells
[c
].style
.backgroundColor
= newColor
;
739 } // end of the 'setPointer()' function
742 * Sets/unsets the pointer and marker in vertical browse mode
744 * @param object the table row
745 * @param integer the column number
746 * @param string the action calling this script (over, out or click)
747 * @param string the default background Class
748 * @param string the Class to use for mouseover
749 * @param string the Class to use for marking a row
751 * @return boolean whether pointer is set or not
753 * @author Garvin Hicking <me@supergarv.de> (rewrite of setPointer.)
755 function setVerticalPointer(theRow
, theColNum
, theAction
, theDefaultClass1
, theDefaultClass2
, thePointerClass
, theMarkClass
) {
756 // 1. Pointer and mark feature are disabled or the browser can't get the
758 if ((thePointerClass
== '' && theMarkClass
== '')
759 || typeof(theRow
.style
) == 'undefined') {
763 var tagSwitch
= null;
765 // 2. Gets the current row and exits if the browser can't get it
766 if (typeof(document
.getElementsByTagName
) != 'undefined') {
768 } else if (typeof(document
.getElementById('table_results')) != 'undefined') {
776 if (tagSwitch
== 'tag') {
777 theRows
= document
.getElementById('table_results').getElementsByTagName('tr');
778 theCells
= theRows
[1].getElementsByTagName('td');
779 } else if (tagSwitch
== 'cells') {
780 theRows
= document
.getElementById('table_results').rows
;
781 theCells
= theRows
[1].cells
;
784 // 3. Gets the current Class...
785 var currentClass
= null;
788 // 3.1 ... with DOM compatible browsers except Opera that does not return
789 // valid values with "getAttribute"
790 if (typeof(window
.opera
) == 'undefined'
791 && typeof(theCells
[theColNum
].getAttribute
) != 'undefined') {
792 currentClass
= theCells
[theColNum
].className
;
795 // 4. Defines the new Class
796 // 4.1 Current Class is the default one
797 if (currentClass
== ''
798 || currentClass
.toLowerCase() == theDefaultClass1
.toLowerCase()
799 || currentClass
.toLowerCase() == theDefaultClass2
.toLowerCase()) {
800 if (theAction
== 'over' && thePointerClass
!= '') {
801 newClass
= thePointerClass
;
802 } else if (theAction
== 'click' && theMarkClass
!= '') {
803 newClass
= theMarkClass
;
804 marked_row
[theColNum
] = true;
807 // 4.1.2 Current Class is the pointer one
808 else if (currentClass
.toLowerCase() == thePointerClass
.toLowerCase() &&
809 (typeof(marked_row
[theColNum
]) == 'undefined' || !marked_row
[theColNum
]) || marked_row
[theColNum
] == false) {
810 if (theAction
== 'out') {
812 newClass
= theDefaultClass1
;
814 newClass
= theDefaultClass2
;
817 else if (theAction
== 'click' && theMarkClass
!= '') {
818 newClass
= theMarkClass
;
819 marked_row
[theColNum
] = true;
822 // 4.1.3 Current Class is the marker one
823 else if (currentClass
.toLowerCase() == theMarkClass
.toLowerCase()) {
824 if (theAction
== 'click') {
825 newClass
= (thePointerClass
!= '')
827 : ((theColNum
% 2) ? theDefaultClass2
: theDefaultClass1
);
828 marked_row
[theColNum
] = false;
832 // 5 ... with DOM compatible browsers except Opera
836 var rowCnt
= theRows
.length
;
837 for (c
= 0; c
< rowCnt
; c
++) {
838 if (tagSwitch
== 'tag') {
839 Cells
= theRows
[c
].getElementsByTagName('td');
840 } else if (tagSwitch
== 'cells') {
841 Cells
= theRows
[c
].cells
;
844 Cell
= Cells
[theColNum
];
846 // 5.1 Sets the new Class...
847 Cell
.className
= Cell
.className
.replace(currentClass
, newClass
);
852 } // end of the 'setVerticalPointer()' function
855 * Checks/unchecks all checkbox in given conainer (f.e. a form, fieldset or div)
857 * @param string container_id the container id
858 * @param boolean state new value for checkbox (true or false)
859 * @return boolean always true
861 function setCheckboxes( container_id
, state
) {
862 var checkboxes
= document
.getElementById(container_id
).getElementsByTagName('input');
864 for ( var i
= 0; i
< checkboxes
.length
; i
++ ) {
865 if ( checkboxes
[i
].type
== 'checkbox' ) {
866 checkboxes
[i
].checked
= state
;
871 } // end of the 'setCheckboxes()' function
874 // added 2004-05-08 by Michael Keck <mail_at_michaelkeck_dot_de>
875 // copy the checked from left to right or from right to left
876 // so it's easier for users to see, if $cfg['ModifyAtRight']=true, what they've checked ;)
877 function copyCheckboxesRange(the_form
, the_name
, the_clicked
)
879 if (typeof(document
.forms
[the_form
].elements
[the_name
]) != 'undefined' && typeof(document
.forms
[the_form
].elements
[the_name
+ 'r']) != 'undefined') {
880 if (the_clicked
!== 'r') {
881 if (document
.forms
[the_form
].elements
[the_name
].checked
== true) {
882 document
.forms
[the_form
].elements
[the_name
+ 'r'].checked
= true;
884 document
.forms
[the_form
].elements
[the_name
+ 'r'].checked
= false;
886 } else if (the_clicked
== 'r') {
887 if (document
.forms
[the_form
].elements
[the_name
+ 'r'].checked
== true) {
888 document
.forms
[the_form
].elements
[the_name
].checked
= true;
890 document
.forms
[the_form
].elements
[the_name
].checked
= false;
897 // added 2004-05-08 by Michael Keck <mail_at_michaelkeck_dot_de>
898 // - this was directly written to each td, so why not a function ;)
899 // setCheckboxColumn(\'id_rows_to_delete' . $row_no . ''\');
900 function setCheckboxColumn(theCheckbox
){
901 if (document
.getElementById(theCheckbox
)) {
902 document
.getElementById(theCheckbox
).checked
= (document
.getElementById(theCheckbox
).checked
? false : true);
903 if (document
.getElementById(theCheckbox
+ 'r')) {
904 document
.getElementById(theCheckbox
+ 'r').checked
= document
.getElementById(theCheckbox
).checked
;
907 if (document
.getElementById(theCheckbox
+ 'r')) {
908 document
.getElementById(theCheckbox
+ 'r').checked
= (document
.getElementById(theCheckbox
+'r').checked
? false : true);
909 if (document
.getElementById(theCheckbox
)) {
910 document
.getElementById(theCheckbox
).checked
= document
.getElementById(theCheckbox
+ 'r').checked
;
918 * Checks/unchecks all options of a <select> element
920 * @param string the form name
921 * @param string the element name
922 * @param boolean whether to check or to uncheck the element
924 * @return boolean always true
926 function setSelectOptions(the_form
, the_select
, do_check
)
928 var selectObject
= document
.forms
[the_form
].elements
[the_select
];
929 var selectCount
= selectObject
.length
;
931 for (var i
= 0; i
< selectCount
; i
++) {
932 selectObject
.options
[i
].selected
= do_check
;
936 } // end of the 'setSelectOptions()' function
939 * Inserts multiple fields.
942 function insertValueQuery() {
943 var myQuery
= document
.sqlform
.sql_query
;
944 var myListBox
= document
.sqlform
.dummy
;
946 if(myListBox
.options
.length
> 0) {
947 sql_box_locked
= true;
950 for(var i
=0; i
<myListBox
.options
.length
; i
++) {
951 if (myListBox
.options
[i
].selected
){
955 chaineAj
+= myListBox
.options
[i
].value
;
960 if (document
.selection
) {
962 sel
= document
.selection
.createRange();
964 document
.sqlform
.insert
.focus();
966 //MOZILLA/NETSCAPE support
967 else if (document
.sqlform
.sql_query
.selectionStart
|| document
.sqlform
.sql_query
.selectionStart
== "0") {
968 var startPos
= document
.sqlform
.sql_query
.selectionStart
;
969 var endPos
= document
.sqlform
.sql_query
.selectionEnd
;
970 var chaineSql
= document
.sqlform
.sql_query
.value
;
972 myQuery
.value
= chaineSql
.substring(0, startPos
) + chaineAj
+ chaineSql
.substring(endPos
, chaineSql
.length
);
974 myQuery
.value
+= chaineAj
;
976 sql_box_locked
= false;
981 * listbox redirection
983 function goToUrl(selObj
, goToLocation
) {
984 eval("document.location.href = '" + goToLocation
+ "pos=" + selObj
.options
[selObj
.selectedIndex
].value
+ "'");
990 function getElement(e
,f
){
993 if(f
.document
.layers
[e
]) {
994 return f
.document
.layers
[e
];
996 for(W
=0;W
<f
.document
.layers
.length
;W
++) {
997 return(getElement(e
,f
.document
.layers
[W
]));
1001 return document
.all
[e
];
1003 return document
.getElementById(e
);
1007 * Refresh the WYSIWYG-PDF scratchboard after changes have been made
1009 function refreshDragOption(e
) {
1010 myid
= getElement(e
);
1011 if (myid
.style
.visibility
== 'visible') {
1017 * Refresh/resize the WYSIWYG-PDF scratchboard
1019 function refreshLayout() {
1020 myid
= getElement('pdflayout');
1022 if (document
.pdfoptions
.orientation
.value
== 'P') {
1030 myid
.style
.width
= pdfPaperSize(document
.pdfoptions
.paper
.value
, posa
) + 'px';
1031 myid
.style
.height
= pdfPaperSize(document
.pdfoptions
.paper
.value
, posb
) + 'px';
1035 * Show/hide the WYSIWYG-PDF scratchboard
1037 function ToggleDragDrop(e
) {
1038 myid
= getElement(e
);
1040 if (myid
.style
.visibility
== 'hidden') {
1042 myid
.style
.visibility
= 'visible';
1043 myid
.style
.display
= 'block';
1044 document
.edcoord
.showwysiwyg
.value
= '1';
1046 myid
.style
.visibility
= 'hidden';
1047 myid
.style
.display
= 'none';
1048 document
.edcoord
.showwysiwyg
.value
= '0';
1053 * PDF scratchboard: When a position is entered manually, update
1054 * the fields inside the scratchboard.
1056 function dragPlace(no
, axis
, value
) {
1058 getElement("table_" + no
).style
.left
= value
+ 'px';
1060 getElement("table_" + no
).style
.top
= value
+ 'px';
1065 * Returns paper sizes for a given format
1067 function pdfPaperSize(format
, axis
) {
1068 switch (format
.toUpperCase()) {
1070 if (axis
== 'x') return 4767.87; else return 6740.79;
1073 if (axis
== 'x') return 3370.39; else return 4767.87;
1076 if (axis
== 'x') return 2383.94; else return 3370.39;
1079 if (axis
== 'x') return 1683.78; else return 2383.94;
1082 if (axis
== 'x') return 1190.55; else return 1683.78;
1085 if (axis
== 'x') return 841.89; else return 1190.55;
1088 if (axis
== 'x') return 595.28; else return 841.89;
1091 if (axis
== 'x') return 419.53; else return 595.28;
1094 if (axis
== 'x') return 297.64; else return 419.53;
1097 if (axis
== 'x') return 209.76; else return 297.64;
1100 if (axis
== 'x') return 147.40; else return 209.76;
1103 if (axis
== 'x') return 104.88; else return 147.40;
1106 if (axis
== 'x') return 73.70; else return 104.88;
1109 if (axis
== 'x') return 2834.65; else return 4008.19;
1112 if (axis
== 'x') return 2004.09; else return 2834.65;
1115 if (axis
== 'x') return 1417.32; else return 2004.09;
1118 if (axis
== 'x') return 1000.63; else return 1417.32;
1121 if (axis
== 'x') return 708.66; else return 1000.63;
1124 if (axis
== 'x') return 498.90; else return 708.66;
1127 if (axis
== 'x') return 354.33; else return 498.90;
1130 if (axis
== 'x') return 249.45; else return 354.33;
1133 if (axis
== 'x') return 175.75; else return 249.45;
1136 if (axis
== 'x') return 124.72; else return 175.75;
1139 if (axis
== 'x') return 87.87; else return 124.72;
1142 if (axis
== 'x') return 2599.37; else return 3676.54;
1145 if (axis
== 'x') return 1836.85; else return 2599.37;
1148 if (axis
== 'x') return 1298.27; else return 1836.85;
1151 if (axis
== 'x') return 918.43; else return 1298.27;
1154 if (axis
== 'x') return 649.13; else return 918.43;
1157 if (axis
== 'x') return 459.21; else return 649.13;
1160 if (axis
== 'x') return 323.15; else return 459.21;
1163 if (axis
== 'x') return 229.61; else return 323.15;
1166 if (axis
== 'x') return 161.57; else return 229.61;
1169 if (axis
== 'x') return 113.39; else return 161.57;
1172 if (axis
== 'x') return 79.37; else return 113.39;
1175 if (axis
== 'x') return 2437.80; else return 3458.27;
1178 if (axis
== 'x') return 1729.13; else return 2437.80;
1181 if (axis
== 'x') return 1218.90; else return 1729.13;
1184 if (axis
== 'x') return 864.57; else return 1218.90;
1187 if (axis
== 'x') return 609.45; else return 864.57;
1190 if (axis
== 'x') return 2551.18; else return 3628.35;
1193 if (axis
== 'x') return 1814.17; else return 2551.18;
1196 if (axis
== 'x') return 1275.59; else return 1814.17;
1199 if (axis
== 'x') return 907.09; else return 1275.59;
1202 if (axis
== 'x') return 637.80; else return 907.09;
1205 if (axis
== 'x') return 612.00; else return 792.00;
1208 if (axis
== 'x') return 612.00; else return 1008.00;
1211 if (axis
== 'x') return 521.86; else return 756.00;
1214 if (axis
== 'x') return 612.00; else return 936.00;