/[bfilter]/trunk/bfilter.js
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /trunk/bfilter.js

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 25 by dpavlin, Wed Sep 15 15:30:04 2004 UTC revision 28 by dpavlin, Thu Sep 23 18:22:50 2004 UTC
# Line 10  function BFilter(arr) { Line 10  function BFilter(arr) {
10          // total number of hits          // total number of hits
11          this.hits = 0;          this.hits = 0;
12    
13            this.results_html = null;
14    
15          // this function is called for each result          // this function is called for each result
16          this.result = function (arr) {          this.result = function (arr) {
17                  return '<li><a href="'+arr[1]+'">'+                  this.results_html += '<li><a href="'+arr[1]+'">'+
18                          (this.hits % 2 == 0 ? '<span style="background: #e0e0e0;">' : '') +                          (this.hits % 2 == 0 ? '<span style="background: #e0e0e0;">' : '') +
19                          arr[0] +                          arr[0] +
20                          (this.hits % 2 == 0 ? '</span>' : '') +                          (this.hits % 2 == 0 ? '</span>' : '') +
21                          '</a></li>';                          '</a></li>';
22                    return true;
23          }          }
24    
25          // this function is called when updating innerHTML with results          // this function is called when updating innerHTML with results
26          this.display = function (html) {          this.display = function () {
27                  return '<ul>'+html+'</ul>';                  if (this.results_html) {
28                            return '<ul>'+this.results_html+'</ul>';
29                    } else {
30                            return null;
31                    }
32          }          }
33    
34    
# Line 92  BFilter.prototype.results = function (ht Line 99  BFilter.prototype.results = function (ht
99          if (clean) {          if (clean) {
100                  results_div.innerHTML = html;                  results_div.innerHTML = html;
101          } else {          } else {
102                  results_div.innerHTML += this.display(html);                  html = this.display();
103                    if (html) results_div.innerHTML += html;
104          }          }
105  }  }
106    
# Line 182  BFilter.prototype.filter = function (doc Line 190  BFilter.prototype.filter = function (doc
190    
191          // full part? (optimization)          // full part? (optimization)
192          if (find.length == this.min_len) {          if (find.length == this.min_len) {
                 var html = '';  
193                  for (i = 0; i < this.arr[part].length; i++) {                  for (i = 0; i < this.arr[part].length; i++) {
194                          html += this.result(this.arr[part][i]);                          this.result(this.arr[part][i]);
195                          this.hits++;                          this.hits++;
196                  }                  }
197                  this.results(html);                  this.results();
198          } else {          } else {
199    
200                  var from = this.binarySearch(this.arr[part], find_lc);                  var from = this.binarySearch(this.arr[part], find_lc);
# Line 196  BFilter.prototype.filter = function (doc Line 203  BFilter.prototype.filter = function (doc
203                                    
204                          this.debug("loop "+from+" ... "+this.arr[part].length);                          this.debug("loop "+from+" ... "+this.arr[part].length);
205    
                         html = '';  
   
206                          for(i = from ; i < this.arr[part].length ; i++) {                          for(i = from ; i < this.arr[part].length ; i++) {
207                                  if (this.arr[part][i][0].substring(0,find.length).toLowerCase() != find_lc) {                                  if (this.arr[part][i][0].substring(0,find.length).toLowerCase() != find_lc) {
208                                          this.debug("loop exit at "+i);                                          this.debug("loop exit at "+i);
209                                          break;                                          break;
210                                  }                                  }
211                                  html += this.result(this.arr[part][i]);                                  this.result(this.arr[part][i]);
212                                  this.hits++;                                  this.hits++;
213                          }                          }
214    
215                          this.results(html);                          this.results();
216                  }                  }
217    
218          }          }

Legend:
Removed from v.25  
changed lines
  Added in v.28

  ViewVC Help
Powered by ViewVC 1.1.26