portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From smi...@apache.org
Subject svn commit: r578912 - in /portals/jetspeed-2/branches/JETSPEED-2.1.3/src/webapp/javascript/jetspeed: debug.js debug.src.js
Date Mon, 24 Sep 2007 19:10:40 GMT
Author: smilek
Date: Mon Sep 24 12:10:39 2007
New Revision: 578912

URL: http://svn.apache.org/viewvc?rev=578912&view=rev
Log:
moved debugging code out of common.js

Added:
    portals/jetspeed-2/branches/JETSPEED-2.1.3/src/webapp/javascript/jetspeed/debug.js
    portals/jetspeed-2/branches/JETSPEED-2.1.3/src/webapp/javascript/jetspeed/debug.src.js

Added: portals/jetspeed-2/branches/JETSPEED-2.1.3/src/webapp/javascript/jetspeed/debug.js
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/branches/JETSPEED-2.1.3/src/webapp/javascript/jetspeed/debug.js?rev=578912&view=auto
==============================================================================
--- portals/jetspeed-2/branches/JETSPEED-2.1.3/src/webapp/javascript/jetspeed/debug.js (added)
+++ portals/jetspeed-2/branches/JETSPEED-2.1.3/src/webapp/javascript/jetspeed/debug.js Mon
Sep 24 12:10:39 2007
@@ -0,0 +1,169 @@
+if(window.dojo){
+dojo.provide("jetspeed.debug");
+}
+if(!window.jetspeed){
+jetspeed={};
+}
+jetspeed.dumpary=function(_1,_2){
+if(!(_1&&_1.length>=0)){
+return null;
+}
+var _3=jetspeed;
+if(_2){
+_3.println(_2+"  len="+_1.length);
+}
+for(var i=0;i<_1.length;i++){
+_3.println(_3.debugindentH+"["+i+"]: "+_3.printobj(_1[i]));
+}
+};
+jetspeed.printobj=function(_5,_6,_7,_8,_9,_a){
+var _b=[];
+for(var _c in _5){
+try{
+var _d=_5[_c];
+if(_8){
+if(dojo.lang.isArray(_d)){
+_d="["+_d.length+"]";
+}
+}
+if(dojo.lang.isFunction(_d)){
+if(!_9){
+continue;
+}
+if(!_a){
+_d="function";
+}
+}
+_d=_d+"";
+if(!_7||_d.length>0){
+_b.push(_c+": "+_d);
+}
+}
+catch(E){
+_b.push(_c+": ERROR - "+E.message);
+}
+}
+_b.sort();
+var _e="";
+for(var i=0;i<_b.length;i++){
+if(_e.length>0){
+_e+=(_6?", ":"\r\n");
+}
+_e+=_b[i];
+}
+return _e;
+};
+jetspeed.println=function(_10){
+try{
+var _11=jetspeed.getDebugElement();
+var div=document.createElement("div");
+div.appendChild(document.createTextNode(_10));
+_11.appendChild(div);
+}
+catch(e){
+try{
+document.write("<div>"+_10+"</div>");
+}
+catch(e2){
+window.status=_10;
+}
+}
+};
+jetspeed.debugNodeTree=function(_13,_14){
+if(!_13){
+return;
+}
+if(_14){
+if(_14.length>0){
+jetspeed.println(_14);
+}
+}else{
+jetspeed.println("node: ");
+}
+if(_13.nodeType!=1&&_13.nodeType!=3){
+if(_13.length&&_13.length>0&&(_13[0].nodeType==1||_13[0].nodeType==3)){
+for(var i=0;i<_13.length;i++){
+jetspeed.debugNodeTree(_13[i]," ["+i+"]");
+}
+}else{
+jetspeed.println(" node is not a node! "+_13.length);
+}
+return;
+}
+if(_13.innerXML){
+jetspeed.println(_13.innerXML);
+}else{
+if(_13.xml){
+jetspeed.println(_13.xml);
+}else{
+if(typeof XMLSerializer!="undefined"){
+jetspeed.println((new XMLSerializer()).serializeToString(_13));
+}else{
+jetspeed.println(" node != null (IE no XMLSerializer)");
+}
+}
+}
+};
+jetspeed.debugShallow=function(obj,_17){
+if(_17){
+jetspeed.println(_17);
+}else{
+jetspeed.println("Object: "+obj);
+}
+var _18=[];
+for(var _19 in obj){
+try{
+_18.push(_19+": "+obj[_19]);
+}
+catch(E){
+_18.push(_19+": ERROR - "+E.message);
+}
+}
+_18.sort();
+for(var i=0;i<_18.length;i++){
+jetspeed.println(_18[i]);
+}
+};
+jetspeed.getDebugElement=function(_1b){
+var _1c=null;
+var _1d=null;
+try{
+var _1e=jetspeed.debug.debugContainerId;
+_1d=document.getElementById(_1e);
+if(!_1d){
+_1e="debug_container";
+_1d=document.getElementById(_1e);
+if(!_1d){
+_1c=jetspeed.docBody;
+if(_1c==null){
+_1c=jetspeed.getBody();
+}
+_1d=document.createElement("div");
+_1d.setAttribute("id","debug_container");
+_1c.appendChild(_1d);
+}
+}
+if(_1d&&_1b){
+_1d.innerHTML="";
+}
+}
+catch(e){
+try{
+if(_1d==null){
+_1d=jetspeed.getBody();
+}
+}
+catch(e2){
+}
+}
+return _1d;
+};
+if(window.djConfig!=null&&window.djConfig.isDebug){
+var ch=String.fromCharCode(160);
+jetspeed.debugindentch=ch;
+jetspeed.debugindentH=ch+ch;
+jetspeed.debugindent=ch+ch+ch+ch;
+jetspeed.debugindent2=jetspeed.debugindent+jetspeed.debugindent;
+jetspeed.debugindent3=jetspeed.debugindent+jetspeed.debugindent+jetspeed.debugindent;
+}
+

