summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorjohn.j.camilleri <john.j.camilleri@chalmers.se>2012-11-16 09:33:55 +0000
committerjohn.j.camilleri <john.j.camilleri@chalmers.se>2012-11-16 09:33:55 +0000
commit67ca0a1eae3875cb72c4a89fe7d0f454722c3b59 (patch)
treed9c7d820f08adb8d6015081fcf0e1534c57ce8ad /src
parent225cebf1214c07b5195cc8ea898bab01fabbdbc6 (diff)
Syntax editor: select subset of available languages
Also added a basic readme file with a list of todo's
Diffstat (limited to 'src')
-rw-r--r--src/www/syntax-editor/README.md32
-rw-r--r--src/www/syntax-editor/js/editor.js6
-rw-r--r--src/www/syntax-editor/js/editor_menu.js25
-rw-r--r--src/www/syntax-editor/ui/style.css12
4 files changed, 67 insertions, 8 deletions
diff --git a/src/www/syntax-editor/README.md b/src/www/syntax-editor/README.md
new file mode 100644
index 000000000..e47d67518
--- /dev/null
+++ b/src/www/syntax-editor/README.md
@@ -0,0 +1,32 @@
+# GF web-based syntax editor
+
+John J. Camilleri
+November 2012
+
+An improved version of the [old syntax editor][1].
+
+[1]:http://www.grammaticalframework.org/~meza/restWiki/editor.html
+
+## Notes
+
+Tested with latest Chrome and Firefox.
+
+## TODO
+
+- Enter string/float/int literals
+- UI issue with DisambPhrasebookEng
+- more prominence to Disamb-linearizations
+- ambiguity: (optionally) parse all the resulting linearizations/variants and point out those which are ambiguous
+- random-generate a non-empty tree as a starting point
+- try to retain subtree when replacing node
+- add undo/redo (or back/forward) navigation
+- structure the set of fridge magnets some more. Even though they
+are alphabetically sorted, it's difficult to find the one that I want,
+maybe put a newline before the magnet whose first letter is different
+with respect to the previous magnet
+- The formal-looking funs and cats are not linked/aligned to the linearizations.
+Maybe a possible UI could be where the user is
+clicking on the linearization (in a chosen language) and the tree is
+drawn under it (from top to bottom, not from left to right as
+currently). So that the alignment of words to functions is always
+explicit. But maybe this is not doable.
diff --git a/src/www/syntax-editor/js/editor.js b/src/www/syntax-editor/js/editor.js
index b7fa2dd87..608770edb 100644
--- a/src/www/syntax-editor/js/editor.js
+++ b/src/www/syntax-editor/js/editor.js
@@ -108,14 +108,16 @@ Editor.prototype.get_refinements=function(cat) {
Editor.prototype.select_refinement=function(fun) {
with (this) {
+ clear(ui.refinements);
ast.removeChildren();
ast.setFun(fun);
+// redraw_tree();
+
var args = {
id: fun,
format: "json"
};
var err = function(data){
- clear(refinements);
alert("no refinements");
};
server.browse(args, bind(complete_refinement,this), err);
@@ -139,7 +141,7 @@ Editor.prototype.complete_refinement=function(data) {
}
}
- // Update vis
+ // Update ui
redraw_tree();
update_linearisation();
diff --git a/src/www/syntax-editor/js/editor_menu.js b/src/www/syntax-editor/js/editor_menu.js
index 874859ae7..ce0894ee0 100644
--- a/src/www/syntax-editor/js/editor_menu.js
+++ b/src/www/syntax-editor/js/editor_menu.js
@@ -15,11 +15,22 @@ function EditorMenu(editor,opts) {
this.container = editor.ui.menubar;
this.ui = {
startcat_menu: empty("select"),
- to_menu: empty_id("select","to_menu")
+ to_toggle: button("...", function(){
+ var sel = t.ui.to_menu;
+ if (sel.classList.contains("hidden"))
+ sel.classList.remove("hidden")
+ else
+ sel.classList.add("hidden")
+ }),
+ to_menu: node("select",{
+ id: "to_menu",
+ multiple: "multiple",
+ class: "hidden"
+ } )
};
with(this.ui) {
appendChildren(this.container, [text(" Startcat: "),startcat_menu]);
- appendChildren(this.container, [text(" To: "), to_menu]);
+ appendChildren(this.container, [text(" To: "), to_toggle, to_menu]);
startcat_menu.onchange=bind(this.change_startcat,this);
to_menu.onchange=bind(this.change_language,this);
}
@@ -119,10 +130,12 @@ EditorMenu.prototype.change_startcat=function () {
//
EditorMenu.prototype.change_language=function () {
- if (this.ui.to_menu.value == "All")
- this.editor.languages = new Array();
- else
- this.editor.languages = new Array(this.ui.to_menu.value);
+ this.editor.languages = new Array();
+ for (i in this.ui.to_menu.options) {
+ var opt = this.ui.to_menu.options[i];
+ if (opt.selected)
+ this.editor.languages.push(opt.value);
+ }
this.editor.update_linearisation();
}
diff --git a/src/www/syntax-editor/ui/style.css b/src/www/syntax-editor/ui/style.css
index f4f29d040..127b1ad2a 100644
--- a/src/www/syntax-editor/ui/style.css
+++ b/src/www/syntax-editor/ui/style.css
@@ -2,6 +2,18 @@ body {
background: #ccc url("http://cloud.grammaticalframework.org/minibar/brushed-metal.png");
}
+.hidden
+{
+ display:none;
+}
+
+select#to_menu
+{
+ height: 10em;
+ position: absolute;
+ min-width: 5em;
+ }
+
#tree
{
white-space:pre;