summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/consts.js1
-rw-r--r--src/history.js14
-rw-r--r--src/textanalysis.ui.js3
3 files changed, 18 insertions, 0 deletions
diff --git a/src/consts.js b/src/consts.js
index 310d6153..cfcdd1c2 100644
--- a/src/consts.js
+++ b/src/consts.js
@@ -6,5 +6,6 @@ define(function() {
KEYSTROKE_WHERE_EDIT_NODE: 'keystroke_where_edit_node',
KEYSTROKE_WHERE_DOCUMENT: 'keystroke_where_document',
KEYSTROKE_WHERE_TEXTANALYSIS: 'keystroke_where_textanalysis',
+ INPUT_WHERE_TEXTANALYSIS: 'input_where_textanalysis',
};
});
diff --git a/src/history.js b/src/history.js
index a6a02ec3..37e96718 100644
--- a/src/history.js
+++ b/src/history.js
@@ -31,6 +31,7 @@ function History(user, graph, transform_element) {
return that.record_graph_diff(obj)
});
rz_bus.ui_key.onValue(that.record_keystrokes.bind(that));
+ rz_bus.ui_input.onValue(that.record_input.bind(that));
// XXX create zoom behavior - then proof to event name change
$(window).on('wheel.history', function(obj) {
that.record_zoom(obj);
@@ -39,6 +40,7 @@ function History(user, graph, transform_element) {
}
var ACTION_KEYSTROKES = 'ACTION_KEYSTROKES';
+var ACTION_INPUT = 'ACTION_INPUT';
var ACTION_GRAPH_DIFF = 'ACTION_GRAPH_DIFF';
var ACTION_ZOOM = 'ACTION_ZOOM';
@@ -126,6 +128,18 @@ History.prototype.record_keystrokes = function(obj)
});
}
+History.prototype.record_input = function(obj)
+{
+ var where = obj.where,
+ input = obj.input;
+
+ if (where === undefined || input === undefined || input.length === undefined || typeof input !== 'string') {
+ console.log('invalid arguments');
+ return;
+ }
+ this.record(ACTION_INPUT, {where: where, input: input});
+}
+
return {
History:History,
KEYSTROKE_WHERE_TEXTANALYSIS:KEYSTROKE_WHERE_TEXTANALYSIS,
diff --git a/src/textanalysis.ui.js b/src/textanalysis.ui.js
index 380427be..f41ebaa5 100644
--- a/src/textanalysis.ui.js
+++ b/src/textanalysis.ui.js
@@ -174,10 +174,13 @@ return {
return ret;
});
+ var input = new Bacon.Bus();
+ rz_bus.ui_input.plug(input);
if ('oninput' in document.documentElement) {
element.on('input', function(e) {
text = element.val();
analyzeSentence(text, false);
+ input.push({where: consts.INPUT_WHERE_TEXTANALYSIS, input: text});
});
} else {
console.log('textanalysis.ui: fallback to polling');