Monday, November 08, 2010 at 12:00 AM.
scripting2Suite.server.makeExpandable
on makeExpandable (title, text, flExpanded=false, id=nil) {
<<Changes
<<6/7/10; 8:05:19 AM by DW
<<Wrap the text in code that makes it possible to expand and collapse it. If flExpanded is true, it's expanded by default.
local (htmltext = "\r", indentlevel = 0, icon, showClassName = "showForOutline");
on add (s) {
htmltext = htmltext + string.filledstring ("\t", indentlevel) + s + "\r\n"};
bundle { //make up an id if it's nil
if id == nil {
id = string.innerCaseName (title) + random (1, 1000)}};
bundle { //set icon
local (iconname);
if flExpanded {
iconname = "minus"}
else {
iconname = "plus"};
icon = scripting2Suite.server.getExpandCollapseIcon (id, flExpanded, showClassName)};
add ("<b>" + icon + title + "</b>");
bundle { //add the text in a special <div> that makes it expandable
local (classname);
if flExpanded {
classname = showClassName}
else {
classname = "hide"};
add ("<div class=\"" + classname + "\" id=\"" + id + "\" name=\"" + id + "\">"); indentlevel++;
add (text);
add ("</div>")}};
bundle { //test code
webbrowser.displaytext (makeExpandable ("About the Author", string (config.scripting2.server.users.davewiner.prefs.aboutTheAuthor)))}
This listing is for code that runs in the OPML Editor environment. I created these listings because I wanted the search engines to index it, so that when I want to look up something in my codebase I don't have to use the much slower search functionality in my object database. Dave Winer.