From 6bf0a5cb5034a7e684dcc3500e841785237ce2dd Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 19:32:43 +0200 Subject: Adding upstream version 1:115.7.0. Signed-off-by: Daniel Baumann --- comm/mail/components/about-support/content/chat.js | 73 ++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 comm/mail/components/about-support/content/chat.js (limited to 'comm/mail/components/about-support/content/chat.js') diff --git a/comm/mail/components/about-support/content/chat.js b/comm/mail/components/about-support/content/chat.js new file mode 100644 index 0000000000..50c34b9ba0 --- /dev/null +++ b/comm/mail/components/about-support/content/chat.js @@ -0,0 +1,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; + }) + ); +} -- cgit v1.2.3