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

📄 sugar_3.js

📁 SugarCRM5.1 开源PHP客户关系管理系统
💻 JS
📖 第 1 页 / 共 5 页
字号:
/** * Javascript file for Sugar * * SugarCRM is a customer relationship management program developed by * SugarCRM, Inc. Copyright (C) 2004 - 2007 SugarCRM Inc. *  * This program is free software; you can redistribute it and/or modify it under * the terms of the GNU General Public License version 3 as published by the * Free Software Foundation with the addition of the following permission added * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK * IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY * OF NON INFRINGEMENT OF THIRD PARTY RIGHTS. *  * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more * details. *  * You should have received a copy of the GNU General Public License along with * this program; if not, see http://www.gnu.org/licenses or write to the Free * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA * 02110-1301 USA. *  * You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road, * SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com. *  * The interactive user interfaces in modified source and object code versions * of this program must display Appropriate Legal Notices, as required under * Section 5 of the GNU General Public License version 3. *  * In accordance with Section 7(b) of the GNU General Public License version 3, * these Appropriate Legal Notices must retain the display of the "Powered by * SugarCRM" logo. If the display of the logo is not reasonably feasible for * technical reasons, the Appropriate Legal Notices must display the words * "Powered by SugarCRM". *//** * Namespace for Sugar Objects */if(typeof(SUGAR) == "undefined"){var SUGAR = {};SUGAR.themes = {};}    	/**    	 * Namespace for Homepage    	 */    	 SUGAR.sugarHome= {};    	/**    	 * Namespace for Subpanel Utils    	 */    	SUGAR.subpanelUtils= {};    	/**    	 * AJAX status class    	 */    	SUGAR.ajaxStatusClass= {};    	/**    	 * Tab selector utils    	 */    	SUGAR.tabChooser= {};    	/**    	 * General namespace for Sugar utils    	 */    	SUGAR.util= {};    	SUGAR.savedViews= {};    	/**    	 * Dashlet utils    	 */    	SUGAR.dashlets= {};    	SUGAR.unifiedSearchAdvanced= {};    	SUGAR.searchForm= {};    	SUGAR.language= {};    	SUGAR.Studio= {};    	SUGAR.contextMenu= {};/** * DHTML date validation script. Courtesy of SmartWebby.com (http://www.smartwebby.com/dhtml/) * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc. * All Rights Reserved. * Contributor(s): ______________________________________.. */// Declaring valid date character, minimum year and maximum yearvar dtCh= "-";var minYear=1900;var maxYear=2100;var nameIndex = 0;var typeIndex = 1;var requiredIndex = 2;var msgIndex = 3;var jstypeIndex = 5;var minIndex = 10;var maxIndex = 11;var compareToIndex = 7;var arrIndex = 12;var operatorIndex = 13;var allowblank = 8;var validate = new Array();var maxHours = 24;var requiredTxt = 'Missing Required Field:'var invalidTxt = 'Invalid Value:'var secondsSinceLoad = 0;var inputsWithErrors = new Array();var lastSubmitTime = 0;var alertList = new Array();var oldStartsWith = '';function isSupportedIE() {	var userAgent = navigator.userAgent.toLowerCase() ;	// IE Check supports ActiveX controls	if (userAgent.indexOf("msie") != -1 && userAgent.indexOf("mac") == -1 && userAgent.indexOf("opera") == -1) {		var version = navigator.appVersion.match(/MSIE (.\..)/)[1] ;		if(version >= 5.5 ) {			return true;		} else {			return false;		}	}}var isIE = isSupportedIE();// escapes regular expression charactersRegExp.escape = function(text) { // http://simon.incutio.com/archive/2006/01/20/escape  if (!arguments.callee.sRE) {    var specials = ['/', '.', '*', '+', '?', '|','(', ')', '[', ']', '{', '}', '\\'];    arguments.callee.sRE = new RegExp('(\\' + specials.join('|\\') + ')', 'g');  }  return text.replace(arguments.callee.sRE, '\\$1');}function addAlert(type, name,subtitle, description,time, redirect) {	var addIndex = alertList.length;	alertList[addIndex]= new Array();	alertList[addIndex]['name'] = name;	alertList[addIndex]['type'] = type;	alertList[addIndex]['subtitle'] = subtitle;	alertList[addIndex]['description'] = description.replace(/<br>/gi, "\n").replace(/&amp;/gi,'&').replace(/&lt;/gi,'<').replace(/&gt;/gi,'>').replace(/&#039;/gi,'\'').replace(/&quot;/gi,'"');	alertList[addIndex]['time'] = time;	alertList[addIndex]['done'] = 0;	alertList[addIndex]['redirect'] = redirect;}function checkAlerts() {	secondsSinceLoad += 1;	var mj = 0;	var alertmsg = '';	for(mj = 0 ; mj < alertList.length; mj++) {		if(alertList[mj]['done'] == 0) {			if(alertList[mj]['time'] < secondsSinceLoad && alertList[mj]['time'] > -1 ) {				alertmsg = alertList[mj]['type'] + ":" + alertList[mj]['name'] + "\n" +alertList[mj]['subtitle']+ "\n"+ alertList[mj]['description'] + "\n\n";				alertList[mj]['done'] = 1;				if(alertList[mj]['redirect'] == '') {					alert(alertmsg);				}				else if(confirm(alertmsg)) {					window.location = alertList[mj]['redirect'];				}			}		}	}	setTimeout("checkAlerts()", 1000);}function toggleDisplay(id) {	if(this.document.getElementById(id).style.display == 'none') {		this.document.getElementById(id).style.display = '';		if(this.document.getElementById(id+"link") != undefined) {			this.document.getElementById(id+"link").style.display = 'none';		}		if(this.document.getElementById(id+"_anchor") != undefined)			this.document.getElementById(id+"_anchor").innerHTML='[ - ]';	}	else {		this.document.getElementById(id).style.display = 'none'		if(this.document.getElementById(id+"link") != undefined) {			this.document.getElementById(id+"link").style.display = '';		}		if(this.document.getElementById(id+"_anchor") != undefined)			this.document.getElementById(id+"_anchor").innerHTML='[+]';	}}function checkAll(form, field, value) {	for (i = 0; i < form.elements.length; i++) {		if(form.elements[i].name == field)			form.elements[i].checked = value;	}}function replaceAll(text, src, rep) {	offset = text.toLowerCase().indexOf(src.toLowerCase());	while(offset != -1) {		text = text.substring(0, offset) + rep + text.substring(offset + src.length ,text.length);		offset = text.indexOf( src, offset + rep.length + 1);	}	return text;}function addForm(formname) {	validate[formname] = new Array();}/** * Adds a function to be called during the window.onload() event * * @param func function to be called */function addLoadEvent(functiondef) {	var oldonload = window.onload;	// add this function call after the current one(s)    if (typeof window.onload == 'function') {		window.onload = function() {            if (oldonload) {                oldonload();            }            functiondef();        }        return;    }    // otherwise, set this as the function to call    window.onload = functiondef;}function addToValidate(formname, name, type,required, msg) {	if(typeof validate[formname] == 'undefined') {		addForm(formname);	}	validate[formname][validate[formname].length] = new Array(name, type,required, msg);}function addToValidateRange(formname, name, type,required,  msg,min,max) {	addToValidate(formname, name, type,required,  msg);	validate[formname][validate[formname].length - 1][jstypeIndex] = 'range'	validate[formname][validate[formname].length - 1][minIndex] = min;	validate[formname][validate[formname].length - 1][maxIndex] = max;}function addToValidateIsValidDate(formname, name, type, required, msg) {	addToValidate(formname, name, type, required, msg);	validate[formname][validate[formname].length - 1][jstypeIndex] = 'date'}function addToValidateIsValidTime(formname, name, type, required, msg) {	addToValidate(formname, name, type, required, msg);	validate[formname][validate[formname].length - 1][jstypeIndex] = 'time'}function addToValidateDateBefore(formname, name, type, required, msg, compareTo) {	addToValidate(formname, name, type,required,  msg);	validate[formname][validate[formname].length - 1][jstypeIndex] = 'isbefore'	validate[formname][validate[formname].length - 1][compareToIndex] = compareTo;}function addToValidateDateBeforeAllowBlank(formname, name, type, required, msg, compareTo, allowBlank) {	addToValidate(formname, name, type,required,  msg);	validate[formname][validate[formname].length - 1][jstypeIndex] = 'isbefore'	validate[formname][validate[formname].length - 1][compareToIndex] = compareTo;	validate[formname][validate[formname].length - 1][allowblank] = allowBlank;}function addToValidateBinaryDependency(formname, name, type, required, msg, compareTo) {	addToValidate(formname, name, type, required, msg);	validate[formname][validate[formname].length - 1][jstypeIndex] = 'binarydep';	validate[formname][validate[formname].length - 1][compareToIndex] = compareTo;}function addToValidateComparison(formname, name, type, required, msg, compareTo) {	addToValidate(formname, name, type, required, msg);	validate[formname][validate[formname].length - 1][jstypeIndex] = 'comparison';	validate[formname][validate[formname].length - 1][compareToIndex] = compareTo;}function addToValidateIsInArray(formname, name, type, required, msg, arr, operator) {	addToValidate(formname, name, type, required, msg);	validate[formname][validate[formname].length - 1][jstypeIndex] = 'in_array';	validate[formname][validate[formname].length - 1][arrIndex] = arr;	validate[formname][validate[formname].length - 1][operatorIndex] = operator;}function removeFromValidate(formname, name) {	for(i = 0; i < validate[formname].length; i++){		if(validate[formname][i][nameIndex] == name){			validate[formname].splice(i, 1);		}	}}function checkValidate(formname, name) {    if(validate[formname]){	    for(i = 0; i < validate[formname].length; i++){	        if(validate[formname][i][nameIndex] == name){	            return true;	        }	    }	}    return false;}var formsWithFieldLogic=null;var formWithPrecision =null;function addToValidateFieldLogic(formId,minFieldId, maxFieldId, defaultFieldId, lenFieldId,type,msg){	this.formId = document.getElementById(formId);	this.min=document.getElementById(minFieldId);	this.max= document.getElementById(maxFieldId);	this._default= document.getElementById(defaultFieldId);	this.len = document.getElementById(lenFieldId);	this.msg = msg;	this.type= type;}//@params: formid- Dom id of the form containing the precision and float fields//         valudId- Dom id of the field containing a float whose precision is to be checked.//         precisionId- Dom id of the field containing precision value.function addToValidatePrecision(formId, valueId, precisionId){	this.form = document.getElementById(formId);	this.float= document.getElementById(valueId);	this.precision = document.getElementById(precisionId);}//function checkLength(value, referenceValue){//	return value//}function isValidPrecision(value, precision){	value = value.toString();	if(precision == '')		return true;	for(var i =0; i<value.length; i++){		if(value[i]==".")			break;	}	var actualPrecision = value.substr(i+1, value.length).length;	return actualPrecision == precision;}function toDecimal(original, precision) {    precision = (precision == null) ? 2 : precision;    num = Math.pow(10, precision);	temp = Math.round(original*num)/num;	if((temp * 100) % 100 == 0)		return temp + '.00';	if((temp * 10) % 10 == 0)		return temp + '0';	return temp}function isInteger(s) {	if(typeof num_grp_sep != 'undefined' && typeof dec_sep != 'undefined')		s = unformatNumberNoParse(s, num_grp_sep, dec_sep).toString();	var i;    for (i = 0; i < s.length; i++){        // Check that current character is number.        var c = s.charAt(i);        if (((c < "0") || (c > "9"))){        	if(i == 0 && c == "-"){        		//do nothing        	}else        		return false;        }    }    // All characters are numbers.    return true;}function isNumeric(s) {  if(!/^-*[0-9\.]+$/.test(s)) {   		return false   }   else {		return true;   }}function stripCharsInBag(s, bag) {	var i;    var returnString = "";    // Search through string's characters one by one.    // If character is not in bag, append to returnString.    for (i = 0; i < s.length; i++){        var c = s.charAt(i);        if (bag.indexOf(c) == -1) returnString += c;    }    return returnString;}function daysInFebruary(year) {	// February has 29 days in any year evenly divisible by four,    // EXCEPT for centurial years which are not also divisible by 400.    return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );}function DaysArray(n) {	for (var i = 1; i <= n; i++) {		this[i] = 31		if (i==4 || i==6 || i==9 || i==11) {this[i] = 30}		if (i==2) {this[i] = 29}   }   return this}var date_reg_positions = {'Y': 1,'m': 2,'d': 3};var date_reg_format = '([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})'function isDate(dtStr) {	if(dtStr.length== 0) {

⌨️ 快捷键说明

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