From 3c900ee6a3a31ba8a438d876ad8cfd352e97608a Mon Sep 17 00:00:00 2001 From: hallgren Date: Thu, 29 Nov 2012 19:15:30 +0000 Subject: [PATCH] minibar: add a button to get detailed grammar info After pressing the "i" button to view grammar info, there is now a "More info" button to get more detailed information about all categories and functions in the grammar. --- src/www/minibar/about.html | 6 ++++- src/www/minibar/minibar.css | 5 ++++ src/www/minibar/minibar.js | 47 ++++++++++++++++++++++++++++++------- 3 files changed, 49 insertions(+), 9 deletions(-) diff --git a/src/www/minibar/about.html b/src/www/minibar/about.html index cfc367c7c..c30884078 100644 --- a/src/www/minibar/about.html +++ b/src/www/minibar/about.html @@ -217,11 +217,15 @@ Some implementation details:
  • [Added 2012-11-23] Added support for switching back and forth between the minibar and the new syntax tree editor. The default configuration in minibar_online.js shows how to enable it. +
  • [Added 2012-11-29] After pressing the i button to view + grammar info, there is now a More info button to get + more detailed information about all categories and functions in the + grammar.
    -Last modified: Thu Nov 29 17:02:43 CET 2012 +Last modified: Thu Nov 29 20:13:55 CET 2012
    TH diff --git a/src/www/minibar/minibar.css b/src/www/minibar/minibar.css index 4766f79f8..03a75a2de 100644 --- a/src/www/minibar/minibar.css +++ b/src/www/minibar/minibar.css @@ -82,3 +82,8 @@ span.brackets { div.brackets .token { padding: 0 0.5ex; } + +div.browse, table.browse td { + background: white; + padding: 2px; +} diff --git a/src/www/minibar/minibar.js b/src/www/minibar/minibar.js index 51849fc91..e65141ca2 100644 --- a/src/www/minibar/minibar.js +++ b/src/www/minibar/minibar.js @@ -142,17 +142,48 @@ Minibar.prototype.change_grammar=function(grammar_info) { } Minibar.prototype.show_grammarinfo=function() { - this.translations.main.innerHTML="" + var t=this var g=this.grammar; + function draw_cats(cats) { + function draw_cat(cat) { + var i=cats[cat] + return tr([td(text(i.def)), + td(text(i.producers.join(", "))), + td(text(i.consumers.join(", ")))]) + } + var table=wrap_class("table","browse",g.categories.map(draw_cat)) + var hdr=tr([th(text("Category")), + th(text("Producers")), + th(text("Consumers"))]) + insertFirst(table,hdr) + return table + } + function draw_funs(funs) { + function draw_fun(fun) { + var def=funs[fun].def.split(":") + return tr([td(text(def[0])),td(text(":")),td(text(def[1]||""))]) + } + return div_class("browse",wrap("table",g.functions.map(draw_fun))) + } + function draw_more(info) { + replaceChildren(cats,draw_cats(info.cats)) + replaceChildren(funs,draw_funs(info.funs)) + btn.disabled=true; + } + + function more() { t.server.browse({},draw_more) } + + var cats=wrap("div",text(g.categories.join(", "))) + var funs=wrap("div",text(g.functions.join(", "))) + var btn=button("More info",more) + + clear(t.translations.main) appendChildren(this.translations.main, [wrap("h3",text(g.name)), - node("dl",{}, - [dt(text("Start category")), - dd(text(g.startcat || "")), - dt(text("Categories")), - dd(text(g.categories.join(", "))), - dt(text("Functions")), - dd(text(g.functions.join(", ")))])]) + btn, + wrap("h4",text("Start category")), text(g.startcat || ""), + wrap("h4",text("Categories")), cats, + wrap("h4",text("Functions")), funs]) } Minibar.prototype.append_extra_buttons=function(extra,options) {