I am trying to add a folderpane to the main view (something like http://extensions.sanjer.nl/xpi/tb/contactssidebar-1.7pre.xpi). This seems to give a nice tool to start with but I want to add an event listener so that every time I click an email it will allow me to do some "extra work" to retrieve some data from a server (i.e. a crm system based on the email). I want to be able to use something like the contactssidebar as a template to learn from or similar but my challenge is that I can try to get this working by adding the following to the file contactsSideBar.js file at the top, to learn from and test it out
window.addEventListener("load", function load(event) {
window.removeEventListener("load", load, false);
myExtension.init();
}, false);
var myExtension = {
init: function() {
var appcontent = document.getElementById("appcontent"); // browser app content
if (appcontent) {
appcontent.addEventListener("OMContentLoaded", myExtension.onPageLoad, true);
}
var messagepane = document.getElementById("messagepane"); // tunderbird message pane
if(messagepane) {
messagepane.addEventListener("load", function(event) { myExtension.onPageLoad(event); }, true);
}
},
onPageLoad: function(aEvent) {
var win = Components.classes["@mozilla.org/appshell/window-mediator;1"].getService(Components.interfaces.nsIWindowMediator).getMostRecentWindow("mail:3pane");
var currentMsg = win.gFolderDisplay.selectedMessages[0];
var currentEmail = currentMsg.mime2DecodedAuthor.replace(/^.*</, "").replace(/>$/, "");
document.getElementById("searchInputElem").value = currentEmail;
aEvent.originalTarget.defaultView.addEventListener("unload", function(event) { myExtension.onPageUnload(event); }, true);
},
onPageUnload: function(aEvent) {
// No action necessary yet
}
};
However I can not seem to be able to locate the element in the DOM for
document.getElementById("searchInputElem")
it is null
I think I have to access some other pane or window but not sure. This element is found in the chrome\content\contactssidebar\search.xml Jar file that I have used (contactssidebar). I didnt write it but just trying to be able to update an element
Does someone know how to do this?