Changeset 20875
- Timestamp:
- 10/07/08 07:43:44 (6 weeks ago)
- Files:
-
- 1 modified
-
lang/javascript/vimperator-plugins/trunk/lo.js (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
lang/javascript/vimperator-plugins/trunk/lo.js
r20201 r20875 4 4 // @description-ja リンクをフィルタリングして開く 5 5 // @license Creative Commons 2.1 (Attribution + Share Alike) 6 // @version 1. 06 // @version 1.1 7 7 // ==/VimperatorPlugin== 8 8 // 9 9 // Usage: 10 // :fo pen<REGEXP> [-i <INTERVAL_SEC>]10 // :fo[pen][!] <REGEXP> [-i <INTERVAL_SEC>] 11 11 // Open filtered links by regexp. 12 // When used "!", open links in foreground. 12 13 // 13 // :lo[pen] URI14 // :lo[pen][!] URI 14 15 // Open URI 15 16 // 16 17 // Usage-ja: 17 // :fo[pen] <ミゲ文字列> [-i <INTERVAL_SEC>]18 // :fo[pen] /<正規表現> [-i <INTERVAL_SEC>]18 // :fo[pen][!] <ミゲ文字列> [-i <INTERVAL_SEC>] 19 // :fo[pen][!] /<正規表現> [-i <INTERVAL_SEC>] 19 20 // ミゲ文字列か正規表現でフィルタされたリンクを開く 20 21 // 21 // :lo[pen] URI22 // :lo[pen][!] URI 22 23 // URI を開く 23 24 // … … 27 28 // Variables: 28 29 // let g:fopen_default_interval="<INTERVAL_SEC>" 30 // 31 // Notice: 32 // "--where" option's implementation has not been completed yet. 29 33 30 34 … … 58 62 } 59 63 64 function charToWhere (str, fail) { 65 const table = { 66 f: NEW_TAB, 67 t: NEW_TAB, 68 b: NEW_BACKGROUND_TAB, 69 c: CURRENT_TAB, 70 w: NEW_WINDOW, 71 }; 72 return (str && table[str.charAt(0).toLowerCase()]) || fail; 73 } 74 60 75 let foihandle; 61 76 … … 63 78 ['fo[pen]', 'filteropen'], 64 79 'Filtered open', 65 function (opts) { 80 function (opts, bang) { 81 let where = charToWhere(opts['-where'], bang ? NEW_TAB : NEW_BACKGROUND_TAB); 66 82 let [i, links] = [1, filteredLinks(opts.arguments.join(''))]; 67 83 if (!links.length) 68 84 return; 69 open(links[0].href, NEW_BACKGROUND_TAB);85 open(links[0].href, where); 70 86 if (links.length <= 1) 71 87 return; … … 73 89 foihandle = setInterval(function () { 74 90 try { 75 open(links[i].href, NEW_BACKGROUND_TAB);91 open(links[i].href, where); 76 92 if ((++i) >= links.length) 77 93 clearInterval(foihandle); … … 84 100 options: [ 85 101 [['-interval', '-i'], liberator.commands.OPTIONS_INT], 102 [['-where', '-w'], liberator.commands.OPTIONS_STRING], 86 103 ], 87 104 completer: function (word) { … … 93 110 94 111 liberator.commands.addUserCommand( 95 ['stopfilteropen' ],112 ['stopfilteropen', 'stopfo[pen]'], 96 113 'Stop filtered open', 97 114 function () { … … 101 118 102 119 let lolinks = []; 120 let looptions = [ [['-where', '-w'], liberator.commands.OPTIONS_STRING], ]; 103 121 104 122 liberator.commands.addUserCommand( 105 123 ['lo[pen]', 'linkopen'], 106 124 'Filtered open', 107 function (uri) { 125 function (opts, bang) { 126 let where = charToWhere(opts['-where'], bang ? NEW_TAB : CURRENT_TAB); 127 let uri = opts.arguments[0]; 108 128 for each (let link in lolinks) { 109 129 if (~link.href.indexOf(uri)) 110 return liberator.buffer.followLink(link );130 return liberator.buffer.followLink(link, where); 111 131 } 112 132 if (lolinks[0]) { 113 liberator.buffer.followLink(lolinks[0] );133 liberator.buffer.followLink(lolinks[0], where); 114 134 } else { 115 135 liberator.echoerr('lol') … … 117 137 }, 118 138 { 139 options: looptions; 119 140 completer: function (word) { 120 lolinks = filteredLinks(word); 141 let opts = liberator.parseArgs(word, looptions, "1", true); 142 log(opts); 143 lolinks = filteredLinks(word);//word.match(/\bhttp[^\s]+/)); 121 144 return [0, [[it.href, it.textContent] for each (it in lolinks)]]; 122 145 }
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)