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

📄 vbulletin_global.js

📁 这是从网上下载下来的一个计算程序
💻 JS
📖 第 1 页 / 共 3 页
字号:
* Sets all <input type="checkbox" /> elements to have the same checked status as 'allbox'** @param	object	Form object*/function js_check_all(formobj){	exclude = new Array();	exclude[0] = 'keepattachments';	exclude[1] = 'allbox';	exclude[2] = 'removeall';	js_toggle_all(formobj, 'checkbox', '', exclude, formobj.allbox.checked);}/*** Sets all <input type="radio" /> groups to have a particular option checked** @param	object	Form object* @param	mixed	Selected option*/function js_check_all_option(formobj, option){	exclude = new Array();	exclude[0] = 'useusergroup';	js_toggle_all(formobj, 'radio', option, exclude, true);}/*** Alias to js_check_all*/function checkall(formobj) { js_check_all(formobj); }/*** Alias to js_check_all_option*/function checkall_option(formobj, option) { js_check_all_option(formobj, option); }/*** Resize function for CP textareas** @param	integer	If positive, size up, otherwise size down* @param	string	ID of the textarea** @return	boolean	false*/function resize_textarea(to, id){	if (to < 0)	{		var rows = -5;		var cols = -10;	}	else	{		var rows = 5;		var cols = 10;	}	var textarea = fetch_object(id);	if (typeof textarea.orig_rows == 'undefined')	{		textarea.orig_rows = textarea.rows;		textarea.orig_cols = textarea.cols;	}	var newrows = textarea.rows + rows;	var newcols = textarea.cols + cols;	if (newrows >= textarea.orig_rows && newcols >= textarea.orig_cols)	{		textarea.rows = newrows;		textarea.cols = newcols;	}	return false;}// #############################################################################// Collapsible element handlers/*** Toggles the collapse state of an object, and saves state to 'vbulletin_collapse' cookie** @param	string	Unique ID for the collapse group** @return	boolean	false*/function toggle_collapse(objid){	if (!is_regexp)	{		return false;	}	obj = fetch_object('collapseobj_' + objid);	img = fetch_object('collapseimg_' + objid);	cel = fetch_object('collapsecel_' + objid);	if (!obj)	{		// nothing to collapse!		if (img)		{			// hide the clicky image if there is one			img.style.display = 'none';		}		return false;	}	if (obj.style.display == 'none')	{		obj.style.display = '';		save_collapsed(objid, false);		if (img)		{			img_re = new RegExp("_collapsed\\.gif$");			img.src = img.src.replace(img_re, '.gif');		}		if (cel)		{			cel_re = new RegExp("^(thead|tcat)(_collapsed)$");			cel.className = cel.className.replace(cel_re, '$1');		}	}	else	{		obj.style.display = 'none';		save_collapsed(objid, true);		if (img)		{			img_re = new RegExp("\\.gif$");			img.src = img.src.replace(img_re, '_collapsed.gif');		}		if (cel)		{			cel_re = new RegExp("^(thead|tcat)$");			cel.className = cel.className.replace(cel_re, '$1_collapsed');		}	}	return false;}/*** Updates vbulletin_collapse cookie with collapse preferences** @param	string	Unique ID for the collapse group* @param	boolean	Add a cookie*/function save_collapsed(objid, addcollapsed){	var collapsed = fetch_cookie('vbulletin_collapse');	var tmp = new Array();	if (collapsed != null)	{		collapsed = collapsed.split('\n');		for (var i in collapsed)		{			if (collapsed[i] != objid && collapsed[i] != '')			{				tmp[tmp.length] = collapsed[i];			}		}	}	if (addcollapsed)	{		tmp[tmp.length] = objid;	}	expires = new Date();	expires.setTime(expires.getTime() + (1000 * 86400 * 365));	set_cookie('vbulletin_collapse', tmp.join('\n'), expires);}// #############################################################################// Event Handlers for PageNav menus/*** Class to handle pagenav events*/function vBpagenav(){}/*** Handles clicks on pagenav menu control objects*/vBpagenav.prototype.controlobj_onclick = function(e){	this._onclick(e);	var inputs = fetch_tags(this.menu.menuobj, 'input');	for (var i = 0; i < inputs.length; i++)	{		if (inputs[i].type == 'text')		{			inputs[i].focus();			break;		}	}};/*** Submits the pagenav form... sort of*/vBpagenav.prototype.form_gotopage = function(e){	if ((pagenum = parseInt(fetch_object('pagenav_itxt').value, 10)) > 0)	{		window.location = this.addr + '&page=' + pagenum;	}	return false;};/*** Handles clicks on the 'Go' button in pagenav popups*/vBpagenav.prototype.ibtn_onclick = function(e){	return this.form.gotopage();};/*** Handles keypresses in the text input of pagenav popups*/vBpagenav.prototype.itxt_onkeypress = function(e){	return ((e ? e : window.event).keyCode == 13 ? this.form.gotopage() : true);};// #############################################################################// DHTML Popup Menu Handling (complements vbulletin_menu.js)/*** Wrapper for vBmenu.register** @param	string	Control ID* @param	boolean	No image (true)* @param	boolean	Does nothing any more*/function vbmenu_register(controlid, noimage, datefield){	if (typeof(vBmenu) == "object")	{		return vBmenu.register(controlid, noimage);	}	else	{		return false;	}}// #############################################################################// Stuff that really doesn't fit anywhere else/*** Sets an element and all its children to be 'unselectable'** @param	object	Object to be made unselectable*/function set_unselectable(obj){	if (!is_ie4 && typeof obj.tagName != 'undefined')	{		if (obj.hasChildNodes())		{			for (var i = 0; i < obj.childNodes.length; i++)			{				set_unselectable(obj.childNodes[i]);			}		}		obj.unselectable = 'on';	}}/*** Fetches the sessionhash from the SESSIONURL variable** @return	string*/function fetch_sessionhash(){	return (SESSIONURL == '' ? '' : SESSIONURL.substr(2, 32));}/*** Emulates the PHP version of vBulletin's construct_phrase() sprintf wrapper** @param	string	String containing %1$s type replacement markers* @param	string	First replacement* @param	string	Nth replacement** @return	string*/function construct_phrase(){	if (!arguments || arguments.length < 1 || !is_regexp)	{		return false;	}	var args = arguments;	var str = args[0];	var re;	for (var i = 1; i < args.length; i++)	{		re = new RegExp("%" + i + "\\$s", 'gi');		str = str.replace(re, args[i]);	}	return str;}/*** Handles the quick style/language options in the footer** @param	object	Select object* @param	string	Type (style or language)*/function switch_id(selectobj, type){	var id = selectobj.options[selectobj.selectedIndex].value;	if (id == '')	{		return;	}	var url = new String(window.location);	var fragment = new String('');	// get rid of fragment	url = url.split('#');	// deal with the fragment first	if (url[1])	{		fragment = '#' + url[1];	}	// deal with the main url	url = url[0];	// remove id=x& from main bit	if (url.indexOf(type + 'id=') != -1 && is_regexp)	{		re = new RegExp(type + "id=\\d+&?");		url = url.replace(re, '');	}	// add the ? to the url if needed	if (url.indexOf('?') == -1)	{		url += '?';	}	else	{		// make sure that we have a valid character to join our id bit		lastchar = url.substr(url.length - 1);		if (lastchar != '&' && lastchar != '?')		{			url += '&';		}	}	window.location = url + type + 'id=' + id + fragment;}/*** Takes the 'alt' attribute for an image and attaches it to the 'title' attribute** @param	object	Image object*/function img_alt_2_title(img){	if (!img.title && img.alt != '')	{		img.title = img.alt;	}}// #############################################################################// Initialize a PostBit/*** This function runs all the necessary Javascript code on a PostBit* after it has been loaded via AJAX. Don't use this method before a* complete page load or you'll have problems.** @param	object	Object containing postbits*/function PostBit_Init(obj, postid){	if (typeof vBmenu != 'undefined')	{		// init profile menu(s)		var divs = fetch_tags(obj, 'div');		for (var i = 0; i < divs.length; i++)		{			if (divs[i].id && divs[i].id.substr(0, 9) == 'postmenu_')			{				vBmenu.register(divs[i].id, true);			}		}	}	if (typeof vB_QuickEditor != 'undefined')	{		// init quick edit controls		vB_AJAX_QuickEdit_Init(obj);	}	if (typeof vB_QuickReply != 'undefined')	{		// init quick reply button		qr_init_buttons(obj);	}	if (typeof mq_init != 'undefined')	{		// init quick reply button		mq_init(obj);	}	if (typeof vBrep != 'undefined')	{		if (typeof postid != 'undefined' && typeof postid != 'null')		{			vbrep_register(postid);		}	}	if (typeof inlineMod != 'undefined')	{		im_init(obj);	}}// #############################################################################// Main vBulletin Javascript Initialization/*** This function runs (almost) at the end of script loading on most vBulletin pages** It sets up things like image alt->title tags, turns on the popup menu system etc.** @return	boolean*/function vBulletin_init(){	// don't bother doing any exciting stuff for WebTV	if (is_webtv)	{		return false;	}	// set 'title' tags for image elements	var imgs = fetch_tags(document, 'img');	for (var i = 0; i < imgs.length; i++)	{		img_alt_2_title(imgs[i]);	}	// finalize popup menus	if (typeof vBmenu == 'object')	{		// close all menus on document click or resize		if (typeof(YAHOO) != "undefined")		{			YAHOO.util.Event.on(document, "click", vbmenu_hide);			YAHOO.util.Event.on(window, "resize", vbmenu_hide);		}		else if (window.attachEvent && !is_saf)		{			document.attachEvent('onclick', vbmenu_hide);			window.attachEvent('onresize', vbmenu_hide);		}		else if (document.addEventListener && !is_saf)		{			document.addEventListener('click', vbmenu_hide, false);			window.addEventListener('resize', vbmenu_hide, false);		}		else		{			window.onclick = vbmenu_hide;			window.onresize = vbmenu_hide;		}		// add popups to pagenav elements		var pagenavs = fetch_tags(document, 'td');		for (var n = 0; n < pagenavs.length; n++)		{			if (pagenavs[n].hasChildNodes() && pagenavs[n].firstChild.name && pagenavs[n].firstChild.name.indexOf('PageNav') != -1)			{				var addr = pagenavs[n].title;				pagenavs[n].title = '';				pagenavs[n].innerHTML = '';				pagenavs[n].id = 'pagenav.' + n;				var pn = vBmenu.register(pagenavs[n].id);				if (is_saf)				{					pn.controlobj._onclick = pn.controlobj.onclick;					pn.controlobj.onclick = vBpagenav.prototype.controlobj_onclick;				}			}		}		// process the pagenavs popup form		if (typeof addr != 'undefined')		{			fetch_object('pagenav_form').addr = addr;			fetch_object('pagenav_form').gotopage = vBpagenav.prototype.form_gotopage;			fetch_object('pagenav_ibtn').onclick = vBpagenav.prototype.ibtn_onclick;			fetch_object('pagenav_itxt').onkeypress = vBpagenav.prototype.itxt_onkeypress;		}		// activate the menu system		vBmenu.activate(true);	}	// the new init system	vBulletin.init();	return true;}// #############################################################################// deal with Firebug console callsif (!console){	var console = function() { var moo = 1 + 1; };	console.log = function(str) { var moo = 1 + 1; };}// #############################################################################function vBulletin_Framework(){	this.elements = new Array();	this.ajaxurls = new Array();	this.events = new Array();	this.regexp = "(^|[^a-z0-9_])([a-z0-9_]+)\\[([^\\]]*)\\]";	this.add_event("systemInit");	this.time = new Date();}vBulletin_Framework.prototype.init = function(){	this.find_elements(document.getElementsByTagName("body")[0]);	this.events.systemInit.fire();}vBulletin_Framework.prototype.extend = function(subClass, baseClass){   function inheritance() {}   inheritance.prototype = baseClass.prototype;   subClass.prototype = new inheritance();   subClass.prototype.constructor = subClass;   subClass.baseConstructor = baseClass;   subClass.superClass = baseClass.prototype;}vBulletin_Framework.prototype.find_elements = function(parent){	for (var i = 0; i < parent.childNodes.length; i++)	{		var element = parent.childNodes[i];		if (element.className)		{			var classmatch = PHP.match_all(element.className, this.regexp);			if (classmatch)			{				this.register_element(element, classmatch);			}		}		if (parent.childNodes[i].hasChildNodes())		{			this.find_elements(parent.childNodes[i]);		}	}}vBulletin_Framework.prototype.register_element = function(element, classmatch){	for (var i = 0; i < classmatch.length; i++)	{		if (!this.elements[classmatch[i][2]])		{			this.elements[classmatch[i][2]] = new Array();		}		this.elements[classmatch[i][2]][this.elements[classmatch[i][2]].length] = new Array(element, classmatch[i][3]);	}}vBulletin_Framework.prototype.register_ajax_urls = function(fetch, save, elements){	var fetch = fetch.split("?"); fetch[1] = SESSIONURL + "ajax=1&" + fetch[1].replace(/\{(\d+)(:\w+)?\}/gi, '%$1$s');	var save  =  save.split("?");  save[1] = SESSIONURL + "ajax=1&" + save[1].replace(/\{(\d+)(:\w+)?\}/gi, '%$1$s');	for (var i = 0; i < elements.length; i++)	{		this.ajaxurls[elements[i]] = new Array(fetch, save);	}}vBulletin_Framework.prototype.add_event = function(eventname){	this.events[eventname] = (typeof YAHOO != 'undefined' ? new YAHOO.util.CustomEvent(eventname) : new null_event());}vBulletin_Framework.prototype.console = function(){	if (is_moz && console)	{		var args = new Array();		for (var i = 0; i < arguments.length; i++)		{			args[args.length] = arguments[i];		}		try		{			eval("console.log('" + args.join("','") + "');");		}		catch(e) {}	}}if (typeof YAHOO == 'undefined'){	function null_event()	{		this.fire = function() {};		this.subscribe = function() {};	};}vBulletin = new vBulletin_Framework();

⌨️ 快捷键说明

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