Skip to content

Instantly share code, notes, and snippets.

@satyr
Created January 11, 2009 07:49
Show Gist options
  • Save satyr/45666 to your computer and use it in GitHub Desktop.
Save satyr/45666 to your computer and use it in GitHub Desktop.
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;
}
};
--- 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