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

📄 node.jsc

📁 《JavaScript王者归来》examples.rar
💻 JSC
📖 第 1 页 / 共 2 页
字号:
# language: jsvm2/* * Copyright (c) 2000 World Wide Web Consortium, * (Massachusetts Institute of Technology, Institut National de * Recherche en Informatique et en Automatique, Keio University). All * Rights Reserved. This program is distributed under the W3C's Software * Intellectual Property License. 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 W3C License http://www.w3.org/Consortium/Legal/ for more details. */package org.w3c.dom;import js.lang.BObject;import js.util.ArrayList;import org.w3c.dom.DOMException;class Node extends BObject (sType, sName, vValue){	super.call(this);	this.__nodeType = sType || Node.ELEMENT_NODE;	this.__nodeName = sName || null;	this.__nodeValue = vValue || null;	this.__namedNodeMap = null;	this.__parentNode = null;	this.__childNodes = new ArrayList();;	this.__ownerDocument = null;	this.__namespaceURI = null;	this.__prefix = "";	this.__localName = null;}/** * The name of this node, depending on its type; see the table above. */Node.prototype.getNodeName = function (){	return this.__nodeName;}/** * The value of this node, depending on its type; see the table above. * When it is defined to be <code>null</code>, setting it has no effect. * @exception DOMException *   NO_MODIFICATION_ALLOWED_ERR: Raised when the node is readonly. * @exception DOMException *   DOMSTRING_SIZE_ERR: Raised when it would return more characters than *   fit in a <code>DOMString</code> variable on the implementation *   platform. */Node.prototype.getNodeValue = function (){	return this.__nodeValue;}/** * The value of this node, depending on its type; see the table above. * When it is defined to be <code>null</code>, setting it has no effect. * @exception DOMException *   NO_MODIFICATION_ALLOWED_ERR: Raised when the node is readonly. * @exception DOMException *   DOMSTRING_SIZE_ERR: Raised when it would return more characters than *   fit in a <code>DOMString</code> variable on the implementation *   platform. */Node.prototype.setNodeValue = function (value){	this.__nodeValue = value;}/** * A code representing the type of the underlying object, as defined above. */Node.prototype.getNodeType = function (){	return this.__nodeType;}/** * The parent of this node. All nodes, except <code>Attr</code>, * <code>Document</code>, <code>DocumentFragment</code>, * <code>Entity</code>, and <code>Notation</code> may have a parent. * However, if a node has just been created and not yet added to the * tree, or if it has been removed from the tree, this is * <code>null</code>. */Node.prototype.getParentNode = function (){	return this.__parentNode;}Node.prototype.__setParentNode = function (oNode){	this.__parentNode = oNode;}/** * A <code>NodeList</code> that contains all children of this node. If * there are no children, this is a <code>NodeList</code> containing no * nodes. */Node.prototype.getChildNodes = function (){	return this.__childNodes.toArray();}/** * The first child of this node. If there is no such node, this returns * <code>null</code>. */Node.prototype.getFirstChild = function (){	return this.__childNodes.get(0);}/** * The last child of this node. If there is no such node, this returns * <code>null</code>. */Node.prototype.getLastChild = function (){	return this.__childNodes.get(this.__childNodes.size() - 1);}/** * The node immediately preceding this node. If there is no such node, * this returns <code>null</code>. */Node.prototype.getPreviousSibling = function (){	var parentNode = this.getParentNode();	if (parentNode != null)	{		var children = parentNode.getChildNodes();		var len = children.length;		for (var i = 0; i < len; i++)		{			if (children[i] == this	&& i > 1)			{				return children[i - 1];			}		}	}	return null;}/** * The node immediately following this node. If there is no such node, * this returns <code>null</code>. */Node.prototype.getNextSibling = function (){	var parentNode = this.getParentNode();	if (parentNode != null)	{		var children = parentNode.getChildNodes();		var len = children.length;		for (var i = 0; i < len; i++)		{			if (children[i] == this	&& i < (len - 1))			{				return children[i + 1];			}		}	}	return null;}/** * A <code>NamedNodeMap</code> containing the attributes of this node (if * it is an <code>Element</code>) or <code>null</code> otherwise. */Node.prototype.getAttributes = function (){	if (this.__namedNodeMap == null)	{		this.__namedNodeMap = Class.forName("org.w3c.dom.NamedNodeMap").newInstance();	}	return this.__namedNodeMap;}/** * The <code>Document</code> object associated with this node. This is * also the <code>Document</code> object used to create new nodes. When * this node is a <code>Document</code> or a <code>DocumentType</code> * which is not used with any <code>Document</code> yet, this is * <code>null</code>. * @version DOM Level 2 */Node.prototype.getOwnerDocument = function (){	return this.__ownerDocument;}/** * Inserts the node <code>newChild</code> before the existing child node * <code>refChild</code>. If <code>refChild</code> is <code>null</code>, * insert <code>newChild</code> at the end of the list of children. * <br>If <code>newChild</code> is a <code>DocumentFragment</code> object, * all of its children are inserted, in the same order, before * <code>refChild</code>. If the <code>newChild</code> is already in the * tree, it is first removed. * @param newChild The node to insert. * @param refChild The reference node, i.e., the node before which the *   new node must be inserted. * @return The node being inserted. * @exception DOMException *   HIERARCHY_REQUEST_ERR: Raised if this node is of a type that does not *   allow children of the type of the <code>newChild</code> node, or if *   the node to insert is one of this node's ancestors or this node *   itself. *   <br>WRONG_DOCUMENT_ERR: Raised if <code>newChild</code> was created *   from a different document than the one that created this node. *   <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly or *   if the parent of the node being inserted is readonly. *   <br>NOT_FOUND_ERR: Raised if <code>refChild</code> is not a child of *   this node. */Node.prototype.insertBefore = function (newChild, refChild){	var index = this.__childNodes.indexOf(refChild);	if (index == -1)	{		this.__childNodes.add(newChild);	}	else	{		this.__childNodes.add(index, newChild);	}	newChild.__parentNode = this;	return newChild;}/** * Replaces the child node <code>oldChild</code> with <code>newChild</code> *  in the list of children, and returns the <code>oldChild</code> node. * <br>If <code>newChild</code> is a <code>DocumentFragment</code> object, * <code>oldChild</code> is replaced by all of the * <code>DocumentFragment</code> children, which are inserted in the * same order. If the <code>newChild</code> is already in the tree, it * is first removed. * @param newChild The new node to put in the child list. * @param oldChild The node being replaced in the list. * @return The node replaced. * @exception DOMException *   HIERARCHY_REQUEST_ERR: Raised if this node is of a type that does not *   allow children of the type of the <code>newChild</code> node, or if *   the node to put in is one of this node's ancestors or this node *   itself. *   <br>WRONG_DOCUMENT_ERR: Raised if <code>newChild</code> was created *   from a different document than the one that created this node. *   <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this node or the parent of *   the new node is readonly. *   <br>NOT_FOUND_ERR: Raised if <code>oldChild</code> is not a child of *   this node. */Node.prototype.replaceChild = function (newChild, oldChild){	this.__childNodes.remove(newChild);	var index = this.__childNodes.indexOf(oldChild);	if (index == -1)	{		throw new DOMException(this.getClass().getName() +			".replaceChild(newChild, oldChild) error: oldChild does not exist.");	}	this.__childNodes.add(index, newChild);	this.__childNodes.removeAt(index + 1);	oldChild.__parentNode = null;	newChild.__parentNode = this;	return oldChild;}/** * Removes the child node indicated by <code>oldChild</code> from the list * of children, and returns it. * @param oldChild The node being removed.

⌨️ 快捷键说明

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