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

Contents of /trunk/combo.html

Parent Directory Parent Directory | Revision Log Revision Log


Revision 25 - (show annotations)
Wed Sep 15 15:30:04 2004 UTC (19 years, 7 months ago) by dpavlin
File MIME type: text/html
File size: 2523 byte(s)
major refacture: 0 element is searched, all others can be used in result
function to generate html specific to one result. All that will be displayed
by calling display function which can add additional markup before or after
results.

1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
2 <HTML>
3 <HEAD>
4 <TITLE>Combobox example</TITLE>
5
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 <script type="text/javascript" src="combo-test.js"></script>
42 <script type="text/javascript">
43
44 var combo_active = 1;
45
46 function combo_onKeyDown(event) {
47 //debug("event: "+event.keyCode);
48 if (event.keyCode == 13) {
49 var el = document.myfilter.element_id('textfilter');
50 if (el) el.focus();
51
52 el = document.myfilter.element_id('results');
53 if (el) el.innerHTML = '';
54
55 combo_active = 0;
56 }
57
58 }
59
60
61 function myfilter() {
62
63 document.getElementById('textfilter').focus();
64 document.getElementById('textfilter').caretPos=1;
65 // document.getElementById('textfilter').select();
66 document.myfilter = new BFilter(headlines);
67
68 document.myfilter.result = function (arr) {
69 return '<option value="'+arr[1]+'">'+
70 arr[0] +
71 '</option>';
72 }
73
74 // this function is called when updating innerHTML with results
75 document.myfilter.display = function (html) {
76 return '<select id="sel" size="5" onKeyDown="combo_onKeyDown(event);" onChange="document.getElementById(\'textfilter\').value = this.options[this.selectedIndex].text;">'+html+'</select>';
77 }
78 }
79
80 function combo_filter(document,value) {
81
82 if (! combo_active) {
83 return null;
84 }
85
86 return document.myfilter.filter(document, value, headlines);
87 }
88
89 function keypress(e) {
90 var d = e.keyCode;
91 if ((d == 37) || (d == 38) || (d == 39) || (d == 40)) {
92 if (document.getElementById('sel')) document.getElementById('sel').focus();
93 }
94
95 if (d != 13) combo_active = 1;
96 }
97
98 </script>
99
100
101
102
103 </HEAD>
104
105 <BODY onload="myfilter();">
106
107 <div id="filterholder">
108 <div id="textfilterholder">
109 <input autocomplete="off" id="textfilter" name="textfilter" type="text"
110 onKeyDown="keypress(event);"
111 onKeyUp="combo_filter(document, this.value);"
112 value=""></div>
113
114 <div id="results">
115 </div>
116
117 </div>
118
119 <div id="status">
120 </div>
121
122 <div style="color: #a0a0a0">
123 If this combobox isn't working for you, try running <tt>make combo</tt> to create
124 example data from first 10000 words in <tt>/usr/share/dict/words</tt>.
125 </div>
126
127 </BODY>
128 </HTML>

  ViewVC Help
Powered by ViewVC 1.1.26