diff options
| author | Alon Levy <alon@pobox.com> | 2015-04-10 14:27:55 +0200 |
|---|---|---|
| committer | Alon Levy <alon@pobox.com> | 2015-04-10 14:27:55 +0200 |
| commit | f29bbaa624991cedc1bfdec06aeb254357472555 (patch) | |
| tree | da39751f28e1fafae379275eb7a2d15d0ca00fcf /src/client | |
| parent | a3691e04c8e43d2482fc7be3193455c8c72adc0e (diff) | |
client: hack to allow collaborator/person to be default (will fix today)
Diffstat (limited to 'src/client')
| -rw-r--r-- | src/client/textanalysis.js | 2 | ||||
| -rw-r--r-- | src/client/util.js | 13 |
2 files changed, 13 insertions, 2 deletions
diff --git a/src/client/textanalysis.js b/src/client/textanalysis.js index 4058f5b7..0e64fed3 100644 --- a/src/client/textanalysis.js +++ b/src/client/textanalysis.js @@ -12,7 +12,7 @@ var separator_string = rz_config.separator_string; var typeindex = 0, nodetypes = model_types.nodetypes, nodetypes_count = nodetypes.length, - default_nodetype = 'collaborator', + default_nodetype = util.first_contained(nodetypes, ['collaborator', 'person'], nodetypes[0]), node_name_to_type = {}; util.assert(nodetypes.indexOf(default_nodetype) !== -1); diff --git a/src/client/util.js b/src/client/util.js index 88226a4d..fcb0eec7 100644 --- a/src/client/util.js +++ b/src/client/util.js @@ -1,6 +1,6 @@ "use strict" -define(['jquery'], function($) { +define(['underscore', 'jquery'], function(_, $) { function assert(condition, message) { if (false == condition) { @@ -53,6 +53,16 @@ define(['jquery'], function($) { return set_diff(sa, sb); } + function first_contained(list, candidates, default_result) { + for (var k in candidates) { + var list_item = list[k]; + if (_.contains(candidates, list_item)) { + return list_item; + } + }; + return default_result; + } + // TODO: jquery BBQ: $.deparam.querystring().json; function getParameterByName(name) { name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]"); @@ -251,6 +261,7 @@ define(['jquery'], function($) { set_from_array: set_from_array, set_from_object: set_from_object, set_diff: set_diff, + first_contained: first_contained, setSelection: setSelection, selectionStart: selectionStart, |
