InterJinn

Development Framework For PHP

interJinnJavaScript
Class JinnOutputDebugger (EXPERIMENTAL)

public class JinnOutputDebugger
extends JinnBaseClass

Implements a window for writing debug information via the debug() method of the JinnBaseClass and subsequently any subclasses. To see the Output Debugger in action you can move your mouse over and click on the following links:

Test Link 1
Test Link 2
Test Link 3
Test Link 4

Printing on the debugger window from within your own class objects (presuming they extend JinnBaseClass or a subclass of it) is as simple as the following:

this.debug'A line of text to print on the debugger window!' );

Text can include HTML markup. Only one debugger is ever generated for a given loaded page; however, multiple output debuggers can exist when multiple pages are loaded.

Direct Known Subclasses

Method Summary
public JinnOutputDebugger( )

Class constructor.
public assignHandlers( )

Registeres event handlers.
public clear( )

Clears the output window.
public close( )

Clears the output window.
public debug( string   content )

Attempts to echo the given content to the output debugger window.
public array getWindowSpecs( )

This function returns the default window configuration for the output debugger window.
public jinnit( )

Class constructor.
public scrollToBottom( )

Scrolls the output debugger window to the bottom.
public scrollToTop( )

Scrolls the output debugger window to the top.
public write( string   content )

Attempts to echo the given content to the output debugger window.

Methods Inherited from JinnBaseClass
JinnBaseClass , asFloat , asInt , augmentEvent , debug , defaultForNaN , defaultValue , destroy , getArgsPunter , getClassName , getDataType , getDocument , getDocumentBody , getDocumentHead , getElement , getElementStyle , getImageBase , getInterJinnVar , getInterJinnVars , getLibrary , getPageBase , getPageRoot , getPrintData , getPrintDataPrimitive , getScreenHeight , getScreenWidth , getService , getSize , getTime , getUid , getUniqueId , getUrl , getUrlAbsolute , getUrlVar , getWindow , getWindowHeight , getWindowScrollX , getWindowScrollY , getWindowViewMaxX , getWindowViewMaxY , getWindowViewMinX , getWindowViewMinY , getWindowWidth , isDestroyed , isWindowClosed , isWindowOpen , isset , jinnfo , jinnit , libraryExists , localizeImage , localizePage , localizePath , maxValue , minValue , normalizePath , numberFormat , objectHandler , printData , rand , redirect , rgbToHex , serviceExists , setInterJinnVar , setWindow , shallowCopy , signalHandler , sprintf , trim , urlencode  

Method Details
JinnOutputDebugger

public JinnOutputDebugger ( )

Since:
0.9.3

Class constructor. This contains the general layout of the output debugger window. So if you want a different look and feel you can extend this class and assign your own htmlTemplate property that defines your desired look and feel.

