diff options
author | anekos | 2010-12-03 17:23:26 +0900 |
---|---|---|
committer | anekos | 2010-12-03 17:23:26 +0900 |
commit | 14881504aca54741a3a217da3645cd20721552f6 (patch) | |
tree | 22e7648f900a9f974621632e08b8e5a953138dbb /lo.js | |
parent | 6fa7de1eb12c23cf185661a7b8709d1b300d20d5 (diff) | |
download | vimperator-plugins-14881504aca54741a3a217da3645cd20721552f6.tar.bz2 |
現在のURLをデフォルトでは含めないようにした
Diffstat (limited to 'lo.js')
-rw-r--r-- | lo.js | 51 |
1 files changed, 32 insertions, 19 deletions
@@ -39,7 +39,7 @@ let PLUGIN_INFO = <name lang="ja">Link Opener</name> <description>Link Opener</description> <description lang="ja">リンクを開く</description> - <version>2.2.0</version> + <version>2.3.0</version> <author mail="anekos@snca.net" homepage="http://d.hatena.ne.jp/nokturnalmortum/">anekos</author> <license>new BSD License (Please read the source code comments of this plugin)</license> <license lang="ja">修正BSDライセンス (ソースコードのコメントを参照してください)</license> @@ -54,21 +54,21 @@ let PLUGIN_INFO = // INFO {{{ let INFO = <> - <plugin name="link-opener" version="2.2.0" + <plugin name="link-opener" version="2.3.0" href="http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk/lo.js" summary="Link Opener" lang="en-US" xmlns="http://vimperator.org/namespaces/liberator"> <author email="anekos@snca.net">anekos</author> <license>New BSD License</license> - <project name="Vimperator" minVersion="2.3"/> + <project name="Vimperator" minVersion="2.3" maxVersion="3.0"/> <p> </p> <item> <tags>:fo</tags> <tags>:fopen</tags> <tags>:filteropen</tags> - <spec>:fo<oa>pen</oa><oa>!</oa> <oa>-w<oa>here</oa>=<a>where</a></oa> <oa>-i<oa>nterval</oa>=<a>interval</a></oa> <a>filter</a></spec> + <spec>:fo<oa>pen</oa><oa>!</oa> <oa>-w<oa>here</oa>=<a>where</a></oa> <oa>-i<oa>nterval</oa>=<a>interval</a></oa> <oa>-include-current</oa> <a>filter</a></spec> <description> <p> Open the links selected with <a>filter</a>. @@ -87,7 +87,7 @@ let INFO = <tags>:lopen</tags> <tags>:lo</tags> <tags>:linkopen</tags> - <spec>:lo<oa>pen</oa><oa>!</oa> <oa>-w<oa>here</oa>=<a>where</a></oa> <a>link</a></spec> + <spec>:lo<oa>pen</oa><oa>!</oa> <oa>-w<oa>here</oa>=<a>where</a></oa> <oa>-include-current</oa> <a>link</a></spec> <description> <p> Open selected <a>link</a>. @@ -103,25 +103,26 @@ let INFO = </description> </item> </plugin> - <plugin name="link-opener" version="2.2.0" + <plugin name="link-opener" version="2.3.0" href="http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk/lo.js" summary="Link Opener" lang="ja" xmlns="http://vimperator.org/namespaces/liberator"> <author email="anekos@snca.net">anekos</author> <license>New BSD License</license> - <project name="Vimperator" minVersion="2.3"/> + <project name="Vimperator" minVersion="2.3" maxVersion="3.0"/> <p> </p> <item> <tags>:fo</tags> <tags>:fopen</tags> <tags>:filteropen</tags> - <spec>:fo<oa>pen</oa><oa>!</oa> <oa>-w<oa>here</oa>=<a>where</a></oa> <oa>-i<oa>nterval</oa>=<a>interval</a></oa> <a>filter</a></spec> + <spec>:fo<oa>pen</oa><oa>!</oa> <oa>-w<oa>here</oa>=<a>where</a></oa> <oa>-i<oa>nterval</oa>=<a>interval</a></oa> <oa>-include-current</oa> <a>filter</a></spec> <description> <p> <a>filter</a> で選択されたリンクを開きます。 <a>interval</a> はリンクを開く間隔です。 + <a>-include-current</a>が指定されると、現在のURLを指すリンクが含まれるようになります。 </p> <p><a>where</a> オプションの値</p> <dl> @@ -136,10 +137,11 @@ let INFO = <tags>:lopen</tags> <tags>:lo</tags> <tags>:linkopen</tags> - <spec>:lo<oa>pen</oa><oa>!</oa> <oa>-w<oa>here</oa>=<a>where</a></oa> <a>link</a></spec> + <spec>:lo<oa>pen</oa><oa>!</oa> <oa>-w<oa>here</oa>=<a>where</a></oa> <oa>-include-current</oa> <a>link</a></spec> <description> <p> 選択されたリンク(<a>link</a>)を開きます。 + <a>-include-current</a>が指定されると、現在のURLを指すリンクが含まれるようになります。 </p> <p><a>where</a> オプションの値</p> <dl> @@ -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']; |