From 56c452280fc23e22f92e70f2524abd65ba59e2bc Mon Sep 17 00:00:00 2001 From: blueb Date: Mon, 21 Aug 2023 19:27:45 -0400 Subject: [PATCH] add servers & css for them --- src/front/cobalt.css | 18 +++++++++++++++++ src/localization/languages/en.json | 2 ++ src/modules/pageRender/elements.js | 24 +++++++++++++++++++++-- src/modules/pageRender/page.js | 31 ++++++++++++++++++++++++++++++ 4 files changed, 73 insertions(+), 2 deletions(-) diff --git a/src/front/cobalt.css b/src/front/cobalt.css index 8e666dde..8cad317b 100644 --- a/src/front/cobalt.css +++ b/src/front/cobalt.css @@ -1192,4 +1192,22 @@ button:active, .popup-title { line-height: inherit; } +} + +.switches-vertical { + display: flex; + width: auto; + flex-direction: column; + flex-wrap: nowrap; + overflow-x: scroll; +} +.switch-vertical.first { + border-top-left-radius: 5px 6px!important; + border-top-right-radius: 5px 6px!important; + border-bottom-left-radius: 0px; +} +.switch-vertical.last { + border-bottom-left-radius: 5px 6px!important; + border-bottom-right-radius: 5px 6px!important; + border-top-right-radius: 0px; } \ No newline at end of file diff --git a/src/localization/languages/en.json b/src/localization/languages/en.json index b087f998..3c7fec7d 100644 --- a/src/localization/languages/en.json +++ b/src/localization/languages/en.json @@ -41,6 +41,8 @@ "SettingsThemeLight": "light", "SettingsThemeDark": "dark", "SettingsKeepDownloadButton": "keep >> visible", + "SettingsServerPicker": "server picker", + "SettingsServerPickerDescription": "choose which server to download from", "AccessibilityKeepDownloadButton": "keep the download button always visible", "SettingsEnableDownloadPopup": "ask how to save", "AccessibilityEnableDownloadPopup": "ask what to do with downloads", diff --git a/src/modules/pageRender/elements.js b/src/modules/pageRender/elements.js index 66e6de19..b445b7fb 100644 --- a/src/modules/pageRender/elements.js +++ b/src/modules/pageRender/elements.js @@ -13,6 +13,13 @@ export function switcher(obj) { let items = ``; if (obj.name === "download") { items = obj.items; + } else if (obj.vertical) { + for (let i = 0; i < obj.items.length; i++) { + let classes = obj.items[i]["classes"] ? obj.items[i]["classes"] : []; + if (i === 0) classes.push("first"); + if (i === (obj.items.length - 1)) classes.push("last"); + items += `` + } } else { for (let i = 0; i < obj.items.length; i++) { let classes = obj.items[i]["classes"] ? obj.items[i]["classes"] : []; @@ -22,12 +29,25 @@ export function switcher(obj) { } } - if (obj.noParent) return `
${items}
`; - return `
+ if (obj.noParent && obj.vertical) { + return `
${items}
` + } else if (obj.noParent) { + return `
${items}
` + } + + if (obj.vertical) { + return `
+ ${obj.subtitle ? `
${obj.subtitle}
` : ``} +
${items}
+ ${obj.explanation ? `
${obj.explanation}
` : ``} +
` + } else { + return `
${obj.subtitle ? `
${obj.subtitle}
` : ``}
${items}
${obj.explanation ? `
${obj.explanation}
` : ``}
` + } } export function checkbox(obj) { let paddings = ["bottom-margin", "top-margin", "no-margin", "top-margin-only"]; diff --git a/src/modules/pageRender/page.js b/src/modules/pageRender/page.js index 50d756f5..ba7bbf8f 100644 --- a/src/modules/pageRender/page.js +++ b/src/modules/pageRender/page.js @@ -451,6 +451,37 @@ export default function(obj) { aria: t("AccessibilityEnableDownloadPopup") }]) }) + + settingsCategory({ + name: "serverpicker", + title: t('SettingsServerPicker'), + explanation: t('SettingsServerPickerDescription'), + body: switcher({ + name: "serverpicker", + vertical: true, + items: [{ + action: "co.wuk.sh", + text: "co.wuk.sh" + }, { + action: "api.c0ba.lt", + text: "api.c0ba.lt" + }, { + action: "co-api.blueb.me", + text: "co-api.blueb.me" + }, { + action: "wukko.wolfdo.gg", + text: "wukko.wolfdo.gg" + }, { + action: "api.co.749.city", + text: "api.co.749.city" + }, { + action: "cobalt-api.fluffy.tools", + text: "cobalt-api.fluffy.tools" + }, { + action: "capi.oak.li", + text: "capi.oak.li" + }] + }) + }) }], })} ${popupWithBottomButtons({