blob: 0f39cecbf1ce834ed504def078a19b7ae1db59bb (
plain)
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
|
/* 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/. */
var { cal } = ChromeUtils.import("resource:///modules/calendar/calUtils.jsm");
window.addEventListener("DOMContentLoaded", onLoad);
function onLoad() {
let extension = window.arguments[0].extension;
document.getElementById("provider-name-label").value = extension.name;
let calendarList = document.getElementById("calendar-list");
for (let calendar of cal.manager.getCalendars()) {
if (calendar.providerID != extension.id) {
continue;
}
let item = document.createXULElement("richlistitem");
item.setAttribute("calendar-id", calendar.id);
let checkbox = document.createXULElement("checkbox");
checkbox.classList.add("calendar-selected");
item.appendChild(checkbox);
let colorMarker = document.createElement("div");
colorMarker.classList.add("calendar-color");
item.appendChild(colorMarker);
colorMarker.style.backgroundColor = calendar.getProperty("color");
let label = document.createXULElement("label");
label.classList.add("calendar-name");
label.value = calendar.name;
item.appendChild(label);
calendarList.appendChild(item);
}
}
document.addEventListener("dialogaccept", () => {
// Tell our caller that the extension should be uninstalled.
let args = window.arguments[0];
args.shouldUninstall = true;
let calendarList = document.getElementById("calendar-list");
// Unsubscribe from all selected calendars
for (let item of calendarList.children) {
if (item.querySelector(".calendar-selected").checked) {
cal.manager.unregisterCalendar(cal.manager.getCalendarById(item.getAttribute("calendar-id")));
}
}
});
document.addEventListener("dialogcancel", () => {
let args = window.arguments[0];
args.shouldUninstall = false;
});
|