Changeset 26633
- Timestamp:
- 12/13/08 20:21:58 (4 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
lang/javascript/vimperator-plugins/trunk/stella.js
r26125 r26633 1 // ==VimperatorPlugin== 2 // @name すてら 3 // @description-ja ステータスラインに動画の再生時間などを表示する。 4 // @license Creative Commons Attribution-Share Alike 3.0 Unported 5 // @version 0.07 6 // @author anekos (anekos@snca.net) 7 // @minVersion 2.0pre 8 // @maxVersion 2.0pre 9 // ==/VimperatorPlugin== 10 // 11 // Usage-ja: 12 // 作成中 13 // 1 var PLUGIN_INFO = 2 <VimperatorPlugin> 3 <name>Stella</name> 4 <name lang="ja">すてら</name> 5 <description>Show video informations on the status line.</description> 6 <description lang="ja">ステータスラインに動画の再生時間などを表示する。</description> 7 <version>0.09</version> 8 <author mail="anekos@snca.net" homepage="http://d.hatena.ne.jp/nokturnalmortum/">anekos</author> 9 <minVersion>2.0pre</minVersion> 10 <maxVersion>2.0pre</maxVersion> 11 <license document="http://creativecommons.org/licenses/by-sa/3.0/"> 12 Creative Commons Attribution-Share Alike 3.0 Unported 13 </license> 14 <detail><![CDATA[ 15 == Commands == 16 :stpl[ay]: 17 play or pause 18 :stpa[use]: 19 pause 20 :stvolume <VOLUME>: 21 set to the specified volume. 22 :stmu[te]: 23 turn on/off mute. 24 :stre[peat]: 25 turn on/off mute. 26 :stco[mment]: 27 turn on/off comment visible. 28 :stse[ek] <TIMECODE>: 29 seek to specified position. 30 TIMECODE formats 31 :stseek 1:30 # 1分30秒 32 :stseek 1.5 # 1.5分。90秒 33 :stseek 90 # 90秒 34 :stse[ek]! <TIMECODE>: 35 seek to the specified position from current position at relatively. 36 :stfe[tch]: 37 fetch and save the video. 38 :stla[rge]: 39 enlarge video screen. 40 :stfu[llscreen]: 41 turn on/off fullscreen. 42 ]]></detail> 43 <detail lang="ja"><![CDATA[ 44 == Commands == 45 :stpl[ay]: 46 再生/ポーズの解除を行う。 47 :stpa[use]: 48 一時停止する。 49 :stvolume <VOLUME>: 50 指定の音量にする。 51 0から100の数字で指定する。 52 :stmu[te]: 53 ミュートのOn/Offを切り替える。 54 :stre[peat]: 55 リピートモードのOn/Offを切り替える。 56 :stco[mment]: 57 コメントのOn/Offを切り替える。 58 :stse[ek] <TIMECODE>: 59 指定の秒数までシークスする。 60 TIMECODE は以下の様に指定できる。 61 :stseek 1:30 # 1分30秒 62 :stseek 1.5 # 1.5分。90秒 63 :stseek 90 # 90秒 64 :stse[ek]! <TIMECODE>: 65 現在の位置から TIMECODE 分移動する。 66 :stfe[tch]: 67 動画をファイルとして保存する。 68 :stla[rge]: 69 画面を大きくする/戻す。 70 :stfu[llscreen]: 71 フルスクリーン表示のOn/Offを切り替える。 72 ]]></detail> 73 </VimperatorPlugin>; 74 14 75 // TODO 15 76 // Icons … … 26 87 // Thanks! 27 88 // 28 // License:29 // http://creativecommons.org/licenses/by-sa/3.0/30 31 var PLUGIN_INFO =32 <VimperatorPlugin>33 <name>{NAME}</name>34 <description>Show the time of movie on status line</description>35 <description lang="ja">{"ステータスラインに動画の再生時間などを表示する。"}</description>36 <version>0.08</version>37 <detail><![CDATA[38 :stfetch39 :stfullscreen40 :stpause41 :stplay42 :strelations43 :strepeat44 :stseek45 :stvolume46 ]]></detail>47 </VimperatorPlugin>;48 89 49 90 (function () { … … 189 230 } 190 231 232 // 上手い具合に病数に直すよ 233 function fromTimeCode (code) { 234 let m; 235 function sign (s, v) 236 (s == '-' ? -v : v); 237 if (m = code.match(/^([-+])?(\d+):(\d+)$/)) 238 return sign(m[1], parseInt(m[2]) * 60 + parseInt(m[3])); 239 if (m = code.match(/^([-+])?(\d+.\d+)$/)) 240 return sign(m[1], parseFloat(m[2]) * 60); 241 return parseInt(code); 242 } 243 191 244 // }}} 192 245 … … 212 265 setf('fetch', this.has('fileURL', 'r') && 'x'); 213 266 setf('relations', [name for each (name in Player.RELATIONS) if (this.has(name, 'r'))].length && 'r'); 267 if (!this.functions.large) 268 this.functions.large = this.functions.fullscreen; 214 269 } 215 270 … … 248 303 relatedTags: '', 249 304 repeating: '', 305 large: '', 250 306 tags: '', 251 307 title: '', … … 279 335 280 336 get fileExtension () '', 337 338 get fullscreen () undefined, 339 set fullscreen (value) value, 281 340 282 341 get fileURL () undefined, … … 310 369 set repeating (value) value, 311 370 371 get large () this.fullscreen, 372 set large (value) (this.fullscreen = value), 373 312 374 get state () undefined, 313 375 … … 350 412 351 413 seek: function (v) { 352 v = parseInt(v, 10);414 v = fromTimeCode(v); 353 415 if (v < 0) 354 416 v = this.totalTime + v; … … 357 419 358 420 seekRelative: function (v) 359 this.currentTime = Math.min(Math.max(this.currentTime + parseInt(v, 10), 0), this.totalTime),421 this.currentTime = Math.min(Math.max(this.currentTime + fromTimeCode(v), 0), this.totalTime), 360 422 361 423 toggle: function (name) { … … 402 464 403 465 get currentTime () parseInt(this.player.getCurrentTime()), 404 set currentTime (value) (this.player.seekTo( value), value),466 set currentTime (value) (this.player.seekTo(fromTimeCode(value)), this.currentTime), 405 467 406 468 get fileExtension () '.mp4', … … 499 561 ]; 500 562 563 NicoPlayer.SIZE_NORMAL = 'normal'; 564 NicoPlayer.SIZE_LARGE = 'fit'; 565 501 566 NicoPlayer.prototype = { 502 567 __proto__: Player.prototype, … … 511 576 makeURL: 'x', 512 577 muted: 'rwt', 578 large: 'rwt', 513 579 pause: 'x', 514 580 play: 'x', … … 532 598 533 599 get currentTime () parseInt(this.player.ext_getPlayheadTime()), 534 set currentTime (value) (this.player.ext_setPlayheadTime( value), value),600 set currentTime (value) (this.player.ext_setPlayheadTime(fromTimeCode(value)), this.currentTime), 535 601 536 602 get fileExtension () '.flv', … … 660 726 set repeating (value) (this.player.ext_setRepeat(value), value), 661 727 728 get large () this.player.ext_getVideoSize() === NicoPlayer.SIZE_LARGE, 729 set large (value) { 730 liberator.log(value) 731 this.player.ext_setVideoSize(value ? NicoPlayer.SIZE_LARGE : NicoPlayer.SIZE_NORMAL) 732 return this.large; 733 }, 734 662 735 get state () { 663 736 switch (this.player.ext_getStatus()) { … … 682 755 683 756 fetch: function (filepath) { 684 let onComplete = function (xhr) {757 let onComplete = bindr(this, function (xhr) { 685 758 let res = xhr.responseText; 686 759 let info = {}; 687 760 res.split(/&/).forEach(function (it) let ([n, v] = it.split(/=/)) (info[n] = v)); 688 761 download(decodeURIComponent(info.url), filepath, this.fileExtension, this.title); 689 } ;690 httpRequest('http://www.nicovideo.jp/api/getflv?v=' + this.id, bindr(this, onComplete));762 }); 763 httpRequest('http://www.nicovideo.jp/api/getflv?v=' + this.id, onComplete); 691 764 }, 692 765 … … 909 982 add('se[ek]', 'seek', 'seekRelative'); 910 983 add('fe[tch]', 'fetch'); 984 add('la[rge]', 'large'); 911 985 add('fu[llscreen]', 'fullscreen'); 912 986
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)