var defsTable = table "definitions" with (id:String, word:String, meaning:String) where id readonly from database "dictionary"; fun newDef(def) server { insert defsTable values (word, meaning) [def] } fun updateDef(def) server { update (d <-- defsTable) where (d.id == def.id) set (meaning=def.meaning) } fun deleteDef(id) server { delete (def <-- defsTable) where (def.id == id) } fun completions(s) server { if (s == "") [] else { query [10] { for (def <-- defsTable) where (def.word =~ /^{s}.*/) orderby (def.word) [def] } } } fun suggest(s) client { replaceChildren(format(completions(s)), getNodeById("suggestions")) } fun editDef(def) client { redraw(
Entry: editing
Meaning:
, def.id) } fun redraw(xml, defId) { replaceChildren(xml, getNodeById("def:"++defId)) } fun formatDef(def) { {stringToXml(def.meaning)} } fun format(defs) {
Click a definition to edit it.
{ for (def <- defs) }
{stringToXml(def.word)} {formatDef(def)}
} fun addForm(handler) {
Word:
Meaning: