summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlon Levy <alon@pobox.com>2014-12-04 18:45:14 +0200
committerAlon Levy <alon@pobox.com>2014-12-04 18:45:14 +0200
commit04f27ccb05b429b3d1fd96d8389c561a87c4e2a0 (patch)
treec2e89ac7abc4101138f0bea2ab3203fccf82ad61 /src
parent52f4be6d1044f791d98f9d887e09034ec3a23f07 (diff)
implement graph.editStatus (small refactor)
Diffstat (limited to 'src')
-rw-r--r--src/model/graph.js26
1 files changed, 15 insertions, 11 deletions
diff --git a/src/model/graph.js b/src/model/graph.js
index 0fb61775..de9cddd7 100644
--- a/src/model/graph.js
+++ b/src/model/graph.js
@@ -369,24 +369,28 @@ function Graph() {
* @return true if type changed
*/
this.editType = function(id, state, newtype) {
- var index = findNode(id, state);
- if ((index !== undefined)) {
- index.type = newtype;
- }
+ return this._editProperty(id, state, 'type', newtype);
}
this.editURL = function(id, state, url) {
- var index = findNode(id, state);
- if ((index === undefined)) return;
- index.url = url;
+ return this._editProperty(id, state, 'url', url);
}
- this.editState = function(id, state, newstate) {
+ this._editProperty = function(id, state, prop, value) {
var index = findNode(id, state);
-
- if ((index !== undefined)) {
- index.state = newstate;
+ if ((index === undefined)) {
+ return false;
}
+ index[prop] = value;
+ return true;
+ }
+
+ this.editStatus = function(id, state, status) {
+ return this._editProperty(id, state, 'status', status);
+ }
+
+ this.editState = function(id, state, newstate) {
+ return this._editProperty(id, state, 'state', newstate);
}
this.findCoordinates = function(id, type) {