1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
|
/**
* Permafrost - Protect your privacy!
* *
* Copyright (C) 2012 2013 Loic J. Duros
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
var FORM_TYPES;
/* constructor for form types options */
function FormType(options) {
"use strict";
var item;
for (item in options) {
this[item] = options[item];
}
}
FormType.prototype = {
onblur: 'submit',
showbuttons: true,
pk: null,
name: null,
value: null,
url: function (params) {
"use strict";
// see https://addons.mozilla.org/en-US/developers/docs/sdk/latest/dev-guide/guides/content-scripts/communicating-with-other-scripts.html#Using%20Custom%20DOM%20Events for information on this.
FORM_TYPES.triggerEvent({'event': 'rules-form-update', 'value': params});
}
};
FORM_TYPES = {
patternPlaceholder: 'Enter wildcard patterns or regular expression ' +
'patterns, one per line',
ruleType: null,
requestOrigin: null,
visitingSite: null,
contentType: null,
blockUI: function () {
"use strict";
$.blockUI({
message: null,
overlayCSS: { backgroundColor: 'none' }});
},
unblockUI: function () {
"use strict";
window.setTimeout($.unblockUI, 500);
},
triggerEvent: function (msg) {
"use strict";
var event = document.createEvent("CustomEvent");
var that = this;
event.initCustomEvent("permafrost-settings-change", true, true, msg);
document.documentElement.dispatchEvent(event);
this.blockUI();
var success = function (event) {
that.unblockUI();
document.documentElement.removeListener("rules-form-data-written", success, false);
};
document.documentElement.addEventListener("rules-form-data-written", success, false);
},
init: function () {
"use strict";
var formTypesHelper = this;
// these four objects will be used to represent all the
// form items in the table, and will hold different values
// depending on the last active html form object.
this.ruleType = new FormType({
type: 'select',
name: 'rule',
source: [
{value: 'block', text: 'Block'},
{value: 'allow', text: 'Allow'}
]
});
this.requestOrigin = new FormType({
type: 'textarea',
name: 'content-location',
title: 'Requests originating from',
placeholder: formTypesHelper.patternPlaceholder
});
this.visitingSite = new FormType({
type: 'textarea',
name: 'request-origin',
title: 'when visiting (referrer)',
placeholder: formTypesHelper.patternPlaceholder
});
this.contentType = new FormType({
type: 'checklist',
name: 'content-type',
title: 'and are of type',
separator: ',',
source: [
{ value: 'script', text: 'scripts' },
{ value: 'image', text: 'images' },
{ value: 'stylesheet', text: 'stylesheets' },
{ value: 'object', text: 'objects and plugin contents' },
{ value: 'object-request', text: 'requests made by plugins' },
{ value: 'subdocument', text: 'subdocuments (iframes, frames, and objects)' },
{ value: 'font', text: 'web font (@font-face)' },
{ value: 'media', text: 'video or audio content' },
{ value: 'xbl', text: 'XBL binding request' },
{ value: 'dtd', text: 'DTD loaded by an XML document' },
{ value: 'xrh', text: 'Ajax requests (XMLHttpRequests)' },
{ value: 'others', text: 'miscellaneous content' }
]
});
}
};
|