3 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
\r
4 <title>The source code</title>
\r
5 <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
\r
6 <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
\r
8 <body onload="prettyPrint();">
\r
9 <pre class="prettyprint lang-js">Ext.debug = {};
15 function createConsole(){
17 var scriptPanel = new Ext.debug.ScriptsPanel();
18 var logView = new Ext.debug.LogPanel();
19 var tree = new Ext.debug.DomTree();
20 var compInspector = new Ext.debug.ComponentInspector();
21 var compInfoPanel = new Ext.debug.ComponentInfoPanel();
22 var storeInspector = new Ext.debug.StoreInspector();
23 var objInspector = new Ext.debug.ObjectInspector();
25 var tabs = new Ext.TabPanel({
28 tabPosition: 'bottom',
30 title: 'Debug Console',
32 items: [logView, scriptPanel]
34 title: 'HTML Inspector',
38 title: 'Component Inspector',
40 items: [compInspector,compInfoPanel]
42 title: 'Object Inspector',
48 items: [storeInspector]
53 id: 'x-debug-browser',
57 style: 'position:absolute;left:0;bottom:0;z-index:101',
67 Ext.EventManager.removeResizeListener(handleResize);
74 cp.render(Ext.getBody());
76 cp.resizer = new Ext.Resizable(cp.el, {
81 resizeElement : function(){
82 var box = this.proxy.getBox();
84 cp.setHeight(box.height);
89 // function handleResize(){
90 // cp.setWidth(Ext.getBody().getViewSize().width);
92 // Ext.EventManager.onWindowResize(handleResize);
96 function handleResize(){
98 var size = b.getViewSize();
99 if(size.height < b.dom.scrollHeight) {
102 cp.setWidth(size.width);
104 Ext.EventManager.onWindowResize(handleResize);
114 cp.logView.log.apply(cp.logView, arguments);
117 logf : function(format, arg1, arg2, etc){
118 Ext.log(String.format.apply(String, arguments));
122 if(typeof o == 'string' || typeof o == 'number' || typeof o == 'undefined' || Ext.isDate(o)){
126 }else if(typeof o != "object"){
127 Ext.log('Unknown return type');
128 }else if(Ext.isArray(o)){
129 Ext.log('['+o.join(',')+']');
133 var to = typeof o[key];
134 if(to != "function" && to != "object"){
135 b.push(String.format(" {0}: {1},\n", key, o[key]));
140 s = s.substr(0, s.length-2);
148 time : function(name){
149 name = name || "def";
150 Ext._timers[name] = new Date().getTime();
153 timeEnd : function(name, printResults){
154 var t = new Date().getTime();
155 name = name || "def";
156 var v = String.format("{0} ms", t-Ext._timers[name]);
157 Ext._timers[name] = new Date().getTime();
158 if(printResults !== false){
159 Ext.log('Timer ' + (name == "def" ? v : name + ": " + v));
168 Ext.debug.ScriptsPanel = Ext.extend(Ext.Panel, {
169 id:'x-debug-scripts',
176 style:'border-width:0 0 0 1px;',
178 initComponent : function(){
180 this.scriptField = new Ext.form.TextArea({
182 style:'border-width:0;'
185 this.trapBox = new Ext.form.Checkbox({
187 boxLabel: 'Trap Errors',
191 this.toolbar = new Ext.Toolbar([{
194 handler: this.evalScript
205 this.items = [this.toolbar, this.scriptField];
207 Ext.debug.ScriptsPanel.superclass.initComponent.call(this);
210 evalScript : function(){
211 var s = this.scriptField.getValue();
212 if(this.trapBox.getValue()){
215 Ext.dump(rt === undefined? '(no return)' : rt);
217 Ext.log(e.message || e.descript);
221 Ext.dump(rt === undefined? '(no return)' : rt);
226 this.scriptField.setValue('');
227 this.scriptField.focus();
232 Ext.debug.LogPanel = Ext.extend(Ext.Panel, {
236 style:'border-width:0 1px 0 0',
239 var markup = [ '<div style="padding:5px !important;border-bottom:1px solid #ccc;">',
240 Ext.util.Format.htmlEncode(Array.prototype.join.call(arguments, ', ')).replace(/\n/g, '<br/>').replace(/\s/g, ' '),
244 this.body.insertHtml('beforeend', markup);
245 bd.scrollTop = bd.scrollHeight;
249 this.body.update('');
250 this.body.dom.scrollTop = 0;
254 Ext.debug.DomTree = Ext.extend(Ext.tree.TreePanel, {
264 initComponent : function(){
267 Ext.debug.DomTree.superclass.initComponent.call(this);
269 // tree related stuff
270 var styles = false, hnode;
271 var nonSpace = /^\s*$/;
272 var html = Ext.util.Format.htmlEncode;
273 var ellipsis = Ext.util.Format.ellipsis;
274 var styleRe = /\s?([a-z\-]*)\:([^;]*)(?:[;\s\n\r]*)/gi;
276 function findNode(n){
277 if(!n || n.nodeType != 1 || n == document.body || n == document){
281 while((p = p.parentNode) && p.nodeType == 1 && p.tagName.toUpperCase() != 'HTML'){
285 for(var i = 0, len = pn.length; i < len; i++){
287 cn = cn.findChild('htmlNode', pn[i]);
288 if(!cn){ // in this dialog?
293 var a = cn.ui.anchor;
294 this.getTreeEl().dom.scrollTop = Math.max(0 ,a.offsetTop-10);
295 //treeEl.dom.scrollLeft = Math.max(0 ,a.offsetLeft-10); no likey
300 function nodeTitle(n){
304 }else if(n.className){
305 s += '.'+n.className;
311 function onNodeSelect(t, n, last){
313 if(last && last.unframe){
325 reload.setDisabled(n.leaf);
326 var dom = n.htmlNode;
327 stylePanel.setTitle(nodeTitle(dom));
328 if(styles && !showAll.pressed){
329 var s = dom.style ? dom.style.cssText : '';
332 while ((m = styleRe.exec(s)) != null){
333 props[m[1].toLowerCase()] = m[2];
337 var cl = Ext.debug.cssList;
338 var s = dom.style, fly = Ext.fly(dom);
340 for(var i = 0, len = cl.length; i<len; i++){
342 var v = s[st] || fly.getStyle(st);
343 if(v != undefined && v !== null && v !== ''){
351 if((isNaN(a+10)) && v != undefined && v !== null && v !== '' && !(Ext.isGecko && a[0] == a[0].toUpperCase())){
363 stylesGrid.setSource(props);
364 stylesGrid.treeNode = n;
365 stylesGrid.view.fitColumns();
369 this.loader = new Ext.tree.TreeLoader();
370 this.loader.load = function(n, cb){
371 var isBody = n.htmlNode == document.body;
372 var cn = n.htmlNode.childNodes;
373 for(var i = 0, c; c = cn[i]; i++){
374 if(isBody && c.id == 'x-debug-browser'){
378 n.appendChild(new Ext.debug.HtmlNode(c));
379 }else if(c.nodeType == 3 && !nonSpace.test(c.nodeValue)){
380 n.appendChild(new Ext.tree.TreeNode({
381 text:'<em>' + ellipsis(html(String(c.nodeValue)), 35) + '</em>',
389 //tree.getSelectionModel().on('selectionchange', onNodeSelect, null, {buffer:250});
391 this.root = this.setRootNode(new Ext.tree.TreeNode('Ext'));
393 hnode = this.root.appendChild(new Ext.debug.HtmlNode(
394 document.getElementsByTagName('html')[0]
400 Ext.debug.ComponentNodeUI = Ext.extend(Ext.tree.TreeNodeUI,{
401 onOver : function(e){
402 Ext.debug.ComponentNodeUI.superclass.onOver.call(this);
403 var cmp = this.node.attributes.component;
404 if (cmp.el && cmp.el.mask && cmp.id !='x-debug-browser') {
405 try { // Oddly bombs on some elements in IE, gets any we care about though
412 Ext.debug.ComponentNodeUI.superclass.onOut.call(this);
413 var cmp = this.node.attributes.component;
414 if (cmp.el && cmp.el.unmask && cmp.id !='x-debug-browser') {
422 Ext.debug.ComponentInspector = Ext.extend(Ext.tree.TreePanel, {
432 initComponent : function(){
433 this.loader = new Ext.tree.TreeLoader();
434 this.bbar = new Ext.Toolbar([{
436 handler: this.refresh,
439 Ext.debug.ComponentInspector.superclass.initComponent.call(this);
441 this.root = this.setRootNode(new Ext.tree.TreeNode({
442 text: 'Ext Components',
443 component: Ext.ComponentMgr.all,
446 this.parseRootNode();
448 this.on('click', this.onClick, this);
451 createNode: function(n,c) {
452 var leaf = (c.items && c.items.length > 0);
453 return n.appendChild(new Ext.tree.TreeNode({
454 text: c.id + (c.getXType() ? ' [ ' + c.getXType() + ' ]': '' ),
456 uiProvider:Ext.debug.ComponentNodeUI,
461 parseChildItems: function(n) {
462 var cn = n.attributes.component.items;
464 for (var i = 0;i < cn.length; i++) {
466 if (c.id != this.id && c.id != this.bottomToolbar.id) {
467 var newNode = this.createNode(n,c);
469 this.parseChildItems(newNode)
476 parseRootNode: function() {
478 var cn = n.attributes.component.items;
479 for (var i = 0,c;c = cn[i];i++) {
480 if (c.id != this.id && c.id != this.bottomToolbar.id) {
482 var newNode = this.createNode(n,c);
484 this.parseChildItems(newNode);
491 onClick: function(node, e) {
492 var oi = Ext.getCmp('x-debug-objinspector');
493 oi.refreshNodes(node.attributes.component);
497 refresh: function() {
498 while (this.root.firstChild) {
499 this.root.removeChild(this.root.firstChild);
501 this.parseRootNode();
502 var ci = Ext.getCmp('x-debug-compinfo');
504 ci.message('refreshed component tree - '+Ext.ComponentMgr.all.length)
509 Ext.debug.ComponentInfoPanel = Ext.extend(Ext.Panel,{
510 id:'x-debug-compinfo',
518 style:'border-width:0 0 0 1px;',
520 initComponent: function() {
521 this.watchBox = new Ext.form.Checkbox({
522 id: 'x-debug-watchcomp',
523 boxLabel: 'Watch ComponentMgr',
525 check: function(cb, val) {
527 Ext.ComponentMgr.all.on('add', this.onAdd, this);
528 Ext.ComponentMgr.all.on('remove', this.onRemove, this);
530 Ext.ComponentMgr.all.un('add', this.onAdd, this);
531 Ext.ComponentMgr.all.un('remove', this.onRemove, this);
538 this.tbar = new Ext.Toolbar([{
544 Ext.debug.ComponentInfoPanel.superclass.initComponent.call(this);
547 onAdd: function(i, o, key) {
548 var markup = ['<div style="padding:5px !important;border-bottom:1px solid #ccc;">',
551 this.insertMarkup(markup);
554 onRemove: function(o, key) {
555 var markup = ['<div style="padding:5px !important;border-bottom:1px solid #ccc;">',
558 this.insertMarkup(markup);
561 message: function(msg) {
562 var markup = ['<div style="padding:5px !important;border-bottom:1px solid #ccc;">',
565 this.insertMarkup(markup);
567 insertMarkup: function(markup) {
568 this.body.insertHtml('beforeend', markup);
569 this.body.scrollTo('top', 100000);
572 this.body.update('');
573 this.body.dom.scrollTop = 0;
577 Ext.debug.ColumnNodeUI = Ext.extend(Ext.tree.TreeNodeUI, {
578 focus: Ext.emptyFn, // prevent odd scrolling behavior
580 renderElements : function(n, a, targetNode, bulkRender){
581 this.indentMarkup = n.parentNode ? n.parentNode.ui.getChildIndent() : '';
583 var t = n.getOwnerTree();
584 var cols = t.columns;
585 var bw = t.borderWidth;
589 '<li class="x-tree-node"><div ext:tree-node-id="',n.id,'" class="x-tree-node-el x-tree-node-leaf ', a.cls,'">',
590 '<div class="x-tree-col" style="width:',c.width-bw,'px;">',
591 '<span class="x-tree-node-indent">',this.indentMarkup,"</span>",
592 '<img src="', this.emptyIcon, '" class="x-tree-ec-icon x-tree-elbow"/>',
593 '<img src="', a.icon || this.emptyIcon, '" class="x-tree-node-icon',(a.icon ? " x-tree-node-inline-icon" : ""),(a.iconCls ? " "+a.iconCls : ""),'" unselectable="on"/>',
594 '<a hidefocus="on" class="x-tree-node-anchor" href="',a.href ? a.href : "#",'" tabIndex="1" ',
595 a.hrefTarget ? ' target="'+a.hrefTarget+'"' : "", '>',
596 '<span unselectable="on">', n.text || (c.renderer ? c.renderer(a[c.dataIndex], n, a) : a[c.dataIndex]),"</span></a>",
598 for(var i = 1, len = cols.length; i < len; i++){
601 buf.push('<div class="x-tree-col ',(c.cls?c.cls:''),'" style="width:',c.width-bw,'px;">',
602 '<div class="x-tree-col-text">',(c.renderer ? c.renderer(a[c.dataIndex], n, a) : a[c.dataIndex]),"</div>",
606 '<div class="x-clear"></div></div>',
607 '<ul class="x-tree-node-ct" style="display:none;"></ul>',
610 if(bulkRender !== true && n.nextSibling && n.nextSibling.ui.getEl()){
611 this.wrap = Ext.DomHelper.insertHtml("beforeBegin",
612 n.nextSibling.ui.getEl(), buf.join(""));
614 this.wrap = Ext.DomHelper.insertHtml("beforeEnd", targetNode, buf.join(""));
617 this.elNode = this.wrap.childNodes[0];
618 this.ctNode = this.wrap.childNodes[1];
619 var cs = this.elNode.firstChild.childNodes;
620 this.indentNode = cs[0];
622 this.iconNode = cs[2];
624 this.textNode = cs[3].firstChild;
628 Ext.debug.ObjectInspector = Ext.extend(Ext.tree.TreePanel, {
629 id: 'x-debug-objinspector',
639 borderWidth: Ext.isBorderBox ? 0 : 2, // the combined left/right border for each cell
642 initComponent : function(){
643 this.showFunc = false;
644 this.toggleFunc = function() {
645 this.showFunc = !this.showFunc;
646 this.refreshNodes(this.currentObject);
648 this.bbar = new Ext.Toolbar([{
649 text: 'Show Functions',
652 handler: this.toggleFunc,
658 loader: new Ext.tree.TreeLoader(),
670 Ext.debug.ObjectInspector.superclass.initComponent.call(this);
672 this.root = this.setRootNode(new Ext.tree.TreeNode({
677 if (this.currentObject) {
682 refreshNodes: function(newObj) {
683 this.currentObject = newObj;
684 var node = this.root;
685 while(node.firstChild){
686 node.removeChild(node.firstChild);
691 parseNodes: function() {
692 for (var o in this.currentObject) {
693 if (!this.showFunc) {
694 if (Ext.isFunction(this.currentObject[o])) {
702 createNode: function(o) {
703 return this.root.appendChild(new Ext.tree.TreeNode({
705 value: this.currentObject[o],
706 uiProvider:Ext.debug.ColumnNodeUI,
707 iconCls: 'x-debug-node',
712 onRender : function(){
713 Ext.debug.ObjectInspector.superclass.onRender.apply(this, arguments);
714 this.headers = this.header.createChild({cls:'x-tree-headers'});
716 var cols = this.columns, c;
719 for(var i = 0, len = cols.length; i < len; i++){
721 totalWidth += c.width;
722 this.headers.createChild({
723 cls:'x-tree-hd ' + (c.cls?c.cls+'-hd':''),
725 cls:'x-tree-hd-text',
728 style:'width:'+(c.width-this.borderWidth)+'px;'
731 this.headers.createChild({cls:'x-clear'});
732 // prevent floats from wrapping when clipped
733 this.headers.setWidth(totalWidth);
734 this.innerCt.setWidth(totalWidth);
739 Ext.debug.StoreInspector = Ext.extend(Ext.tree.TreePanel, {
749 initComponent: function() {
750 this.bbar = new Ext.Toolbar([{
752 handler: this.refresh,
755 Ext.debug.StoreInspector.superclass.initComponent.call(this);
757 this.root = this.setRootNode(new Ext.tree.TreeNode({
761 this.on('click', this.onClick, this);
766 parseStores: function() {
767 var cn = Ext.StoreMgr.items;
768 for (var i = 0,c;c = cn[i];i++) {
769 this.root.appendChild({
770 text: c.storeId + ' - ' + c.totalLength + ' records',
777 onClick: function(node, e) {
778 var oi = Ext.getCmp('x-debug-objinspector');
779 oi.refreshNodes(node.attributes.component);
783 refresh: function() {
784 while (this.root.firstChild) {
785 this.root.removeChild(this.root.firstChild);
791 // highly unusual class declaration
792 Ext.debug.HtmlNode = function(){
793 var html = Ext.util.Format.htmlEncode;
794 var ellipsis = Ext.util.Format.ellipsis;
795 var nonSpace = /^\s*$/;
799 {n: 'className', v: 'class'},
800 {n: 'name', v: 'name'},
801 {n: 'type', v: 'type'},
802 {n: 'src', v: 'src'},
803 {n: 'href', v: 'href'}
806 function hasChild(n){
807 for(var i = 0, c; c = n.childNodes[i]; i++){
815 function renderNode(n, leaf){
816 var tag = n.tagName.toLowerCase();
817 var s = '<' + tag;
818 for(var i = 0, len = attrs.length; i < len; i++){
821 if(v && !nonSpace.test(v)){
822 s += ' ' + a.v + '="<i>' + html(v) +'</i>"';
825 var style = n.style ? n.style.cssText : '';
827 s += ' style="<i>' + html(style.toLowerCase()) +'</i>"';
829 if(leaf && n.childNodes.length > 0){
830 s+='><em>' + ellipsis(html(String(n.innerHTML)), 35) + '</em></'+tag+'>';
839 var HtmlNode = function(n){
840 var leaf = !hasChild(n);
842 this.tagName = n.tagName.toLowerCase();
844 text : renderNode(n, leaf),
848 HtmlNode.superclass.constructor.call(this, attr);
849 this.attributes.htmlNode = n; // for searching
851 this.on('expand', this.onExpand, this);
852 this.on('collapse', this.onCollapse, this);
857 Ext.extend(HtmlNode, Ext.tree.AsyncTreeNode, {
858 cls: 'x-tree-noicon',
859 preventHScroll: true,
860 refresh : function(highlight){
861 var leaf = !hasChild(this.htmlNode);
862 this.setText(renderNode(this.htmlNode, leaf));
864 Ext.fly(this.ui.textNode).highlight();
868 onExpand : function(){
869 if(!this.closeNode && this.parentNode){
870 this.closeNode = this.parentNode.insertBefore(new Ext.tree.TreeNode({
871 text:'</' + this.tagName + '>',
873 }), this.nextSibling);
874 }else if(this.closeNode){
875 this.closeNode.ui.show();
879 onCollapse : function(){
881 this.closeNode.ui.hide();
885 render : function(bulkRender){
886 HtmlNode.superclass.render.call(this, bulkRender);
889 highlightNode : function(){
890 //Ext.fly(this.htmlNode).highlight();
893 highlight : function(){
894 //Ext.fly(this.ui.textNode).highlight();
898 this.htmlNode.style.border = '1px solid #0000ff';
899 //this.highlightNode();
902 unframe : function(){
903 //Ext.fly(this.htmlNode).removeClass('x-debug-frame');
904 this.htmlNode.style.border = '';