if(!isWidgetSupported(protocol)) {
return;
}
TimerAttributes timerAttributes = (TimerAttributes)attributes;
// require AJAX script module
if ( timerAttributes.getLoadAttributes() != null ) {
require(WidgetScriptModules.BASE_AJAX, protocol, attributes);
}
protocol.writeCloseSpan(timerSpanAttributes);
// retrive list of attributes of clock content element which are
// within the timer element.
List contentAttributes = timerAttributes.getContentAttributes();
// create ClockContentHandler to merge contents
ClockContextHandler clockContextHandler = new ClockContextHandler();
clockContextHandler.mergeContentAttributes(contentAttributes);
String[] digits = clockContextHandler.getClockContentIds("digits");
String[] separators = clockContextHandler.getClockContentIds("separators");
Styles styles = timerAttributes.getStyles();
StylesExtractor stylesExtractor = createStylesExtractor(
protocol, styles);
String dateTimeFormat =
getDateTimeFormat(stylesExtractor.getDateTimeFormat(),specialMarks);
LoadAttributes loadAttributes = timerAttributes.getLoadAttributes();
StringBuffer textLoadAttr = new StringBuffer();
if(loadAttributes != null) {
textLoadAttr.append(", load_src: ")
.append(createJavaScriptString(loadAttributes.getSrc()));
}
StringBuffer startStopAttr = new StringBuffer();
Integer start = timerAttributes.getStartTime();
Integer stop = timerAttributes.getStopTime();
if(start!= null && stop !=null) {
startStopAttr.append(", start_time: '")
.append(timerAttributes.getStartTime().toString()).append("', ")
.append("stop_time: '")
.append(timerAttributes.getStopTime().toString()).append("'");
}
StringBuffer textBuffer = new StringBuffer();
textBuffer.append(createJavaScriptWidgetRegistrationOpening(timerAttributes.getId()))
.append("new Widget.Timer(")
.append(createJavaScriptString(timerSpanAttributes.getId()))
.append(", {")
.append("start_time: '").append(""+timerAttributes.getStartTime()).append("', ")
.append("stop_time: '").append(""+timerAttributes.getStopTime()).append("', ")
.append("format: [").append(dateTimeFormat).append("], ")
.append("digits: [").append(splitIds(digits)).append("], ")
.append("separators: [")
.append(splitIds(separators)).append("]")
.append(textLoadAttr)