summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlon Levy <alon@pobox.com>2014-08-18 21:25:20 +0300
committerAlon Levy <alon@pobox.com>2014-08-18 21:27:01 +0300
commitf8741870a1dcd066a22545635faac274413b05bd (patch)
tree0a98ce9ec4d72d107b4723308884bd9cfb0bce16
parent59370f16a20cc56aaa61ca8a9a2aa62d418af22b (diff)
recording: record keystrokes. no strokes recorded for link renames
-rw-r--r--scripts/history.js21
-rw-r--r--scripts/rhizicore.js3
-rw-r--r--scripts/textanalysis.js14
3 files changed, 31 insertions, 7 deletions
diff --git a/scripts/history.js b/scripts/history.js
index 396b3f3c..03c9f4a1 100644
--- a/scripts/history.js
+++ b/scripts/history.js
@@ -20,11 +20,15 @@ function History(user) {
this.user = user;
}
-var ACTION_TYPE = 'ACTION_TYPE';
+var ACTION_KEYSTROKES = 'ACTION_KEYSTROKES';
var ACTION_MOUSE = 'ACTION_MOUSE';
var ACTION_GRAPH_ADD = 'ACTION_GRAPH_ADD';
var ACTION_GRAPH_DELETE = 'ACTION_GRAPH_DELETE';
+var KEYSTROKE_WHERE_TEXTANALYSIS = 'KEYSTROKE_WHERE_TEXTANALYSIS';
+var KEYSTROKE_WHERE_DOCUMENT = 'KEYSTROKE_WHERE_DOCUMENT';
+var KEYSTROKE_WHERE_EDIT_NODE = 'KEYSTROKE_WHERE_EDIT_NODE';
+
History.prototype.record = function(d)
{
if (d === undefined || d.action === undefined) {
@@ -77,3 +81,18 @@ History.prototype.record_nodes = function(nodes)
'linkes': []
});
}
+
+History.prototype.record_keystrokes = function(where, keys)
+{
+ if (keys === undefined || keys.length === undefined || keys.length <= 0) {
+ throw "Invalid arguments";
+ }
+ keys = keys.filter(function(k) { return k !== undefined; });
+ if (keys.length == 0) {
+ return;
+ }
+ this.record({'action': ACTION_KEYSTROKES,
+ 'keys': keys,
+ 'where': where
+ });
+}
diff --git a/scripts/rhizicore.js b/scripts/rhizicore.js
index f4e4f3c0..d0ba46dc 100644
--- a/scripts/rhizicore.js
+++ b/scripts/rhizicore.js
@@ -953,6 +953,9 @@ function editNode(d, i) {
$('#editname').val(oldname);
$('#editform').keypress(function(e) {
+ if (graph.history !== undefined) {
+ graph.history.record_keystrokes(KEYSTROKE_WHERE_EDIT_NODE, [e.which]);
+ }
if (e.which == 13) {
$('.editinfo').css('top', -100);
$('.editinfo').css('left', 0);
diff --git a/scripts/textanalysis.js b/scripts/textanalysis.js
index e38422d8..cff5f658 100644
--- a/scripts/textanalysis.js
+++ b/scripts/textanalysis.js
@@ -22,27 +22,27 @@ $('#textanalyser').autocompleteTrigger({
$("#textanalyser").keypress(function(e) {
+ if (graph.history !== undefined) {
+ graph.history.record_keystrokes(KEYSTROKE_WHERE_TEXTANALYSIS, [e.which]);
+ }
if (e.which == 13) {
if(!suggestionChange){
text = $('#textanalyser').val();
$('#textanalyser').val("");
TextAnalyser2(text, true);
typeStack=[];
- }else{
+ } else {
suggestionChange=false;
}
-
- return false;
+ return false;
}
if (e.which == 37) {//RIGHT
-
$('body').scrollLeft(0);
e.stopPropagation();
return false;
}
if (e.which == 39) { //LEFT
-
$('body').scrollLeft(0);
e.stopPropagation();
return false;
@@ -52,7 +52,9 @@ $("#textanalyser").keypress(function(e) {
$(document).keydown(function(e) {
-
+ if (graph.history !== undefined) {
+ graph.history.record_keystrokes(KEYSTROKE_WHERE_DOCUMENT, [e.KeyCode]);
+ }
if (e.keyCode == 9) {//TAB
e.preventDefault();
changeType("down", lastnode);