4
dump: function dump(aMessage)
6
var consoleService = Components.classes["@mozilla.org/consoleservice;1"].getService(Components.interfaces.nsIConsoleService);
7
consoleService.logStringMessage("RefControl: " + aMessage);
10
dumpEx: function dumpEx(aException)
12
Components.utils.reportError(aException);
13
if ('stack' in aException)
15
var msg = new String(aException);
16
msg += "\n" + aException.stack;
21
getString: function getString(sStringName)
23
return document.getElementById('refcontrol-strings').getString(sStringName);
26
onLoad: function onLoad()
29
var fldSite = document.getElementById("fldSite");
30
var fldActionGroup = document.getElementById("fldActionGroup");
31
var fldActionNormal = document.getElementById("fldActionNormal");
32
var fldActionBlock = document.getElementById("fldActionBlock");
33
var fldActionForge = document.getElementById("fldActionForge");
34
var fldActionCustom = document.getElementById("fldActionCustom");
35
var fldAction = document.getElementById("fldAction");
36
var fld3rdParty = document.getElementById("fld3rdParty");
38
var site = window.arguments[0].site;
39
var action = window.arguments[0].action;
41
if (site == '@DEFAULT')
43
fldSite.value = this.getString("SiteDefault");
44
fldSite.style.fontWeight = "bold";
45
fldSite.disabled = true;
55
fldActionGroup.selectedItem = fldActionNormal;
57
fldAction.disabled = true;
60
fldActionGroup.selectedItem = fldActionBlock;
62
fldAction.disabled = true;
65
fldActionGroup.selectedItem = fldActionForge;
67
fldAction.disabled = true;
70
fldActionGroup.selectedItem = fldActionCustom;
71
fldAction.value = action.str;
72
fldAction.disabled = false;
76
fld3rdParty.checked = action.if3rdParty;
85
var fldSite = document.getElementById("fldSite");
86
var fldActionGroup = document.getElementById("fldActionGroup");
87
var fldActionNormal = document.getElementById("fldActionNormal");
88
var fldActionBlock = document.getElementById("fldActionBlock");
89
var fldActionForge = document.getElementById("fldActionForge");
90
var fldActionCustom = document.getElementById("fldActionCustom");
91
var fldAction = document.getElementById("fldAction");
92
var fld3rdParty = document.getElementById("fld3rdParty");
101
// if user specified a complete URL, extract just the host from it
103
var svcIO = Components.classes["@mozilla.org/network/io-service;1"].getService(Components.interfaces.nsIIOService);
104
site = svcIO.newURI(fldSite.value, null, null).host;
106
site = fldSite.value;
108
// strip off any leading "*." components
109
// "example.com" will do what users expect from "*.example.com"
110
while (site.search(/^\*\./) != -1)
111
site = site.substr(2)
114
window.alert(this.getString("SiteNotFilledInAlert"));
117
if (site.search(/[ =*]/) != -1)
119
window.alert(this.getString("SiteInvalidCharactersAlert"));
124
switch (fldActionGroup.selectedItem)
126
case fldActionNormal:
127
action.str = '@NORMAL';
133
action.str = '@FORGE';
135
case fldActionCustom:
136
action.str = fldAction.value;
139
window.alert("Unable to determine selected action.");
143
action.if3rdParty = fld3rdParty.checked;
145
window.arguments[0].site = site;
146
window.arguments[0].action = action;
147
window.arguments[0].ret = true;
155
onActionChange: function onActionChange(aEvent)
157
var fldAction = document.getElementById("fldAction");
158
fldAction.disabled = !(aEvent.target.id == "fldActionCustom");