Вход Регистрация
Файл: IPBMafia.ru_IPB_3.4.6_Final_Rus _Nulled/board/upload/admin/js/acp.upgrade.js
Строк: 415
<?php
/**
* IPS Upgrade Javascript
*
* @author Matt Mecham
* @started Monday 7th January 2008
*
* STEPS-----------------
* SQL
* App Module
* Check for more modules
* Templates
* Languages
* Tasks
* Settings
* Caches / Done
*/

ipsUpgrade = new ipsUpgrade();

/* 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  
*/
Ajax.Responders.register( {
                            
onCreate: function( )
                            {
                                
t['_t'] = window.setInterval(
                                                            function()
                                                            {
                                                                if ( 
ipsUpgrade.callInProgresst.transport) )
                                                                {
                                                                    
ipsUpgrade.timeOutAjax);
                                                                }
                                                            },
                                                            
300000
                                                        
);
                                                        
                                
t['_t2'] = window.setInterval(
                                                            function()
                                                            {
                                                                switch( 
t.transport.readyState )
                                                                {
                                                                    case 
1:
                                                                    case 
2:
                                                                        
ipsUpgrade.updateProgressImage'wait' );
                                                                    break;    
                                                                    case 
3:
                                                                    default:
                                                                    case 
4:
                                                                        
ipsUpgrade.updateProgressImage'receive' );
                                                                    break;
                                                                }
                                                            },
                                                            
500
                                                        
);
                            },
                            
onComplete: function( )
                            {
                                
window.clearIntervalt['_t'] );
                                
window.clearIntervalt['_t2'] );
                            }
                        } );

/**
* Main Parent Class
*/
function ipsUpgrade()
{
    
/**
    * Applications array
    */
    
this.applications = {};
    
    
/**
    * Upgrade Steps
    */
    
this.upgradeSteps = new Array( 'sql_steps''app_module''next_check''templates''languages''tasks''settings''finish' );
    
    
/**
    * URLS
    */
    
this.baseUrl  '';
    
this.imageUrl '';
    
    
/*
    * Stored JSON
    */
    
this.storedJSON = {};
    
    
/**
    * Current upgrade app
    */
    
this.upgradingApp = {};
    
    
/**
    * Current step
    */
    
this.currentStep '';
    
    
/**
    * Upgrading Version
    */
    
this.upgradingVersion 0;
    
    
/*
    * Current Image
    */
    
this.currentImage '';
    
    
/**
    * Init Function
    * @author Matt Mecham 
    */
    
this.init = function()
    {
        
/* Reset buttons */
        
this.resetApplications();
    };
    
    
/**
    * Begin the upgrade procedure
    */
    
this.beginUpgrade = function( edivapp_dir )
    {
        
/* Blank out all other rows... */
        
for( var i in this.applications )
        {
            var 
_element = $( 'upgradeRowWrapper-' this.applications[i].app_dir );
            
            if ( 
this.applications[i].app_dir != app_dir )
            {
                var 
newdiv            document.createElement('DIV');
                
newdiv.id             'upgradeRowWrapper-' this.applications[i].app_dir '-HIDDEN';
                
newdiv.className      = (is_ie ) ? 'dragmove-hide-ie' 'dragmove-hide-moz';
                
newdiv.style.position 'absolute';
                
newdiv.style.top      _element.cumulativeOffset().top 'px';
                
newdiv.style.left     _element.cumulativeOffset().left 'px';
                
newdiv.style.width    _element.offsetWidth 'px';
                
newdiv.style.height   _element.offsetHeight 'px';
                
document.body.appendChildnewdiv );
            }
            
            
/* Stop observing any upgrade buttons */
            
Event.stopObserving'upgradeRowButton-' this.applications[i].app_dir'click'this._buttonClicker );
        }
        
        
/* Update array */
        
this.upgradingApp this.applicationsapp_dir ];
        
        
/* Get the next available upgrade */
        
