Subversion Repositories general

Compare Revisions

Ignore whitespace Rev 1296 → Rev 1297

/firefox/selsearch/trunk/chrome/content/selsearch.xul
3,15 → 3,13
<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>
<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">
</menupopup>
<menupopup id="context-selsearch-menupopup" />
</menu>
</popup>
<menuitem id="context-searchselect" removeelement="true" />
<!--menuitem id="context-searchselect" removeelement="true" /-->
</overlay>
/firefox/selsearch/trunk/chrome/content/selsearch.js
10,6 → 10,10
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) {
64,6 → 68,46
}
},
 
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;
/firefox/selsearch/trunk/install.rdf
5,7 → 5,7
 
<Description about="urn:mozilla:install-manifest">
<em:id>{58C3BCF4-A9A4-11DD-A2A9-4FD0196F0FEF}</em:id>
<em:version>1.0</em:version>
<em:version>1.1</em:version>
<em:type>2</em:type>
<em:targetApplication>
17,7 → 17,7
</em:targetApplication>
<em:name>SelSearch</em:name>
<em:description>Select a search engine to query from the context menu</em:description>
<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>
</Description>