Web Interface For Lite Argus Control modules
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.

916 lines
27 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  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.debug = {};
  16. (function(){
  17. var cp;
  18. function createConsole(){
  19. var scriptPanel = new Ext.debug.ScriptsPanel();
  20. var logView = new Ext.debug.LogPanel();
  21. var tree = new Ext.debug.DomTree();
  22. var compInspector = new Ext.debug.ComponentInspector();
  23. var compInfoPanel = new Ext.debug.ComponentInfoPanel();
  24. var storeInspector = new Ext.debug.StoreInspector();
  25. var objInspector = new Ext.debug.ObjectInspector();
  26. var tabs = new Ext.TabPanel({
  27. activeTab: 0,
  28. border: false,
  29. tabPosition: 'bottom',
  30. items: [{
  31. title: 'Debug Console',
  32. layout:'border',
  33. items: [logView, scriptPanel]
  34. },{
  35. title: 'HTML Inspector',
  36. layout:'border',
  37. items: [tree]
  38. },{
  39. title: 'Component Inspector',
  40. layout: 'border',
  41. items: [compInspector,compInfoPanel]
  42. },{
  43. title: 'Object Inspector',
  44. layout: 'border',
  45. items: [objInspector]
  46. },{
  47. title: 'Data Stores',
  48. layout: 'border',
  49. items: [storeInspector]
  50. }]
  51. });
  52. cp = new Ext.Panel({
  53. id: 'x-debug-browser',
  54. title: 'Console',
  55. collapsible: true,
  56. animCollapse: false,
  57. style: 'position:absolute;left:0;bottom:0;z-index:101',
  58. height:200,
  59. logView: logView,
  60. layout: 'fit',
  61. tools:[{
  62. id: 'close',
  63. handler: function(){
  64. cp.destroy();
  65. cp = null;
  66. Ext.EventManager.removeResizeListener(handleResize);
  67. }
  68. }],
  69. items: tabs
  70. });
  71. cp.render(Ext.getBody());
  72. cp.resizer = new Ext.Resizable(cp.el, {
  73. minHeight:50,
  74. handles: "n",
  75. pinned: true,
  76. transparent:true,
  77. resizeElement : function(){
  78. var box = this.proxy.getBox();
  79. this.proxy.hide();
  80. cp.setHeight(box.height);
  81. return box;
  82. }
  83. });
  84. // function handleResize(){
  85. // cp.setWidth(Ext.getBody().getViewSize().width);
  86. // }
  87. // Ext.EventManager.onWindowResize(handleResize);
  88. //
  89. // handleResize();
  90. function handleResize(){
  91. var b = Ext.getBody();
  92. var size = b.getViewSize();
  93. if(size.height < b.dom.scrollHeight) {
  94. size.width -= 18;
  95. }
  96. cp.setWidth(size.width);
  97. }
  98. Ext.EventManager.onWindowResize(handleResize);
  99. handleResize();
  100. }
  101. Ext.apply(Ext, {
  102. log : function(){
  103. if(!cp){
  104. createConsole();
  105. }
  106. cp.logView.log.apply(cp.logView, arguments);
  107. },
  108. logf : function(format, arg1, arg2, etc){
  109. Ext.log(String.format.apply(String, arguments));
  110. },
  111. dump : function(o){
  112. if(typeof o == 'string' || typeof o == 'number' || typeof o == 'undefined' || Ext.isDate(o)){
  113. Ext.log(o);
  114. }else if(!o){
  115. Ext.log("null");
  116. }else if(typeof o != "object"){
  117. Ext.log('Unknown return type');
  118. }else if(Ext.isArray(o)){
  119. Ext.log('['+o.join(',')+']');
  120. }else{
  121. var b = ["{\n"];
  122. for(var key in o){
  123. var to = typeof o[key];
  124. if(to != "function" && to != "object"){
  125. b.push(String.format(" {0}: {1},\n", key, o[key]));
  126. }
  127. }
  128. var s = b.join("");
  129. if(s.length > 3){
  130. s = s.substr(0, s.length-2);
  131. }
  132. Ext.log(s + "\n}");
  133. }
  134. },
  135. _timers : {},
  136. time : function(name){
  137. name = name || "def";
  138. Ext._timers[name] = new Date().getTime();
  139. },
  140. timeEnd : function(name, printResults){
  141. var t = new Date().getTime();
  142. name = name || "def";
  143. var v = String.format("{0} ms", t-Ext._timers[name]);
  144. Ext._timers[name] = new Date().getTime();
  145. if(printResults !== false){
  146. Ext.log('Timer ' + (name == "def" ? v : name + ": " + v));
  147. }
  148. return v;
  149. }
  150. });
  151. })();
  152. Ext.debug.ScriptsPanel = Ext.extend(Ext.Panel, {
  153. id:'x-debug-scripts',
  154. region: 'east',
  155. minWidth: 200,
  156. split: true,
  157. width: 350,
  158. border: false,
  159. layout:'anchor',
  160. style:'border-width:0 0 0 1px;',
  161. initComponent : function(){
  162. this.scriptField = new Ext.form.TextArea({
  163. anchor: '100% -26',
  164. style:'border-width:0;'
  165. });
  166. this.trapBox = new Ext.form.Checkbox({
  167. id: 'console-trap',
  168. boxLabel: 'Trap Errors',
  169. checked: true
  170. });
  171. this.toolbar = new Ext.Toolbar([{
  172. text: 'Run',
  173. scope: this,
  174. handler: this.evalScript
  175. },{
  176. text: 'Clear',
  177. scope: this,
  178. handler: this.clear
  179. },
  180. '->',
  181. this.trapBox,
  182. ' ', ' '
  183. ]);
  184. this.items = [this.toolbar, this.scriptField];
  185. Ext.debug.ScriptsPanel.superclass.initComponent.call(this);
  186. },
  187. evalScript : function(){
  188. var s = this.scriptField.getValue();
  189. if(this.trapBox.getValue()){
  190. try{
  191. var rt = eval(s);
  192. Ext.dump(rt === undefined? '(no return)' : rt);
  193. }catch(e){
  194. Ext.log(e.message || e.descript);
  195. }
  196. }else{
  197. var rt = eval(s);
  198. Ext.dump(rt === undefined? '(no return)' : rt);
  199. }
  200. },
  201. clear : function(){
  202. this.scriptField.setValue('');
  203. this.scriptField.focus();
  204. }
  205. });
  206. Ext.debug.LogPanel = Ext.extend(Ext.Panel, {
  207. autoScroll: true,
  208. region: 'center',
  209. border: false,
  210. style:'border-width:0 1px 0 0',
  211. log : function(){
  212. var markup = [ '<div style="padding:5px !important;border-bottom:1px solid #ccc;">',
  213. Ext.util.Format.htmlEncode(Array.prototype.join.call(arguments, ', ')).replace(/\n/g, '<br/>').replace(/\s/g, '&#160;'),
  214. '</div>'].join(''),
  215. bd = this.body.dom;
  216. this.body.insertHtml('beforeend', markup);
  217. bd.scrollTop = bd.scrollHeight;
  218. },
  219. clear : function(){
  220. this.body.update('');
  221. this.body.dom.scrollTop = 0;
  222. }
  223. });
  224. Ext.debug.DomTree = Ext.extend(Ext.tree.TreePanel, {
  225. enableDD:false ,
  226. lines:false,
  227. rootVisible:false,
  228. animate:false,
  229. hlColor:'ffff9c',
  230. autoScroll: true,
  231. region:'center',
  232. border:false,
  233. initComponent : function(){
  234. Ext.debug.DomTree.superclass.initComponent.call(this);
  235. // tree related stuff
  236. var styles = false, hnode;
  237. var nonSpace = /^\s*$/;
  238. var html = Ext.util.Format.htmlEncode;
  239. var ellipsis = Ext.util.Format.ellipsis;
  240. var styleRe = /\s?([a-z\-]*)\:([^;]*)(?:[;\s\n\r]*)/gi;
  241. function findNode(n){
  242. if(!n || n.nodeType != 1 || n == document.body || n == document){
  243. return false;
  244. }
  245. var pn = [n], p = n;
  246. while((p = p.parentNode) && p.nodeType == 1 && p.tagName.toUpperCase() != 'HTML'){
  247. pn.unshift(p);
  248. }
  249. var cn = hnode;
  250. for(var i = 0, len = pn.length; i < len; i++){
  251. cn.expand();
  252. cn = cn.findChild('htmlNode', pn[i]);
  253. if(!cn){ // in this dialog?
  254. return false;
  255. }
  256. }
  257. cn.select();
  258. var a = cn.ui.anchor;
  259. this.getTreeEl().dom.scrollTop = Math.max(0 ,a.offsetTop-10);
  260. //treeEl.dom.scrollLeft = Math.max(0 ,a.offsetLeft-10); no likey
  261. cn.highlight();
  262. return true;
  263. }
  264. function nodeTitle(n){
  265. var s = n.tagName;
  266. if(n.id){
  267. s += '#'+n.id;
  268. }else if(n.className){
  269. s += '.'+n.className;
  270. }
  271. return s;
  272. }
  273. /*
  274. function onNodeSelect(t, n, last){
  275. return;
  276. if(last && last.unframe){
  277. last.unframe();
  278. }
  279. var props = {};
  280. if(n && n.htmlNode){
  281. if(frameEl.pressed){
  282. n.frame();
  283. }
  284. if(inspecting){
  285. return;
  286. }
  287. addStyle.enable();
  288. reload.setDisabled(n.leaf);
  289. var dom = n.htmlNode;
  290. stylePanel.setTitle(nodeTitle(dom));
  291. if(styles && !showAll.pressed){
  292. var s = dom.style ? dom.style.cssText : '';
  293. if(s){
  294. var m;
  295. while ((m = styleRe.exec(s)) != null){
  296. props[m[1].toLowerCase()] = m[2];
  297. }
  298. }
  299. }else if(styles){
  300. var cl = Ext.debug.cssList;
  301. var s = dom.style, fly = Ext.fly(dom);
  302. if(s){
  303. for(var i = 0, len = cl.length; i<len; i++){
  304. var st = cl[i];
  305. var v = s[st] || fly.getStyle(st);
  306. if(v != undefined && v !== null && v !== ''){
  307. props[st] = v;
  308. }
  309. }
  310. }
  311. }else{
  312. for(var a in dom){
  313. var v = dom[a];
  314. if((isNaN(a+10)) && v != undefined && v !== null && v !== '' && !(Ext.isGecko && a[0] == a[0].toUpperCase())){
  315. props[a] = v;
  316. }
  317. }
  318. }
  319. }else{
  320. if(inspecting){
  321. return;
  322. }
  323. addStyle.disable();
  324. reload.disabled();
  325. }
  326. stylesGrid.setSource(props);
  327. stylesGrid.treeNode = n;
  328. stylesGrid.view.fitColumns();
  329. }
  330. */
  331. this.loader = new Ext.tree.TreeLoader();
  332. this.loader.load = function(n, cb){
  333. var isBody = n.htmlNode == document.body;
  334. var cn = n.htmlNode.childNodes;
  335. for(var i = 0, c; c = cn[i]; i++){
  336. if(isBody && c.id == 'x-debug-browser'){
  337. continue;
  338. }
  339. if(c.nodeType == 1){
  340. n.appendChild(new Ext.debug.HtmlNode(c));
  341. }else if(c.nodeType == 3 && !nonSpace.test(c.nodeValue)){
  342. n.appendChild(new Ext.tree.TreeNode({
  343. text:'<em>' + ellipsis(html(String(c.nodeValue)), 35) + '</em>',
  344. cls: 'x-tree-noicon'
  345. }));
  346. }
  347. }
  348. cb();
  349. };
  350. //tree.getSelectionModel().on('selectionchange', onNodeSelect, null, {buffer:250});
  351. this.root = this.setRootNode(new Ext.tree.TreeNode('Ext'));
  352. hnode = this.root.appendChild(new Ext.debug.HtmlNode(
  353. document.getElementsByTagName('html')[0]
  354. ));
  355. }
  356. });
  357. Ext.debug.ComponentNodeUI = Ext.extend(Ext.tree.TreeNodeUI,{
  358. onOver : function(e){
  359. Ext.debug.ComponentNodeUI.superclass.onOver.call(this);
  360. var cmp = this.node.attributes.component;
  361. if (cmp.el && cmp.el.mask && cmp.id !='x-debug-browser') {
  362. try { // Oddly bombs on some elements in IE, gets any we care about though
  363. cmp.el.mask();
  364. } catch(e) {}
  365. }
  366. },
  367. onOut : function(e){
  368. Ext.debug.ComponentNodeUI.superclass.onOut.call(this);
  369. var cmp = this.node.attributes.component;
  370. if (cmp.el && cmp.el.unmask && cmp.id !='x-debug-browser') {
  371. try {
  372. cmp.el.unmask();
  373. } catch(e) {}
  374. }
  375. }
  376. });
  377. Ext.debug.ComponentInspector = Ext.extend(Ext.tree.TreePanel, {
  378. enableDD:false ,
  379. lines:false,
  380. rootVisible:false,
  381. animate:false,
  382. hlColor:'ffff9c',
  383. autoScroll: true,
  384. region:'center',
  385. border:false,
  386. initComponent : function(){
  387. this.loader = new Ext.tree.TreeLoader();
  388. this.bbar = new Ext.Toolbar([{
  389. text: 'Refresh',
  390. handler: this.refresh,
  391. scope: this
  392. }]);
  393. Ext.debug.ComponentInspector.superclass.initComponent.call(this);
  394. this.root = this.setRootNode(new Ext.tree.TreeNode({
  395. text: 'Ext Components',
  396. component: Ext.ComponentMgr.all,
  397. leaf: false
  398. }));
  399. this.parseRootNode();
  400. this.on('click', this.onClick, this);
  401. },
  402. createNode: function(n,c) {
  403. var leaf = (c.items && c.items.length > 0);
  404. return n.appendChild(new Ext.tree.TreeNode({
  405. text: c.id + (c.getXType() ? ' [ ' + c.getXType() + ' ]': '' ),
  406. component: c,
  407. uiProvider:Ext.debug.ComponentNodeUI,
  408. leaf: !leaf
  409. }));
  410. },
  411. parseChildItems: function(n) {
  412. var cn = n.attributes.component.items;
  413. if (cn) {
  414. for (var i = 0;i < cn.length; i++) {
  415. var c = cn.get(i);
  416. if (c.id != this.id && c.id != this.bottomToolbar.id) {
  417. var newNode = this.createNode(n,c);
  418. if (!newNode.leaf) {
  419. this.parseChildItems(newNode);
  420. }
  421. }
  422. }
  423. }
  424. },
  425. parseRootNode: function() {
  426. var n = this.root;
  427. var cn = n.attributes.component.items;
  428. for (var i = 0,c;c = cn[i];i++) {
  429. if (c.id != this.id && c.id != this.bottomToolbar.id) {
  430. if (!c.ownerCt) {
  431. var newNode = this.createNode(n,c);
  432. if (!newNode.leaf) {
  433. this.parseChildItems(newNode);
  434. }
  435. }
  436. }
  437. }
  438. },
  439. onClick: function(node, e) {
  440. var oi = Ext.getCmp('x-debug-objinspector');
  441. oi.refreshNodes(node.attributes.component);
  442. oi.ownerCt.show();
  443. },
  444. refresh: function() {
  445. while (this.root.firstChild) {
  446. this.root.removeChild(this.root.firstChild);
  447. }
  448. this.parseRootNode();
  449. var ci = Ext.getCmp('x-debug-compinfo');
  450. if (ci) {
  451. ci.message('refreshed component tree - '+Ext.ComponentMgr.all.length);
  452. }
  453. }
  454. });
  455. Ext.debug.ComponentInfoPanel = Ext.extend(Ext.Panel,{
  456. id:'x-debug-compinfo',
  457. region: 'east',
  458. minWidth: 200,
  459. split: true,
  460. width: 350,
  461. border: false,
  462. autoScroll: true,
  463. layout:'anchor',
  464. style:'border-width:0 0 0 1px;',
  465. initComponent: function() {
  466. this.watchBox = new Ext.form.Checkbox({
  467. id: 'x-debug-watchcomp',
  468. boxLabel: 'Watch ComponentMgr',
  469. listeners: {
  470. check: function(cb, val) {
  471. if (val) {
  472. Ext.ComponentMgr.all.on('add', this.onAdd, this);
  473. Ext.ComponentMgr.all.on('remove', this.onRemove, this);
  474. } else {
  475. Ext.ComponentMgr.all.un('add', this.onAdd, this);
  476. Ext.ComponentMgr.all.un('remove', this.onRemove, this);
  477. }
  478. },
  479. scope: this
  480. }
  481. });
  482. this.tbar = new Ext.Toolbar([{
  483. text: 'Clear',
  484. handler: this.clear,
  485. scope: this
  486. },'->',this.watchBox
  487. ]);
  488. Ext.debug.ComponentInfoPanel.superclass.initComponent.call(this);
  489. },
  490. onAdd: function(i, o, key) {
  491. var markup = ['<div style="padding:5px !important;border-bottom:1px solid #ccc;">',
  492. 'Added: '+o.id,
  493. '</div>'].join('');
  494. this.insertMarkup(markup);
  495. },
  496. onRemove: function(o, key) {
  497. var markup = ['<div style="padding:5px !important;border-bottom:1px solid #ccc;">',
  498. 'Removed: '+o.id,
  499. '</div>'].join('');
  500. this.insertMarkup(markup);
  501. },
  502. message: function(msg) {
  503. var markup = ['<div style="padding:5px !important;border-bottom:1px solid #ccc;">',
  504. msg,
  505. '</div>'].join('');
  506. this.insertMarkup(markup);
  507. },
  508. insertMarkup: function(markup) {
  509. this.body.insertHtml('beforeend', markup);
  510. this.body.scrollTo('top', 100000);
  511. },
  512. clear : function(){
  513. this.body.update('');
  514. this.body.dom.scrollTop = 0;
  515. }
  516. });
  517. Ext.debug.ColumnNodeUI = Ext.extend(Ext.tree.TreeNodeUI, {
  518. focus: Ext.emptyFn, // prevent odd scrolling behavior
  519. renderElements : function(n, a, targetNode, bulkRender){
  520. this.indentMarkup = n.parentNode ? n.parentNode.ui.getChildIndent() : '';
  521. var t = n.getOwnerTree();
  522. var cols = t.columns;
  523. var bw = t.borderWidth;
  524. var c = cols[0];
  525. var buf = [
  526. '<li class="x-tree-node"><div ext:tree-node-id="',n.id,'" class="x-tree-node-el x-tree-node-leaf ', a.cls,'">',
  527. '<div class="x-tree-col" style="width:',c.width-bw,'px;">',
  528. '<span class="x-tree-node-indent">',this.indentMarkup,"</span>",
  529. '<img src="', this.emptyIcon, '" class="x-tree-ec-icon x-tree-elbow"/>',
  530. '<img src="', a.icon || this.emptyIcon, '" class="x-tree-node-icon',(a.icon ? " x-tree-node-inline-icon" : ""),(a.iconCls ? " "+a.iconCls : ""),'" unselectable="on"/>',
  531. '<a hidefocus="on" class="x-tree-node-anchor" href="',a.href ? a.href : "#",'" tabIndex="1" ',
  532. a.hrefTarget ? ' target="'+a.hrefTarget+'"' : "", '>',
  533. '<span unselectable="on">', n.text || (c.renderer ? c.renderer(a[c.dataIndex], n, a) : a[c.dataIndex]),"</span></a>",
  534. "</div>"];
  535. for(var i = 1, len = cols.length; i < len; i++){
  536. c = cols[i];
  537. buf.push('<div class="x-tree-col ',(c.cls?c.cls:''),'" style="width:',c.width-bw,'px;">',
  538. '<div class="x-tree-col-text">',(c.renderer ? c.renderer(a[c.dataIndex], n, a) : a[c.dataIndex]),"</div>",
  539. "</div>");
  540. }
  541. buf.push(
  542. '<div class="x-clear"></div></div>',
  543. '<ul class="x-tree-node-ct" style="display:none;"></ul>',
  544. "</li>");
  545. if(bulkRender !== true && n.nextSibling && n.nextSibling.ui.getEl()){
  546. this.wrap = Ext.DomHelper.insertHtml("beforeBegin",
  547. n.nextSibling.ui.getEl(), buf.join(""));
  548. }else{
  549. this.wrap = Ext.DomHelper.insertHtml("beforeEnd", targetNode, buf.join(""));
  550. }
  551. this.elNode = this.wrap.childNodes[0];
  552. this.ctNode = this.wrap.childNodes[1];
  553. var cs = this.elNode.firstChild.childNodes;
  554. this.indentNode = cs[0];
  555. this.ecNode = cs[1];
  556. this.iconNode = cs[2];
  557. this.anchor = cs[3];
  558. this.textNode = cs[3].firstChild;
  559. }
  560. });
  561. Ext.debug.ObjectInspector = Ext.extend(Ext.tree.TreePanel, {
  562. id: 'x-debug-objinspector',
  563. enableDD:false ,
  564. lines:false,
  565. rootVisible:false,
  566. animate:false,
  567. hlColor:'ffff9c',
  568. autoScroll: true,
  569. region:'center',
  570. border:false,
  571. lines:false,
  572. borderWidth: Ext.isBorderBox ? 0 : 2, // the combined left/right border for each cell
  573. cls:'x-column-tree',
  574. initComponent : function(){
  575. this.showFunc = false;
  576. this.toggleFunc = function() {
  577. this.showFunc = !this.showFunc;
  578. this.refreshNodes(this.currentObject);
  579. };
  580. this.bbar = new Ext.Toolbar([{
  581. text: 'Show Functions',
  582. enableToggle: true,
  583. pressed: false,
  584. handler: this.toggleFunc,
  585. scope: this
  586. }]);
  587. Ext.apply(this,{
  588. title: ' ',
  589. loader: new Ext.tree.TreeLoader(),
  590. columns:[{
  591. header:'Property',
  592. width: 300,
  593. dataIndex:'name'
  594. },{
  595. header:'Value',
  596. width: 900,
  597. dataIndex:'value'
  598. }]
  599. });
  600. Ext.debug.ObjectInspector.superclass.initComponent.call(this);
  601. this.root = this.setRootNode(new Ext.tree.TreeNode({
  602. text: 'Dummy Node',
  603. leaf: false
  604. }));
  605. if (this.currentObject) {
  606. this.parseNodes();
  607. }
  608. },
  609. refreshNodes: function(newObj) {
  610. this.currentObject = newObj;
  611. var node = this.root;
  612. while(node.firstChild){
  613. node.removeChild(node.firstChild);
  614. }
  615. this.parseNodes();
  616. },
  617. parseNodes: function() {
  618. for (var o in this.currentObject) {
  619. if (!this.showFunc) {
  620. if (Ext.isFunction(this.currentObject[o])) {
  621. continue;
  622. }
  623. }
  624. this.createNode(o);
  625. }
  626. },
  627. createNode: function(o) {
  628. return this.root.appendChild(new Ext.tree.TreeNode({
  629. name: o,
  630. value: this.currentObject[o],
  631. uiProvider:Ext.debug.ColumnNodeUI,
  632. iconCls: 'x-debug-node',
  633. leaf: true
  634. }));
  635. },
  636. onRender : function(){
  637. Ext.debug.ObjectInspector.superclass.onRender.apply(this, arguments);
  638. this.headers = this.header.createChild({cls:'x-tree-headers'});
  639. var cols = this.columns, c;
  640. var totalWidth = 0;
  641. for(var i = 0, len = cols.length; i < len; i++){
  642. c = cols[i];
  643. totalWidth += c.width;
  644. this.headers.createChild({
  645. cls:'x-tree-hd ' + (c.cls?c.cls+'-hd':''),
  646. cn: {
  647. cls:'x-tree-hd-text',
  648. html: c.header
  649. },
  650. style:'width:'+(c.width-this.borderWidth)+'px;'
  651. });
  652. }
  653. this.headers.createChild({cls:'x-clear'});
  654. // prevent floats from wrapping when clipped
  655. this.headers.setWidth(totalWidth);
  656. this.innerCt.setWidth(totalWidth);
  657. }
  658. });
  659. Ext.debug.StoreInspector = Ext.extend(Ext.tree.TreePanel, {
  660. enableDD:false ,
  661. lines:false,
  662. rootVisible:false,
  663. animate:false,
  664. hlColor:'ffff9c',
  665. autoScroll: true,
  666. region:'center',
  667. border:false,
  668. initComponent: function() {
  669. this.bbar = new Ext.Toolbar([{
  670. text: 'Refresh',
  671. handler: this.refresh,
  672. scope: this
  673. }]);
  674. Ext.debug.StoreInspector.superclass.initComponent.call(this);
  675. this.root = this.setRootNode(new Ext.tree.TreeNode({
  676. text: 'Data Stores',
  677. leaf: false
  678. }));
  679. this.on('click', this.onClick, this);
  680. this.parseStores();
  681. },
  682. parseStores: function() {
  683. var cn = Ext.StoreMgr.items;
  684. for (var i = 0,c;c = cn[i];i++) {
  685. this.root.appendChild({
  686. text: c.storeId + ' - ' + c.totalLength + ' records',
  687. component: c,
  688. leaf: true
  689. });
  690. }
  691. },
  692. onClick: function(node, e) {
  693. var oi = Ext.getCmp('x-debug-objinspector');
  694. oi.refreshNodes(node.attributes.component);
  695. oi.ownerCt.show();
  696. },
  697. refresh: function() {
  698. while (this.root.firstChild) {
  699. this.root.removeChild(this.root.firstChild);
  700. }
  701. this.parseStores();
  702. }
  703. });
  704. // highly unusual class declaration
  705. Ext.debug.HtmlNode = function(){
  706. var html = Ext.util.Format.htmlEncode;
  707. var ellipsis = Ext.util.Format.ellipsis;
  708. var nonSpace = /^\s*$/;
  709. var attrs = [
  710. {n: 'id', v: 'id'},
  711. {n: 'className', v: 'class'},
  712. {n: 'name', v: 'name'},
  713. {n: 'type', v: 'type'},
  714. {n: 'src', v: 'src'},
  715. {n: 'href', v: 'href'}
  716. ];
  717. function hasChild(n){
  718. for(var i = 0, c; c = n.childNodes[i]; i++){
  719. if(c.nodeType == 1){
  720. return true;
  721. }
  722. }
  723. return false;
  724. }
  725. function renderNode(n, leaf){
  726. var tag = n.tagName.toLowerCase();
  727. var s = '&lt;' + tag;
  728. for(var i = 0, len = attrs.length; i < len; i++){
  729. var a = attrs[i];
  730. var v = n[a.n];
  731. if(v && !nonSpace.test(v)){
  732. s += ' ' + a.v + '=&quot;<i>' + html(v) +'</i>&quot;';
  733. }
  734. }
  735. var style = n.style ? n.style.cssText : '';
  736. if(style){
  737. s += ' style=&quot;<i>' + html(style.toLowerCase()) +'</i>&quot;';
  738. }
  739. if(leaf && n.childNodes.length > 0){
  740. s+='&gt;<em>' + ellipsis(html(String(n.innerHTML)), 35) + '</em>&lt;/'+tag+'&gt;';
  741. }else if(leaf){
  742. s += ' /&gt;';
  743. }else{
  744. s += '&gt;';
  745. }
  746. return s;
  747. }
  748. var HtmlNode = function(n){
  749. var leaf = !hasChild(n);
  750. this.htmlNode = n;
  751. this.tagName = n.tagName.toLowerCase();
  752. var attr = {
  753. text : renderNode(n, leaf),
  754. leaf : leaf,
  755. cls: 'x-tree-noicon'
  756. };
  757. HtmlNode.superclass.constructor.call(this, attr);
  758. this.attributes.htmlNode = n; // for searching
  759. if(!leaf){
  760. this.on('expand', this.onExpand, this);
  761. this.on('collapse', this.onCollapse, this);
  762. }
  763. };
  764. Ext.extend(HtmlNode, Ext.tree.AsyncTreeNode, {
  765. cls: 'x-tree-noicon',
  766. preventHScroll: true,
  767. refresh : function(highlight){
  768. var leaf = !hasChild(this.htmlNode);
  769. this.setText(renderNode(this.htmlNode, leaf));
  770. if(highlight){
  771. Ext.fly(this.ui.textNode).highlight();
  772. }
  773. },
  774. onExpand : function(){
  775. if(!this.closeNode && this.parentNode){
  776. this.closeNode = this.parentNode.insertBefore(new Ext.tree.TreeNode({
  777. text:'&lt;/' + this.tagName + '&gt;',
  778. cls: 'x-tree-noicon'
  779. }), this.nextSibling);
  780. }else if(this.closeNode){
  781. this.closeNode.ui.show();
  782. }
  783. },
  784. onCollapse : function(){
  785. if(this.closeNode){
  786. this.closeNode.ui.hide();
  787. }
  788. },
  789. render : function(bulkRender){
  790. HtmlNode.superclass.render.call(this, bulkRender);
  791. },
  792. highlightNode : function(){
  793. //Ext.fly(this.htmlNode).highlight();
  794. },
  795. highlight : function(){
  796. //Ext.fly(this.ui.textNode).highlight();
  797. },
  798. frame : function(){
  799. this.htmlNode.style.border = '1px solid #0000ff';
  800. //this.highlightNode();
  801. },
  802. unframe : function(){
  803. //Ext.fly(this.htmlNode).removeClass('x-debug-frame');
  804. this.htmlNode.style.border = '';
  805. }
  806. });
  807. return HtmlNode;
  808. }();</pre>
  809. </body>
  810. </html>