From 1767f68b2e0437ac574bd265c25bed9e3fd99643 Mon Sep 17 00:00:00 2001 From: Alon Levy Date: Tue, 28 Oct 2014 19:15:55 +0200 Subject: history: refactor action key to record parameter --- scripts/history.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/scripts/history.js b/scripts/history.js index 1df562ce..0a1df199 100644 --- a/scripts/history.js +++ b/scripts/history.js @@ -44,11 +44,12 @@ 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) +History.prototype.record = function(action, d) { - if (d === undefined || d.action === undefined) { + if (d === undefined || action === undefined) { throw "Invalid arguments"; } + d['action'] = action; d['user'] = this.user; d['timestamp'] = new Date(); this.records.push(d); @@ -75,8 +76,7 @@ History.prototype.clear_history = function() History.prototype.record_graph_diff = function(obj) { - this.record({ - action: ACTION_GRAPH_DIFF, + this.record(ACTION_GRAPH_DIFF, { nodes: {add: obj.nodes && obj.nodes.add, remove: obj.nodes && obj.nodes.remove, change: obj.nodes && obj.nodes.change}, links: {add: obj.links && obj.links.add, remove: obj.links && obj.links.remove, @@ -97,7 +97,7 @@ History.prototype.record_keystrokes = function(obj) if (keys.length == 0) { return; } - this.record({action: ACTION_KEYSTROKES, + this.record(ACTION_KEYSTROKES, { 'keys': keys, 'where': where }); -- cgit v1.3.1