Changeset 9231 for lang/javascript
- Timestamp:
- 04/10/08 02:54:47 (5 years ago)
- Files:
-
- 1 modified
-
lang/javascript/vimperator-plugins/trunk/proxy.js (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
lang/javascript/vimperator-plugins/trunk/proxy.js
r8786 r9231 1 1 /** 2 * vimperator plugin2 * Vimperator plugin 3 3 * 4 * proxy setting plugin (for vimperator-0.6pre)4 * proxy setting plugin (for Vimperator 0.6pre) 5 5 * 6 6 * @author cho45 7 7 * @author halt feits 8 * @version 0.6 .18 * @version 0.6 9 9 */ 10 10 … … 12 12 13 13 const proxy_settings = [ 14 {15 conf_name: 'disable',16 conf_usage: 'direct connection',17 setting: [18 {19 label: 'type',20 param: 021 }22 ]23 },24 {25 conf_name: 'polipo',26 conf_usage: 'use polipo cache proxy',27 setting: [28 {29 label: 'type',30 param: 131 },32 {33 label: 'http',34 param: 'localhost'35 },36 {37 label: 'http_port',38 param: 812339 }40 ]41 }14 { 15 conf_name: 'disable', 16 conf_usage: 'direct connection', 17 settings: [ 18 { 19 label: 'type', 20 param: 0 21 } 22 ] 23 }, 24 { 25 conf_name: 'polipo', 26 conf_usage: 'use polipo cache proxy', 27 settings: [ 28 { 29 label: 'type', 30 param: 1 31 }, 32 { 33 label: 'http', 34 param: 'localhost' 35 }, 36 { 37 label: 'http_port', 38 param: 8123 39 } 40 ] 41 } 42 42 ]; 43 43 44 liberator.commands.addUserCommand(["proxy"], ' proxy settings',45 function (args) {46 const prefs = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefService);44 liberator.commands.addUserCommand(["proxy"], 'Proxy settings', function (args) { 45 const prefs = Components.classes["@mozilla.org/preferences-service;1"] 46 .getService(Components.interfaces.nsIPrefService); 47 47 var name = args; 48 48 if (!name) { 49 49 liberator.echo("Usage: proxy {setting name}"); 50 50 } 51 for (var i = 0; i < proxy_settings.length; i++) { 52 var proxy_setting = proxy_settings[i]; 53 if (proxy_setting.conf_name.toLowerCase() == name.toLowerCase()) { 51 proxy_settings.some(function (proxy_setting) { 52 if (proxy_setting.conf_name.toLowerCase() != name.toLowerCase()) { 53 return false; 54 } 54 55 55 //delete setting 56 ['http', 'ssl', 'ftp', 'gopher'].forEach( 57 function (p) { 58 prefs.setCharPref("network.proxy." + p, ''); 59 prefs.setIntPref("network.proxy." + p + "_port", 0); 60 } 61 ); 56 //delete setting 57 ['http', 'ssl', 'ftp', 'gopher'].forEach(function (scheme_name) { 58 prefs.setCharPref("network.proxy." + scheme_name, ''); 59 prefs.setIntPref("network.proxy." + scheme_name + "_port", 0); 60 }); 62 61 63 for (var j = 0; j < proxy_setting.setting.length; j++) { 64 var conf = proxy_setting.setting[j]; 65 liberator.options.setPref('network.proxy.' + conf.label, conf.param); 66 } 62 proxy_setting.settings.forEach(function (conf) { 63 liberator.options.setPref('network.proxy.' + conf.label, conf.param); 64 }); 67 65 68 liberator.echo("set config:" + name); 69 break; 70 } 71 } 66 liberator.echo("Set config: " + name); 67 return true; 68 }); 72 69 }, 73 70 { 74 71 completer: function (filter) { 75 72 var completions = []; 73 var exp = new RegExp("^" + filter); 76 74 77 for (var i = 0; i < proxy_settings.length; i++) { 78 var name = proxy_settings[i].conf_name; 79 var usage = proxy_settings[i].conf_usage; 80 81 var exp = new RegExp("^" + filter); 82 75 for each (let { conf_name: name, conf_usage: usage } in proxy_settings) { 83 76 if (exp.test(name)) { 84 77 completions.push([name, usage]); … … 88 81 return [0, completions]; 89 82 } 90 } 91 ); 83 }); 92 84 93 85 })();
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)