home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Chip 2001 October
/
Chip_2001-10_cd1.bin
/
tema
/
goldring
/
js
/
xxapi2_lite.js
< prev
Wrap
Text File
|
2001-09-03
|
8KB
|
210 lines
// ********************************************************************
//
// XXAPI2.2LITE (010417)
// Copyright (c) Y2K-1 - Y2K+1 Xycht (www.xycht.cz)
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program 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 General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//
// ********************************************************************
// global variables & functions
var _width = 0;
var _height = 0;
var blank_img = 'images/blank.gif';
function browser_check() {
this.agt = navigator.userAgent.toLowerCase();
this.major = parseInt( navigator.appVersion );
this.minor = parseFloat( navigator.appVersion );
// netscape detection
this.ns = ( ( this.agt.indexOf( 'mozilla' ) != -1 ) && // mozilla YES
( this.agt.indexOf( 'spoofer' ) == -1 ) && // spoofers NO
( this.agt.indexOf( 'compatible' ) == -1) && // compatible (ie and so on) NO
( this.agt.indexOf( 'opera' ) == -1 ) && // opera NO
( this.agt.indexOf( 'webtv' ) == -1 ) ); // webtv NO
this.ns2 = ( this.ns && ( this.major == 2 ) ); // netscape 2
this.ns3 = ( this.ns && ( this.major == 3 ) ); // netscape 3
this.ns4 = ( this.ns && ( this.major == 4 ) ); // netscape 4
this.ns5 = ( this.ns && ( this.major == 5 ) ); // netscape 5
this.ie = ( this.agt.indexOf( 'msie' ) != -1); // explorer
this.ie3 = ( this.ie && ( this.major < 4 ) ); // explorer 3
this.ie4 = ( this.ie && ( this.major == 4 ) && // explorer 4
( this.agt.indexOf( 'msie 4.0' ) != -1 ) );
this.ie5 = ( this.ie &&
( this.major == 4 ) &&
( this.agt.indexOf ('msie 5.0') != -1) ); // explorer 5
this.ie55 = ( this.ie &&
( this.major == 4 ) &&
( this.agt.indexOf( 'msie 5.5' ) != -1 ) ); // explorer 5.5
this.ie6 = ( this.ie &&
( this.major == 4 ) &&
( this.agt.indexOf( 'msie 6.0' ) != -1 ) ); // explorer 6.0
this.aol = ( this.agt.indexOf( 'aol' ) != -1 ); // aol browser
this.aol3 = ( this.aol && this.ie3 ); // aol3
this.aol4 = ( this.aol && this.ie4 ); // aol4
this.aol5 = ( this.aol && this.ie5 ); // aol5
this.opera = ( this.agt.indexOf( 'opera' ) != -1 ); // opera
this.webtv = ( this.agt.indexOf( 'webtv' ) != -1 ); // webtv
this.js;
if ( this.ns2 || this.ie3 ) this.js = 1.0;
else if ( this.ns3 || this.opera ) this.js = 1.1;
else if ( ( this.ns4 && ( this.minor <= 4.05 ) ) || this.ie4 ) this.js = 1.2;
else if ( ( this.ns4 && ( this.minor > 4.05 ) ) || this.ie5 ) this.js = 1.3;
else if ( this.ns5 ) this.js = 1.4;
else if ( this.ns && ( this.major > 5 ) ) this.js = 1.4;
else if ( this.ie && ( this.major > 5 ) ) this.js = 1.3;
else this.js = 0.0;
this.win = ( ( this.agt.indexOf( 'win' ) != -1 ) || // windows
( this.agt.indexOf( '16bit' ) != -1 ) );
this.win31 = ( ( this.agt.indexOf( 'windows 3.1' ) != -1 ) || // windows 3.1x
( this.agt.indexOf( 'win16' ) != -1 ) ||
( this.agt.indexOf( 'windows 16-bit' ) != -1 ) );
this.win95 = ( ( this.agt.indexOf( 'win95' ) != -1 ) || // windows 95
( this.agt.indexOf( 'windows 95' ) != -1 ) );
this.win98 = ( ( this.agt.indexOf( 'win98' ) != -1 ) || // windows 98
( this.agt.indexOf( 'windows 98' ) != -1 ) );
this.winnt = ( ( this.agt.indexOf( 'winnt' ) != -1 ) || // windows nt
( this.agt.indexOf( 'windows nt' ) != -1 ) );
this.win2000 = ( ( this.agt.indexOf( 'winnt 5.0' ) != -1 ) || // windows 2000
( this.agt.indexOf( 'windows nt 5.0' ) != -1 ) );
this.win16 = ( ( this.agt.indexOf( 'win16' ) != -1 ) || // windows 16bit
( this.agt.indexOf( '16bit' ) != -1 ) ||
( this.agt.indexOf( 'windows 3.1' ) != -1 ) ||
( this.agt.indexOf( 'windows 16-bit' ) != -1 ) );
this.win32 = ( this.win95 || this.winnt || this.win98 || // windows 32bit
( ( this.major >= 4) &&
( navigator.platform == 'Win32' ) ) ||
( this.agt.indexOf( 'win32' ) != -1 ) ||
( this.agt.indexOf( '32bit' ) != -1 ) );
this.os2 = ( ( this.agt.indexOf('os/2')!=-1) || // os/2
( navigator.appVersion.indexOf( 'OS/2' ) != -1 ) ||
( this.agt.indexOf( 'ibm-webexplorer' ) != -1 ) );
this.mac = ( this.agt.indexOf( 'mac' ) != -1 ); // mac
this.mac68k = ( this.mac && // mac68k
( ( this.agt.indexOf( '68k' ) != -1 ) ||
( this.agt.indexOf( '68000' ) != -1 ) ) );
this.macppc = ( this.mac && // mac powerpc
( ( this.agt.indexOf( 'ppc' ) != -1 ) ||
( this.agt.indexOf( 'powerpc' ) != -1 ) ) );
this.linux = ( this.agt.indexOf( 'inux' ) != -1 ); // linux
this.unix = ( ( this.agt.indexOf( 'inux' ) != -1 ) || // unix
( this.agt.indexOf( 'sunos' ) != -1 ) ||
( this.agt.indexOf( 'irix' ) != -1 ) ||
( this.agt.indexOf( 'hp-ux' ) != -1 ) ||
( this.agt.indexOf( 'aix' ) != -1 ) ||
( this.agt.indexOf( 'sco' ) != -1 ) ||
( this.agt.indexOf( 'unix' ) != -1 ) ||
( this.agt.indexOf( 'ncr' ) != -1 ) ||
( this.agt.indexOf( 'dec' ) != -1 ) ||
( this.agt.indexOf( 'sinix' ) != -1 ) ||
( this.agt.indexOf( 'bsd' ) != -1 ) );
this.x11 = ( this.agt.indexOf( 'x11' ) != -1 ); // x11
this.min = ( this.ns4 || this.ns5 || this.ie4 || this.ie5 || this.ie55 || this.ie6) // supported
this.dom1 = ( this.ns5 ); // dom1 full support (mozilla)
this.domns = ( this.ns4 ); // netscape 4 dom style
this.domie = ( this.ie4 || this.ie5 || this.ie55 || this.ie6 || this.aol4 || this.aol5 ); // iexplore 4 dom style
this.lang = ( ( this.ns ) ? navigator.language : navigator.userLanguage ).substr( 0, 2 ); // check 4 language
this.sublang = ( ( this.ns ) ? navigator.language : navigator.userLanguage ).substr( 3, 2 );
}
function get_scr_res() {
// check out the document resolution
// todo: in ns it checks 4 window.size, in ie document.size!
_width = ( is.ns ) ? window.innerWidth + 4 : document.body.offsetWidth;
_height = ( is.ns ) ? window.innerHeight + 4 : document.body.offsetHeight;
if ( is.ns5 ) {
_width -= 4;
_height -= 4;
}
}
// ------------------------------------------------------------------------------------------------
// dynamic code generation
// ------------------------------------------------------------------------------------------------
function add_reset() {
add_str = '';
}
function add( str ) {
add_str += str + '\n';
}
function add_finish() {
document.writeln( add_str );
}
// ------------------------------------------------------------------------------------------------
// images
// ------------------------------------------------------------------------------------------------
function im_preload( img_obj, img_src ) {
// preload the image
if ( document.images ) {
eval( img_obj + ' = new Image()' );
eval( img_obj + '.src = "' + img_src + '"' );
}
}
function im_change( layer, img_name, img_obj ) {
// chacge the image to the preloaded one
if ( document.images ) {
if ( document.layers && layer != null ) eval( 'document.layers["' + layer + '"].document.images["' + img_name + '"].src = ' + img_obj + '.src');
else document.images[ img_name ].src = eval( img_obj + ".src" );
}
}
function im_swap( layer, my_obj, my_val ) {
// swap image to the url
if ( document.images ) {
if ( document.layers && layer != null ) eval( 'document.' + layer + '.document.images["' + my_obj + '"].src = \'' + my_val + '\'' );
else document.images[ my_obj ].src = my_val;
}
}
// ------------------------------------------------------------------------------------------------
// runtime
// ------------------------------------------------------------------------------------------------
// check for the browser
is = new browser_check();