summaryrefslogtreecommitdiff
path: root/src/www/syntax-editor/editor_online.js
blob: dc2325737dffba50d08312a98feadc928705b051 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
var server_options = {
    // grammars_url: "http://www.grammaticalframework.org/grammars/",
    // grammars_url: "http://localhost:41296/grammars/",
}
var editor_options = {
    target: "editor",
    initial: {
//        abstr: "PropOpenDate (SuperlPlace TheMostExpensive School) Tomorrow"
    },
    show: {
        grammar_menu: true,
        startcat_menu: true,
        to_menu: true,
        random_button: true
    }
}
var gm_options = {
    initial: {
        // grammar: "http://localhost:41296/grammars/Smart.pgf",
        // startcat: "Command",
        // languages: ["Eng","Swe"]
    }
}
if(window.Minibar) // Minibar loaded?
    editor_options.lin_action_tooltip="Load sentence in Minibar";
    editor_options.lin_action=function(s,langFrom) {
        var editor=this;
        var minibar_options = {
            target: "minibar",
            show_abstract: true,
            show_trees: true,
            show_grouped_translations: false,
            show_brackets: true,
            word_replacements: true,
            initial_grammar: editor.menu.ui.grammar_menu.value, // hmm
            initial: {
                from: langFrom,
                input: s.split(" "), // is it that easy?
		startcat: editor.menu.ui.startcat_menu.value // hmm
            },
	    initial_toLangs: multiMenuSelections(editor.menu.ui.to_menu), // hmm

            // get us back to the editor!
            abstract_action: function(tree) {
                var opts = {
                    abstr: tree
                }
                editor.initialize_from(opts);
                editor.minibar.hide();
                editor.show();
            }
        }
        editor.hide();
        editor.minibar=new Minibar(server,minibar_options);
        //editor.minibar.editor = editor; // :S
	editor.minibar.show();
    }
if(/^\?\/tmp\//.test(location.search)) {
    var args=decodeURIComponent(location.search.substr(1)).split(" ")
    if(args[0]) server_options.grammars_url=args[0];
}
var server = pgf_online(server_options);
var gm = new GrammarManager(server, gm_options);
var editor = new Editor(gm, editor_options);