1 var mashTapePreferences = {
2 populateServices:
function(providerType) {
3 var box = document.getElementById(
"services-" + providerType);
4 var enabledKey =
"extensions.mashTape." + providerType +
".enabled";
5 var enabled =
Application.prefs.getValue(enabledKey,
true);
7 for each (var contract
in this.providers[providerType]) {
8 var classId = this.compMgr.contractIDToCID(contract);
9 var prov =
Cc[contract].createInstance(
Ci.sbIMashTapeProvider);
12 var attribute =
"checked";
13 switch(providerType) {
15 prov = prov.QueryInterface(
Ci.sbIMashTapeInfoProvider);
17 attribute =
"selected";
20 prov = prov.QueryInterface(
Ci.sbIMashTapeReviewProvider);
23 prov = prov.QueryInterface(
Ci.sbIMashTapeRSSProvider);
26 prov = prov.QueryInterface(
Ci.sbIMashTapePhotoProvider);
28 attribute =
"selected";
31 prov = prov.QueryInterface(
Ci.sbIMashTapeFlashProvider);
37 var li = document.createElement(
"richlistitem");
40 "extensions.mashTape." + providerType +
".providers",
"")
42 var el = document.createElement(element);
43 el.setAttribute(
"command",
"cmd-" + providerType);
44 el.setAttribute(
"value", classId);
45 for each (var provider
in providers) {
46 if (classId == provider)
47 el.setAttribute(attribute,
true);
51 if (providerType ==
"info") {
52 var icons =
new Object;
53 var favicon = document.createElement(
"image");
54 favicon.setAttribute(
"src", prov.providerIconBio);
55 li.appendChild(favicon);
56 icons[prov.providerIconBio] = 1;
57 if (typeof(icons[prov.providerIconTags]) ==
"undefined") {
58 favicon = document.createElement(
"image");
59 favicon.setAttribute(
"src", prov.providerIconTags);
60 li.appendChild(favicon);
61 icons[prov.providerIconTags] = 1;
63 if (typeof(icons[prov.providerIconDiscography]) ==
"undefined") {
64 favicon = document.createElement(
"image");
65 favicon.setAttribute(
"src", prov.providerIconDiscography);
66 li.appendChild(favicon);
67 icons[prov.providerIconDiscography] = 1;
69 if (typeof(icons[prov.providerIconMembers]) ==
"undefined") {
70 favicon = document.createElement(
"image");
71 favicon.setAttribute(
"src", prov.providerIconMembers);
72 li.appendChild(favicon);
73 icons[prov.providerIconMembers] = 1;
75 if (typeof(icons[prov.providerIconLinks]) ==
"undefined") {
76 favicon = document.createElement(
"image");
77 favicon.setAttribute(
"src", prov.providerIconLinks);
78 li.appendChild(favicon);
79 icons[prov.providerIconLinks] = 1;
82 var favicon = document.createElement(
"image");
83 favicon.setAttribute(
"src", prov.providerIcon);
84 li.appendChild(favicon);
87 var serviceLabel = document.createElement(
"label");
88 serviceLabel.setAttribute(
"value", prov.providerName);
89 li.appendChild(serviceLabel);
95 this.toggleServices(box, providerType, !enabled);
99 enumerateServices:
function() {
101 Components.manager.QueryInterface(
Ci.nsIComponentRegistrar);
103 this.providers =
new Array();
104 this.providers[
"info"] =
new Array();
105 this.providers[
"review"] =
new Array();
106 this.providers[
"rss"] =
new Array();
107 this.providers[
"photo"] =
new Array();
108 this.providers[
"flash"] =
new Array();
110 for (var contract in
Cc) {
111 if (contract.indexOf(
"mashTape/provider") >= 0) {
112 var mtClass = contract.substring(
113 contract.indexOf(
"mashTape/provider") + 18,contract.length);
114 mtClass = mtClass.substring(0, mtClass.indexOf(
"/"));
115 this.providers[mtClass].push(contract);
118 this.providers[
"info"].sort();
119 this.providers[
"review"].sort();
120 this.providers[
"rss"].sort();
121 this.providers[
"photo"].sort();
122 this.providers[
"flash"].sort();
125 savePrefs:
function(providerType) {
126 var box = document.getElementById(
"services-" + providerType);
127 var prefKey =
"extensions.mashTape." + providerType +
".providers";
128 var prefServices =
new Array();
130 switch (providerType) {
141 var providerSelected =
false;
142 for each (var rli
in box.childNodes) {
143 if (rli.tagName !=
"richlistitem")
145 var el = rli.firstChild;
146 if (el.hasAttribute(attr)) {
147 prefServices.push(el.getAttribute(
"value"));
148 providerSelected =
true;
151 if (!providerSelected) {
152 document.getElementById(
"checkbox-" + providerType).checked =
false;
153 mashTapePreferences.toggle(providerType);
156 Application.prefs.setValue(prefKey, prefServices.join(
","));
159 toggle:
function(providerType) {
160 var checkbox = document.getElementById(
"checkbox-" + providerType);
161 var box = document.getElementById(
"services-" + providerType);
164 var enabledKey =
"extensions.mashTape." + providerType +
".enabled";
165 var enabled = checkbox.hasAttribute(
"checked");
169 this.toggleServices(box, providerType, !enabled);
170 if (providerType ==
"photo") {
171 var hbox = document.getElementById(
"hbox-photo-speed");
172 for each (var
node in hbox.childNodes)
173 node.disabled = !enabled;
179 var box = document.getElementById(
"services-" + providerType);
181 switch (providerType) {
192 var providerSelected =
false;
193 var firstProvider =
null;
194 for each (var rli
in box.childNodes) {
195 if (rli.tagName !=
"richlistitem")
197 var el = rli.firstChild;
201 if (!providerSelected) {
203 firstProvider.setAttribute(attr,
true);
204 mashTapePreferences.savePrefs(providerType);
209 toggleServices:
function(box, providerType, disabled) {
210 var helpText = document.getElementById(
"help-" + providerType);
211 helpText.disabled = disabled;
212 helpText.setAttribute(
"disabled", disabled);
213 box.setAttribute(
"disabled", disabled);
214 for each (var rli
in box.childNodes) {
215 if (rli.tagName !=
"richlistitem")
217 var el = rli.firstChild;
218 el.setAttribute(
"disabled", disabled);
223 if (subject instanceof Components.interfaces.nsIPrefBranch) {
225 if (pref.length == 2 && pref[1] ==
"enabled") {
226 var tabName = pref[0];
227 this.checkDefaultTab(tabName);
232 getDefaultTabItem :
function(providerType) {
233 for (var
i=0;
i<this.defaultTabSelect.itemCount;
i++) {
234 var item = this.defaultTabSelect.getItemAtIndex(
i);
235 if (item.value == providerType)
241 checkDefaultTab:
function(tabName) {
242 var prefKey = tabName +
".enabled";
243 var enabled = this.
_prefBranch.getBoolPref(prefKey);
244 var item = this.getDefaultTabItem(tabName);
246 item.disabled =
true;
249 for each (var
tab in [
"info",
"review",
"rss",
"photo",
"flash"])
251 if (this.
_prefBranch.getBoolPref(tab +
".enabled") &&
252 this.providers[
tab].length > 0) {
253 var sItem = this.getDefaultTabItem(tab);
254 this.defaultTabSelect.selectedItem = sItem;
261 item.disabled =
false;
265 this.defaultTabSelect = document.getElementById(
"general-default-tab");
268 this.
_prefBranch = Cc[
"@mozilla.org/preferences-service;1"]
269 .getService(
Ci.nsIPrefService).getBranch(
"extensions.mashTape.")
270 .QueryInterface(
Ci.nsIPrefBranch2);
273 for each (var tab
in [
"info",
"review",
"rss",
"photo",
"flash"])
274 this.checkDefaultTab(tab);
276 if (!this.
_prefBranch.getBoolPref(
"photo.enabled")) {
277 var hbox = document.getElementById(
"hbox-photo-speed");
278 for each (var node
in hbox.childNodes)
279 node.disabled =
true;
289 var scale = document.getElementById(
"scale-photo-speed");
290 scale.value = this.
_prefBranch.getIntPref(
"photo.speed");
291 scale.setAttribute(
"preference",
"photo-speed");
293 this.enumerateServices();
294 this.populateServices(
"info");
295 this.populateServices(
"review");
296 this.populateServices(
"rss");
297 this.populateServices(
"photo");
298 this.populateServices(
"flash");
pref("extensions.7digital.configured", false)
function toggle(toShow, toHide, data, clickedActive, down)
_getSelectedPageStyle s i
sbDeviceFirmwareAutoCheckForUpdate prototype observe