From ae80deeaa05ab66b44f354fd179129d73375a9c1 Mon Sep 17 00:00:00 2001 From: anekos Date: Mon, 22 Feb 2010 11:11:32 +0000 Subject: 設定クラス(Setting)を globalVariables から読み込めるように実装 git-svn-id: http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk@36850 d0d07461-0603-4401-acd4-de1884942a52 --- stella.js | 46 ++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 40 insertions(+), 6 deletions(-) (limited to 'stella.js') diff --git a/stella.js b/stella.js index 0d638a5..733a9d6 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.7 + 0.25.0 anekos new BSD License (Please read the source code comments of this plugin) 修正BSDライセンス (ソースコードのコメントを参照してください) @@ -483,10 +483,44 @@ Thanks: * Setting {{{ *********************************************************************************/ - function Setting () { - this.niconico = { - autoFullscreenDelay: 1000 + function Setting (isVimp) { + function ul (s) + s.replace(/[a-z][A-Z]/g, function (s) (s[0] + '_' + s[1].toLowerCase())); + + function readFrom (obj, reader) { + function _readFrom (obj, parents) { + for (let [name, value] in Iterator(obj)) { + let _parents = parents.concat([name]); + if (typeof value === 'object') { + _readFrom(value, _parents); + } else { + let newValue = reader(ul(_parents.join('_'))); + if (typeof newValue !== 'undefined') + obj[name] = newValue; + } + } + } + return _readFrom([]); + } + + function vimpReader (name) + liberator.globalVariables['stella_' + name]; + + function firefoxReader (name) + undefined; + + let setting = { + common: { + autoFullscreenDelay: 200 + }, + nico: { + useComment: false + } }; + + readFrom(setting, isVimp ? vimpReader : firefoxReader); + + return setting; } // }}} @@ -1573,7 +1607,7 @@ Thanks: add('fe[tch]', 'fetch'); add('la[rge]', 'large'); add('fu[llscreen]', 'fullscreen'); - if (U.s2b(liberator.globalVariables.stella_use_nico_comment, false)) + if (U.s2b(liberator.globalVariables.stella_nico_use_comment, false)) add('sa[y]', 'say'); commands.addUserCommand( @@ -1864,7 +1898,7 @@ Thanks: clearInterval(this.__autoFullscreenTimer) setTimeout( U.bindr(this, function () (this.player[this.player.last.screenMode] = true)), - this.setting.niconico.autoFullscreenDelay + this.setting.common.autoFullscreenDelay ); delete this.__autoFullscreenTimer; }), -- cgit v1.2.3