The below control can be used as Literal control and extends the Control class in the Nokia WRT Control Kit. It is based on the Label control, but without the need for a caption and no CSS wrappers. This way the control can render HTML or text content literally as is.
///////////////////////////////////////////////////////////////////////////////
// The Literal class implements a control that displays raw HTML or Text content.
// Constructor.
function Literal(id, text) {
if (id != UI_NO_INIT_ID) {
this.init(id, text);
}
}
// Literal inherits from Control.
Literal.prototype = new Control(UI_NO_INIT_ID);
// Content element for Literal text.
Literal.prototype.contentElement = null;
// Initializer - called from constructor.
Literal.prototype.init = function(id, text) {
uiLogger.debug("Literal.init(" + id + ", " + text + ")");
// call superclass initializer
Control.prototype.init.call(this, id);
// create content element
this.contentElement = document.createElement("div");
this.controlElement.appendChild(this.contentElement);
// set the text
this.setText(text);
}
// Returns the enabled state for the control.
Literal.prototype.isEnabled = function() {
return true;
}
// Returns the focusable state for the control.
Literal.prototype.isFocusable = function() {
return false;
}
// Returns the control text.
Literal.prototype.getText = function() {
return this.contentElement.innerHTML;
}
// Sets the text for the control.
Literal.prototype.setText = function(text) {
uiLogger.debug("Literal.setText(" + text + ")");
this.contentElement.innerHTML = (text == null) ? "" : text;
}