Version 3.0.5

This commit is contained in:
Neo committed 2025-12-19 00:31:03 -08:00
1 parent 19b38c7c74
commit 1d4720f3e2
3755 files changed
+508378 -664541

No files matched your search

@@ -0,0 +1,43 @@
/************************************************/
/* IPB3 Javascript */
/* -------------------------------------------- */
/* ips.global.js - Global functionality */
/* (c) IPS, Inc 2008 */
/* -------------------------------------------- */
/* Author: Rikki Tissier */
/************************************************/
ACPEasyLogo = {
init: function()
{
Debug.write("Initializing acp.easylogo.js");
document.observe("dom:loaded", function(){
$('skin').observe( "change", ACPEasyLogo.resetMacro );
});
},
resetMacro: function(e)
{
var value = $F('skin');
//Get hits
new Ajax.Request(
ipb.vars['base_url'] + "app=core&module=ajax&section=replacements&do=retrieve&secure_key=" + ipb.vars['md5_hash'] + "&value=" + value ,
{
method: 'get',
evalJSON: 'force',
onSuccess: function(t){
if ( t.responseJSON['url'] )
{
$('logo_url').value = t.responseJSON['url'];
$('replacementId').value = t.responseJSON['id'];
}
}
}
);
return false;
}
}
ACPEasyLogo.init();
@@ -0,0 +1,35 @@
/************************************************/
/* IPB3 Javascript */
/* -------------------------------------------- */
/* acp.homepage.js - Homepage javascript */
/* (c) IPS, Inc 2008 */
/* -------------------------------------------- */
/* Author: Brandon Farber */
/************************************************/
ACPHomepage = {
/*------------------------------*/
/* Constructor */
init: function()
{
Debug.write("Initializing acp.homepage.js");
document.observe("dom:loaded", function(){
ACPHomepage.autoComplete = new ipb.Autocomplete( $('members_display_name'), { multibox: false, url: acp.autocompleteUrl, templates: { wrap: acp.autocompleteWrap, item: acp.autocompleteItem } } );
});
},
editMember: function()
{
if ( $('members_display_name').value == "" )
{
alert("Нужно ввести имя пользователя!");
return false;
}
return true;
}
};
ACPHomepage.init();
@@ -0,0 +1 @@
<html>␍<head><title>IP.Board - Bulletin Board System</title></head>␍<body>␍<h1>403: IP.Board -> Forbidden</h1>␍<hr>␍You have reached this page in error, please use your back button to return to the forum.␍<hr>␍<a href="http://www.invisionboard.com/">IP.Board</a>␍</body>␍</html>␍
@@ -0,0 +1,412 @@
/**
* INVISION POWER BOARD v3
*
* Topics View Javascript File
* @author Matt Mecham, Brandon Farber, Josh Williams
* @since 2008
*/
/**
* "ACP" Class. Designed for ... ACP CSS Functions
* @author (v.1.0.0) Matt Mecham
*/
function IPBCSS()
{
/**
* Template groups
*
* @var array
*/
this.CSSData = {};
/**
* Current template bit
*
* @var array
*/
this.currentCSS = '';
/**
* Current set ID
*
* @var array
*/
this.currentSetData = {};
/**
* CSS Names
*
* @var hash
*/
this.cssNames = {
'cssRow' : 'tablerow2',
'cssHover' : 'cssHover' };
/**
* INIT Applications
*/
this.init = function()
{
/* Build CSS list */
this.buildCSSList();
}
/**
* Load css groups
*/
this.loadCSSGroups = function()
{
/* Grab the JSON for the template bits for the current template group */
url = ipb.vars['base_url'] + "app=core&amp;module=ajax&amp;section=css&amp;do=getCSSGroups&amp;setID=" + this.currentSetData['set_id'] + '&secure_key=' + ipb.vars['md5_hash'];
new Ajax.Request( url.replace( /&amp;/g, '&' ),
{
method: 'GET',
onSuccess: function (t )
{
if ( t.responseText.match( /^(\s+?)?\{/ ) )
{
$('tplate_debug').innerHTML += "\n" + t.responseText;
eval( "var json = " + t.responseText );
if ( json['error'] )
{
alert( json['error'] );
return;
}
else
{
IPB3CSS.CSSData = json;
IPB3CSS.buildCSSList();
}
}
else
{
alert( "Ooops. Something went wrong. Does this help?: " + t.responseText );
}
},
onException: function( f,e ){ alert( "Исключение: " + e ) },
onFailure: function( t ){ alert( "Ошибка: " + t.responseText ) }
} );
}
/**
* Save CSS
*/
this.saveCSS = function( css_id )
{
/* Grab the JSON for the template bits for the current template group */
url = ipb.vars['base_url'] + "app=core&amp;module=ajax&amp;section=css&amp;do=saveCSS&amp;setID=" + this.currentSetData['set_id'] + '&css_id=' + css_id + '&secure_key=' + ipb.vars['md5_hash'];
/* Set up params */
var params = { 'css_content' : $F('tplate_editBox_' + css_id ),
'css_position' : $F('tplate_posBox_' + css_id ),
'css_set_id' : this.currentSetData['set_id'],
'_css_group' : $F('tplate_groupBox_' + css_id ),
'type' : ( css_id == 0 ) ? 'add' : 'edit' };
new Ajax.Request( url.replace( /&amp;/g, '&' ),
{
method: 'POST',
parameters: params,
onSuccess: function (t )
{
if ( t.responseText.match( /^(\s+?)?\{/ ) )
{
eval( "var json = " + t.responseText );
if ( json['error'] )
{
alert( json['error'] );
return;
}
else
{
IPB3CSS.currentCSS = json['cssData'];
IPB3CSS.showCSSEditor( json );
IPB3CSS.loadCSSGroups();
if ( json['errors'] )
{
/* Something inline would be very nice here.. rather than this ugly alert */
alert("Ошибка: " + json['errors'] );
}
else
{
alert("Сохранено!");
}
}
}
else
{
alert( "Галектеко ОПАСНОСТЕ! ПЫЩПЫЩ!11: " + t.responseText );
}
},
onException: function( f,e ){ alert( "Исключение: " + e ) },
onFailure: function( t ){ alert( "Ошибка: " + t.responseText ) }
} );
}
/**
* Revert css
*/
this.revertCSS = function( css_id )
{
/* Make sure we're mean it... */
if ( $('tplate_cssRow_' + css_id ).hasClassName( 'tplateRow_new') )
{
if ( ! confirm( "Удалить CSS файл ?\nФайл будет удален из ВСЕХ стилей!" ) )
{
return false;
}
}
else
{
if ( ! confirm( "Отменить изменения в CSS файле ?\nВсе изменения будут утеряны!" ) )
{
return false;
}
}
/* Grab the JSON for the template bits for the current template group */
url = ipb.vars['base_url'] + "app=core&amp;module=ajax&amp;section=css&amp;do=revertCSS&amp;setID=" + this.currentSetData['set_id'] + '&css_id=' + css_id + '&secure_key=' + ipb.vars['md5_hash'];
new Ajax.Request( url.replace( /&amp;/g, '&' ),
{
method: 'GET',
onSuccess: function (t )
{
if ( t.responseText.match( /^(\s+?)?\{/ ) )
{
eval( "var json = " + t.responseText );
if ( json['error'] )
{
alert( json['error'] );
return;
}
else
{
IPB3CSS.loadCSSGroups();
if ( json['errors'] )
{
/* Something inline would be very nice here.. rather than this ugly alert */
alert("Я СКАЗАЛ: " + json['errors'] );
}
}
}
else
{
alert( "Галектеко ОПАСНОСТЕ! ПЫЩПЫЩ!11: " + t.responseText );
}
},
onException: function( f,e ){ alert( "Исключение: " + e ) },
onFailure: function( t ){ alert( "Ошибка: " + t.responseText ) }
} );
}
/**
* Load template bits
*/
this.loadCSSEditor = function( css_id )
{
/* Grab the JSON for the template bits for the current template group */
url = ipb.vars['base_url'] + "app=core&amp;module=ajax&amp;section=css&amp;do=getCSSForEdit&amp;setID=" + this.currentSetData['set_id'] + '&css_id=' + css_id + '&secure_key=' + ipb.vars['md5_hash'];
new Ajax.Request( url.replace( /&amp;/g, '&' ),
{
method: 'GET',
onSuccess: function (t )
{
if ( t.responseText.match( /^(\s+?)?\{/ ) )
{
eval( "var json = " + t.responseText );
if ( json['error'] )
{
alert( json['error'] );
return;
}
else
{
IPB3CSS.showCSSEditor( json );
}
}
else
{
alert( "Галектеко ОПАСНОСТЕ! ПЫЩПЫЩ!11: " + t.responseText );
}
},
onException: function( f,e ){ alert( "Исключение: " + e ) },
onFailure: function( t ){ alert( "Ошибка: " + t.responseText ) }
} );
}
/**
* Add CSS form
*/
this.addCSSForm = function()
{
IPB3CSS.showCSSEditor( { 'cssData' : { 'css_id' : 0, 'css_group' : '', 'css_content' : '', 'css_added_to' : 0, '_type' : 'new' } } );
}
/**
* Shows the template editor
*/
this.showCSSEditor = function( json )
{
/* Close any open editors */
IPB3CSS.cancelCSS( json['cssData']['css_id'] );
var _tplate = new Template( $('tplate_cssEditor').innerHTML );
IPB3CSS.currentCSS = json['cssData'];
var _div = document.createElement( "DIV" );
_div.id = 'tplate_editorWrapper';
_div.update( _tplate.evaluate( json['cssData'] ) );
document.body.appendChild( _div );
/* New? */
if ( json['cssData']['_type'] == 'new' || ( json['cssData']['css_added_to'] == IPB3CSS.currentSetData['set_id'] ) )
{
$( 'tplate_groupBoxWrap_' + json['cssData']['css_id'] ).show();
}
ipb.positionCenter( 'tplate_editor_' + json['cssData']['css_id'] );
}
/**
* Shows the template editor
*/
this.cancelCSS = function( cssID )
{
/*if ( ! confirm( "All unsaved changes will be lost!" ) )
{
return false;
}*/
try
{
$('tplate_editorWrapper').remove();
}
catch(e)
{
}
}
/**
* Build a list of CSS groups (files)
*/
this.buildCSSList = function()
{
/* INIT */
var _output = '';
var _tplate = new Template( $('tplate_cssRow').innerHTML );
var json = IPB3CSS.CSSData;
var _groups = Object.keys( json['css'] ).sort( function(a,b) { return a-b; } );
/* Clear out any current listing */
$('tplate_cssList').update('');
/* Format... */
_groups.each( function( i )
{
/* Inline deleted? */
if ( ! json['css'][i]['_deleted'] )
{
/* Figure out if this in an inherited row, a changed row, a new row or a default row */
if ( json['css'][i]['css_added_to'] == IPB3CSS.currentSetData['set_id'] )
{
/* This is a modified row */
json['css'][i]['_cssState'] = 'new';
json['css'][i]['_cssClass'] = 'tplateRow_new';
}
else if ( json['css'][i]['css_set_id'] == IPB3CSS.currentSetData['set_id'] )
{
/* This is a modified row */
json['css'][i]['_cssState'] = 'modified';
json['css'][i]['_cssClass'] = 'tplateRow_mod';
}
else if ( IPB3CSS.currentSetData['_parentTree'].indexOf( json['css'][i]['css_set_id'] ) != -1 )
{
/* Inherited */
json['css'][i]['_cssState'] = 'inherit';
json['css'][i]['_cssClass'] = 'tplateRow_inh';
}
else
{
/* This is a default row */
json['css'][i]['_cssState'] = 'default';
json['css'][i]['_cssClass'] = 'tplateRow_def';
}
_output += _tplate.evaluate( json['css'][i] );
}
} );
/* Write it out */
$('tplate_cssList').update( _output );
/* Post Process */
_groups.each( function( i )
{
/* Inline deleted? */
if ( ! json['css'][i]['_deleted'] )
{
if ( json['css'][i]['_cssState'] == 'new' )
{
$('tplate_cssRow_' + json['css'][i]['css_id'] + '_revert').update('Remove');
}
else if ( json['css'][i]['_cssState'] != 'default' )
{
$('tplate_cssRow_' + json['css'][i]['css_id'] + '_revert').show();
}
else
{
$('tplate_cssRow_' + json['css'][i]['css_id'] + '_revert').hide();
}
}
} );
}
/**
* Template Mouse Event
*/
this.mouseEvent = function( e )
{
if ( _div = $( Event.element( e ) ).up( '.' + IPB3CSS.cssNames['cssRow'] ) )
{
var _css_id = _div.id.replace( 'tplate_cssRow_', '' );
if ( e.type == 'mouseover' )
{
_div.addClassName( IPB3CSS.cssNames['cssHover'] );
}
else if ( e.type == 'mouseout' )
{
_div.removeClassName( IPB3CSS.cssNames['cssHover'] );
}
else if ( e.type == 'click' )
{
var _el = Event.findElement( e, 'div' ).id;
if ( _el.endsWith('_revert' ) )
{
IPB3CSS.revertCSS( _css_id );
}
else
{
IPB3CSS.loadCSSEditor( _css_id );
}
}
}
}
}
@@ -0,0 +1,207 @@
function addAnotherFile()
{
elementIndex = parseInt(elementIndex) + 1;
var list = new Element( 'ul', { 'id': 'fileTable_' + elementIndex } );
list.addClassName( 'acp-form' );
list.addClassName( 'alternate_rows' );
$('fileTableContainer').insert( list );
var li1 = new Element( 'li' ).update( "<label>" + ipb.lang['hook_filename'] + "</label><input type='text' name='file[" + elementIndex + "]' value='' size='50' class='inputtext' />" );
var li2 = new Element( 'li' ).update( "<label>" + ipb.lang['hook_classname'] + "</label><input type='text' name='hook_classname[" + elementIndex + "]' value='' size='50' class='inputtext' />" );
var li3 = new Element( 'li' ).update( "<label>" + ipb.lang['hook_filetype'] + "</label><select name='hook_type[" + elementIndex + "]' id='hook_type[" + elementIndex + "]' onchange='selectHookType(" + elementIndex + ");'><option value='0'>" + ipb.lang['hook_filetype_select'] + "</option><option value='commandHooks'>" + ipb.lang['hook_filetype_action'] + "</option><option value='skinHooks'>" + ipb.lang['hook_filetype_skin'] + "</option><option value='templateHooks'>" + ipb.lang['hook_filetype_template'] + "</option></select>" );
$('fileTable_' + elementIndex).insert( li1 );
$('fileTable_' + elementIndex).insert( li2 );
$('fileTable_' + elementIndex).insert( li3 );
}
function selectHookType( elementIndex )
{
var type = $F('hook_type[' + elementIndex + ']');
if( $('tr_classToOverload[' + elementIndex + ']') != null )
{
$('tr_classToOverload[' + elementIndex + ']').remove();
}
if( $('tr_skinGroup[' + elementIndex + ']') != null )
{
$('tr_skinGroup[' + elementIndex + ']').remove();
}
if( $('tr_skinFunction[' + elementIndex + ']') != null )
{
$('tr_skinFunction[' + elementIndex + ']').remove();
}
if( $('tr_type[' + elementIndex + ']') != null )
{
$('tr_type[' + elementIndex + ']').remove();
}
if( $('tr_id[' + elementIndex + ']') != null )
{
$('tr_id[' + elementIndex + ']').remove();
}
if( $('tr_position[' + elementIndex + ']') != null )
{
$('tr_position[' + elementIndex + ']').remove();
}
if( type == 'templateHooks' )
{
// Show the skin dropdown now
url = ipb.vars['base_url'] + "app=core&amp;module=ajax&amp;section=hooks&amp;do=getGroupsForAdd&amp;secure_key=" + ipb.vars['md5_hash'] + "&i=" + elementIndex;
url = url.replace( /&amp;/g, '&' );
new Ajax.Request( url,
{
method: 'GET',
onSuccess: function (t )
{
li1 = new Element( 'li', { 'id': 'tr_skinGroup[' + elementIndex + ']' } ).update( "<label>" + ipb.lang['hook_skingroup'] + "</label>" + t.responseText );
$('fileTable_' + elementIndex).insert( li1 );
},
onException: function( f,e ){ alert( "Exception: " + e ) },
onFailure: function( t ){ alert( "Failure: " + t.responseText ) }
} );
}
else if( type != '0' )
{
// Show the classToOverload field
var li1 = new Element( 'li', { 'id': 'tr_classToOverload[' + elementIndex + ']' } ).update( "<label>" + ipb.lang['hook_extends'] + "</label><input type='text' name='classToOverload[" + elementIndex + "]' value='' size='50' class='inputtext' />" );
$('fileTable_' + elementIndex).insert( li1 );
}
}
function getTemplatesForAdd( elementIndex )
{
var type = $F('skinGroup[' + elementIndex + ']');
if( $('tr_skinFunction[' + elementIndex + ']') != null )
{
$('tr_skinFunction[' + elementIndex + ']').remove();
}
if( $('tr_type[' + elementIndex + ']') != null )
{
$('tr_type[' + elementIndex + ']').remove();
}
if( $('tr_id[' + elementIndex + ']') != null )
{
$('tr_id[' + elementIndex + ']').remove();
}
if( $('tr_position[' + elementIndex + ']') != null )
{
$('tr_position[' + elementIndex + ']').remove();
}
url = ipb.vars['base_url'] + "app=core&amp;module=ajax&amp;section=hooks&amp;do=getTemplatesForAdd&amp;secure_key=" + ipb.vars['md5_hash'] + "&i=" + elementIndex + "&group=" + type;
url = url.replace( /&amp;/g, '&' );
new Ajax.Request( url,
{
method: 'GET',
onSuccess: function (t )
{
li1 = new Element( 'li', { 'id': 'tr_skinFunction[' + elementIndex + ']' } ).update( "<label>" + ipb.lang['hook_skinfunc'] + "</label>" + t.responseText );
$('fileTable_' + elementIndex).insert( li1 );
},
onException: function( f,e ){ alert( "Exception: " + e ) },
onFailure: function( t ){ alert( "Failure: " + t.responseText ) }
} );
}
function getTypeOfHook( elementIndex )
{
var type = $F('skinFunction[' + elementIndex + ']');
if( $('tr_type[' + elementIndex + ']') != null )
{
$('tr_type[' + elementIndex + ']').remove();
}
if( $('tr_id[' + elementIndex + ']') != null )
{
$('tr_id[' + elementIndex + ']').remove();
}
if( $('tr_position[' + elementIndex + ']') != null )
{
$('tr_position[' + elementIndex + ']').remove();
}
li1 = new Element( 'li', { 'id': 'tr_type[' + elementIndex + ']' } ).update( "<label>" + ipb.lang['hook_temptype'] + "</label><select name='type[" + elementIndex + "]' id='type[" + elementIndex + "]' onchange='getHookIds(" + elementIndex + ");'><option value='0'>" + ipb.lang['hook_filetype_select'] + "</option><option value='foreach'>foreach loop</option><option value='if'>if statement</option></select>" );
$('fileTable_' + elementIndex).insert( li1 );
}
function getHookIds( elementIndex )
{
var template = $F('skinFunction[' + elementIndex + ']');
var type = $F('type[' + elementIndex + ']');
if( $('tr_id[' + elementIndex + ']') != null )
{
$('tr_id[' + elementIndex + ']').remove();
}
if( $('tr_position[' + elementIndex + ']') != null )
{
$('tr_position[' + elementIndex + ']').remove();
}
url = ipb.vars['base_url'] + "app=core&amp;module=ajax&amp;section=hooks&amp;do=getHookIds&amp;secure_key=" + ipb.vars['md5_hash'] + "&i=" + elementIndex + "&type=" + type + "&template=" + template;
url = url.replace( /&amp;/g, '&' );
new Ajax.Request( url,
{
method: 'GET',
onSuccess: function (t )
{
li1 = new Element( 'li', { 'id': 'tr_id[' + elementIndex + ']' } ).update( "<label>" + ipb.lang['hook_hookid'] + "</label>" + t.responseText );
$('fileTable_' + elementIndex).insert( li1 );
},
onException: function( f,e ){ alert( "Exception: " + e ) },
onFailure: function( t ){ alert( "Failure: " + t.responseText ) }
} );
}
function getHookEntryPoints( elementIndex )
{
var type = $F('type[' + elementIndex + ']');
if( $('tr_position[' + elementIndex + ']') != null )
{
$('tr_position[' + elementIndex + ']').remove();
}
var options = '';
options += "<option value='0'>" + ipb.lang['hook_filetype_select'] + "</option>";
if( type == 'foreach' )
{
options += "<option value='outer.pre'>(outer.pre) " + ipb.lang['a_outerpre'] + "</option>";
options += "<option value='inner.pre'>(inner.pre) " + ipb.lang['a_innerpre'] + "</option>";
options += "<option value='inner.post'>(inner.post) " + ipb.lang['a_innerpost']+ "</option>";
options += "<option value='outer.post'>(outer.post) " + ipb.lang['a_outerpost']+ "</option>";
}
else
{
options += "<option value='pre.startif'>(pre.startif) " + ipb.lang['a_prestartif'] + "</option>";
options += "<option value='post.startif'>(post.startif) " + ipb.lang['a_poststartif'] + "</option>";
options += "<option value='pre.else'>(pre.else) " + ipb.lang['a_preelse'] + "</option>";
options += "<option value='post.else'>(post.else) " + ipb.lang['a_postelse'] + "</option>";
options += "<option value='pre.endif'>(pre.endif) " + ipb.lang['a_preendif'] + "</option>";
options += "<option value='post.endif'>(post.endif) " + ipb.lang['a_postendif'] + "</option>";
}
var li1 = new Element( 'li', { 'id': 'tr_position[' + elementIndex + ']' } ).update( "<label>" + ipb.lang['hook_temptype'] + "</label><select name='position[" + elementIndex + "]' id='position[" + elementIndex + "]'>" + options + "</select>" );
$('fileTable_' + elementIndex).insert( li1 );
}
@@ -0,0 +1,447 @@
/**
* INVISION POWER BOARD v3
*
* Topics View Javascript File
* @author Matt Mecham, Brandon Farber, Josh Williams
* @since 2008
*/
/**
* "ACP" Class. Designed for ... ACP Replacements Functions
* @author (v.1.0.0) Matt Mecham
*/
function IPBReplacements()
{
/**
* Template groups
*
* @var array
*/
this.ReplacementsData = {};
/**
* Current template bit
*
* @var array
*/
this.currentReplacement = '';
/**
* Current set ID
*
* @var array
*/
this.currentSetData = {};
/**
* Replacements Names
*
* @var hash
*/
this.cssNames = {
'replacementsRow' : 'tablerow2',
'replacementsHover' : 'replacementsHover' };
/**
* INIT Applications
*/
this.init = function()
{
/* Build Replacements list */
this.buildReplacementsList();
}
/**
* Load css groups
*/
this.loadReplacementsGroups = function()
{
/* Grab the JSON for the template bits for the current template group */
url = ipb.vars['base_url'] + "app=core&amp;module=ajax&amp;section=replacements&amp;do=getReplacementsGroups&amp;setID=" + this.currentSetData['set_id'] + '&secure_key=' + ipb.vars['md5_hash'];
new Ajax.Request( url.replace( /&amp;/g, '&' ),
{
method: 'GET',
onSuccess: function (t )
{
if ( t.responseText.match( /^(\s+?)?\{/ ) )
{
$('tplate_debug').innerHTML += "\n" + t.responseText;
eval( "var json = " + t.responseText );
if ( json['error'] )
{
alert( json['error'] );
return;
}
else
{
IPB3Replacements.ReplacementsData = json;
IPB3Replacements.buildReplacementsList();
}
}
else
{
alert( "Ooops. Something went wrong. Does this help?: " + t.responseText );
}
},
onException: function( f,e ){ alert( "Exception: " + e ) },
onFailure: function( t ){ alert( "Failure: " + t.responseText ) }
} );
}
/**
* Save Replacements
*/
this.saveReplacement = function( replacement_id )
{
/* Grab the JSON for the template bits for the current template group */
url = ipb.vars['base_url'] + "app=core&amp;module=ajax&amp;section=replacements&amp;do=saveReplacement&amp;setID=" + this.currentSetData['set_id'] + '&replacement_id=' + replacement_id + '&secure_key=' + ipb.vars['md5_hash'];
/* Set up params */
var params = { 'replacement_content' : $F('tplate_editBox_' + replacement_id ),
'replacement_set_id' : this.currentSetData['set_id'],
'_replacement_key' : $F('tplate_keyBox_' + replacement_id ),
'type' : ( replacement_id == 0 ) ? 'add' : 'edit' };
new Ajax.Request( url.replace( /&amp;/g, '&' ),
{
method: 'POST',
parameters: params,
onSuccess: function (t )
{
if ( t.responseText.match( /^(\s+?)?\{/ ) )
{
eval( "var json = " + t.responseText );
if ( json['error'] )
{
alert( json['error'] );
return;
}
else
{
IPB3Replacements.ReplacementsData = json;
IPB3Replacements.buildReplacementsList();
if ( json['errors'] )
{
/* Something inline would be very nice here.. rather than this ugly alert */
alert("Message: " + json['errors'] );
}
else
{
alert("Message: Saved!");
}
}
}
else
{
alert( "Ooops. Something went wrong. Does this help?: " + t.responseText );
}
},
onException: function( f,e ){ alert( "Exception: " + e ) },
onFailure: function( t ){ alert( "Failure: " + t.responseText ) }
} );
}
/**
* Revert css
*/
this.revertReplacement = function( replacement_id )
{
/* Make sure we're mean it... */
if ( $('tplate_replacementsRow_' + replacement_id ).hasClassName( 'tplateRow_new') )
{
if ( ! confirm( "REMOVE Replacements file?\n This will remove this replacement in ALL skins!" ) )
{
return false;
}
}
else
{
if ( ! confirm( "Revert Replacements file?\n All changes WILL be lost!" ) )
{
return false;
}
}
/* Grab the JSON for the template bits for the current template group */
url = ipb.vars['base_url'] + "app=core&amp;module=ajax&amp;section=replacements&amp;do=revertReplacement&amp;setID=" + this.currentSetData['set_id'] + '&replacement_id=' + replacement_id + '&secure_key=' + ipb.vars['md5_hash'];
new Ajax.Request( url.replace( /&amp;/g, '&' ),
{
method: 'GET',
onSuccess: function (t )
{
if ( t.responseText.match( /^(\s+?)?\{/ ) )
{
eval( "var json = " + t.responseText );
if ( json['error'] )
{
alert( json['error'] );
return;
}
else
{
IPB3Replacements.ReplacementsData = json;
IPB3Replacements.buildReplacementsList();
if ( json['errors'] )
{
/* Something inline would be very nice here.. rather than this ugly alert */
alert("Message: " + json['errors'] );
}
}
}
else
{
alert( "Ooops. Something went wrong. Does this help?: " + t.responseText );
}
},
onException: function( f,e ){ alert( "Exception: " + e ) },
onFailure: function( t ){ alert( "Failure: " + t.responseText ) }
} );
}
/**
* Add Replacements form
*/
this.addReplacementsForm = function()
{
IPB3Replacements.showReplacementsEditor( 0 );
}
/**
* Shows the template editor
*/
this.showReplacementsEditor = function( replacement_id )
{
/* Close any open editors */
IPB3Replacements.cancelReplacements();
var _tplate = new Template( $('tplate_replacementsEditor').innerHTML );
var _keys = Object.keys( IPB3Replacements.ReplacementsData['replacements'] ).sort();
var _data = {};
/* Get replacement Data */
if ( replacement_id )
{
_keys.each( function( i )
{
if ( IPB3Replacements.ReplacementsData['replacements'][ i ]['replacement_id'] == replacement_id )
{
_data = IPB3Replacements.ReplacementsData['replacements'][ i ];
}
} );
}
else
{
_data = { 'replacement_id' : 0, 'replacement_key' : '', 'SAFE_replacement_content' : '' };
}
var _div = document.createElement( "DIV" );
_div.id = 'tplate_editorWrapper';
_div.update( _tplate.evaluate( _data ) );
document.body.appendChild( _div );
/* New? */
if ( ! replacement_id || ( _data['replacement_added_to'] == IPB3Replacements.currentSetData['set_id'] ) )
{
$( 'tplate_keyBoxWrap_' + replacement_id ).show();
}
/* Adjust title */
if ( ! replacement_id )
{
$('tplate_title_' + replacement_id ).update("Adding Replacement");
}
ipb.positionCenter( 'tplate_editor_' + replacement_id );
}
/**
* Preview the replacement
*/
this.previewReplacement = function( replacement_id )
{
/* Close any open editors */
IPB3Replacements.closePreview();
var _tplate = new Template( $('tplate_replacementsPreview').innerHTML );
var _keys = Object.keys( IPB3Replacements.ReplacementsData['replacements'] ).sort();
var _data = {};
/* Get replacement Data */
_keys.each( function( i )
{
if ( IPB3Replacements.ReplacementsData['replacements'][ i ]['replacement_id'] == replacement_id )
{
_data = IPB3Replacements.ReplacementsData['replacements'][ i ];
}
} );
/* For mat.... oh, for me? */
_data['_preview'] = _data['replacement_content'].escapeHTML();
/* But, is it an image? */
if ( _data['replacement_content'].startsWith( "<img" ) )
{
_data['_preview'] = _data['replacement_content'].sub( '\{style_image_url\}', IPB3Replacements.imgURL );
}
var _div = document.createElement( "DIV" );
_div.id = 'tplate_previewWrapper';
_div.update( _tplate.evaluate( _data ) );
document.body.appendChild( _div );
ipb.positionCenter( 'tplate_preview_' + _data['replacement_id'] );
}
/**
* Close Preview
*/
this.closePreview = function()
{
try
{
$('tplate_previewWrapper').remove();
}
catch(e)
{
}
}
/**
* Shows the template editor
*/
this.cancelReplacements = function()
{
/*if ( ! confirm( "All unsaved changes will be lost!" ) )
{
return false;
}*/
try
{
$('tplate_editorWrapper').remove();
}
catch(e)
{
}
}
/**
* Build a list of Replacements groups (files)
*/
this.buildReplacementsList = function()
{
/* INIT */
var _output = '';
var _tplate = new Template( $('tplate_replacementsRow').innerHTML );
var json = IPB3Replacements.ReplacementsData;
var _groups = Object.keys( json['replacements'] ).sort();
/* Clear out any current listing */
$('tplate_replacementsList').update('');
/* Format... */
_groups.each( function( i )
{
/* Figure out if this in an inherited row, a changed row, a new row or a default row */
if ( json['replacements'][i]['replacement_added_to'] == IPB3Replacements.currentSetData['set_id'] )
{
/* This is a modified row */
json['replacements'][i]['_cssState'] = 'new';
json['replacements'][i]['_cssClass'] = 'tplateRow_new';
}
else if ( json['replacements'][i]['replacement_set_id'] == IPB3Replacements.currentSetData['set_id'] )
{
/* This is a modified row */
json['replacements'][i]['_cssState'] = 'modified';
json['replacements'][i]['_cssClass'] = 'tplateRow_mod';
}
else if ( IPB3Replacements.currentSetData['_parentTree'].indexOf( json['replacements'][i]['replacement_set_id'] ) != -1 )
{
/* Inherited */
json['replacements'][i]['_cssState'] = 'inherit';
json['replacements'][i]['_cssClass'] = 'tplateRow_inh';
}
else
{
/* This is a default row */
json['replacements'][i]['_cssState'] = 'default';
json['replacements'][i]['_cssClass'] = 'tplateRow_def';
}
_output += _tplate.evaluate( json['replacements'][i] );
} );
/* Write it out */
$('tplate_replacementsList').update( _output );
/* Post Process */
_groups.each( function( i )
{
/* Inline deleted? */
if ( json['replacements'][i]['_cssState'] == 'new' )
{
$('tplate_replacementsRow_' + json['replacements'][i]['replacement_id'] + '_revert').update('Remove');
}
else if ( json['replacements'][i]['_cssState'] != 'default' )
{
$('tplate_replacementsRow_' + json['replacements'][i]['replacement_id'] + '_revert').show();
}
else
{
$('tplate_replacementsRow_' + json['replacements'][i]['replacement_id'] + '_revert').hide();
}
} );
}
/**
* Template Mouse Event
*/
this.mouseEvent = function( e )
{
if ( _div = $( Event.element( e ) ).up( '.' + IPB3Replacements.cssNames['replacementsRow'] ) )
{
var _replacement_id = _div.id.replace( 'tplate_replacementsRow_', '' );
if ( e.type == 'mouseover' )
{
_div.addClassName( IPB3Replacements.cssNames['replacementsHover'] );
}
else if ( e.type == 'mouseout' )
{
_div.removeClassName( IPB3Replacements.cssNames['replacementsHover'] );
}
else if ( e.type == 'click' )
{
var _el = Event.findElement( e, 'div' ).id;
if ( _el.endsWith('_revert' ) )
{
IPB3Replacements.revertReplacement( _replacement_id );
}
else if ( _el.endsWith('_preview' ) )
{
IPB3Replacements.previewReplacement( _replacement_id );
}
else
{
IPB3Replacements.showReplacementsEditor( _replacement_id );
}
}
}
}
}
@@ -0,0 +1,299 @@
/**
* 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['_t'] = window.setInterval(
function()
{
if ( IPB3TemplateDiff.callInProgress( t.transport) )
{
IPB3TemplateDiff.timeOutAjax( t );
}
},
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( t )
{
window.clearInterval( t['_t'] );
window.clearInterval( t['_t2'] );
}
} );
function IPBTemplateDiff()
{
/**
* URLS
*/
this.baseUrl = '';
this.imageUrl = '';
/*
* 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( 0 );
/* Reset progress bar */
this.updateProgressBar( false );
/* Reset image */
this.updateProgressImage( 'send' );
/* Start off with the SQL */
this.fireAjax( 0 );
}
/**
* Update the progress bar
*/
this.updateProgressBar = function( processed )
{
/* INIT */
var _element = $( 'diffLogProgressBarInner' );
if ( processed !== false )
{
if ( processed == -1 )
{
_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.Request( this.baseUrl + '&do=process',
{
method: 'get',
onSuccess: this.processAjax.bind(this),
onException: this.exceptionAjax.bind(this),
onFailure: this.failureAjax.bind(this)
} );
};
/**
* Checking to see if there's a call in progres...
*/
this.callInProgress = function( t )
{
switch ( t.readyState )
{
case 1:
case 2:
case 3:
return true;
break;
default:
return false;
break;
}
};
/**
* On Timeout
*/
this.timeOutAjax = function( t )
{
if ( confirm( "No response from the webserver.\nDo you wish to continue waiting?" ) )
{
return true;
}
else
{
t.transport.abort();
alert( "Request Cancelled" );
}
};
/**
* On Failure
*/
this.failureAjax = function( t )
{
alert( "Failure: " + t.responseText );
};
/**
* On Failure
*/
this.exceptionAjax = function( t )
{
alert( "Exception: " + t.responseText );
}
/**
* Process Ajax (Success)
*/
this.processAjax = function( t )
{
/* 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'] )
{
alert( "An error occured: " . json['error'] );
return false;
}
/* All good: Update status message... */
this.updateCounter( json['processed'] );
/* Update progress bar */
this.updateProgressBar( json['processed'] );
/* Finish? If so - say all done and go tubby-bye-bye */
if ( json['completed'] != 1 )
{
/* Fire Ajax */
this.fireAjax();
}
else
{
/* All Done */
this.updateProgressBar( -1 );
this.updateProgressImage( 'ready' );
/* Show done thing */
$( 'diffDone' ).show();
}
};
/**
* Write to Log
*/
this.updateCounter = function( count )
{
$( 'diffLogProcessed' ).innerHTML = count;
};
}
@@ -0,0 +1,393 @@
/**
* INVISION POWER BOARD v3
*
* Topics View Javascript File
* @author Matt Mecham, Brandon Farber, Josh Williams
* @since 2008
*/
/**
* "ACP" Class. Designed for ... ACP Template Search And Replace Functions
* @author (v.1.0.0) Matt Mecham
*/
function IPBTemplateSandR()
{
/**
* Session ID
*/
this.sessionID = '';
/*
* JSON
*/
this.sessionData = {};
this.templateGroups = {};
this.setData = {};
this.currentTemplateBit = {};
this.currentTemplateGroup = {};
/**
* Init Function
* @author Matt Mecham
*/
this.init = function()
{
/* Set Session ID */
this.sessionID = this.sessionData['sandr_session_id'];
/* Build group list */
this.buildGroupsList();
};
/**
* Toggle all template bits box
*/
this.toggleGroupBox = function( groupName )
{
var checked = $( 'cbox_group_' + groupName ).checked;
$$('.cboxGroup' + groupName ).each(function(cbox)
{
cbox.checked = checked;
});
}
/**
* Check group check box
*/
this.checkGroupBox = function( groupName )
{
var _checkedCount = 0;
var _allCount = 0;
$$('.cboxGroup' + groupName ).each(function(cbox)
{
if ( cbox.checked )
{
_checkedCount++;
}
_allCount++;
});
$( 'cbox_group_' + groupName ).checked = ( _allCount == _checkedCount ) ? true : false;
}
/**
* Load template bits
*/
this.loadTemplateEditor = function( template_id )
{
/* Grab the JSON for the template bits for the current template group */
url = ipb.vars['base_url'] + "app=core&amp;module=ajax&amp;section=templates&amp;do=getTemplateForEdit&amp;setID=" + this.setData['set_id'] + '&template_id=' + template_id + '&secure_key=' + ipb.vars['md5_hash'];
new Ajax.Request( url.replace( /&amp;/g, '&' ),
{
method: 'GET',
onSuccess: function (t )
{
if ( t.responseText.match( /^(\s+?)?\{/ ) )
{
eval( "var json = " + t.responseText );
if ( json['error'] )
{
alert( json['error'] );
return;
}
else
{
IPB3TemplatesSandR.showTemplateEditor( json );
}
}
else
{
alert( "Галектеко ОПАСНОСТЕ! ПЫЩПЫЩ!11: " + t.responseText );
}
},
onException: function( f,e ){ alert( "Исключение: " + e ) },
onFailure: function( t ){ alert( "Ошибка: " + t.responseText ) }
} );
}
/**
* Shows the template editor
*/
this.showTemplateEditor = function( json )
{
/* Close any open editors */
IPB3TemplatesSandR.cancelTemplateBit( json['templateData']['template_id'] );
var _tplate = new Template( $('tplate_templateEditor').innerHTML );
IPB3TemplatesSandR.currentTemplateBit = json['templateData'];
var _div = document.createElement( "DIV" );
_div.id = 'tplate_editorWrapper';
_div.update( _tplate.evaluate( json['templateData'] ) );
document.body.appendChild( _div );
ipb.positionCenter( 'tplate_editor_' + json['templateData']['template_id'] );
}
/**
* Peform the placements
*/
this.performReplacement = function()
{
/* Grab the JSON for the template bits for the current template group */
url = ipb.vars['base_url'] + "app=core&amp;module=ajax&amp;section=templatesandr&amp;do=replace&&sessionID=" + this.sessionID + '&secure_key=' + ipb.vars['md5_hash'];
$('replaceButton').disabled = true;
$('replaceButton').value = "Сохранение...";
new Ajax.Request( url.replace( /&amp;/g, '&' ),
{
method: 'POST',
parameters: $('sandrForm').serialize(true),
onSuccess: function (t )
{
if ( t.responseText.match( /^(\s+?)?\{/ ) )
{
eval( "var json = " + t.responseText );
if ( json['error'] )
{
alert( json['error'] );
return;
}
else
{
if ( json['errors'] )
{
/* Something inline would be very nice here.. rather than this ugly alert */
alert("Ошибка: " + json['errors'] );
}
else
{
$('replaceButton').disabled = false;
$('replaceButton').value = "Заменить выбранные";
}
}
}
else
{
alert( "Галектеко ОПАСНОСТЕ! ПЫЩПЫЩ!11: " + t.responseText );
}
},
onException: function( f,e ){ alert( "Исключение: " + e ) },
onFailure: function( t ){ alert( "Ошибка: " + t.responseText ) }
} );
}
/**
* Save template bit
*/
this.saveTemplateBit = function( template_id )
{
/* Grab the JSON for the template bits for the current template group */
url = ipb.vars['base_url'] + "app=core&amp;module=ajax&amp;section=templates&amp;do=saveTemplateBit&amp;setID=" + this.setData['set_id'] + '&template_id=' + template_id + '&secure_key=' + ipb.vars['md5_hash'];
/* Set up params */
var params = { 'template_content' : $F('tplate_editBox_' + template_id ),
'template_data' : $F('tplate_dataBox_' + template_id ),
'template_set' : this.setData['set_id'],
'template_group' : IPB3TemplatesSandR.currentTemplateGroup,
'type' : 'edit' };
new Ajax.Request( url.replace( /&amp;/g, '&' ),
{
method: 'POST',
parameters: params,
onSuccess: function (t )
{
if ( t.responseText.match( /^(\s+?)?\{/ ) )
{
eval( "var json = " + t.responseText );
if ( json['error'] )
{
alert( json['error'] );
return;
}
else
{
IPB3TemplatesSandR.currentTemplateBit = json['templateData'];
IPB3TemplatesSandR.showTemplateEditor( json );
if ( json['errors'] )
{
/* Something inline would be very nice here.. rather than this ugly alert */
alert("Ошибка: " + json['errors'] );
}
else
{
new Effect.Pulsate( $('tplate_editor_' + template_id ), { 'pulses' : 2, 'from' : 0.7, 'duration' : 0.5 } );
}
}
}
else
{
alert( "Галектеко ОПАСНОСТЕ! ПЫЩПЫЩ!11: " + t.responseText );
}
},
onException: function( f,e ){ alert( "Исключение: " + e ) },
onFailure: function( t ){ alert( "Ошибка: " + t.responseText ) }
} );
}
/**
* Shows the template editor
*/
this.cancelTemplateBit = function( templateID )
{
try
{
$('tplate_editorWrapper').remove();
}
catch(e)
{
}
}
/**
* Build a list of template groups
*/
this.buildGroupsList = function()
{
/* INIT */
var _output = '';
var _tplate = new Template( $('tplate_groupRow').innerHTML );
var json = IPB3TemplatesSandR.templateGroups;
var ROW_ON_OFF = true;
var CLASS_NAME = '';
var _groups = Object.keys( json['groups'] ).sort();
/* Clear out any current listing */
$('tplate_groupList').update('');
/* Format... */
_groups.each( function( i )
{
if( ROW_ON_OFF)
{
ROW_ON_OFF = false;
CLASS_NAME = 'acp-row-off';
}
else
{
ROW_ON_OFF = true;
CLASS_NAME = 'acp-row-on';
}
_output += _tplate.evaluate( { 'groupName' : i, '_matches' : Object.keys( json['groups'][i] ).length, 'classname' : CLASS_NAME } );
} );
/* Write it out */
$('tplate_groupList').update( _output );
/* Post process */
_groups.each( function( i )
{
if ( IPB3TemplatesSandR.sessionData['sandr_search_only'] )
{
$( 'groupRowCbox_' + i ).hide();
}
else
{
$( 'groupRowCbox_' + i ).show();
}
} );
doStriping();
};
/**
* Build a list of template bits
*/
this.buildTemplateList = function( groupName, json )
{
/* INIT */
var _output = '';
var _tplate = new Template( $('tplate_templateRow').innerHTML );
IPB3TemplatesSandR.currentTemplateGroup = groupName;
/* Clear out any current listing */
$( 'groupRowTemplates_' + groupName ).update('');
/* Add in the new... */
for( i = 0 ; i < json['templates'].length; i++ )
{
_output += _tplate.evaluate( json['templates'][i] );
};
/* Write it out */
$( 'groupRowTemplates_' + groupName ).update( _output );
/* Post process */
for( i = 0 ; i < json['templates'].length; i++ )
{
if ( IPB3TemplatesSandR.sessionData['sandr_search_only'] )
{
$( 'templateRowCbox_' + json['templates'][i]['template_id'] ).hide();
}
else
{
$( 'templateRowCbox_' + json['templates'][i]['template_id'] ).show();
/* Checked, please? */
IPB3TemplatesSandR.toggleGroupBox( json['templates'][i]['template_group'] );
}
};
};
/**
* Show / Hide templates
*/
this.toggleTemplates = function( groupName )
{
if ( $('groupRowTemplates_' + groupName ).hasClassName( 'tmplShow' ) )
{
$('groupRowTemplates_' + groupName ).removeClassName( 'tmplShow' );
$('groupRowTemplates_' + groupName ).hide();
}
else
{
$('groupRowTemplates_' + groupName ).addClassName( 'tmplShow' );
$('groupRowTemplates_' + groupName ).show();
/* Ajax */
/* Grab the JSON for the template bits for the current template group */
url = ipb.vars['base_url'] + "app=core&amp;module=ajax&amp;section=templatesandr&amp;do=getTemplateBitList&amp;setID=" + this.setData['set_id'] + '&templateGroup=' + groupName + '&secure_key=' + ipb.vars['md5_hash'] + '&sessionID=' + this.sessionID;
new Ajax.Request( url.replace( /&amp;/g, '&' ),
{
method: 'GET',
onSuccess: function (t )
{
if ( t.responseText.match( /^(\s+?)?\{/ ) )
{
eval( "var json = " + t.responseText );
if ( json['error'] )
{
alert( json['error'] );
return;
}
else
{
IPB3TemplatesSandR.buildTemplateList( groupName, json );
}
}
else
{
alert( "Ooops. Something went wrong. Does this help?: " + t.responseText );
}
}
} );
}
}
}
@@ -0,0 +1,583 @@
/**
* INVISION POWER BOARD v3
*
* Topics View Javascript File
* @author Matt Mecham, Brandon Farber, Josh Williams
* @since 2008
*/
/**
* "ACP" Class. Designed for ... ACP Templating Functions
* @author (v.1.0.0) Matt Mecham
*/
function IPBTemplates()
{
/**
* Template groups
*
* @var array
*/
this.templateGroups = {};
/**
* Current template group
*
* @var array
*/
this.currentTemplateGroup = '';
/**
* Current template bit
*
* @var array
*/
this.currentTemplateBit = '';
/**
* Current set ID
*
* @var array
*/
this.currentSetData = {};
/**
* CSS Names
*
* @var hash
*/
this.cssNames = { 'groupRowLit' : 'tplateLit',
'groupHover' : 'groupHover',
'groupRowLitMain' : 'tablerow1',
'groupRow' : 'tablerow2',
'templateRow' : 'tablerow2',
'templateHover' : 'templateHover' };
/**
* INIT Applications
*/
this.init = function()
{
/* Build group list */
this.buildGroupsList();
/* fix template window to same height as group list and make it scrollable */
$('tplate_bitList').setStyle( { 'height' : $('tplate_groupList').getHeight() + 'px', 'overflow' : 'auto'} );
this.loadTemplateBits( this.currentTemplateGroup );
}
/**
* Load template groups
*/
this.loadTemplateGroups = function()
{
/* Grab the JSON for the template bits for the current template group */
url = ipb.vars['base_url'] + "app=core&amp;module=ajax&amp;section=templates&amp;do=getTemplateGroupList&amp;setID=" + this.currentSetData['set_id'] + '&secure_key=' + ipb.vars['md5_hash'];
new Ajax.Request( url.replace( /&amp;/g, '&' ),
{
method: 'GET',
onSuccess: function (t )
{
if ( t.responseText.match( /^(\s+?)?\{/ ) )
{
$('tplate_debug').innerHTML += "\n" + t.responseText;
eval( "var json = " + t.responseText );
if ( json['error'] )
{
alert( json['error'] );
return;
}
else
{
IPB3Templates.templateGroups = json;
IPB3Templates.buildGroupsList();
/* Hilite */
IPB3Templates.hiliteGroup( IPB3Templates.currentTemplateGroup );
}
}
else
{
alert( "Ooops. Something went wrong. Does this help?: " + t.responseText );
}
},
onException: function( f,e ){ alert( "Exception: " + e ) },
onFailure: function( t ){ alert( "Failure: " + t.responseText ) }
} );
}
/**
* Load template bits
*/
this.loadTemplateBits = function( groupName, force )
{
/* Grab the JSON for the template bits for the current template group */
url = ipb.vars['base_url'] + "app=core&amp;module=ajax&amp;section=templates&amp;do=getTemplateBitList&amp;setID=" + this.currentSetData['set_id'] + '&templateGroup=' + groupName + '&secure_key=' + ipb.vars['md5_hash'];
new Ajax.Request( url.replace( /&amp;/g, '&' ),
{
method: 'GET',
onSuccess: function (t )
{
if ( t.responseText.match( /^(\s+?)?\{/ ) )
{
$('tplate_debug').innerHTML += "\n" + t.responseText;
eval( "var json = " + t.responseText );
if ( json['error'] )
{
alert( json['error'] );
return;
}
else
{
var _reload = 0;
/* New group? */
if ( ! IPB3Templates.templateGroups['groups'][ groupName ] )
{
IPB3Templates.templateGroups['groups'][ groupName ] = { '_modCount' : 0, 'template_group' : groupName };
_reload = 1;
}
/* Update group's template count */
if ( json['groupData'] )
{
if ( json['groupData']['_modCount'] != IPB3Templates.templateGroups['groups'][ groupName ]['_modCount'] )
{
IPB3Templates.templateGroups['groups'][ groupName ]['_modCount'] = json['groupData']['_modCount'];
_reload = 1;
}
}
/* Re-draw list */
if ( _reload )
{
IPB3Templates.buildGroupsList();
}
/* Hilite */
IPB3Templates.hiliteGroup( groupName );
IPB3Templates.buildTemplateList( json );
}
}
else
{
alert( "Ooops. Something went wrong. Does this help?: " + t.responseText );
}
},
onException: function( f,e ){ alert( "Exception: " + e ) },
onFailure: function( t ){ alert( "Failure: " + t.responseText ) }
} );
}
/**
* Save template bit
*/
this.saveTemplateBit = function( template_id )
{
/* Grab the JSON for the template bits for the current template group */
url = ipb.vars['base_url'] + "app=core&amp;module=ajax&amp;section=templates&amp;do=saveTemplateBit&amp;setID=" + this.currentSetData['set_id'] + '&template_id=' + template_id + '&secure_key=' + ipb.vars['md5_hash'];
/* Set up params */
var params = { 'template_content' : $F('tplate_editBox_' + template_id ),
'template_data' : $F('tplate_dataBox_' + template_id ),
'template_set' : this.currentSetData['set_id'],
'template_group' : IPB3Templates.currentTemplateGroup,
'type' : IPB3Templates.currentTemplateBit['_type'] };
if ( IPB3Templates.currentTemplateBit['_type'] == 'add' )
{
params['_template_name'] = $F('tplate_addNameTextField_0');
params['_template_group'] = $F('tplate_addGroupTextField_0');
}
new Ajax.Request( url.replace( /&amp;/g, '&' ),
{
method: 'POST',
parameters: params,
onSuccess: function (t )
{
if ( t.responseText.match( /^(\s+?)?\{/ ) )
{
eval( "var json = " + t.responseText );
if ( json['error'] )
{
alert( json['error'] );
return;
}
else
{
IPB3Templates.currentTemplateBit = json['templateData'];
IPB3Templates.showTemplateEditor( json );
IPB3Templates.loadTemplateBits( json['templateData']['template_group'] );
if ( json['errors'] )
{
/* Something inline would be very nice here.. rather than this ugly alert */
alert("UGLY ALERT BOX SAYS: " + json['errors'] );
}
else
{
alert("UGLY ALERT BOX SAYS: Saved!");
}
}
}
else
{
alert( "Ooops. Something went wrong. Does this help?: " + t.responseText );
}
},
onException: function( f,e ){ alert( "Exception: " + e ) },
onFailure: function( t ){ alert( "Failure: " + t.responseText ) }
} );
}
/**
* Revert template bit
*/
this.revertTemplateBit = function( template_id )
{
/* Make sure we're mean it... */
if ( $('tplate_templaterow_' + template_id ).hasClassName( 'tplateRow_new') )
{
if ( ! confirm( "REMOVE template bit?\n This will remove this template bit in ALL skins!" ) )
{
return false;
}
}
else
{
if ( ! confirm( "Revert template bit?\n All changes WILL be lost!" ) )
{
return false;
}
}
/* Grab the JSON for the template bits for the current template group */
url = ipb.vars['base_url'] + "app=core&amp;module=ajax&amp;section=templates&amp;do=revertTemplateBit&amp;setID=" + this.currentSetData['set_id'] + '&template_id=' + template_id + '&secure_key=' + ipb.vars['md5_hash'];
new Ajax.Request( url.replace( /&amp;/g, '&' ),
{
method: 'GET',
onSuccess: function (t )
{
if ( t.responseText.match( /^(\s+?)?\{/ ) )
{
eval( "var json = " + t.responseText );
if ( json['error'] )
{
alert( json['error'] );
return;
}
else
{
if ( json['templateData'] )
{
IPB3Templates.currentTemplateBit = json['templateData'];
}
else
{
/* Reload the group */
IPB3Templates.loadTemplateGroups();
}
IPB3Templates.loadTemplateBits( IPB3Templates.currentTemplateBit['template_group'] );
if ( json['errors'] )
{
/* Something inline would be very nice here.. rather than this ugly alert */
alert("UGLY ALERT BOX SAYS: " + json['errors'] );
}
}
}
else
{
alert( "Ooops. Something went wrong. Does this help?: " + t.responseText );
}
},
onException: function( f,e ){ alert( "Exception: " + e ) },
onFailure: function( t ){ alert( "Failure: " + t.responseText ) }
} );
}
/**
* Load template bits
*/
this.loadTemplateEditor = function( template_id )
{
/* Grab the JSON for the template bits for the current template group */
url = ipb.vars['base_url'] + "app=core&amp;module=ajax&amp;section=templates&amp;do=getTemplateForEdit&amp;setID=" + this.currentSetData['set_id'] + '&template_id=' + template_id + '&secure_key=' + ipb.vars['md5_hash'];
new Ajax.Request( url.replace( /&amp;/g, '&' ),
{
method: 'GET',
onSuccess: function (t )
{
if ( t.responseText.match( /^(\s+?)?\{/ ) )
{
eval( "var json = " + t.responseText );
if ( json['error'] )
{
alert( json['error'] );
return;
}
else
{
IPB3Templates.showTemplateEditor( json );
}
}
else
{
alert( "Ooops. Something went wrong. Does this help?: " + t.responseText );
}
},
onException: function( f,e ){ alert( "Exception: " + e ) },
onFailure: function( t ){ alert( "Failure: " + t.responseText ) }
} );
}
/**
* Shows the new template bit form
*/
this.addBitForm = function()
{
/* Close any open editors */
IPB3Templates.cancelTemplateBit( 0 );
var _tplate = new Template( $('tplate_templateEditorAdd').innerHTML );
var _data = { 'template_id' : 0,
'template_set_id' : IPB3Templates.currentSetData['set_id'],
'template_group' : IPB3Templates.currentTemplateGroup,
'template_content' : '',
'_type' : 'add' };
var _div = document.createElement( "DIV" );
_div.id = 'tplate_editorWrapper';
_div.update( _tplate.evaluate( _data ) );
document.body.appendChild( _div );
ipb.positionCenter( 'tplate_editor_0' );
IPB3Templates.currentTemplateBit = _data;
}
/**
* Shows the template editor
*/
this.showTemplateEditor = function( json )
{
/* Close any open editors */
IPB3Templates.cancelTemplateBit( json['templateData']['template_id'] );
var _tplate = new Template( $('tplate_templateEditor').innerHTML );
IPB3Templates.currentTemplateBit = json['templateData'];
var _div = document.createElement( "DIV" );
_div.id = 'tplate_editorWrapper';
_div.update( _tplate.evaluate( json['templateData'] ) );
document.body.appendChild( _div );
ipb.positionCenter( 'tplate_editor_' + json['templateData']['template_id'] );
}
/**
* Shows the template editor
*/
this.cancelTemplateBit = function( templateID )
{
/*if ( ! confirm( "All unsaved changes will be lost!" ) )
{
return false;
}*/
try
{
$('tplate_editorWrapper').remove();
}
catch(e)
{
}
}
/**
* Shows a group entry as 'lit'
*/
this.hiliteGroup = function( templateGroup )
{
/* Un-hi-lite all groups */
var _groups = Object.keys( IPB3Templates.templateGroups['groups'] ).sort();
/* Format... */
_groups.each( function( i )
{
/* Fix up template */
$('tplate_grouprow_' + i ).removeClassName( IPB3Templates.cssNames['groupRowLitMain'] );
$('tplate_grouprow_' + i ).removeClassName( IPB3Templates.cssNames['groupRowLit'] );
$('tplate_grouprow_' + i ).addClassName( IPB3Templates.cssNames['groupRow'] );
} );
$('tplate_grouprow_' + templateGroup ).removeClassName( IPB3Templates.cssNames['groupRow'] );
$('tplate_grouprow_' + templateGroup ).addClassName( IPB3Templates.cssNames['groupRowLitMain'] );
$('tplate_grouprow_' + templateGroup ).addClassName( IPB3Templates.cssNames['groupRowLit'] );
}
/**
* Build a list of template groups
*/
this.buildGroupsList = function()
{
/* INIT */
var _output = '';
var _tplate = new Template( $('tplate_groupRow').innerHTML );
var json = IPB3Templates.templateGroups;
var _groups = Object.keys( json['groups'] ).sort();
/* Clear out any current listing */
$('tplate_groupList').update('');
/* Format... */
_groups.each( function( i )
{
_output += _tplate.evaluate( { 'groupName' : i, '_modCount' : json['groups'][i]['_modCount'] } );
} );
/* Write it out */
$('tplate_groupList').update( _output );
}
/**
* Build a list of template bits
*/
this.buildTemplateList = function( json )
{
/* INIT */
var _output = '';
var _tplate = new Template( $('tplate_templateRow').innerHTML );
/* Clear out any current listing */
$('tplate_bitList').update('');
/* Add in the new... */
for( i = 0 ; i < json['templates'].length; i++ )
{
/* Figure out if this in an inherited row, a changed row, a new row or a default row */
if ( json['templates'][i]['template_added_to'] == IPB3Templates.currentSetData['set_id'] )
{
/* This is a modified row */
json['templates'][i]['_templateState'] = 'new';
json['templates'][i]['_cssClass'] = 'tplateRow_new';
}
else if ( json['templates'][i]['template_set_id'] == IPB3Templates.currentSetData['set_id'] )
{
/* This is a modified row */
json['templates'][i]['_templateState'] = 'modified';
json['templates'][i]['_cssClass'] = 'tplateRow_mod';
}
else if ( IPB3Templates.currentSetData['_parentTree'].indexOf( json['templates'][i]['template_set_id'] ) != -1 )
{
/* Inherited */
json['templates'][i]['_templateState'] = 'inherit';
json['templates'][i]['_cssClass'] = 'tplateRow_inh';
}
else
{
/* This is a default row */
json['templates'][i]['_templateState'] = 'default';
json['templates'][i]['_cssClass'] = 'tplateRow_def';
}
_output += _tplate.evaluate( json['templates'][i] );
};
/* Write it out */
$('tplate_bitList').update( _output );
/* Post Process */
for( i = 0 ; i < json['templates'].length; i++ )
{
if ( json['templates'][i]['_templateState'] == 'new' )
{
$('tplate_templateRow_' + json['templates'][i]['template_id'] + '_revert').update('Remove');
}
else if ( json['templates'][i]['_templateState'] != 'default' )
{
$('tplate_templateRow_' + json['templates'][i]['template_id'] + '_revert').show();
}
else
{
$('tplate_templateRow_' + json['templates'][i]['template_id'] + '_revert').hide();
}
}
}
/**
* Template Mouse Event
*/
this.templateMouseEvent = function( e )
{
if ( _div = $( Event.element( e ) ).up( '.' + IPB3Templates.cssNames['templateRow'] ) )
{
var _template_id = _div.id.replace( 'tplate_templaterow_', '' );
if ( e.type == 'mouseover' )
{
_div.addClassName( IPB3Templates.cssNames['templateHover'] );
}
else if ( e.type == 'mouseout' )
{
_div.removeClassName( IPB3Templates.cssNames['templateHover'] );
}
else if ( e.type == 'click' )
{
var _el = Event.findElement( e, 'div' ).id;
if ( _el.endsWith('_revert' ) )
{
IPB3Templates.revertTemplateBit( _template_id );
}
else
{
IPB3Templates.loadTemplateEditor( _template_id );
}
}
}
}
/**
* Group Mouse Event
*/
this.groupMouseEvent = function( e )
{
var groupName = $( Event.findElement( e, 'div' ) ).id;
var _groupName = groupName.replace( 'tplate_grouprow_', '' );
if ( e.type == 'mouseover' )
{
$( groupName ).addClassName( IPB3Templates.cssNames['groupHover'] );
}
else if ( e.type == 'mouseout' )
{
$( groupName ).removeClassName( IPB3Templates.cssNames['groupHover'] );
}
else if ( e.type == 'click' )
{
IPB3Templates.currentTemplateGroup = _groupName;
IPB3Templates.loadTemplateBits( _groupName );
}
}
}
@@ -0,0 +1,604 @@
/**
* INVISION POWER BOARD v3
*
* Topics View Javascript File
* @author Matt Mecham, Brandon Farber, Josh Williams
* @since 2008
*/
/**
* "ACP" Class. Designed for ... ACP User Agents Functions
* @author (v.1.0.0) Matt Mecham
*/
function IPBUAgents()
{
/**
* Template groups
*
* @var array
*/
this.uAgentsData = {};
/**
* Group Data
*/
this.uAgentsGroupData = {};
/**
* Agents by key
*/
this.agentsByKey = {};
/**
* uagents Names
*
* @var hash
*/
this.cssNames = {
'uagentsRow' : 'uAgentsRow',
'uagentsHover' : 'uAgentsHover',
'uagentsGRow' : 'uAgentsGRow',
'uagentsGHover' : 'uAgentsGHover',
'uagentsGRRow' : 'uAgentsGRRow',
'uagentsGRHover' : 'uAgentsGRHover'
};
/**
* INIT User Agents List
*/
this.init = function()
{
/* Build uagents list */
this.buildUAgentsList();
}
/**
* INIT User Agent Form
*/
this.groupFormInit = function()
{
/* Figure out which are already in the list */
/* Set up key based array */
Object.keys( this.uAgentsData['uagents'] ).each( function( i )
{
IPB3UAgents.agentsByKey[ IPB3UAgents.uAgentsData['uagents'][i]['uagent_key'] ] = IPB3UAgents.uAgentsData['uagents'][i];
} );
/* Soft delete the ones in the group already */
Object.keys( this.uAgentsGroupData ).each( function( i )
{
IPB3UAgents.uAgentsData['uagents'][ IPB3UAgents.agentsByKey[ IPB3UAgents.uAgentsGroupData[i]['uagent_key'] ]['uagent_id'] ]['_used'] = 1;
} );
/* Build uagents list */
this.buildGroupAgentList();
/* Build uagents list that are already in the group */
this.buildGroupAgentsUsedList();
}
/**
* Save uagents
*/
this.saveuAgent = function( uagent_id )
{
/* Grab the JSON for the template bits for the current template group */
url = ipb.vars['base_url'] + "app=core&amp;module=ajax&amp;section=uagents&amp;do=saveuAgent&amp;&uagent_id=" + uagent_id + '&secure_key=' + ipb.vars['md5_hash'];
/* Set up params */
var params = { 'uagent_key' : $F('tplate_keyBox_' + uagent_id ),
'uagent_name' : $F('tplate_titleBox_' + uagent_id ),
'uagent_regex' : $F('tplate_regexBox_' + uagent_id ),
'uagent_regex_capture' : $F('tplate_captureBox_' + uagent_id ),
'uagent_type' : $F('tplate_typeBox_' + uagent_id ),
'uagent_position' : $F('tplate_positionBox_' + uagent_id ),
'type' : ( uagent_id == 0 ) ? 'add' : 'edit'
};
new Ajax.Request( url.replace( /&amp;/g, '&' ),
{
method: 'POST',
parameters: params,
onSuccess: function (t )
{
if ( t.responseText.match( /^(\s+?)?\{/ ) )
{
eval( "var json = " + t.responseText );
if ( json['error'] )
{
alert( json['error'] );
return;
}
else
{
IPB3UAgents.uAgentsData = json;
IPB3UAgents.buildUAgentsList();
if ( json['errors'] )
{
/* Something inline would be very nice here.. rather than this ugly alert */
alert("UGLY ALERT BOX SAYS: " + json['errors'] );
}
else
{
alert("UGLY ALERT BOX SAYS: Saved!");
}
}
}
else
{
alert( "Ooops. Something went wrong. Does this help?: " + t.responseText );
}
},
onException: function( f,e ){ alert( "Exception: " + e ) },
onFailure: function( t ){ alert( "Failure: " + t.responseText ) }
} );
}
/**
* Revert css
*/
this.removeuAgent = function( uagent_id )
{
/* Make sure we're mean it... */
if ( ! confirm( "Remove user agent?\\nThis will be removed permanently" ) )
{
return false;
}
/* Grab the JSON for the template bits for the current template group */
url = ipb.vars['base_url'] + "app=core&amp;module=ajax&amp;section=uagents&amp;do=removeuAgent&amp;uagent_id=" + uagent_id + '&secure_key=' + ipb.vars['md5_hash'];
new Ajax.Request( url.replace( /&amp;/g, '&' ),
{
method: 'GET',
onSuccess: function (t )
{
if ( t.responseText.match( /^(\s+?)?\{/ ) )
{
eval( "var json = " + t.responseText );
if ( json['error'] )
{
alert( json['error'] );
return;
}
else
{
IPB3UAgents.uAgentsData = json;
IPB3UAgents.buildUAgentsList();
if ( json['errors'] )
{
/* Something inline would be very nice here.. rather than this ugly alert */
alert("UGLY ALERT BOX SAYS: " + json['errors'] );
}
}
}
else
{
alert( "Ooops. Something went wrong. Does this help?: " + t.responseText );
}
},
onException: function( f,e ){ alert( "Exception: " + e ) },
onFailure: function( t ){ alert( "Failure: " + t.responseText ) }
} );
}
/**
* Add uagents form
*/
this.adduAgentForm = function()
{
IPB3UAgents.showuAgentsEditor( 0 );
}
/**
* Shows the template editor
*/
this.showuAgentsEditor = function( uagent_id )
{
/* Close any open editors */
IPB3UAgents.canceluAgents();
var _tplate = new Template( $('tplate_uagentsEditor').innerHTML );
var _keys = Object.keys( IPB3UAgents.uAgentsData['uagents'] );
var _data = {};
/* Get replacement Data */
if ( uagent_id )
{
_keys.each( function( i )
{
if ( IPB3UAgents.uAgentsData['uagents'][ i ]['uagent_id'] == uagent_id )
{
_data = IPB3UAgents.uAgentsData['uagents'][ i ];
}
} );
}
else
{
_data = { 'uagent_id' : 0 };
}
var _div = new Element('div', { id: 'tplate_editorWrapper' } );
//_div.id = 'tplate_editorWrapper';
_div.update( _tplate.evaluate( _data ) );
document.body.appendChild( _div );
/* Adjust title */
if ( ! uagent_id )
{
$('tplate_title_' + uagent_id ).update("Adding User Agent");
}
/* Select box type */
_box = $('tplate_typeBox_' + _data['uagent_id'] );
for( i = 0 ; i < _box.options.length ; i++ )
{
if ( _box.options[i].value == _data['uagent_type'] )
{
_box.selectedIndex = i;
}
};
ipb.positionCenter( 'tplate_editor_' + uagent_id );
}
/**
* Close the editor
*/
this.canceluAgents = function()
{
/*if ( ! confirm( "All unsaved changes will be lost!" ) )
{
return false;
}*/
try
{
$('tplate_editorWrapper').remove();
}
catch(e)
{
}
}
/**
* Build a list of uagents groups (files)
*/
this.buildUAgentsList = function()
{
/* INIT */
var _output = '';
var _tplate = new Template( $('tplate_uagentsRow').innerHTML );
var json = IPB3UAgents.uAgentsData;
var _groups = Object.keys( json['uagents'] );
/* Clear out any current listing */
$('tplate_uagentList').update('');
/* Format... */
_groups.each( function( i )
{
json['uagents'][i]['_cssClass'] = IPB3UAgents.cssNames['uagentsRow'];
_output += _tplate.evaluate( json['uagents'][i] );
} );
/* Write it out */
$('tplate_uagentList').update( _output );
/* Post process */
_groups.each( function( i )
{
/* Image. Can't use #{...} inline as it parses as HTML entities. Most annoying */
$('tplate_img_' + json['uagents'][i]['uagent_id'] ).src += 'type_' + json['uagents'][i]['uagent_type'] + '.png';
} );
}
/**
* Template Mouse Event
*/
this.mouseEvent = function( e )
{
if ( _div = $( Event.element( e ) ).up( '.' + IPB3UAgents.cssNames['uagentsRow'] ) )
{
var _uagent_id = _div.id.replace( 'tplate_uagentsRow_', '' );
if ( e.type == 'mouseover' )
{
_div.addClassName( IPB3UAgents.cssNames['uagentsHover'] );
}
else if ( e.type == 'mouseout' )
{
_div.removeClassName( IPB3UAgents.cssNames['uagentsHover'] );
}
else if ( e.type == 'click' )
{
var _el = Event.findElement( e, 'div' ).id;
if ( _el.endsWith('_remove' ) )
{
IPB3UAgents.removeuAgent( _uagent_id );
}
else
{
IPB3UAgents.showuAgentsEditor( _uagent_id );
}
}
}
}
/**
* Build a list of USED uagents
*/
this.buildGroupAgentsUsedList = function()
{
/* INIT */
var _output = '';
var _tplate = new Template( $('tplate_groupRow').innerHTML );
var json = IPB3UAgents.uAgentsGroupData;
var _groups = Object.keys( json );
var _save = {};
/* Clear out any current listing */
$('tplate_groupList').update('');
/* Format... */
_groups.each( function( i )
{
if ( ! IPB3UAgents.uAgentsGroupData[i]['_hide'] )
{
_save[i] = IPB3UAgents.uAgentsGroupData[i];
json[i] = IPB3UAgents.uAgentsData['uagents'][ IPB3UAgents.agentsByKey[ IPB3UAgents.uAgentsGroupData[i]['uagent_key'] ]['uagent_id'] ];
json[i]['uagent_versions'] = _save[i]['uagent_versions'];
json[i]['_cssClass'] = IPB3UAgents.cssNames['uagentsGRRow'];
_output += _tplate.evaluate( json[i] );
}
} );
/* Write it out */
$('tplate_groupList').update( _output );
/* Post process */
_groups.each( function( i )
{
if ( ! IPB3UAgents.uAgentsGroupData[i]['_hide'] )
{
/* Image. Can't use #{...} inline as it parses as HTML entities. Most annoying */
$('tplate_groupimg_' + json[i]['uagent_id'] ).src += 'type_' + json[i]['uagent_type'] + '.png';
/* Can we configure a version? */
var _data = IPB3UAgents.uAgentsData['uagents'][ IPB3UAgents.agentsByKey[ IPB3UAgents.uAgentsGroupData[i]['uagent_key'] ]['uagent_id'] ];
if ( _data['uagent_regex_capture'] > 0 )
{
$('tplate_grouprow_' + _data['uagent_id'] + '_configure').show();
}
}
} );
/* Update hidden field */
$('uAgentsData').value = Object.toJSON( _save );
}
/**
* Save user agent form
*/
this.saveGroupForm = function()
{
$('uAgentsForm').submit();
}
/**
* Template Mouse Event
*/
this.groupUsedMouseEvent = function( e )
{
if ( _div = $( Event.element( e ) ).up( '.' + IPB3UAgents.cssNames['uagentsGRRow'] ) )
{
var _uagent_id = _div.id.replace( 'tplate_grouprow_', '' );
if ( e.type == 'mouseover' )
{
_div.addClassName( IPB3UAgents.cssNames['uagentsGRHover'] );
}
else if ( e.type == 'mouseout' )
{
_div.removeClassName( IPB3UAgents.cssNames['uagentsGRHover'] );
}
else if ( e.type == 'click' )
{
var _el = Event.findElement( e, 'div' ).id;
if ( _el.endsWith('_remove' ) )
{
IPB3UAgents.groupRemoveFromList( _uagent_id );
}
else if ( _el.endsWith( '_configure' ) )
{
IPB3UAgents.showConfigureEditor( _uagent_id );
}
}
}
}
/**
* Close the editor
*/
this.cancelAgentVersion = function()
{
/*if ( ! confirm( "All unsaved changes will be lost!" ) )
{
return false;
}*/
try
{
$('tplate_versionsWrapper').remove();
}
catch(e)
{
}
}
/**
* Shows the versions editor
*/
this.showConfigureEditor = function( uagent_id )
{
/* Close any open editors */
IPB3UAgents.cancelAgentVersion();
var _tplate = new Template( $('tplate_versionsEditor').innerHTML );
var _keys = Object.keys( IPB3UAgents.uAgentsData['uagents'] );
var _data = {};
_keys.each( function( i )
{
if ( IPB3UAgents.uAgentsData['uagents'][ i ]['uagent_id'] == uagent_id )
{
_data = IPB3UAgents.uAgentsData['uagents'][ i ];
_data['uagent_versions'] = IPB3UAgents.uAgentsGroupData[ IPB3UAgents.uAgentsData['uagents'][ i ]['uagent_key'] ]['uagent_versions'];
}
} );
var _div = new Element('div', { id: 'tplate_versionsWrapper' } );
_div.update( _tplate.evaluate( _data ) );
document.body.appendChild( _div );
ipb.positionCenter( 'tplate_versions_' + uagent_id );
}
/**
* Save agent version info
*/
this.saveAgentVersion = function( uagent_id )
{
/* Update array */
IPB3UAgents.uAgentsGroupData[ IPB3UAgents.uAgentsData['uagents'][ uagent_id ]['uagent_key'] ]['uagent_versions'] = $F( 'tplate_versionsBox_' + uagent_id );
/* Update display */
IPB3UAgents.buildGroupAgentsUsedList();
/* Close any open editors */
IPB3UAgents.cancelAgentVersion();
}
/**
* Add user agent to the list
*/
this.groupRemoveFromList = function( uagent_id )
{
/* Soft delete */
IPB3UAgents.uAgentsData['uagents'][ uagent_id ]['_used'] = 0;
/* Add to add to group array */
IPB3UAgents.uAgentsGroupData[ IPB3UAgents.uAgentsData['uagents'][ uagent_id ]['uagent_key'] ]['_hide'] = 1;
/* Build uagents list */
IPB3UAgents.buildGroupAgentList();
/* Build uagents list that are already in the group */
IPB3UAgents.buildGroupAgentsUsedList();
}
/**
* Add user agent to the list
*/
this.groupAddToList = function( uagent_id )
{
/* Soft delete */
IPB3UAgents.uAgentsData['uagents'][ uagent_id ]['_used'] = 1;
/* Add to add to group array */
IPB3UAgents.uAgentsGroupData[ IPB3UAgents.uAgentsData['uagents'][ uagent_id ]['uagent_key'] ] = IPB3UAgents.uAgentsData['uagents'][ uagent_id ];
IPB3UAgents.uAgentsGroupData[ IPB3UAgents.uAgentsData['uagents'][ uagent_id ]['uagent_key'] ]['_hide'] = 0;
/* Build uagents list */
IPB3UAgents.buildGroupAgentList();
/* Build uagents list that are already in the group */
IPB3UAgents.buildGroupAgentsUsedList();
}
/**
* Template Mouse Event
*/
this.groupMouseEvent = function( e )
{
if ( _div = $( Event.element( e ) ).up( '.' + IPB3UAgents.cssNames['uagentsGRow'] ) )
{
var _uagent_id = _div.id.replace( 'tplate_agentrow_', '' );
if ( e.type == 'mouseover' )
{
_div.addClassName( IPB3UAgents.cssNames['uagentsGHover'] );
}
else if ( e.type == 'mouseout' )
{
_div.removeClassName( IPB3UAgents.cssNames['uagentsGHover'] );
}
else if ( e.type == 'click' )
{
IPB3UAgents.groupAddToList( _uagent_id );
}
}
}
/**
* Build a list of uagents
*/
this.buildGroupAgentList = function()
{
/* INIT */
var _output = '';
var _tplate = new Template( $('tplate_agentRow').innerHTML );
var json = IPB3UAgents.uAgentsData;
var _groups = Object.keys( json['uagents'] );
/* Clear out any current listing */
$('tplate_agentsList').update('');
/* Format... */
_groups.each( function( i )
{
if ( ! json['uagents'][i]['_used'] )
{
json['uagents'][i]['_cssClass'] = IPB3UAgents.cssNames['uagentsGRow'];
_output += _tplate.evaluate( json['uagents'][i] );
}
} );
/* Write it out */
$('tplate_agentsList').update( _output );
/* Post process */
_groups.each( function( i )
{
if ( ! json['uagents'][i]['_used'] )
{
/* Image. Can't use #{...} inline as it parses as HTML entities. Most annoying */
$('tplate_agentimg_' + json['uagents'][i]['uagent_id'] ).src += 'type_' + json['uagents'][i]['uagent_type'] + '.png';
}
} );
}
}