Changeset View
Changeset View
Standalone View
Standalone View
extension/action_popup.js
- This file was added.
1 | /* | ||||
---|---|---|---|---|---|
2 | Copyright (C) 2019 Kai Uwe Broulik <kde@privat.broulik.de> | ||||
3 | | ||||
4 | This program is free software; you can redistribute it and/or | ||||
5 | modify it under the terms of the GNU General Public License as | ||||
6 | published by the Free Software Foundation; either version 3 of | ||||
7 | the License, or (at your option) any later version. | ||||
8 | | ||||
9 | This program is distributed in the hope that it will be useful, | ||||
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||||
12 | GNU General Public License for more details. | ||||
13 | | ||||
14 | You should have received a copy of the GNU General Public License | ||||
15 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||||
16 | */ | ||||
17 | | ||||
18 | document.addEventListener("DOMContentLoaded", () => { | ||||
19 | | ||||
20 | sendMessage("browserAction", "getStatus").then((status) => { | ||||
21 | | ||||
22 | switch (status.portStatus) { | ||||
23 | case "UNSUPPORTED_OS": | ||||
24 | document.getElementById("unsupported_os_error").classList.remove("hidden"); | ||||
25 | break; | ||||
26 | | ||||
27 | case "STARTUP_FAILED": | ||||
28 | document.getElementById("startup_error").classList.remove("hidden"); | ||||
29 | break; | ||||
30 | | ||||
31 | default: | ||||
32 | document.getElementById("main").classList.remove("hidden"); | ||||
33 | | ||||
34 | let errorText = status.portLastErrorMessage; | ||||
35 | if (errorText === "UNKNOWN") { | ||||
36 | errorText = chrome.i18n.getMessage("general_error_unknown"); | ||||
37 | } | ||||
38 | | ||||
39 | if (errorText) { | ||||
40 | document.getElementById("runtime_error_text").innerText = errorText; | ||||
41 | document.getElementById("runtime_error").classList.remove("hidden"); | ||||
42 | } | ||||
43 | | ||||
44 | break; | ||||
45 | } | ||||
46 | | ||||
47 | // HACK so the extension can tell we closed, see "browserAction" "ready" callback in extension.js | ||||
48 | chrome.runtime.onConnect.addListener((port) => { | ||||
49 | if (port.name !== "browserActionPort") { | ||||
50 | return; | ||||
51 | } | ||||
52 | | ||||
53 | // do we need to do something with the port here? | ||||
54 | }); | ||||
55 | sendMessage("browserAction", "ready"); | ||||
56 | }); | ||||
57 | | ||||
58 | }); |