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

📄 vbulletin_global.js

📁 这是从网上下载下来的一个计算程序
💻 JS
📖 第 1 页 / 共 3 页
字号:
			var code = matches[matchid].substring(1,3);			if (parseInt(code, 16) >= 128)			{				text = text.replace(matches[matchid], '%u00' + code);			}		}	}	// %25 gets translated to % by PHP, so if you have %25u1234,	// we see it as %u1234 and it gets translated. So make it %u0025u1234,	// which will print as %u1234!	text = text.replace('%25', '%u0025');	return text;}/*** Works a bit like ucfirst, but with some extra options** @param	string	String with which to work* @param	string	Cut off string before first occurence of this string** @return	string*/vB_PHP_Emulator.prototype.ucfirst = function(str, cutoff){	if (typeof cutoff != 'undefined')	{		var cutpos = str.indexOf(cutoff);		if (cutpos > 0)		{			str = str.substr(0, cutpos);		}	}	str = str.split(' ');	for (var i = 0; i < str.length; i++)	{		str[i] = str[i].substr(0, 1).toUpperCase() + str[i].substr(1);	}	return str.join(' ');}// initialize the PHP emulatorvar PHP = new vB_PHP_Emulator();// #############################################################################// vB_AJAX_Handler// #############################################################################/*** XML Sender Class** @param	boolean	Should connections be asyncronous?*/function vB_AJAX_Handler(async){	/**	* Should connections be asynchronous?	*	* @var	boolean	*/	this.async = async ? true : false;}// =============================================================================// vB_AJAX_Handler methods/*** Initializes the XML handler** @return	boolean	True if handler created OK*/vB_AJAX_Handler.prototype.init = function(){	if (typeof vb_disable_ajax != 'undefined' && vb_disable_ajax == 2)	{		// disable all ajax features		return false;	}	try	{		this.handler = new XMLHttpRequest();		return (this.handler.setRequestHeader ? true : false);	}	catch(e)	{		try		{			this.handler = eval("new A" + "ctiv" + "eX" + "Ob" + "ject('Micr" + "osoft.XM" + "LHTTP');");			return true;		}		catch(e)		{			return false;		}	}}/*** Detects if the browser is fully compatible** @return	boolean*/vB_AJAX_Handler.prototype.is_compatible = function(){	if (typeof vb_disable_ajax != 'undefined' && vb_disable_ajax == 2)	{		// disable all ajax features		return false;	}	if (is_ie && !is_ie4) { return true; }	else if (typeof XMLHttpRequest != 'undefined')	{		try { return XMLHttpRequest.prototype.setRequestHeader ? true : false; }		catch(e)		{			try { var tester = new XMLHttpRequest(); return tester.setRequestHeader ? true : false; }			catch(e) { return false; }		}	}	else { return false; }}/*** Checks if the system is ready** @return	boolean	False if ready*/vB_AJAX_Handler.prototype.not_ready = function(){	return (this.handler.readyState && (this.handler.readyState < 4));}/*** OnReadyStateChange event handler** @param	function*/vB_AJAX_Handler.prototype.onreadystatechange = function(event){	if (!this.handler)	{		if  (!this.init())		{			return false;		}	}	if (typeof event == 'function')	{		this.handler.onreadystatechange = event;	}	else	{		alert('XML Sender OnReadyState event is not a function');	}	return false;}/*** Sends data** @param	string	Destination URL* @param	string	Request Data** @return	mixed	Return message*/vB_AJAX_Handler.prototype.send = function(desturl, datastream){	if (!this.handler)	{		if (!this.init())		{			return false;		}	}	if (!this.not_ready())	{		this.handler.open('POST', desturl, this.async);		this.handler.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');		this.handler.send(datastream + '&s=' + fetch_sessionhash());		if (!this.async && this.handler.readyState == 4 && this.handler.status == 200)		{			return true;		}	}	return false;}/*** Fetches the contents of an XML node** @param	object	XML node** @return	string	XML node contents*/vB_AJAX_Handler.prototype.fetch_data = function(xml_node){	if (xml_node && xml_node.firstChild && xml_node.firstChild.nodeValue)	{		return PHP.unescape_cdata(xml_node.firstChild.nodeValue);	}	else	{		return '';	}}// we can check this variable to see if browser is AJAX compatiblevar AJAX_Compatible = vB_AJAX_Handler.prototype.is_compatible();// #############################################################################// vB_Hidden_Form// #############################################################################/*** Form Generator Class** Builds a form filled with hidden fields for invisible submit via POST** @param	string	Script (my_target_script.php)*/function vB_Hidden_Form(script){	this.action = script;	this.variables = new Array();}// =============================================================================// vB_Hidden_Form methods/*** Adds a hidden input field to the form object** @param	string	Name attribute* @param	string	Value attribute*/vB_Hidden_Form.prototype.add_variable = function(name, value){	this.variables[this.variables.length] = new Array(name, value);};/*** Fetches all form elements inside an HTML element and performs 'add_input()' on them** @param	object	HTML element to search*/vB_Hidden_Form.prototype.add_variables_from_object = function(obj){	var inputs = fetch_tags(obj, 'input');	for (var i = 0; i < inputs.length; i++)	{		switch (inputs[i].type)		{			case 'checkbox':			case 'radio':				if (inputs[i].checked)				{					this.add_variable(inputs[i].name, inputs[i].value);				}				break;			case 'text':			case 'hidden':			case 'password':				this.add_variable(inputs[i].name, inputs[i].value);				break;			default:				continue;		}	}	var textareas = fetch_tags(obj, 'textarea');	for (var i = 0; i < textareas.length; i++)	{		this.add_variable(textareas[i].name, textareas[i].value);	}	var selects = fetch_tags(obj, 'select');	for (var i = 0; i < selects.length; i++)	{		if (selects[i].multiple)		{			for (var j = 0; j < selects[i].options.length; j++)			{				if (selects[i].options[j].selected)				{					this.add_variable(selects[i].name, selects[i].options[j].value);				}			}		}		else		{			this.add_variable(selects[i].name, selects[i].options[selects[i].selectedIndex].value);		}	}};/*** Fetches a variable value** @param	string	Variable name** @return	mixed	Variable value*/vB_Hidden_Form.prototype.fetch_variable = function(varname){	for (var i = 0; i < this.variables.length; i++)	{		if (this.variables[i][0] == varname)		{			return this.variables[i][1];		}	}	return null;};/*** Submits the hidden form object*/vB_Hidden_Form.prototype.submit_form = function(){	this.form = document.createElement('form');	this.form.method = 'post';	this.form.action = this.action;	for (var i = 0; i < this.variables.length; i++)	{		var inputobj = document.createElement('input');		inputobj.type  = 'hidden';		inputobj.name  = this.variables[i][0];		inputobj.value = this.variables[i][1];		this.form.appendChild(inputobj);	}	document.body.appendChild(this.form).submit();};/*** Builds a URI query string from the given variables*/vB_Hidden_Form.prototype.build_query_string = function(){	var query_string = '';	for (var i = 0; i < this.variables.length; i++)	{		query_string += this.variables[i][0] + '=' + PHP.urlencode(this.variables[i][1]) + '&';	}	return query_string;}/*** Legacy functions for backward compatability*/vB_Hidden_Form.prototype.add_input = vB_Hidden_Form.prototype.add_variable;vB_Hidden_Form.prototype.add_inputs_from_object = vB_Hidden_Form.prototype.add_variables_from_object;// #############################################################################// Window openers and instant messenger wrappers/*** Opens a generic browser window** @param	string	URL* @param	integer	Width* @param	integer	Height* @param	string	Optional Window ID*/function openWindow(url, width, height, windowid){	return window.open(		url,		(typeof windowid == 'undefined' ? 'vBPopup' : windowid),		'statusbar=no,menubar=no,toolbar=no,scrollbars=yes,resizable=yes'		+ (typeof width != 'undefined' ? (',width=' + width) : '') + (typeof height != 'undefined' ? (',height=' + height) : '')	);}/*** Opens control panel help window** @param	string	Script name* @param	string	Action type* @param	string	Option value** @return	window*/function js_open_help(scriptname, actiontype, optionval){	return openWindow(		'help.php?s=' + SESSIONHASH + '&do=answer&page=' + scriptname + '&pageaction=' + actiontype + '&option=' + optionval,		600, 450, 'helpwindow'	);}/*** Opens a window to show a list of attachments in a thread (misc.php?do=showattachments)** @param	integer	Thread ID** @return	window*/function attachments(threadid){	return openWindow(		'misc.php?' + SESSIONURL + 'do=showattachments&t=' + threadid,		480, 300	);}/*** Opens a window to show a list of posters in a thread (misc.php?do=whoposted)** @param	integer	Thread ID** @return	window*/function who(threadid){	return openWindow(		'misc.php?' + SESSIONURL + 'do=whoposted&t=' + threadid,		230, 300	);}/*** Opens an IM Window** @param	string	IM type* @param	integer	User ID* @param	integer	Width of window* @param	integer	Height of window** @return	window*/function imwindow(imtype, userid, width, height){	return openWindow(		'sendmessage.php?' + SESSIONURL + 'do=im&type=' + imtype + '&u=' + userid,		width, height	);}/*** Sends an MSN message** @param	string	Target MSN handle** @return	boolean	false*/function SendMSNMessage(name){	if (!is_ie)	{		alert(vbphrase['msn_functions_only_work_in_ie']);		return false;	}	else	{		MsgrObj.InstantMessage(name);		return false;	}}/*** Adds an MSN Contact (requires MSN)** @param	string	MSN handle** @return	boolean	false*/function AddMSNContact(name){	if (!is_ie)	{		alert(vbphrase['msn_functions_only_work_in_ie']);		return false;	}	else	{		MsgrObj.AddContact(0, name);		return false;	}}/*** Detects Caps-Lock when a key is pressed** @param	event** @return	boolean	True if Caps-Lock is on*/function detect_caps_lock(e){	e = (e ? e : window.event);	var keycode = (e.which ? e.which : (e.keyCode ? e.keyCode : (e.charCode ? e.charCode : 0)));	var shifted = (e.shiftKey || (e.modifiers && (e.modifiers & 4)));	var ctrled = (e.ctrlKey || (e.modifiers && (e.modifiers & 2)));	// if characters are uppercase without shift, or lowercase with shift, caps-lock is on.	return (keycode >= 65 && keycode <= 90 && !shifted && !ctrled) || (keycode >= 97 && keycode <= 122 && shifted);}/*** Confirms log-out request** @param	string	Log-out confirmation message** @return	boolean*/function log_out(confirmation_message){	var ht = document.getElementsByTagName("html")[0];	ht.style.filter = "progid:DXImageTransform.Microsoft.BasicImage(grayscale=1)";	if (confirm(confirmation_message))	{		return true;	}	else	{		ht.style.filter = "";		return false;	}}// #############################################################################// Cookie handlers/*** Sets a cookie** @param	string	Cookie name* @param	string	Cookie value* @param	date	Cookie expiry date*/function set_cookie(name, value, expires){	document.cookie = name + '=' + escape(value) + '; path=/' + (typeof expires != 'undefined' ? '; expires=' + expires.toGMTString() : '');}/*** Deletes a cookie** @param	string	Cookie name*/function delete_cookie(name){	document.cookie = name + '=' + '; expires=Thu, 01-Jan-70 00:00:01 GMT' +  '; path=/';}/*** Fetches the value of a cookie** @param	string	Cookie name** @return	string*/function fetch_cookie(name){	cookie_name = name + '=';	cookie_length = document.cookie.length;	cookie_begin = 0;	while (cookie_begin < cookie_length)	{		value_begin = cookie_begin + cookie_name.length;		if (document.cookie.substring(cookie_begin, value_begin) == cookie_name)		{			var value_end = document.cookie.indexOf (';', value_begin);			if (value_end == -1)			{				value_end = cookie_length;			}			return unescape(document.cookie.substring(value_begin, value_end));		}		cookie_begin = document.cookie.indexOf(' ', cookie_begin) + 1;		if (cookie_begin == 0)		{			break;		}	}	return null;}// #############################################################################// Form element managers (used for 'check all' type systems/*** Sets all checkboxes, radio buttons or selects in a given form to a given state, with exceptions** @param	object	Form object* @param	string	Target element type (one of 'radio', 'select-one', 'checkbox')* @param	string	Selected option in case of 'radio'* @param	array	Array of element names to be excluded* @param	mixed	Value to give to found elements*/function js_toggle_all(formobj, formtype, option, exclude, setto){	for (var i =0; i < formobj.elements.length; i++)	{		var elm = formobj.elements[i];		if (elm.type == formtype && PHP.in_array(elm.name, exclude, false) == -1)		{			switch (formtype)			{				case 'radio':					if (elm.value == option) // option == '' evaluates true when option = 0					{						elm.checked = setto;					}				break;				case 'select-one':					elm.selectedIndex = setto;				break;				default:					elm.checked = setto;				break;			}		}	}}/*** Sets all <select> elements to the selectedIndex specified by the 'selectall' element** @param	object	Form object*/function js_select_all(formobj){	exclude = new Array();	exclude[0] = 'selectall';	js_toggle_all(formobj, 'select-one', '', exclude, formobj.selectall.selectedIndex);}/**

⌨️ 快捷键说明

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