Вход Регистрация
Файл: IPBMafia.ru_IPB_3.4.6_Final_Rus _Nulled/board/upload/admin/applications/core/js/ipb3TemplateDiff.js
Строк: 166
<?php
/**
* INVISION POWER BOARD v3
*
* Topics View Javascript File
* @author Matt Mecham, Brandon Farber, Josh Williams
* @since 2008
*/

/**
* "ACP" Class. Designed for ... ACP Template Diff Functions
* @author (v.1.0.0) Matt Mecham
*/

/* Prototype Ajax Global Responders
 * Based on code from: http://codejanitor.com/wp/2006/03/23/ajax-timeouts-with-prototype/
 * Aborts ajax after a 5 minute delay of nothing happening  
*/

var IPB3TemplateDiff = new IPBTemplateDiff;

Ajax.Responders.register( {
                            
onCreate: function( )
                            {
                                
t['_t'] = window.setInterval(
                                                            function()
                                                            {
                                                                if ( 
IPB3TemplateDiff.callInProgresst.transport) )
                                                                {
                                                                    
IPB3TemplateDiff.timeOutAjax);
                                                                }
                                                            },
                                                            
300000
                                                        
);
                                                        
                                
t['_t2'] = window.setInterval(
                                                            function()
                                                            {
                                                                switch( 
t.transport.readyState )
                                                                {
                                                                    case 
1:
                                                                    case 
2:
                                                                        
IPB3TemplateDiff.updateProgressImage'wait' );
                                                                    break;    
                                                                    case 
3:
                                                                    default:
                                                                    case 
4:
                                                                        
IPB3TemplateDiff.updateProgressImage'receive' );
                                                                    break;
                                                                }
                                                            },
                                                            
500
                                                        
);
                            },
                            
onComplete: function( )
                            {
                                
window.clearIntervalt['_t'] );
                                
window.clearIntervalt['_t2'] );
                            }
                        } );
                        
function 
IPBTemplateDiff()
{
    
/**
    * URLS
    */
    
this.baseUrl       '';
    
this.baseUrlMerge  '';
    
this.imageUrl      '';
    
this.doneUrl       '';
    
this.currentAction 'process';
    
    
/*
    * Stored JSON
    */
    
this.storedJSON = {};
    
    
/**
    * Per go
    */
    
this.perGo 10;
    
    
/**
    * Total bits
    */
    
this.totalBits 0;
    
    
/**
    * Init Function
    * @author Matt Mecham 
    */
    
this.init = function()
    {
        
this.beginDiff();
    };
    
    
/**
    * Begin the upgrade procedure
    */
    
this.beginDiff = function()
    {
        
/* Start text output.. */
        
this.updateCounter'' );
        
        
/* Reset progress bar */
        
this.updateProgressBarfalse );
        
        
/* Reset image */
        
this.updateProgressImage'send' );
        
        
/* Start off with the SQL */
        
this.fireAjax);
    };
    
    
/**
    * Update the progress bar
    */
    
this.updateProgressBar = function( processed )
    {
        
/* INIT */
        
var _element = $( 'diffLogProgressBarInner' );
        
        if ( 
processed !== false )
        {
            if ( 
processed == -)
            {
                
_element.style.backgroundImage 'url(' this.imageUrl 'donebar.gif)';
                
_element.style.width '100%';
            }
            else
            {
                
_element.style.backgroundImage 'url(' this.imageUrl 'progressbar.gif)';
                
_element.style.width Math.round( ( 100 this.totalBits ) * processed ) + '%';
            }
        }
        else
        {
            
_element.style.width '1%';
        }
    };
    
    
/**
    * Update progress image
    */
    
