Changeset 26633

Show
Ignore:
Timestamp:
12/13/08 20:21:58 (4 years ago)
Author:
anekos
Message:

:stlarge 追加
説明追加

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 // 
     1var 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 
    1475// TODO 
    1576//    Icons 
     
    2687//    Thanks! 
    2788// 
    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 :stfetch 
    39 :stfullscreen 
    40 :stpause 
    41 :stplay 
    42 :strelations 
    43 :strepeat 
    44 :stseek 
    45 :stvolume 
    46 ]]></detail> 
    47 </VimperatorPlugin>; 
    4889 
    4990(function () { 
     
    189230  } 
    190231 
     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 
    191244  // }}} 
    192245 
     
    212265    setf('fetch', this.has('fileURL', 'r') && 'x'); 
    213266    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; 
    214269  } 
    215270 
     
    248303      relatedTags: '', 
    249304      repeating: '', 
     305      large: '', 
    250306      tags: '', 
    251307      title: '', 
     
    279335 
    280336    get fileExtension () '', 
     337 
     338    get fullscreen () undefined, 
     339    set fullscreen (value) value, 
    281340 
    282341    get fileURL () undefined, 
     
    310369    set repeating (value) value, 
    311370 
     371    get large () this.fullscreen, 
     372    set large (value) (this.fullscreen = value), 
     373 
    312374    get state () undefined, 
    313375 
     
    350412 
    351413    seek: function (v) { 
    352       v = parseInt(v, 10); 
     414      v = fromTimeCode(v); 
    353415      if (v < 0) 
    354416        v = this.totalTime + v; 
     
    357419 
    358420    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), 
    360422 
    361423    toggle: function (name) { 
     
    402464 
    403465    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), 
    405467 
    406468    get fileExtension () '.mp4', 
     
    499561  ]; 
    500562 
     563  NicoPlayer.SIZE_NORMAL  = 'normal'; 
     564  NicoPlayer.SIZE_LARGE   = 'fit'; 
     565 
    501566  NicoPlayer.prototype = { 
    502567    __proto__: Player.prototype, 
     
    511576      makeURL: 'x', 
    512577      muted: 'rwt', 
     578      large: 'rwt', 
    513579      pause: 'x', 
    514580      play: 'x', 
     
    532598 
    533599    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), 
    535601 
    536602    get fileExtension () '.flv', 
     
    660726    set repeating (value) (this.player.ext_setRepeat(value), value), 
    661727 
     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 
    662735    get state () { 
    663736      switch (this.player.ext_getStatus()) { 
     
    682755 
    683756    fetch: function (filepath) { 
    684       let onComplete = function (xhr) { 
     757      let onComplete = bindr(this, function (xhr) { 
    685758          let res = xhr.responseText; 
    686759          let info = {}; 
    687760          res.split(/&/).forEach(function (it) let ([n, v] = it.split(/=/)) (info[n] = v)); 
    688761          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); 
    691764    }, 
    692765 
     
    909982      add('se[ek]', 'seek', 'seekRelative'); 
    910983      add('fe[tch]', 'fetch'); 
     984      add('la[rge]', 'large'); 
    911985      add('fu[llscreen]', 'fullscreen'); 
    912986