super(ureq, wControl);
// dummy translator, empty
Translator trans = Util.createPackageTranslator(
JavaScriptTracingController.class, ureq.getLocale());
// dummy velocity container, empty
VelocityContainer mainVC = new VelocityContainer("JSTracing", Util
.getPackageVelocityRoot(JavaScriptTracingController.class)
+ "/JSTracing.html", trans, this);
// The javascript ajax tracing library, attached to the dummy velocity
// container so that it gets included
JSAndCSSComponent tmJs = new JSAndCSSComponent("js",
JavaScriptTracingController.class,
new String[] { "JSTracing.js" }, null, false);
mainVC.put("js", tmJs);
// The mapper that handels all log postings
Mapper mapper = new Mapper() {
public MediaResource handle(String relPath,
HttpServletRequest request) {
// the log message
String logMsg = request.getParameter("logMsg");
// optional, the logging file name
String jsFile = request.getParameter("jsFile");
// currently only debug level is supported but in the future...
String level = request.getParameter("level");
if (level.equals("debug")) {
// log to standard OLAT logging system
logDebug(logMsg, jsFile);
}
// sent empty response
StringMediaResource smr = new StringMediaResource();
smr.setContentType("application/javascript");
smr.setEncoding("utf-8");
smr.setData("");
StringMediaResource mediaResource = new StringMediaResource();
mediaResource.setEncoding("utf-8");
mediaResource.setContentType("text/javascript;charset=utf-8");
mediaResource.setData("");
return mediaResource;
}
};
String mapperUri = registerMapper(mapper);
// push some variables to the header that are needed to initialize the
// JS Tracing
String jsHeader = "<script type='text/javascript'>o_info.JSTracingUri='"
+ mapperUri
+ "/';o_info.JSTracingLogDebugEnabled="
+ isLogDebugEnabled()
+ ";</script>";
HtmlHeaderComponent JSTracingHeader = new HtmlHeaderComponent(
"JSTracingHeader", null, jsHeader);
mainVC.put("JSTracingHeader", JSTracingHeader);
putInitialPanel(mainVC);
}