aboutsummaryrefslogtreecommitdiffstats
path: root/proxy.js
diff options
context:
space:
mode:
authordrry2008-04-09 17:54:47 +0000
committerdrry2008-04-09 17:54:47 +0000
commiteca06d9aedea8ada998ab8204d1959983dc361bc (patch)
tree28b643a577fe4a055b318512d82fcb3fb352d6b6 /proxy.js
parent67e78bae03b218db17646b5c4ba5c35b3bb2bee4 (diff)
downloadvimperator-plugins-eca06d9aedea8ada998ab8204d1959983dc361bc.tar.bz2
lang/javascript/vimperator-plugins/trunk/proxy.js:
* 整理しました。 git-svn-id: http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk@9231 d0d07461-0603-4401-acd4-de1884942a52
Diffstat (limited to 'proxy.js')
-rw-r--r--proxy.js112
1 files changed, 52 insertions, 60 deletions
diff --git a/proxy.js b/proxy.js
index 6437124..65cddbc 100644
--- a/proxy.js
+++ b/proxy.js
@@ -1,85 +1,78 @@
/**
- * vimperator plugin
+ * Vimperator plugin
*
- * proxy setting plugin (for vimperator-0.6pre)
+ * proxy setting plugin (for Vimperator 0.6pre)
*
* @author cho45
* @author halt feits
- * @version 0.6.1
+ * @version 0.6
*/
(function() {
const proxy_settings = [
- {
- conf_name: 'disable',
- conf_usage: 'direct connection',
- setting: [
- {
- label: 'type',
- param: 0
- }
- ]
- },
- {
- conf_name: 'polipo',
- conf_usage: 'use polipo cache proxy',
- setting: [
- {
- label: 'type',
- param: 1
- },
- {
- label: 'http',
- param: 'localhost'
- },
- {
- label: 'http_port',
- param: 8123
- }
- ]
- }
+ {
+ conf_name: 'disable',
+ conf_usage: 'direct connection',
+ settings: [
+ {
+ label: 'type',
+ param: 0
+ }
+ ]
+ },
+ {
+ conf_name: 'polipo',
+ conf_usage: 'use polipo cache proxy',
+ settings: [
+ {
+ label: 'type',
+ param: 1
+ },
+ {
+ label: 'http',
+ param: 'localhost'
+ },
+ {
+ label: 'http_port',
+ param: 8123
+ }
+ ]
+ }
];
- liberator.commands.addUserCommand(["proxy"], 'proxy settings',
- function (args) {
- const prefs = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefService);
+ liberator.commands.addUserCommand(["proxy"], 'Proxy settings', function (args) {
+ const prefs = Components.classes["@mozilla.org/preferences-service;1"]
+ .getService(Components.interfaces.nsIPrefService);
var name = args;
if (!name) {
liberator.echo("Usage: proxy {setting name}");
}
- for (var i = 0; i < proxy_settings.length; i++) {
- var proxy_setting = proxy_settings[i];
- if (proxy_setting.conf_name.toLowerCase() == name.toLowerCase()) {
+ proxy_settings.some(function (proxy_setting) {
+ if (proxy_setting.conf_name.toLowerCase() != name.toLowerCase()) {
+ return false;
+ }
- //delete setting
- ['http', 'ssl', 'ftp', 'gopher'].forEach(
- function (p) {
- prefs.setCharPref("network.proxy." + p, '');
- prefs.setIntPref("network.proxy." + p + "_port", 0);
- }
- );
+ //delete setting
+ ['http', 'ssl', 'ftp', 'gopher'].forEach(function (scheme_name) {
+ prefs.setCharPref("network.proxy." + scheme_name, '');
+ prefs.setIntPref("network.proxy." + scheme_name + "_port", 0);
+ });
- for (var j = 0; j < proxy_setting.setting.length; j++) {
- var conf = proxy_setting.setting[j];
- liberator.options.setPref('network.proxy.' + conf.label, conf.param);
- }
+ proxy_setting.settings.forEach(function (conf) {
+ liberator.options.setPref('network.proxy.' + conf.label, conf.param);
+ });
- liberator.echo("set config:" + name);
- break;
- }
- }
+ liberator.echo("Set config: " + name);
+ return true;
+ });
},
{
completer: function (filter) {
var completions = [];
+ var exp = new RegExp("^" + filter);
- for (var i = 0; i < proxy_settings.length; i++) {
- var name = proxy_settings[i].conf_name;
- var usage = proxy_settings[i].conf_usage;
-
- var exp = new RegExp("^" + filter);
-
+ for each (let { conf_name: name, conf_usage: usage } in proxy_settings) {
if (exp.test(name)) {
completions.push([name, usage]);
}
@@ -87,8 +80,7 @@
return [0, completions];
}
- }
-);
+ });
})();
// vim: set sw=4 ts=4 et: