⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 acp_template.js

📁 sabreipb 2.1.6 utf-8中文版本!
💻 JS
📖 第 1 页 / 共 2 页
字号:
//------------------------------------------
// Invision Power Board v2.1
// ACP Specific JS File
// (c) 2005 Invision Power Services, Inc.
//
// 
//------------------------------------------

var div_template_sections;
var div_template_bits;
var div_template_edit;
var iframe_template_bits;
var iframe_template_edit;
var template_section_anim;
var template_column_anim;
var template_section_fwidth       = 50;
var template_section_fheight      = 475;
var template_section_mheight      = 250;
var template_edit_mheight         = 400;
var template_edit_mheight_mpl     = 360;
var template_edit_mheight_mpl_pad = 65;
var template_section_moved        = 0;
var template_columns_moved        = 0;
var main_height;
var template_group_loaded;
var template_search_input_obj	  = '';

var template_bit_loaded    = new Array();

var template_anim_done = 0;

var class_before      = 'tablerow1';
var class_after       = 'tablerow3';

var editor_contents   = new Array();
var editor_unload_set = 0;
var editor_form_id    = 'template-bits-form';

var iframes_loaded    = new Array();

var search_group_name;
var search_template_bit;

var ie_rs_count    = 0;
var cur_tid_loaded = 0;

var bits_clicked   = new Array();

/*-------------------------------------------------------------------------*/
// Template View Diff
/*-------------------------------------------------------------------------*/

function template_view_diff( tid )
{
	try
	{
		menu_action_close();
	}
	catch(e) { }
	
	pop_win( 'section=lookandfeel&act=skindiff&code=skin_diff_view_diff&diff_key=' + tid, 'DiffWindow'+tid.replace( /:/g, '_' ), 700, 500 );
	
	return false;
}

/*-------------------------------------------------------------------------*/
// Template INIT
/*-------------------------------------------------------------------------*/

function template_init()
{
	div_template_sections     = document.getElementById('template-sections');
	div_template_bits         = document.getElementById('template-bits');
	div_template_edit         = document.getElementById('template-edit');
	iframe_template_bits      = document.getElementById('tb-iframe');
	iframe_template_edit      = document.getElementById('te-iframe');
	template_search_input_obj = document.getElementById('entered_template');
	
	main_height = parseInt( div_template_sections.style.height );
	
	//------------------------------------------
	// Use quick search?
	//------------------------------------------
	
	if ( ! use_enhanced_js )
	{
		try
		{
			document.getElementById( 'quick-search-box' ).innerHTML = ' ';
		}
		catch(e){  }
	}
	
	//------------------------------------------
	// Add key listener to capture enter
	//------------------------------------------
	
	if ( use_enhanced_js )
	{
		try
		{
			template_search_input_obj.onkeypress = function(e)
			{
				e = e ? e : window.event;
				switch (e.keyCode)
				{
					case 13:
						template_find_bits(e);
						return false;
				}
			}
		}
		catch(e){  }
	}
	
	//------------------------------------------
	// IE FIX... grrr
	//------------------------------------------
	
	if ( is_ie )
	{
		div_template_sections.style.position = 'absolute';
		document.getElementById('template-main-wrap').style.height = parseInt( div_template_sections.style.height ) + 'px';
	}
	
	//------------------------------------------
	// Searching?
	//------------------------------------------
	
	if ( template_search )
	{
		//------------------------------------------
		// Hide rows we don't have matches for
		//------------------------------------------
		
		var groups = document.getElementsByTagName('DIV');

		for ( var i = 0 ; i <= groups.length ; i++ )
		{
			var e = groups[i];
			
			if ( e && e.id )
			{
				var id    = e.id;
				var gname = id.replace( /^dv-(.+?)$/, "$1" );
				
				if ( gname != id && ! search_template_sections[ gname ] )
				{
					e.style.display = 'none';
				}
			}
		}
		
		//------------------------------------------
		// Add in matches
		//------------------------------------------
		
		try
		{
			for ( var i in search_template_matches )
			{
				document.getElementById( 'match-'+i ).innerHTML = '(' + search_template_matches[i] + ' ' + lang_matches + ')';
			}
		}
		catch(e)
		{
		}
	}
}

/*-------------------------------------------------------------------------*/
// Onload events
/*-------------------------------------------------------------------------*/

