/[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 2 by dpavlin, Tue Sep 7 08:37:14 2004 UTC revision 6 by dpavlin, Tue Sep 7 09:29:36 2004 UTC
# Line 3  Line 3 
3     Dobrica Pavlinusic, dpavlin@rot13.org 2004-09-06     Dobrica Pavlinusic, dpavlin@rot13.org 2004-09-06
4  */  */
5    
6  var debug = 1;  var debug = 0;
7    
8  function bfilter_init() {  function bfilter_init() {
9          show_status();          show_status();
# Line 61  function results(html,clean) { Line 61  function results(html,clean) {
61    
62  // modified binary search to find first element with substring  // modified binary search to find first element with substring
63  function binarySearch(arr, find) {  function binarySearch(arr, find) {
64          if (!arr ||          if (!arr || typeof (find) == "undefined" || !arr.length) {
                 typeof (arr) != "object" ||  
                 typeof (find) == "undefined" || !arr.length) {  
65                  return null;                  return null;
66          }          }
67          var low = 0;          var low = 0;
# Line 129  function bfilter(document, id, find, arr Line 127  function bfilter(document, id, find, arr
127          if (find.length == min_len) {          if (find.length == min_len) {
128                  var html = '';                  var html = '';
129                  for (var i = 0; i < arr[part].length; i++) {                  for (var i = 0; i < arr[part].length; i++) {
130                          html += "<li>"+i+": "+arr[part][i]+"</li>\n";                          html += "<li>";
131                            if (debug) { $html += i+": "; }
132                            html += arr[part][i]+"</li>\n";
133                          hits++;                          hits++;
134                  }                  }
135                  results(html);                  results(html);
# Line 140  function bfilter(document, id, find, arr Line 140  function bfilter(document, id, find, arr
140                  if (from != null) {                  if (from != null) {
141                                    
142                          if (debug) { results("loop "+from+" ... "+arr[part].length)+"<br>\n"; }                          if (debug) { results("loop "+from+" ... "+arr[part].length)+"<br>\n"; }
143    
144                            var html = '';
145    
146                          for(var i = from ; i < arr[part].length ; i++) {                          for(var i = from ; i < arr[part].length ; i++) {
147                                  if (arr[part][i].substring(0,find.length).toLowerCase() != find_lc) {                                  if (arr[part][i].substring(0,find.length).toLowerCase() != find_lc) {
148                                          break;                                          break;
149                                  }                                  }
150                                  results(i+": "+arr[part][i]+"<br>\n");                                  if (debug) { html += i+": "; }
151                                    html += arr[part][i]+"<br>\n";
152                                  hits++;                                  hits++;
153                          }                          }
154                  } else {  
155                          // clean results list                          results(html);
 //                      results("",1);  
156                  }                  }
157    
158          }          }

Legend:
Removed from v.2  
changed lines
  Added in v.6

  ViewVC Help
Powered by ViewVC 1.1.26