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

📄 utils.js

📁 尚洋仓库管理系统,对仓库
💻 JS
📖 第 1 页 / 共 3 页
字号:
  if (!el) {    return null;  }	el = el.firstChild;  if (!el) {    return null;  }	if (!tag) {		return el;	}	tag = tag.toLowerCase();	if (el.nodeType == 1) {		if (el.tagName.toLowerCase() == tag) {			return el;		} else if (alternateTag) {			alternateTag = alternateTag.toLowerCase();			if (el.tagName.toLowerCase() == alternateTag) {				return el;			}		}	}	return Zapatec.Utils.getNextSibling(el, tag, alternateTag);};/** * Function that concatenates and returns all text child nodes of the * specified node. * * @param objNode [Node] -- reference to the node. * @return [string] -- concatenated text child nodes */Zapatec.Utils.getChildText = function(objNode) {	if (objNode == null) {		return '';	}	var arrText = [];	var objChild = objNode.firstChild;	while (objChild != null) {		if (objChild.nodeType == 3) { // Node.TEXT_NODE			arrText.push(objChild.data);		}		objChild = objChild.nextSibling;	}	return arrText.join(' ');};/** * Similar to the DOM's built in insertBefore. * Insert a node after an existing node. * * @param el [oldNode] The existing element * @param el [newNode] the new element to insert after the old one. * */Zapatec.Utils.insertAfter = function(oldNode, newNode) {	if(oldNode.nextSibling) {		oldNode.parentNode.insertBefore(newNode, oldNode.nextSibling);	} else {		oldNode.parentNode.appendChild(newNode);	}}Zapatec.Utils._ids = {};	/**< [number, static] maintains a list of generated IDs *//** * Generates an unique ID, for a certain code (let's say "class").  If the * optional "id" argument is passed, then it just returns the id for that code * (no generation).  This function is sometimes useful when we need to create * elements and be able to access them later by ID. * * @param code [string] the class of ids.  User defined, can be anything. * @param id [string, optional] specify if the ID is already known. * * @return [string] the unique ID */Zapatec.Utils.generateID = function(code, id) {	if (typeof id == "undefined") {		if (typeof this._ids[code] == "undefined")			this._ids[code] = 0;		id = ++this._ids[code];	}	return "zapatec-" + code + "-" + id;};/***  Add a tooltip to the specified element.**  Function that adds a custom tooltip for an element.  The "target" is the*  element to where the tooltip should be added to, and the "tooltip" is a DIV*  that contains the tooltip text.  Optionally, the tooltip DIV can have the*  "title" attribute set; if so, its value will be displayed highlighted as*  the title of the tooltip.**  @param target  reference to or ID of the target element*  @param tooltip reference to or ID of the tooltip content element*/Zapatec.Utils.addTooltip = function(target, tooltip) {return new Zapatec.Tooltip(target, tooltip);};Zapatec.isLite=true;Zapatec.Utils.checkActivation = function() {	if (!Zapatec.isLite)	return true;	var arrProducts=[]	add_product=function(script, webdir_in, name_in)	{	arrProducts[script]={webdir:webdir_in, name:name_in, bActive:false}	}	add_product('calendar.js', 'prod1',   'Calendar')	add_product('menu.js',     'prod2',   'Menu')	add_product('tree.js',     'prod3',   'Tree')	add_product('form.js',     'forms',   'Forms')	add_product('effects.js',  'effects', 'Effects')	add_product('hoverer.js',  'effects', 'Effects - Hoverer')	add_product('slideshow.js','effects', 'Effects - Slidshow')	add_product('zpgrid.js',   'grid',    'Grid')	add_product('slider.js',   'slider',  'Slider')	add_product('zptabs.js',   'tabs',    'Tabs')	add_product('zptime.js',   'time',    'Time')	add_product('window.js',   'windows', 'Window')	var strName, arrName, i	var bProduct=false // Flag yes if we have a zapatec script	var scripts = document.getElementsByTagName('script');	for (i=0; i<scripts.length; i++)	{		// If wizard then do NOT do link back check, which makes wizard err out		if (/wizard.js/i.test(scripts[i].src))			return true		arrName=scripts[i].src.split('/')		if (arrName.length==0)			strName=scripts[i]		else			strName=arrName[arrName.length-1]		strName=strName.toLowerCase()		// Get each active product		if (typeof arrProducts[strName] != 'undefined')			{			bProduct=true			arrProducts[strName].bActive=true			}	}	// Is a LITE product even being used?	if (!bProduct) return true;	var anchors = document.getElementsByTagName('A');	for(i = 0; i < anchors.length; i++)		if (/(dev|www)\.zapatec\.com/i.test(anchors[i].href))			return true;	var strMsg='You are using the Free version of the Zapatec Software.\n'+	'While using the Free version, a link to www.zapatec.com in this page is required.'	for (i in arrProducts)		// Get each active product		if (arrProducts[i].bActive==true)			strMsg+='\nTo purchase the Zapatec ' + arrProducts[i].name + ' visit www.zapatec.com/website/main/products/' + arrProducts[i].webdir + '/'	alert(strMsg)	return false;}// Browser sniffing/// detect Opera browserZapatec.is_opera = /opera/i.test(navigator.userAgent);/// detect a special case of "web browser"Zapatec.is_ie = ( /msie/i.test(navigator.userAgent) && !Zapatec.is_opera );/// detect IE5.0/WinZapatec.is_ie5 = ( Zapatec.is_ie && /msie 5\.0/i.test(navigator.userAgent) );/// detect IE for MacintoshZapatec.is_mac_ie = ( /msie.*mac/i.test(navigator.userAgent) && !Zapatec.is_opera );/// detect KHTML-based browsersZapatec.is_khtml = /Konqueror|Safari|KHTML/i.test(navigator.userAgent);/// detect KonquerorZapatec.is_konqueror = /Konqueror/i.test(navigator.userAgent);/// detect GeckoZapatec.is_gecko = /Gecko/i.test(navigator.userAgent);/** * Simulation of Function call() method that is missing in IE 5.0. */if (!Function.prototype.call) {	Function.prototype.call = function () {		var self = arguments[0];		self._this_func = this;		var args = new Array();		for (var i=1; i < arguments.length; i++) {			args[args.length] = 'arguments[' + i + ']';		}		var ret = eval('self._this_func(' + args.join(',') + ')');		self._this_func = null;		return ret;	};}/** * Simulation of Array pop() method that is missing in IE 5.0. */if (!Array.prototype.pop) {	Array.prototype.pop = function() {		var last;		if (this.length) {			last = this[this.length - 1];			this.length -= 1;		}		return last;	};}/** * Simulation of Array push() method that is missing in IE 5.0 */if (!Array.prototype.push) {	Array.prototype.push = function() {		for (var i = 0; i < arguments.length; i++) {			this[this.length] = arguments[i];		}		return this.length;	};}/** * Simulation of Array shift() method that is missing in IE 5.0. */if (!Array.prototype.shift) {	Array.prototype.shift = function() {		var first;		if (this.length) {			first = this[0];			for (var i = 0; i < this.length - 1; i++) {				this[i] = this[i + 1];			}			this.length -= 1;		}		return first;	};}/** * Simulation of Array unshift() method that is missing in IE 5.0. */if (!Array.prototype.unshift) {	Array.prototype.unshift = function() {		if (arguments.length) {			var i, len = arguments.length;			for (i = this.length + len - 1; i >= len; i--) {				this[i] = this[i - len];			}			for (i = 0; i < len; i++) {				this[i] = arguments[i];			}		}		return this.length;	};}/** * Simulation of Array splice() method that is missing in IE 5.0. */if (!Array.prototype.splice) {	Array.prototype.splice = function(index, howMany) {		var elements = [], removed = [], i;		for (i = 2; i < arguments.length; i++) {			elements.push(arguments[i]);		}		for (i = index; (i < index + howMany) && (i < this.length); i++) {			removed.push(this[i]);		}		for (i = index + howMany; i < this.length; i++) {			this[i - howMany] = this[i];		}		this.length -= removed.length;		for (i = this.length + elements.length - 1; i >= index + elements.length;		 i--) {			this[i] = this[i - elements.length];		}		for (i = 0; i < elements.length; i++) {			this[index + i] = elements[i];		}		return removed;	};}/** * Displays error message. Override this if needed. * * \param objArgs [number] error object: * { *   severity: [string, optional] error severity, *   description: [string] human readable error description * } */Zapatec.Log = function(objArgs) {  // Check arguments  if (!objArgs) {    return;  }  // Form error message  var strMessage = objArgs.description;  if (objArgs.severity) {    strMessage = objArgs.severity + ':\n' + strMessage;  }  // Display error message  alert(strMessage);};/// Zapatec.Utils.Array object which contains additional for arrays methodZapatec.Utils.Array = {};/** * Inserts the element into array.  * It influences the order in which the elements will be iterated in the for...in cycle. * * @param arr [array] array to work with. * @param el [mixed] element to insert. * @param key [string] element to insert. * @param nextKey [string] element to be inserted before. * @return [string] new Array. */Zapatec.Utils.Array.insertBefore = function (arr, el, key, nextKey) {	var tmp = new Array();	for(var i in arr) {		if (i == nextKey) {			if (key) {				tmp[key] = el;			} else {				tmp.push(el);			}		}		tmp[i] = arr[i];	}	return tmp;}

⌨️ 快捷键说明

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