Bento box search with multiple targets
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

1 lines
1.4 KiB

(function(e){var t={};var n=function(e){for(var t=0;t<e.length;t++){if(!(e[t]instanceof Array)){throw new Error("Every argument must be an array!")}}};t.distinct=function(t){if(arguments.length!=1)throw new Error("There must be exactly 1 array argument!");n(arguments);var r=[];for(var i=0;i<t.length;i++){var s=t[i];if(e.inArray(s,r)===-1){r.push(s)}}return r};t.union=function(){if(arguments.length<2)throw new Error("There must be minimum 2 array arguments!");n(arguments);var t=this.distinct(arguments[0]);for(var r=1;r<arguments.length;r++){var i=arguments[r];for(var s=0;s<i.length;s++){var o=i[s];if(e.inArray(o,t)===-1){t.push(o)}}}return t};t.intersect=function(){if(arguments.length<2)throw new Error("There must be minimum 2 array arguments!");n(arguments);var t=[];var r=this.distinct(arguments[0]);if(r.length===0)return[];for(var i=0;i<r.length;i++){var s=r[i];var o=true;for(var u=1;u<arguments.length;u++){var a=arguments[u];if(a.length==0)return[];if(e.inArray(s,a)===-1){o=false;break}}if(o){t.push(s)}}return t};t.except=function(){if(arguments.length<2)throw new Error("There must be minimum 2 array arguments!");n(arguments);var t=[];var r=this.distinct(arguments[0]);var i=[];for(var s=1;s<arguments.length;s++){var o=arguments[s];i=i.concat(o)}for(var s=0;s<r.length;s++){var u=r[s];if(e.inArray(u,i)===-1){t.push(u)}}return t};e.arrayUtilities=t;e.distinct=t.distinct;e.union=t.union;e.intersect=t.intersect;e.except=t.except})(jQuery)