aboutsummaryrefslogtreecommitdiff
path: root/ext/bg/js/settings.js
diff options
context:
space:
mode:
Diffstat (limited to 'ext/bg/js/settings.js')
-rw-r--r--ext/bg/js/settings.js49
1 files changed, 24 insertions, 25 deletions
diff --git a/ext/bg/js/settings.js b/ext/bg/js/settings.js
index 75082f3e..cdcdae77 100644
--- a/ext/bg/js/settings.js
+++ b/ext/bg/js/settings.js
@@ -116,7 +116,7 @@ async function formMainDictionaryOptionsPopulate(options) {
select.append($('<option class="text-muted" value="">Not selected</option>'));
let mainDictionary = '';
- for (const dictRow of await utilDatabaseSummarize()) {
+ for (const dictRow of toIterable(await utilDatabaseSummarize())) {
if (dictRow.sequenced) {
select.append($(`<option value="${dictRow.title}">${dictRow.title}</option>`));
if (dictRow.title === options.general.mainDictionary) {
@@ -314,12 +314,12 @@ async function dictionaryGroupsPopulate(options) {
const dictGroups = $('#dict-groups').empty();
const dictWarning = $('#dict-warning').hide();
- const dictRows = await utilDatabaseSummarize();
+ const dictRows = toIterable(await utilDatabaseSummarize());
if (dictRows.length === 0) {
dictWarning.show();
}
- for (const dictRow of dictRowsSort(dictRows, options)) {
+ for (const dictRow of toIterable(dictRowsSort(dictRows, options))) {
const dictOptions = options.dictionaries[dictRow.title] || {
enabled: false,
priority: 0,
@@ -581,26 +581,25 @@ async function onAnkiFieldTemplatesReset(e) {
*/
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";
- }
+ if (EXTENSION_IS_BROWSER_EDGE) {
+ return 'edge';
+ }
+ if (typeof browser !== 'undefined') {
+ try {
+ const info = await browser.runtime.getBrowserInfo();
+ if (info.name === 'Fennec') {
+ return 'firefox-mobile';
+ }
+ } catch (e) { }
+ return 'firefox';
} else {
- return "edge";
+ return 'chrome';
}
}
function storageBytesToLabeledString(size) {
const base = 1000;
- const labels = ["bytes", "KB", "MB", "GB"];
+ const labels = ['bytes', 'KB', 'MB', 'GB'];
let labelIndex = 0;
while (size >= base) {
size /= base;
@@ -620,14 +619,14 @@ storageEstimate.mostRecent = null;
async function storageInfoInitialize() {
const browser = await getBrowser();
- const container = document.querySelector("#storage-info");
- container.setAttribute("data-browser", browser);
+ const container = document.querySelector('#storage-info');
+ container.setAttribute('data-browser', browser);
await storageShowInfo();
- container.classList.remove("storage-hidden");
+ container.classList.remove('storage-hidden');
- document.querySelector("#storage-refresh").addEventListener('click', () => storageShowInfo(), false);
+ document.querySelector('#storage-refresh').addEventListener('click', () => storageShowInfo(), false);
}
async function storageUpdateStats() {
@@ -637,8 +636,8 @@ async function storageUpdateStats() {
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-usage').textContent = storageBytesToLabeledString(estimate.usage);
+ document.querySelector('#storage-quota').textContent = storageBytesToLabeledString(estimate.quota);
}
storageUpdateStats.isUpdating = false;
@@ -650,8 +649,8 @@ async function storageShowInfo() {
storageSpinnerShow(true);
const valid = await storageUpdateStats();
- document.querySelector("#storage-use").classList.toggle("storage-hidden", !valid);
- document.querySelector("#storage-error").classList.toggle("storage-hidden", valid);
+ document.querySelector('#storage-use').classList.toggle('storage-hidden', !valid);
+ document.querySelector('#storage-error').classList.toggle('storage-hidden', valid);
storageSpinnerShow(false);
}