/[bfilter]/trunk/combo.html
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/combo.html

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

revision 23 by dpavlin, Tue Sep 14 22:43:16 2004 UTC revision 30 by dpavlin, Fri Sep 24 16:58:08 2004 UTC
# Line 1  Line 1 
1  <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">  <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
2  <HTML>  <HTML>
3  <HEAD>  <HEAD>
4  <TITLE> New Document </TITLE>  <TITLE>Combobox example</TITLE>
5    
6  <style type="text/css">  <style type="text/css">
7  #textfilterholder {  #textfilterholder {
# Line 38  z-index:10; Line 38  z-index:10;
38    
39    
40  <script type="text/javascript" src="bfilter.js"></script>  <script type="text/javascript" src="bfilter.js"></script>
41    <script type="text/javascript" src="combo-test.js"></script>
42  <script type="text/javascript">  <script type="text/javascript">
43    
 var headlines = new Object();  
 headlines['ad'] = [  
   ['thes/232.html','adacta']  
 , ['thes/232.html','added']  
 , ['thes/232.html','addenda']  
 , ['thes/232.html','adlib']  
 ];  
   
 headlines.min_len = 2;  
 headlines.length = 4;  
   
44  var combo_active = 1;  var combo_active = 1;
45    
46  function combo_onKeyDown(event) {  function combo_onKeyDown(event) {
47          //debug("event: "+event.keyCode);          //debug("event: "+event.keyCode);
48          if (event.keyCode == 13) {          if (event.keyCode == 13) {
49                  var el = document.myfilter.element_id('textfilter');                  var el = self.document.myfilter.element_id('textfilter');
50                  if (el) el.focus();                  if (el) el.focus();
51                                    
52                  el = document.myfilter.element_id('results');                  el = self.document.myfilter.element_id('results');
53                  if (el) el.innerHTML = '';                  if (el) el.innerHTML = '';
54                    
55                  combo_active = 0;                  combo_active = 0;
# Line 70  function combo_onKeyDown(event) { Line 60  function combo_onKeyDown(event) {
60    
61  function myfilter() {  function myfilter() {
62    
63          document.getElementById('textfilter').focus();          self.document.getElementById('textfilter').focus();
64  document.getElementById('textfilter').caretPos=1;          self.document.getElementById('textfilter').caretPos=1;
65  //      document.getElementById('textfilter').select();  //      self.document.getElementById('textfilter').select();
66          document.myfilter = new BFilter(headlines);          self.document.myfilter = new BFilter(headlines);
67            
68          document.myfilter.html_pre = '<option value="';          self.document.myfilter.result = function (arr) {
69          document.myfilter.html_mid = '">';                  this.results_html += '<option value="'+arr[1]+'">'+
70          document.myfilter.html_post = '</option>';                          arr[0] +
71          document.myfilter.html_full_pre = '<select id="sel" size="5" onKeyDown="combo_onKeyDown(event);" onChange="document.getElementById(\'textfilter\').value = this.options[this.selectedIndex].text;">';                          '</option>';
72          document.myfilter.html_full_post = '</select>';                  return true;
73            }
74    
75            // this function is called when updating innerHTML with results
76            self.document.myfilter.display = function () {
77                    return '<select id="sel" size="5" onKeyDown="combo_onKeyDown(event);" onChange="self.document.getElementById(\'textfilter\').value = this.options[this.selectedIndex].text;">'+this.results_html+'</select>';
78            }
79  }  }
80    
81  function combo_filter(document,value) {  function combo_filter(value) {
82    
83          if (! combo_active) {          if (! combo_active) {
84                  return;                  return null;
85          }          }
86    
87          return document.myfilter.filter(document, value, headlines);          return self.document.myfilter.filter(value);
88  }  }
89    
90  function keypress(e) {  function keypress(e) {
91          var d = e.keyCode;          var d = e.keyCode;
92          if ((d == 37) || (d == 38) || (d == 39) || (d == 40)) {          if ((d == 37) || (d == 38) || (d == 39) || (d == 40)) {
93                  if (document.getElementById('sel'))     document.getElementById('sel').focus();                  if (self.document.getElementById('sel'))        self.document.getElementById('sel').focus();
94          }          }
95    
96          if (d != 13) combo_active = 1;          if (d != 13) combo_active = 1;
# Line 113  function keypress(e) { Line 109  function keypress(e) {
109  <div id="textfilterholder">  <div id="textfilterholder">
110  <input autocomplete="off" id="textfilter" name="textfilter" type="text"  <input autocomplete="off" id="textfilter" name="textfilter" type="text"
111   onKeyDown="keypress(event);"   onKeyDown="keypress(event);"
112   onKeyUp="combo_filter(document, this.value);"   onKeyUp="combo_filter(this.value);"
113  value=""></div>  value=""></div>
114    
115  <div id="results">  <div id="results">
116  </div>  </div>
117    
 <div id="status">  
118  </div>  </div>
119    
120    <div id="status">
121  </div>  </div>
122    
123    <div style="color: #a0a0a0">
124  Text  If this combobox isn't working for you, try running <tt>make combo</tt> to create
125    example data from first 10000 words in <tt>/usr/share/dict/words</tt>.
126    </div>
127    
128  </BODY>  </BODY>
129  </HTML>  </HTML>

Legend:
Removed from v.23  
changed lines
  Added in v.30

  ViewVC Help
Powered by ViewVC 1.1.26