4 * @var sql_box_locked lock for the sqlbox textarea in the querybox/querywindow
6 var sql_box_locked
= false;
9 * @var array holds elements which content should only selected once
11 var only_once_elements
= new Array();
14 * selects the content of a given object, f.e. a textarea
16 * @param object element element of which the content will be selected
17 * @param var lock variable which holds the lock for this element
18 * or true, if no lock exists
19 * @param boolean only_once if true this is only done once
20 * f.e. only on first focus
22 function selectContent( element
, lock
, only_once
) {
23 if ( only_once
&& only_once_elements
[element
.name
] ) {
27 only_once_elements
[element
.name
] = true;
37 * Displays an confirmation box before to submit a "DROP DATABASE" query.
38 * This function is called while clicking links
40 * @param object the link
41 * @param object the sql query to submit
43 * @return boolean whether to run the query or not
45 function confirmLinkDropDB(theLink
, theSqlQuery
)
47 // Confirmation is not required in the configuration file
48 // or browser is Opera (crappy js implementation)
49 if (confirmMsg
== '' || typeof(window
.opera
) != 'undefined') {
53 var is_confirmed
= confirm(confirmMsgDropDB
+ '\n' + confirmMsg
+ ' :\n' + theSqlQuery
);
55 theLink
.href
+= '&is_js_confirmed=1';
59 } // end of the 'confirmLinkDropDB()' function
62 * Displays an confirmation box before to submit a "DROP/DELETE/ALTER" query.
63 * This function is called while clicking links
65 * @param object the link
66 * @param object the sql query to submit
68 * @return boolean whether to run the query or not
70 function confirmLink(theLink
, theSqlQuery
)
72 // Confirmation is not required in the configuration file
73 // or browser is Opera (crappy js implementation)
74 if (confirmMsg
== '' || typeof(window
.opera
) != 'undefined') {
78 var is_confirmed
= confirm(confirmMsg
+ ' :\n' + theSqlQuery
);
80 if ( typeof(theLink
.href
) != 'undefined' ) {
81 theLink
.href
+= '&is_js_confirmed=1';
82 } else if ( typeof(theLink
.form
) != 'undefined' ) {
83 theLink
.form
.action
+= '?is_js_confirmed=1';
88 } // end of the 'confirmLink()' function
92 * Displays an confirmation box before doing some action
94 * @param object the message to display
96 * @return boolean whether to run the query or not
98 function confirmAction(theMessage
)
100 // TODO: Confirmation is not required in the configuration file
101 // or browser is Opera (crappy js implementation)
102 if (typeof(window
.opera
) != 'undefined') {
106 var is_confirmed
= confirm(theMessage
);
109 } // end of the 'confirmAction()' function
113 * Displays an error message if a "DROP DATABASE" statement is submitted
114 * while it isn't allowed, else confirms a "DROP/DELETE/ALTER" query before
115 * sumitting it if required.
116 * This function is called by the 'checkSqlQuery()' js function.
118 * @param object the form
119 * @param object the sql query textarea
121 * @return boolean whether to run the query or not
123 * @see checkSqlQuery()
125 function confirmQuery(theForm1
, sqlQuery1
)
127 // Confirmation is not required in the configuration file
128 if (confirmMsg
== '') {
132 // The replace function (js1.2) isn't supported
133 else if (typeof(sqlQuery1
.value
.replace
) == 'undefined') {
137 // js1.2+ -> validation with regular expressions
139 // "DROP DATABASE" statement isn't allowed
140 if (noDropDbMsg
!= '') {
141 var drop_re
= new RegExp('DROP\\s+(IF EXISTS\\s+)?DATABASE\\s', 'i');
142 if (drop_re
.test(sqlQuery1
.value
)) {
150 // Confirms a "DROP/DELETE/ALTER" statement
152 // TODO: find a way (if possible) to use the parser-analyser
153 // for this kind of verification
154 // For now, I just added a ^ to check for the statement at
155 // beginning of expression
157 var do_confirm_re_0
= new RegExp('^DROP\\s+(IF EXISTS\\s+)?(TABLE|DATABASE)\\s', 'i');
158 var do_confirm_re_1
= new RegExp('^ALTER\\s+TABLE\\s+((`[^`]+`)|([A-Za-z0-9_$]+))\\s+DROP\\s', 'i');
159 var do_confirm_re_2
= new RegExp('^DELETE\\s+FROM\\s', 'i');
160 if (do_confirm_re_0
.test(sqlQuery1
.value
)
161 || do_confirm_re_1
.test(sqlQuery1
.value
)
162 || do_confirm_re_2
.test(sqlQuery1
.value
)) {
163 var message
= (sqlQuery1
.value
.length
> 100)
164 ? sqlQuery1
.value
.substr(0, 100) + '\n ...'
166 var is_confirmed
= confirm(confirmMsg
+ ' :\n' + message
);
167 // drop/delete/alter statement is confirmed -> update the
168 // "is_js_confirmed" form field so the confirm test won't be
169 // run on the server side and allows to submit the form
171 theForm1
.elements
['is_js_confirmed'].value
= 1;
174 // "DROP/DELETE/ALTER" statement is rejected -> do not submit
180 } // end if (handle confirm box result)
181 } // end if (display confirm box)
182 } // end confirmation stuff
185 } // end of the 'confirmQuery()' function
189 * Displays an error message if the user submitted the sql query form with no
190 * sql query, else checks for "DROP/DELETE/ALTER" statements
192 * @param object the form
194 * @return boolean always false
196 * @see confirmQuery()
198 function checkSqlQuery(theForm
)
200 var sqlQuery
= theForm
.elements
['sql_query'];
203 // The replace function (js1.2) isn't supported -> basic tests
204 if (typeof(sqlQuery
.value
.replace
) == 'undefined') {
205 isEmpty
= (sqlQuery
.value
== '') ? 1 : 0;
206 if (isEmpty
&& typeof(theForm
.elements
['sql_file']) != 'undefined') {
207 isEmpty
= (theForm
.elements
['sql_file'].value
== '') ? 1 : 0;
209 if (isEmpty
&& typeof(theForm
.elements
['sql_localfile']) != 'undefined') {
210 isEmpty
= (theForm
.elements
['sql_localfile'].value
== '') ? 1 : 0;
212 if (isEmpty
&& typeof(theForm
.elements
['id_bookmark']) != 'undefined') {
213 isEmpty
= (theForm
.elements
['id_bookmark'].value
== null || theForm
.elements
['id_bookmark'].value
== '');
216 // js1.2+ -> validation with regular expressions
218 var space_re
= new RegExp('\\s+');
219 if (typeof(theForm
.elements
['sql_file']) != 'undefined' &&
220 theForm
.elements
['sql_file'].value
.replace(space_re
, '') != '') {
223 if (typeof(theForm
.elements
['sql_localfile']) != 'undefined' &&
224 theForm
.elements
['sql_localfile'].value
.replace(space_re
, '') != '') {
227 if (isEmpty
&& typeof(theForm
.elements
['id_bookmark']) != 'undefined' &&
228 (theForm
.elements
['id_bookmark'].value
!= null || theForm
.elements
['id_bookmark'].value
!= '') &&
229 theForm
.elements
['id_bookmark'].selectedIndex
!= 0
233 // Checks for "DROP/DELETE/ALTER" statements
234 if (sqlQuery
.value
.replace(space_re
, '') != '') {
235 if (confirmQuery(theForm
, sqlQuery
)) {
253 } // end of the 'checkSqlQuery()' function
257 * Check if a form's element is empty
260 * @param object the form
261 * @param string the name of the form field to put the focus on
263 * @return boolean whether the form field is empty or not
265 function emptyCheckTheField(theForm
, theFieldName
)
268 var theField
= theForm
.elements
[theFieldName
];
269 // Whether the replace function (js1.2) is supported or not
270 var isRegExp
= (typeof(theField
.value
.replace
) != 'undefined');
273 isEmpty
= (theField
.value
== '') ? 1 : 0;
275 var space_re
= new RegExp('\\s+');
276 isEmpty
= (theField
.value
.replace(space_re
, '') == '') ? 1 : 0;
280 } // end of the 'emptyCheckTheField()' function
284 * Displays an error message if an element of a form hasn't been completed and
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 emptyFormElements(theForm
, theFieldName
)
294 var theField
= theForm
.elements
[theFieldName
];
295 isEmpty
= emptyCheckTheField(theForm
, theFieldName
);
306 } // end of the 'emptyFormElements()' function
310 * Ensures a value submitted in a form is numeric and is in a range
312 * @param object the form
313 * @param string the name of the form field to check
314 * @param integer the minimum authorized value
315 * @param integer the maximum authorized value
317 * @return boolean whether a valid number has been submitted or not
319 function checkFormElementInRange(theForm
, theFieldName
, message
, min
, max
)
321 var theField
= theForm
.elements
[theFieldName
];
322 var val
= parseInt(theField
.value
);
324 if (typeof(min
) == 'undefined') {
327 if (typeof(max
) == 'undefined') {
328 max
= Number
.MAX_VALUE
;
338 // It's a number but it is not between min and max
339 else if (val
< min
|| val
> max
) {
341 alert(message
.replace('%d', val
));
345 // It's a valid number
347 theField
.value
= val
;
351 } // end of the 'checkFormElementInRange()' function
354 function checkTableEditForm(theForm
, fieldsCnt
)
356 // TODO: avoid sending a message if user just wants to add a line
357 // on the form but has not completed at least one field name
359 var atLeastOneField
= 0;
360 var i
, elm
, elm2
, elm3
, val
, id
;
362 for (i
=0; i
<fieldsCnt
; i
++)
364 id
= "field_" + i
+ "_2";
365 elm
= getElement(id
);
366 if (elm
.value
== 'VARCHAR' || elm
.value
== 'CHAR') {
367 elm2
= getElement("field_" + i
+ "_3");
368 val
= parseInt(elm2
.value
);
369 elm3
= getElement("field_" + i
+ "_1");
370 if (isNaN(val
) && elm3
.value
!= "") {
378 if (atLeastOneField
== 0) {
379 id
= "field_" + i
+ "_1";
380 if (!emptyCheckTheField(theForm
, id
)) {
385 if (atLeastOneField
== 0) {
386 var theField
= theForm
.elements
["field_0_1"];
393 } // enf of the 'checkTableEditForm()' function
397 * Ensures the choice between 'transmit', 'zipped', 'gzipped' and 'bzipped'
398 * checkboxes is consistant
400 * @param object the form
401 * @param string a code for the action that causes this function to be run
403 * @return boolean always true
405 function checkTransmitDump(theForm
, theAction
)
407 var formElts
= theForm
.elements
;
409 // 'zipped' option has been checked
410 if (theAction
== 'zip' && formElts
['zip'].checked
) {
411 if (!formElts
['asfile'].checked
) {
412 theForm
.elements
['asfile'].checked
= true;
414 if (typeof(formElts
['gzip']) != 'undefined' && formElts
['gzip'].checked
) {
415 theForm
.elements
['gzip'].checked
= false;
417 if (typeof(formElts
['bzip']) != 'undefined' && formElts
['bzip'].checked
) {
418 theForm
.elements
['bzip'].checked
= false;
421 // 'gzipped' option has been checked
422 else if (theAction
== 'gzip' && formElts
['gzip'].checked
) {
423 if (!formElts
['asfile'].checked
) {
424 theForm
.elements
['asfile'].checked
= true;
426 if (typeof(formElts
['zip']) != 'undefined' && formElts
['zip'].checked
) {
427 theForm
.elements
['zip'].checked
= false;
429 if (typeof(formElts
['bzip']) != 'undefined' && formElts
['bzip'].checked
) {
430 theForm
.elements
['bzip'].checked
= false;
433 // 'bzipped' option has been checked
434 else if (theAction
== 'bzip' && formElts
['bzip'].checked
) {
435 if (!formElts
['asfile'].checked
) {
436 theForm
.elements
['asfile'].checked
= true;
438 if (typeof(formElts
['zip']) != 'undefined' && formElts
['zip'].checked
) {
439 theForm
.elements
['zip'].checked
= false;
441 if (typeof(formElts
['gzip']) != 'undefined' && formElts
['gzip'].checked
) {
442 theForm
.elements
['gzip'].checked
= false;
445 // 'transmit' option has been unchecked
446 else if (theAction
== 'transmit' && !formElts
['asfile'].checked
) {
447 if (typeof(formElts
['zip']) != 'undefined' && formElts
['zip'].checked
) {
448 theForm
.elements
['zip'].checked
= false;
450 if ((typeof(formElts
['gzip']) != 'undefined' && formElts
['gzip'].checked
)) {
451 theForm
.elements
['gzip'].checked
= false;
453 if ((typeof(formElts
['bzip']) != 'undefined' && formElts
['bzip'].checked
)) {
454 theForm
.elements
['bzip'].checked
= false;
459 } // end of the 'checkTransmitDump()' function
463 * This array is used to remember mark status of rows in browse mode
465 var marked_row
= new Array
;
468 * enables highlight and marking of rows in data tables
471 function PMA_markRowsInit() {
472 // for every table row ...
473 var rows
= document
.getElementsByTagName('tr');
474 for ( var i
= 0; i
< rows
.length
; i
++ ) {
475 // ... with the class 'odd' or 'even' ...
476 if ( 'odd' != rows
[i
].className
&& 'even' != rows
[i
].className
) {
479 // ... add event listeners ...
480 // ... to highlight the row on mouseover ...
481 if ( navigator
.appName
== 'Microsoft Internet Explorer' ) {
482 // but only for IE, other browsers are handled by :hover in css
483 rows
[i
].onmouseover = function() {
484 this.className
+= ' hover';
486 rows
[i
].onmouseout = function() {
487 this.className
= this.className
.replace( ' hover', '' );
490 // ... and to mark the row on click ...
491 rows
[i
].onmousedown = function() {
495 checkbox
= this.getElementsByTagName( 'input' )[0];
496 if ( checkbox
&& checkbox
.type
== 'checkbox' ) {
497 unique_id
= checkbox
.name
+ checkbox
.value
;
498 } else if ( this.id
.length
> 0 ) {
504 if ( typeof(marked_row
[unique_id
]) == 'undefined' || !marked_row
[unique_id
] ) {
505 marked_row
[unique_id
] = true;
507 marked_row
[unique_id
] = false;
510 if ( marked_row
[unique_id
] ) {
511 this.className
+= ' marked';
513 this.className
= this.className
.replace(' marked', '');
516 if ( checkbox
&& checkbox
.disabled
== false ) {
517 checkbox
.checked
= marked_row
[unique_id
];
521 // ... and disable label ...
522 var labeltag
= rows
[i
].getElementsByTagName('label')[0];
524 labeltag
.onclick = function() {
528 // .. and checkbox clicks
529 var checkbox
= rows
[i
].getElementsByTagName('input')[0];
531 checkbox
.onclick = function() {
532 // opera does not recognize return false;
533 this.checked
= ! this.checked
;
538 window
.onload
=PMA_markRowsInit
;
541 * marks all rows and selects its first checkbox inside the given element
542 * the given element is usaly a table or a div containing the table or tables
544 * @param container DOM element
546 function markAllRows( container_id
) {
547 var rows
= document
.getElementById(container_id
).getElementsByTagName('tr');
551 for ( var i
= 0; i
< rows
.length
; i
++ ) {
553 checkbox
= rows
[i
].getElementsByTagName( 'input' )[0];
555 if ( checkbox
&& checkbox
.type
== 'checkbox' ) {
556 unique_id
= checkbox
.name
+ checkbox
.value
;
557 if ( checkbox
.disabled
== false ) {
558 checkbox
.checked
= true;
559 if ( typeof(marked_row
[unique_id
]) == 'undefined' || !marked_row
[unique_id
] ) {
560 rows
[i
].className
+= ' marked';
561 marked_row
[unique_id
] = true;
571 * marks all rows and selects its first checkbox inside the given element
572 * the given element is usaly a table or a div containing the table or tables
574 * @param container DOM element
576 function unMarkAllRows( container_id
) {
577 var rows
= document
.getElementById(container_id
).getElementsByTagName('tr');
581 for ( var i
= 0; i
< rows
.length
; i
++ ) {
583 checkbox
= rows
[i
].getElementsByTagName( 'input' )[0];
585 if ( checkbox
&& checkbox
.type
== 'checkbox' ) {
586 unique_id
= checkbox
.name
+ checkbox
.value
;
587 checkbox
.checked
= false;
588 rows
[i
].className
= rows
[i
].className
.replace(' marked', '');
589 marked_row
[unique_id
] = false;
597 * Sets/unsets the pointer and marker in browse mode
599 * @param object the table row
600 * @param integer the row number
601 * @param string the action calling this script (over, out or click)
602 * @param string the default background color
603 * @param string the color to use for mouseover
604 * @param string the color to use for marking a row
606 * @return boolean whether pointer is set or not
608 function setPointer(theRow
, theRowNum
, theAction
, theDefaultColor
, thePointerColor
, theMarkColor
)
612 // 1. Pointer and mark feature are disabled or the browser can't get the
614 if ((thePointerColor
== '' && theMarkColor
== '')
615 || typeof(theRow
.style
) == 'undefined') {
619 // 1.1 Sets the mouse pointer to pointer on mouseover and back to normal otherwise.
620 if (theAction
== "over" || theAction
== "click") {
621 theRow
.style
.cursor
='pointer';
623 theRow
.style
.cursor
='default';
626 // 2. Gets the current row and exits if the browser can't get it
627 if (typeof(document
.getElementsByTagName
) != 'undefined') {
628 theCells
= theRow
.getElementsByTagName('td');
630 else if (typeof(theRow
.cells
) != 'undefined') {
631 theCells
= theRow
.cells
;
637 // 3. Gets the current color...
638 var rowCellsCnt
= theCells
.length
;
639 var domDetect
= null;
640 var currentColor
= null;
642 // 3.1 ... with DOM compatible browsers except Opera that does not return
643 // valid values with "getAttribute"
644 if (typeof(window
.opera
) == 'undefined'
645 && typeof(theCells
[0].getAttribute
) != 'undefined') {
646 currentColor
= theCells
[0].getAttribute('bgcolor');
649 // 3.2 ... with other browsers
651 currentColor
= theCells
[0].style
.backgroundColor
;
655 // 3.3 ... Opera changes colors set via HTML to rgb(r,g,b) format so fix it
656 if (currentColor
.indexOf("rgb") >= 0)
658 var rgbStr
= currentColor
.slice(currentColor
.indexOf('(') + 1,
659 currentColor
.indexOf(')'));
660 var rgbValues
= rgbStr
.split(",");
662 var hexChars
= "0123456789ABCDEF";
663 for (var i
= 0; i
< 3; i
++)
665 var v
= rgbValues
[i
].valueOf();
666 currentColor
+= hexChars
.charAt(v
/16) + hexChars
.charAt(v
%16);
670 // 4. Defines the new color
671 // 4.1 Current color is the default one
672 if (currentColor
== ''
673 || currentColor
.toLowerCase() == theDefaultColor
.toLowerCase()) {
674 if (theAction
== 'over' && thePointerColor
!= '') {
675 newColor
= thePointerColor
;
677 else if (theAction
== 'click' && theMarkColor
!= '') {
678 newColor
= theMarkColor
;
679 marked_row
[theRowNum
] = true;
680 // Garvin: deactivated onclick marking of the checkbox because it's also executed
681 // when an action (like edit/delete) on a single item is performed. Then the checkbox
682 // would get deactived, even though we need it activated. Maybe there is a way
683 // to detect if the row was clicked, and not an item therein...
684 // document.getElementById('id_rows_to_delete' + theRowNum).checked = true;
687 // 4.1.2 Current color is the pointer one
688 else if (currentColor
.toLowerCase() == thePointerColor
.toLowerCase()
689 && (typeof(marked_row
[theRowNum
]) == 'undefined' || !marked_row
[theRowNum
])) {
690 if (theAction
== 'out') {
691 newColor
= theDefaultColor
;
693 else if (theAction
== 'click' && theMarkColor
!= '') {
694 newColor
= theMarkColor
;
695 marked_row
[theRowNum
] = true;
696 // document.getElementById('id_rows_to_delete' + theRowNum).checked = true;
699 // 4.1.3 Current color is the marker one
700 else if (currentColor
.toLowerCase() == theMarkColor
.toLowerCase()) {
701 if (theAction
== 'click') {
702 newColor
= (thePointerColor
!= '')
705 marked_row
[theRowNum
] = (typeof(marked_row
[theRowNum
]) == 'undefined' || !marked_row
[theRowNum
])
708 // document.getElementById('id_rows_to_delete' + theRowNum).checked = false;
712 // 5. Sets the new color...
715 // 5.1 ... with DOM compatible browsers except Opera
717 for (c
= 0; c
< rowCellsCnt
; c
++) {
718 theCells
[c
].setAttribute('bgcolor', newColor
, 0);
721 // 5.2 ... with other browsers
723 for (c
= 0; c
< rowCellsCnt
; c
++) {
724 theCells
[c
].style
.backgroundColor
= newColor
;
730 } // end of the 'setPointer()' function
733 * Sets/unsets the pointer and marker in vertical browse mode
735 * @param object the table row
736 * @param integer the column number
737 * @param string the action calling this script (over, out or click)
738 * @param string the default background color
739 * @param string the color to use for mouseover
740 * @param string the color to use for marking a row
742 * @return boolean whether pointer is set or not
744 * @author Garvin Hicking <me@supergarv.de> (rewrite of setPointer.)
746 function setVerticalPointer(theRow
, theColNum
, theAction
, theDefaultColor1
, theDefaultColor2
, thePointerColor
, theMarkColor
) {
748 var tagSwitch
= null;
750 // 1. Pointer and mark feature are disabled or the browser can't get the
752 if ((thePointerColor
== '' && theMarkColor
== '')
753 || typeof(theRow
.style
) == 'undefined') {
757 if (typeof(document
.getElementsByTagName
) != 'undefined') {
759 } else if (typeof(document
.getElementById('table_results')) != 'undefined') {
765 // 2. Gets the current row and exits if the browser can't get it
766 if (tagSwitch
== 'tag') {
767 theRows
= document
.getElementById('table_results').getElementsByTagName('tr');
768 theCells
= theRows
[1].getElementsByTagName('td');
769 } else if (tagSwitch
== 'cells') {
770 theRows
= document
.getElementById('table_results').rows
;
771 theCells
= theRows
[1].cells
;
774 // 3. Gets the current color...
775 var rowCnt
= theRows
.length
;
776 var domDetect
= null;
777 var currentColor
= null;
780 // 3.1 ... with DOM compatible browsers except Opera that does not return
781 // valid values with "getAttribute"
782 if (typeof(window
.opera
) == 'undefined'
783 && typeof(theCells
[theColNum
].getAttribute
) != 'undefined') {
784 currentColor
= theCells
[theColNum
].getAttribute('bgcolor');
787 // 3.2 ... with other browsers
790 currentColor
= theCells
[theColNum
].style
.backgroundColor
;
795 // 4. Defines the new color
796 // 4.1 Current color is the default one
797 if (currentColor
== ''
798 || currentColor
.toLowerCase() == theDefaultColor1
.toLowerCase()
799 || currentColor
.toLowerCase() == theDefaultColor2
.toLowerCase()) {
800 if (theAction
== 'over' && thePointerColor
!= '') {
801 newColor
= thePointerColor
;
802 } else if (theAction
== 'click' && theMarkColor
!= '') {
803 newColor
= theMarkColor
;
804 marked_row
[theColNum
] = true;
807 // 4.1.2 Current color is the pointer one
808 else if (currentColor
.toLowerCase() == thePointerColor
.toLowerCase() &&
809 (typeof(marked_row
[theColNum
]) == 'undefined' || !marked_row
[theColNum
]) || marked_row
[theColNum
] == false) {
810 if (theAction
== 'out') {
812 newColor
= theDefaultColor1
;
814 newColor
= theDefaultColor2
;
817 else if (theAction
== 'click' && theMarkColor
!= '') {
818 newColor
= theMarkColor
;
819 marked_row
[theColNum
] = true;
822 // 4.1.3 Current color is the marker one
823 else if (currentColor
.toLowerCase() == theMarkColor
.toLowerCase()) {
824 if (theAction
== 'click') {
825 newColor
= (thePointerColor
!= '')
827 : ((theColNum
% 2) ? theDefaultColor1
: theDefaultColor2
);
828 marked_row
[theColNum
] = false;
832 // 5 ... with DOM compatible browsers except Opera
834 for (c
= 0; c
< rowCnt
; c
++) {
835 if (tagSwitch
== 'tag') {
836 Cells
= theRows
[c
].getElementsByTagName('td');
837 } else if (tagSwitch
== 'cells') {
838 Cells
= theRows
[c
].cells
;
841 Cell
= Cells
[theColNum
];
843 // 5.1 Sets the new color...
846 Cell
.setAttribute('bgcolor', newColor
, 0);
848 Cell
.style
.backgroundColor
= newColor
;
854 } // end of the 'setVerticalPointer()' function
857 * Checks/unchecks all checkbox in given conainer (f.e. a form, fieldset or div)
859 * @param string container_id the container id
860 * @param boolean state new value for checkbox (true or false)
861 * @return boolean always true
863 function setCheckboxes( container_id
, state
) {
864 var checkboxes
= document
.getElementById(container_id
).getElementsByTagName('input');
866 for ( var i
= 0; i
< checkboxes
.length
; i
++ ) {
867 if ( checkboxes
[i
].type
== 'checkbox' ) {
868 checkboxes
[i
].checked
= state
;
873 } // end of the 'setCheckboxes()' function
876 // added 2004-05-08 by Michael Keck <mail_at_michaelkeck_dot_de>
877 // copy the checked from left to right or from right to left
878 // so it's easier for users to see, if $cfg['ModifyAtRight']=true, what they've checked ;)
879 function copyCheckboxesRange(the_form
, the_name
, the_clicked
)
881 if (typeof(document
.forms
[the_form
].elements
[the_name
]) != 'undefined' && typeof(document
.forms
[the_form
].elements
[the_name
+ 'r']) != 'undefined') {
882 if (the_clicked
!== 'r') {
883 if (document
.forms
[the_form
].elements
[the_name
].checked
== true) {
884 document
.forms
[the_form
].elements
[the_name
+ 'r'].checked
= true;
886 document
.forms
[the_form
].elements
[the_name
+ 'r'].checked
= false;
888 } else if (the_clicked
== 'r') {
889 if (document
.forms
[the_form
].elements
[the_name
+ 'r'].checked
== true) {
890 document
.forms
[the_form
].elements
[the_name
].checked
= true;
892 document
.forms
[the_form
].elements
[the_name
].checked
= false;
899 // added 2004-05-08 by Michael Keck <mail_at_michaelkeck_dot_de>
900 // - this was directly written to each td, so why not a function ;)
901 // setCheckboxColumn(\'id_rows_to_delete' . $row_no . ''\');
902 function setCheckboxColumn(theCheckbox
){
903 if (document
.getElementById(theCheckbox
)) {
904 document
.getElementById(theCheckbox
).checked
= (document
.getElementById(theCheckbox
).checked
? false : true);
905 if (document
.getElementById(theCheckbox
+ 'r')) {
906 document
.getElementById(theCheckbox
+ 'r').checked
= document
.getElementById(theCheckbox
).checked
;
909 if (document
.getElementById(theCheckbox
+ 'r')) {
910 document
.getElementById(theCheckbox
+ 'r').checked
= (document
.getElementById(theCheckbox
+'r').checked
? false : true);
911 if (document
.getElementById(theCheckbox
)) {
912 document
.getElementById(theCheckbox
).checked
= document
.getElementById(theCheckbox
+ 'r').checked
;
920 * Checks/unchecks all options of a <select> element
922 * @param string the form name
923 * @param string the element name
924 * @param boolean whether to check or to uncheck the element
926 * @return boolean always true
928 function setSelectOptions(the_form
, the_select
, do_check
)
930 var selectObject
= document
.forms
[the_form
].elements
[the_select
];
931 var selectCount
= selectObject
.length
;
933 for (var i
= 0; i
< selectCount
; i
++) {
934 selectObject
.options
[i
].selected
= do_check
;
938 } // end of the 'setSelectOptions()' function
941 * Inserts multiple fields.
944 function insertValueQuery() {
945 var myQuery
= document
.sqlform
.sql_query
;
946 var myListBox
= document
.sqlform
.dummy
;
948 if(myListBox
.options
.length
> 0) {
949 sql_box_locked
= true;
952 for(var i
=0; i
<myListBox
.options
.length
; i
++) {
953 if (myListBox
.options
[i
].selected
){
957 chaineAj
+= myListBox
.options
[i
].value
;
962 if (document
.selection
) {
964 sel
= document
.selection
.createRange();
966 document
.sqlform
.insert
.focus();
968 //MOZILLA/NETSCAPE support
969 else if (document
.sqlform
.sql_query
.selectionStart
|| document
.sqlform
.sql_query
.selectionStart
== "0") {
970 var startPos
= document
.sqlform
.sql_query
.selectionStart
;
971 var endPos
= document
.sqlform
.sql_query
.selectionEnd
;
972 var chaineSql
= document
.sqlform
.sql_query
.value
;
974 myQuery
.value
= chaineSql
.substring(0, startPos
) + chaineAj
+ chaineSql
.substring(endPos
, chaineSql
.length
);
976 myQuery
.value
+= chaineAj
;
978 sql_box_locked
= false;
983 * listbox redirection
985 function goToUrl(selObj
, goToLocation
) {
986 eval("document.location.href = '" + goToLocation
+ "pos=" + selObj
.options
[selObj
.selectedIndex
].value
+ "'");
992 function getElement(e
,f
){
995 if(f
.document
.layers
[e
]) {
996 return f
.document
.layers
[e
];
998 for(W
=0;i
<f
.document
.layers
.length
;W
++) {
999 return(getElement(e
,fdocument
.layers
[W
]));
1003 return document
.all
[e
];
1005 return document
.getElementById(e
);
1009 * Refresh the WYSIWYG-PDF scratchboard after changes have been made
1011 function refreshDragOption(e
) {
1012 myid
= getElement(e
);
1013 if (myid
.style
.visibility
== 'visible') {
1019 * Refresh/resize the WYSIWYG-PDF scratchboard
1021 function refreshLayout() {
1022 myid
= getElement('pdflayout');
1024 if (document
.pdfoptions
.orientation
.value
== 'P') {
1032 myid
.style
.width
= pdfPaperSize(document
.pdfoptions
.paper
.value
, posa
) + 'px';
1033 myid
.style
.height
= pdfPaperSize(document
.pdfoptions
.paper
.value
, posb
) + 'px';
1037 * Show/hide the WYSIWYG-PDF scratchboard
1039 function ToggleDragDrop(e
) {
1040 myid
= getElement(e
);
1042 if (myid
.style
.visibility
== 'hidden') {
1044 myid
.style
.visibility
= 'visible';
1045 myid
.style
.display
= 'block';
1046 document
.edcoord
.showwysiwyg
.value
= '1';
1048 myid
.style
.visibility
= 'hidden';
1049 myid
.style
.display
= 'none';
1050 document
.edcoord
.showwysiwyg
.value
= '0';
1055 * PDF scratchboard: When a position is entered manually, update
1056 * the fields inside the scratchboard.
1058 function dragPlace(no
, axis
, value
) {
1060 getElement("table_" + no
).style
.left
= value
+ 'px';
1062 getElement("table_" + no
).style
.top
= value
+ 'px';
1067 * Returns paper sizes for a given format
1069 function pdfPaperSize(format
, axis
) {
1070 switch (format
.toUpperCase()) {
1072 if (axis
== 'x') return 4767.87; else return 6740.79;
1075 if (axis
== 'x') return 3370.39; else return 4767.87;
1078 if (axis
== 'x') return 2383.94; else return 3370.39;
1081 if (axis
== 'x') return 1683.78; else return 2383.94;
1084 if (axis
== 'x') return 1190.55; else return 1683.78;
1087 if (axis
== 'x') return 841.89; else return 1190.55;
1090 if (axis
== 'x') return 595.28; else return 841.89;
1093 if (axis
== 'x') return 419.53; else return 595.28;
1096 if (axis
== 'x') return 297.64; else return 419.53;
1099 if (axis
== 'x') return 209.76; else return 297.64;
1102 if (axis
== 'x') return 147.40; else return 209.76;
1105 if (axis
== 'x') return 104.88; else return 147.40;
1108 if (axis
== 'x') return 73.70; else return 104.88;
1111 if (axis
== 'x') return 2834.65; else return 4008.19;
1114 if (axis
== 'x') return 2004.09; else return 2834.65;
1117 if (axis
== 'x') return 1417.32; else return 2004.09;
1120 if (axis
== 'x') return 1000.63; else return 1417.32;
1123 if (axis
== 'x') return 708.66; else return 1000.63;
1126 if (axis
== 'x') return 498.90; else return 708.66;
1129 if (axis
== 'x') return 354.33; else return 498.90;
1132 if (axis
== 'x') return 249.45; else return 354.33;
1135 if (axis
== 'x') return 175.75; else return 249.45;
1138 if (axis
== 'x') return 124.72; else return 175.75;
1141 if (axis
== 'x') return 87.87; else return 124.72;
1144 if (axis
== 'x') return 2599.37; else return 3676.54;
1147 if (axis
== 'x') return 1836.85; else return 2599.37;
1150 if (axis
== 'x') return 1298.27; else return 1836.85;
1153 if (axis
== 'x') return 918.43; else return 1298.27;
1156 if (axis
== 'x') return 649.13; else return 918.43;
1159 if (axis
== 'x') return 459.21; else return 649.13;
1162 if (axis
== 'x') return 323.15; else return 459.21;
1165 if (axis
== 'x') return 229.61; else return 323.15;
1168 if (axis
== 'x') return 161.57; else return 229.61;
1171 if (axis
== 'x') return 113.39; else return 161.57;
1174 if (axis
== 'x') return 79.37; else return 113.39;
1177 if (axis
== 'x') return 2437.80; else return 3458.27;
1180 if (axis
== 'x') return 1729.13; else return 2437.80;
1183 if (axis
== 'x') return 1218.90; else return 1729.13;
1186 if (axis
== 'x') return 864.57; else return 1218.90;
1189 if (axis
== 'x') return 609.45; else return 864.57;
1192 if (axis
== 'x') return 2551.18; else return 3628.35;
1195 if (axis
== 'x') return 1814.17; else return 2551.18;
1198 if (axis
== 'x') return 1275.59; else return 1814.17;
1201 if (axis
== 'x') return 907.09; else return 1275.59;
1204 if (axis
== 'x') return 637.80; else return 907.09;
1207 if (axis
== 'x') return 612.00; else return 792.00;
1210 if (axis
== 'x') return 612.00; else return 1008.00;
1213 if (axis
== 'x') return 521.86; else return 756.00;
1216 if (axis
== 'x') return 612.00; else return 936.00;