diff options
author | drry | 2009-01-04 16:13:55 +0000 |
---|---|---|
committer | drry | 2009-01-04 16:13:55 +0000 |
commit | 86bd945c9645fa6249373671cb3d6f55347ad96d (patch) | |
tree | 87e39d99fa9f3ad54fba66ddd3a643f35b9c7bc3 | |
parent | fd0cf0e50070bdf4b7bc42eb461577b5038d64b4 (diff) | |
download | vimperator-plugins-86bd945c9645fa6249373671cb3d6f55347ad96d.tar.bz2 |
* fixed and removed regexes.
* et cetera.
git-svn-id: http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk@27919 d0d07461-0603-4401-acd4-de1884942a52
-rw-r--r-- | uaSwitchLite.js | 33 |
1 files changed, 16 insertions, 17 deletions
diff --git a/uaSwitchLite.js b/uaSwitchLite.js index 6ecfb97..44b177a 100644 --- a/uaSwitchLite.js +++ b/uaSwitchLite.js @@ -73,7 +73,7 @@ global.useragent_list = global.useragent_list ? global.useragent_list : [ } ]; -var Class = function(){ return function(){ this.initialize.apply(this, arguments); }}; +var Class = function() function(){ this.initialize.apply(this, arguments); }; var UASwitcherLite = new Class(); UASwitcherLite.prototype = { @@ -81,8 +81,8 @@ UASwitcherLite.prototype = { // init this.completer = []; this.switcher = { - __noSuchMethod__: function(arg) liberator.echoerr('cannot switch useragent "'+arg+'"'), - '':function(){ + __noSuchMethod__: function(arg) liberator.echoerr('cannot switch user agent "'+arg+'"'), + '': function(){ var ua = options.getPref(USER_AGENT); liberator.echo('Current User Agent : ' + (ua ? ua : DEFAULT) ); } @@ -90,18 +90,18 @@ UASwitcherLite.prototype = { var self = this; // default values - this.completer.push([DEFAULT , '']); + this.completer.push([DEFAULT, '']); this.switcher[DEFAULT] = function() self.switch(); - + // expand setting global.useragent_list.forEach( function(item){ - let desc = item.description; - let userAgent = item.useragent; - let appName = item.appname; - let appVersion = item.appversion; - let platform = item.platform; - let vendor = item.vendor; - let vendorSub = item.vendorSub; + var desc = item.description; + var userAgent = item.useragent; + var appName = item.appname; + var appVersion = item.appversion; + var platform = item.platform; + var vendor = item.vendor; + var vendorSub = item.vendorSub; self.completer.push([desc, userAgent]); self.switcher[desc] = function() self.switch(appName, appVersion, platform, userAgent, vendor, vendorSub); }); @@ -109,23 +109,22 @@ UASwitcherLite.prototype = { }, switch: function(appName, appVersion, platform, userAgent, vendor, vendorSub){ if (!userAgent && !options.getPref(USER_AGENT)) return; - let setter = userAgent ? options.setPref : options.resetPref; + var setter = userAgent ? options.setPref : options.resetPref; setter(APP_NAME, decodeURIComponent(appName || '')); setter(APP_VERSION, decodeURIComponent(appVersion || '')); setter(PLATFORM, decodeURIComponent(platform || '')); setter(USER_AGENT, decodeURIComponent(userAgent || '')); setter(VENDOR, decodeURIComponent(vendor || '')); setter(VENDOR_SUB, decodeURIComponent(vendorSub || '')); - }, registerCommand: function(){ var self = this; commands.addUserCommand(['ua'], 'Switch User Agent', - function(arg) - self.switcher[ arg.string ? arg.string.replace(/\\/g,''): (arg+'').replace(/\\/g,'') ](), + function(arg) + self.switcher[ (arg.string || arg+'').replace(/\\+/g,'') ](), { completer: function(context, args, special){ - let filter = context.filter; + var filter = context.filter; context.title = ['Description', 'User Agent']; if (!filter) { context.completions = self.completer; |