summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--edit.html4
-rw-r--r--r.js41
2 files changed, 44 insertions, 1 deletions
diff --git a/edit.html b/edit.html
index 2adb397..a1394ec 100644
--- a/edit.html
+++ b/edit.html
@@ -11,10 +11,12 @@
<body>
<div id='holder'></div>
<input type='button' value='+' onClick='add_obj()' />
+ <input type='button' value='D' onClick='extract_data()' onClick='extract_data()' />
<p id='debug'></p>
+ <pre id='data'></pre>
<h3>TODO</h3>
<ul>
- <li>extract data</li>
+ <li>integrate into MT system</li>
</ul>
</body>
</html>
diff --git a/r.js b/r.js
index ec67b05..811aa61 100644
--- a/r.js
+++ b/r.js
@@ -368,6 +368,47 @@ make_objs = function (a, type)
}
};
+/*
+ * data
+ *
+ */
+var extract_data = function ()
+{
+ el = document.getElementById("data");
+ d = {};
+ d["source"] = [];
+ d["target"] = [];
+ d["align"] = [];
+ // target
+ var ids = [];
+ target_shapes.sort(function(a, b) {
+ return a["grid_"]-b["grid_"];
+ });
+ for (var i=0; i<target_shapes.length; i++) {
+ d["target"].push(target_shapes[i].pair.attr("text"));
+ ids.push(target_shapes[i]["id_"]);
+ }
+ // alignment
+ for (key in connections) {
+ var a = key.split('-');
+ var src = a[0], tgt = ids.indexOf(parseInt(a[1]));
+ d["align"].push(src+'-'+tgt);
+ }
+ // source
+ for (var i=0; i<shapes.length; i++) {
+ if (shapes[i]["type_"] == "source") {
+ d["source"].push(shapes[i].pair.attr("text"));
+ } else {
+ break;
+ }
+ }
+ // output
+ s = JSON.stringify(d);
+ el.innerHTML = s;
+
+ return s;
+}
+
///////////////////////////////////////////////////////////////////////////////