StopwatchAttributes stopwatchAttributes = (StopwatchAttributes)attributes;
protocol.writeCloseSpan(stopwatchSpanAttributes);
// insert an empty block container which will be used to store split times
BlockContainerAttributes blockContainerAttributes =
new BlockContainerAttributes();
blockContainerAttributes.setId(protocol.getMarinerPageContext().generateUniqueFCID());
renderWidgetOpen(protocol, blockContainerAttributes);
renderWidgetClose(protocol, blockContainerAttributes);
// retrive list of attributes of clock content element which are
// within the timer element.
List contentAttributes = stopwatchAttributes.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 = stopwatchAttributes.getStyles();
StylesExtractor stylesExtractor = createStylesExtractor(
protocol, styles);
// count mode can be set to split and lap, default is split
String count_mode = "split";
if (styles.getPropertyValues().getComputedValue(StylePropertyDetails.MCS_COUNT_MODE) == StyleKeywords.LAP) {
count_mode = "lap";
}
String dateTimeFormat =
getDateTimeFormat(stylesExtractor.getDateTimeFormat(),specialMarks);
StringBuffer textBuffer = new StringBuffer();
textBuffer.append(createJavaScriptWidgetRegistrationOpening(stopwatchSpanAttributes.getId()))
.append("new Widget.Stopwatch(")
.append(createJavaScriptString(stopwatchSpanAttributes.getId()))
.append(", '").append(count_mode).append("', ")
.append(createJavaScriptWidgetReference(blockContainerAttributes.getId()))
.append(", {")
.append("format: [").append(dateTimeFormat).append("], ")
.append("digits: [").append(splitIds(digits)).append("], ")
.append("separators: [")
.append(splitIds(separators)).append("]")
.append("})")
.append(createJavaScriptWidgetRegistrationClosure());
//clock-content elements must be rendered before stopwatch element
addCreatedWidgetId(stopwatchSpanAttributes.getId());
addUsedWidgetIds(digits);
addUsedWidgetIds(separators);
addUsedWidgetId(blockContainerAttributes.getId());
writeJavaScript(textBuffer.toString());
}