function template_iframe_loaded( framekey )
{
	if ( framekey == 'tb' )
	{
		//------------------------------------------
		// Add onclick events to revert images
		//------------------------------------------
		
		var images = window.frames['tb-iframe'].document.getElementsByTagName('img');
		
		//----------------------------------
		// Sort through and grab topic links
		//----------------------------------
	
		for ( var i = 0 ; i <= images.length ; i++ )
		{
			try
			{
				if ( ! images[i].id )
				{
					continue;
				}
			}
			catch(e)
			{
				continue;
			}
			
			var imgid   = images[i].id;
			var imgname = imgid.replace( /^(.*)-(\d+)$/, "$1" );
			
			if ( imgname == 'img-remove' )
			{
				images[i].onclick = template_revert_clicked;
			}
		}
	}
}

/*-------------------------------------------------------------------------*/
// Find template bits
/*-------------------------------------------------------------------------*/

function template_find_bits(event)
{
	//------------------------------------------
	// INIT
	//------------------------------------------
	
	var search_box = document.getElementById( 'entered_template' );
	
	if ( ! search_box.value )
	{
		return false;
	}
	
	//------------------------------------------
	// Get template bit name and stuff
	//------------------------------------------
	
	search_group_name   = search_box.value.replace( /.*\((.+?)\)/, "$1" );
	search_template_bit = search_box.value.replace( /(.*)\(.+?\)/, "$1" );
	
	//------------------------------------------
	// Strip whitespace
	//------------------------------------------
	
	search_group_name   = search_group_name.replace( /^\s*|\s*$/g  , "" );
	search_template_bit = search_template_bit.replace( /^\s*|\s*$/g, "" );
	
	//------------------------------------------
	// Load group name
	//------------------------------------------
	
	try
	{
		if ( search_group_name )
		{
			if ( search_template_bit )
			{
				if ( is_ie )
				{
					iframe_template_bits.onreadystatechange = _template_load_editor_loader;
				}
				else
				{
					iframe_template_bits.onload = _template_load_editor_loader;
				}
			}
			
			template_load_bits( search_group_name, event, false );
			
		}
	}
	catch(e)
	{
		alert( "Could not locate a template bit called: " + search_box.value + "\nPlease search in the format:\ntemplate_name (template_group)" );
	}
}

/*-------------------------------------------------------------------------*/
// Restore template bit
/*-------------------------------------------------------------------------*/

function template_bit_restore( tid )
{
	//------------------------------------------
	// INIT
	//------------------------------------------
	
	var edit_box_obj    = window.frames['te-iframe'].document.getElementById( 't'+tid );
	var edit_box_button = window.frames['te-iframe'].document.getElementById( 'sb-t' + tid );
	
	edit_box_button.className = 'realdarkbutton';
	
	if ( editor_contents[ 't'+tid ] )
	{
		if ( confirm("Are you sure you want to restore the template?\nALL UNSAVED CHANGES WILL BE LOST!") )
		{
			edit_box_obj.value     = editor_contents[ 't'+tid ];
			editor_contents[ 't'+tid ] = '';
		}
	}
}

/*-------------------------------------------------------------------------*/
// Close down template edit screen
/*-------------------------------------------------------------------------*/

function template_edit_close( tid )
{
	//------------------------------------------
	// Check
	//------------------------------------------
	
	if ( editor_contents[ 't'+tid ] )
	{
		if ( ! confirm('WARNING: CLICK "OK" TO LOSE ANY UNSAVED CHANGES' ) )
		{
			return false;
		}
	}
	
	//------------------------------------------
	// Close
	//------------------------------------------
	
	editor_contents[ 't'+tid ]      = '';
	div_template_edit.style.display = 'none';
	iframe_template_edit.src        = 'javascript:;';
}
		
/*-------------------------------------------------------------------------*/
// Editor has changed
/*-------------------------------------------------------------------------*/

function template_bit_changed( tid )
{
	//------------------------------------------
	// Already changed?
	//------------------------------------------
	
	var edit_box_obj    = window.frames['te-iframe'].document.getElementById( tid );
	var edit_box_button = window.frames['te-iframe'].document.getElementById( 'sb-' + tid );
	
	if ( edit_box_button.className == 'realredbutton' )
	{
		return;
	}
	
	//------------------------------------------
	// Store current tid loaded
	//------------------------------------------
	
	cur_tid_loaded = tid.replace( /t(\d+)/, "$1" );
	
	//------------------------------------------
	// Change flag
	//------------------------------------------
	
	window.frames['te-iframe'].document.getElementById( 'edited-' + cur_tid_loaded ).value = 1;
	
	//------------------------------------------
	// No?
	//------------------------------------------
	
	editor_contents[ tid ] = edit_box_obj.value;
	
	edit_box_button.className = 'realredbutton';
	editor_unload_set         = 1;
	
	//------------------------------------------
	// Set onsubmit event
	//------------------------------------------
	
	window.frames['te-iframe'].document.getElementById( editor_form_id ).onsubmit = template_edit_onsubmit;
}