Added: portals/jetspeed-2/branches/JETSPEED-2.1.3/src/webapp/javascript/jetspeed/debug.src.js
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/branches/JETSPEED-2.1.3/src/webapp/javascript/jetspeed/debug.src.js?rev=578912&view=auto
==============================================================================
--- portals/jetspeed-2/branches/JETSPEED-2.1.3/src/webapp/javascript/jetspeed/debug.src.js
(added)
+++ portals/jetspeed-2/branches/JETSPEED-2.1.3/src/webapp/javascript/jetspeed/debug.src.js
Mon Sep 24 12:10:39 2007
@@ -0,0 +1,214 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * author: Steve Milek
+ */
+
+if ( window.dojo )
+{
+    dojo.provide( "jetspeed.debug" );
+}
+
+
+// jetspeed base objects
+
+if ( ! window.jetspeed )
+    jetspeed = {};
+
+
+// common debugging functions
+
+jetspeed.dumpary = function( ary, header )
+{
+    if ( ! ( ary && ary.length >= 0 ) ) return null;
+    var jsObj = jetspeed;
+    if ( header )
+        jsObj.println( header + "  len=" + ary.length );
+    for( var i = 0; i < ary.length; i++ )
+    {
+        jsObj.println( jsObj.debugindentH + "[" + i + "]: " + jsObj.printobj( ary[i] ) );
+    }
+};
+
+jetspeed.printobj = function( obj, omitLineBreaks, omitEmptyValsProperties, arrayLengthsOnly,
showFunctions, showFunctionCode )
+{
+    var props = [];
+    for( var prop in obj )
+    {
+        try
+        {
+            var propVal = obj[prop];
+            if ( arrayLengthsOnly )
+            {
+                if ( dojo.lang.isArray( propVal ) )
+                {
+                    propVal = "[" + propVal.length + "]";
+                }
+            }
+            if ( dojo.lang.isFunction( propVal ) )
+            {
+                if ( ! showFunctions )
+                    continue;
+                if ( ! showFunctionCode )
+                    propVal = "function";
+            }
+            propVal = propVal + "";
+            if ( ! omitEmptyValsProperties || propVal.length > 0 )
+                props.push( prop + ': ' + propVal );
+        }
+        catch(E)
+        {
+            props.push( prop + ': ERROR - ' + E.message );
+        }
+    }
+    props.sort();
+    var buff = "";
+    for( var i = 0; i < props.length; i++ )
+    {
+        if ( buff.length > 0 )
+            buff += ( omitLineBreaks ? ", " : "\r\n" );
+        buff += props[i];
+    }
+    return buff;
+};
+
+jetspeed.println = function( line )
+{
+    try
+    {
+        var console = jetspeed.getDebugElement();
+        var div = document.createElement( "div" );
+        div.appendChild( document.createTextNode( line ) );
+        console.appendChild( div );
+    }
+    catch (e)
+    {
+        try
+        {   // safari needs the output wrapped in an element for some reason
+            document.write("<div>" + line + "</div>");
+        }
+        catch(e2)
+        {
+            window.status = line;
+        }
+    }
+};
+
+jetspeed.debugNodeTree = function( node, string )
+{
+    if ( ! node ) return ;
+    
+    if ( string )
+    {
+        if ( string.length > 0 )
+            jetspeed.println( string );
+    }
+    else
+    {
+        jetspeed.println( 'node: ' );
+    }
+    if ( node.nodeType != 1 && node.nodeType != 3 )
+    {
+        if ( node.length && node.length > 0 && ( node[0].nodeType == 1
|| node[0].nodeType == 3 ) )
+        {
+            for ( var i = 0 ; i < node.length ; i++ )
+            {
+                jetspeed.debugNodeTree( node[i], " [" + i + "]" )
+            }
+        }
+        else
+        {
+            jetspeed.println( " node is not a node! " + node.length );
+        }   
+        return ;
+    }
+    if ( node.innerXML )
+    {
+        jetspeed.println( node.innerXML );
+    }
+    else if ( node.xml )
+    {
+        jetspeed.println( node.xml );
+    }
+    else if ( typeof XMLSerializer != "undefined" )
+    {
+        jetspeed.println( (new XMLSerializer()).serializeToString( node ) );
+    }
+    else
+    {
+        jetspeed.println( " node != null (IE no XMLSerializer)" );
+    }
+};
+jetspeed.debugShallow = function( obj, string )
+{
+    if ( string )
+        jetspeed.println( string );
+    else
+        jetspeed.println( 'Object: ' + obj );
+    var props = [];
+    for(var prop in obj){
+        try {
+            props.push(prop + ': ' + obj[prop]);
+        } catch(E) {
+            props.push(prop + ': ERROR - ' + E.message);
+        }
+    }
+    props.sort();
+    for(var i = 0; i < props.length; i++) {
+        jetspeed.println( props[i] );
+    }
+};
+jetspeed.getDebugElement = function( clear )
+{
+    var docBody = null;
+    var console = null;
+    try {
+        var consoleId = jetspeed.debug.debugContainerId;
+        console = document.getElementById(consoleId);
+        if(!console)
+        {
+            consoleId = "debug_container";
+            console = document.getElementById(consoleId);
+            if(!console)
+            {
+                docBody = jetspeed.docBody;
+                if ( docBody == null )
+                    docBody = jetspeed.getBody();
+                console = document.createElement("div");
+                console.setAttribute( "id", "debug_container" );
+                docBody.appendChild(console);
+            }
+        }
+        if ( console && clear )
+        {
+            console.innerHTML = "";
+        }
+    } catch (e) {
+        try {
+            if ( console == null ) console = jetspeed.getBody();
+        } catch(e2){}
+    }
+    return console;
+};
+if ( window.djConfig != null && window.djConfig.isDebug )
+{
+    var ch = String.fromCharCode(0x00a0);
+    jetspeed.debugindentch = ch;
+    jetspeed.debugindentH = ch + ch;
+    jetspeed.debugindent = ch + ch + ch + ch;
+    jetspeed.debugindent2 = jetspeed.debugindent + jetspeed.debugindent;
+    jetspeed.debugindent3 = jetspeed.debugindent + jetspeed.debugindent + jetspeed.debugindent;
+}



---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-dev-help@portals.apache.org


Mime
View raw message