/[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 12 by dpavlin, Sat Sep 11 08:21:57 2004 UTC revision 22 by dpavlin, Tue Sep 14 22:42:55 2004 UTC
# Line 9  function BFilter(arr) { Line 9  function BFilter(arr) {
9          this.id_cache = Array();          this.id_cache = Array();
10          // total number of hits          // total number of hits
11          this.hits = 0;          this.hits = 0;
12          this.html_pre = '<a href="';          // before all results
13            this.html_full_pre = '<ul>';
14            // before result
15            this.html_pre = '<li><a href="';
16            // id from result
17          this.html_mid = '">';          this.html_mid = '">';
18          this.html_post = '</a><br/>';          // title from result (which was searched also)
19          this.html_full_pre = '';          this.html_post = '</a></li>';
20          this.html_full_post = '';          // after all results
21            this.html_full_post = '</ul>';
22            // highlight for every second row in results
23            //this.html_hl_start = '<span style="background: #e0e0e0;">';
24            //this.html_hl_end = '</span>';
25            this.html_hl_start = '';
26            this.html_hl_end = '';
27    
28          if (! arr) {          if (! arr) {
29                  this.debug("ERROR: can't search empty array");                  this.debug("ERROR: can't search empty array");
# Line 53  BFilter.prototype.element_id = function Line 63  BFilter.prototype.element_id = function
63                          }                          }
64                  }                  }
65          }          }
66            return null;
67  }  }
68    
69    
# Line 94  BFilter.prototype.debug = function (html Line 105  BFilter.prototype.debug = function (html
105          if (! html) { return 1; }          if (! html) { return 1; }
106    
107          var debug_div = this.element_id("debug",1);          var debug_div = this.element_id("debug",1);
108          if (! debug_div) { return; }          if (! debug_div) { return null; }
109    
110          debug_div.innerHTML += html + "<br>\n";          debug_div.innerHTML += html + "<br>\n";
111    
112            return null;
113  }  }
114    
115    
# Line 165  BFilter.prototype.filter = function (doc Line 178  BFilter.prototype.filter = function (doc
178          // start anim icon          // start anim icon
179          //results("<img  src=\"pie.gif\">&nbsp;Please wait, filtering...\n",1);          //results("<img  src=\"pie.gif\">&nbsp;Please wait, filtering...\n",1);
180    
181            var i;
182    
183          // full part? (optimization)          // full part? (optimization)
184          if (find.length == this.min_len) {          if (find.length == this.min_len) {
185                  var html = '';                  var html = '';
186                  for (var i = 0; i < this.arr[part].length; i++) {                  for (i = 0; i < this.arr[part].length; i++) {
187                          html += this.html_pre +                          html += this.html_pre +
188                                  this.arr[part][i][0] +                                  this.arr[part][i][0] +
189                                  this.html_mid +                                  this.html_mid +
190                                  (this.hits % 2 == 0 ? '<span style="background: #e0e0e0">' : '');                                  (this.hits % 2 == 0 ? this.html_hl_start : '');
191                          //if (this.debug()) { html += i+": "; }                          //if (this.debug()) { html += i+": "; }
192                          html += this.arr[part][i][1] +                          html += this.arr[part][i][1] +
193                                  (this.hits % 2 == 0 ? '</span>' : '') +                                  (this.hits % 2 == 0 ? this.html_hl_end : '') +
194                                  this.html_post + "\n";                                  this.html_post + "\n";
195                          this.hits++;                          this.hits++;
196                  }                  }
# Line 188  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    
206                          var html = '';                          html = '';
207    
208                          for(var i = from ; i < this.arr[part].length ; i++) {                          for(i = from ; i < this.arr[part].length ; i++) {
209                                  if (this.arr[part][i][1].substring(0,find.length).toLowerCase() != find_lc) {                                  if (this.arr[part][i][1].substring(0,find.length).toLowerCase() != find_lc) {
210                                          this.debug("loop exit at "+i);                                          this.debug("loop exit at "+i);
211                                          break;                                          break;
# Line 198  BFilter.prototype.filter = function (doc Line 213  BFilter.prototype.filter = function (doc
213                                  html += this.html_pre +                                  html += this.html_pre +
214                                          this.arr[part][i][0] +                                          this.arr[part][i][0] +
215                                          this.html_mid +                                          this.html_mid +
216                                          (this.hits % 2 == 0 ? '<span style="background: #e0e0e0">' : '');                                          (this.hits % 2 == 0 ? this.html_hl_start : '');
217                                  //if (this.debug()) { html += i+": "; }                                  //if (this.debug()) { html += i+": "; }
218                                  html += this.arr[part][i][1] +                                  html += this.arr[part][i][1] +
219                                          (this.hits % 2 == 0 ? '</span>' : '') +                                          (this.hits % 2 == 0 ? this.html_hl_end : '') +
220                                          this.html_post + "\n";                                          this.html_post + "\n";
221                                  this.hits++;                                  this.hits++;
222                          }                          }

Legend:
Removed from v.12  
changed lines
  Added in v.22

  ViewVC Help
Powered by ViewVC 1.1.26