From 05ab6ac6e41586b57221e6a61c5edcb64533cb55 Mon Sep 17 00:00:00 2001 From: anekos Date: Thu, 18 Feb 2010 18:53:17 +0000 Subject: ローカルなマッピング設定のサンプル git-svn-id: http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk@36806 d0d07461-0603-4401-acd4-de1884942a52 --- stella.js | 108 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 107 insertions(+), 1 deletion(-) (limited to 'stella.js') diff --git a/stella.js b/stella.js index 8178246..325e5de 100644 --- a/stella.js +++ b/stella.js @@ -39,7 +39,7 @@ let PLUGIN_INFO = すてら For Niconico/YouTube/Vimeo, Add control commands and information display(on status line). ニコニコ動画/YouTube/Vimeo 用。操作コマンドと情報表示(ステータスライン上に)追加します。 - 0.24.4 + 0.24.5 anekos new BSD License (Please read the source code comments of this plugin) 修正BSDライセンス (ソースコードのコメントを参照してください) @@ -76,6 +76,60 @@ let PLUGIN_INFO = turn on/off fullscreen. :stqu[ality]: Set video quality. + + == Local Mappings Sample == + >|| +function addLocalMappings(buffer, maps) { + maps.forEach( + function (map) { + let [cmd, action, extra] = map; + let actionFunc = action; + extra || (extra = {}); + + if (typeof action == "string") { + if (action.charAt(0) == ':') + actionFunc = extra.open ? function () commandline.open("", action, modes.EX) + : function () liberator.execute(action); + else + actionFunc = function () events.feedkeys(action, extra.noremap, true); + } + extra.matchingUrls = buffer; + mappings.addUserMap( + [modes.NORMAL], + [cmd], + "Local mapping for " + buffer, + actionFunc, + extra + ); + } + ); +} + +addLocalMappings( + /^(http:\/\/(es|www).nicovideo.jp\/watch|http:\/\/(jp|www)\.youtube\.com\/watch|http:\/\/(www\.)?vimeo\.com\/(channels\/(hd)?#)?\d+)/, + [ + ['', ':pageinfo S', ], + ['p', ':stplay', ], + ['m', ':stmute', ], + ['c', ':stcomment', ], + ['zz', ':stlarge', ], + ['r', ':strepeat', ], + ['+', ':stvolume! 10', ], + ['-', ':stvolume! -10', ], + ['h', ':stseek! -10', ], + ['l', ':stseek! 10', ], + ['k', ':stvolume! 10', ], + ['j', ':stvolume! -10', ], + ['s', ':stseek ', {open: true}], + ['S', ':stseek! ', {open: true}], + ['v', ':stvolume ', {open: true}], + ['V', ':stvolume! ', {open: true}], + ['o', ':strelations ', {open: true}], + ['O', ':strelations! ', {open: true}], + ] +); +||< + ]]> || +function addLocalMappings(buffer, maps) { + maps.forEach( + function (map) { + let [cmd, action, extra] = map; + let actionFunc = action; + extra || (extra = {}); + + if (typeof action == "string") { + if (action.charAt(0) == ':') + actionFunc = extra.open ? function () commandline.open("", action, modes.EX) + : function () liberator.execute(action); + else + actionFunc = function () events.feedkeys(action, extra.noremap, true); + } + extra.matchingUrls = buffer; + mappings.addUserMap( + [modes.NORMAL], + [cmd], + "Local mapping for " + buffer, + actionFunc, + extra + ); + } + ); +} + +addLocalMappings( + /^(http:\/\/(es|www).nicovideo.jp\/watch|http:\/\/(jp|www)\.youtube\.com\/watch|http:\/\/(www\.)?vimeo\.com\/(channels\/(hd)?#)?\d+)/, + [ + ['', ':pageinfo S', ], + ['p', ':stplay', ], + ['m', ':stmute', ], + ['c', ':stcomment', ], + ['zz', ':stlarge', ], + ['r', ':strepeat', ], + ['+', ':stvolume! 10', ], + ['-', ':stvolume! -10', ], + ['h', ':stseek! -10', ], + ['l', ':stseek! 10', ], + ['k', ':stvolume! 10', ], + ['j', ':stvolume! -10', ], + ['s', ':stseek ', {open: true}], + ['S', ':stseek! ', {open: true}], + ['v', ':stvolume ', {open: true}], + ['V', ':stvolume! ', {open: true}], + ['o', ':strelations ', {open: true}], + ['O', ':strelations! ', {open: true}], + ] +); +||< == Link == http://d.hatena.ne.jp/nokturnalmortum/20081213/1229168832 ]]> -- cgit v1.2.3