"
<% if(icon) { %>
style="foreground-image:url(<% =icon %>)"
<% } %>
><% = content !== undefined? content.toString().trim() : "{nothing?}"; %>
<%
var captions = { ok:"OK", cancel:"Cancel", abort:"Abort", ignore:"Ignore",yes:"Yes",no:"No",close:"Close"};
function renderButton(role, button_def)
{
try
{
var id;
var text;
var accesskey = "";
if( typeof button_def == #object ) { id = button_def.id; text = button_def.text; accesskey = button_def.accesskey;}
else { id = button_def; text = captions[id]; }
%><% =text %><%
return true;
} catch(e) { stdout << "msgbox error - bad button definition:" << e; }
return false;
}
var numbuttons = 0;
if( typeof buttons == #array )
{
var has_default, has_cancel;
for(var i = 0; i < buttons.length; ++i)
{
var btn = buttons[i];
if( typeof btn != #object )
continue;
if( btn.role == "default-button" )
has_default = true;
else if( btn.role == "cancel-button" )
has_cancel = true;
}
for(var i = 0; i < buttons.length; ++i)
{
var btn = buttons[i];
var role = typeof btn == #object ? btn.role : "";
if( i == 0 && !has_default ) role = "default-button";
else if( i != 0 && i == (buttons.length-1) && !has_cancel && role != "default-button") role = "cancel-button";
if(renderButton(role, buttons[i]));
++numbuttons;
}
}
else if( typeof buttons == #object || typeof buttons == #symbol)
{
if(renderButton("default-button", buttons))
++numbuttons;
}
if(!numbuttons) // no buttons - no luck
{
%>OK <%
}
%>