mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-04-23 03:32:51 -06:00
translator: you can now import text by copying and pasting
This commit is contained in:
@@ -22,7 +22,8 @@
|
|||||||
</dl>
|
</dl>
|
||||||
<td>Edit
|
<td>Edit
|
||||||
<dl>
|
<dl>
|
||||||
<dt onclick="translator.import(this)">Add a segment...
|
<dt onclick="translator.import(this)">Import text...
|
||||||
|
<dt onclick="translator.add_segment(this)">Add a segment...
|
||||||
<dt onclick="translator.remove(this)">Remove the last segment
|
<dt onclick="translator.remove(this)">Remove the last segment
|
||||||
</dl>
|
</dl>
|
||||||
<td>View
|
<td>View
|
||||||
@@ -68,7 +69,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<hr>
|
<hr>
|
||||||
<div class=modtime><small>HMTL
|
<div class=modtime><small>HMTL
|
||||||
<!-- hhmts start --> Last modified: Wed May 16 16:15:20 CEST 2012 <!-- hhmts end -->
|
<!-- hhmts start --> Last modified: Fri May 25 16:08:41 CEST 2012 <!-- hhmts end -->
|
||||||
</small></div>
|
</small></div>
|
||||||
<a href="about.html">About</a>
|
<a href="about.html">About</a>
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
body { margin: 5px; }
|
body { margin: 5px; }
|
||||||
h1 { float: right; margin: 0; font-size: 150%; }
|
h1 { float: right; margin: 0; font-size: 150%; }
|
||||||
h2 { font-size: 120%; }
|
h2 { font-size: 120%; }
|
||||||
|
h3 { font-size: 100%; }
|
||||||
|
|
||||||
div.pagehead { font-family: sans-serif;
|
div.pagehead { font-family: sans-serif;
|
||||||
background-color: #ccc;
|
background-color: #ccc;
|
||||||
}
|
}
|
||||||
@@ -26,7 +28,7 @@ div.document {
|
|||||||
padding: 0.6ex;
|
padding: 0.6ex;
|
||||||
}
|
}
|
||||||
|
|
||||||
div.document h2 { color: #009; }
|
div.document h2, div.document h3 { color: #009; }
|
||||||
|
|
||||||
table.segments { margin-left: auto; margin-right: auto; }
|
table.segments { margin-left: auto; margin-right: auto; }
|
||||||
tr.segment:hover { background: #ffc; }
|
tr.segment:hover { background: #ffc; }
|
||||||
@@ -46,9 +48,11 @@ td.options > div > dl {
|
|||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
}
|
}
|
||||||
|
|
||||||
td.target input[name=it] {
|
td.source input[name=it], td.target input[name=it], textarea {
|
||||||
width: 100%; font-family: inherit; font-size: inherit;
|
width: 100%; font-family: inherit; font-size: inherit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
div.document form { width: 100%; }
|
||||||
|
|
||||||
span.arrow { color: blue; }
|
span.arrow { color: blue; }
|
||||||
span.error { color: red; }
|
span.error { color: red; }
|
||||||
|
|||||||
@@ -211,8 +211,8 @@ Translator.prototype.close=function(el) {
|
|||||||
hide_menu(el);
|
hide_menu(el);
|
||||||
this.browse();
|
this.browse();
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
Translator.prototype.import=function(el) {
|
Translator.prototype.add_segment1=function(el) {
|
||||||
hide_menu(el);
|
hide_menu(el);
|
||||||
var t=this
|
var t=this
|
||||||
function imp() {
|
function imp() {
|
||||||
@@ -224,6 +224,70 @@ Translator.prototype.import=function(el) {
|
|||||||
}
|
}
|
||||||
setTimeout(imp,100)
|
setTimeout(imp,100)
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
Translator.prototype.add_segment=function(el) {
|
||||||
|
hide_menu(el);
|
||||||
|
var t=this
|
||||||
|
function imp() {
|
||||||
|
function restore() {
|
||||||
|
t.redraw()
|
||||||
|
}
|
||||||
|
function done() {
|
||||||
|
var text=inp.value
|
||||||
|
if(text) t.document.segments.push(new_segment(text))
|
||||||
|
restore()
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
var inp=node("input",{name:"it",value:""})
|
||||||
|
var e=wrap("form",[inp, submit(), button("Cancel",restore)])
|
||||||
|
var source=wrap_class("td","source",e)
|
||||||
|
var edit=wrap_class("tr","segment",source)
|
||||||
|
|
||||||
|
var ss=t.drawing.segments
|
||||||
|
var n=ss.length
|
||||||
|
if(n>0) insertAfter(edit,ss[n-1])
|
||||||
|
else t.view.appendChild(wrap_class("table","segments",edit))
|
||||||
|
|
||||||
|
e.onsubmit=done
|
||||||
|
inp.focus();
|
||||||
|
}
|
||||||
|
setTimeout(imp,100)
|
||||||
|
}
|
||||||
|
|
||||||
|
Translator.prototype.import=function(el) {
|
||||||
|
hide_menu(el);
|
||||||
|
var t=this
|
||||||
|
function imp() {
|
||||||
|
function restore() {
|
||||||
|
t.redraw()
|
||||||
|
}
|
||||||
|
function done2() {
|
||||||
|
var text=inp.value
|
||||||
|
var ls=text.split("\n")
|
||||||
|
var segs= paras.firstChild.checked ? join_paragraphs(ls) : ls
|
||||||
|
for(var i in segs)
|
||||||
|
t.document.segments.push(new_segment(segs[i]))
|
||||||
|
restore()
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
var inp=node("textarea",{name:"it",value:"",rows:"10"})
|
||||||
|
var lines=radiobutton("separator","lines",
|
||||||
|
"Segments are separated by line breaks",null,true)
|
||||||
|
var paras=radiobutton("separator","paras",
|
||||||
|
"Segments are separate by blank lines",null,false)
|
||||||
|
var e=node("form",{onsubmit:done2},
|
||||||
|
[wrap("h3",text("Import text")),
|
||||||
|
inp,
|
||||||
|
wrap("dl",map(dt,[lines,paras])),
|
||||||
|
submit(), button("Cancel",restore)])
|
||||||
|
|
||||||
|
t.view.appendChild(e)
|
||||||
|
e.onsubmit=done2
|
||||||
|
inp.focus();
|
||||||
|
}
|
||||||
|
setTimeout(imp,100)
|
||||||
|
}
|
||||||
|
|
||||||
Translator.prototype.remove=function(el) {
|
Translator.prototype.remove=function(el) {
|
||||||
hide_menu(el);
|
hide_menu(el);
|
||||||
var t=this
|
var t=this
|
||||||
@@ -419,6 +483,17 @@ function mapix(f,xs) {
|
|||||||
return ys;
|
return ys;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Convert array of lines to array of paragraphs
|
||||||
|
function join_paragraphs(lines) {
|
||||||
|
var paras=[]
|
||||||
|
var current="";
|
||||||
|
for(var i in lines)
|
||||||
|
if(lines[i]=="") paras.push(current),current=""
|
||||||
|
else current+=" "+lines[i]
|
||||||
|
if(current) paras.push(current)
|
||||||
|
return paras
|
||||||
|
}
|
||||||
|
|
||||||
/* --- DOM Support ---------------------------------------------------------- */
|
/* --- DOM Support ---------------------------------------------------------- */
|
||||||
|
|
||||||
function a(url,linked) { return node("a",{href:url},linked); }
|
function a(url,linked) { return node("a",{href:url},linked); }
|
||||||
|
|||||||
Reference in New Issue
Block a user