diff options
author | anekos | 2009-01-26 14:12:43 +0000 |
---|---|---|
committer | anekos | 2009-01-26 14:12:43 +0000 |
commit | 4775a6602be86c59a0754be098ea9e191c612340 (patch) | |
tree | 3e61dbefccb3d68a266489b8ceec40c29ac63fc6 | |
parent | e3e145b4d14d4ee1bb958f133b18871ad39709c4 (diff) | |
download | vimperator-plugins-4775a6602be86c59a0754be098ea9e191c612340.tar.bz2 |
Follow the HEAD.
git-svn-id: http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk@29086 d0d07461-0603-4401-acd4-de1884942a52
-rw-r--r-- | encodingSwitcher.js | 45 |
1 files changed, 26 insertions, 19 deletions
diff --git a/encodingSwitcher.js b/encodingSwitcher.js index d4b312f..c5ceb05 100644 --- a/encodingSwitcher.js +++ b/encodingSwitcher.js @@ -82,25 +82,29 @@ function completion(array, filter){ } var sbCharDefault = sbService.createBundle(gPrefService.getDefaultBranch('intl.charset.').getCharPref('default')); const DEFAULT_CHARSET = sbCharDefault.GetStringFromName('intl.charset.default'); -liberator.options.add(['fileencoding','fenc'],'set the charactor encoding for the current page','string', DEFAULT_CHARSET, +options.add(['fileencoding','fenc'],'set the charactor encoding for the current page','string', DEFAULT_CHARSET, { + scope: options.OPTION_SCOPE_LOCAL, setter: function(value){ - if (!value) return; - value = getEncoding(value); - SetForcedCharset(value); - //SetDefaultCharacterSet(value); + if (value) { + value = getEncoding(value); + liberator.log('set: ' + value) + SetForcedCharset(value); + } + return value; }, getter: function() getBrowser().docShell.QueryInterface(Ci.nsIDocCharset).charset, validator: function(value) - isValid( encodings, value), - completer: function(filter) - [0,completion( encodings, filter)] + isValid(encodings, value), + completer: function(context) { + context.completions = completion(encodings, context.filter); + } } ); var sbCharDetector = sbService.createBundle(gPrefService.getDefaultBranch('intl.charset.').getCharPref('detector')); const DEFAULT_DETECTOR = createDetector(sbCharDetector.GetStringFromName('intl.charset.detector'))[0]; -liberator.options.add(['autodetector','audet'],'set auto detect character encoding','string',DEFAULT_DETECTOR, +options.add(['autodetector','audet'],'set auto detect character encoding','string',DEFAULT_DETECTOR, { setter: function(value){ var pref = Cc['@mozilla.org/preferences-service;1'].getService(Ci.nsIPrefBranch); @@ -124,8 +128,9 @@ liberator.options.add(['autodetector','audet'],'set auto detect character encodi }, validator: function(value) isValid( detectors, value), - completer: function(filter) - [0,completion( detectors, filter)] + completer: function(context) { + context.completions = completion(detectors, context.filter); + } } ); function listCharset(arg, current, list){ @@ -146,20 +151,22 @@ function listCharset(arg, current, list){ str.push('</table>'); liberator.echo( str.join(''), true); } -liberator.commands.addUserCommand(['listencoding','lsenc'],'list all encodings', +commands.addUserCommand(['listencoding','lsenc'],'list all encodings', function(arg){ - listCharset(arg, liberator.options.fileencoding, encodings); + listCharset(arg, options.fileencoding, encodings); },{ - completer: function(filter) - [0,completion(encodings, filter)] + completer: function(context) { + context.completions = completion(encodings, context.filter); + } } ); -liberator.commands.addUserCommand(['listdetector','lsdet'],'list all auto detectors', +commands.addUserCommand(['listdetector','lsdet'],'list all auto detectors', function(arg){ - listCharset(arg, liberator.options.autodetector, detectors); + listCharset(arg, options.autodetector, detectors); },{ - completer: function(filter) - [0,completion(detectors, filter)] + completer: function(context) { + context.completions = completion(detectors, context.filter); + } } ); |