diff --git a/examples/phrasebook/DiffPhrasebook.gf b/examples/phrasebook/DiffPhrasebook.gf index 8be58bb7e..27076323b 100644 --- a/examples/phrasebook/DiffPhrasebook.gf +++ b/examples/phrasebook/DiffPhrasebook.gf @@ -3,6 +3,7 @@ interface DiffPhrasebook = open Syntax in { oper want_V2 : V2 ; like_V2 : V2 ; - + cost_V2 : V2 ; -- it costs five euros + cost_V : V ; -- how much does it cost } diff --git a/examples/phrasebook/DiffPhrasebookEng.gf b/examples/phrasebook/DiffPhrasebookEng.gf index 435ca1603..40c802459 100644 --- a/examples/phrasebook/DiffPhrasebookEng.gf +++ b/examples/phrasebook/DiffPhrasebookEng.gf @@ -1,10 +1,12 @@ instance DiffPhrasebookEng of DiffPhrasebook = open SyntaxEng, - ParadigmsEng + ParadigmsEng, + IrregEng in { oper want_V2 = mkV2 (mkV "want") ; like_V2 = mkV2 (mkV "like") ; - + cost_V2 = mkV2 IrregEng.cost_V ; + cost_V = IrregEng.cost_V ; } diff --git a/examples/phrasebook/DiffPhrasebookFin.gf b/examples/phrasebook/DiffPhrasebookFin.gf index 3865c9091..c90820e06 100644 --- a/examples/phrasebook/DiffPhrasebookFin.gf +++ b/examples/phrasebook/DiffPhrasebookFin.gf @@ -9,4 +9,6 @@ oper want_V2 = mkV2 (mkV "haluta") ; like_V2 = mkV2 (mkV "pitää") elative ; + cost_V2 = mkV2 (mkV "maksaa") ; + cost_V = mkV "maksaa" ; } diff --git a/examples/phrasebook/DiffPhrasebookFre.gf b/examples/phrasebook/DiffPhrasebookFre.gf index 039258776..7a83a4f88 100644 --- a/examples/phrasebook/DiffPhrasebookFre.gf +++ b/examples/phrasebook/DiffPhrasebookFre.gf @@ -10,4 +10,7 @@ oper want_V2 = vouloir_V2 ; like_V2 = mkV2 (mkV "aimer") ; + cost_V2 = mkV2 (mkV "coûter") ; + cost_V = mkV "coûter" ; + } diff --git a/examples/phrasebook/DiffPhrasebookRon.gf b/examples/phrasebook/DiffPhrasebookRon.gf index 0b842bd81..060b8301d 100644 --- a/examples/phrasebook/DiffPhrasebookRon.gf +++ b/examples/phrasebook/DiffPhrasebookRon.gf @@ -10,4 +10,7 @@ oper want_V2 = dirV2 (lin V want_VV) ; -- mkVV (v_besch74 "vrea") like_V2 = dirV2 (v_besch71 "plăcea") ; + cost_V2 = dirV2 (mkV "costa") ; ---- ? + cost_V = mkV "costa" ; ---- ? + } diff --git a/examples/phrasebook/Greetings.gf b/examples/phrasebook/Greetings.gf index 11d0f9cc1..bdbc1b5bc 100644 --- a/examples/phrasebook/Greetings.gf +++ b/examples/phrasebook/Greetings.gf @@ -26,7 +26,6 @@ fun GImTired : Greeting ; GImScared : Greeting ; GIdontUnderstand : Greeting ; - GWheresTheBathroom : Greeting ; GTheCheck : Greeting ; GYes : Greeting ; diff --git a/examples/phrasebook/GreetingsEng.gf b/examples/phrasebook/GreetingsEng.gf index 5f3cc23e7..b89fdabab 100644 --- a/examples/phrasebook/GreetingsEng.gf +++ b/examples/phrasebook/GreetingsEng.gf @@ -26,7 +26,6 @@ lin GImTired = ss "I'm tired" ; GImScared = ss "I'm scared" ; GIdontUnderstand = ss "I don't understand" ; - GWheresTheBathroom = ss "where's the bathroom" ; GTheCheck = ss "the bill" ; GYes = ss "yes" ; diff --git a/examples/phrasebook/GreetingsFin.gf b/examples/phrasebook/GreetingsFin.gf index 2b7b5568f..220d1312b 100644 --- a/examples/phrasebook/GreetingsFin.gf +++ b/examples/phrasebook/GreetingsFin.gf @@ -28,7 +28,6 @@ lin GImTired = ss "minä olen väsynyt" ; GImScared = ss "minua pelottaa" ; GIdontUnderstand = ss "en ymmärrä" ; - GWheresTheBathroom = ss "missä on vessa" ; GTheCheck = ss "lasku" ; GYes = ss "kyllä" ; diff --git a/examples/phrasebook/GreetingsFre.gf b/examples/phrasebook/GreetingsFre.gf index 32f422f3c..bc5b8e9a5 100644 --- a/examples/phrasebook/GreetingsFre.gf +++ b/examples/phrasebook/GreetingsFre.gf @@ -29,7 +29,6 @@ lin GImTired = speakerDistinct "je suis fatigué" "je suis fatiguée" ; GImScared = roleNeutral "j'ai peur" ; GIdontUnderstand = roleNeutral "je ne comprends pas" ; - GWheresTheBathroom = roleNeutral "où est la toilette" ; GTheCheck = roleNeutral "l'addition" ; GYes = roleNeutral "oui" ; ---- si diff --git a/examples/phrasebook/GreetingsRon.gf b/examples/phrasebook/GreetingsRon.gf index acc0f5241..14aec6020 100644 --- a/examples/phrasebook/GreetingsRon.gf +++ b/examples/phrasebook/GreetingsRon.gf @@ -28,7 +28,6 @@ lin GImTired = ss "mi-e somn" ; GImScared = ss "mi-e frică" ; GIdontUnderstand = ss "nu înÅ£eleg" ; - GWheresTheBathroom = ss "unde e toaleta" ; GTheCheck = ss "nota de plată" ; GYes = ss "da" ; diff --git a/examples/phrasebook/Phrasebook.gf b/examples/phrasebook/Phrasebook.gf index f5f5a4663..001b250f5 100644 --- a/examples/phrasebook/Phrasebook.gf +++ b/examples/phrasebook/Phrasebook.gf @@ -1,6 +1,6 @@ abstract Phrasebook = Greetings, - Food + Words ** { flags startcat = Phrase ; @@ -11,6 +11,7 @@ cat fun PNumeral : Numeral -> Phrase ; PSentence : Sentence -> Phrase ; + PQuestion : Question -> Phrase ; PGreeting : Greeting -> Phrase ; ---- PGreeting : Politeness -> Gender -> Gender -> Greeting -> Phrase ; diff --git a/examples/phrasebook/PhrasebookEng.gf b/examples/phrasebook/PhrasebookEng.gf index 4d4b26781..5aa946bf0 100644 --- a/examples/phrasebook/PhrasebookEng.gf +++ b/examples/phrasebook/PhrasebookEng.gf @@ -2,19 +2,20 @@ concrete PhrasebookEng of Phrasebook = GreetingsEng, - FoodEng ** open + WordsEng ** open (R = Roles), SyntaxEng, ResEng, ---- for Num to Utt Prelude in { lincat - Phrase = Utt ; + Phrase = Text ; lin PNumeral n = mkPhrase ((SyntaxEng.mkCard ).s ! Nom) ; ---- - PSentence s = s ; + PSentence s = mkText s ; + PQuestion s = mkText s ; PGreeting g = mkPhrase g.s ; ---- PGreeting p s h g = mkPhrase (g.s ++ p.s ++ s.s ++ h.s) ; diff --git a/examples/phrasebook/PhrasebookFin.gf b/examples/phrasebook/PhrasebookFin.gf index 340d1c075..2144d90fe 100644 --- a/examples/phrasebook/PhrasebookFin.gf +++ b/examples/phrasebook/PhrasebookFin.gf @@ -2,19 +2,20 @@ concrete PhrasebookFin of Phrasebook = GreetingsFin, - FoodFin ** open + WordsFin ** open SyntaxFin, ResFin, ---- for Num to Utt Prelude in { lincat - Phrase = Utt ; + Phrase = Text ; lin PNumeral n = mkPhrase (ss ((SyntaxFin.mkCard ).s ! Sg ! Nom)) ; ---- PGreeting g = mkPhrase g ; - PSentence s = s ; + PSentence s = mkText s ; + PQuestion s = mkText s ; oper diff --git a/examples/phrasebook/PhrasebookFre.gf b/examples/phrasebook/PhrasebookFre.gf index 7cf812466..5df0c0c86 100644 --- a/examples/phrasebook/PhrasebookFre.gf +++ b/examples/phrasebook/PhrasebookFre.gf @@ -2,7 +2,7 @@ concrete PhrasebookFre of Phrasebook = GreetingsFre, - FoodFre + WordsFre ** open (R = Roles), SyntaxFre, @@ -11,13 +11,14 @@ concrete PhrasebookFre of Phrasebook = Prelude in { lincat - Phrase = Utt ; + Phrase = Text ; Gender = {s : Str ; g : R.Gender} ; Politeness = {s : Str ; p : R.Politeness} ; lin PNumeral n = mkPhrase ((mkCard ).s ! masculine) ; ---- - PSentence s = s ; + PSentence s = mkText s ; + PQuestion s = mkText s ; PGreeting g = mkPhrase (g.s ! R.Polite ! R.Male ! R.Male) ; ---- PGreeting p s h g = mkPhrase (g.s ! p.p ! s.g ! h.g ++ p.s ++ s.s ++ h.s) ; diff --git a/examples/phrasebook/PhrasebookRon.gf b/examples/phrasebook/PhrasebookRon.gf index 5dd15b04b..40cdf1eda 100644 --- a/examples/phrasebook/PhrasebookRon.gf +++ b/examples/phrasebook/PhrasebookRon.gf @@ -2,19 +2,20 @@ concrete PhrasebookRon of Phrasebook = GreetingsRon, - FoodRon + WordsRon ** open SyntaxRon, ResRon, ---- for Num to Utt Prelude in { lincat - Phrase = Utt ; + Phrase = Text ; lin PNumeral n = mkPhrase (ss ((mkCard ).sp ! Masc)) ; ---- PGreeting g = mkPhrase g ; - PSentence s = s ; + PSentence s = mkText s ; + PQuestion s = mkText s ; oper mkPhrase : SS -> Utt = \s -> lin Utt s ; diff --git a/examples/phrasebook/Sentences.gf b/examples/phrasebook/Sentences.gf index 7afd69435..d1f79498b 100644 --- a/examples/phrasebook/Sentences.gf +++ b/examples/phrasebook/Sentences.gf @@ -1,7 +1,8 @@ abstract Sentences = Numeral ** { cat - Sentence ; Object ; Item ; Kind ; Quality ; + Sentence ; Question ; Object ; Item ; Kind ; Quality ; + Place ; PlaceKind ; Currency ; Price ; fun Is : Item -> Quality -> Sentence ; @@ -9,13 +10,22 @@ abstract Sentences = Numeral ** { IWant : Object -> Sentence ; ILike : Item -> Sentence ; - DoYouHave : Kind -> Sentence ; - WhetherIs : Item -> Quality -> Sentence ; + DoYouHave : Kind -> Question ; + WhetherIs : Item -> Quality -> Question ; + WhereIs : Place -> Question ; + + HowMuchCost : Item -> Question ; + ItCost : Item -> Price -> Sentence ; + AmountCurrency : Numeral -> Currency -> Price ; + ObjItem : Item -> Object ; ObjNumber : Numeral -> Kind -> Object ; - This, That, These, Those : Kind -> Item ; + This, That, These, Those, The, Thes : Kind -> Item ; SuchKind : Quality -> Kind -> Kind ; Very : Quality -> Quality ; + Too : Quality -> Quality ; + + ThePlace : PlaceKind -> Place ; } diff --git a/examples/phrasebook/SentencesFre.gf b/examples/phrasebook/SentencesFre.gf index 46c57b19c..d4415e74a 100644 --- a/examples/phrasebook/SentencesFre.gf +++ b/examples/phrasebook/SentencesFre.gf @@ -1,3 +1,9 @@ -concrete SentencesFre of Sentences = NumeralFre ** SentencesI with - (DiffPhrasebook = DiffPhrasebookFre), - (Syntax = SyntaxFre) ; +concrete SentencesFre of Sentences = NumeralFre ** SentencesI - [WhetherIs] + with + (DiffPhrasebook = DiffPhrasebookFre), + (Syntax = SyntaxFre) ** open SyntaxFre, ExtraFre in { + + lin WhetherIs item quality = + lin QS {s = \\_ => (EstcequeS (mkS (mkCl item quality))).s} ; + +} diff --git a/examples/phrasebook/SentencesI.gf b/examples/phrasebook/SentencesI.gf index 73c0c9e97..09096dea5 100644 --- a/examples/phrasebook/SentencesI.gf +++ b/examples/phrasebook/SentencesI.gf @@ -4,19 +4,30 @@ incomplete concrete SentencesI of Sentences = Numeral ** Syntax in { lincat - Sentence = Utt ; + Sentence = S ; + Question = QS ; Item = NP ; Kind = CN ; Quality = AP ; Object = NP ; + Place = NP ; + PlaceKind = CN ; + Currency = CN ; + Price = NP ; lin - Is item quality = mkUtt (mkCl item quality) ; - IsNot item quality = mkUtt (mkS negativePol (mkCl item quality)) ; - WhetherIs item quality = mkUtt (mkQCl (mkCl item quality)) ; - IWant obj = mkUtt (mkCl (mkNP i_Pron) want_V2 obj) ; - ILike item = mkUtt (mkCl (mkNP i_Pron) like_V2 item) ; + Is item quality = mkS (mkCl item quality) ; + IsNot item quality = mkS negativePol (mkCl item quality) ; + WhetherIs item quality = mkQS (mkQCl (mkCl item quality)) ; + WhereIs place = mkQS (mkQCl where_IAdv place) ; + IWant obj = mkS (mkCl (mkNP i_Pron) want_V2 obj) ; + ILike item = mkS (mkCl (mkNP i_Pron) like_V2 item) ; DoYouHave kind = - mkUtt (mkQCl (mkCl (mkNP youPol_Pron) have_V2 (mkNP kind))) ; + mkQS (mkQCl (mkCl (mkNP youPol_Pron) have_V2 (mkNP kind))) ; + + HowMuchCost item = mkQS (mkQCl how8much_IAdv (mkCl item cost_V)) ; + ItCost item price = mkS (mkCl item cost_V2 price) ; + AmountCurrency num curr = mkNP curr ; + ObjItem i = i ; ObjNumber n k = mkNP k ; @@ -24,6 +35,12 @@ incomplete concrete SentencesI of Sentences = Numeral ** That kind = mkNP that_Quant kind ; These kind = mkNP this_Quant plNum kind ; Those kind = mkNP that_Quant plNum kind ; + The kind = mkNP the_Quant kind ; + The kind = mkNP the_Quant kind ; + Thes kind = mkNP the_Quant plNum kind ; SuchKind quality kind = mkCN quality kind ; Very quality = mkAP very_AdA quality ; + Too quality = mkAP too_AdA quality ; + ThePlace kind = mkNP the_Quant kind ; + } diff --git a/examples/phrasebook/Food.gf b/examples/phrasebook/Words.gf similarity index 58% rename from examples/phrasebook/Food.gf rename to examples/phrasebook/Words.gf index c0ee9077e..dec6358ac 100644 --- a/examples/phrasebook/Food.gf +++ b/examples/phrasebook/Words.gf @@ -1,8 +1,13 @@ -- (c) 2009 Aarne Ranta under LGPL -abstract Food = Sentences ** { +abstract Words = Sentences ** { fun Wine, Cheese, Fish, Pizza : Kind ; Fresh, Warm, Italian, Expensive, Delicious, Boring : Quality ; + + Bar, Restaurant, Toilet : PlaceKind ; + + Euro, Dollar, Lei : Currency ; + } diff --git a/examples/phrasebook/FoodEng.gf b/examples/phrasebook/WordsEng.gf similarity index 60% rename from examples/phrasebook/FoodEng.gf rename to examples/phrasebook/WordsEng.gf index 45e13813c..017d8aebc 100644 --- a/examples/phrasebook/FoodEng.gf +++ b/examples/phrasebook/WordsEng.gf @@ -1,6 +1,6 @@ -- (c) 2009 Aarne Ranta under LGPL -concrete FoodEng of Food = SentencesEng ** +concrete WordsEng of Words = SentencesEng ** open SyntaxEng, ParadigmsEng in { lin Wine = mkCN (mkN "wine") ; @@ -14,4 +14,12 @@ concrete FoodEng of Food = SentencesEng ** Delicious = mkAP (mkA "delicious") ; Boring = mkAP (mkA "boring") ; + Restaurant = mkCN (mkN "restaurant") ; + Bar = mkCN (mkN "bar") ; + Toilet = mkCN (mkN "toilet") ; + + Euro = mkCN (mkN "euro" "euros") ; -- to prevent euroes + Dollar = mkCN (mkN "dollar") ; + Lei = mkCN (mkN "leu" "lei") ; + } diff --git a/examples/phrasebook/FoodFin.gf b/examples/phrasebook/WordsFin.gf similarity index 74% rename from examples/phrasebook/FoodFin.gf rename to examples/phrasebook/WordsFin.gf index 59e15b039..d26b7f797 100644 --- a/examples/phrasebook/FoodFin.gf +++ b/examples/phrasebook/WordsFin.gf @@ -1,6 +1,6 @@ -- (c) 2009 Aarne Ranta under LGPL -concrete FoodFin of Food = SentencesFin ** +concrete WordsFin of Words = SentencesFin ** open SyntaxFin, ParadigmsFin in { lin Wine = mkCN (mkN "viini") ; @@ -18,6 +18,14 @@ concrete FoodFin of Food = SentencesFin ** Delicious = mkAP (mkA "herkullinen") ; Boring = mkAP (mkA "tylsä") ; + Restaurant = mkCN (mkN "ravintola") ; + Bar = mkCN (mkN "baari") ; + Toilet = mkCN (mkN "vessa") ; + + Euro = mkCN (mkN "euro") ; + Dollar = mkCN (mkN "dollari") ; + Lei = mkCN (mkN "lei") ; + -- oper ---- optimization lasts forever -- mkCNN : Str -> CN = \s -> mkCN (mkN s) ; -- mkAPA : Str -> AP = \s -> mkAP (mkA s) ; diff --git a/examples/phrasebook/FoodFre.gf b/examples/phrasebook/WordsFre.gf similarity index 62% rename from examples/phrasebook/FoodFre.gf rename to examples/phrasebook/WordsFre.gf index 0c7c1af1c..733038ce3 100644 --- a/examples/phrasebook/FoodFre.gf +++ b/examples/phrasebook/WordsFre.gf @@ -1,6 +1,6 @@ -- (c) 2009 Ramona Enache and Aarne Ranta under LGPL -concrete FoodFre of Food = SentencesFre ** open +concrete WordsFre of Words = SentencesFre ** open SyntaxFre, ParadigmsFre in { @@ -20,6 +20,14 @@ Expensive = mkAPA "cher" ; Delicious = mkAPA "délicieux" ; Boring = mkAPA "ennuyeux" ; + Restaurant = mkCN (mkN "restaurant") ; + Bar = mkCN (mkN "bar") ; + Toilet = mkCN (mkN "toilette") ; + + Euro = mkCN (mkN "euro") ; + Dollar = mkCN (mkN "dollar") ; + Lei = mkCN (mkN "lei") ; ---- ? + oper mkAPA : (_ : Str) -> AP = \x -> mkAP (mkA x) ; diff --git a/examples/phrasebook/FoodRon.gf b/examples/phrasebook/WordsRon.gf similarity index 71% rename from examples/phrasebook/FoodRon.gf rename to examples/phrasebook/WordsRon.gf index 76cc3753f..673eead8f 100644 --- a/examples/phrasebook/FoodRon.gf +++ b/examples/phrasebook/WordsRon.gf @@ -1,6 +1,6 @@ -- (c) 2009 Ramona Enache under LGPL -concrete FoodRon of Food = SentencesRon ** open +concrete WordsRon of Words = SentencesRon ** open SyntaxRon, ParadigmsRon in { @@ -20,6 +20,14 @@ Expensive = mkAPA "scump" "scumpă" "scumpi" "scumpe" ; Delicious = mkAPA "delicios" "delcioasă" "delicioÅŸi" "delicioase" ; Boring = mkAPA "plictisitor" "plictisitoare" "plictisitori" "plictisitoare" ; + Restaurant = mkCN (mkN "restaurant") ; + Bar = mkCN (mkN "bar") ; + Toilet = mkCN (mkN "toaleta") ; + + Euro = mkCN (mkN "euro") ; + Dollar = mkCN (mkN "dollar") ; + Lei = mkCN (mkN "leu" "lei") ; + oper mkAPA : (_,_,_,_ : Str) -> AP = \x,y,z,u -> mkAP (mkA x y z u) ; diff --git a/examples/phrasebook/www/phrasebook.css b/examples/phrasebook/www/phrasebook.css new file mode 100644 index 000000000..17d7350c9 --- /dev/null +++ b/examples/phrasebook/www/phrasebook.css @@ -0,0 +1,37 @@ +body { + background: #ccc url("http://www.grammaticalframework.org:41296/fridge/se.chalmers.cs.gf.gwt.FridgeApp/brushed-metal.png"); +} + +h1, h2, h3, small, th { font-family: sans-serif; } + +th, td { vertical-align: baseline; text-align: left; } + +div#surface { + min-height: 3ex; + margin: 5px; + padding: 5px; + border: 3px dashed #e0e0e0; +} + +div#words { + min-height: 3ex; + margin: 5px; + padding: 6px; + border: 3px solid #e0e0e0; +} + +div.word, span.word, div#words div { + display: inline-block; + font-family: sans-serif; + background-color: white; + border: 1px solid black; + padding: 3px; + margin: 3px; +} + +.invalid { color: red; } + +div.modtime { float: right; } +.modtime { color: #444; white-space: nowrap; } + +ul.space>li { margin-top: 0.5ex; } diff --git a/examples/phrasebook/www/phrasebook.html b/examples/phrasebook/www/phrasebook.html new file mode 100644 index 000000000..7d34a27fa --- /dev/null +++ b/examples/phrasebook/www/phrasebook.html @@ -0,0 +1,28 @@ + + +Phrasebook + + + + + + + +
+
+
+ + + +Based on +minibar, +powered by +GF + + + + + + + + diff --git a/examples/phrasebook/www/phrasebook.js b/examples/phrasebook/www/phrasebook.js new file mode 100644 index 000000000..bbbcfd061 --- /dev/null +++ b/examples/phrasebook/www/phrasebook.js @@ -0,0 +1,211 @@ + +//var server="http://www.grammaticalframework.org:41296" +//var server="http://tournesol.cs.chalmers.se:41296"; +var server="http://localhost:41296"; +var grammars_url=server+"/grammars/"; +var current_grammar_url=grammars_url+"Foods.pgf"; + +var tree_icon=server+"/translate/se.chalmers.cs.gf.gwt.TranslateApp/tree-btn.png"; + +function start_minibar() { + var minibar=element("minibar"); + minibar.appendChild(div_id("menubar")); + minibar.appendChild(div_id("surface")); + minibar.appendChild(div_id("words")); + minibar.appendChild(div_id("translations")); + /// jsonp(grammars_url+"grammars.cgi",""); // calls show_grammarlist + show_grammarlist(["Phrasebook.pgf","Foods.pgf", "ResourceDemo.pgf"]) ; +} + +function show_grammarlist(grammars) { + var menu=empty("select"); + for(var i=0;i0) box.appendChild(word(s)); + else emptycnt++; + } + if(emptycnt>0) + //setTimeout(function(){get_translations(menu);},200); + get_translations(menu); +} + +function get_translations(menu) { + jsonp(current_grammar_url + +"?command=translategroup" + // +"?command=translate" + +"&from="+encodeURIComponent(menu.current.from) + +"&input="+encodeURIComponent(menu.current.input), + "show_translations") +} + +function show_translations(translations) { + var trans=element("translations"); + var cnt=translations.length; + trans.innerHTML=""; + for(p=0;p -1) + url += "&jsonp=" + else + url += "?jsonp=" + url += callback + "&"; + //url += new Date().getTime().toString(); // prevent caching + + var script = empty("script"); + script.setAttribute("src",url); + script.setAttribute("type","text/javascript"); + document.body.appendChild(script); +} + +/* --- HTML construction ---------------------------------------------------- */ +function text(s) { return document.createTextNode(s); } + +function empty(tag,name,value) { + var el=document.createElement(tag); + if(name && value) el.setAttribute(name,value); + return el; +} + +function empty_id(tag,id) { return empty(tag,"id",id); } +function empty_class(tag,cls) { return empty(tag,"class",cls); } + +function div_id(id) { return empty_id("div",id); } + +function wrap(tag,contents) { + var el=empty(tag); + el.appendChild(contents); + return el; +} + +function wrap_class(tag,cls,contents) { + var el=empty_class(tag,cls); + if(contents) el.appendChild(contents); + return el; +} + +function span_class(cls,contents) { return wrap_class("span",cls,contents); } +function div_class(cls,contents) { return wrap_class("div",cls,contents); } + +function p(contents) { return wrap("p",contents); } +function dt(contents) { return wrap("dt",contents); } + +function th(contents) { return wrap("th",contents); } +function td(contents) { return wrap("td",contents); } + +function tr(cells) { + var tr=empty("tr"); + for(var i=0;i"; + } + return result; +} + +function field_names(obj) { + var result = ""; + for (var i in obj) { + result += " " + i; + } + return result; +} + +/* --- Data manipulation ---------------------------------------------------- */ +function swap(a,i,j) { // Note: this doesn't work on strings. + var tmp=a[i]; + a[i]=a[j]; + a[j]=tmp; + return a; +} + +function sort(a) { // Note: this doesn't work on strings. + for(var i=0;i