script.js.php

来自「最近在做软交换时研究的一个软交换的东东」· PHP 代码 · 共 577 行 · 第 1/2 页

PHP
577
字号
<?phpheader ("Content-type: application/x-javascript");if (!extension_loaded('gettext')) {       function _($str) {               return $str;       }} else {    if (isset($_COOKIE['lang'])) {    	setlocale(LC_MESSAGES,  $_COOKIE['lang']);    } else {     	setlocale(LC_MESSAGES,  'en_US');    }    bindtextdomain('amp','../i18n');    textdomain('amp');}?>// ***************************************************// ** Client-side Browser Detection                 **// ***************************************************Is_DOM = (document.getElementById) ? true : false;Is_NS4 = (document.layers) ? true : false;Is_IE = (document.all) ? true : false;// detect for konqueror, taken from// http://www.javascript-source.com/var detect = navigator.userAgent.toLowerCase();if (checkIt('konqueror'))        Is_IE = false;function checkIt(string){	place = detect.indexOf(string) + 1;	thestring = string;	return place;}Is_IE4 = Is_IE && !Is_DOM;Is_Mac = (navigator.appVersion.indexOf("Mac") != -1);Is_IE4M = Is_IE4 && Is_Mac;// ***************************************************// ** Client-side library functions                     **// ***************************************************function decision(message, url) {	if (confirm(message))		location.href = url;}//this will hide or show all the <select> elements on a pagefunction hideSelects(b){      var allelems = document.all.tags('SELECT');      if (allelems != null)      {              var i;              for (i = 0; i < allelems.length; i++)                      allelems[i].style.visibility = (b ? 'hidden' : 'inherit');      }}// these two 'do' functions are needed to assign to the onmouse eventsfunction doHideSelects(event){      hideSelects(true);}function doShowSelects(event){      hideSelects(false);}// this will setup all the 'A' tags on a page, with the 'info' class, with the// above functionsfunction setAllInfoToHideSelects(){      if (Is_IE)      {              var allelems = document.all.tags('A');              if (allelems != null)              {                      var i, elem;                      for (i = 0; elem = allelems[i]; i++)                      {                              if (elem.className=='info' && elem.onmouseover == null && elem.onmouseout == null)                              {                                      elem.onmouseover = doHideSelects;                                      elem.onmouseout = doShowSelects;                              }                      }              }      }}//call this function from forms that include module destinations//numForms is the number of destination forms to process (usually 1)function setDestinations(theForm,numForms) {	for (var formNum = 0; formNum < numForms; formNum++) {		var whichitem = 0;		while (whichitem < theForm['goto_indicate'+formNum].length) {			if (theForm['goto_indicate'+formNum][whichitem].checked) {				theForm['goto'+formNum].value=theForm['goto_indicate'+formNum][whichitem].value;			}			whichitem++;		}	}}// ***************************************************// ** CLIENT-SIDE FORM VALIDATION FUNCTIONS         **// ***************************************************// Defaults and Consts for validation functionsvar whitespace = " \t\n\r";var decimalPointDelimiter = ".";var defaultEmptyOK = false;//call this function to validate all your destinations//numForms is the number of destinatino forms to process (usually 1)//bRequired true|false if user must select somethingfunction validateDestinations(theForm,numForms,bRequired) {	var valid = true;	for (var formNum = 0; formNum < numForms && valid == true; formNum++) {		valid = validateSingleDestination(theForm,formNum,bRequired);	}		return valid;}//this is called from validateDestinations to check each set//you can call this directly if you have multiple sets and only//require one to be selected, for example.//formNum is the set number (0 indexed)//bRequired true|false if user must select somethingfunction validateSingleDestination(theForm,formNum,bRequired) {	var gotoType = theForm.elements[ 'goto'+formNum ].value;		if (bRequired && gotoType == '') {		alert('<?php echo _("Please select a \"Destination\""); ?>');		return false;	} else {		// check the 'custom' goto, if selected		if (gotoType == 'custom') {			var gotoFld = theForm.elements[ 'custom'+formNum ];			var gotoVal = gotoFld.value;			if (gotoVal.indexOf('custom-') == -1) {				alert('<?php echo _("Custom Goto contexts must contain the string \"custom-\".  ie: custom-app,s,1"); ?>');				gotoFld.focus();				return false;			}		}	}		return true;}// this will display a message, select the content of the relevent field and// then set the focus to that field.  finally return FALSE to the 'onsubmit' event// NOTE: <select> boxes do not support the .select method, therefore you cannot// use this function on any <select> elementsfunction warnInvalid (theField, s) {    theField.focus();    theField.select();    alert(s);    return false;}// ***************************************************// ** Checks for a valid Email address              **// ***************************************************function isEmail (s) {	if (isEmpty(s))        if (isEmail.arguments.length == 1) return defaultEmptyOK;       else return (isEmail.arguments[1] == true);    if (isWhitespace(s)) return false;    var i = 1;    var sLength = s.length;    // look for @    while ((i < sLength) && (s.charAt(i) != "@")) {		i++;    }    if ((i >= sLength) || (s.charAt(i) != "@")) return false;    else i += 2;    // look for .    while ((i < sLength) && (s.charAt(i) != ".")) {		i++;    }	if ((i >= sLength - 1) || (s.charAt(i) != ".")) return false;    else return true;}// ***************************************************// ** String must contain Alphabetic letters ONLY   **// ***************************************************function isAlphabetic (s) {	var i;    if (isEmpty(s))        if (isAlphabetic.arguments.length == 1) return defaultEmptyOK;       else return (isAlphabetic.arguments[1] == true);    for (i = 0; i < s.length; i++) {           var c = s.charAt(i);        if (!isLetter(c))        return false;    }    return true;}// ***************************************************// ** String must be letters and numbers ONLY       **// ***************************************************function isAlphanumeric (s) {	var i;    if (isEmpty(s))        if (isAlphanumeric.arguments.length == 1) return defaultEmptyOK;       else return (isAlphanumeric.arguments[1] == true);    for (i = 0; i < s.length; i++) {           var c = s.charAt(i);        if (! (isLetter(c) || isDigit(c) ) )        return false;    }    return true;}// ***************************************************// ** Is Whole Number ?                             **// ***************************************************function isInteger (s) {    var i;    if (isEmpty(s))        if (isInteger.arguments.length == 1) return defaultEmptyOK;       else return (isInteger.arguments[1] == true);    for (i = 0; i < s.length; i++)    {           var c = s.charAt(i);        if (!isDigit(c)) return false;    }    return true;}// ***************************************************// ** Is Floating-point Number ?                    **// ***************************************************function isFloat (s) {	var i;    var seenDecimalPoint = false;    if (isEmpty(s))        if (isFloat.arguments.length == 1) return defaultEmptyOK;       else return (isFloat.arguments[1] == true);    if (s == decimalPointDelimiter) return false;    for (i = 0; i < s.length; i++) {           var c = s.charAt(i);        if ((c == decimalPointDelimiter) && !seenDecimalPoint) seenDecimalPoint = true;        else if (!isDigit(c)) return false;    }    return true;}// ***************************************************// ** General number check                          **// ***************************************************

⌨️ 快捷键说明

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