Show
Ignore:
Timestamp:
12/03/08 20:31:13 (5 weeks ago)
Author:
anekos
Message:

Meow meow fixes.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • lang/javascript/vimperator-plugins/trunk/stella.js

    r25781 r25786  
    473473    get fullscreen () !!this.storage.fullscreen, 
    474474    set fullscreen (value) { 
    475       let self = this; 
    476475      value = !!value; 
    477476 
     
    481480      this.storage.fullscreen = value; 
    482481 
    483       let variablesSetter = function () { 
     482      let self = this, player = this.player, 
     483          win = content.wrappedJSObject, doc = content.document.wrappedJSObject; 
     484 
     485      win.toggleMaximizePlayer(); 
     486      if(value)  { 
     487        turnOn(); 
     488        win.onresize = fixFullscreen; 
     489      } else { 
     490        turnOff(); 
     491        delete win.onresize; 
     492      } 
     493      win.scrollTo(0, 0); 
     494 
     495      // 以下関数定義のみ - setVariables turnOn/Off fixFullscreen 
     496 
     497      function setVariables (fullscreen) { 
    484498        NicoPlayer.Variables.forEach(function ([name, normal, full]) { 
    485           let v = value ? full : normal; 
     499          let v = fullscreen ? full : normal; 
    486500          if (v !== null) 
    487501            self.player.SetVariable(name, v); 
    488502        }); 
    489       }; 
    490  
    491       let doc = content.document.wrappedJSObject; 
    492       let win = content.wrappedJSObject; 
    493       let player = getElementByIdEx('flvplayer'); 
    494  
    495       win.toggleMaximizePlayer(); 
    496  
    497       if(value)  { 
    498         let f = function () { 
    499           let viewer = {w: 544, h: 384}; 
    500           let screen = { 
    501             w: content.innerWidth, 
    502             h: content.innerHeight 
    503           }; 
    504           let scale = { 
    505             w: Math.max(1, screen.w / viewer.w), 
    506             h: Math.max(1, screen.h / viewer.h) 
    507           }; 
    508           scale.v = Math.min(scale.w, scale.h); 
    509           storeStyle(doc.body, { 
    510             backgroundImage: 'url()', 
    511             backgroundRepeat: '', 
    512             backgroundColor: 'black' 
    513           }); 
    514           player.SetVariable('videowindow.video_mc.video.smoothing' , 1); 
    515           player.SetVariable('videowindow.video_mc.video.deblocking', 5); 
    516           storeStyle( 
    517             player, 
    518             (scale.w >= scale.h) ? { 
    519               width:       Math.floor(viewer.w * scale.h) + 'px', 
    520               height:      screen.h + 'px', 
    521               marginLeft:  ((screen.w - viewer.w * scale.h) / 2) + 'px', 
    522               marginTop:   '0px' 
    523             } : { 
    524               width:       screen.w + 'px', 
    525               height:      Math.floor(viewer.h * scale.w) + 'px', 
    526               marginLeft:  '0px', 
    527               marginTop:   ((screen.h - viewer.h * scale.w) / 2) + 'px' 
    528             } 
    529           ); 
    530           player.SetVariable('videowindow._xscale', 100 * scale.v); 
    531           player.SetVariable('videowindow._yscale', 100 * scale.v); 
    532           variablesSetter(); 
     503      } 
     504 
     505      function turnOn () { 
     506        let viewer = {w: 544, h: 384}; 
     507        let screen = { 
     508          w: content.innerWidth, 
     509          h: content.innerHeight 
    533510        }; 
    534         f(); 
    535         win.onresize = function () 
    536           (InVimperator && liberator.mode === modes.COMMAND_LINE) || setTimeout(f, 1000); 
    537       } else { 
    538         restoreStyle(doc.body); 
     511        let scale = { 
     512          w: Math.max(1, screen.w / viewer.w), 
     513          h: Math.max(1, screen.h / viewer.h) 
     514        }; 
     515        scale.v = Math.min(scale.w, scale.h); 
     516        storeStyle(doc.body, { 
     517          backgroundImage: 'url()', 
     518          backgroundRepeat: '', 
     519          backgroundColor: 'black' 
     520        }); 
     521        storeStyle( 
     522          player, 
     523          (scale.w >= scale.h) ? { 
     524            width:       Math.floor(viewer.w * scale.h) + 'px', 
     525            height:      screen.h + 'px', 
     526            marginLeft:  ((screen.w - viewer.w * scale.h) / 2) + 'px', 
     527            marginTop:   '0px' 
     528          } : { 
     529            width:       screen.w + 'px', 
     530            height:      Math.floor(viewer.h * scale.w) + 'px', 
     531            marginLeft:  '0px', 
     532            marginTop:   ((screen.h - viewer.h * scale.w) / 2) + 'px' 
     533          } 
     534        ); 
     535        player.SetVariable('videowindow._xscale', 100 * scale.v); 
     536        player.SetVariable('videowindow._yscale', 100 * scale.v); 
     537        setVariables(true); 
     538      } 
     539 
     540      function turnOff () { 
     541        restoreStyle(content.document.wrappedJSObject.body); 
    539542        //restoreStyle(player); 
    540543        player.style.marginLeft = ''; 
    541544        player.style.marginTop  = ''; 
    542         variablesSetter(); 
    543         delete win.onresize; 
    544       } 
    545       win.scrollTo(0, 0); 
     545        setVariables(false); 
     546      } 
     547 
     548      function fixFullscreen () 
     549        ((InVimperator && liberator.mode === modes.COMMAND_LINE) || setTimeout(turnOn, 500)); 
     550 
    546551    }, 
    547552 
     
    600605        setTimeout(bindr(this, function () (base === this.currentTime ? this.playEx() : this.pause())), 100); 
    601606      } 
    602     } 
     607    }, 
     608 
    603609  }; 
    604610 
     
    619625    'repeat', 
    620626    'fullscreen', 
     627    'fetch', 
    621628    { 
    622629      name: 'volume-root', 
     
    887894    onCommentClick: function () (this.player.toggle('comment')), 
    888895 
     896    onFetchClick: function () this.player.fetch(), 
     897 
    889898    // フルスクリーン時にステータスバーを隠さないようにする 
    890899    onFullScreen: function () { 
     
    928937    onPlayClick: function () this.player.play(), 
    929938 
    930     onRepeatingClick: function () this.player.toggle('repeating'), 
     939    onRepeatClick: function () this.player.toggle('repeating'), 
    931940 
    932941    onResize: function () {