import { services, appName, authorInfo, version, quality, repo, donations, supportedAudio } from "../config.js"; import { getCommitInfo } from "../sub/currentCommit.js"; import loc from "../../localization/manager.js"; import { backdropLink, checkbox, footerButtons, multiPagePopup, popup, settingsCategory, switcher } from "./elements.js"; import emoji from "../emoji.js"; let s = services; let com = getCommitInfo(); let enabledServices = Object.keys(s).filter((p) => { if (s[p].enabled) return true; }).sort().map((p) => { return s[p].alias ? s[p].alias : p }).join(', ') let donate = `` let donateLinks = `` let audioFormats = supportedAudio.map((p) => { return {"action": p} }) audioFormats.unshift({ "action": "best" }) for (let i in donations["other"]) { donateLinks += `${i}` } let extr = '' for (let i in donations["crypto"]) { donate += `
${i} (REPLACEME)
${donations["crypto"][i]}
` extr = ' extra' } export default function(obj) { audioFormats[0]["text"] = loc(obj.lang, 'SettingsAudioFormatBest') let isIOS = obj.useragent.toLowerCase().match("iphone os") try { return ` ${appName} ${multiPagePopup({ name: "about", closeAria: loc(obj.lang, 'AccessibilityClosePopup'), tabs: [{ name: "about", title: `${emoji("🐲")} ${loc(obj.lang, 'AboutTab')}`, content: popup({ embed: true, name: "about", header: { aboveTitle: { text: loc(obj.lang, 'MadeWithLove'), url: authorInfo.link }, closeAria: loc(obj.lang, 'AccessibilityClosePopup'), title: loc(obj.lang, 'TitlePopupAbout') }, body: [{ text: loc(obj.lang, 'AboutSummary') }, { text: `${loc(obj.lang, 'AboutSupportedServices')} ${enabledServices}.` }, { text: backdropLink(repo, loc(obj.lang, 'LinkGitHubIssues')), classes: ["bottom-link"] }] }) }, { name: "changelog", title: `${emoji("🎉")} ${loc(obj.lang, 'ChangelogTab')}`, content: popup({ embed: true, name: "changelog", header: { closeAria: loc(obj.lang, 'AccessibilityClosePopup'), title: `${emoji("🪄", 30)} ${loc(obj.lang, 'TitlePopupChangelog')}` }, body: [{ text: `
${loc(obj.lang, 'ChangelogLastMajor')}
`, raw: true }, { text: loc('en', 'ChangelogContentTitle'), classes: ["changelog-subtitle"], nopadding: true }, { text: loc('en', 'ChangelogContent') }, { text: `
${loc(obj.lang, 'ChangelogLastCommit')}
`, raw: true }, { text: `${com[0]} (${obj.hash})`, classes: ["changelog-subtitle"], nopadding: true }, { text: com[1] }, { text: backdropLink(`${repo}/commits`, loc(obj.lang, 'LinkGitHubChanges')), classes: ["bottom-link"] }] }) }, { name: "donate", title: `${emoji("💰")} ${loc(obj.lang, 'DonationsTab')}`, content: popup({ embed: true, name: "donate", header: { closeAria: loc(obj.lang, 'AccessibilityClosePopup'), title: emoji("💸", 30) + loc(obj.lang, 'TitlePopupDonate'), subtitle: loc(obj.lang, 'DonateSubtitle') }, body: [{ text: donateLinks, raw: true }, { text: loc(obj.lang, 'DonateLinksDescription'), classes: ["explanation"] }, { text: donate.replace(/REPLACEME/g, loc(obj.lang, 'ClickToCopy')) }, { text: loc(obj.lang, 'DonateDescription'), classes: ["explanation", "no-top-padding"] }, { text: backdropLink(authorInfo.contact, loc(obj.lang, 'LinkDonateContact')), classes: ["bottom-link"] }] }) }], })} ${multiPagePopup({ name: "settings", closeAria: loc(obj.lang, 'AccessibilityClosePopup'), header: { aboveTitle: { text: `v.${version} ~ ${obj.hash}`, url: repo }, title: `${emoji("⚙️", 30)} ${loc(obj.lang, 'TitlePopupSettings')}` }, tabs: [{ name: "video", title: `${emoji("🎬")} ${loc(obj.lang, 'SettingsVideoTab')}`, content: settingsCategory({ name: "downloads", title: loc(obj.lang, 'SettingsDownloadsSubtitle'), body: switcher({ name: "quality", subtitle: loc(obj.lang, 'SettingsQualitySubtitle'), explanation: loc(obj.lang, 'SettingsQualityDescription'), items: [{ "action": "max", "text": loc(obj.lang, 'SettingsQualitySwitchMax') }, { "action": "hig", "text": `${loc(obj.lang, 'SettingsQualitySwitchHigh')}(${quality.hig}p)` }, { "action": "mid", "text": `${loc(obj.lang, 'SettingsQualitySwitchMedium')}(${quality.mid}p)` }, { "action": "low", "text": `${loc(obj.lang, 'SettingsQualitySwitchLow')}(${quality.low}p)` }] }) }) + `${!isIOS ? checkbox("downloadPopup", loc(obj.lang, 'SettingsEnableDownloadPopup'), loc(obj.lang, 'AccessibilityEnableDownloadPopup')) : ''}` + settingsCategory({ name: "youtube", body: switcher({ name: "ytFormat", subtitle: loc(obj.lang, 'SettingsFormatSubtitle'), explanation: loc(obj.lang, 'SettingsFormatDescription'), items: [{ "action": "mp4" }, { "action": "webm" }] }) }) }, { name: "audio", title: `${emoji("🎶")} ${loc(obj.lang, 'SettingsAudioTab')}`, content: settingsCategory({ name: "general", title: loc(obj.lang, 'SettingsAudioTab'), body: switcher({ name: "audioFormat", subtitle: loc(obj.lang, 'SettingsFormatSubtitle'), explanation: loc(obj.lang, 'SettingsAudioFormatDescription'), items: audioFormats }) }) }, { name: "other", title: `${emoji("🪅")} ${loc(obj.lang, 'SettingsOtherTab')}`, content: settingsCategory({ name: "appearance", title: loc(obj.lang, 'SettingsAppearanceSubtitle'), body: switcher({ name: "theme", subtitle: loc(obj.lang, 'SettingsThemeSubtitle'), items: [{ "action": "auto", "text": loc(obj.lang, 'SettingsThemeAuto') },{ "action": "dark", "text": loc(obj.lang, 'SettingsThemeDark') },{ "action": "light", "text": loc(obj.lang, 'SettingsThemeLight') }] }) }) + checkbox("alwaysVisibleButton", loc(obj.lang, 'SettingsKeepDownloadButton'), loc(obj.lang, 'AccessibilityKeepDownloadButton')) + checkbox("disableChangelog", loc(obj.lang, 'SettingsDisableChangelogOnUpdate'), loc(obj.lang, 'SettingsDisableChangelogOnUpdate')) }], })} ${popup({ name: "download", header: { closeAria: loc(obj.lang, 'AccessibilityClosePopup'), subtitle: loc(obj.lang, 'TitlePopupDownload') }, body: switcher({ name: "download", subtitle: loc(obj.lang, 'DownloadPopupWayToSave'), explanation: `${!isIOS ? loc(obj.lang, 'DownloadPopupDescription') : loc(obj.lang, 'DownloadPopupDescriptionIOS')}`, items: `${loc(obj.lang, 'Download')}
${loc(obj.lang, 'CopyURL')}
` }) })} ${popup({ name: "error", header: { closeAria: loc(obj.lang, 'AccessibilityClosePopup'), title: loc(obj.lang, 'TitlePopupError') }, body: `
` })} `; } catch (err) { return `${loc(obj.lang, 'ErrorPageRenderFail', obj.hash)}`; } }