/**
* Copyright (c) 2011
* OJC Technologies
* all rights reserved
* @author: Jake Smith
*
* Useful for debugging output.
*
* REQUIRES JQuery to function properly
*
* Call 'printDebug(string)' to append
* to a designated zone at the bottom of the
* page in a
*
section
*
* Call 'resetStdOut()' to clear the existing
* content
*/
var elementType = 'div';
var classLabel = 'debug';
var debugTag = elementType + '.' + classLabel;
var styling = "border: 2px solid black; padding: 25px; margin: 25px; color: black;";
/*
* clear contents of the output region (after checking its existence)
*/
function resetStdOut() {
if ( $(debugTag).get(0)) {
$(debugTag).empty();
}
}
/*
* Put the string out to the region (after checking the region's existence)
*/
function printDebug(information) {
var stdOut = $(debugTag).get(0);
if( !stdOut ) { // element does not yet exist
stdOut = makeStdOut();
$('body').append(stdOut);
}
var divElem = document.createElement('div');
var textElem = document.createTextNode(information);
divElem.appendChild(textElem);
stdOut.appendChild(divElem);
}
/*
* internal function, creates the output region
*/
function makeStdOut() {
var elem = document.createElement(elementType);
elem.setAttribute('class', classLabel);
elem.setAttribute('style', styling);
return elem;
}