X-Git-Url: http://git.roojs.org/?p=Pman.Core;a=blobdiff_plain;f=Pman.SearchTokenizer.js;h=8db0be1b8579dbfad2a4dac29c7e41c7d518e78a;hp=1f6536c137a53bb3f4d617488609eefe7d17b880;hb=1524f8b36295809a3eedd6da3c6494f8aa0d86f5;hpb=fe82c513a6ed8b425909cb92e93366ed842db364 diff --git a/Pman.SearchTokenizer.js b/Pman.SearchTokenizer.js index 1f6536c1..8db0be1b 100644 --- a/Pman.SearchTokenizer.js +++ b/Pman.SearchTokenizer.js @@ -14,8 +14,8 @@ Pman.SearchTokenizer = function(s) { - this.str = s; - this.strlen = s.length; + this.str = typeof(s) == 'string' ? s : ''; + this.strlen = typeof(s) == 'string' ? s.length : 0; this.i = 0; this.tokens = []; //print_r(this); @@ -49,6 +49,10 @@ Pman.SearchTokenizer.prototype = { } } + // sort tokens longest first.. + + + // should not get here... return this.tokens; }, @@ -111,12 +115,12 @@ Pman.SearchTokenizer.prototype = { } if (!q) { - if ((s..toUpperCase() == 'AND') || (s.toUpperCase() == 'OR')) { + if ((s.toUpperCase() == 'AND') || (s.toUpperCase() == 'OR')) { this.tokens.push( { type: s.toUpperCase() }); return; } } - this.tokens.push( { type : 's' , v : s }); + this.tokens.push( { type : 's' , v : s, q: q }); }, getChar : function () @@ -134,10 +138,10 @@ Pman.SearchTokenizer.prototype = { this.i--; } -} -Pman.SearchTokenizer.parse(v) { - var x = new Pman.SearchTokenizer(); +}; + +Pman.SearchTokenizer.parse = function(v) { + var x = new Pman.SearchTokenizer(v); return x.parse(); - } \ No newline at end of file