this.upgradingVersion this.applicationsapp_dir ].next_version;
        
        
/* Slide out log tray */
        
if ( ! $( 'upgradeLogDraw' ).visible() )
        {
            
Effect.SlideDown( $( 'upgradeLogDraw' ), {duration:0.5} );
        }
        
        
/* Start text output.. */
        
this.writeToLog"Обновление <strong>" this.applicationsapp_dir ].real_name "</strong>" );
        
        
/* Reset progress bar */
        
this.updateProgressBarfalse );
        
        
/* Reset image */
        
this.updateProgressImage'send' );
        
        
/* Start off with the SQL */
        
this.fireAjax'sql_step''do=sql_steps');
    };
    
    
/**
    * Update the progress bar
    */
    
this.updateProgressBar = function( step )
    {
        
/* INIT */
        
var _element = $( 'upgradeLogProgressBarInner' );
        
        if ( 
step != false )
        {
            if ( 
step == 'finish' )
            {
                
_element.style.backgroundImage 'url(' this.imageUrl 'donebar.gif)';
                
_element.style.width '100%';
            }
            else
            {
                var 
0;
            
                for( var 
<= this.upgradeSteps.length x++ )
                {
                    
i++;
                
                    if ( 
step == this.upgradeSteps[x] )
                    {
                        break;
                    }
                }
                
                
_element.style.backgroundImage 'url(' this.imageUrl 'progressbar.gif)';
                
                
_element.style.width Math.round( ( 100 this.upgradeSteps.length ) * ) + '%';
            }
        }
        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 ( ipsUpgrade.currentImage != _img )
        {
            $( 
'upgradeStatusImage' ).src ipsUpgrade.imageUrl _img;
            
ipsUpgrade.currentImage       _img;
        }
        
        
//$( 'upgradeLogText' ).innerHTML = ipsUpgrade.imageUrl + _img + "<br />" + $( 'upgradeLogText' ).innerHTML;
    
};
    
    
/**
    * Fire Ajax
    */
    
this.fireAjax = function( stepurl)
    {
        
/* Update image */
        
this.updateProgressImage'send' );
        
        
/* Update current step */
        
this.currentStep step;
        
        new 
Ajax.Requestthis.baseUrl '&app_directory=' this.upgradingApp.app_dir '&version=' this.upgradingVersion '&' url,
                          {
                            
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 );
            return;
        }
        
        
/* Process results */
        
eval( "var json = " t.responseText );
        
        if ( 
json['error'] )
        {
            
this.showErrorjson );
            return 
false;
        }
        
        if ( 
json['warning'] )
        {
            
alert'Warning: ' json['warning'] );
        }
        
        
/* All good: Update status message... */
        
this.writeToLogjson['message'] );
        
        
/* Update progress bar */
        
if ( json['current_step'] != json['next_step'] )
        {
            
this.updateProgressBarjson['current_step'] );
        }
        
        
/* Update version? */
        
if ( json['next_version'] != '' )
        {
            
this.upgradingVersion json['next_version'];
        }
        
        
/* Finish? If so - say all done and go tubby-bye-bye */
        
if ( json['next_step'] != '__FINISH__' )
        {
            
/* Fire Ajax */
            
this.fireAjaxjson['next_step'], json['next_url'] );
        }
        else
        {
            
/* All Done */
            
this.updateProgressBar'finish' );
            
this.updateProgressImage'ready' );
            
            
this.writeToLog"<strong>Обновление завершено</strong>" );
            
            
/* Update version information */
            
this.applicationsthis.upgradingApp.app_dir ].current_human json['new_human'];
            
this.applicationsthis.upgradingApp.app_dir ].current_long  json['new_long'];
            
            
/* Remove Blanks... */
            
