/[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

Annotation of /trunk/combo.html

Parent Directory Parent Directory | Revision Log Revision Log


Revision 30 - (hide annotations)
Fri Sep 24 16:58:08 2004 UTC (19 years, 6 months ago) by dpavlin
File MIME type: text/html
File size: 2581 byte(s)
implemented timeout to start filtering (by default 200ms)

1 dpavlin 11 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
2     <HTML>
3     <HEAD>
4 dpavlin 24 <TITLE>Combobox example</TITLE>
5 dpavlin 11
6     <style type="text/css">
7     #textfilterholder {
8     border:1px black solid
9     padding:0px;
10     width:200px;
11     }
12     #filterholder {
13     position:relative;
14     }
15    
16     #textfilter {
17     width:175px;
18     font-size:12px;
19     border: 0px black solid
20     height:20px;
21     }
22     #sel {
23     width:200px;
24     font-size:12px;
25     }
26     #results {
27     z-index:100;
28     border: 0px black solid;
29     width:200px;;
30     position:absolute;
31     top:20px;
32     left:0px;
33     }
34     #status {
35     z-index:10;
36     }
37     </style>
38    
39    
40     <script type="text/javascript" src="bfilter.js"></script>
41 dpavlin 24 <script type="text/javascript" src="combo-test.js"></script>
42 dpavlin 11 <script type="text/javascript">
43    
44 dpavlin 23 var combo_active = 1;
45    
46     function combo_onKeyDown(event) {
47     //debug("event: "+event.keyCode);
48     if (event.keyCode == 13) {
49 dpavlin 30 var el = self.document.myfilter.element_id('textfilter');
50 dpavlin 23 if (el) el.focus();
51    
52 dpavlin 30 el = self.document.myfilter.element_id('results');
53 dpavlin 23 if (el) el.innerHTML = '';
54    
55     combo_active = 0;
56     }
57    
58     }
59    
60    
61 dpavlin 11 function myfilter() {
62 dpavlin 23
63 dpavlin 30 self.document.getElementById('textfilter').focus();
64     self.document.getElementById('textfilter').caretPos=1;
65     // self.document.getElementById('textfilter').select();
66     self.document.myfilter = new BFilter(headlines);
67 dpavlin 25
68 dpavlin 30 self.document.myfilter.result = function (arr) {
69 dpavlin 29 this.results_html += '<option value="'+arr[1]+'">'+
70 dpavlin 25 arr[0] +
71     '</option>';
72 dpavlin 29 return true;
73 dpavlin 25 }
74    
75     // this function is called when updating innerHTML with results
76 dpavlin 30 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 dpavlin 25 }
79 dpavlin 11 }
80    
81 dpavlin 30 function combo_filter(value) {
82 dpavlin 23
83     if (! combo_active) {
84 dpavlin 25 return null;
85 dpavlin 23 }
86    
87 dpavlin 30 return self.document.myfilter.filter(value);
88 dpavlin 23 }
89    
90 dpavlin 11 function keypress(e) {
91     var d = e.keyCode;
92     if ((d == 37) || (d == 38) || (d == 39) || (d == 40)) {
93 dpavlin 30 if (self.document.getElementById('sel')) self.document.getElementById('sel').focus();
94 dpavlin 11 }
95 dpavlin 23
96     if (d != 13) combo_active = 1;
97 dpavlin 11 }
98    
99     </script>
100    
101    
102    
103    
104     </HEAD>
105    
106     <BODY onload="myfilter();">
107    
108     <div id="filterholder">
109 dpavlin 23 <div id="textfilterholder">
110     <input autocomplete="off" id="textfilter" name="textfilter" type="text"
111     onKeyDown="keypress(event);"
112 dpavlin 30 onKeyUp="combo_filter(this.value);"
113 dpavlin 23 value=""></div>
114 dpavlin 11
115     <div id="results">
116     </div>
117    
118 dpavlin 24 </div>
119    
120 dpavlin 11 <div id="status">
121     </div>
122    
123 dpavlin 24 <div style="color: #a0a0a0">
124     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 dpavlin 11 </div>
127    
128     </BODY>
129     </HTML>

  ViewVC Help
Powered by ViewVC 1.1.26