File: JS_toolbucket/Log.js

Recommend this page to a friend!
  Classes of Joseph   Input Type Picker   JS_toolbucket/Log.js   Download  
File: JS_toolbucket/Log.js
Role: Unit test script
Content type: text/plain
Description: unrelated script
Class: Input Type Picker
Let user choose input values with clicks
Author: By
Last change:
Date: 11 years ago
Size: 1,295 bytes
 

Contents

Class file image Download
/* 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);} }