diff options
Diffstat (limited to 'src/client/util.js')
| -rw-r--r-- | src/client/util.js | 13 |
1 files changed, 12 insertions, 1 deletions
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, |