for( var i in this.applications )
            {
                try
                {
                    
/* Remove any old rows */
                    
document.body.removeChild( $('upgradeRowWrapper-' this.applications[i].app_dir '-HIDDEN') );
                    
                    
/* Stop observing any upgrade buttons */
                    
Event.stopObserving'upgradeRowButton-' this.applications[i].app_dir'click'this._buttonClicker );
                }
                catch(
err)
                {
                    
//alert( err );
                
}
            }
            
            
this.resetApplications();
        }
    };
    
    
/**
    * Show Error
    */
    
this.showError = function( json )
    {
        var 
_parent  = $( 'upgradeWrap' );
        var 
_thisone = $( 'upgradeErrorBox' );
        
        
_thisone.style.top      _parent.cumulativeOffset().top 'px';
        
_thisone.style.left     _parent.cumulativeOffset().left 'px';
        
_thisone.style.width    _parent.offsetWidth 'px';
        
_thisone.style.height   _parent.offsetHeight 23 'px';
        
_thisone.style.position 'absolute';
        
        
_thisone.style.display  '';
        
        
/* Store JSON */
        
this.storedJSON json;
        
        
/* Add error message */
        
$( 'upgradeErrorText' ).innerHTML json['error'];
    };
    
    
/**
    * Error; Continue
    */
    
this.errorContinue = function()
    {
        
/* Button has been clicked, so hide error box... */
        
$( 'upgradeErrorBox' ).hide();
        
        
/* Fire Ajax */
        
ipsUpgrade.fireAjaxipsUpgrade.storedJSON['next_step'], ipsUpgrade.storedJSON['next_url'] );
    };
    
    
/**
    * Write to Log
    */
    
this.writeToLog = function( text )
    {
        $( 
'upgradeLogText' ).innerHTML text "<br />" + $( 'upgradeLogText' ).innerHTML;
    };
    
    
/**
    * Reset Application Buttons
    */
    
this.resetApplications = function()
    {
        
/* Loopy */
        
for( var i in this.applications )
        {
            var 
_button  = $( 'upgradeRowButton-' this.applications[i].app_dir );
            var 
_version = $( 'upgradeRowVersion-' this.applications[i].app_dir );
            
            
/* Version */
            
_version.innerHTML this.applications[i].current_human;
            
            
/* Button */
            
if ( this.applications[i].current_long >= this.applications[i].latest )
            {
                
_button.className _button.className.replace( / available$/, '' );
                
_button.title     '';
                
_button.innerHTML "Нет доступных обновлений";
                
                
Event.stopObserving'upgradeRowButton-' this.applications[i].app_dir'click'this._buttonClicker );
                
            }
            else
            { 
                
_button.className _button.className ' available';
                
_button.title     'Нажмите для начала обновления';
                
_button.innerHTML "Есть обновления";
                
                
this._buttonClicker  this.beginUpgrade.bindAsEventListenerthis'upgradeRowButton-' this.applications[i].app_dirthis.applications[i].app_dir );
                
Event.observe(  'upgradeRowButton-' this.applications[i].app_dir'click'this._buttonClicker );
            }
        }
    };
    
    
/**
    * Add application to the array
    */
    
this.addApplication = function( app_dirreal_namecurrent_long_versionlatest_long_versioncurrent_human_versionlatest_human_versionnext_version )
    {
        
/* INIT */
        
var _found 0;
        
        
/* Loop to see if this already exists */
        
for( var i in this.applications )
        {
            if ( 
this.applications[i].app_dir == app_dir )
            {
                
_found 1;
                break;
            }
        }
        
        
/* Add it */
        
if ( _found != )
        {
            
this.applicationsapp_dir ] = { 'app_dir'       app_dir,
                                             
'real_name'     real_name,
                                             
'latest'        latest_long_version,
                                             
'current_long'  current_long_version,
                                             
'latest_human'  latest_human_version,
                                             
'current_human' current_human_version,
                                             
'next_version'  next_version,
                                             
'upgrading'     };
        }
    };
    
    

}
?>
Онлайн: 1
Реклама