Вход Регистрация
Файл: IPBMafia.ru_IPB_3.4.6_Final_Rus _Nulled/board/upload/admin/js/acp.uagents.js
Строк: 296
<?php
/************************************************/
/* IPB3 Javascript                                */
/* -------------------------------------------- */
/* acp.uagents.js - User agent mapping            */
/* (c) IPS, Inc 2008                            */
/* -------------------------------------------- */
/* Author: Rikki Tissier                         */
/************************************************/

var _uagents window.IPBACP;
_uagents.prototype.uagents = {
    
popups: {},
    
    
init: function()
    {
        
Debug.write("Initializing acp.uagents.js");
        
document.observe("dom:loaded", function(){
            
Debug.write("Here");
            
Sortable.create'sortable_handle', { tag'li'only'isDraggable'reverttrueformat'uagent_([0-9]+)'handle'draghandle'onUpdateacp.uagents.updateAgents } );
            
            if( $(
'add_uagent') )
            {
                $(
'add_uagent').observe('click'acp.uagents.addNewAgent);
            }
        });
    },
    
    
updateAgents: function( draggablemouse )
    {
        var 
uagents Sortable.serialize'sortable_handle', { tag'li'name'uagents' } );
        
        new 
Ajax.Requestacp.uagents.updateURL,
                        {
                            
method'post',
                            
parametersuagents,
                            
onSuccess: function(t)
                            {
                                
Debug.writet.responseText );
                            }
                        });
    },
    
    
deleteAgent: function(eid)
    {
        if( !$(
'uagent_' id) ){
            return;
        }
        
        if( !
confirmipb.lang['ua_perm_remove'] ) )
        {
            return;
        }
        
        var 
url ipb.vars['base_url'] + "app=core&amp;module=ajax&amp;section=uagents&amp;do=removeuAgent&amp;uagent_id=" id '&secure_key=' ipb.vars['md5_hash'];
        
        new 
Ajax.Requesturl.replace(/&amp;/g'&'),
                        {
                            
method'post',
                            
evalJSON'force',
                            
onSuccess: function(t)
                            {
                                if( 
Object.isUndefinedt.responseJSON ) )
                                {
                                    
alertipb.lang['ua_error_remove'] );
                                    return;
                                }
                                
                                if( 
t.responseJSON['errors'] )
                                {
                                    
alertipb.lang['ua_error_remove2'] + t.responseJSON['errors']);
                                    return;
                                }
                                
                                
acp.uagents.json t.responseJSON;
                                
                                $(
'uagent_' id).remove();
                                
ipb.global.showInlineNotificationipb.lang['useragent_removed'], { showClosetrue } );
                            }
                        });
    },
    
    
addNewAgent: function( )
    {
        
Event.stop(e);
        
        if( 
acp.uagents.popups['new'] )
        {
            
acp.uagents.popups['new'].show();
        }
        else
        {
            var 
html ipb.templates['add_uagent'].evaluate( { id'new'box_titleipb.lang['ua_add_string'] } );
            
            var 
afterInit = function( popup ){
                $(
'uagent_new_save').observe('click'acp.uagents.saveEditAgent.bindAsEventListenerthis'new' ) );
            };
            
            
acp.uagents.popups['new'] = new ipb.Popup('add_uagent_popup', { type'pane'modalfalsehideAtStartfalsew'600px'initialhtml }, { afterInitafterInit } );
        }
    },
    
    
editAgent: function(eid)
    {
        
Event.stop(e);
        
        if( !$(
'uagent_' id) ){
            return;
        }
        
        if( 
acp.uagents.popupsid ] )
        {
            
acp.uagents.popupsid ].show();
        }
        else
        {
            
// Get info
            
var info acp.uagents.json['uagents'][ id ];
            if( !
info ){ return; }
            
            var 
replace = {
                            
'id':             id,
                            
'box_title':     ipb.lang['ua_edit_string'],
                            
'a_name':         info['uagent_name'],
                            
'a_key':         info['uagent_key'],
                            
'a_position':     info['uagent_position'],
                            
'a_regex':         info['uagent_regex'],
                            
'a_capture':     info['uagent_regex_capture'],
                            
'type_search':     '',
                            
'type_browser''',
                            
'type_other'''
                        
};
                        
            if( 
info['uagent_type'] == 'browser' ){
                
replace['type_browser'] = "selected='selected'";
            } else if ( 
info['uagent_type'] == 'search' ) {
                
replace['type_search'] = "selected='selected'";
            } else {
                
replace['type_pther'] = "selected='selected'";
            }
                        
            var 
html ipb.templates['add_uagent'].evaluatereplace );
            
            var 
