debug.js
来自「php绿色服务器,让大家试用greenamp」· JavaScript 代码 · 共 734 行 · 第 1/2 页
JS
734 行
stylesGrid.setSource(props); stylesGrid.treeNode = n; stylesGrid.view.fitColumns(); } // lets build a list of nodes to filter from the tree // this is gonna be nasty var filterIds = '^(?:'; var eds = stylesGrid.colModel.editors; for(var edType in eds){ filterIds += eds[edType].id +'|'; } Ext.each([dlg.shim? dlg.shim.id : 'noshim', dlg.proxyDrag.id], function(id){ filterIds += id +'|'; }); filterIds += dlg.el.id; filterIds += ')$'; var filterRe = new RegExp(filterIds); var loader = new Ext.tree.TreeLoader(); loader.load = function(n, cb){ var isBody = n.htmlNode == bd.dom; var cn = n.htmlNode.childNodes; for(var i = 0, c; c = cn[i]; i++){ if(isBody && filterRe.test(c.id)){ continue; } if(c.nodeType == 1){ n.appendChild(new Ext.debug.HtmlNode(c)); }else if(c.nodeType == 3 && !nonSpace.test(c.nodeValue)){ n.appendChild(new Ext.tree.TreeNode({ text:'<em>' + ellipsis(html(String(c.nodeValue)), 35) + '</em>', cls: 'x-tree-noicon' })); } } cb(); }; var tree = new Ext.tree.TreePanel(treeEl, { enableDD:false , loader: loader, lines:false, rootVisible:false, animate:false, hlColor:'ffff9c' }); tree.getSelectionModel().on('selectionchange', onNodeSelect, null, {buffer:250}); var root = tree.setRootNode(new Ext.tree.TreeNode('Ext')); hnode = root.appendChild(new Ext.debug.HtmlNode( document.getElementsByTagName('html')[0] )); tree.render(); Ext.debug.console = new Ext.JsonView(clayout.main.getEl(), '<pre><xmp>> {msg}</xmp></pre>'); Ext.debug.console.jsonData = []; Ext.debug.dialog = dlg; }, show : function(){ var d = Ext.debug; if(!d.dialog){ d.init(); } if(!d.dialog.isVisible()){ d.dialog.show(); } }, hide : function(){ if(Ext.debug.dialog){ Ext.debug.dialog.hide(); } }, /** * Debugging function. Prints all arguments to a resizable, movable, scrolling region without * the need to include separate js or css. Double click it to hide it. * @param {Mixed} arg1 * @param {Mixed} arg2 * @param {Mixed} etc * @method print */ log : function(arg1, arg2, etc){ Ext.debug.show(); var m = ""; for(var i = 0, len = arguments.length; i < len; i++){ m += (i == 0 ? "" : ", ") + arguments[i]; } var cn = Ext.debug.console; cn.jsonData.unshift({msg: m}); cn.refresh(); }, /** * Applies the passed C#/DomHelper style format (e.g. "The variable {0} is equal to {1}") before calling Ext.debug.log * @param {String} format * @param {Mixed} arg1 * @param {Mixed} arg2 * @param {Mixed} etc * @method printf */ logf : function(format, arg1, arg2, etc){ Ext.debug.log(String.format.apply(String, arguments)); }, /** * Dumps an object to Ext.debug.log * @param {Object} o * @method dump */ dump : function(o){ if(typeof o == 'string' || typeof o == 'number' || typeof o == 'undefined' || o instanceof Date){ Ext.debug.log(o); }else if(!o){ Ext.debug.log("null"); }else if(typeof o != "object"){ Ext.debug.log('Unknown return type'); }else if(o instanceof Array){ Ext.debug.log('['+o.join(',')+']'); }else{ var b = ["{\n"]; for(var key in o){ var to = typeof o[key]; if(to != "function" && to != "object"){ b.push(String.format(" {0}: {1},\n", key, o[key])); } } var s = b.join(""); if(s.length > 3){ s = s.substr(0, s.length-2); } Ext.debug.log(s + "\n}"); } }, _timers : {}, /** * Starts a timer. * @param {String} name (optional) * @method timer */ time : function(name){ name = name || "def"; Ext._timers[name] = new Date().getTime(); }, /** * Ends a timer, returns the results (formatted "{1} ms") and optionally prints them to Ext.print() * @param {String} name (optional) * @param {Boolean} printResults (optional) false to stop printing the results to Ext.print * @method timerEnd */ timeEnd : function(name, printResults){ var t = new Date().getTime(); name = name || "def"; var v = String.format("{0} ms", t-Ext._timers[name]); Ext._timers[name] = new Date().getTime(); if(printResults !== false){ Ext.debug.log('Timer ' + (name == "def" ? v : name + ": " + v)); } return v; }};// highly unusual class declarationExt.debug.HtmlNode = function(){ var html = Ext.util.Format.htmlEncode; var ellipsis = Ext.util.Format.ellipsis; var nonSpace = /^\s*$/; var attrs = [ {n: 'id', v: 'id'}, {n: 'className', v: 'class'}, {n: 'name', v: 'name'}, {n: 'type', v: 'type'}, {n: 'src', v: 'src'}, {n: 'href', v: 'href'} ]; function hasChild(n){ for(var i = 0, c; c = n.childNodes[i]; i++){ if(c.nodeType == 1){ return true; } } return false; } function renderNode(n, leaf){ var tag = n.tagName.toLowerCase(); var s = '<' + tag; for(var i = 0, len = attrs.length; i < len; i++){ var a = attrs[i]; var v = n[a.n]; if(v && !nonSpace.test(v)){ s += ' ' + a.v + '="<i>' + html(v) +'</i>"'; } } var style = n.style ? n.style.cssText : ''; if(style){ s += ' style="<i>' + html(style.toLowerCase()) +'</i>"'; } if(leaf && n.childNodes.length > 0){ s+='><em>' + ellipsis(html(String(n.innerHTML)), 35) + '</em></'+tag+'>'; }else if(leaf){ s += ' />'; }else{ s += '>'; } return s; } var HtmlNode = function(n){ var leaf = !hasChild(n); this.htmlNode = n; this.tagName = n.tagName.toLowerCase(); var attr = { text : renderNode(n, leaf), leaf : leaf, cls: 'x-tree-noicon' }; HtmlNode.superclass.constructor.call(this, attr); this.attributes.htmlNode = n; // for searching if(!leaf){ this.on('expand', this.onExpand, this); this.on('collapse', this.onCollapse, this); } }; Ext.extend(HtmlNode, Ext.tree.AsyncTreeNode, { cls: 'x-tree-noicon', preventHScroll: true, refresh : function(highlight){ var leaf = !hasChild(this.htmlNode); this.setText(renderNode(this.htmlNode, leaf)); if(highlight){ Ext.fly(this.ui.textNode).highlight(); } }, onExpand : function(){ if(!this.closeNode && this.parentNode){ this.closeNode = this.parentNode.insertBefore(new Ext.tree.TreeNode({ text:'</' + this.tagName + '>', cls: 'x-tree-noicon' }), this.nextSibling); }else if(this.closeNode){ this.closeNode.ui.show(); } }, onCollapse : function(){ if(this.closeNode){ this.closeNode.ui.hide(); } }, render : function(bulkRender){ HtmlNode.superclass.render.call(this, bulkRender); }, highlightNode : function(){ //Ext.fly(this.htmlNode).highlight(); }, highlight : function(){ //Ext.fly(this.ui.textNode).highlight(); }, frame : function(){ this.htmlNode.style.border = '1px solid #0000ff'; //this.highlightNode(); }, unframe : function(){ //Ext.fly(this.htmlNode).removeClass('x-debug-frame'); this.htmlNode.style.border = ''; } }); return HtmlNode;}();// subclass for the standard layout panelsExt.debug.InnerLayout = function(id, w, cfg){ // console layout var el = Ext.DomHelper.append(document.body, {id:id}); var layout = new Ext.BorderLayout(el, { north: { initialSize:28 }, center: { titlebar: false }, east: { split:true, initialSize:w, titlebar:true } }); Ext.debug.InnerLayout.superclass.constructor.call(this, layout, cfg); layout.beginUpdate(); var tbPanel = layout.add('north', new Ext.ContentPanel({ autoCreate:true, fitToFrame:true})); this.main = layout.add('center', new Ext.ContentPanel({ autoCreate:true, fitToFrame:true, autoScroll:true})); this.tbar = new Ext.Toolbar(tbPanel.el); var mtbEl = tbPanel.resizeEl = tbPanel.el.child('div.x-toolbar'); mtbEl.setStyle('border-bottom', '0 none'); layout.endUpdate(true);};Ext.extend(Ext.debug.InnerLayout, Ext.NestedLayoutPanel, { add : function(){ return this.layout.add.apply(this.layout, arguments); }});Ext.debug.cssList = ['background-color','border','border-color','border-spacing','border-style','border-top','border-right','border-bottom','border-left','border-top-color','border-right-color','border-bottom-color','border-left-color','border-top-width','border-right-width','border-bottom-width','border-left-width','border-width','bottom','color','font-size','font-size-adjust','font-stretch','font-style','height','left','letter-spacing','line-height','margin','margin-top','margin-right','margin-bottom','margin-left','marker-offset','max-height','max-width','min-height','min-width','orphans','outline','outline-color','outline-style','outline-width','overflow','padding','padding-top','padding-right','padding-bottom','padding-left','quotes','right','size','text-indent','top','width','word-spacing','z-index','opacity','outline-offset'];if(typeof console == 'undefined'){ console = Ext.debug;}/*if(Ext.isSafari || Ext.isIE || Ext.isOpera){ window.onerror = function(msg, url, line){ Ext.log.apply(Ext, arguments); };}*/// attach shortcut keyExt.EventManager.on(window, 'load', function(){ Ext.get(document).on('keydown', function(e){ if(e.ctrlKey && e.shiftKey && e.getKey() == e.HOME){ Ext.debug.show(); } });});// backwards compatExt.print = Ext.log = Ext.debug.log;Ext.printf = Ext.logf = Ext.debug.logf;Ext.dump = Ext.debug.dump;Ext.timer = Ext.debug.time;Ext.timerEnd = Ext.debug.timeEnd;
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?