mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-04-09 04:59:31 -06:00
minibar+syntax editor integration, work in progress
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
<head>
|
||||
<title>Minibar</title>
|
||||
<link rel=stylesheet type="text/css" href="minibar.css">
|
||||
<link rel=stylesheet type="text/css" href="../syntax-editor/editor.css">
|
||||
|
||||
<link rel=author href="http://www.cse.chalmers.se/~hallgren/" title="Thomas Hallgren">
|
||||
|
||||
@@ -14,6 +15,7 @@
|
||||
<body class=minibar>
|
||||
<h2>Minibar online</h2>
|
||||
<div id=minibar></div>
|
||||
<div id=editor></div>
|
||||
|
||||
<noscript>This page doesn't works unless JavaScript is enabled.</noscript>
|
||||
|
||||
@@ -25,7 +27,7 @@
|
||||
& <a href="http://www.grammaticalframework.org:41296/translate/">Translator</a>]
|
||||
</small>
|
||||
<small class=modtime>
|
||||
HTML <!-- hhmts start -->Last modified: Tue Nov 20 13:38:35 CET 2012 <!-- hhmts end -->
|
||||
HTML <!-- hhmts start -->Last modified: Wed Nov 21 15:50:29 CET 2012 <!-- hhmts end -->
|
||||
</small>
|
||||
<address>
|
||||
|
||||
@@ -35,6 +37,9 @@ HTML <!-- hhmts start -->Last modified: Tue Nov 20 13:38:35 CET 2012 <!-- hhmts
|
||||
<script type="text/JavaScript" src="minibar_translations.js"></script>
|
||||
<script type="text/JavaScript" src="minibar_support.js"></script>
|
||||
<script type="text/JavaScript" src="../js/pgf_online.js"></script>
|
||||
<script type="text/javascript" src="../syntax-editor/ast.js"></script>
|
||||
<script type="text/javascript" src="../syntax-editor/editor_menu.js"></script>
|
||||
<script type="text/javascript" src="../syntax-editor/editor.js"></script>
|
||||
<script type="text/javascript" src="minibar_online.js"></script>
|
||||
<script type="text/javascript" src="../gfse/gf_abs.js"></script>
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// minibar_demo.js, assumes that minibar.js and pgf_online.js have been loaded.
|
||||
// minibar_online.js, assumes that minibar.js and pgf_online.js have been loaded.
|
||||
|
||||
var online_options={
|
||||
//grammars_url: "http://www.grammaticalframework.org/grammars/",
|
||||
@@ -19,6 +19,20 @@ var minibar_options= {
|
||||
try_google: true
|
||||
}
|
||||
|
||||
/*
|
||||
if(window.Editor) // Syntax editor loaded?
|
||||
minibar_options.abstract_action=function(tree) {
|
||||
var editor_options = {
|
||||
target: "editor",
|
||||
initial: { grammar: minibar.grammar_menu.value, // hmm
|
||||
startcat: minibar.input.startcat_menu.value, // hmm
|
||||
ast: tree
|
||||
}
|
||||
}
|
||||
minibar.minibar.style.display="none"
|
||||
minibar.editor=new Editor(server,editor_options)
|
||||
}
|
||||
*/
|
||||
if(/^\?\/tmp\//.test(location.search)) {
|
||||
var args=decodeURIComponent(location.search.substr(1)).split(" ")
|
||||
if(args[0]) online_options.grammars_url=args[0];
|
||||
@@ -31,4 +45,5 @@ else if(window.localStorage) {
|
||||
|
||||
var server=pgf_online(online_options);
|
||||
if(editor_dir) server.add_grammars_url(editor_dir+"/");
|
||||
|
||||
var minibar=new Minibar(server,minibar_options);
|
||||
|
||||
@@ -9,6 +9,7 @@ function Translations(server,opts) {
|
||||
// Default values for options:
|
||||
this.options={
|
||||
show_abstract: false,
|
||||
abstract_action: null, // action when selecting the abstracy syntax tree
|
||||
show_trees: false, // add buttons to show abstract syntax trees,
|
||||
// parse trees & word alignment
|
||||
tree_img_format: "png", // format for trees & alignment images,
|
||||
@@ -100,12 +101,19 @@ Translations.prototype.show_translations=function(translationResults) {
|
||||
var t = tra.translations[q];
|
||||
var lin=t.linearizations;
|
||||
var tbody=empty("tbody");
|
||||
if(options.show_abstract && t.tree)
|
||||
if(options.show_abstract && t.tree) {
|
||||
function abs_act() {
|
||||
self.options.abstract_action(t.tree)
|
||||
}
|
||||
var abs_hdr = options.abstract_action
|
||||
? button("Abstract",abs_act)
|
||||
: text("Abstract: ")
|
||||
tbody.appendChild(
|
||||
tr([th(text("Abstract: ")),
|
||||
tr([th(abs_hdr),
|
||||
tdt(node("span",{},[abstree_button(t.tree),
|
||||
alignment_button(t.tree)]),
|
||||
t.tree)]));
|
||||
}
|
||||
for(var i=0;i<lin.length;i++) {
|
||||
if(lin[i].to==to)
|
||||
trans.single_translation.push(lin[i].text);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
body {
|
||||
background: #ccc url("http://cloud.grammaticalframework.org/minibar/brushed-metal.png");
|
||||
body.syntax_editor {
|
||||
background: #ccc url("../minibar/brushed-metal.png");
|
||||
}
|
||||
|
||||
.hidden
|
||||
|
||||
@@ -4,10 +4,10 @@
|
||||
<meta charset="utf-8">
|
||||
<link rel="author" href="http://www.grammaticalframework.org/~john/" title="John J. Camilleri">
|
||||
<title>Syntax Editor</title>
|
||||
<link rel="stylesheet" type="text/css" href="http://cloud.grammaticalframework.org/minibar/minibar.css" />
|
||||
<link rel="stylesheet" type="text/css" href="../minibar/minibar.css" />
|
||||
<link rel="stylesheet" type="text/css" href="editor.css" />
|
||||
</head>
|
||||
<body>
|
||||
<body class=syntax_editor>
|
||||
<h2>Syntax Editor</h2>
|
||||
<div id="editor"></div>
|
||||
<noscript>This page doesn't works unless JavaScript is enabled.</noscript>
|
||||
|
||||
@@ -82,7 +82,7 @@ EditorMenu.prototype.show_grammarlist=function(dir,grammar_names,dir_count) {
|
||||
return hasPrefix(dir,"/tmp/gfse.") ? "gfse: "+g : g
|
||||
}
|
||||
function opt(g) { return option(glabel(g),dir+g); }
|
||||
appendChildren(grammar_menu,map(opt,grammar_names));
|
||||
appendChildren(t.ui.grammar_menu,map(opt,grammar_names));
|
||||
function pick_first_grammar() {
|
||||
if(t.timeout) clearTimeout(t.timeout),t.timeout=null;
|
||||
var grammar0=t.options.initial.grammar;
|
||||
|
||||
Reference in New Issue
Block a user