/*-------------------------------------------------------------------------*/
// On submit, reload to iframe
/*-------------------------------------------------------------------------*/

function template_edit_onsubmit( event )
{
	editor_unload_set = 0;

	//------------------------------------------
	// Change row image
	//------------------------------------------
	
	if ( cur_tid_loaded > 0 )
	{
		_template_change_state_image(  cur_tid_loaded, 'altered' );
		_template_change_revert_image( cur_tid_loaded, img_revert_real );
	}
	
	return true;
}
	
/*-------------------------------------------------------------------------*/
// EDITOR LOADED: On load, reload to selected bit
/*-------------------------------------------------------------------------*/

function template_bit_onload()
{
	if ( template_bit_loaded.length ) 
	{
		for ( var i in template_bit_loaded )
		{
			window.frames['tb-iframe'].document.getElementById( template_bit_loaded[i] ).className = class_after;
		}
	}

	return true;
}

/*-------------------------------------------------------------------------*/
// TEMPLATE BIT NAMES LOADED: On load chop out non search results
/*-------------------------------------------------------------------------*/

function template_bits_onload()
{
	//------------------------------------------
	// Searching?
	//------------------------------------------
	
	var maingroup = template_group_loaded.replace( /^dv-/, '' );
	
	if ( parent.template_search )
	{
		//------------------------------------------
		// Hide rows we don't have matches for
		//------------------------------------------
		
		var groups = window.frames['tb-iframe'].document.getElementsByTagName('DIV');

		for ( var i = 0 ; i <= groups.length ; i++ )
		{
			var e = groups[i];
			
			if ( e && e.id )
			{
				var id    = e.id;
				var gname = id.replace( /^dvb-(.+?)$/, "$1" );
				
				if ( gname != id && ! search_template_bits[ maingroup + '_' + gname ] )
				{
					e.style.display = 'none';
				}
			}
		}
	}
	return true;
}

/*-------------------------------------------------------------------------*/
// Onclick handler: Revert clicked
/*-------------------------------------------------------------------------*/

function template_revert_clicked(event)
{
	event = template_cancel_bubble( event, true );
		
	if ( this.id )
	{
		var clickedid = this.id.replace( /^.*-(\d+)$/, "$1" );
	}
	
	if ( clickedid )
	{
		var clicked_href = window.frames['tb-iframe'].document.getElementById('link-remove-'+clickedid).href;
		var finalhref    = clicked_href.replace( /javascript:confirm_action\('(.+?)'\)/, "$1" );
		var bitname      = clicked_href.replace( /.*bitname=(.+?)&.*/  , "$1" );
		var custombit    = clicked_href.replace( /.*custombit=(.+?)/, "$1" );
		
		if ( confirm( "WARNING: You cannot undo this action!\nPress OK to continue or CANCEL to cancel this action..." ) )
		{
			if ( use_enhanced_js && parseInt(custombit) != 1 )
			{
				/*--------------------------------------------*/
				// Main function to do on request
				// Must be defined first!!
				/*--------------------------------------------*/
				
				do_request_function = function()
				{
					//----------------------------------
					// Ignore unless we're ready to go
					//----------------------------------
					
					if ( ! xmlobj.readystate_ready_and_ok() )
					{
						return;
					}
		
					//----------------------------------
					// Change icons
					//----------------------------------
					
					_template_change_state_image(  clickedid, 'unaltered' );
					_template_change_revert_image( clickedid, img_revert_blank );
		
					//----------------------------------
					// Re-load editor frame
					//----------------------------------
					
					if ( template_bit_loaded.length ) 
					{
						for ( var i in template_bit_loaded )
						{
							if ( template_bit_loaded[i] && template_bit_loaded[i].replace('dvb-', '' ) == bitname )
							{
								 iframe_template_edit.src = iframe_template_edit.src;
							}
						}
					}
				}
				
				//----------------------------------
				// LOAD XML
				//----------------------------------
				
				xmlobj = new ajax_request();
				xmlobj.onreadystatechange( do_request_function );
	
				xmlobj.process( finalhref.replace( /type=frame/, 'type=xml' ) );
			}
			else
			{
				iframe_template_bits.src = finalhref;
			}
		}
	}
	
	return false;
}

/*-------------------------------------------------------------------------*/

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -