📄 overview-summary-sarissa.js.html
字号:
&& Sarissa.getDomDocument(<span class="literal">""</span>,<span class="literal">"foo"</span>, null).xml){ <span class="comment">/** * Utility class to serialize DOM Node objects to XML strings * <span class="attrib">@constructor</span> */</span> XMLSerializer = <span class="reserved">function</span>(){}; <span class="comment">/** * Serialize the given DOM Node to an XML string * <span class="attrib">@param</span> oNode the DOM Node to serialize */</span> XMLSerializer.<span class="reserved">prototype</span>.serializeToString = <span class="reserved">function</span>(oNode) { <span class="reserved">return</span> oNode.xml; };};<span class="comment">/** * strips tags from a markup string */</span>Sarissa.stripTags = <span class="reserved">function</span> (s) { <span class="reserved">return</span> s.replace(/<[^>]+>/g,<span class="literal">""</span>);};<span class="comment">/** * <p>Deletes all child nodes of the given node</p> * <span class="attrib">@argument</span> oNode the Node to empty */</span>Sarissa.clearChildNodes = <span class="reserved">function</span>(oNode) { <span class="comment">// need to check for firstChild due to opera 8 bug with hasChildNodes</span> <span class="reserved">while</span>(oNode.firstChild) { oNode.removeChild(oNode.firstChild); };};<span class="comment">/** * <p> Copies the childNodes of nodeFrom to nodeTo</p> * <p> <b>Note:</b> The second object's original content is deleted before * the copy operation, unless you supply a true third parameter</p> * <span class="attrib">@argument</span> nodeFrom the Node to copy the childNodes from * <span class="attrib">@argument</span> nodeTo the Node to copy the childNodes to * <span class="attrib">@argument</span> bPreserveExisting whether to preserve the original content of nodeTo, default is false */</span>Sarissa.copyChildNodes = <span class="reserved">function</span>(nodeFrom, nodeTo, bPreserveExisting) { <span class="reserved">if</span>((!nodeFrom) || (!nodeTo)){ throw <span class="literal">"Both source and destination nodes must be provided"</span>; }; <span class="reserved">if</span>(!bPreserveExisting){ Sarissa.clearChildNodes(nodeTo); }; var ownerDoc = nodeTo.nodeType == Node.DOCUMENT_NODE ? nodeTo : nodeTo.ownerDocument; var nodes = nodeFrom.childNodes; <span class="reserved">if</span>(typeof(ownerDoc.importNode) != <span class="literal">"undefined"</span>) { <span class="reserved">for</span>(var i=0;i < nodes.length;i++) { nodeTo.appendChild(ownerDoc.importNode(nodes[i], true)); }; } <span class="reserved">else</span> { <span class="reserved">for</span>(var i=0;i < nodes.length;i++) { nodeTo.appendChild(nodes[i].cloneNode(true)); }; };};<span class="comment">/** * <p> Moves the childNodes of nodeFrom to nodeTo</p> * <p> <b>Note:</b> The second object's original content is deleted before * the move operation, unless you supply a true third parameter</p> * <span class="attrib">@argument</span> nodeFrom the Node to copy the childNodes from * <span class="attrib">@argument</span> nodeTo the Node to copy the childNodes to * <span class="attrib">@argument</span> bPreserveExisting whether to preserve the original content of nodeTo, default is */</span> Sarissa.moveChildNodes = <span class="reserved">function</span>(nodeFrom, nodeTo, bPreserveExisting) { <span class="reserved">if</span>((!nodeFrom) || (!nodeTo)){ throw <span class="literal">"Both source and destination nodes must be provided"</span>; }; <span class="reserved">if</span>(!bPreserveExisting){ Sarissa.clearChildNodes(nodeTo); }; var nodes = nodeFrom.childNodes; <span class="comment">// if within the same doc, just move, else copy and delete</span> <span class="reserved">if</span>(nodeFrom.ownerDocument == nodeTo.ownerDocument){ <span class="reserved">while</span>(nodeFrom.firstChild){ nodeTo.appendChild(nodeFrom.firstChild); }; } <span class="reserved">else</span> { var ownerDoc = nodeTo.nodeType == Node.DOCUMENT_NODE ? nodeTo : nodeTo.ownerDocument; <span class="reserved">if</span>(typeof(ownerDoc.importNode) != <span class="literal">"undefined"</span>) { <span class="reserved">for</span>(var i=0;i < nodes.length;i++) { nodeTo.appendChild(ownerDoc.importNode(nodes[i], true)); }; }<span class="reserved">else</span>{ <span class="reserved">for</span>(var i=0;i < nodes.length;i++) { nodeTo.appendChild(nodes[i].cloneNode(true)); }; }; Sarissa.clearChildNodes(nodeFrom); };};<span class="comment">/** * <p>Serialize any object to an XML string. All properties are serialized using the property name * as the XML element name. Array elements are rendered as <code>array-item</code> elements, * using their index/key as the value of the <code>key</code> attribute.</p> * <span class="attrib">@argument</span> anyObject the object to serialize * <span class="attrib">@argument</span> objectName a name for that object * <span class="attrib">@return</span> the XML serializationj of the given object as a string */</span>Sarissa.xmlize = <span class="reserved">function</span>(anyObject, objectName, indentSpace){ indentSpace = indentSpace?indentSpace:<span class="literal">''</span>; var s = indentSpace + <span class="literal">'<'</span> + objectName + <span class="literal">'>'</span>; var isLeaf = false; <span class="reserved">if</span>(!(anyObject instanceof Object) || anyObject instanceof Number || anyObject instanceof String || anyObject instanceof Boolean || anyObject instanceof Date){ s += Sarissa.escape(<span class="literal">""</span>+anyObject); isLeaf = true; }<span class="reserved">else</span>{ s += <span class="literal">"\n"</span>; var itemKey = <span class="literal">''</span>; var isArrayItem = anyObject instanceof Array; <span class="reserved">for</span>(var name in anyObject){ s += Sarissa.xmlize(anyObject[name], (isArrayItem?<span class="literal">"array-item key=\"</span><span class="literal">"+name+"</span>\<span class="literal">""</span>:name), indentSpace + <span class="literal">" "</span>); }; s += indentSpace; }; <span class="reserved">return</span> s += (objectName.indexOf(<span class="literal">' '</span>)!=-1?<span class="literal">"</array-item>\n"</span>:<span class="literal">"</"</span> + objectName + <span class="literal">">\n"</span>);};<span class="comment">/** * Escape the given string chacters that correspond to the five predefined XML entities * <span class="attrib">@param</span> sXml the string to escape */</span>Sarissa.escape = <span class="reserved">function</span>(sXml){ <span class="reserved">return</span> sXml.replace(/&/g, <span class="literal">"&amp;"</span>) .replace(/</g, <span class="literal">"&lt;"</span>) .replace(/>/g, <span class="literal">"&gt;"</span>) .replace(/<span class="literal">"/g, "</span>&quot;<span class="literal">") .replace(/'/g, "</span>&apos;<span class="literal">");};/** * Unescape the given string. This turns the occurences of the predefined XML * entities to become the characters they represent correspond to the five predefined XML entities * @param sXml the string to unescape */Sarissa.unescape = function(sXml){ return sXml.replace(/&apos;/g,"</span>'<span class="literal">") .replace(/&quot;/g,"</span>\<span class="literal">""</span>) .replace(/&gt;/g,<span class="literal">">"</span>) .replace(/&lt;/g,<span class="literal">"<"</span>) .replace(/&amp;/g,<span class="literal">"&"</span>);};<span class="comment">// EOF</span></pre> <hr><!-- ========== START OF NAVBAR ========== --><a name="navbar_top"><!-- --></a><table border="0" width="100%" cellpadding="1" cellspacing="0"><tr><td colspan=2 bgcolor="#b8cade" class="NavBarCell1"><a name="navbar_top_firstrow"><!-- --></a><table border="0" cellpadding="0" cellspacing="3"> <tr align="center" valign="top"> <td bgcolor="#b8cade" class="NavBarCell1"> <a href="overview-summary.html"><font class="NavBarFont1"><b>Overview</b></font></a> </td> <td bgcolor="#FFFFFF" class="NavBarCell1Rev"> <font class="NavBarFont1Rev"><b>File</b></font> </td> <td bgcolor="#FFFFFF" class="NavBarCell1"> <font class="NavBarFont1">Class</font> </td> <td bgcolor="#b8cade" class="NavBarCell1"> <a href="overview-tree.html"><font class="NavBarFont1"><b>Tree</b></font></a> </td> <td bgcolor="#b8cade" class="NavBarCell1"> <a href="index-all.html"--><font class="NavBarFont1"><b>Index</b></font></a> </td> <td bgcolor="#b8cade" class="NavBarCell1"> <a href="help-doc.html"><font class="NavBarFont1"><b>Help</b></font></a> </td> </tr></table></td><td bgcolor="#b8cade" align="right" valign="top"><em><b>sarissa</b></em></td></tr><tr><td bgcolor="#eeeeee" class="NavBarCell2"><font size="-2"> PREV NEXT</font></td><td bgcolor="#eeeeee" class="NavBarCell2"><font size="-2"> <a href="index.html" target="_top"><b>FRAMES</b></a> <a href="overview-summary.html" target="_top"><b>NO FRAMES</b></a> <script> <!-- if(window==top) { document.writeln('<A HREF="allclasses-noframe.html" TARGET=""><B>All Classes</B></A>'); } //--></script><noscript><a href="allclasses-noframe.html" target=""><b>All Classes</b></a></noscript></font></td></tr></table><!-- =========== END OF NAVBAR =========== --><hr><font size="-1"></font><div class="jsdoc_ctime">Documentation generated by <a href="http://jsdoc.sourceforge.net/" target="_parent">JSDoc</a> on Thu Nov 30 22:06:11 2006</div></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -