kopia lustrzana https://github.com/magicbug/Cloudlog
3 wiersze
46 KiB
JavaScript
3 wiersze
46 KiB
JavaScript
![]() |
/*! selectize.js - v0.13.0 | https://github.com/selectize/selectize.js | Apache License (v2) */
|
|||
|
|
|||
|
!function(e,t){"function"==typeof define&&define.amd?define("sifter",t):"object"==typeof exports?module.exports=t():e.Sifter=t()}(this,function(){function e(e,t){this.items=e,this.settings=t||{diacritics:!0}}e.prototype.tokenize=function(e){if(!(e=a(String(e||"").toLowerCase()))||!e.length)return[];for(var t,n,i=[],o=e.split(/ +/),s=0,r=o.length;s<r;s++){if(t=l(o[s]),this.settings.diacritics)for(n in p)p.hasOwnProperty(n)&&(t=t.replace(new RegExp(n,"g"),p[n]));i.push({string:o[s],regex:new RegExp(t,"i")})}return i},e.prototype.iterator=function(e,t){var n=r(e)?Array.prototype.forEach||function(e){for(var t=0,n=this.length;t<n;t++)e(this[t],t,this)}:function(e){for(var t in this)this.hasOwnProperty(t)&&e(this[t],t,this)};n.apply(e,[t])},e.prototype.getScoreFunction=function(e,t){var o,s,r,a;e=this.prepareSearch(e,t),s=e.tokens,o=e.options.fields,r=s.length,a=e.options.nesting;function l(e,t){var n;return!e||-1===(n=(e=String(e||"")).search(t.regex))?0:(e=t.string.length/e.length,0===n&&(e+=.5),e)}var p,c=(p=o.length)?1===p?function(e,t){return l(g(t,o[0],a),e)}:function(e,t){for(var n=0,i=0;n<p;n++)i+=l(g(t,o[n],a),e);return i/p}:function(){return 0};return r?1===r?function(e){return c(s[0],e)}:"and"===e.options.conjunction?function(e){for(var t,n=0,i=0;n<r;n++){if((t=c(s[n],e))<=0)return 0;i+=t}return i/r}:function(e){for(var t=0,n=0;t<r;t++)n+=c(s[t],e);return n/r}:function(){return 0}},e.prototype.getSortFunction=function(e,n){var t,i,o,s,r,a,l,p=this,c=!(e=p.prepareSearch(e,n)).query&&n.sort_empty||n.sort,d=function(e,t){return"$score"===e?t.score:g(p.items[t.id],e,n.nesting)},u=[];if(c)for(t=0,i=c.length;t<i;t++)!e.query&&"$score"===c[t].field||u.push(c[t]);if(e.query){for(l=!0,t=0,i=u.length;t<i;t++)if("$score"===u[t].field){l=!1;break}l&&u.unshift({field:"$score",direction:"desc"})}else for(t=0,i=u.length;t<i;t++)if("$score"===u[t].field){u.splice(t,1);break}for(a=[],t=0,i=u.length;t<i;t++)a.push("desc"===u[t].direction?-1:1);return(s=u.length)?1===s?(o=u[0].field,r=a[0],function(e,t){return r*h(d(o,e),d(o,t))}):function(e,t){for(var n,i=0;i<s;i++)if(n=u[i].field,n=a[i]*h(d(n,e),d(n,t)))return n;return 0}:null},e.prototype.prepareSearch=function(e,t){if("object"==typeof e)return e;var n=(t=s({},t)).fields,i=t.sort,o=t.sort_empty;return n&&!r(n)&&(t.fields=[n]),i&&!r(i)&&(t.sort=[i]),o&&!r(o)&&(t.sort_empty=[o]),{options:t,query:String(e||"").toLowerCase(),tokens:this.tokenize(e),total:0,items:[]}},e.prototype.search=function(e,n){var i,o,t=this,s=this.prepareSearch(e,n);return n=s.options,e=s.query,o=n.score||t.getScoreFunction(s),e.length?t.iterator(t.items,function(e,t){i=o(e),(!1===n.filter||0<i)&&s.items.push({score:i,id:t})}):t.iterator(t.items,function(e,t){s.items.push({score:1,id:t})}),(t=t.getSortFunction(s,n))&&s.items.sort(t),s.total=s.items.length,"number"==typeof n.limit&&(s.items=s.items.slice(0,n.limit)),s};var h=function(e,t){return"number"==typeof e&&"number"==typeof t?t<e?1:e<t?-1:0:(e=n(String(e||"")),(t=n(String(t||"")))<e?1:e<t?-1:0)},s=function(e,t){for(var n,i,o=1,s=arguments.length;o<s;o++)if(i=arguments[o])for(n in i)i.hasOwnProperty(n)&&(e[n]=i[n]);return e},g=function(e,t,n){if(e&&t){if(!n)return e[t];for(var i=t.split(".");i.length&&(e=e[i.shift()]););return e}},a=function(e){return(e+"").replace(/^\s+|\s+$|/g,"")},l=function(e){return(e+"").replace(/([.?*+^$[\]\\(){}|-])/g,"\\$1")},r=Array.isArray||"undefined"!=typeof $&&$.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)},p={a:"[aḀḁĂăÂâǍǎȺⱥȦȧẠạÄäÀàÁáĀāÃãÅåąĄÃąĄ]",b:"[b␢βΒB฿𐌁ᛒ]",c:"[cĆćĈĉČčĊċC̄c̄ÇçḈḉȻȼƇƈɕᴄCc]",d:"[dĎďḊḋḐḑḌḍḒḓḎḏĐđD̦d̦ƉɖƊɗƋƌᵭᶁᶑȡᴅDdð]",e:"[eÉéÈèÊêḘḙĚěĔĕẼẽḚḛẺẻĖėËëĒēȨȩĘęᶒɆɇȄȅẾếỀềỄễỂểḜḝḖḗḔḕȆȇẸẹỆệⱸᴇEeɘǝƏƐε]",f:"[fƑƒḞḟ]",g:"[gɢ₲ǤǥĜĝĞğĢģƓɠĠġ]",h:"[hĤĥĦħḨḩẖẖḤḥḢḣɦʰǶƕ]",i:"[iÍíÌìĬĭÎîǏǐÏïḮḯĨĩĮįĪīỈỉȈȉȊȋỊịḬḭƗɨɨ
|