aboutsummaryrefslogtreecommitdiff
path: root/ext/js/pages/settings
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2022-05-28 21:57:25 -0400
committerGitHub <noreply@github.com>2022-05-28 21:57:25 -0400
commit0d82c52a7624d80ec48dc774fb23db5244bc14f9 (patch)
treece8f7c24250d24c2c4d1eae6c48dfe319de46d57 /ext/js/pages/settings
parent4e4fa49b0b1fd6ec5a018e742eb9910aa32e7637 (diff)
HTML page script refactoring (#2162)
* Move some common functionality * Move setupEnvironmentInfo into ExtensionContentController * Move background/environment.js to extension/environment.js
Diffstat (limited to 'ext/js/pages/settings')
-rw-r--r--ext/js/pages/settings/settings-display-controller.js59
-rw-r--r--ext/js/pages/settings/settings-main.js20
2 files changed, 4 insertions, 75 deletions
diff --git a/ext/js/pages/settings/settings-display-controller.js b/ext/js/pages/settings/settings-display-controller.js
index 783d5bec..1b70843f 100644
--- a/ext/js/pages/settings/settings-display-controller.js
+++ b/ext/js/pages/settings/settings-display-controller.js
@@ -55,14 +55,6 @@ class SettingsDisplayController {
node.addEventListener('keydown', onInputTabActionKeyDown, false);
}
- const onSpecialUrlLinkClick = this._onSpecialUrlLinkClick.bind(this);
- const onSpecialUrlLinkMouseDown = this._onSpecialUrlLinkMouseDown.bind(this);
- for (const node of document.querySelectorAll('[data-special-url]')) {
- node.addEventListener('click', onSpecialUrlLinkClick, false);
- node.addEventListener('auxclick', onSpecialUrlLinkClick, false);
- node.addEventListener('mousedown', onSpecialUrlLinkMouseDown, false);
- }
-
for (const node of document.querySelectorAll('.defer-load-iframe')) {
this._setupDeferLoadIframe(node);
}
@@ -229,57 +221,6 @@ class SettingsDisplayController {
}
}
- _onSpecialUrlLinkClick(e) {
- switch (e.button) {
- case 0:
- case 1:
- e.preventDefault();
- this._createTab(e.currentTarget.dataset.specialUrl, true);
- break;
- }
- }
-
- _onSpecialUrlLinkMouseDown(e) {
- switch (e.button) {
- case 0:
- case 1:
- e.preventDefault();
- break;
- }
- }
-
- async _createTab(url, useOpener) {
- let openerTabId;
- if (useOpener) {
- try {
- const tab = await new Promise((resolve, reject) => {
- chrome.tabs.getCurrent((result) => {
- const e = chrome.runtime.lastError;
- if (e) {
- reject(new Error(e.message));
- } else {
- resolve(result);
- }
- });
- });
- openerTabId = tab.id;
- } catch (e) {
- // NOP
- }
- }
-
- return await new Promise((resolve, reject) => {
- chrome.tabs.create({url, openerTabId}, (tab2) => {
- const e = chrome.runtime.lastError;
- if (e) {
- reject(new Error(e.message));
- } else {
- resolve(tab2);
- }
- });
- });
- }
-
_updateScrollTarget() {
const hash = window.location.hash;
if (!hash.startsWith('#!')) { return; }
diff --git a/ext/js/pages/settings/settings-main.js b/ext/js/pages/settings/settings-main.js
index 5aab25f7..a3dcf357 100644
--- a/ext/js/pages/settings/settings-main.js
+++ b/ext/js/pages/settings/settings-main.js
@@ -24,7 +24,7 @@
* DictionaryController
* DictionaryImportController
* DocumentFocusController
- * Environment
+ * ExtensionContentController
* ExtensionKeyboardShortcutController
* GenericSettingController
* KeyboardShortcutController
@@ -48,19 +48,6 @@
* TranslationTextReplacementsController
*/
-async function setupEnvironmentInfo() {
- const {dataset} = document.documentElement;
- const {manifest_version: manifestVersion} = chrome.runtime.getManifest();
- dataset.manifestVersion = `${manifestVersion}`;
-
- const environment = new Environment();
- await environment.prepare();
- const {browser, platform} = environment.getInfo();
-
- dataset.browser = browser;
- dataset.os = platform.os;
-}
-
async function setupGenericSettingsController(genericSettingController) {
await genericSettingController.prepare();
await genericSettingController.refresh();
@@ -71,11 +58,12 @@ async function setupGenericSettingsController(genericSettingController) {
const documentFocusController = new DocumentFocusController();
documentFocusController.prepare();
+ const extensionContentController = new ExtensionContentController();
+ extensionContentController.prepare();
+
const statusFooter = new StatusFooter(document.querySelector('.status-footer-container'));
statusFooter.prepare();
- setupEnvironmentInfo();
-
let prepareTimer = setTimeout(() => {
prepareTimer = null;
document.documentElement.dataset.loadingStalled = 'true';