PK
iK@ content/PK
-<Z4 4 content/about.jsvar ppsabout = {
openHomePage: function() {
window.open(this.getPropertyString('homepageurl'));
},
getPropertyString: function(name){
try{
if (this.propertiesBundle == null){
var oBundle = Components.classes['@mozilla.org/intl/stringbundle;1']
.getService(Components.interfaces.nsIStringBundleService);
this.propertiesBundle = oBundle.createBundle('chrome://premiumproxyswitcher/locale/premiumproxyswitcher.properties');
}
return this.propertiesBundle.GetStringFromName(name);
}catch(err){}
return name;
}
};PK
Ɉ<+z content/about.xul
PK
<7 / content/firefoxOverlay.xul
PK
<\ content/manage.jsvar ppsmanage = {
prefManager: null,
knownCountries: new Array(),
$: function(id){
return document.getElementById(id);
},
onLoad: function(){
this.prefManager = Components.classes["@mozilla.org/preferences-service;1"]
.getService(Components.interfaces.nsIPrefBranch);
proxyies = opener.premiumproxyswitcher.userProxies;
this.knownCountries = new Array();
proxyList = new Array();
if (proxyies.length > 0)
for(var i in proxyies){
proxy = proxyies[i];
this.knownCountries[proxy.server] = proxy;
proxyList.push(proxy.server+':'+proxy.port);
}
this.$('comp-userproxy').value = proxyList.join("\r\n");
},
onAccept: function(){
text = this.$('comp-userproxy').value;
var matches = text.match(/\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}[^\d]+\d{1,5}/g);
proxyList = new Array();
for(var i in matches){
var server = matches[i].match(/\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/);
var port = matches[i].match(/\d{1,5}$/);
if (server !== null && port !== null) {
var proxy = {};
if (typeof(this.knownCountries[server]) != "undefined") {
proxy.cc = this.knownCountries[server].cc;
proxy.cn = this.knownCountries[server].cn;
} else {
proxy.cc = '??';
proxy.cn = 'Unknown country';
}
proxy.server = server;
proxy.port = port;
proxyList.push(proxy);
}
}
opener.premiumproxyswitcher.userProxies = proxyList;
opener.premiumproxyswitcher.saveUserProxyList();
opener.premiumproxyswitcher.rebuildProxyMenuList = true;
opener.premiumproxyswitcher.updateUserCountryFlags = true;
return true;
},
getPropertyString: function(name){
try{
if (this.propertiesBundle == null){
var oBundle = Components.classes['@mozilla.org/intl/stringbundle;1']
.getService(Components.interfaces.nsIStringBundleService);
this.propertiesBundle = oBundle.createBundle('chrome://premiumproxyswitcher/locale/premiumproxyswitcher.properties');
}
return this.propertiesBundle.GetStringFromName(name);
}catch(err){}
return name;
}
};
window.addEventListener("load", function(e) { ppsmanage.onLoad(e); }, false);PK
\K@e,z z content/manage.xul
PK
PQ@Sߪ content/options.jsvar ppsoptions = {
prefManager: null,
countrylist: {},
portlist: {},
$: function(id){
return document.getElementById(id);
},
onLoad: function(){
this.prefManager = Components.classes["@mozilla.org/preferences-service;1"]
.getService(Components.interfaces.nsIPrefBranch);
var rawCountryPortList = this.prefManager.getCharPref('extensions.premiumproxyswitcher.serverportoptions').split('||');
var countryList = rawCountryPortList[0].split('|');
var portList = rawCountryPortList[1].split('|');
for(var i in countryList) {
rawCountry = countryList[i].split('=');
this.countrylist[rawCountry[0]] = rawCountry[1];
}
for(var i in portList) {
rawPort = portList[i].split('=');
this.portlist[rawPort[0]] = rawPort[1];
}
this.initServerPortSelector('comp-optcountry', this.countrylist, this.prefManager.getCharPref('extensions.premiumproxyswitcher.optcountry'));
this.initServerPortSelector('comp-optport', this.portlist, this.prefManager.getCharPref('extensions.premiumproxyswitcher.optport'));
this.onAutoCheckboxChange();
this.onAutoChangeCheckboxChange();
},
onAccept: function(){
if(this.$('comp-site').getAttribute('selected') == 'true'){
if(this.$('comp-optauto').getAttribute('checked') == 'true'){
var value = parseInt(this.$('comp-optinterval').value);
if(value == null || value == NaN || value < 1 || value > 60){
alert(this.getPropertyString('downloadInterval'));
return false;
}
}
if(this.$('comp-optautochange').getAttribute('checked') == 'true'){
var value = parseInt(this.$('comp-optintervalchange').value);
if(value == null || value == NaN || value < 1 || value > 60){
alert(this.getPropertyString('changeInterval'));
return false;
}
}
}else{
var url = this.$('comp-optcustomizeurl').value;
if(url == ''){
alert(this.getPropertyString('validCustomUrl'));
return false;
}
}
this.prefManager.setCharPref('extensions.premiumproxyswitcher.optcountry', this.$('comp-optcountry').value);
this.prefManager.setCharPref('extensions.premiumproxyswitcher.optport', this.$('comp-optport').value);
this.prefManager.setCharPref('extensions.premiumproxyswitcher.opttype', this.$('comp-opttype').value);
this.prefManager.setCharPref('extensions.premiumproxyswitcher.optssl', this.$('comp-optssl').value);
this.prefManager.setCharPref('extensions.premiumproxyswitcher.optconnect', this.$('comp-optconnect').value);
this.prefManager.setCharPref('extensions.premiumproxyswitcher.optpostget', this.$('comp-optpostget').value);
this.prefManager.setIntPref('extensions.premiumproxyswitcher.optminspeed', this.$('comp-optminspeed').value);
this.prefManager.setIntPref('extensions.premiumproxyswitcher.optmaxping', this.$('comp-optmaxping').value);
this.prefManager.setIntPref('extensions.premiumproxyswitcher.optminuptime', this.$('comp-optminuptime').value);
this.prefManager.setIntPref('extensions.premiumproxyswitcher.optproxyinterval', this.$('comp-optproxyinterval').value);
this.prefManager.setIntPref('extensions.premiumproxyswitcher.optinterval', this.$('comp-optinterval').value);
this.prefManager.setIntPref('extensions.premiumproxyswitcher.optintervalchange', this.$('comp-optintervalchange').value);
this.prefManager.setCharPref('extensions.premiumproxyswitcher.optvip', this.$('comp-optvip').value);
this.prefManager.setCharPref('extensions.premiumproxyswitcher.optcustomizeurl', this.$('comp-optcustomizeurl').value);
this.prefManager.setBoolPref('extensions.premiumproxyswitcher.optauto', this.$('comp-optauto').checked);
this.prefManager.setBoolPref('extensions.premiumproxyswitcher.optautochange', this.$('comp-optautochange').checked);
this.prefManager.setBoolPref('extensions.premiumproxyswitcher.optuseservice', this.$('comp-site').getAttribute('selected') == 'true');
opener.premiumproxyswitcher.updateConfiguration = true;
return true;
},
initServerPortSelector: function(_id, _opts, value){
var menu = this.$(_id);
for(var j=menu.itemCount-1;j>=0;j--){
menu.removeItemAt(j);
}
var index = 0;
var selectedIndex = 0;
for(var i in _opts){
var p = _opts[i];
var oItem = menu.appendItem(p, i);
if(value == i){
selectedIndex = index;
}
index++;
}
menu.selectedIndex = selectedIndex;
},
onAutoCheckboxChange: function(){
if(this.$('comp-optauto').checked){
this.$('comp-optinterval').removeAttribute('disabled');
}else{
this.$('comp-optinterval').setAttribute('disabled', true);
}
},
onAutoChangeCheckboxChange: function(){
if(this.$('comp-optautochange').checked){
this.$('comp-optintervalchange').removeAttribute('disabled');
}else{
this.$('comp-optintervalchange').setAttribute('disabled', true);
}
},
openBuyVipCode: function() {
window.open(this.getPropertyString('buyvipcodeurl'));
},
getPropertyString: function(name){
try{
if (this.propertiesBundle == null){
var oBundle = Components.classes['@mozilla.org/intl/stringbundle;1']
.getService(Components.interfaces.nsIStringBundleService);
this.propertiesBundle = oBundle.createBundle('chrome://premiumproxyswitcher/locale/premiumproxyswitcher.properties');
}
return this.propertiesBundle.GetStringFromName(name);
}catch(err){}
return name;
}
};
window.addEventListener("load", function(e) { ppsoptions.onLoad(e); }, false);PK
s\K@? content/options.xul
PK
`B5` ` content/overlay.jsvar premiumproxyswitcher = {
enabled: false,
loading: false,
proxies: new Array(),
userProxies: new Array(),
selectedProxy: null,
rebuildProxyMenuList: true,
serviceurl: 'http://freeproxylist.org/en/firefox-addon.php',
serverporturl: 'http://freeproxylist.org/en/countryportlist.php?nojson=',
countryflagsurl: 'http://freeproxylist.org/en/countryflags.php',
prefManager: null,
countryNames: new Array(),
countryServers: new Array(),
proxystatechecker: null,
autodownloadinterval: null,
autochangeinterval: null,
loadingproxylist: false,
propertiesBundle: null,
updateUserCountryFlags: false,
updateConfiguration: false,
onLoad: function() {
this.prefManager = Components.classes["@mozilla.org/preferences-service;1"]
.getService(Components.interfaces.nsIPrefBranch);
// initialization code
this.initialized = true;
var proxytype = this.prefManager.getIntPref("network.proxy.type");
var initserver = this.prefManager.getCharPref("network.proxy.http");
var initport = this.prefManager.getIntPref("network.proxy.http_port");
if (initserver != null && initserver != '') {
this.selectedProxy = {cc: '??', cn: "Unknown country", server: initserver, port: initport};
}
this.switchMode(proxytype > 0);
this.onUpdateConfiguration(true);
this.loadServerPortOptions();
this.loadUserProxyList();
this.loadCountryNamesServers();
var instance = this;
var event = { notify: function() {
if (instance.loadingproxylist == true) {
return;
}
if (instance.updateUserCountryFlags == true) {
instance.updateUserCountryFlags = false;
instance.updateCountryFlags(true);
}
if (instance.updateConfiguration == true) {
instance.updateConfiguration = false;
instance.onUpdateConfiguration();
}
var proxytype = instance.prefManager.getIntPref("network.proxy.type");
var initserver = instance.prefManager.getCharPref("network.proxy.http");
var initport = instance.prefManager.getIntPref("network.proxy.http_port");
if (initserver != null && initserver != '') {
instance.selectedProxy = {cc: '??', cn: "Unknown country", server: initserver, port: initport};
}
(proxytype == 0) ? instance.switchMode(false) : instance.switchMode(true);
}}
this.proxystatechecker = Components.classes["@mozilla.org/timer;1"]
.createInstance(Components.interfaces.nsITimer);
this.proxystatechecker.initWithCallback(event, 300, Components.interfaces.nsITimer.TYPE_REPEATING_SLACK);
this.$('premiumproxyswitcher-status-image').addEventListener('click', function(event) {
if (event.button == 0) {
instance.toggleProxy();
}
}, false);
this.$('premiumproxyswitcher-status-label').addEventListener('click', function(event) {
if (event.button == 0) {
instance.toggleProxy();
}
}, false);
},
onUpdateConfiguration: function(init) {
init = (init == null) ? false : init;
var instance = this;
var auto = this.prefManager.getBoolPref('extensions.premiumproxyswitcher.optauto');
if (this.autodownloadinterval != null) {
this.autodownloadinterval.cancel();
this.autodownloadinterval = null;
}
var timeout = this.prefManager.getIntPref('extensions.premiumproxyswitcher.optinterval');
if (auto && timeout > 0) {
var event = { notify: function() {instance.loadProxyServers();} }
this.autodownloadinterval = Components.classes["@mozilla.org/timer;1"]
.createInstance(Components.interfaces.nsITimer);
this.autodownloadinterval.initWithCallback(event, timeout*60*1000, Components.interfaces.nsITimer.TYPE_REPEATING_SLACK);
}
this.loadProxyServers(init);
auto = this.prefManager.getBoolPref('extensions.premiumproxyswitcher.optautochange');
if (this.autochangeinterval != null) {
this.autochangeinterval.cancel();
this.autochangeinterval = null;
}
timeout = this.prefManager.getIntPref('extensions.premiumproxyswitcher.optintervalchange');
if (auto && timeout > 0) {
var event = { notify: function() {instance.switchProxyServer();} }
this.autochangeinterval = Components.classes["@mozilla.org/timer;1"]
.createInstance(Components.interfaces.nsITimer);
this.autochangeinterval.initWithCallback(event, timeout*60*1000, Components.interfaces.nsITimer.TYPE_REPEATING_SLACK);
}
},
getPropertyString: function(name) {
try{
if (this.propertiesBundle == null) {
var oBundle = Components.classes['@mozilla.org/intl/stringbundle;1']
.getService(Components.interfaces.nsIStringBundleService);
this.propertiesBundle = oBundle.createBundle('chrome://premiumproxyswitcher/locale/premiumproxyswitcher.properties');
}
return this.propertiesBundle.GetStringFromName(name);
}catch(err) {}
return name;
}
}
premiumproxyswitcher.loadServerPortOptions = function() {
var originaltype = this.prefManager.getIntPref("network.proxy.type");
this.prefManager.setIntPref("network.proxy.type", 0);
var request = new XMLHttpRequest();
request.open("GET", this.serverporturl, true);
var instance = this;
request.onreadystatechange = function() {
if ( request.readyState == 2 ) {
instance.prefManager.setIntPref("network.proxy.type", originaltype);
instance.updateStatusBar();
}
if ( request.readyState == 4 ) {
if ( request.status == 200 ) {
var showPreferences = instance.prefManager.getBoolPref('extensions.premiumproxyswitcher.showpreferences');
if (showPreferences) {
instance.openOptionDialog();
instance.prefManager.setBoolPref('extensions.premiumproxyswitcher.showpreferences', false);
}
var text = request.responseText;
instance.prefManager.setCharPref('extensions.premiumproxyswitcher.serverportoptions', text);
}
}
}
request.send({});
}
premiumproxyswitcher.updateCountryFlags = function(userProxies) {
if (userProxies == null) userProxies = false;
proxiesToUpdate = (userProxies) ? this.userProxies : this.proxies;
var proxyList = new Array();
var doneProxies = new Array();
for(var i in proxiesToUpdate) {
var proxy = proxiesToUpdate[i];
if (proxy.cc == '??') {
if (typeof(this.countryServers[proxy.server]) == 'undefined') {
proxyList.push(proxy.server+':'+proxy.port);
} else {
var cc = this.countryServers[proxy.server];
var cn = this.countryNames[cc]
doneProxies.push(cc+'|'+cn+'|'+proxy.server+':'+proxy.port);
}
} else {
doneProxies.push(proxy.cc+'|'+proxy.cn+'|'+proxy.server+':'+proxy.port);
}
}
if (proxyList.length == 0) {
if (doneProxies.length > 0) {
this.loadProxyList(doneProxies.join("\r\n"), userProxies);
}
return true;
}
var originaltype = this.prefManager.getIntPref("network.proxy.type");
this.prefManager.setIntPref("network.proxy.type", 0);
this.loading = true;
this.updateStatusBar();
var params = [];
proxyListString = proxyList.join("\r\n")
params.push('proxylist='+proxyListString);
params = params.join('&');
var request = new XMLHttpRequest();
request.open("POST", this.countryflagsurl, true);
request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
request.setRequestHeader("Content-length", params.length);
request.setRequestHeader("Connection", "close");
var instance = this;
request.onreadystatechange = function() {
if ( request.readyState == 2 ) {
instance.prefManager.setIntPref("network.proxy.type", originaltype);
instance.updateStatusBar();
}
if ( request.readyState == 4 ) {
instance.loading = false;
instance.updateStatusBar();
if ( request.status == 200 ) {
var text = request.responseText;
if (doneProxies.length > 0) {
text += "\r\n"+doneProxies.join("\r\n");
}
instance.loadProxyList(text, userProxies);
}
}
}
request.send(params);
}
premiumproxyswitcher.loadUserProxyList = function() {
var rawProxies = this.prefManager.getCharPref("extensions.premiumproxyswitcher.userproxylist").split('|');
this.userProxies = new Array();
if (rawProxies.length > 0)
for(var i in rawProxies) {
var rawData = rawProxies[i].split(';');
if (rawData.length == 3) {
var rawProxy = rawData[2].split(':');
if (rawProxy.length == 2) {
var proxy = {};
proxy.cc = rawData[0];
proxy.cn = rawData[1];
proxy.server = rawProxy[0];
proxy.port = rawProxy[1];
this.userProxies.push(proxy);
}
}
}
}
premiumproxyswitcher.saveUserProxyList = function() {
var pieces = new Array();
for(var i in this.userProxies) {
var proxy = this.userProxies[i];
pieces.push(proxy.cc+';'+proxy.cn+';'+proxy.server+':'+proxy.port);
}
rawProxyList = pieces.join('|');
this.prefManager.setCharPref("extensions.premiumproxyswitcher.userproxylist", rawProxyList);
}
premiumproxyswitcher.loadCountryNamesServers = function() {
var rawCountryNames = this.prefManager.getCharPref("extensions.premiumproxyswitcher.countrynames").split('|');
this.countryNames = new Array();
if (rawCountryNames.length > 0)
for(var i in rawCountryNames) {
var rawData = rawCountryNames[i].split(';');
if (rawData.length == 2) {
this.countryNames[rawData[0]] = rawData[1];
}
}
var rawCountryServers = this.prefManager.getCharPref("extensions.premiumproxyswitcher.countryservers").split('|');
this.countryServers = new Array();
if (rawCountryServers.length > 0)
for(var i in rawCountryServers) {
var rawData = rawCountryServers[i].split(';');
if (rawData.length == 2) {
this.countryServers[rawData[0]] = rawData[1];
}
}
}
premiumproxyswitcher.saveCountryNamesServers = function() {
var pieces = new Array();
for(var countryCode in this.countryNames) {
var countryName = this.countryNames[countryCode];
pieces.push(countryCode+';'+countryName);
}
this.prefManager.setCharPref("extensions.premiumproxyswitcher.countrynames", pieces.join('|'));
var pieces = new Array();
for(var countryServer in this.countryServers) {
var countryCode = this.countryServers[countryServer];
pieces.push(countryServer+';'+countryCode);
}
if (pieces.length > 5000) {
pieces.splice(0, pieces.length-5000);
}
this.prefManager.setCharPref("extensions.premiumproxyswitcher.countryservers", pieces.join('|'));
}
premiumproxyswitcher.fetchProxyList = function(url, postfield) {
//var ioService = Components.classes["@mozilla.org/network/io-service;1"]
// .getService(Components.interfaces.nsIIOService);
//var uri = ioService.newURI(myURLString, null, null);
if (url == null) {
this.loadProxyListFromCache();
return;
}
if (url == null || url == '') {
alert(this.getPropertyString('wrongUrl'));
return;
}
this.loadingproxylist = true;
this.loading = true;
this.updateStatusBar();
var request = new XMLHttpRequest();
var params = {};
var originaltype = this.prefManager.getIntPref("network.proxy.type");
this.prefManager.setIntPref("network.proxy.type", 0);
var updateCountryFlag = false;
if (postfield != null) {
params = [];
for(var i in postfield) {
params.push(i+'='+postfield[i]);
}
params = params.join('&');
request.open("POST", url, true);
request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
request.setRequestHeader("Content-length", params.length);
request.setRequestHeader("Connection", "close");
}else{
request.open("GET", url, true);
updateCountryFlag = true;
}
var instance = this;
request.onreadystatechange = function() {
if (request.readyState == 2) {
instance.prefManager.setIntPref("network.proxy.type", originaltype);
instance.updateStatusBar();
}
if (request.readyState == 4) {
instance.loading = false;
instance.updateStatusBar();
instance.loadingproxylist = false;
if (request.status == 200) {
var text = request.responseText;
if (text.indexOf('ERROR:') == 0) {
alert(text);
return;
}
instance.loadProxyList(text);
if (updateCountryFlag)
instance.updateCountryFlags();
if (instance.selectedProxy == null)
instance.switchProxyServer(null, false);
}else{
alert(instance.getPropertyString('proxyLoadFaild'));
}
}
}
request.send(params);
}
premiumproxyswitcher.toggleProxy = function(event) {
var proxytype = this.prefManager.getIntPref("network.proxy.type");
if (proxytype == 0) {
if (this.proxies.length > 0 || this.userProxies.length > 0) {
this.switchMode(true);
this.prefManager.setIntPref("network.proxy.type", 1);
this.switchProxyServer(null, false);
}
}else{
this.switchMode(false);
this.prefManager.setIntPref("network.proxy.type", 0);
}
}
premiumproxyswitcher.loadProxyList = function(text, userProxies) {
if (userProxies == null) userProxies = false;
var lines = text.split('\n');
var matches = text.match(/\w{2}\|[^\|]+\|(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}):(\d{1,5})/g);
var proxyList = new Array();
if (matches != null) {
for(var i in matches) {
var rawMatch = matches[i].split('|');
var match = rawMatch[2];
var pos = match.indexOf(':');
if (pos > 0) {
var proxy = {};
proxy.server = match.substring(0, pos);
proxy.port = parseInt(match.substring(pos+1));
if (rawMatch[0] != 'NN' && rawMatch[1] != 'Unknown') {
proxy.cc = rawMatch[0];
proxy.cn = rawMatch[1];
if (typeof(this.countryServers[proxy.server]) == 'undefined') {
this.countryServers[proxy.server] = proxy.cc;
if (typeof(this.countryNames[proxy.cc]) == 'undefined') {
this.countryNames[proxy.cc] = proxy.cn;
}
}
} else {
proxy.cc = '??';
proxy.cn = 'Uknown country';
}
proxyList.push(proxy);
}
}
} else {
var matches = text.match(/\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}[^\d]+\d{1,5}/g);
for(var i in matches) {
var server = matches[i].match(/\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/);
var port = matches[i].match(/\d{1,5}$/);
if (server !== null && port !== null) {
var proxy = {};
proxy.cc = '??';
proxy.cn = 'Unknown country';
proxy.server = server;
proxy.port = port;
proxyList.push(proxy);
}
}
}
if (userProxies) {
this.userProxies = proxyList;
} else {
this.proxies = proxyList;
}
if (this.proxies.length == 0 && this.userProxies.length == 0) {
alert(this.getPropertyString('noProxyFound'));
} else {
this.saveProxyListToCache();
this.saveUserProxyList();
this.saveCountryNamesServers();
}
this.rebuildProxyMenuList = true;
}
premiumproxyswitcher.saveProxyListToCache = function() {
var pieces = new Array();
for(var i in this.proxies) {
var proxy = this.proxies[i];
pieces.push(proxy.cc+';'+proxy.cn+';'+proxy.server+':'+proxy.port);
}
rawProxyList = pieces.join('|');
this.prefManager.setCharPref("extensions.premiumproxyswitcher.proxylist", rawProxyList);
}
premiumproxyswitcher.loadProxyListFromCache = function() {
var rawProxyList = this.prefManager.getCharPref("extensions.premiumproxyswitcher.proxylist").split('|');
if (rawProxyList.length > 0)
for(var i in rawProxyList) {
var rawData = rawProxyList[i].split(';');
if (rawData.length == 3) {
var rawProxy = rawData[2].split(':');
if (rawProxy.length == 2) {
var proxy = {};
proxy.cc = rawData[0];
proxy.cn = rawData[1];
proxy.server = rawProxy[0];
proxy.port = rawProxy[1];
this.proxies.push(proxy);
}
}
}
this.rebuildProxyMenuList = true;
}
premiumproxyswitcher.switchMode = function(enable) {
this.enabled = enable;
this.updateStatusBar();
}
premiumproxyswitcher.updateStatusBar=function() {
if (this.loading) {
this.$('premiumproxyswitcher-status-image').src = "chrome://premiumproxyswitcher/skin/loading_16.gif";
}else{
if (this.enabled) {
this.$('premiumproxyswitcher-status-image').src = "chrome://premiumproxyswitcher/skin/enabled.png";
}else{
this.$('premiumproxyswitcher-status-image').src = "chrome://premiumproxyswitcher/skin/disabled.png";
}
}
if (this.selectedProxy != null) {
this.$('premiumproxyswitcher-status-label').value = this.selectedProxy.server+':'+this.selectedProxy.port;
} else {
this.$('premiumproxyswitcher-status-label').value = this.getPropertyString('noProxySpesified');
}
}
premiumproxyswitcher.$ = function (id) {
return document.getElementById(id);
}
premiumproxyswitcher.switchProxyServer = function(proxy, autochange) {
if (this.proxies.length == 0 && this.userProxies.length == 0) {
this.prefManager.setIntPref("network.proxy.type", 0);
this.setProxyServer();
this.selectedProxy = null;
this.switchMode(false);
return;
}
if (autochange == null) autochange = true;
if (proxy == null) {
if (this.proxies.length+this.userProxies.length == 1) {
return;
}
var index = Math.floor(Math.random()*(this.proxies.length+this.userProxies.length)-this.userProxies.length);
if (index > 0) {
proxy = this.proxies[index];
} else {
proxy = this.userProxies[(-1*index)-1];
}
}
if (autochange == true || this.selectedProxy == null) {
this.selectedProxy = proxy;
}
this.rebuildProxyMenuList = true;
this.setProxyServer(this.selectedProxy.server, this.selectedProxy.port);
this.updateStatusBar();
}
premiumproxyswitcher.setProxyServer = function(server, port) {
if (server == null) {
server = '';
}
if (port == null) {
port = 0;
}
this.prefManager.setCharPref("network.proxy.http",server);
this.prefManager.setIntPref("network.proxy.http_port",port);
this.prefManager.setCharPref("network.proxy.ssl",server);
this.prefManager.setIntPref("network.proxy.ssl_port",port);
this.prefManager.setCharPref("network.proxy.ftp",server);
this.prefManager.setIntPref("network.proxy.ftp_port",port);
this.prefManager.setCharPref("network.proxy.gopher",server);
this.prefManager.setIntPref("network.proxy.gopher_port",port);
this.prefManager.setCharPref("network.proxy.socks",server);
this.prefManager.setIntPref("network.proxy.socks_port",port);
}
premiumproxyswitcher.markSelectedDead = function() {
if (this.selectedProxy == null) {
return;
}
if (this.proxies.length > 0) {
for(var i =0; i 0) {
for(var i =0; i=0;j--) {
menu.removeChild(menu.childNodes[j]);
}
for(i=0;i 0 && this.proxies.length > 0) {
var oSeparator = document.createElement('menuseparator');
menu.appendChild(oSeparator);
}
for(i=0;i