Source for file JavaScript.class.php
Documentation is available at JavaScript.class.php
* For including this file you have to define the constant "CLASSPATH".
* Because every include in the framework depends on the CLASSPATH definition.
* The CLASSPATH means the relative path to the folder that contains the
echo "<h3>You have to define the constant CLASSPATH!</h3>\n";
echo "Example: define( 'CLASSPATH', '../path/to/classes/' );\n";
* Including a class to format plain text.
require_once( CLASSPATH. "core/PlainTextFormatter.class.php" );
* Setting up javascripts.
* @author Daniel Plücken <daniel@debakel.net>
* @license http://www.gnu.org/copyleft/lesser.html
* GNU Lesser General Public License
* @copyright Copyright (c) 2004 Daniel Plücken <daniel@debakel.net>
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License.
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
* You should have received a copy of the GNU Lesser General
* Public License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307 USA
* The content of the javascript.
* Sets up a function to check if a given variable is empty. It has the same
* behavior like the function "empty" in php.
* @author Daniel Plücken <daniel@debakel.net>
static $alreadyIncluded = false;
$out = " function empty( value )\r\n";
$out .= " return ( value == \"\"\r\n";
$out .= " || value == 0\r\n";
$out .= " || value == undefined\r\n";
$out .= " || value == \"0\" );\r\n";
* Sets up a function to encode a string to md5.
* @author Henri Torgemane (Javasript)
* @author Ralf Mieke <ralf@miekenet.de> (Javascript modifications)
* @author Daniel Plücken <daniel@debakel.net>
* @copyright Copyright (c) 1996 Henri Torgemane
* @license see output javascript.
* Permission to use, copy, modify, and distribute this software
* and its documentation for any purposes and without
* fee is hereby granted provided that this copyright notice
* Of course, this soft is provided \"as is\" without express or
* implied warranty of any kind.
static $alreadyIncluded = false;
$this->body .= JavaScript::getMD5();
* Returns a function to encode a string to md5.
* @author Henri Torgemane (Javasript)
* @author Ralf Mieke <ralf@miekenet.de> (Javascript modifications)
* @author Daniel Plücken <daniel@debakel.net> (only include here)
* @copyright Copyright (c) 1996 Henri Torgemane
* @license see output javascript:
* Permission to use, copy, modify, and distribute this software
* and its documentation for any purposes and without
* fee is hereby granted provided that this copyright notice
* Of course, this soft is provided \"as is\" without express or
* implied warranty of any kind.
* @param boolean $withJSdeclaration
function getMD5( $withJSdeclaration = false )
static $alreadyReturned = false;
* Javascript implementation of the RSA Data Security, Inc. MD5
* Message-Digest Algorithm.
* Copyright (c) 1996 Henri Torgemane. All Rights Reserved.
* Permission to use, copy, modify, and distribute this software
* and its documentation for any purposes and without
* fee is hereby granted provided that this copyright notice
* Of course, this soft is provided "as is" without express or implied
* Modified with german comments and some information about collisions.
* (Ralf Mieke, ralf@miekenet.de, http://mieke.home.pages.de)
for(i=0;i<n;i++) this[i]=0;
/* Einige grundlegenden Funktionen müssen wegen
* Javascript Fehlern umgeschrieben werden.
* Man versuche z.B. 0xffffffff >> 4 zu berechnen..
* Die nun verwendeten Funktionen sind zwar langsamer als die Originale,
* aber sie funktionieren.
function integer(n) { return n%(0xffffffff+1); }
if (a&0x40000000==0x40000000)
for (var i=0;i<b;i++) a=shl1(a);
return ((t1&t2)+0x80000000);
return ((t1|t2)+0x80000000);
return ((t1|b)+0x80000000);
return ((a|t2)+0x80000000);
return ((t1^b)+0x80000000);
return ((a^t2)+0x80000000);
/* Beginn des Algorithmus */
var state = new array(4);
var count = new array(2);
var buffer = new array(64);
var transformBuffer = new array(16);
var digestBits = new array(16);
return or(and(x,y),and(not(x),z));
return or(and(x,z),and(y,not(z)));
return xor(y ,or(x , not(z)));
function rotateLeft(a,n) {
return or(shl(a, n),(shr(a,(32 - n))));
function FF(a,b,c,d,x,s,ac) {
a = a+F(b, c, d) + x + ac;
function GG(a,b,c,d,x,s,ac) {
a = a+G(b, c, d) +x + ac;
function HH(a,b,c,d,x,s,ac) {
a = a+H(b, c, d) + x + ac;
function II(a,b,c,d,x,s,ac) {
a = a+I(b, c, d) + x + ac;
function transform(buf,offset) {
for (i = 0; i < 16; i++) {
x[i] = and(buf[i*4+offset],0xff);
for (j = 1; j < 4; j++) {
x[i]+=shl(and(buf[i*4+j+offset] ,0xff), j * 8);
a = FF ( a, b, c, d, x[ 0], S11, 0xd76aa478); /* 1 */
d = FF ( d, a, b, c, x[ 1], S12, 0xe8c7b756); /* 2 */
c = FF ( c, d, a, b, x[ 2], S13, 0x242070db); /* 3 */
b = FF ( b, c, d, a, x[ 3], S14, 0xc1bdceee); /* 4 */
a = FF ( a, b, c, d, x[ 4], S11, 0xf57c0faf); /* 5 */
d = FF ( d, a, b, c, x[ 5], S12, 0x4787c62a); /* 6 */
c = FF ( c, d, a, b, x[ 6], S13, 0xa8304613); /* 7 */
b = FF ( b, c, d, a, x[ 7], S14, 0xfd469501); /* 8 */
a = FF ( a, b, c, d, x[ 8], S11, 0x698098d8); /* 9 */
d = FF ( d, a, b, c, x[ 9], S12, 0x8b44f7af); /* 10 */
c = FF ( c, d, a, b, x[10], S13, 0xffff5bb1); /* 11 */
b = FF ( b, c, d, a, x[11], S14, 0x895cd7be); /* 12 */
a = FF ( a, b, c, d, x[12], S11, 0x6b901122); /* 13 */
d = FF ( d, a, b, c, x[13], S12, 0xfd987193); /* 14 */
c = FF ( c, d, a, b, x[14], S13, 0xa679438e); /* 15 */
b = FF ( b, c, d, a, x[15], S14, 0x49b40821); /* 16 */
a = GG ( a, b, c, d, x[ 1], S21, 0xf61e2562); /* 17 */
d = GG ( d, a, b, c, x[ 6], S22, 0xc040b340); /* 18 */
c = GG ( c, d, a, b, x[11], S23, 0x265e5a51); /* 19 */
b = GG ( b, c, d, a, x[ 0], S24, 0xe9b6c7aa); /* 20 */
a = GG ( a, b, c, d, x[ 5], S21, 0xd62f105d); /* 21 */
d = GG ( d, a, b, c, x[10], S22, 0x2441453); /* 22 */
c = GG ( c, d, a, b, x[15], S23, 0xd8a1e681); /* 23 */
b = GG ( b, c, d, a, x[ 4], S24, 0xe7d3fbc8); /* 24 */
a = GG ( a, b, c, d, x[ 9], S21, 0x21e1cde6); /* 25 */
d = GG ( d, a, b, c, x[14], S22, 0xc33707d6); /* 26 */
c = GG ( c, d, a, b, x[ 3], S23, 0xf4d50d87); /* 27 */
b = GG ( b, c, d, a, x[ 8], S24, 0x455a14ed); /* 28 */
a = GG ( a, b, c, d, x[13], S21, 0xa9e3e905); /* 29 */
d = GG ( d, a, b, c, x[ 2], S22, 0xfcefa3f8); /* 30 */
c = GG ( c, d, a, b, x[ 7], S23, 0x676f02d9); /* 31 */
b = GG ( b, c, d, a, x[12], S24, 0x8d2a4c8a); /* 32 */
a = HH ( a, b, c, d, x[ 5], S31, 0xfffa3942); /* 33 */
d = HH ( d, a, b, c, x[ 8], S32, 0x8771f681); /* 34 */
c = HH ( c, d, a, b, x[11], S33, 0x6d9d6122); /* 35 */
b = HH ( b, c, d, a, x[14], S34, 0xfde5380c); /* 36 */
a = HH ( a, b, c, d, x[ 1], S31, 0xa4beea44); /* 37 */
d = HH ( d, a, b, c, x[ 4], S32, 0x4bdecfa9); /* 38 */
c = HH ( c, d, a, b, x[ 7], S33, 0xf6bb4b60); /* 39 */
b = HH ( b, c, d, a, x[10], S34, 0xbebfbc70); /* 40 */
a = HH ( a, b, c, d, x[13], S31, 0x289b7ec6); /* 41 */
d = HH ( d, a, b, c, x[ 0], S32, 0xeaa127fa); /* 42 */
c = HH ( c, d, a, b, x[ 3], S33, 0xd4ef3085); /* 43 */
b = HH ( b, c, d, a, x[ 6], S34, 0x4881d05); /* 44 */
a = HH ( a, b, c, d, x[ 9], S31, 0xd9d4d039); /* 45 */
d = HH ( d, a, b, c, x[12], S32, 0xe6db99e5); /* 46 */
c = HH ( c, d, a, b, x[15], S33, 0x1fa27cf8); /* 47 */
b = HH ( b, c, d, a, x[ 2], S34, 0xc4ac5665); /* 48 */
a = II ( a, b, c, d, x[ 0], S41, 0xf4292244); /* 49 */
d = II ( d, a, b, c, x[ 7], S42, 0x432aff97); /* 50 */
c = II ( c, d, a, b, x[14], S43, 0xab9423a7); /* 51 */
b = II ( b, c, d, a, x[ 5], S44, 0xfc93a039); /* 52 */
a = II ( a, b, c, d, x[12], S41, 0x655b59c3); /* 53 */
d = II ( d, a, b, c, x[ 3], S42, 0x8f0ccc92); /* 54 */
c = II ( c, d, a, b, x[10], S43, 0xffeff47d); /* 55 */
b = II ( b, c, d, a, x[ 1], S44, 0x85845dd1); /* 56 */
a = II ( a, b, c, d, x[ 8], S41, 0x6fa87e4f); /* 57 */
d = II ( d, a, b, c, x[15], S42, 0xfe2ce6e0); /* 58 */
c = II ( c, d, a, b, x[ 6], S43, 0xa3014314); /* 59 */
b = II ( b, c, d, a, x[13], S44, 0x4e0811a1); /* 60 */
a = II ( a, b, c, d, x[ 4], S41, 0xf7537e82); /* 61 */
d = II ( d, a, b, c, x[11], S42, 0xbd3af235); /* 62 */
c = II ( c, d, a, b, x[ 2], S43, 0x2ad7d2bb); /* 63 */
b = II ( b, c, d, a, x[ 9], S44, 0xeb86d391); /* 64 */
/* Mit der Initialisierung von Dobbertin:
M7MH=JO6_>MG!X?!51\$)W,CXV!A"=(!AR71,<X`Y-IIT9^Z&8L$2N'Y*Y:R.;
39GIK9>TF $W()/MEHR%C4:G1R:Q"=
M7MH=JO6_>MG!X?!51\$)W,CXV!A"=(!AR71,<X`Y-IIT9^Z&8L$2N'Y*Y:R.;
39GIK9>TF $W()/MEHREC4:G1R:Q"=
for (i = 0; i < digestBits.length; i++)
index = and(shr(count[0],3) , 0x3f);
if (count[0]<0xffffffff-7)
buffer[index] = and(b,0xff);
var i=0, index=0, padLen=0;
for (i = 0; i < 4; i++) {
bits[i] = and(shr(count[0],(i * 8)), 0xff);
for (i = 0; i < 4; i++) {
bits[i+4]=and(shr(count[1],(i * 8)), 0xff);
index = and(shr(count[0], 3) ,0x3f);
padLen = (index < 56) ? (56 - index) : (120 - index);
for (i = 0; i < 4; i++) {
for (j = 0; j < 4; j++) {
digestBits[i*4+j] = and(shr(state[i], (j * 8)) , 0xff);
/* Ende des MD5 Algorithmus */
var hexa_h = "0123456789abcdef";
for (hexa_i=0;hexa_i<8;hexa_i++) {
hexa_c=hexa_h.charAt(Math.abs(hexa_m)%16)+hexa_c;
hexa_m=Math.floor(hexa_m/16);
var ascii="01234567890123456789012345678901" +
" !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ"+
"[\\\\]^_`abcdefghijklmnopqrstuvwxyz{|}~";
for (k=0;k<nachricht.length;k++) {
update(ascii.lastIndexOf(l));
for (i=0;i<4;i++) ka+=shl(digestBits[15-i], (i*8));
for (i=4;i<8;i++) kb+=shl(digestBits[15-i], ((i-4)*8));
for (i=8;i<12;i++) kc+=shl(digestBits[15-i], ((i-8)*8));
for (i=12;i<16;i++) kd+=shl(digestBits[15-i], ((i-12)*8));
s=hexa(kd)+hexa(kc)+hexa(kb)+hexa(ka);
if( $withJSdeclaration === true )
} // if ( !$alreadyReturned )
* Returns a function to inspect the type of a data.
* @see http://javascript.crockford.com/remedial.html
* @param boolean $withJSdeclaration
function getTypeOf( $withJSdeclaration = false )
static $alreadyReturned = false;
if (typeof value.length === 'number' &&
!(value.propertyIsEnumerable('length')) &&
typeof value.splice === 'function') {
if (typeOf(o) === 'object') {
if (v !== undefined && typeOf(v) !== 'function') {
String.prototype.entityify = function () {
return this.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
String.prototype.quote = function () {
var c, i, l = this.length, o = '"';
for (i = 0; i < l; i += 1) {
if (c === '\\\\' || c === '"') {
o += '\\\\u00' + Math.floor(c / 16).toString(16) +
String.prototype.supplant = function (o) {
v = o[s.substring(i + 1, j)];
if (typeOf(v) !== 'string' && typeOf(v) !== 'number') {
s = s.substring(0, i) + v + s.substring(j + 1);
String.prototype.trim = function () {
return this.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1");
if ( $withJSdeclaration === true )
* Sets up a function to inspect the type of data.
* @see http://javascript.crockford.com/remedial.html
static $alreadyIncluded = false;
$this->body .= JavaScript::getTypeOf();
* Sets up a function to serialize arrays like in php.
* @deprecated Use the js library jslib/phpserializer.js
* @author Daniel Plücken <daniel@debakel.net>
static $alreadyIncluded = false;
$this->body .= JavaScript::getSerialize();
* Returns a function to serialize arrays like in php.
* @deprecated Use the js library jslib/phpserializer.js
* @author Daniel Plücken <daniel@debakel.net>
* @param boolean $withJSdeclaration
static $alreadyReturned = false;
$out .= JavaScript::getTypeOf();
function php_serialize( arr )
if ( typeof ia != 'object' )
if ( typeOf( ia ) == 'array' )
var out = 'a:' + ia.length + ':{';
for ( var i = 0; i < ia.length; i++ )
// only index based arrays at this moment!
if ( typeof ia[i] === 'object' )
out += '' + php_serialize( ia[i] );
if ( typeof ia[i] === 'string' )
out += 's:' + ia[i].length + ':"' + ia[i] + '";';
if ( typeof ia[i] === 'number' )
out += 'i:' + ia[i] + ';';
out += 's:' + pos.length + ':"' + pos + '";';
if ( typeof ia[pos] == 'object' )
out += '' + php_serialize( ia[pos] );
if ( typeof ia[pos] == 'string' )
out += 's:' + ia[pos].length + ':"' + ia[pos] + '";';
if ( typeof ia[pos] == 'number' )
out += 'i:' + ia[pos] + ';';
out = 'o:' + cnt + ':{' + out + '}';
if( $withJSdeclaration === true )
* Sets up a function to unserialize arrays like in php.
* @deprecated Use the js library jslib/phpserializer.js
* @author Daniel Plücken <daniel@debakel.net>
static $alreadyIncluded = false;
$this->body .= JavaScript::getUnserialize();
* Returns a function to unserialize arrays like in php.
* @deprecated Use the js library jslib/phpserializer.js
* @author Daniel Plücken <daniel@debakel.net>
* @param boolean $withJSdeclaration
static $alreadyReturned = false;
$out = " function php_unserialize( str )\r\n"
. " for( i = 0; i < str.length; i++ )\r\n"
. " if( str.substr( i, 2 ) == 'a:' )\r\n"
. " while( t = str.substr( i+2, 1 ).match(/[0-9]/) )\r\n"
. " // set pointer behind next \"\x7B\"\r\n"
. " arr = new Array( parseInt( tmp ) );\r\n"
. " arr[arr.length] = unserialize( str );\r\n"
. " if( str.substr( i, 2 ) == 's:' )\r\n"
. " while( t = str.substr( i+2, 1 ).match(/[0-9]/) )\r\n"
. " if( str.substr( i, 2 ) == 'i:' )\r\n"
if( $withJSdeclaration === true )
* Returns a function to proof whether the document is scrollable in
* @author Daniel Plücken <daniel@debakel.net>
* @param boolean $withJSdeclaration
static $alreadyReturned = false;
function bodyIsVerticallyScrollable()
var bool_scrollable = false;
var pos_y = window.pageYOffset;
if ( pos_y == undefined )
pos_y = document.documentElement.scrollTop;
if ( pos_y == undefined )
pos_y = document.body.scrollTop;
window.scrollBy( 0, -1 );
var pos_y_after_scrolling = window.pageYOffset;
if ( pos_y_after_scrolling == undefined )
pos_y_after_scrolling = document.documentElement.scrollTop;
if ( pos_y_after_scrolling == undefined )
pos_y_after_scrolling = document.body.scrollTop;
if ( pos_y_after_scrolling != pos_y )
if ( $withJSdeclaration === true )
* Returns a function to proof whether the document is scrollable in
* horizontally direction.
* @author Daniel Plücken <daniel@debakel.net>
* @param boolean $withJSdeclaration
static $alreadyReturned = false;
function bodyIsHorizontallyScrollable()
var bool_scrollable = false;
var pos_x = window.pageXOffset;
if ( pos_x == undefined )
pos_x = document.documentElement.scrollLeft;
if ( pos_x == undefined )
pos_x = document.body.scrollLeft;
window.scrollBy( -1, 0 );
var pos_x_after_scrolling = window.pageXOffset;
if ( pos_x_after_scrolling == undefined )
pos_x_after_scrolling = document.documentElement.scrollLeft;
if ( pos_x_after_scrolling == undefined )
pos_x_after_scrolling = document.body.scrollLeft;
if ( pos_x_after_scrolling != pos_x )
if ( $withJSdeclaration === true )
* Returns a function to repeat a string given times.
* @author Daniel Plücken <daniel@debakel.net>
* @param boolean $withJSdeclaration
static $alreadyReturned = false;
function str_repeat( str, times )
for ( var i = 1; i < times; i++ )
if ( $withJSdeclaration === true )
* Sets up a function to repeat a given string given times. It has the same
* behavior like the function "str_repeat" in php.
* @author Daniel Plücken <daniel@debakel.net>
static $alreadyIncluded = false;
$this->body .= JavaScript::getStrRepeat();
* Returns a function to get the value of the inner window width.
* @author Daniel Plücken <daniel@debakel.net>
* @param boolean $withJSdeclaration
static $alreadyReturned = false;
function getInnerWindowWidth()
if ( typeof( window.innerWidth ) == 'number' )
window_width = window.innerWidth;
&& document.documentElement.clientWidth
window_width = document.documentElement.clientWidth;
&& document.body.clientWidth
window_width = document.body.clientWidth;
if ( $withJSdeclaration === true )
* Sets up a function to get the value of the inner window width.
* @author Daniel Plücken <daniel@debakel.net>
static $alreadyIncluded = false;
$this->body .= JavaScript::getGetInnerWindowWidth();
* Returns a function to get the value of the inner window height.
* @author Daniel Plücken <daniel@debakel.net>
* @param boolean $withJSdeclaration
static $alreadyReturned = false;
function getInnerWindowHeight()
if ( typeof( window.innerHeight ) == 'number' )
window_height = window.innerHeight;
&& document.documentElement.clientHeight
window_height = document.documentElement.clientHeight;
&& document.body.clientHeight
window_height = document.body.clientHeight;
if ( $withJSdeclaration === true )
* Sets up a function to get the value of the inner window height.
* @author Daniel Plücken <daniel@debakel.net>
static $alreadyIncluded = false;
$this->body .= JavaScript::getGetInnerWindowHeight();
* Sets up a function to fill a given string with zeros until it has the count
* @author Daniel Plücken <daniel@debakel.net>
static $alreadyIncluded = false;
$out = " function leadingZeros( value, digits )\r\n";
$out .= " var string = '' + value;\r\n";
$out .= " var reptimes = digits - string.length;\r\n\r\n";
$out .= " return str_repeat( '0', reptimes ) + string;\r\n";
* Sets up a function to open a centred browser window.
* @author Daniel Plücken <daniel@debakel.net>
static $alreadyIncluded = false;
function openCentredWindow( theURL, winName, w, h, features )
var winl = ( screen.width - w ) / 2;
var wint = ( screen.height - h ) / 2;
tmp_obj = window.open( theURL, winName,
eval( "window." + winName + " = tmp_obj;" );
* Sets up a function to check if a given array contains the given value.
* It has the same behavior like the function "in_array" in php.
* @author Daniel Plücken <daniel@debakel.net>
static $alreadyIncluded = false;
$this->body .= JavaScript::getInArray();
* Returns a function to check if a given array contains the given value.
* It has the same behavior like the function "in_array" in php.
* @author Daniel Plücken <daniel@debakel.net>
* @param boolean $withJSdeclaration
static $alreadyReturned = false;
$out .= " function in_array( val, arr )\r\n"
. " for( i = 0; i < arr.length; i++ )\r\n"
. " if( val == arr[i] )\r\n"
* Sets up a function to check if a given HTML-element includes another
* @author Daniel Plücken <daniel@debakel.net>
static $alreadyIncluded = false;
$this->body .= JavaScript::getIsAncestorOf();
* Returns a function to check if a given HTML-element includes another
* @author Daniel Plücken <daniel@debakel.net>
* @param boolean $withJSdeclaration
static $alreadyReturned = false;
$out .= " function isAncestorOf( "
. "id_of_assumed_ancestor, "
. "element_which_has_ancestor "
. "!document.getElementById( id_of_assumed_ancestor ) "
. "|| !element_which_has_ancestor.parentNode "
. " par_el = element_which_has_ancestor.parentNode;\r\n"
. "&& par_el.getAttribute( 'id' ) "
. "== id_of_assumed_ancestor "
. " while( par_el = par_el.parentNode );\r\n\r\n"
* Sets up a function to insert a record into an array only if the record
* does not already exists in the array.
* @author Daniel Plücken <daniel@debakel.net>
static $alreadyIncluded = false;
$out = " function arrayUniqueInsert( arr, record )\r\n";
$out .= " if( !in_array( record, arr ) )\r\n";
$out .= " arr[arr.length] = record;\r\n\r\n";
$out .= " return arr;\r\n";
* Sets up a function to get the x-position of an html-element.
* @author Daniel Plücken <daniel@debakel.net>
static $alreadyIncluded = false;
$out = " function findPosX( obj )\r\n";
$out .= " var curleft = 0;\r\n";
$out .= " if ( obj.offsetParent )\r\n";
$out .= " while ( obj.offsetParent )\r\n";
$out .= " curleft += obj.offsetLeft;\r\n";
$out .= " obj = obj.offsetParent;\r\n";
$out .= " if( obj.x )\r\n";
$out .= " curleft += obj.x;\r\n\r\n";
$out .= " return curleft;\r\n";
* Sets up a function to get the y-position of an html-element.
* @author Daniel Plücken <daniel@debakel.net>
static $alreadyIncluded = false;
$out = " function findPosY( obj )\r\n";
$out .= " var curtop = 0;\r\n";
$out .= " if ( obj.offsetParent )\r\n";
$out .= " while ( obj.offsetParent )\r\n";
$out .= " curtop += obj.offsetTop\r\n";
$out .= " obj = obj.offsetParent;\r\n";
$out .= " if( obj.y )\r\n";
$out .= " curtop += obj.y;\r\n\r\n";
$out .= " return curtop;\r\n";
* Returns a function that has the same behaviour like the same named
* @author Frank Olschewski <info.2004-03-27@fobit.de> (Javasript)
* @author Daniel Plücken <daniel@debakel.net> (only include here)
* @see http://www.fobit.com
* @copyright Copyright (c) Frank Olschewski
static $alreadyIncluded = false;
function number_format (number, decimals, dec_point, thousands_sep)
var numberstr = number.toString ();
var eindex = numberstr.indexOf ("e");
exponent = numberstr.substring (eindex);
number = parseFloat (numberstr.substring (0, eindex));
var temp = Math.pow (10, decimals);
number = Math.round (number * temp) / temp;
var sign = number < 0 ? "-" : "";
var integer = (number > 0 ?
Math.floor (number) : Math.abs (Math.ceil (number))).toString ();
var fractional = number.toString ().substring (integer.length + sign.length);
dec_point = dec_point != null ? dec_point : ".";
fractional = decimals != null && decimals > 0 || fractional.length > 1 ?
(dec_point + fractional.substring (1)) : "";
if (decimals != null && decimals > 0)
for (i = fractional.length - 1, z = decimals; i < z; ++i)
thousands_sep = (thousands_sep != dec_point || fractional.length == 0) ?
if (thousands_sep != null && thousands_sep != "")
for (i = integer.length - 3; i > 0; i -= 3)
integer = integer.substring (0 , i) + thousands_sep + integer.substring (i);
return sign + integer + fractional + exponent;
* @author Daniel Plücken <daniel@debakel.net>
static $alreadyIncluded = false;
$this->setArrayUniqueInsert();
$out = " stateSTYLE = undefined;\r\n";
$out .= " styleObj = new Array();\r\n";
$out .= " function swapStyle( which, styleArr, styleValArr )\r\n";
$out .= " if( which != stateSTYLE )\r\n";
$out .= " for( i = 0; i < styleArr.length; i++ )\r\n";
$out .= " which.style[styleArr[i]] = styleValArr[i];\r\n";
$out .= " if( styleArr[i] == \"backgroundColor\" )\r\n";
$out .= " which.style.backgroundColor = styleValArr[i];\r\n";
$out .= " if( styleArr[i] == \"color\" )\r\n";
$out .= " which.style.color = styleValArr[i];\r\n";
* @author Daniel Plücken <daniel@debakel.net>
static $alreadyIncluded = false;
$out = " function stateStyle( which )\r\n";
$out .= " stateSTYLE = which;\r\n";
* Adds a string to the content of this javascript.
* @author Daniel Plücken <daniel@debakel.net>
{ $this->body .= $string; }
* Returns a generated string based on the attributes of this object.
* @param boolean $bool_no_html_comments
* If this is set to true, there will be no html-comments
* added at first and last script line.
function get( $bool_no_html_comments = false )
if( !empty( $this->body ) )
$out = "\r\n<script language=\"javascript\" type=\"text/javascript\">"
if ( !$bool_no_html_comments )
$out .= "\r\n". $this->body. "\r\n";
if ( !$bool_no_html_comments )
{ $out .= "// -->\r\n"; }
} // END of class JavaScripts
|