blob: 50c34b9ba0f1ac251ce436d7967a0485f3c156fb (
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
/* 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 { IMServices } = ChromeUtils.importESModule(
"resource:///modules/IMServices.sys.mjs"
);
/**
* Populates the "Chat" section of the troubleshooting information page with
* the chat accounts.
*/
function populateChatSection() {
let table = document.getElementById("chat-table");
let rowTmpl = document.getElementById("chat-table-row-template");
let dateTimeFormatter = new Services.intl.DateTimeFormat(undefined, {
dateStyle: "short",
timeStyle: "long",
});
let formatDebugMessage = dbgMsg => {
let m = dbgMsg.message;
let time = new Date(m.timeStamp);
time = dateTimeFormatter.format(time);
let level = dbgMsg.logLevel;
if (!level) {
return "(" + m.errorMessage + ")";
}
if (level == dbgMsg.LEVEL_ERROR) {
level = "ERROR";
} else if (level == dbgMsg.LEVEL_WARNING) {
level = "WARN.";
} else if (level == dbgMsg.LEVEL_LOG) {
level = "LOG ";
} else {
level = "DEBUG";
}
return (
"[" +
time +
"] " +
level +
" (@ " +
m.sourceLine +
" " +
m.sourceName +
":" +
m.lineNumber +
")\n" +
m.errorMessage
);
};
let chatAccounts = IMServices.accounts.getAccounts();
if (!chatAccounts.length) {
return;
}
table.querySelector("tbody").append(
...chatAccounts.map(account => {
const row = rowTmpl.content.cloneNode(true).querySelector("tr");
row.cells[0].textContent = account.id;
row.cells[1].textContent = account.protocol.id;
row.cells[2].textContent = account.name;
row.cells[3].addEventListener("click", () => {
const text = account
.getDebugMessages()
.map(formatDebugMessage)
.join("\n");
navigator.clipboard.writeText(text);
});
return row;
})
);
}
|