Created
January 11, 2009 07:49
-
-
Save satyr/45666 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var noun_arb_text = { | |
_name: "text", | |
rankLast: true, | |
_magicWords: { | |
url: { | |
re: /\burl\b/ig, | |
fn: function() Application.activeWindow.activeTab.document.URL, | |
}, | |
}, | |
suggest: function( text, html, callback, selectionIndices ) { | |
var suggestion = CmdUtils.makeSugg(text, html); | |
/* If the input comes all or in part from a text selection, | |
* we'll stick some html tags into the summary so that the part | |
* that comes from the text selection can be visually marked in | |
* the suggestion list. | |
*/ | |
if (selectionIndices) { | |
var pre = suggestion.summary.slice(0, selectionIndices[0]); | |
var middle = suggestion.summary.slice(selectionIndices[0], | |
selectionIndices[1]); | |
var post = suggestion.summary.slice(selectionIndices[1]); | |
suggestion.summary = pre + "<span class='selection'>" + | |
middle + "</span>" + post; | |
} | |
var suggs = [suggestion]; | |
for each(var p in this._magicWords) if(p.re.test(text)) | |
suggs.push(CmdUtils.makeSugg(text.replace(p.re, p.fn))); | |
return suggs; | |
} | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- feed-parts/header/en/nountypes.js.orig 2008-12-30 16:08:16.000000000 +0900 | |
+++ feed-parts/header/en/nountypes.js 2009-01-11 16:40:37.758800000 +0900 | |
@@ -116,6 +116,12 @@ | |
var noun_arb_text = { | |
_name: "text", | |
rankLast: true, | |
+ _magicWords: { | |
+ url: { | |
+ re: /\burl\b/ig, | |
+ fn: function() Application.activeWindow.activeTab.document.URL, | |
+ }, | |
+ }, | |
suggest: function( text, html, callback, selectionIndices ) { | |
var suggestion = CmdUtils.makeSugg(text, html); | |
/* If the input comes all or in part from a text selection, | |
@@ -131,7 +137,10 @@ | |
suggestion.summary = pre + "<span class='selection'>" + | |
middle + "</span>" + post; | |
} | |
- return [suggestion]; | |
+ var suggs = [suggestion]; | |
+ for each(var p in this._magicWords) if(p.re.test(text)) | |
+ suggs.push(CmdUtils.makeSugg(text.replace(p.re, p.fn))); | |
+ return suggs; | |
} | |
}; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment