mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-06 17:16:12 +00:00
191 lines
6.8 KiB
XML
191 lines
6.8 KiB
XML
<?xml-stylesheet href="chrome://messenger/skin/messenger.css" type="text/css"?>
|
|
|
|
<?xul-overlay href="chrome://global/content/globalOverlay.xul"?>
|
|
<?xul-overlay href="chrome://communicator/content/utilityOverlay.xul"?>
|
|
|
|
|
|
<window id="actest"
|
|
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
|
xmlns:html="http://www.w3.org/1999/xhtml"
|
|
xmlns:nc="http://home.netscape.com/NC-rdf#"
|
|
align="vertical"
|
|
width="750"
|
|
height="500"
|
|
onload="Initialize();"
|
|
>
|
|
|
|
<script type="application/x-javascript">
|
|
|
|
var AutoCompleteSession = {
|
|
onStartLookup: function(value, prevResult, listener)
|
|
{
|
|
dump("Search Session: onStartLookup\n");
|
|
|
|
var results = Components.classes["@mozilla.org/autocomplete/results;1"].createInstance();
|
|
results = results.QueryInterface(Components.interfaces.nsIAutoCompleteResults);
|
|
results.searchString = value;
|
|
results.defaultItemIndex = 0;
|
|
results.param = null;
|
|
|
|
var item = Components.classes["@mozilla.org/autocomplete/item;1"].createInstance();
|
|
item = item.QueryInterface(Components.interfaces.nsIAutoCompleteItem);
|
|
item.value = "Jean-Francois Ducarroz";
|
|
item.comment = "[put your comment here]";
|
|
item.className = "";
|
|
item.param = null;
|
|
|
|
results.items.AppendElement(item);
|
|
listener.onAutoComplete(results, Components.interfaces.nsIAutoCompleteStatus.matchFound);
|
|
},
|
|
|
|
onStopLookup: function()
|
|
{
|
|
dump("Search Session: onStopLookup\n");
|
|
},
|
|
|
|
onAutoComplete: function(value, prevResult, listener)
|
|
{
|
|
dump("Search Session: onAutoComplete, value =" + value + "\n");
|
|
|
|
var results = Components.classes["@mozilla.org/autocomplete/results;1"].createInstance();
|
|
results = results.QueryInterface(Components.interfaces.nsIAutoCompleteResults);
|
|
results.searchString = value;
|
|
results.defaultItemIndex = 0;
|
|
results.param = null;
|
|
|
|
var item = Components.classes["@mozilla.org/autocomplete/item;1"].createInstance();
|
|
item = item.QueryInterface(Components.interfaces.nsIAutoCompleteItem);
|
|
item.value = value + "@mozilla.org";
|
|
item.comment = "[put your comment here]";
|
|
item.className = "";
|
|
item.param = null;
|
|
|
|
results.items.AppendElement(item);
|
|
|
|
item = Components.classes["@mozilla.org/autocomplete/item;1"].createInstance();
|
|
item = item.QueryInterface(Components.interfaces.nsIAutoCompleteItem);
|
|
item.value = value + "@netscape.com";
|
|
item.comment = "[put your comment here]";
|
|
item.className = "";
|
|
item.param = null;
|
|
|
|
results.items.AppendElement(item);
|
|
|
|
listener.onAutoComplete(results, Components.interfaces.nsIAutoCompleteStatus.matchFound);
|
|
}
|
|
};
|
|
|
|
function function1()
|
|
{
|
|
var myAutoComplete = document.getElementById("test");
|
|
value = myAutoComplete.value;
|
|
match = "Jean-Francois Ducarroz";
|
|
|
|
lmatch = match.toLowerCase();
|
|
lvalue = value.toLowerCase();
|
|
|
|
dump("value = " + lvalue + ", match = " + lmatch + "\n");
|
|
|
|
if (lvalue == lmatch)
|
|
dump("exact match\n");
|
|
else
|
|
{
|
|
dump("substring = " + lmatch.substring(0, lvalue.length) + "\n");
|
|
if (lmatch.substring(0, lvalue.length) == lvalue)
|
|
{
|
|
dump("Ok, we can merge\n");
|
|
myAutoComplete.value = value + match.substring(value.length, match.length);
|
|
// myAutoComplete.anonymousContent[0].firstChild.anonymousContent[0].firstChild.setSelectionRange(value.length, match.length);
|
|
}
|
|
else
|
|
{
|
|
dump("oops, no match!\n");
|
|
myAutoComplete.value = value + " " + match;
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
function Initialize()
|
|
{
|
|
dump("Initialize!!\n");
|
|
|
|
var myAutoComplete = document.getElementById("test");
|
|
dump("myAutoComplete = " + myAutoComplete + ", session = " + myAutoComplete.mSessions + "\n");
|
|
myAutoComplete.autoCompleteSession = AutoCompleteSession;
|
|
|
|
var secondAutoComplete = document.getElementById("test2");
|
|
abSession = secondAutoComplete.mSessions['addrbook'].QueryInterface(Components.interfaces.nsIAbAutoCompleteSession);
|
|
abSession.defaultDomain = "mozilla.org";
|
|
|
|
var thirdAutoComplete = document.getElementById("test3");
|
|
var abSession3 = thirdAutoComplete.mSessions['ldap'].QueryInterface(Components.interfaces.nsILDAPAutoCompleteSession);
|
|
dump("\nthirdAutoComplete = " + thirdAutoComplete + "\n");
|
|
dump("thirdAutoComplete.mSessions['ldap'] = " +
|
|
thirdAutoComplete.mSessions['ldap'] + "\n");
|
|
dump("abSession3 = " + abSession3 + "\n");
|
|
|
|
var serverURL = Components.classes["@mozilla.org/network/ldap-url;1"].
|
|
createInstance().QueryInterface( Components.interfaces.nsILDAPURL);
|
|
|
|
//serverURL.spec = "ldap://ldap.bigfoot.com:389/??one?";
|
|
serverURL.spec = "ldap://nsdirectory.netscape.com/ou=People," +
|
|
"dc=netscape,dc=com??one";
|
|
|
|
abSession3.serverURL = serverURL;
|
|
abSession3.filterTemplate = "sn=";
|
|
abSession3.outputFormat = "cn <mail>";
|
|
abSession3.sizeLimit = 10;
|
|
|
|
var fourthAutoComplete = document.getElementById("test3");
|
|
var abSession4 = fourthAutoComplete.mSessions['ldap'].QueryInterface(Components.interfaces.nsILDAPAutoCompleteSession);
|
|
dump("\nfourthAutoComplete = " + fourthAutoComplete + "\n");
|
|
dump("fourthAutoComplete.mSessions['ldap'] = " +
|
|
fourthAutoComplete.mSessions['ldap'] + "\n");
|
|
dump("abSession4 = " + abSession4 + "\n");
|
|
|
|
var serverURL4 = Components.classes["@mozilla.org/network/ldap-url;1"].
|
|
createInstance().QueryInterface( Components.interfaces.nsILDAPURL);
|
|
|
|
//serverURL4.spec = "ldap://ldap.bigfoot.com:389/??one?";
|
|
serverURL4.spec = "ldap://nsdirectory.netscape.com/ou=People," +
|
|
"dc=netscape,dc=com??one";
|
|
|
|
abSession3.serverURL = serverURL4;
|
|
abSession3.filterTemplate = "sn=";
|
|
abSession3.outputFormat = "cn <mail>";
|
|
abSession3.sizeLimit = 10;
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
<html>Inline JS:</html>
|
|
<textbox id="test" timeout="300" type="autocomplete" />
|
|
|
|
<html>addrbook:</html>
|
|
<textbox id="test2"
|
|
type="autocomplete"
|
|
searchSessions="addrbook"
|
|
timeout="300"
|
|
onkeypress="if (event.keyCode == 13) dump('Done, value=' + this.value + '\n');"
|
|
/>
|
|
|
|
<html>ldap:</html>
|
|
<textbox id="test3"
|
|
type="autocomplete"
|
|
searchSessions="ldap"
|
|
timeout="300"
|
|
onkeypress="if (event.keyCode == 13) dump('Done, value=' + this.value + '\n');"
|
|
/>
|
|
|
|
<html>composite (addrbook, ldap):</html>
|
|
<textbox id="test3"
|
|
type="autocomplete"
|
|
searchSessions="addrbook ldap"
|
|
timeout="300"
|
|
onkeypress="if (event.keyCode == 13) dump('Done, value=' + this.value + '\n');"
|
|
/>
|
|
|
|
</window>
|