-- <<<- global theHotList if (not (isDefined theHotList)) do ( theHotList := #( "People": #( "Don": "http://www.kaleida.com/u/hopkins", "Kelly": "http://www.apocalypse.org/pub/u/kjc/home.html", "Regis": "http://www.apocalypse.org/zonker/" ), "Places": #( "Work": #( "Kaleida": "http://www.kaleida.com/", "Apple": "http://www.apple.com/", "IBM": "http://www.ibm.com/" ), "Fun": #( "Art on the Net": "http://www.art.net/" ) ), "Things": #( "ScriptX Hello": "scriptx:hello", "ScriptX Help": "scriptx:help", "ScriptX Date": "scriptx:date" ) ) ) global theHotListServicePage := object (WebPage) title: "Hot List" base: "" contents object (WebMacro) func: (self stream props -> local topics := #() function makeHotList title l -> ( local hotlist if ((size l) == 0) then ( hotlist := " (empty)" ) else ( hotlist := new WebBulletedList forEachBinding l (key val xxx -> if (isAKindOf val ExplicitlyKeyedCollection) then ( append topics key append hotlist (makeHotList key val) ) else ( append hotlist (object (WebLink) url: val contents key end) ) ) ok ) object (WebGroup) contents object (WebLink) name: title contents object (WebBold) contents title end end ": " object (WebLink) url: (theSXPrefix + (anchorProps \ dialog: "HotListEditTopic" \ target: (externalize theWebServer l) \ title: title)) contents "[Edit]" end hotlist end ) local hotlist := makeHotList "Hot List" theHotList local topiclist if (size topics == 0) then ( topiclist := "" ) else ( local l := new WebList forEach topics (topic xxx -> append l (object (WebLink) url: ("#" + (topic as String)) contents topic end) ) ok topicList := (object (WebGroup) contents "Topics: " l object (WebParagraph) end end) ) object (WebGroup) contents topiclist hotlist end ) end end global theHotListEditTopicDialogPage := object (WebPage) title: "Hot List Topic Editor" base: "" contents object (WebMacro) func: (self stream props -> local target := empty local id := getInt (props[@Target]) 0 if (id != 0) do (target := internalize theWebServer id) if (target == empty) do (return "Undefined target!") function findHotlistParent hl child -> ( if (isMember hl child) do ( return hl ) for subhl in hl do ( if (isAKindOf subhl ExplicitlyKeyedCollection) do ( local result := findHotlistParent subhl child if (result != undefined) do ( return result ) ) ) return undefined ) local hotlistParent local hotlistTitle if (target == theHotList) then ( hotlistParent := undefined hotlistTitle := "Hot List" ) else ( hotlistParent := findHotlistParent theHotList target hotlistTitle := getKeyOne hotlistParent target if (hotlistTitle == empty) do ( hotlistTitle := "undefined" ) ) local itemList := new WebBulletedList local keyEditor := new WebTextArea \ name: "keys" \ rows: ((size target) + 1) \ cols: 60 forEachBinding target (key val -> local valStr if (isAKindOf val ExplicitlyKeyedCollection) then ( valStr := "..." ) else ( valStr := val ) append keyEditor (key + " => " + valStr + "\r") append itemList (object (WebGroup) contents if (isAKindOf val ExplicitlyKeyedCollection) then ( object (WebGroup) contents "Topic: " object (WebBold) contents object (WebLink) url: (theSXPrefix + (anchorProps \ dialog: "HotListEditTopic" \ target: (externalize theWebServer \ val))) contents key end end end ) else ( object (WebGroup) contents "Link: " object (WebLink) url: val contents key end end ) end) ) ok object (WebGroup) contents object (WebHeading) level: 1 contents hotlistTitle end if (hotlistParent == undefined) then ( "" ) else ( object (WebLink) url: (theSXPrefix + (anchorProps \ dialog: "HotListEditTopic" \ target: (externalize theWebServer \ hotlistParent))) contents "[Up]" end ) itemList object (WebLineBreak) end object (WebForm) method: @get url: "scriptx:" contents object (WebSubmitInput) contents "Apply" end object (WebResetInput) contents "Reset" end object (WebLineBreak) end keyEditor object (WebLineBreak) end end end ) end end registerService theWebServer \ (new WebService \ name: "HotList" \ about: "Hot List Manager!" \ handler: (service request params -> printHTML \ theHotListServicePage \ (new String) \ #(:))) registerDialog theWebServer \ (new WebDialog \ name: "HotListEditTopic" \ handler: (dialog props params -> printHTML theHotListEditTopicDialogPage \ (new String) props)) -- >>>