a lot of cleanups
This commit is contained in:
parent
e25703a111
commit
3ca270d0e2
3 changed files with 11 additions and 49 deletions
|
|
@ -10,7 +10,7 @@
|
|||
<groupbox align="center" orient="horizontal">
|
||||
<vbox>
|
||||
<text value="Leo Search" style="font-weight: bold; font-size: x-large;"/>
|
||||
<text value="&version; 1.3.0"/>
|
||||
<text value="&version; 1.3.1"/>
|
||||
<separator class="thin"/>
|
||||
<text value="&createdBy;" style="font-weight: bold;"/>
|
||||
<text value="Johannes Findeisen"/>
|
||||
|
|
|
|||
|
|
@ -4,14 +4,15 @@ var leo_search = {
|
|||
this.strings = document.getElementById("leo_search-strings");
|
||||
},
|
||||
onSearchCommand: function(e, lang, sitelang) {
|
||||
// evil but done in one line... ;)
|
||||
var query = window._content.window.getSelection();
|
||||
if(query != null)
|
||||
{
|
||||
var myURL = "http://dict.leo.org/" + lang + "de?lang=" + sitelang + "&search=" + query;
|
||||
var url = "http://dict.leo.org/" + lang + "de?lang=" + sitelang + "&search=" + query;
|
||||
if(e.ctrlKey == true)
|
||||
this.newTab(myURL, true);
|
||||
this.newTab(url, true);
|
||||
else
|
||||
this.newTab(myURL, false);
|
||||
this.newTab(url, false);
|
||||
}
|
||||
},
|
||||
onFirefoxLoad: function(event) {
|
||||
|
|
@ -66,49 +67,10 @@ var leo_search = {
|
|||
}
|
||||
},
|
||||
newTab: function(url, foregroundTab) {
|
||||
//var prefManager = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefBranch);
|
||||
|
||||
//if (prefManager.getIntPref("extensions.leo_search.reuse_tab") == 0) {
|
||||
var browser = top.document.getElementById("content");
|
||||
var newtab = browser.addTab(decodeURIComponent(url), {relatedToCurrent: true});
|
||||
if (foregroundTab) {
|
||||
browser.selectedTab = newtab;
|
||||
}
|
||||
//} else {
|
||||
// this.openOrReuseTab("extensions.leo_search.resultTab", url, foregroundTab);
|
||||
//}
|
||||
},
|
||||
// Taken from https://developer.mozilla.org/en-US/docs/Code_snippets/Tabbed_browser
|
||||
openOrReuseTab: function(attrName, url, foregroundTab) {
|
||||
var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"]
|
||||
.getService(Components.interfaces.nsIWindowMediator);
|
||||
for (var found = false, index = 0, tabbrowser = wm.getEnumerator('navigator:browser').getNext().gBrowser;
|
||||
index < tabbrowser.tabContainer.childNodes.length && !found;
|
||||
index++) {
|
||||
|
||||
var currentTab = tabbrowser.tabContainer.childNodes[index];
|
||||
|
||||
if (currentTab.hasAttribute(attrName)) {
|
||||
found = true;
|
||||
gBrowser.getBrowserAtIndex(index).loadURI(url);
|
||||
|
||||
if (foregroundTab) {
|
||||
tabbrowser.selectedTab = currentTab;
|
||||
tabbrowser.ownerDocument.defaultView.focus();
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!found) {
|
||||
var browserEnumerator = wm.getEnumerator("navigator:browser");
|
||||
var tabbrowser = browserEnumerator.getNext().gBrowser;
|
||||
|
||||
var newTab = tabbrowser.addTab(url);
|
||||
newTab.setAttribute(attrName, "leoOrg");
|
||||
|
||||
if (foregroundTab) {
|
||||
tabbrowser.selectedTab = newTab;
|
||||
tabbrowser.ownerDocument.defaultView.focus();
|
||||
}
|
||||
var browser = top.document.getElementById("content");
|
||||
var newtab = browser.addTab(decodeURIComponent(url), {relatedToCurrent: true});
|
||||
if (foregroundTab) {
|
||||
browser.selectedTab = newtab;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -4,14 +4,14 @@
|
|||
<em:id>{c666c018-6409-4479-afa3-68e4129e7eff}</em:id>
|
||||
<em:type>2</em:type><!-- Extension -->
|
||||
<em:name>Leo Search</em:name>
|
||||
<em:version>1.3.0</em:version>
|
||||
<em:version>1.3.1</em:version>
|
||||
<em:creator>Johannes Findeisen</em:creator>
|
||||
<em:homepageURL>http://hanez.org/leo-search.html</em:homepageURL>
|
||||
<em:localized>
|
||||
<Description>
|
||||
<em:locale>en-US</em:locale>
|
||||
<em:name>LEO Search</em:name>
|
||||
<em:description>Searches for marked words in the database at Leo.org and opens the result in a new background tab or foreground tab when holding "Ctrl".</em:description>
|
||||
<em:description>Searches for marked words in the database at Leo.org and opens the result in a new background tab or foreground tab when holding "Ctrl" pressed.</em:description>
|
||||
</Description>
|
||||
</em:localized>
|
||||
<em:localized>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue