aboutsummaryrefslogtreecommitdiff
path: root/ext/js/pages/info-main.js
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2024-02-01 10:00:59 -0500
committerGitHub <noreply@github.com>2024-02-01 15:00:59 +0000
commitdfd42bad0b46845ad88d1fdc5fa82b4f03bab0f3 (patch)
tree04686b943b84b33b8927238be17e4bc0dda7eb62 /ext/js/pages/info-main.js
parent2356223942a21d1683ac38eed8e7b9485f453d87 (diff)
Application refactor (#591)
* Rename Yomitan class to Application, change initialization style * Rename file * Update init * Update config * Remove dead code
Diffstat (limited to 'ext/js/pages/info-main.js')
-rw-r--r--ext/js/pages/info-main.js29
1 files changed, 17 insertions, 12 deletions
diff --git a/ext/js/pages/info-main.js b/ext/js/pages/info-main.js
index dd55ab4b..ca5094b1 100644
--- a/ext/js/pages/info-main.js
+++ b/ext/js/pages/info-main.js
@@ -16,11 +16,11 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
+import {Application} from '../application.js';
import {log} from '../core/logger.js';
import {promiseTimeout} from '../core/utilities.js';
import {DocumentFocusController} from '../dom/document-focus-controller.js';
import {querySelectorNotNull} from '../dom/query-selector.js';
-import {yomitan} from '../yomitan.js';
import {BackupController} from './settings/backup-controller.js';
import {SettingsController} from './settings/settings-controller.js';
@@ -57,11 +57,13 @@ function getOperatingSystemDisplayName(os) {
}
}
-/** */
-async function showAnkiConnectInfo() {
+/**
+ * @param {import('../comm/api.js').API} api
+ */
+async function showAnkiConnectInfo(api) {
let ankiConnectVersion = null;
try {
- ankiConnectVersion = await yomitan.api.getAnkiConnectVersion();
+ ankiConnectVersion = await api.getAnkiConnectVersion();
} catch (e) {
// NOP
}
@@ -78,11 +80,13 @@ async function showAnkiConnectInfo() {
ankiVersionUnknownElement.hidden = (ankiConnectVersion !== null);
}
-/** */
-async function showDictionaryInfo() {
+/**
+ * @param {import('../comm/api.js').API} api
+ */
+async function showDictionaryInfo(api) {
let dictionaryInfos;
try {
- dictionaryInfos = await yomitan.api.getDictionaryInfo();
+ dictionaryInfos = await api.getDictionaryInfo();
} catch (e) {
return;
}
@@ -121,11 +125,12 @@ async function main() {
const manifest = chrome.runtime.getManifest();
const language = chrome.i18n.getUILanguage();
- await yomitan.prepare();
+ const application = new Application();
+ await application.prepare();
const {userAgent} = navigator;
const {name, version} = manifest;
- const {browser, platform: {os}} = await yomitan.api.getEnvironmentInfo();
+ const {browser, platform: {os}} = await application.api.getEnvironmentInfo();
/** @type {HTMLLinkElement} */
const thisVersionLink = querySelectorNotNull(document, '#release-notes-this-version-link');
@@ -149,10 +154,10 @@ async function main() {
languageElement.textContent = `${language}`;
userAgentElement.textContent = userAgent;
- showAnkiConnectInfo();
- showDictionaryInfo();
+ showAnkiConnectInfo(application.api);
+ showDictionaryInfo(application.api);
- const settingsController = new SettingsController();
+ const settingsController = new SettingsController(application);
await settingsController.prepare();
const backupController = new BackupController(settingsController, null);