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
|
/*
* This file is part of TbSync.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
"use strict";
var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
var { TbSync } = ChromeUtils.import("chrome://tbsync/content/tbsync.jsm");
var tbSyncAccountManager = {
onloadoptions: function () {
window.close();
},
onunloadoptions: function () {
TbSync.manager.openManagerWindow(0);
},
onload: function () {
TbSync.AccountManagerTabs = ["accounts.xhtml", "catman.xhtml", "supporter.xhtml", "help.xhtml"];
tbSyncAccountManager.selectTab(0);
},
onunload: function () {
TbSync.manager.prefWindowObj = null;
},
selectTab: function (t) {
const LOAD_FLAGS_NONE = Components.interfaces.nsIWebNavigation.LOAD_FLAGS_NONE;
//set active tab (css selector for background color)
for (let i=0; i<TbSync.AccountManagerTabs.length; i++) {
if (i==t) document.getElementById("tbSyncAccountManager.t" + i).setAttribute("active","true");
else document.getElementById("tbSyncAccountManager.t" + i).setAttribute("active","false");
}
TbSync.manager.prefWindowObj.document.getElementById("tbSyncAccountManager.installProvider").hidden=true;
//load XUL
document.getElementById("tbSyncAccountManager.contentWindow").setAttribute("src", "chrome://tbsync/content/manager/"+TbSync.AccountManagerTabs[t]);
},
//help tab
getLogPref: function() {
let log = document.getElementById("tbSyncAccountManager.logLevel");
log.value = Math.min(3, TbSync.prefs.getIntPref("log.userdatalevel"));
},
toggleLogPref: function() {
let log = document.getElementById("tbSyncAccountManager.logLevel");
TbSync.prefs.setIntPref("log.userdatalevel", log.value);
},
initSupportWizard: function() {
document.getElementById("SupportWizard").getButton("finish").disabled = true;
let menu = document.getElementById("tbsync.supportwizard.faultycomponent");
let providers = Object.keys(TbSync.providers.loadedProviders);
for (let i=0; i < providers.length; i++) {
let item = document.createXULElement("menuitem");
item.setAttribute("value", providers[i]);
item.setAttribute("label", TbSync.getString("supportwizard.provider::" + TbSync.providers[providers[i]].Base.getProviderName()));
menu.appendChild(item);
}
document.getElementById("tbsync.supportwizard.faultycomponent.menulist").addEventListener("select", tbSyncAccountManager.checkSupportWizard);
document.getElementById("tbsync.supportwizard.description").addEventListener("input", tbSyncAccountManager.checkSupportWizard);
document.addEventListener("wizardfinish", tbSyncAccountManager.prepareBugReport);
// bug https://bugzilla.mozilla.org/show_bug.cgi?id=1618252
document.getElementById('SupportWizard')._adjustWizardHeader();
},
checkSupportWizard: function() {
let provider = document.getElementById("tbsync.supportwizard.faultycomponent").parentNode.value;
let subject = document.getElementById("tbsync.supportwizard.summary").value;
let description = document.getElementById("tbsync.supportwizard.description").value;
//just check and update button status
document.getElementById("SupportWizard").getButton("finish").disabled = (provider == "" || subject == "" || description== "");
},
prepareBugReport: function(event) {
let provider = document.getElementById("tbsync.supportwizard.faultycomponent").parentNode.value;
let subject = document.getElementById("tbsync.supportwizard.summary").value;
let description = document.getElementById("tbsync.supportwizard.description").value;
if (provider == "" || subject == "" || description== "") {
event.preventDefault();
return;
}
//special if core is selected, which is not a provider
let email = (TbSync.providers.loadedProviders.hasOwnProperty(provider)) ? TbSync.providers[provider].Base.getMaintainerEmail() : "john.bieling@gmx.de";
let version = (TbSync.providers.loadedProviders.hasOwnProperty(provider)) ? " " + TbSync.providers.loadedProviders[provider].version : "";
TbSync.manager.createBugReport(email, "[" + provider.toUpperCase() + version + "] " + subject, description);
},
//community tab
initCommunity: function() {
let listOfContributors = document.getElementById("listOfContributors");
let sponsors = {};
let providers = Object.keys(TbSync.providers.loadedProviders);
for (let i=0; i < providers.length; i++) {
let provider = providers[i];
let template = listOfContributors.firstElementChild.cloneNode(true);
template.setAttribute("provider", provider);
template.children[0].setAttribute("src", TbSync.providers[provider].Base.getProviderIcon(48));
template.children[1].children[0].textContent = TbSync.providers[provider].Base.getProviderName();
listOfContributors.appendChild(template);
Object.assign(sponsors, TbSync.providers[provider].Base.getSponsors());
}
listOfContributors.removeChild(listOfContributors.firstElementChild);
let listOfSponsors = document.getElementById("listOfSponsors");
let sponsorlist = Object.keys(sponsors);
sponsorlist.sort();
for (let i=0; i < sponsorlist.length; i++) {
let sponsor = sponsors[sponsorlist[i]];
let template = listOfSponsors.firstElementChild.cloneNode(true);
if (sponsor.link) template.setAttribute("link", sponsor.link);
if (sponsor.icon) template.children[0].setAttribute("src", sponsor.icon);
template.children[1].children[0].textContent = sponsor.name;
template.children[1].children[1].textContent = sponsor.description;
listOfSponsors.appendChild(template);
listOfSponsors.appendChild(template);
}
listOfSponsors.removeChild(listOfSponsors.firstElementChild);
}
};
|