//mozilla/selsearch/trunk/bin/deploy.sh |
---|
0,0 → 1,15 |
#!/bin/sh |
T="$1" |
D="$(dirname $0)/.." |
if [ -z "$T" ] ; then |
echo "Need one parameter - the target dir" >> /dev/stderr |
return 1 |
fi |
rm -f "$T/selsearch.xpi" |
(cd "$D/src"; find . -not -path '*/.svn*' | zip -@ "$T/selsearch.xpi") |
cp "$D/update.rdf" "$T" |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
//mozilla/selsearch/trunk/src/install.rdf |
---|
0,0 → 1,26 |
<?xml version="1.0"?> |
<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#" |
xmlns:em="http://www.mozilla.org/2004/em-rdf#"> |
<Description about="urn:mozilla:install-manifest"> |
<em:id>{58C3BCF4-A9A4-11DD-A2A9-4FD0196F0FEF}</em:id> |
<em:version>1.2.1</em:version> |
<em:type>2</em:type> |
<em:targetApplication> |
<Description> |
<em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id> |
<em:minVersion>3</em:minVersion> |
<em:maxVersion>3.0.*</em:maxVersion> |
</Description> |
</em:targetApplication> |
<em:name>SelSearch</em:name> |
<em:description>Select a search engine to query from the context menu, add the search menu for text boxes</em:description> |
<em:creator>Anatoli Klassen</em:creator> |
<em:homepageURL>http://www.26th.net/public/projects/selsearch</em:homepageURL> |
<em:updateURL>http://www.26th.net/public/projects/selsearch/update.rdf</em:updateURL> |
<em:updateKey>MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQD0n3FJvEygIzLWtleG7RQGsW33KlWt2CEKm4cNdyYtos2PXb68ZwMIGDduDeAdv0kg90Y2vnHpEgJwE4O6Ce6bfjxQWNbCWj6UgjRaosuzqKq4+BBwT65hMcIs72K1x3zQde6oNBsnYiEP18Cy7aY26+QA7M/vcOY5Rut66xYcjQIDAQAB</em:updateKey> |
</Description> |
</RDF> |
Property changes: |
Added: svn:mergeinfo |
//mozilla/selsearch/trunk/src/chrome/content/selsearch.js |
---|
0,0 → 1,162 |
var SelSearch = { |
init: function() |
{ |
var menu = document.getElementById('contentAreaContextMenu'); |
menu.addEventListener('popupshowing', SelSearch.onPopupShowing, false); |
}, |
onPopupShowing: function() |
{ |
try { |
var sel = getBrowserSelection(16); |
if(!sel) { // nothing selected in html - try to find selected text in input box |
sel = SelSearch.getTextBoxSelection(16); |
} |
var submenu = document.getElementById('context-selsearch-submenu'); |
var popup = document.getElementById('context-selsearch-menupopup'); |
if(submenu && popup) { |
while(popup.hasChildNodes()){ |
popup.removeChild(popup.firstChild); |
} |
if(sel) { |
if(sel.length > 15) { |
sel = sel.substr(0,15) + "\u2026"; |
} |
submenu.hidden = false; |
submenu.label = 'Search "' + sel + '" in'; |
var ss = SelSearch.getSearchService(); |
var engines = ss.getVisibleEngines({ }); |
if(engines && engines.length > 0) { |
var curEngine; |
if(isElementVisible(BrowserSearch.searchBar)) { |
curEngine = ss.currentEngine.name; |
} |
else { |
curEngine = ss.defaultEngine.name; |
} |
// show the default engine |
for(var i = 0, l = engines.length; i < l; ++i) { |
if(engines[i].name == curEngine) { |
SelSearch.addMenuItem(popup, i, engines[i].name, engines[i].iconURI, true); |
popup.appendChild(document.createElementNS( |
'http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul', 'menuseparator')); |
break; |
} |
} |
// show all |
for(var i = 0, l = engines.length; i < l; ++i) { |
SelSearch.addMenuItem(popup, i, engines[i].name, engines[i].iconURI, engines[i].name == curEngine); |
} |
} |
} |
else { |
submenu.hidden = true; |
submenu.label = 'Search in'; |
} |
} |
// we cannot just remove the 'context-searchselect' in the overlay because it could be |
// some other items which use it as address point, so hide it here |
var originItem = document.getElementById('context-searchselect'); |
if(originItem) { |
originItem.hidden = true; |
} |
} |
catch(ex) { |
alert(ex); |
} |
}, |
getTextBoxSelection: function(aCharLen) |
{ |
if(!gContextMenu) return null; |
if(!gContextMenu.target) return null; |
if(!gContextMenu.target.value) return null; |
var start = gContextMenu.target.selectionStart; |
var end = gContextMenu.target.selectionEnd; |
if(start < 0 || end < 0) { |
return null; |
} |
var selection = gContextMenu.target.value.toString().substring(start, end); |
// |
// the code from browser.js/getBrowserSelection |
// |
// selections of more than 150 characters aren't useful |
const kMaxSelectionLen = 150; |
const charLen = Math.min(aCharLen || kMaxSelectionLen, kMaxSelectionLen); |
if (selection) { |
if (selection.length > charLen) { |
// only use the first charLen important chars. see bug 221361 |
var pattern = new RegExp("^(?:\\s*.){0," + charLen + "}"); |
pattern.test(selection); |
selection = RegExp.lastMatch; |
} |
selection = selection.replace(/^\s+/, "") |
.replace(/\s+$/, "") |
.replace(/\s+/g, " "); |
if (selection.length > charLen) |
selection = selection.substr(0, charLen); |
} |
return selection; |
}, |
getSearchService: function() |
{ |
const nsIBSS = Components.interfaces.nsIBrowserSearchService; |
return Components.classes["@mozilla.org/browser/search-service;1"].getService(nsIBSS); |
}, |
addMenuItem: function(popup, num, label, iconURI, bold) |
{ |
var e = document.createElementNS('http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul', 'menuitem'); |
e.setAttribute('label', label); |
e.setAttribute('oncommand', 'SelSearch.search(' + num + ')'); |
e.setAttribute('class', 'menuitem-iconic'); |
if(iconURI) { |
e.style.listStyleImage = "url('" + iconURI.spec + "')"; |
} |
if(bold) { |
e.style.fontWeight = 'bold'; |
} |
popup.appendChild(e); |
}, |
search: function(num) { |
var ss = SelSearch.getSearchService(); |
var engines = ss.getVisibleEngines({ }); |
if(num < 0 || num >= engines.length) return; |
var sel = getBrowserSelection(); |
if(!sel) { // nothing selected in html - try to find selected text in input box |
sel = SelSearch.getTextBoxSelection(16); |
} |
if(!sel) return; |
var submission = engines[num].getSubmission(sel, null); // HTML response |
if(!submission) return; |
getBrowser().loadOneTab(submission.uri.spec, null, null, submission.postData, null, false); |
}, |
}; |
window.addEventListener('load', SelSearch.init, false); |
//mozilla/selsearch/trunk/src/chrome/content/selsearch.xul |
---|
0,0 → 1,14 |
<?xml version="1.0"?> |
<overlay id="selsearch" |
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> |
<script type="application/x-javascript" src="chrome://selsearch/content/selsearch.js" /> |
<popup id="contentAreaContextMenu"> |
<menu id="context-selsearch-submenu" class="menuitem-iconic" insertafter="context-searchselect"> |
<menupopup id="context-selsearch-menupopup" /> |
</menu> |
</popup> |
</overlay> |
//mozilla/selsearch/trunk/src/chrome |
---|
Property changes: |
Added: svn:mergeinfo |
//mozilla/selsearch/trunk/src/chrome.manifest |
---|
0,0 → 1,2 |
content selsearch chrome/content/ |
overlay chrome://browser/content/browser.xul chrome://selsearch/content/selsearch.xul |
Property changes: |
Added: svn:mergeinfo |
//mozilla/selsearch/trunk/test/index.html |
---|
0,0 → 1,8 |
<h1>SelSearch</h1> |
Select a search engine to query from the context menu |
<form> |
<input type=text value="some text field"><br> |
<textarea>some text area</textarea> |
</form> |
//mozilla/selsearch/trunk/update.rdf |
---|
0,0 → 1,24 |
<?xml version="1.0"?> |
<RDF:RDF xmlns:em="http://www.mozilla.org/2004/em-rdf#" |
xmlns:NC="http://home.netscape.com/NC-rdf#" |
xmlns:RDF="http://www.w3.org/1999/02/22-rdf-syntax-ns#"> |
<RDF:Description RDF:about="rdf:#$nTfq11" |
em:version="1.2"> |
<em:targetApplication RDF:resource="rdf:#$qTfq11"/> |
</RDF:Description> |
<RDF:Seq RDF:about="rdf:#$mTfq11"> |
<RDF:li RDF:resource="rdf:#$nTfq11"/> |
</RDF:Seq> |
<RDF:Description RDF:about="rdf:#$qTfq11" |
em:id="{ec8030f7-c20a-464f-9b0e-13a3a9e97384}" |
em:minVersion="3" |
em:maxVersion="3.0.*" |
em:updateLink="http://www.26th.net/public/projects/selsearch/selsearch.xpi" /> |
<RDF:Description RDF:about="urn:mozilla:extension:{58C3BCF4-A9A4-11DD-A2A9-4FD0196F0FEF}" |
em:version="1.2" |
em:updateLink="http://www.26th.net/public/projects/selsearch/selsearch.xpi" |
em:updateHash="sha256:3c10d70bd4dad131feb97958bd740765c6dc59af15789c331f098fde329d751b" |
em:signature="MIGTMA0GCSqGSIb3DQEBDQUAA4GBALmmXuf+VpiYfe8jkC8RnOmNDaQ49Lv8BFJOg3V99PPThO6jqAPKhI8or2qyQD0Nva/gb6OgaROGuo5FJsP6kXekhi91HltVUq9r1aSFvQ4iPf3IkyGZnqIQmECYdVmQgMwsRsOES5R+1SuH55wyGdaxtHpy9mg2ce+MMoqeQFKd"> |
<em:updates RDF:resource="rdf:#$mTfq11"/> |
</RDF:Description> |
</RDF:RDF> |
//mozilla/selsearch/tags/1.0/chrome/content/selsearch.xul |
---|
0,0 → 1,17 |
<?xml version="1.0"?> |
<overlay id="selsearch" |
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> |
<script type="application/x-javascript" src="chrome://selsearch/content/selsearch.js"> |
</script> |
<popup id="contentAreaContextMenu"> |
<menu id="context-selsearch-submenu" class="menuitem-iconic" insertafter="context-searchselect"> |
<menupopup id="context-selsearch-menupopup"> |
</menupopup> |
</menu> |
</popup> |
<menuitem id="context-searchselect" removeelement="true" /> |
</overlay> |
//mozilla/selsearch/tags/1.0/chrome/content/selsearch.js |
---|
0,0 → 1,107 |
var SelSearch = { |
init: function() |
{ |
var menu = document.getElementById('contentAreaContextMenu'); |
menu.addEventListener('popupshowing', SelSearch.onPopupShowing, false); |
}, |
onPopupShowing: function() |
{ |
try { |
var sel = getBrowserSelection(16); |
var submenu = document.getElementById('context-selsearch-submenu'); |
var popup = document.getElementById('context-selsearch-menupopup'); |
if(submenu && popup) { |
while(popup.hasChildNodes()){ |
popup.removeChild(popup.firstChild); |
} |
if(sel) { |
if(sel.length > 15) { |
sel = sel.substr(0,15) + "\u2026"; |
} |
submenu.hidden = false; |
submenu.label = 'Search "' + sel + '" in'; |
var ss = SelSearch.getSearchService(); |
var engines = ss.getVisibleEngines({ }); |
if(engines && engines.length > 0) { |
var curEngine; |
if(isElementVisible(BrowserSearch.searchBar)) { |
curEngine = ss.currentEngine.name; |
} |
else { |
curEngine = ss.defaultEngine.name; |
} |
// show the default engine |
for(var i = 0, l = engines.length; i < l; ++i) { |
if(engines[i].name == curEngine) { |
SelSearch.addMenuItem(popup, i, engines[i].name, engines[i].iconURI, true); |
popup.appendChild(document.createElementNS( |
'http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul', 'menuseparator')); |
break; |
} |
} |
// show all |
for(var i = 0, l = engines.length; i < l; ++i) { |
SelSearch.addMenuItem(popup, i, engines[i].name, engines[i].iconURI, engines[i].name == curEngine); |
} |
} |
} |
else { |
submenu.hidden = true; |
submenu.label = 'Search in'; |
} |
} |
} |
catch(ex) { |
alert(ex); |
} |
}, |
getSearchService: function() |
{ |
const nsIBSS = Components.interfaces.nsIBrowserSearchService; |
return Components.classes["@mozilla.org/browser/search-service;1"].getService(nsIBSS); |
}, |
addMenuItem: function(popup, num, label, iconURI, bold) |
{ |
var e = document.createElementNS('http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul', 'menuitem'); |
e.setAttribute('label', label); |
e.setAttribute('oncommand', 'SelSearch.search(' + num + ')'); |
e.setAttribute('class', 'menuitem-iconic'); |
if(iconURI) { |
e.style.listStyleImage = "url('" + iconURI.spec + "')"; |
} |
if(bold) { |
e.style.fontWeight = 'bold'; |
} |
popup.appendChild(e); |
}, |
search: function(num) { |
var sel = getBrowserSelection(); |
var ss = SelSearch.getSearchService(); |
var engines = ss.getVisibleEngines({ }); |
if(num < 0 || num >= engines.length) return; |
if(!sel) return; |
var submission = engines[num].getSubmission(sel, null); // HTML response |
if(!submission) return; |
getBrowser().loadOneTab(submission.uri.spec, null, null, submission.postData, null, false); |
}, |
}; |
window.addEventListener('load', SelSearch.init, false); |
//mozilla/selsearch/tags/1.0/install.rdf |
---|
0,0 → 1,24 |
<?xml version="1.0"?> |
<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#" |
xmlns:em="http://www.mozilla.org/2004/em-rdf#"> |
<Description about="urn:mozilla:install-manifest"> |
<em:id>{58C3BCF4-A9A4-11DD-A2A9-4FD0196F0FEF}</em:id> |
<em:version>1.0</em:version> |
<em:type>2</em:type> |
<em:targetApplication> |
<Description> |
<em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id> |
<em:minVersion>3</em:minVersion> |
<em:maxVersion>3.0.*</em:maxVersion> |
</Description> |
</em:targetApplication> |
<em:name>SelSearch</em:name> |
<em:description>Select a search engine to query from the context menu</em:description> |
<em:creator>Anatoli Klassen</em:creator> |
<em:homepageURL>http://www.26th.net/public/projects/selsearch</em:homepageURL> |
</Description> |
</RDF> |
//mozilla/selsearch/tags/1.0/chrome.manifest |
---|
0,0 → 1,2 |
content selsearch chrome/content/ |
overlay chrome://browser/content/browser.xul chrome://selsearch/content/selsearch.xul |