/* log.js
*/
SoftMoon.WebWare.Log=function(output_element, url, useBreak) {
if (output_element && output_element.nodeType===Node.ELEMENT_NODE) this.logElement=output_element;
else {
if (typeof url !== 'string') url="";
var doc= (output_element) ? window.open(url, (typeof output_element == 'string') ? output_element : 'log').document : document;
this.logElement=doc.createElement('pre');
if (doc !== document) doc.body.appendChild(this.logElement)
useBreak=false; }
// if (!this.logElement.hasChildNodes()) this.logElement.appendChild(document.createTextNode(""));
this.timer=false;
if (useBreak) this.lineEnd='<br />\n';
else this.lineEnd="\n"; }
SoftMoon.WebWare.Log.prototype.write=function(text) {
var span=document.createElement('span');
span.appendChild(document.createTextNode(text + this.lineEnd))
this.logElement.appendChild(span);
if (this.timer) clearTimeout(this.timer);
var Logger=this;
this.timer=setTimeout(function() {Logger.logElement.appendChild(document.createTextNode('——————————————————' + Logger.lineEnd));}, 40);
span.scrollIntoView(); }
SoftMoon.WebWare.Log.prototype.clear=function() {
while (this.logElement.hasChildNodes()) {this.logElement.removeChild(this.logElement.firstChild);} }
|