From c7fd17183d27ccd70aac70f89a832e3448136ad3 Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Tue, 19 Feb 2019 22:45:02 -0500 Subject: Add meta viewport tag to all html pages --- ext/bg/settings.html | 1 + 1 file changed, 1 insertion(+) (limited to 'ext/bg/settings.html') diff --git a/ext/bg/settings.html b/ext/bg/settings.html index 7f18a358..3728876c 100644 --- a/ext/bg/settings.html +++ b/ext/bg/settings.html @@ -2,6 +2,7 @@ + Yomichan Options -- cgit v1.2.3 From d49cbf12eae40e1a898c619ed092af560aa91bc6 Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Tue, 19 Feb 2019 22:47:27 -0500 Subject: Add search link and padding to settings page links This makes the bottom links easier to touch and makes the search page easier to access when there is no extension badge --- ext/bg/settings.html | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'ext/bg/settings.html') diff --git a/ext/bg/settings.html b/ext/bg/settings.html index 3728876c..53d17855 100644 --- a/ext/bg/settings.html +++ b/ext/bg/settings.html @@ -25,6 +25,10 @@ overflow-x: hidden; white-space: pre; } + + .bottom-links { + padding-bottom: 1em; + } @@ -311,8 +315,8 @@

 
-            
- HomepageLegal +
-- cgit v1.2.3 From 2328d61a8135ec3b4ca85a9d823ccdbf38b94e84 Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Sat, 4 May 2019 12:57:55 -0400 Subject: Add storage information to settings page --- ext/bg/js/settings.js | 81 +++++++++++++++++++++++++++++++++++++++++++++++++++ ext/bg/settings.html | 47 +++++++++++++++++++++++++++++- 2 files changed, 127 insertions(+), 1 deletion(-) (limited to 'ext/bg/settings.html') diff --git a/ext/bg/js/settings.js b/ext/bg/js/settings.js index 4bf7181f..579af085 100644 --- a/ext/bg/js/settings.js +++ b/ext/bg/js/settings.js @@ -203,6 +203,8 @@ async function onReady() { } formUpdateVisibility(options); + + storageInfoInitialize(); } $(document).ready(utilAsync(onReady)); @@ -520,3 +522,82 @@ async function onAnkiFieldTemplatesReset(e) { ankiErrorShow(e); } } + + +/* + * Storage + */ + +async function getBrowser() { + if (typeof chrome !== "undefined") { + if (typeof browser !== "undefined") { + try { + const info = await browser.runtime.getBrowserInfo(); + if (info.name === "Fennec") { + return "firefox-mobile"; + } + } catch (e) { } + return "firefox"; + } else { + return "chrome"; + } + } else { + return "edge"; + } +} + +function storageBytesToLabeledString(size) { + const base = 1000; + const labels = ["bytes", "KB", "MB", "GB"]; + let labelIndex = 0; + while (size >= base) { + size /= base; + ++labelIndex; + } + const label = size.toFixed(1).replace(/\.0+$/, ""); + return `${label}${labels[labelIndex]}`; +} + +async function storageEstimate() { + try { + return await navigator.storage.estimate(); + } catch (e) { } + return null; +} + +async function storageInfoInitialize() { + const browser = await getBrowser(); + const container = document.querySelector("#storage-info"); + container.setAttribute("data-browser", browser); + + await storageShowInfo(); + + container.classList.remove("storage-hidden"); + + document.querySelector("#storage-refresh").addEventListener('click', () => storageShowInfo(), false); +} + +async function storageShowInfo() { + storageSpinnerShow(true); + + const estimate = await storageEstimate(); + const valid = (estimate !== null); + + if (valid) { + document.querySelector("#storage-usage").textContent = storageBytesToLabeledString(estimate.usage); + document.querySelector("#storage-quota").textContent = storageBytesToLabeledString(estimate.quota); + } + document.querySelector("#storage-use").classList.toggle("storage-hidden", !valid); + document.querySelector("#storage-error").classList.toggle("storage-hidden", valid); + + storageSpinnerShow(false); +} + +function storageSpinnerShow(show) { + const spinner = $('#storage-spinner'); + if (show) { + spinner.show(); + } else { + spinner.hide(); + } +} diff --git a/ext/bg/settings.html b/ext/bg/settings.html index 53d17855..d41d442b 100644 --- a/ext/bg/settings.html +++ b/ext/bg/settings.html @@ -9,7 +9,7 @@ @@ -197,6 +208,40 @@ +
+
+ +

Storage

+
+ +
+

+ Yomichan is using approximately of . +

+
+ +
+

+ Could not detect how much storage Yomichan is using. +

+
+ On Firefox and Firefox for Android, the storage information feature may be hidden behind a browser flag. + + If you would like to enable this flag, open about:config and search for the + dom.storageManager.enabled option. If this option has a value of false, toggling it to + true may allow storage information to be calculated. +
+
+ +
+ If you are using Firefox for Android, you will have to make sure you have enough free space on your device to install dictionaries. +
+ +
+ +
+
+
-- cgit v1.2.3