1 <?xml-stylesheet href="chrome://messenger/skin/messenger.css" type="text/css"?>
3 <?xul-overlay href="chrome://global/content/globalOverlay.xul"?>
4 <?xul-overlay href="chrome://communicator/content/utilityOverlay.xul"?>
8 xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
9 xmlns:nc="http://home.netscape.com/NC-rdf#"
13 onload="Initialize();"
16 <script type="application/x-javascript">
18 var AutoCompleteSession = {
19 onStartLookup: function(value, prevResult, listener)
21 dump("Search Session: onStartLookup\n");
23 var results = Components.classes["@mozilla.org/autocomplete/results;1"].createInstance();
24 results = results.QueryInterface(Components.interfaces.nsIAutoCompleteResults);
25 results.searchString = value;
26 results.defaultItemIndex = 0;
29 var item = Components.classes["@mozilla.org/autocomplete/item;1"].createInstance();
30 item = item.QueryInterface(Components.interfaces.nsIAutoCompleteItem);
31 item.value = "Jean-Francois Ducarroz";
32 item.comment = "[put your comment here]";
36 results.items.AppendElement(item);
37 listener.onAutoComplete(results, Components.interfaces.nsIAutoCompleteStatus.matchFound);
40 onStopLookup: function()
42 dump("Search Session: onStopLookup\n");
45 onAutoComplete: function(value, prevResult, listener)
47 dump("Search Session: onAutoComplete, value =" + value + "\n");
49 var results = Components.classes["@mozilla.org/autocomplete/results;1"].createInstance();
50 results = results.QueryInterface(Components.interfaces.nsIAutoCompleteResults);
51 results.searchString = value;
52 results.defaultItemIndex = 0;
55 var item = Components.classes["@mozilla.org/autocomplete/item;1"].createInstance();
56 item = item.QueryInterface(Components.interfaces.nsIAutoCompleteItem);
57 item.value = value + "@mozilla.org";
58 item.comment = "[put your comment here]";
62 results.items.AppendElement(item);
64 item = Components.classes["@mozilla.org/autocomplete/item;1"].createInstance();
65 item = item.QueryInterface(Components.interfaces.nsIAutoCompleteItem);
66 item.value = value + "@netscape.com";
67 item.comment = "[put your comment here]";
71 results.items.AppendElement(item);
73 listener.onAutoComplete(results, Components.interfaces.nsIAutoCompleteStatus.matchFound);
79 var myAutoComplete = document.getElementById("test");
80 value = myAutoComplete.value;
81 match = "Jean-Francois Ducarroz";
83 lmatch = match.toLowerCase();
84 lvalue = value.toLowerCase();
86 dump("value = " + lvalue + ", match = " + lmatch + "\n");
89 dump("exact match\n");
92 dump("substring = " + lmatch.substring(0, lvalue.length) + "\n");
93 if (lmatch.substring(0, lvalue.length) == lvalue)
95 dump("Ok, we can merge\n");
96 myAutoComplete.value = value + match.substring(value.length, match.length);
97 // myAutoComplete.anonymousContent[0].firstChild.anonymousContent[0].firstChild.setSelectionRange(value.length, match.length);
101 dump("oops, no match!\n");
102 myAutoComplete.value = value + " " + match;
108 function Initialize()
110 dump("Initialize!!\n");
112 var myAutoComplete = document.getElementById("test");
113 dump("myAutoComplete = " + myAutoComplete + ", session = " + myAutoComplete.mSessions + "\n");
114 myAutoComplete.autoCompleteSession = AutoCompleteSession;
116 var secondAutoComplete = document.getElementById("test2");
117 abSession = secondAutoComplete.mSessions['addrbook'].QueryInterface(Components.interfaces.nsIAbAutoCompleteSession);
118 abSession.defaultDomain = "mozilla.org";
120 var thirdAutoComplete = document.getElementById("test3");
121 var abSession3 = thirdAutoComplete.mSessions['ldap'].QueryInterface(Components.interfaces.nsILDAPAutoCompleteSession);
122 dump("\nthirdAutoComplete = " + thirdAutoComplete + "\n");
123 dump("thirdAutoComplete.mSessions['ldap'] = " +
124 thirdAutoComplete.mSessions['ldap'] + "\n");
125 dump("abSession3 = " + abSession3 + "\n");
127 var serverURL = Components.classes["@mozilla.org/network/ldap-url;1"].
128 createInstance().QueryInterface( Components.interfaces.nsILDAPURL);
130 //serverURL.spec = "ldap://ldap.bigfoot.com:389/??one?";
131 serverURL.spec = "ldap://nsdirectory.netscape.com/ou=People," +
132 "dc=netscape,dc=com??one";
134 abSession3.serverURL = serverURL;
135 abSession3.filterTemplate = "sn=";
136 abSession3.outputFormat = "cn <mail>";
137 abSession3.sizeLimit = 10;
139 var fourthAutoComplete = document.getElementById("test3");
140 var abSession4 = fourthAutoComplete.mSessions['ldap'].QueryInterface(Components.interfaces.nsILDAPAutoCompleteSession);
141 dump("\nfourthAutoComplete = " + fourthAutoComplete + "\n");
142 dump("fourthAutoComplete.mSessions['ldap'] = " +
143 fourthAutoComplete.mSessions['ldap'] + "\n");
144 dump("abSession4 = " + abSession4 + "\n");
146 var serverURL4 = Components.classes["@mozilla.org/network/ldap-url;1"].
147 createInstance().QueryInterface( Components.interfaces.nsILDAPURL);
149 //serverURL4.spec = "ldap://ldap.bigfoot.com:389/??one?";
150 serverURL4.spec = "ldap://nsdirectory.netscape.com/ou=People," +
151 "dc=netscape,dc=com??one";
153 abSession3.serverURL = serverURL4;
154 abSession3.filterTemplate = "sn=";
155 abSession3.outputFormat = "cn <mail>";
156 abSession3.sizeLimit = 10;
162 <html>Inline JS:</html>
163 <textbox id="test" timeout="300" type="autocomplete" />
165 <html>addrbook:</html>
168 searchSessions="addrbook"
170 onkeypress="if (event.keyCode == 13) dump('Done, value=' + this.value + '\n');"
176 searchSessions="ldap"
178 onkeypress="if (event.keyCode == 13) dump('Done, value=' + this.value + '\n');"
181 <html>composite (addrbook, ldap):</html>
184 searchSessions="addrbook ldap"
186 onkeypress="if (event.keyCode == 13) dump('Done, value=' + this.value + '\n');"