From 14881504aca54741a3a217da3645cd20721552f6 Mon Sep 17 00:00:00 2001 From: anekos Date: Fri, 3 Dec 2010 17:23:26 +0900 Subject: 現在のURLをデフォルトでは含めないようにした --- lo.js | 51 ++++++++++++++++++++++++++++++++------------------- 1 file changed, 32 insertions(+), 19 deletions(-) (limited to 'lo.js') diff --git a/lo.js b/lo.js index 0a5a0f0..b89f7a3 100644 --- a/lo.js +++ b/lo.js @@ -39,7 +39,7 @@ let PLUGIN_INFO = Link Opener Link Opener リンクを開く - 2.2.0 + 2.3.0 anekos new BSD License (Please read the source code comments of this plugin) 修正BSDライセンス (ソースコードのコメントを参照してください) @@ -54,21 +54,21 @@ let PLUGIN_INFO = // INFO {{{ let INFO = <> - anekos New BSD License - +

:fo :fopen :filteropen - :fopen! -where=where -interval=interval filter + :fopen! -where=where -interval=interval -include-current filter

Open the links selected with filter. @@ -87,7 +87,7 @@ let INFO = :lopen :lo :linkopen - :lopen! -where=where link + :lopen! -where=where -include-current link

Open selected link. @@ -103,25 +103,26 @@ let INFO = - anekos New BSD License - +

:fo :fopen :filteropen - :fopen! -where=where -interval=interval filter + :fopen! -where=where -interval=interval -include-current filter

filter で選択されたリンクを開きます。 interval はリンクを開く間隔です。 + -include-currentが指定されると、現在のURLを指すリンクが含まれるようになります。

where オプションの値

@@ -136,10 +137,11 @@ let INFO = :lopen :lo :linkopen - :lopen! -where=where link + :lopen! -where=where -include-current link

選択されたリンク(link)を開きます。 + -include-currentが指定されると、現在のURLを指すリンクが含まれるようになります。

where オプションの値

@@ -183,16 +185,25 @@ let INFO = let migemo = window.XMigemoCore; + function constant (value) + function () value; + function isHttpLink (link) (link.href && link.href.indexOf('http') == 0); + function isCurrent (link) + (link.href === buffer.URL); + + function not (func) + function () !func.apply(this, arguments); + function lmatch (re, link) ((link.href.match(re) || link.textContent.toString().match(re))); - function getLinks () { + function getLinks (includeCurrent) { function _get (content) Array.prototype.concat.apply(Array.slice(content.document.links), Array.slice(content.frames).map(_get)); - return _get(content).filter(isHttpLink); + return _get(content).filter(isHttpLink).filter(includeCurrent ? constant(true) : not(isCurrent)); } function makeRegExp (str) { @@ -201,8 +212,8 @@ let INFO = : new RegExp(str, 'i'); } - function filteredLinks (word) { - let links = getLinks(); + function filteredLinks (word, includeCurrent) { + let links = getLinks(includeCurrent); if (word.match(/^\s*$/)) return links; let re = makeRegExp(word); @@ -230,7 +241,7 @@ let INFO = 'Filtered open', function (args) { let where = charToWhere(args['-where'], args.bang ? liberator.NEW_TAB : liberator.NEW_BACKGROUND_TAB); - let [i, links] = [1, filteredLinks(args.join(''))]; + let [i, links] = [1, filteredLinks(args.join(''), args['-include-current'])]; if (!links.length) return; @@ -255,14 +266,15 @@ let INFO = literal: 0, options: [ [['-interval', '-i'], commands.OPTION_INT], - [['-where', '-w'], commands.OPTION_STRING, null, WHERE_COMPLETIONS] + [['-where', '-w'], commands.OPTION_STRING, null, WHERE_COMPLETIONS], + [['-include-current', '-I'], commands.OPTION_NOARG] ], completer: function (context, arg) { context.title = ['URL', 'Text Content']; // 本来の補完の絞り込みを抑止 let filter = context.filter; context.filter = ""; - context.completions = filteredLinks(filter).map(function (it) ([it.href, it.textContent])); + context.completions = filteredLinks(filter, args['-include-current']).map(function (it) ([it.href, it.textContent])); }, }, true @@ -301,11 +313,12 @@ let INFO = { literal: 0, options: [ - [['-where', '-w'], commands.OPTION_STRING, null, WHERE_COMPLETIONS] + [['-where', '-w'], commands.OPTION_STRING, null, WHERE_COMPLETIONS], + [['-include-current', '-I'], commands.OPTION_NOARG] ], bang: true, - completer: function (context) { - lolinks = getLinks(); + completer: function (context, args) { + lolinks = getLinks(args['-include-current']); context.filters = [CompletionContext.Filter.textDescription]; context.anchored = false; context.title = ['URL', 'Text Content']; -- cgit v1.2.3