Changeset View
Changeset View
Standalone View
Standalone View
extension/action_popup.js
Show First 20 Lines • Show All 153 Lines • ▼ Show 20 Line(s) | 153 | document.addEventListener("DOMContentLoaded", () => { | |||
---|---|---|---|---|---|
154 | 154 | | |||
155 | sendMessage("browserAction", "getStatus").then((status) => { | 155 | sendMessage("browserAction", "getStatus").then((status) => { | ||
156 | 156 | | |||
157 | switch (status.portStatus) { | 157 | switch (status.portStatus) { | ||
158 | case "UNSUPPORTED_OS": | 158 | case "UNSUPPORTED_OS": | ||
159 | document.getElementById("unsupported_os_error").classList.remove("hidden"); | 159 | document.getElementById("unsupported_os_error").classList.remove("hidden"); | ||
160 | break; | 160 | break; | ||
161 | 161 | | |||
162 | case "STARTUP_FAILED": | 162 | case "STARTUP_FAILED": { | ||
163 | document.getElementById("startup_error").classList.remove("hidden"); | 163 | document.getElementById("startup_error").classList.remove("hidden"); | ||
164 | | ||||
165 | const errorText = status.portLastErrorMessage; | ||||
166 | // Don't show generic error on startup failure. There's already an explanation. | ||||
167 | if (errorText && errorText !== "UNKNOWN") { | ||||
168 | const errorTextItem = document.getElementById("startup_error_text"); | ||||
169 | errorTextItem.innerText = errorText; | ||||
170 | errorTextItem.classList.remove("hidden"); | ||||
171 | } | ||||
164 | break; | 172 | break; | ||
173 | } | ||||
165 | 174 | | |||
166 | default: | 175 | default: { | ||
167 | document.getElementById("main").classList.remove("hidden"); | 176 | document.getElementById("main").classList.remove("hidden"); | ||
168 | 177 | | |||
169 | let errorText = status.portLastErrorMessage; | 178 | let errorText = status.portLastErrorMessage; | ||
170 | if (errorText === "UNKNOWN") { | 179 | if (errorText === "UNKNOWN") { | ||
171 | errorText = chrome.i18n.getMessage("general_error_unknown"); | 180 | errorText = chrome.i18n.getMessage("general_error_unknown"); | ||
172 | } | 181 | } | ||
173 | 182 | | |||
174 | if (errorText) { | 183 | if (errorText) { | ||
175 | document.getElementById("runtime_error_text").innerText = errorText; | 184 | document.getElementById("runtime_error_text").innerText = errorText; | ||
176 | document.getElementById("runtime_error").classList.remove("hidden"); | 185 | document.getElementById("runtime_error").classList.remove("hidden"); | ||
177 | 186 | | |||
178 | // There's some content, hide dummy placeholder | 187 | // There's some content, hide dummy placeholder | ||
179 | document.getElementById("dummy-main").classList.add("hidden"); | 188 | document.getElementById("dummy-main").classList.add("hidden"); | ||
180 | } | 189 | } | ||
181 | 190 | | |||
182 | break; | 191 | break; | ||
183 | } | 192 | } | ||
193 | } | ||||
184 | 194 | | |||
185 | // HACK so the extension can tell we closed, see "browserAction" "ready" callback in extension.js | 195 | // HACK so the extension can tell we closed, see "browserAction" "ready" callback in extension.js | ||
186 | chrome.runtime.onConnect.addListener((port) => { | 196 | chrome.runtime.onConnect.addListener((port) => { | ||
187 | if (port.name !== "browserActionPort") { | 197 | if (port.name !== "browserActionPort") { | ||
188 | return; | 198 | return; | ||
189 | } | 199 | } | ||
190 | 200 | | |||
191 | // do we need to do something with the port here? | 201 | // do we need to do something with the port here? | ||
▲ Show 20 Lines • Show All 80 Lines • Show Last 20 Lines |