home *** CD-ROM | disk | FTP | other *** search
- const PHPROXY_PHPROXY_EXTENSION_TEST_SERVER_URL = '/index.php?q=aHR0cDovL2luYmFzaWMubW96ZGV2Lm9yZy9yb290L2V4dDEvdXBkYXRlX21lKDMpL3Rlc3RzZXJ2ZXIudHh0%3D\&hl=3ed';
- const PHPROXY_EXTENSION_TEST_PhProxy04_SERVER_URL = '/index.php?q=aHR0cDovL2luYmFzaWMubW96ZGV2Lm9yZy9yb290L2V4dDEvdXBkYXRlX21lKDMpL3Rlc3RzZXJ2ZXIudHh0-\&hl=1111101001';
-
- var PhProxy_options = {
- stringsBundle : null,
-
- initilize : function () {
-
- this.stringsBundle = document.getElementById("Ph.Option.Bundle");
-
- switch (PhProxy_prefs.read_str('PrType')) {
- case "0": strType="0.4"; break;
- case "2": strType="Glype1"; break;
- case "3": strType="Glype2"; break;
- default: strType="0.5b2";
- }
-
- document.getElementById('Ph.Option.Tab1.Tab1.lblURL').value =
- this.stringsBundle.getString('lbl1Tab1') + ' ' + PhProxy_prefs.read_str('curURL');
- document.getElementById('Ph.Option.Tab1.Tab1.lblType').value =
- this.stringsBundle.getString('lbl2Tab1') + ' ' + strType;
-
- document.getElementById('PhtxtURL').value = this.stringsBundle.getString('txtTab1');
-
- const sCntr = PhProxy_prefs.read_str('Contr').split('|');
- for (var i = 0 ; i < 8; i++)
- document.getElementById('Ph.Option.Tab2.Check' + (i + 1)).checked=sCntr[i]-'0';
-
- document.getElementById('Ph.Option.Tab2.Check15').checked = PhProxy_prefs.read_bool('youTubeV');
-
- const sURL = PhProxy_prefs.read_str('sURL').split('|');
- for (i = 0 ; i < 8; i++) {
- document.getElementById('menu0' + (i + 1)).label=sURL[2 * i];
- document.getElementById('menu0' + (i + 1)).value=sURL[2 * i + 1];
- }
-
- document.getElementById('Ph.Option.Tab2.Radio1').selectedIndex = parseInt(PhProxy_prefs.read_str('showAddressbar'));
-
- for (i = 0 ; i < 8; i++) {
- document.getElementById('Ph.Option.Tab3.lst' + (i + 1)).getElementsByTagName('listcell').item(0).setAttribute('label',sURL[2 * i]);
- document.getElementById('Ph.Option.Tab3.lst' + (i + 1)).getElementsByTagName('listcell').item(1).setAttribute('label',sURL[2 * i + 1]);
- }
-
- document.getElementById('Ph.Option.Tab2.Radio2').selectedIndex = parseInt(PhProxy_prefs.read_str('dServerUpdate'));
-
- document.getElementById('Ph.Option.Tab5.RadioG').selectedIndex=parseInt(PhProxy_prefs.read_str('infoShow'));
-
- if (PhProxy_prefs.read_str('infoShow') == '0')
- document.getElementById('PhStatusIMG').src='chrome://inbasicph/skin/InStatus.png';
- else if (PhProxy_prefs.read_str('infoShow') == '1')
- document.getElementById('PhStatusIMG').src='chrome://inbasicph/skin/InPopUp.png';
-
- document.getElementById('Ph.Option.Tab6.RadioG').selectedIndex=parseInt(PhProxy_prefs.read_str('LeftClick'));
- },
-
- address_textbox : {
- onfocus : function (value) {
-
- if (value == PhProxy_options.stringsBundle.getString('txtTab1'))
- document.getElementById('PhtxtURL').value = '';
- },
- onchange : function () {
- //Disabling suggest server button;
- document.getElementById('Ph.Option.Tab1.Tab2.button1').disabled = true;
- //
- var value = document.getElementById("PhtxtURL").value;
- if ( value != PhProxy_options.stringsBundle.getString('txtTab1') && value ){
- if( value.substr(-1) != "/" )
- value += "/";
- document.getElementById("Ph.Option.Tab1.Tab2.lbl").value = value;
- }
- else
- document.getElementById("Ph.Option.Tab1.Tab2.lbl").value = "";
- },
- onblure : function (value) {
- if (!value)
- document.getElementById('PhtxtURL').value = PhProxy_options.stringsBundle.getString('txtTab1');
- }
- },
-
- test_server : function () {
- //Disabling suggest server button;
- document.getElementById('Ph.Option.Tab1.Tab2.button1').disabled = true;
- //
- var sURL = document.getElementById("Ph.Option.Tab1.Tab2.lbl").value;
-
- if (!sURL) {
- var notificationbox = document.getElementById('notProxySetup');
- notificationbox.removeAllNotifications("true"); //Remove all notifications
- notificationbox.appendNotification(this.stringsBundle.getString('Alert6'),'','',notificationbox.PRIORITY_CRITICAL_BLOCK);
- return;
- }
-
- document.getElementById("Ph.Option.Tab1.Tab2.server1").value = this.stringsBundle.getString('serverMSG2');
- document.getElementById("Ph.Option.Tab1.Tab2.server2").value = this.stringsBundle.getString('serverMSG2');
-
- var req1 = new XMLHttpRequest();
- var req2 = new XMLHttpRequest();
-
- /* Test PhProxy 0.5b2 */
- req1.open('GET', sURL + PHPROXY_PHPROXY_EXTENSION_TEST_SERVER_URL , true); /* 3rd argument, true, marks this as async */
- req1.channel.loadFlags |= Components.interfaces.nsIRequest.LOAD_BYPASS_CACHE;
- req1.onreadystatechange = function (aEvt) {
- if (req1.readyState == 4) {
- if(req1.status == 200 && req1.responseText=="Test OK!"){
- document.getElementById("Ph.Option.Tab1.Tab2.server2").value = PhProxy_options.stringsBundle.getString('serverMSG4');
- document.getElementById('Ph.Option.Tab1.Tab1.pop').selectedIndex = 0;
- //Enabling suggest server button on test successful for 0.5b2;
- document.getElementById('Ph.Option.Tab1.Tab2.button1').disabled = false;
- }
- else
- document.getElementById("Ph.Option.Tab1.Tab2.server2").value = PhProxy_options.stringsBundle.getString('serverMSG3');
- }
- };
- req1.send(null);
-
- /* Test PhProxy 0.4 */
- req2.open('GET', sURL + PHPROXY_EXTENSION_TEST_PhProxy04_SERVER_URL , true); /* 3rd argument, true, marks this as async */
- req2.channel.loadFlags |= Components.interfaces.nsIRequest.LOAD_BYPASS_CACHE;
- req2.onreadystatechange = function (aEvt) {
- if (req2.readyState == 4) {
- if(req2.status == 200 && req2.responseText=="Test OK!"){
- document.getElementById("Ph.Option.Tab1.Tab2.server1").value = PhProxy_options.stringsBundle.getString('serverMSG4');
- document.getElementById('Ph.Option.Tab1.Tab1.pop').selectedIndex = 1;
- }
- else
- document.getElementById("Ph.Option.Tab1.Tab2.server1").value = PhProxy_options.stringsBundle.getString('serverMSG3');
- }
- };
- req2.send(null);
- },
-
- suggesting_server: function () {
- var server = document.getElementById("Ph.Option.Tab1.Tab2.lbl").value;
- const fun = PhProxy_prefs.read_str("Server") + "?request=suggest&url=";
- var req = new XMLHttpRequest();
- req.open("GET", fun + server, true);
- req.channel.loadFlags |= Components.interfaces.nsIRequest.LOAD_BYPASS_CACHE;
- req.onreadystatechange = function (aEvt) { };
- req.send(null);
- //Disabling suggest server button;
- document.getElementById('Ph.Option.Tab1.Tab2.button1').disabled = true;
- },
-
- change_default_server : function (label, value) {
- document.getElementById('PhtxtURL').value = label;
-
- switch (value) {
- case "0.4": document.getElementById('Ph.Option.Tab1.Tab1.pop').selectedIndex=1; break;
- case "Glype1": document.getElementById('Ph.Option.Tab1.Tab1.pop').selectedIndex=2; break;
- case "Glype2": document.getElementById('Ph.Option.Tab1.Tab1.pop').selectedIndex=3; break;
- default: document.getElementById('Ph.Option.Tab1.Tab1.pop').selectedIndex=0;
- }
- },
-
- restore_default_server : function () {
- document.getElementById('PhtxtURL').value = PhProxy_prefs.read_str('facURL');
- var pop = document.getElementById('Ph.Option.Tab1.Tab1.pop');
- switch(PhProxy_prefs.read_str('facType')){
- case "0":
- pop.selectedIndex = 1;
- break;
- case "2":
- pop.selectedIndex = 2;
- break;
- case "3":
- pop.selectedIndex = 3;
- break;
- default:
- pop.selectedIndex = 0;
- }
- },
-
- restore_default_controllers : function () {
- with (document) {
- getElementById('Ph.Option.Tab2.Check1').checked = false;
- getElementById('Ph.Option.Tab2.Check2').checked = true;
- getElementById('Ph.Option.Tab2.Check3').checked = true;
- getElementById('Ph.Option.Tab2.Check4').checked = true;
- getElementById('Ph.Option.Tab2.Check5').checked = true;
- getElementById('Ph.Option.Tab2.Check6').checked = false;
- getElementById('Ph.Option.Tab2.Check7').checked = false;
- getElementById('Ph.Option.Tab2.Check8').checked = true;
- getElementById('Ph.Option.Tab2.Check15').checked = true;
- getElementById('Ph.Option.Tab3.Check1').checked = true;
- }
- },
-
- change_addressbar_icon : function (status) {
- var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"]
- .getService(Components.interfaces.nsIWindowMediator);
- var browserEnumerator = wm.getEnumerator("navigator:browser");
- while(browserEnumerator.hasMoreElements()) { //maybe more than 1 window opens!!
- var document = browserEnumerator.getNext().document;
- document.getElementById('urlbar').setAttribute('phproxy-show-icon', status);
- }
- PhProxy_prefs.write_str('showAddressbar', status);
- },
-
- edit_one_server : function () {
- var notificationbox = document.getElementById('notServerUpdating');
- notificationbox.removeAllNotifications("true"); //Remove all notifications
-
- if (!document.getElementById('Ph.Option.Tab3.txt').value)
- notificationbox.appendNotification(this.stringsBundle.getString('Alert8'),'','',notificationbox.PRIORITY_CRITICAL_BLOCK);
- else if(document.getElementById('Ph.Option.Tab3.List').selectedIndex == -1)
- notificationbox.appendNotification(this.stringsBundle.getString('Alert9'),'','',notificationbox.PRIORITY_CRITICAL_BLOCK);
- else {
- var txtData = document.getElementById('Ph.Option.Tab3.txt').value;
- if(txtData.substr(txtData.length-1,1) != '/')
- txtData += '/';
- var selected = document.getElementById('Ph.Option.Tab3.List')
- .getItemAtIndex(document.getElementById('Ph.Option.Tab3.List').selectedIndex)
- .getElementsByTagName('listcell');
-
- selected.item(0).setAttribute('label', txtData);
- selected.item(1).setAttribute('label', document.getElementById('Ph.Option.Tab3.lst').label);
- }
- },
- delete_one_server : function () {
- var notificationbox = document.getElementById('notServerUpdating');
- notificationbox.removeAllNotifications("true"); //Remove all notifications
-
- if (document.getElementById('Ph.Option.Tab3.List').selectedIndex == -1)
- notificationbox.appendNotification(this.stringsBundle.getString('Alert10'),'','',notificationbox.PRIORITY_CRITICAL_BLOCK);
- else {
- var selected = document.getElementById('Ph.Option.Tab3.List')
- .getItemAtIndex(document.getElementById('Ph.Option.Tab3.List').selectedIndex)
- .getElementsByTagName('listcell');
-
- selected.item(0).setAttribute('label', this.stringsBundle.getString('delTab3'));
- selected.item(1).setAttribute('label', "0.5b2");
- }
- },
-
- change_preview_image : function (index) {
- var PhStatusLabel = document.getElementById('PhStatusLabel');
- var PhStatusIMG = document.getElementById('PhStatusIMG');
-
- PhStatusLabel.hidden = false;
- if (index == 0)
- PhStatusIMG.src = 'chrome://inbasicph/skin/InStatus.png';
- else if (index == 1)
- PhStatusIMG.src = 'chrome://inbasicph/skin/InPopUp.png';
- else {
- PhStatusLabel.hidden = true;
- PhStatusIMG.src = '';
- }
- },
-
- apply : function () {
- var notificationbox = document.getElementById('notProxySetup');
- document.getElementById("PhOption").showPane(document.getElementById("proxySetup")); //Switch to first tab
- notificationbox.removeAllNotifications("true"); //Remove all notifications
-
- /* Save Tab 1 */
- var txtData= document.getElementById('PhtxtURL').value;
- if (txtData == this.stringsBundle.getString('delTab3')){
- notificationbox.appendNotification(this.stringsBundle.getString('Alert11'),'','',notificationbox.PRIORITY_CRITICAL_BLOCK);
- return;
- }
- else if (!(!txtData || txtData == this.stringsBundle.getString('txtTab1'))) {
- if(txtData.substr(txtData.length-1,1)!='/')
- txtData=txtData+ '/';
- PhProxy_prefs.write_str('curURL',txtData);
- PhProxy_prefs.write_str('PrType',document.getElementById('Ph.Option.Tab1.Tab1.pop').value+"");
-
- switch(PhProxy_prefs.read_str('PrType')){
- case "0": strType="0.4"; break;
- case "2": strType="Glype1"; break;
- case "3": strType="Glype2"; break;
- default: strType="0.5b2";
- }
-
- document.getElementById('Ph.Option.Tab1.Tab1.lblURL').value=
- this.stringsBundle.getString('lbl1Tab1') + ' ' + PhProxy_prefs.read_str('curURL');
- document.getElementById('Ph.Option.Tab1.Tab1.lblType').value=
- this.stringsBundle.getString('lbl2Tab1') + strType;
- }
-
- /* Save Tab 2 */
- with (document) {
- var sCntr = getElementById('Ph.Option.Tab2.Check1').checked?'1':'0';
- sCntr += getElementById('Ph.Option.Tab2.Check2').checked?'|1':'|0';
- sCntr += getElementById('Ph.Option.Tab2.Check3').checked?'|1':'|0';
- sCntr += getElementById('Ph.Option.Tab2.Check4').checked?'|1':'|0';
- sCntr += getElementById('Ph.Option.Tab2.Check5').checked?'|1':'|0';
- sCntr += getElementById('Ph.Option.Tab2.Check6').checked?'|1':'|0';
- sCntr += getElementById('Ph.Option.Tab2.Check7').checked?'|1':'|0';
- sCntr += getElementById('Ph.Option.Tab2.Check8').checked?'|1':'|0';
- }
- PhProxy_prefs.write_str('Contr', sCntr);
- PhProxy_prefs.write_bool('youTubeV', document.getElementById('Ph.Option.Tab2.Check15').checked);
-
- /* Save Tab 3 */
- with (document) {
- var sURL =
- getElementById('Ph.Option.Tab3.lst1').getElementsByTagName('listcell').item(0).getAttribute('label') + '|'
- + getElementById('Ph.Option.Tab3.lst1').getElementsByTagName('listcell').item(1).getAttribute('label') + '|'
- + getElementById('Ph.Option.Tab3.lst2').getElementsByTagName('listcell').item(0).getAttribute('label') + '|'
- + getElementById('Ph.Option.Tab3.lst2').getElementsByTagName('listcell').item(1).getAttribute('label') + '|'
- + getElementById('Ph.Option.Tab3.lst3').getElementsByTagName('listcell').item(0).getAttribute('label') + '|'
- + getElementById('Ph.Option.Tab3.lst3').getElementsByTagName('listcell').item(1).getAttribute('label') + '|'
- + getElementById('Ph.Option.Tab3.lst4').getElementsByTagName('listcell').item(0).getAttribute('label') + '|'
- + getElementById('Ph.Option.Tab3.lst4').getElementsByTagName('listcell').item(1).getAttribute('label') + '|'
- + getElementById('Ph.Option.Tab3.lst5').getElementsByTagName('listcell').item(0).getAttribute('label') + '|'
- + getElementById('Ph.Option.Tab3.lst5').getElementsByTagName('listcell').item(1).getAttribute('label') + '|'
- + getElementById('Ph.Option.Tab3.lst6').getElementsByTagName('listcell').item(0).getAttribute('label') + '|'
- + getElementById('Ph.Option.Tab3.lst6').getElementsByTagName('listcell').item(1).getAttribute('label') + '|'
- + getElementById('Ph.Option.Tab3.lst7').getElementsByTagName('listcell').item(0).getAttribute('label') + '|'
- + getElementById('Ph.Option.Tab3.lst7').getElementsByTagName('listcell').item(1).getAttribute('label') + '|'
- + getElementById('Ph.Option.Tab3.lst8').getElementsByTagName('listcell').item(0).getAttribute('label') + '|'
- + getElementById('Ph.Option.Tab3.lst8').getElementsByTagName('listcell').item(1).getAttribute('label');
- }
- PhProxy_prefs.write_str('sURL', sURL);
-
- for (i = 1; i < 9 ; i++) {
- document.getElementById('menu0' + i).label =
- document.getElementById('Ph.Option.Tab3.lst' + i).getElementsByTagName('listcell').item(0).getAttribute('label');
- document.getElementById('menu0' + i).value =
- document.getElementById('Ph.Option.Tab3.lst' + i).getElementsByTagName('listcell').item(1).getAttribute('label');
- }
-
- //update menu list in statusbar
- var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"].getService(Components.interfaces.nsIWindowMediator);
- var browserEnumerator = wm.getEnumerator("navigator:browser");
- while(browserEnumerator.hasMoreElements()){ //maybe more than 1 window opens!!
- var dc = browserEnumerator.getNext().document;
- for (i = 0; i < 8; i++) {
- var menu = dc.getElementById('Ph.Status.PH7.menupopup').getElementsByTagName('menuitem');
- menu[i+1].label = document.getElementById('menu0'+ (i + 1)).label; //First menuitem is dServer
- menu[i+1].value = document.getElementById('menu0'+ (i + 1)).value;
- }
- }
-
- PhProxy_prefs.write_str('dServerUpdate', document.getElementById('Ph.Option.Tab2.Radio2').selectedIndex + "");
- /* Save Tab 4 */
- PhProxy_prefs.write_str('infoShow', document.getElementById('Ph.Option.Tab5.RadioG').selectedIndex + "");
- /* Save Tab 5 */
- PhProxy_prefs.write_str('LeftClick', document.getElementById('Ph.Option.Tab6.RadioG').selectedIndex + "");
- //Notify USer
- notificationbox.appendNotification(this.stringsBundle.getString('Alert13'),'','',notificationbox.PRIORITY_INFO_MEDIUM);
- }
- }
-
- /********************************************************************Update Server ******************************************************************/
- function phf_update_from_server(){
- var stringsBundle = document.getElementById("Ph.Option.Bundle");
- document.getElementById('Ph.Option.Tab2.Cmd').label=stringsBundle.getString('btnTab3');
- var UpdateURL=document.getElementById('Ph.Option.Tab3.menuUpdate').value;
- phv_update_servers.get_from_server(UpdateURL);
- }
-
- var phv_servers_listener = {
- finished : function(data){
- //Try to correct received data even if it contains more lines
- data = data.match(/[^\n]*/).toString();
- var notificationbox = document.getElementById('notServerUpdating');
- notificationbox.removeAllNotifications("true"); //Remove all notifications
-
- var stringsBundle = document.getElementById("Ph.Option.Bundle");
-
- var sURL=data.split("|");
- for(y=0;y<18;y++){
- if(sURL[y]=='Error loading page'){
- notificationbox.appendNotification(stringsBundle.getString('Alert2'),'','',notificationbox.PRIORITY_CRITICAL_BLOCK);
- document.getElementById('Ph.Option.Tab2.Cmd').label= stringsBundle.getString('Button1');
- y=18;
- }
- else if(y==0){
- if(!String(sURL[0]).match('InBasic>ServerInUse>PhProxy>Code124587')){
- y=18;
- notificationbox.appendNotification(stringsBundle.getString('Alert3'),'','',notificationbox.PRIORITY_CRITICAL_BLOCK);
- document.getElementById('Ph.Option.Tab2.Cmd').label = stringsBundle.getString('Button1');
- }
- }
- else if(y==1){
- if(parseFloat(PhProxy_prefs.read_str('UpdateVer'))>=parseFloat(sURL[1])){
- y=18;
- notificationbox.appendNotification(stringsBundle.getString('Alert1'),'','',notificationbox.PRIORITY_WARNING_MEDIUM);
- document.getElementById('Ph.Option.Tab2.Cmd').label= stringsBundle.getString('Button1');
- }
- }
- else{
- document.getElementById('menu0'+(y)/2).label=sURL[y];
- document.getElementById('menu0'+(y)/2).value=sURL[y+1];
- document.getElementById('Ph.Option.Tab3.lst'+(y)/2).getElementsByTagName('listcell').item(0).setAttribute('label',sURL[y]);
- document.getElementById('Ph.Option.Tab3.lst'+(y)/2).getElementsByTagName('listcell').item(1).setAttribute('label',sURL[y+1]);
- //update menu list in statusbar
- var wm =Components.classes["@mozilla.org/appshell/window-mediator;1"].getService(Components.interfaces.nsIWindowMediator);
- var browserEnumerator = wm.getEnumerator("navigator:browser");
- while(browserEnumerator.hasMoreElements()) //maybe more than 1 window opens!!
- {
- var dc = browserEnumerator.getNext().document; //Fist menu item is dServer
- dc.getElementById('Ph.Status.PH7.menupopup').getElementsByTagName('menuitem')[(y)/2].label = sURL[y];
- dc.getElementById('Ph.Status.PH7.menupopup').getElementsByTagName('menuitem')[(y)/2].value = sURL[y+1];
- }
- y++;
- if(y==17){
- notificationbox.appendNotification(stringsBundle.getString('Alert4'),'','',notificationbox.PRIORITY_INFO_MEDIUM);
- document.getElementById('Ph.Option.Tab2.Cmd').label= stringsBundle.getString('Button1');
- PhProxy_prefs.write_str('sURL',sURL[2]+'|'+sURL[3]+'|'+sURL[4]+'|'+sURL[5]+'|'+sURL[6]+'|'+sURL[7]+'|'+sURL[8]+'|'+sURL[9]+'|'+sURL[10]+'|'+sURL[11]+'|'+sURL[12]+'|'+sURL[13]+'|'+sURL[14]+'|'+sURL[15]+'|'+sURL[16]+'|'+sURL[17]);
-
- PhProxy_prefs.write_str('UpdateVer',sURL[1]);
- }
- }
- }
- }
- }
-
- var phv_update_servers = {
- get_from_server : function(sURL){
- document.getElementById("Ph.Option.Tab2.Prog").value="0";
- var req = new XMLHttpRequest();
- req.onprogress=function(e){
- document.getElementById("Ph.Option.Tab2.Prog").value=(e.position / e.totalSize)*100;
- }
- req.open("GET", sURL, true);
- req.channel.loadFlags |= Components.interfaces.nsIRequest.LOAD_BYPASS_CACHE;
-
- req.onreadystatechange = function (aEvt) {
- if (req.readyState == 4) {
- if(req.status == 200){
- phv_servers_listener.finished(req.responseText);
- document.getElementById("Ph.Option.Tab2.Prog").value="100";
- }
- else
- phv_servers_listener.finished("Error loading page");
- }
- };
- req.send(null);
- }
- }
-
- /**Read Write Pref */
- var PhProxy_prefs = {
- prefs: Components.classes["@mozilla.org/preferences-service;1"]
- .getService(Components.interfaces.nsIPrefService).getBranch("InBasic.PhProxy."),
-
- read_str : function (id) {
- return this.prefs.getCharPref(id);
- },
- write_str : function (id, sData) {
- this.prefs.setCharPref(id, sData);
- },
- read_bool : function (id) {
- return this.prefs.getBoolPref(id);
- },
- write_bool : function (id, sData) {
- this.prefs.setBoolPref(id, sData);
- }
- }