this.updateProgressImage = function( type )
    {
        
/* INIT */
        
var _img '';
        
        switch( 
type )
        {
            default:
            case 
'stop':
                
_img 'stop.png';
            break;
            case 
'ready':
                
_img 'ready.png';
            break;
            case 
'warn':
                
_img 'warning.png';
            break;
            case 
'send':
                
_img 'sending.png';
            break;
            case 
'wait':
                
_img 'mini-wait.gif';
            break;
            case 
'receive':
                
_img 'receiving.png';
            break;
        }
        
        
/* Update image */
        
if ( IPB3TemplateDiff.currentImage != _img )
        {
            $( 
'diffStatusImage' ).src IPB3TemplateDiff.imageUrl _img;
            
IPB3TemplateDiff.currentImage _img;
        }
    };
    
    
/**
    * Fire Ajax
    */
    
this.fireAjax = function()
    {
        
/* Update image */
        
this.updateProgressImage'send' );
        
        new 
Ajax.Requestthis.baseUrl.replace( /&amp;/g'&' ) + '&do=' this.currentAction,
                          {
                            
method'get',
                            
onSuccessthis.processAjax.bind(this),
                            
onExceptionthis.exceptionAjax.bind(this),
                            
onFailurethis.failureAjax.bind(this)
                          } );
    };
    
    
/**
    * Checking to see if there's a call in progres...
    */
    
this.callInProgress = function( )
    {
        switch ( 
t.readyState )
        {
            case 
1:
            case 
2:
            case 
3:
                return 
true;
            break;
            default:
                return 
false;
            break;
        }
    };
    
    
/**
    * On Timeout
    */
    
this.timeOutAjax = function( )
    {
        if ( 
confirm"Нет ответа от сервера.nХотите подождать?" ) )
        {
            return 
true;
        }
        else
        {
            
t.transport.abort();
            
alert"Запрос отменен" );
        }
    };
    
    
/**
    * On Failure
    */
    
this.failureAjax = function( )
    {
        
alert"Failure: " t.responseText );
    };
    
    
/**
    * On Failure
    */
    
this.exceptionAjax = function( )
    {
        
alert"Exception: " t.responseText );
    };
    
    
/**
    * Process Ajax (Success)
    */
    
this.processAjax = function( )
    {
        
/* Update Image */
        
this.updateProgressImage'receive' );
        
        
/* Not a JSON response? */
        
if ( ! t.responseText.match( /^(s+?)?{/ ) )
        {
            
alert"Error:n" t.responseText );
            
Debug.write);
            return;
        }
        
        
/* Process results */
        
eval( "var json = " t.responseText );
        
        if ( 
json['error'] )
        {
            
alert"An error occurred: " json['error'] );
            return 
false;
        }
        
        
/* All good: Update status message... */
        
this.updateCounterjson['title'], json['message'] );
        
        
/* Update progress bar */
        
this.updateProgressBarjson['processed'] );
        
        if ( 
json['perGo'] )
        {
            
this.baseUrl this.baseUrl.replace'perGo=(d+?)''perGo=' json['perGo'] );
            
this.perGo json['perGo'];
        }
        
        
this.totalBits  json['totalBits'] ? json['totalBits'] : this.totalBits;
        
        
/* Finish? If so - say all done and go tubby-bye-bye */
        
if ( json['completed'] != )
        {
            
/* Fire Ajax */
            
this.fireAjax();
        }
        else
        {
            
/* Diff? Then merge */
            
if ( this.currentAction == 'process' )
            {
                
this.currentAction 'merge';
                
this.perGo         10;
                
this.baseUrl       this.baseUrl.replace'perGo=(d+?)''perGo=' this.perGo );
                
/* Go ahead */
                
this.beginDiff();
            }
            else
            {
                
/* All Done */
                
this.updateProgressBar( -);
                
this.updateProgressImage'ready' );
            
                
/* Show done thing */
                
window.location this.doneUrl.replace( /&amp;/g'&' );
            }
        }
    };
    
    
/**
    * Write to Log
    */
    
this.updateCounter = function( titlemsg )
    {
        $( 
'diffLogTitle' ).updatetitle );
        $( 
'diffLogText' ).updatemsg );
    };
}
?>
Онлайн: 0
Реклама