﻿/* * Copyright (c) 1995-2005 by 4system Polska Sp. z o.o. * All Rights Reserved. */if (typeof(moduleDone)!="undefined") moduleDone("debug.js"); Log = function(){	this.beginDate = new Date();	this.m_debugEnable = false;	this.m_debugShow   = false;	this.showDiff	   = true;	this.showLogTimeOver = 0;	this.m_debugLog    = new Array();	this.m_blockOffset = 0;	this.showError	   = true;	this.showInfo      = true;	this.showWarning   = true;	this.showBegin     = true;	this.showEnd       = true;	this.showBlink     = true;	this.m_mtError     = {"text":"Error", "color":"red"};	this.m_mtInfo      = {"text":"Info", "color":"black"};	this.m_mtWarning   = {"text":"Warning", "color":"blue"};	this.m_mtBegin     = {"text":"Begin", "color":"green"};	this.m_mtEnd       = {"text":"End", "color":"brown"};	this.m_mtBlink     = {"text":"Blink", "color":"purple"};	this.info("Log class - start");}Log.prototype.checkAddMSg = function(type){	switch (type)	{		case 'Error':			return this.showError;			break;		case 'Info':			return this.showInfo;			break;		case 'Warning':			return this.showWarning;			break;		case 'Begin':			return this.showBegin;			break;		case 'End':			return this.showEnd;			break;		case 'Blink':			return this.showBlink;			break;		default:			return true;			break;	}}Log.prototype._msg = function(type, msg, text){	if (!this.m_debugEnable) return;	if (!this.checkAddMSg(type['text'])) return;		//d = d - this.refDate;	var s = "";	var offset = ": ";	var blink = "";	s += "<p style=\"margin: 0px; color:" + type["color"] + ";\">"	for (var i = 0; i < this.m_blockOffset; i++) {		s += "-";		offset = ">: ";	}		var d = new Date();	var diffTime=this.calculateTimeToString(this.beginDate, d);	if (parseInt(diffTime) < this.showLogTimeOver) return;	this.beginDate = new Date();		if (this.showDiff){		s += offset+diffTime+"| ";	}else{		var h = d.getHours();		var m = d.getMinutes();		m = ((m < 10) ? "0" : "") + m;		var sec = d.getSeconds();		sec = ((sec < 10) ? "0" : "") + sec;		var msec = d.getMilliseconds();		msec = ((msec < 10) ? "0" : "") + msec;		//s += "<pre style=\"margin: 0px; color=" + type["color"] + ";\">" + type["text"] + (h + ":" + m + ":" + sec + "." +msec);		s += offset+(h + ":" + m + ":" + sec + "." +msec)+"| ";	}		if (text) {		s += msg + "\r\n<span style='color=#aaaaaa'>" + text + "</span>";//"</pre>";	}else{		s += msg;//+"</pre>";	}	s += "</p>";	if(this.m_debugShow) {		var o = window.open("","WBTAPIDebug","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,left=0,top=0,width=300,height=" + (screen.height - 30));		top.window.moveTo(310, 0);		top.window.resizeTo(screen.width - 310, screen.height - 30);		if (o && this.m_debugLog.length > 0 ) {			for (var i = 0; i < this.m_debugLog.length; i++) {				o.document.write(this.m_debugLog[i]);			}			delete (this.m_debugLog);			this.m_debugLog = new Array();		}		if (o) o.document.write(s);	} else {		this.m_debugLog[this.m_debugLog.length] = s;	}	}Log.prototype.resetTime = function(msg, text){	this.beginDate = new Date();}Log.prototype.error = function(msg, text){	this._msg(this.m_mtError, msg, text);}Log.prototype.info = function(msg, text){	this._msg(this.m_mtInfo, msg, text);}Log.prototype.warning = function(msg, text){	this._msg(this.m_mtWarning, msg, text);}Log.prototype.begin = function(msg, text){	this._msg(this.m_mtBegin, msg, text);	this.m_blockOffset++;}Log.prototype.end = function(msg, text){	this.m_blockOffset--;	if (this.m_blockOffset < 0) this.m_blockOffset = 0;	this._msg(this.m_mtEnd, msg, text);}Log.prototype.blink = function(msg, text){	this._msg(this.m_mtBlink, "<blink>"+msg+"</blink>", text);}Log.prototype.showWindow = function(){	this.m_debugShow = true;	this.info("Show debuger window");}Log.prototype.calculateTimeToString = function(dateStart, dateEnd){  var dd = Math.abs( dateEnd.getTime() - dateStart.getTime() );  var ds = ((dd < 10) ? "0" : "") + dd;  ds = ((dd < 100) ? "0" : "") + ds;  ds = ((dd < 1000) ? "0" : "") + ds;  return (ds);};log = new Log();