afterInit = function( popup ){
                $(
'uagent_' id '_save').observe('click'acp.uagents.saveEditAgent.bindAsEventListenerthisid ) );
            };
            
            
acp.uagents.popupsid ] = new ipb.Popup('edit_uagent_' id , { type'pane'modalfalsehideAtStartfalsew'600px'initialhtml }, { afterInitafterInit } );
        }
    },
    
    
saveEditAgent: function(eid)
    {
        var 
url ipb.vars['base_url'] + "app=core&amp;module=ajax&amp;section=uagents&amp;do=saveuAgent&amp;&uagent_id=" id '&secure_key=' ipb.vars['md5_hash'];
        
        var 
params = {
                        
'uagent_key'            $F('uagent_key_' id ),
                        
'uagent_name'            $F('uagent_name_' id ).encodeParam(),
                        
'uagent_regex'            $F('uagent_regex_' id ),
                        
'uagent_regex_capture'    $F('uagent_capture_' id ),
                        
'uagent_type'            $F('uagent_type_' id ),
                        
'uagent_position'        $F('uagent_position_' id ),
                        
'type'                    : ( id == 'new' ) ? 'add' 'edit'
                    
};
                    
        if( 
id == 'new' )
        {
            
params['uagent_position'] = $Hacp.uagents.json['uagents'] ).size() + 1;
        }
        
        
/* Got enough data? */
        
if ( ! params['uagent_key'] || ! params['uagent_name'] || ! params['uagent_regex'] || ! params['uagent_type'] )
        {
            
alertipb.lang['ua_form_incomplete'] );
            return 
false;
        }
                    
        new 
Ajax.Requesturl.replace( /&amp;/g'&' ),
                        {
                            
method'post',
                            
parametersparams,
                            
evalJSON'force',
                            
onSuccess: function(t)
                            {
                                if( 
Object.isUndefinedt.responseJSON ) )
                                {
                                    
alertipb.lang['ua_error_save'] );
                                    return;
                                }
                                else if( 
t.responseJSON['error'] )
                                {
                                    
t.responseJSON['error'] = ( t.responseJSON['error'] == 'UAGENT_EXISTS' ) ? ipb.lang['ua_exists'] : t.responseJSON['error'];
                                    
alertipb.lang['ua_error_save2'] + t.responseJSON['error'] );
                                    return;
                                }
                                
                                
acp.uagents.json t.responseJSON;

                                if( 
id == 'new' )
                                {
                                    var 
newparams = {
                                        
'id':         t.responseJSON['returnid'],
                                        
'name':     unescape(params['uagent_name']),
                                        
'type':     params['uagent_type']
                                    };
                                    
                                    
// Need to add it to the list
                                    
var html ipb.templates['agent_row'].evaluatenewparams );
                                    $(
'sortable_handle').insert( { bottomhtml } );
                                    
                                    
acp.uagents.popups['new'].hide();
                                    
                                    $(
'uagent_key_new').value '';
                                    $(
'uagent_name_new').value '';
                                    $(
'uagent_regex_new').value '';
                                    $(
'uagent_capture_new').value '';
                                    $(
'uagent_position_new').value 0;

                                    
/* Update ID */
                                    
id newparams['id'];
                                }
                                else
                                {
                                    $(
'agent_' id '_edit').stopObserving();
                                    $(
'agent_' id '_delete').stopObserving();

                                    
/* Update contents so that the name and image are updated in place */
                                    
var newparams = {
                                        
'id':         id,
                                        
'name':     unescape(params['uagent_name']),
                                        
'type':     params['uagent_type']
                                    };

                                    
// Need to add it to the list
                                    
var html ipb.templates['agent_row'].evaluatenewparams );

                                    $(
'uagent_' id ).updatehtml.replace( /^<li([^>]+?)>(.*)</li>/, "$2" ) );

                                    
acp.uagents.popupsid ].hide();
                                }

                                
/* Reset listeners */
                                
$('agent_' id '_edit').observe('click'acp.uagents.editAgent.bindAsEventListenerthisid ) );
                                $(
'agent_' id '_delete').observe('click'acp.uagents.deleteAgent.bindAsEventListenerthisid ) );

                                
ipb.global.showInlineNotificationipb.lang['useragent_saved'], { showClosetrue } );

                                
/* Reset sortable */
                                
Sortable.create'sortable_handle', { tag'li'only'isDraggable'reverttrueformat'uagent_([0-9]+)'handle'draghandle'onUpdateacp.uagents.updateAgents } );
                            }
                        });
    }
};

acp.uagents.init();
?>
Онлайн: 1
Реклама