diff --git a/chrome/content/about.xul b/chrome/content/about.xul index a3fc9b0..3218fcc 100644 --- a/chrome/content/about.xul +++ b/chrome/content/about.xul @@ -10,7 +10,7 @@ - + diff --git a/chrome/content/overlay.js b/chrome/content/overlay.js index e0409cb..1c413cc 100644 --- a/chrome/content/overlay.js +++ b/chrome/content/overlay.js @@ -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; } } }; diff --git a/install.rdf b/install.rdf index aeb9cbb..5970bb2 100644 --- a/install.rdf +++ b/install.rdf @@ -4,14 +4,14 @@ {c666c018-6409-4479-afa3-68e4129e7eff} 2 Leo Search - 1.3.0 + 1.3.1 Johannes Findeisen http://hanez.org/leo-search.html en-US LEO Search - 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". + 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.