/* * Copyright(c) 2011 * OJC Technologies * all rights reserved * @author: Jake Smith */ /** * Handy "object" for debugging output. * * to use: * var p = new Printer(); // create object (and binds to variable) * p.print('msg'); // prints the message 'msg' * p.reset(); // delete all mesages, * p.remove(); // remove the element from your page (optional) * p = null; // dismiss the object (optional) */ function Printer() { this.type = 'div'; this.idLabel = 'printeroutputdiv'; this.styling = "border: 2px solid black; padding: 25px; margin: 25px; color: black;"; this.elem = document.createElement(this.type); this.elem.setAttribute('id', this.idLabel); this.elem.setAttribute('style', this.styling); document.body.appendChild(this.elem); this.print = function(message) { var divElem, textElem; textElem = document.createTextNode(message); divElem = document.createElement('div'); divElem.appendChild(textElem); this.elem.appendChild(divElem); } this.reset = function() { var newElem; newElem = document.createElement(this.type); newElem.setAttribute('id', this.idLabel); newElem.setAttribute('style', this.styling); document.body.replaceChild(newElem, this.elem); this.elem = newElem; } this.remove = function() { document.body.removeChild(this.elem); this.elem = null; } }