Logger.js
Summary
No overview generated for 'Logger.js'
mapbuilder.loadScript(baseDir+"/model/ModelBase.js");
function Logger(modelNode, parent) {
ModelBase.apply(this, new Array(modelNode, parent));
this.namespace = "xmlns:mb='http://mapbuilder.sourceforge.net/mapbuilder'";
this.doc = Sarissa.getDomDocument("http://mapbuilder.sourceforge.net/mapbuilder","mb:Logger");//!no prefix on the URL
Sarissa.setXpathNamespaces(this.doc, this.namespace);
this.doc.async = false;
this.doc.validateOnParse=false; //IE6 SP2 parsing bug
this.logEvent = function(eventType, listenerId, targetId, paramValue) {
var eventLog = this.doc.createElement("event");
eventLog.setAttribute("time", new Date().getTime());
eventLog.setAttribute("listener", listenerId);
eventLog.setAttribute("target", targetId);
if (paramValue) eventLog.setAttribute("param", paramValue);
eventLog.appendChild(this.doc.createTextNode(eventType));
this.doc.documentElement.appendChild(eventLog);
}
this.clearLog = function() {
while (this.doc.documentElement.hasChildNodes() ) {
this.doc.documentElement.removeChild(this.doc.documentElement.firstChild);
}
this.callListeners("refresh");
}
this.saveLog = function() {
if (config.serializeUrl) {
var tempDoc = postLoad(config.serializeUrl,logger.doc);
tempDoc.setProperty("SelectionLanguage", "XPath");
Sarissa.setXpathNamespaces(tempDoc, "xmlns:xlink='http://www.w3.org/1999/xlink'");
var onlineResource = tempDoc.selectSingleNode("//OnlineResource");
var fileUrl = onlineResource.attributes.getNamedItem("xlink:href").nodeValue;
alert(mbGetMessage("eventLogSaved", fileUrl));
} else {
alert(mbGetMessage("unableToSaveLog"));
}
}
this.refreshLog = function(objRef) {
objRef.callListeners("refresh");
}
if (parent) parent.addListener("refresh",this.refreshLog, this);
window.onunload = this.saveLog; //automatically save the log when the page unloads
window.logger = this; //global reference to the logger model
}
Documentation generated by
JSDoc on Tue Aug 21 08:12:28 2007