From 21e87a6412b4dac679846884af16f744bc152eca Mon Sep 17 00:00:00 2001 From: ManeraKai Date: Mon, 30 Jan 2023 15:46:10 +0300 Subject: Fixed locales and other typing stuff --- src/pages/background/background.js | 2 +- src/pages/options/index.js | 16 +++++++++------- src/pages/options/init.js | 5 ++++- src/pages/options/widgets/about.pug | 25 ------------------------- src/pages/options/widgets/general.pug | 6 +++--- src/pages/options/widgets/services.pug | 10 +++++----- src/pages/stylesheets/styles.css | 7 ++----- src/pages/widgets/links.pug | 2 +- src/pages/widgets/switches.pug | 2 +- 9 files changed, 26 insertions(+), 49 deletions(-) delete mode 100644 src/pages/options/widgets/about.pug (limited to 'src/pages') diff --git a/src/pages/background/background.js b/src/pages/background/background.js index d5160ff2..d78efc24 100644 --- a/src/pages/background/background.js +++ b/src/pages/background/background.js @@ -104,7 +104,7 @@ browser.contextMenus.create({ browser.contextMenus.create({ id: "redirectToOriginal", - title: 'Redirect to original', + title: browser.i18n.getMessage("redirectToOriginal"), contexts: ["browser_action"], }) diff --git a/src/pages/options/index.js b/src/pages/options/index.js index 7b560248..c6c21095 100644 --- a/src/pages/options/index.js +++ b/src/pages/options/index.js @@ -6,11 +6,13 @@ let config, divs = {} for (const a of document.getElementById("links").getElementsByTagName("a")) { - a.addEventListener("click", e => { - const path = a.getAttribute("href").replace("#", "") - loadPage(path) - e.preventDefault() - }) + if (!a.href.includes("https://")) { + a.addEventListener("click", e => { + const path = a.getAttribute("href").replace("#", "") + loadPage(path) + e.preventDefault() + }) + } } config = await utils.getConfig() @@ -55,7 +57,7 @@ async function loadPage(path) { window.history.pushState({ id: "100" }, "Page 2", `/pages/options/index.html#${path}`) - if (path != 'general' && path != 'about') { + if (path != 'general') { const service = path; divs[service] = {} @@ -72,7 +74,7 @@ async function loadPage(path) { else options[service][option] = divs[service][option].value browser.storage.local.set({ options }) - changeFrontendsSettings(service) + changeFrontendsSettings(service) }) } diff --git a/src/pages/options/init.js b/src/pages/options/init.js index aab66f93..5883aafa 100644 --- a/src/pages/options/init.js +++ b/src/pages/options/init.js @@ -40,7 +40,10 @@ function changeTheme() { } changeTheme() -if (["ar", "iw", "ku", "fa", "ur"].includes(browser.i18n.getUILanguage())) document.getElementsByTagName("body")[0].classList.add("rtl") +if (["ar", "iw", "ku", "fa", "ur"].includes(browser.i18n.getUILanguage())) { + document.getElementsByTagName("body")[0].classList.add("rtl") + document.getElementsByTagName("body")[0].dir = "rtl" +} localise.localisePage() window.matchMedia("(prefers-color-scheme: dark)").addEventListener("change", changeTheme) diff --git a/src/pages/options/widgets/about.pug b/src/pages/options/widgets/about.pug deleted file mode 100644 index 64d88501..00000000 --- a/src/pages/options/widgets/about.pug +++ /dev/null @@ -1,25 +0,0 @@ -section(class="option-block" id="about_page") - div(class="some-block option-block") - h1 - a(target="_blank" data-localise="__MSG_about__" href="https://libredirect.github.io") About - hr - div(class="about") - div(class="some-block option-block") - h4 Donate: ♥️ - h4 - a(href="https://libredirect.github.io/donate" target="_blank") https://libredirect.github.io/donate - - div(class="some-block option-block") - h4 FAQ: - h4 - a(href="https://libredirect.github.io/faq" target="_blank") https://libredirect.github.io/faq - - div(class="some-block option-block") - h4 Docs: - h4 - a(href="https://libredirect.github.io/docs" target="_blank") https://libredirect.github.io/docs - - div(class="some-block option-block") - h4 Source Code: - h4 - a(href="https://libredirect.github.io/source_code" target="_blank") https://libredirect.github.io/source_code \ No newline at end of file diff --git a/src/pages/options/widgets/general.pug b/src/pages/options/widgets/general.pug index 8a3f1859..eafd3e79 100644 --- a/src/pages/options/widgets/general.pug +++ b/src/pages/options/widgets/general.pug @@ -6,12 +6,12 @@ section(class="option-block" id="general_page") div(class="some-block option-block") h4(data-localise="__MSG_theme__") Theme select#theme - option(value="detect" data-localise="__MSG_detect__") Detect + option(value="detect" data-localise="__MSG_auto__") Auto option(value="light" data-localise="__MSG_light__") Light option(value="dark" data-localise="__MSG_dark__") Dark div(class="some-block option-block") - h4(data-localise="__MSG_exclude_from_redirecting_") Excluded from redirecting + h4(data-localise="__MSG_excludeFromRedirecting__") Excluded from redirecting form(id="custom-exceptions-instance-form") div(class="some-block option-block") @@ -52,6 +52,6 @@ section(class="option-block" id="general_page") svg(xmlns="http://www.w3.org/2000/svg" enable-background="new 0 0 24 24" height="24px" viewBox="0 0 24 24" width="24px" fill="currentColor") path(d="M12,5V2L8,6l4,4V7c3.31,0,6,2.69,6,6c0,2.97-2.17,5.43-5,5.91v2.02c3.95-0.49,7-3.85,7-7.93C20,8.58,16.42,5,12,5z") path(d="M6,13c0-1.65,0.67-3.15,1.76-4.24L6.34,7.34C4.9,8.79,4,10.79,4,13c0,4.08,3.05,7.44,7,7.93v-2.02 C8.17,18.43,6,15.97,6,13z") - x(localise="__MSG_resetSettings__") Reset Settings + x(data-localise="__MSG_resetSettings__") Reset Settings script(type="module" src="./widgets/general.js") \ No newline at end of file diff --git a/src/pages/options/widgets/services.pug b/src/pages/options/widgets/services.pug index b5f330cc..79d20535 100644 --- a/src/pages/options/widgets/services.pug +++ b/src/pages/options/widgets/services.pug @@ -2,7 +2,7 @@ each val, service in services section(class="option-block" id=service+"_page") div(class="some-block option-block") h1 - a(target="_blank" href=services[service].url)=services[service].name + a(target="_blank" href=services[service].url data-localise=`__MSG_${service}__`)=services[service].name hr @@ -13,7 +13,7 @@ each val, service in services div(id=service+"-opacity") div(class="some-block option-block") - h4(data-localise="__MSG_show_in_popup__") Show in Popup + h4(data-localise="__MSG_showInPopup__") Show in popup input(id=service type="checkbox") if Object.keys(services[service].frontends).length> 1 @@ -40,9 +40,9 @@ each val, service in services each val, frontend in services[service].frontends if services[service].frontends[frontend].instanceList - div(id=frontend) - div(class="some-block option-block") - h4(data-localise="__MSG_instances__") Add your favorite instances + div(id=frontend dir="ltr") + div(dir="auto" class="some-block option-block") + h4(data-localise="__MSG_addYourFavoriteInstances__") Add your favorite instances form(class="custom-instance-form") div(class="some-block option-block") diff --git a/src/pages/stylesheets/styles.css b/src/pages/stylesheets/styles.css index fc089728..5f3c1cbe 100644 --- a/src/pages/stylesheets/styles.css +++ b/src/pages/stylesheets/styles.css @@ -28,6 +28,7 @@ body { margin: auto; padding: 0; font-family: "Inter"; + font-size: 16px; background-color: var(--bg-main); color: var(--text); } @@ -325,10 +326,6 @@ button svg { color: var(--text); } -div.checklist { - direction: ltr; -} - div.checklist div { justify-content: space-between; margin: 5px 15px; @@ -390,7 +387,7 @@ div.disabled { body.light-theme { --text: black; --bg-main: white; - --bg-secondary: #fff; + --bg-secondary: #e4e4e4; --active: #fb9817; } diff --git a/src/pages/widgets/links.pug b/src/pages/widgets/links.pug index cc7f86fe..2421a24a 100644 --- a/src/pages/widgets/links.pug +++ b/src/pages/widgets/links.pug @@ -15,7 +15,7 @@ section(class="links" id="links") span(data-localise="__MSG_"+key+"__")=services[key].name div(class="title") - a(href="#about") + a(target="_blank" href="https://libredirect.github.io") img(class='dark' src="/assets/images/about-icon.svg") img(class='light' src="/assets/images/about-icon-light.svg") diff --git a/src/pages/widgets/switches.pug b/src/pages/widgets/switches.pug index 6b6f0c2b..2dfad676 100644 --- a/src/pages/widgets/switches.pug +++ b/src/pages/widgets/switches.pug @@ -1,6 +1,6 @@ each val, service in services div(class=service + " some-block") - a(class="title" href=`/pages/options/index.html#${services[service].name.toLowerCase()}`) + a(class="title" href=services[service].url) if services[service].imageType == 'svgMono' img(class='dark' src=`/assets/images/${service}-icon.svg`) img(class='light' src=`/assets/images/${service}-icon-light.svg`) -- cgit 1.4.1