Web UI for ARGUS server
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

116 lines
4.0 KiB

6 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. <html>
  2. <head>
  3. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  4. <title>The source code</title>
  5. <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
  6. <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
  7. </head>
  8. <body onload="prettyPrint();">
  9. <pre class="prettyprint lang-js">/*!
  10. * Ext JS Library 3.3.1
  11. * Copyright(c) 2006-2010 Sencha Inc.
  12. * licensing@sencha.com
  13. * http://www.sencha.com/license
  14. */
  15. Ext.ns('Ext.ux.tree');
  16. /**
  17. * @class Ext.ux.tree.XmlTreeLoader
  18. * @extends Ext.tree.TreeLoader
  19. * <p>A TreeLoader that can convert an XML document into a hierarchy of {@link Ext.tree.TreeNode}s.
  20. * Any text value included as a text node in the XML will be added to the parent node as an attribute
  21. * called <tt>innerText</tt>. Also, the tag name of each XML node will be added to the tree node as
  22. * an attribute called <tt>tagName</tt>.</p>
  23. * <p>By default, this class expects that your source XML will provide the necessary attributes on each
  24. * node as expected by the {@link Ext.tree.TreePanel} to display and load properly. However, you can
  25. * provide your own custom processing of node attributes by overriding the {@link #processNode} method
  26. * and modifying the attributes as needed before they are used to create the associated TreeNode.</p>
  27. * @constructor
  28. * Creates a new XmlTreeloader.
  29. * @param {Object} config A config object containing config properties.
  30. */
  31. Ext.ux.tree.XmlTreeLoader = Ext.extend(Ext.tree.TreeLoader, {
  32. <div id="prop-Ext.ux.tree.XmlTreeLoader-XML_NODE_ELEMENT"></div>/**
  33. * @property XML_NODE_ELEMENT
  34. * XML element node (value 1, read-only)
  35. * @type Number
  36. */
  37. XML_NODE_ELEMENT : 1,
  38. <div id="prop-Ext.ux.tree.XmlTreeLoader-XML_NODE_TEXT"></div>/**
  39. * @property XML_NODE_TEXT
  40. * XML text node (value 3, read-only)
  41. * @type Number
  42. */
  43. XML_NODE_TEXT : 3,
  44. // private override
  45. processResponse : function(response, node, callback){
  46. var xmlData = response.responseXML,
  47. root = xmlData.documentElement || xmlData;
  48. try{
  49. node.beginUpdate();
  50. node.appendChild(this.parseXml(root));
  51. node.endUpdate();
  52. this.runCallback(callback, scope || node, [node]);
  53. }catch(e){
  54. this.handleFailure(response);
  55. }
  56. },
  57. // private
  58. parseXml : function(node) {
  59. var nodes = [];
  60. Ext.each(node.childNodes, function(n){
  61. if(n.nodeType == this.XML_NODE_ELEMENT){
  62. var treeNode = this.createNode(n);
  63. if(n.childNodes.length > 0){
  64. var child = this.parseXml(n);
  65. if(typeof child == 'string'){
  66. treeNode.attributes.innerText = child;
  67. }else{
  68. treeNode.appendChild(child);
  69. }
  70. }
  71. nodes.push(treeNode);
  72. }
  73. else if(n.nodeType == this.XML_NODE_TEXT){
  74. var text = n.nodeValue.trim();
  75. if(text.length > 0){
  76. return nodes = text;
  77. }
  78. }
  79. }, this);
  80. return nodes;
  81. },
  82. // private override
  83. createNode : function(node){
  84. var attr = {
  85. tagName: node.tagName
  86. };
  87. Ext.each(node.attributes, function(a){
  88. attr[a.nodeName] = a.nodeValue;
  89. });
  90. this.processAttributes(attr);
  91. return Ext.ux.tree.XmlTreeLoader.superclass.createNode.call(this, attr);
  92. },
  93. /*
  94. * Template method intended to be overridden by subclasses that need to provide
  95. * custom attribute processing prior to the creation of each TreeNode. This method
  96. * will be passed a config object containing existing TreeNode attribute name/value
  97. * pairs which can be modified as needed directly (no need to return the object).
  98. */
  99. processAttributes: Ext.emptyFn
  100. });
  101. //backwards compat
  102. Ext.ux.XmlTreeLoader = Ext.ux.tree.XmlTreeLoader;
  103. </pre>
  104. </body>
  105. </html>