From f29bbaa624991cedc1bfdec06aeb254357472555 Mon Sep 17 00:00:00 2001 From: Alon Levy Date: Fri, 10 Apr 2015 14:27:55 +0200 Subject: client: hack to allow collaborator/person to be default (will fix today) --- src/client/textanalysis.js | 2 +- 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, -- cgit v1.3.1