Kod
/**
* This file is part of G-system.
* @copyright 2006 All rights reserved, do not copy, edit or resale.
* @author Krzysztof Jagiełło <balonyo@gmail.com>
* @version 0.1
*/
function Auth()
{
this.url = 'ajax_request.phpaction=login&login=' + document.getElementById( 'form_login' ) + '&pass=' + document.getElementById( 'form_pass' );
this.request = function()
{
var ajax = new Ajax.Request( 'ajax_request.php?action=login&login=' + $F( 'form_login' ) + '&pass=' + $F( 'form_pass' ), {onLoading: this.msgBox( 'SHOW', 'Loading...' ), onComplete: this.login } );
return false;
}
this.login = function( req )
{
switch( req.responseText )
{
case 'OK':
{
this.msgBox( 'SHOW', 'Logged ...' ); this.pause( 1000 ); this.msgBox( 'HIDE', '' ); break
}
case 'ERROR':
{
this.msgBox( 'SHOW', 'Error ...' ); this.pause( 1000 ); this.msgBox( 'HIDE', '' ); break
}
}
return false;
}
this.msgBox = function( type, msg )
{
document.getElementById( 'msg_m_box' ).innerHTML = msg;
switch( type )
{
case 'HIDE': document.getElementById( 'msg_box' ).style.display = 'none'; break
case 'SHOW': document.getElementById( 'msg_box' ).style.display = 'block'; break
}
}
this.pause = function( ms )
{
var now = new Date();
var exitTime = now.getTime() + ms;
while( true )
{
now = new Date();
if( now.getTime() > exitTime ) return;
}
}
}
* This file is part of G-system.
* @copyright 2006 All rights reserved, do not copy, edit or resale.
* @author Krzysztof Jagiełło <balonyo@gmail.com>
* @version 0.1
*/
function Auth()
{
this.url = 'ajax_request.phpaction=login&login=' + document.getElementById( 'form_login' ) + '&pass=' + document.getElementById( 'form_pass' );
this.request = function()
{
var ajax = new Ajax.Request( 'ajax_request.php?action=login&login=' + $F( 'form_login' ) + '&pass=' + $F( 'form_pass' ), {onLoading: this.msgBox( 'SHOW', 'Loading...' ), onComplete: this.login } );
return false;
}
this.login = function( req )
{
switch( req.responseText )
{
case 'OK':
{
this.msgBox( 'SHOW', 'Logged ...' ); this.pause( 1000 ); this.msgBox( 'HIDE', '' ); break
}
case 'ERROR':
{
this.msgBox( 'SHOW', 'Error ...' ); this.pause( 1000 ); this.msgBox( 'HIDE', '' ); break
}
}
return false;
}
this.msgBox = function( type, msg )
{
document.getElementById( 'msg_m_box' ).innerHTML = msg;
switch( type )
{
case 'HIDE': document.getElementById( 'msg_box' ).style.display = 'none'; break
case 'SHOW': document.getElementById( 'msg_box' ).style.display = 'block'; break
}
}
this.pause = function( ms )
{
var now = new Date();
var exitTime = now.getTime() + ms;
while( true )
{
now = new Date();
if( now.getTime() > exitTime ) return;
}
}
}
wywoluje metode request ktora zwraca wynik do metody login, jednak jesli wywoluje w switchu metode klasy to nie jest ona wywolywana....
a jezeli zadeklaruje funkcje poza klasa i bede ja wywolywal nie jako this.msgBox a jako msgBox to wtedy dziala...
jednak zalezy mi na tym zeby byla to klasa i wszystkie funkcje byly w niej zawarte, jak rozwiazac moj problem ?
p.s. jezeli wstawie alert przed this.msgBox(...) to wyskakuje, jesli po to juz nie... a wynik sprawdzalem to jest ok, zwraca albo OK albo ERROR czyli wszystko jest ok procz wywolania msgBox w switchu