Source Code
function JinnOutputDebugger()
{
   
this.jinnit();
}
/*

assignHandlers

public assignHandlers ( )

Since:
0.9.3

Registeres event handlers.

Source Code
JinnOutputDebugger_proto.assignHandlers = function()
{
    var 
element null;

    if( (
element this.getElement'topMenuScrollToBottom' )) )
    {
       
element.onclick =
           
this.objectHandlerthisthis.scrollToBottom );
    }

    if( (
element this.getElement'topMenuClear' )) )
    {
       
element.onclick =
           
this.objectHandlerthisthis.clear );
    }

    if( (
element this.getElement'topMenuWindowClose' )) )
    {
       
element.onclick =
           
this.objectHandlerthisthis.close );
    }

    if( (
element this.getElement'bottomMenuScrollToTop' )) )
    {
       
element.onclick =
           
this.objectHandlerthisthis.scrollToTop );
    }

    if( (
element this.getElement'bottomMenuClear' )) )
    {
       
element.onclick =
           
this.objectHandlerthisthis.clear );
    }

    if( (
element this.getElement'bottomMenuWindowClose' )) )
    {
       
element.onclick =
           
this.objectHandlerthisthis.close );
    }
}
/*

clear

public clear ( )

Since:
0.9.3

Clears the output window.

Source Code
JinnOutputDebugger_proto.clear = function()
{
   
pad this.getElement'content' );
   
pad.innerHTML '';

   
this.content = new Array();
   
this.debug'' );
   
this.scrollToTop();

    return 
false;
}
/*

close

public close ( )

Since:
0.9.3

Clears the output window.

Source Code
JinnOutputDebugger_proto.close = function()
{
   
this.getWindow().close();

    return 
false;
}
/*

debug

public debug
(
     string      content
)


Parameters:
content - The content to be printed on the window.

Since:
0.9.3

Attempts to echo the given content to the output debugger window. if the window does not currently exist or has previously been closed then it will be opened.

Source Code
JinnOutputDebugger_proto.debug = function( content )
{
   
this.writecontent '<br />' );
}
/*

getWindowSpecs

public array getWindowSpecs ( )

Returns:
An array of window configuration settings.

Since:
0.9.3

This function returns the default window configuration for the output debugger window. The values are the same as those defined for the open() method of the standard DOM Window object.

Source Code
JinnOutputDebugger_proto.getWindowSpecs = function()
{
    var 
specs = new Array();

   
specs['width']          = 0.6 this.getScreenWidth();
   
specs['height']         = 0.6 this.getScreenHeight();
   
specs['directories']    = 'no';
   
specs['location']       = 'no';
   
specs['menubar']        = 'no';
   
specs['status']         = 'no';
   
specs['titlebar']       = 'yes';
   
specs['toolbar']        = 'no';
   
specs['scrollbars']     = 'yes';

    return 
specs;
}
/*

jinnit

public jinnit ( )

Since:
0.9.3

Class constructor. This contains the general layout of the output debugger window. So if you want a different look and feel you can extend this class and assign your own htmlTemplate property that defines your desired look and feel.

Source Code
JinnOutputDebugger_proto.jinnit = function()
{
   
JinnOutputDebugger.superjinn.jinnit.callthis );

   
this.windowExists false;
   
this.content      = new Array();
   
this.opening      false;
   
this.windowUid    'JinnOutputDebugger_' this.getUniqueId();

   
this.htmlTemplate =
       
'<html>'
     
'<head>'
     
'<scr' 'ipt type="text/javascript">' "\n"
     
'<' '!--//--' '><' '![' 'CDATA[//><' '!--' "\n"
     
'window ? (window.interJinnSkipUserJavaScript = true) : false;' "\n"
     
'//--' '><' '!]' ']>' "\n"
     
'</' 'script>'
     
'<style type="text/css">'
     
'<!--'
     
'' // ----------------------------------------------------------------
     
'body, h1, h2, h3, p, font, table, td, th, ul, ol, textarea, input, form, blockquote, select'
     
'{'
     
'    font-family: arial, helvetica, sans-serif;'
     
'    font-size: 12px;'
     
'}'
     
''
     
'body'
     
'{'
     
'    background: #fffff4;'
     
'    margin-bottom: 2px;'
     
'}'
     
''
     
'h1.details'
     
'{'
     
'    color: #000000;'
     
'    font-size: 14px;'
     
'    margin-left: 0px;'
     
'    margin-bottom: 2px;'
     
'}'
     
'' // ----------------------------------------------------------------
     
'table.layout'
     
'{'
     
'    width: 100%;'
     
'    padding: 5px;'
     
'    background: transparent;'
     
'}'
     
''
     
'table.details'
     
'{'
     
'    width: 100%;'
     
'    padding: 0px;'
     
'    background: transparent;'
     
'}'
     
''
     
'table.border'
     
'{'
     
'    width: 100%;'
     
'    padding: 0px;'
     
'    background: #554400;'
     
'}'
     
''
     
'table.data'
     
'{'
     
'    width: 100%;'
     
'    padding: 0px;'
     
'    background: #dddddd;'
     
'}'
     
'' // ----------------------------------------------------------------
     
'.content'
     
'{'
     
'    background: #ffffff;'
     
'    color: #000000;'
     
'    padding: 8px;'
     
'    font-size: 12px;'
     
'    text-align: left;'
     
'    white-space: nowrap;'
     
'}'
     
''
     
'.denote'
     
'{'
     
'    color: #ffffff;'
     
'    font-size: 10px;'
     
'    font-weight: bold;'
     
'    padding-left: 10px;'
     
'}'
     
''
     
'.small'
     
'{'
     
'    font-size: 8px;'
     
'}'
     
''
     
'.big'
     
'{'
     
'    font-size: 12px;'
     
'}'
     
''
     
'.success'
     
'{'
     
'    color: #009900;'
     
'}'
     
''
     
'.error'
     
'{'
     
'    color: #990000;'
     
'}'
     
'' // ----------------------------------------------------------------
     
'a:active'
     
'{'
     
'    color: #554400;'
     
'    font-size: 10px;'
     
'    text-decoration: none;'
     
'}'
     
'a:focus'
     
'{'
     
'    color: #554400;'
     
'    font-size: 10px;'
     
'    text-decoration: none;'
     
'}'
     
'a:hover'
     
'{'
     
'    color: #554400;'
     
'    font-size: 10px;'
     
'    text-decoration: none;'
     
'}'
     
'a:link'
     
'{'
     
'    color: #554400;'
     
'    font-size: 10px;'
     
'    text-decoration: none;'
     
'}'
     
'a:visited'
     
'{'
     
'    color: #554400;'
     
'    font-size: 10px;'
     
'    text-decoration: none;'
     
'}'
     
'' // ----------------------------------------------------------------
     
'span.action'
     
'{'
     
'    color: #554400;'
     
'    font-size: 12px;'
     
'    text-decoration: none;'
     
'    margin-bottom: 2px;'
     
'}'
     
'span.action:active'
     
'{'
     
'    color: #554400;'
     
'    font-size: 12px;'
     
'    text-decoration: none;'
     
'    margin-bottom: 2px;'
     
'}'
     
'span.action:focus'
     
'{'
     
'    color: #554400;'
     
'    font-size: 12px;'
     
'    text-decoration: none;'
     
'    margin-bottom: 2px;'
     
'}'
     
'span.action:hover'
     
'{'
     
'    color: #554400;'
     
'    font-size: 12px;'
     
'    text-decoration: underline;'
     
'    margin-bottom: 2px;'
     
'}'
     
'span.action:link'
     
'{'
     
'    color: #554400;'
     
'    font-size: 12px;'
     
'    text-decoration: none;'
     
'    margin-bottom: 2px;'
     
'}'
     
'span.action:visited'
     
'{'
     
'    color: #554400;'
     
'    font-size: 12px;'
     
'    text-decoration: none;'
     
'    margin-bottom: 2px;'
     
'}'
     
'' // ----------------------------------------------------------------
     
'-->'
     
'</style>'
     
'</head>'
     
'<body>'
     
'<div id="interJinnSkipUserJavaScript"></div>'
     
'<div align="left">'

     
'<table class="layout" cellspacing="0">'
     
'<tr>'
     
'<td align="left">'

     
'<table class="details" cellspacing="0">'
     
'<tr>'
     
'<td align="left">'
     
'<h1 class="details">'
     
'Output Debugger'
     
'</h1>'
     
'</td>'
     
'</tr>'
     
'</table>'

     
'<table class="controls" cellspacing="0">'
     
'<tr>'
     
'<td align="left">'
     
'<span id="topControls">'
     
'<table border="0" cellspacing="0" cellpadding="0">'
     
'<tr>'
     
'<td>'
     
'<span class="action" id="topMenuScrollToBottom">'
     
'Bottom'
     
'</span>'
     
'&nbsp;&nbsp;|&nbsp;&nbsp;'
     
'<span class="action" id="topMenuClear">'
     
'Clear'
     
'</span>'
     
'&nbsp;&nbsp;|&nbsp;&nbsp;'
     
'<span class="action" id="topMenuWindowClose">'
     
'Close'
     
'</span>'
     
'</td>'
     
'</tr>'
     
'</table>'
     
'</span>'
     
'</td>'
     
'</tr>'
     
'</table>'

     
'<table class="border" cellspacing="0">'
     
'<tr>'
     
'<td>'
     
'<table id="details" class="data" cellspacing="0">'
     
'<tr>'
     
'<td>'
     
'<pre class="content">'
     
'<span id="content">'
     
'</span>'
     
'</pre>'
     
'</td>'
     
'</tr>'
     
'</table>'
     
'</td>'
     
'</tr>'
     
'</table>'

     
'<table class="details" cellspacing="0">'
     
'<tr>'
     
'<td align="left">'
     
'<span id="bottomControls">'
     
'<table border="0" cellspacing="0" cellpadding="0">'
     
'<tr>'
     
'<td>'
     
'<span class="action" id="bottomMenuScrollToTop">'
     
'Top'
     
'</span>'
     
'&nbsp;&nbsp;|&nbsp;&nbsp;'
     
'<span class="action" id="bottomMenuClear">'
     
'Clear'
     
'</span>'
     
'&nbsp;&nbsp;|&nbsp;&nbsp;'
     
'<span class="action" id="bottomMenuWindowClose">'
     
'Close'
     
'</span>'
     
'</td>'
     
'</tr>'
     
'</table>'
     
'</span>'
     
'</td>'
     
'</tr>'
     
'</table>'

     
'</td>'
     
'</tr>'
     
'</table>'

     
'</div>'
     
'</body>'
     
'</html>';
}
/*

scrollToBottom

public scrollToBottom ( )

Since:
0.9.3

Scrolls the output debugger window to the bottom.

Source Code
JinnOutputDebugger_proto.scrollToBottom = function()
{
   
this.getWindow().scrollBy01000000000 );

    return 
false;
}
/*

scrollToTop

public scrollToTop ( )

Since:
0.9.3

Scrolls the output debugger window to the top.

Source Code
JinnOutputDebugger_proto.scrollToTop = function()
{
   
this.getWindow().scrollBy0, -1000000000 );

    return 
false;
}
/*

write

public write
(
     string      content
)


Parameters:
content - The content to be printed on the window.

Since:
0.9.3

Attempts to echo the given content to the output debugger window. if the window does not currently exist or has previously been closed then it will be opened.

Source Code
JinnOutputDebugger_proto.write = function( content )
{
    var 
opened false;
    var 
rotate false;

    var 
window this.getWindow();

    if( !
this.opening
       
&&
        (!
this.windowExists
         
||
         
window.closed) )
    {
       
this.opening true;
       
this.windowExists true;

       
opened true;

        var 
specs this.getWindowSpecs();
        var 
newSpecs = new Array();
        for( var 
key in specs )
        {
           
newSpecs[newSpecs.length] = key '=' specs[key];
        }

       
window =
           
window.open(
               
''this.windowUidnewSpecs.join',' ) );

        if( 
window )
        {
           
window.document.writethis.htmlTemplate );
           
window.document.close();
           
window.jinnOutputDebugger this;

           
//
            // The following line absolutely must come after the close() call
            // since in Opera this.window.document buggers up and is the wrong
            // document if assigned before the close.
            //
           
this.setWindowwindow );

           
this.assignHandlers();
        }

       
this.opening false;
    }

   
buffer this.content;
   
buffer.pushcontent );
    while( 
buffer.length 500 )
    {
       
buffer.shift();
       
rotate true;
    }

   
window this.getWindow();

    if( 
window )
    {
        try
        {
           
//
            // Gotta use try/catch since stupid opera returns a window object,
            // but then errors out because some internal object isn't
            // initialized due to popup blocking.
            //

           
pad this.getElement'content' );

            if( 
opened )
            {
               
pad.innerHTML =
                   
'<span>'
                 
buffer.join'</span><span>' )
                  + 
'</span>';
            }
            else
            {
                var 
tEntry window.document.createElement'span' );
               
tEntry.innerHTML content;

               
pad.appendChildtEntry );

                if( 
rotate )
                {
                   
pad.removeChildpad.childNodes[0] );
                }
            }

            if( !
opened )
            {
               
this.scrollToBottom();
            }
        }
        catch( 
){}
    }
}
/*