diff --git a/js/tags.js b/js/tags.js index 7bea397e7ec5cadbb0173943e19ab52345dc7d0a..d627aa962d4ee2bd28edf405f97ed72869abb4ec 100644 --- a/js/tags.js +++ b/js/tags.js @@ -254,10 +254,13 @@ function Tags() { tags.mouseclick = function (d) { lock = true; - console.log("clikc", d) - if(filterWords.indexOf(d.key)>-1){ + console.log(d.key, filterWords) _.remove(filterWords,function(d2){ return d2 == d.key; }); + // if hierarchical keywords, could turn those into an array instead of strings + if(d.key.indexOf(":")){ + filterWords = filterWords.filter(f => !f.startsWith(d.key)) + } } else { filterWords.push(d.key); } diff --git a/js/utils.js b/js/utils.js index 0f37d832796bf9f1c97e9a986cecc8d06ee8c3e9..13338d9095b40fb61584455d7276710762b08afa 100644 --- a/js/utils.js +++ b/js/utils.js @@ -149,3 +149,60 @@ utils.simulateLargeDatasets = function(data){ Array.prototype.push.apply(data, _.clone(data, true).slice(0,1036)) } + + + +if (!String.prototype.startsWith) { + (function() { + 'use strict'; // needed to support `apply`/`call` with `undefined`/`null` + var defineProperty = (function() { + // IE 8 only supports `Object.defineProperty` on DOM elements + try { + var object = {}; + var $defineProperty = Object.defineProperty; + var result = $defineProperty(object, object, object) && $defineProperty; + } catch(error) {} + return result; + }()); + var toString = {}.toString; + var startsWith = function(search) { + if (this == null) { + throw TypeError(); + } + var string = String(this); + if (search && toString.call(search) == '[object RegExp]') { + throw TypeError(); + } + var stringLength = string.length; + var searchString = String(search); + var searchLength = searchString.length; + var position = arguments.length > 1 ? arguments[1] : undefined; + // `ToInteger` + var pos = position ? Number(position) : 0; + if (pos != pos) { // better `isNaN` + pos = 0; + } + var start = Math.min(Math.max(pos, 0), stringLength); + // Avoid the `indexOf` call if no match is possible + if (searchLength + start > stringLength) { + return false; + } + var index = -1; + while (++index < searchLength) { + if (string.charCodeAt(start + index) != searchString.charCodeAt(index)) { + return false; + } + } + return true; + }; + if (defineProperty) { + defineProperty(String.prototype, 'startsWith', { + 'value': startsWith, + 'configurable': true, + 'writable': true + }); + } else { + String.prototype.startsWith = startsWith; + } + }()); +} \ No newline at end of file