web: more ipad accommodations and clean up
- moved all user agent toggles to (legacy) frontend, like it should have always been - removed unnecessary building
This commit is contained in:
parent
0e6ea09b16
commit
e2d1913043
5 changed files with 24 additions and 35 deletions
|
@ -1,4 +1,4 @@
|
|||
import { genericUserAgent, version, env } from "../modules/config.js";
|
||||
import { version, env } from "../modules/config.js";
|
||||
import { apiJSON, languageCode } from "../modules/sub/utils.js";
|
||||
import { Bright, Cyan } from "../modules/sub/consoleText.js";
|
||||
|
||||
|
@ -67,7 +67,7 @@ export async function runWeb(express, app, gitCommit, gitBranch, __dirname) {
|
|||
return res.status(200).end()
|
||||
});
|
||||
app.get("/", (req, res) => {
|
||||
return res.sendFile(`${__dirname}/${findRendered(languageCode(req), req.header('user-agent') ? req.header('user-agent') : genericUserAgent)}`)
|
||||
return res.sendFile(`${__dirname}/${findRendered(languageCode(req))}`)
|
||||
});
|
||||
app.get("/favicon.ico", (req, res) => {
|
||||
return res.sendFile(`${__dirname}/src/front/icons/favicon.ico`)
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
const ua = navigator.userAgent.toLowerCase();
|
||||
const isIOS = ua.includes("iphone os") || (ua.includes("mac os") && navigator.maxTouchPoints > 0);
|
||||
const isMobile = ua.includes("android") || ua.includes("iphone os");
|
||||
const isMobile = ua.includes("android") || isIOS;
|
||||
const isSafari = ua.includes("safari/");
|
||||
const isFirefox = ua.includes("firefox/");
|
||||
const isOldFirefox = ua.includes("firefox/") && ua.split("firefox/")[1].split('.')[0] < 103;
|
||||
|
@ -576,6 +576,14 @@ const loadSettings = () => {
|
|||
if (sGet("disableAnimations") === "true") {
|
||||
eid("cobalt-body").classList.add('no-animation');
|
||||
}
|
||||
if (!isMobile) {
|
||||
eid("cobalt-body").classList.add('desktop');
|
||||
}
|
||||
if (isIOS) {
|
||||
eid("download-switcher")
|
||||
.querySelector(".explanation")
|
||||
.innerHTML = loc.DownloadPopupDescriptionIOS;
|
||||
}
|
||||
for (let i = 0; i < checkboxes.length; i++) {
|
||||
try {
|
||||
if (sGet(checkboxes[i]) === "true") eid(checkboxes[i]).checked = true;
|
||||
|
|
|
@ -13,9 +13,6 @@ export async function buildFront(commitHash, branch) {
|
|||
// build html
|
||||
if (!fs.existsSync('./build/')){
|
||||
fs.mkdirSync('./build/');
|
||||
fs.mkdirSync('./build/ios/');
|
||||
fs.mkdirSync('./build/pc/');
|
||||
fs.mkdirSync('./build/mob/');
|
||||
}
|
||||
// get rid of old build path
|
||||
if (fs.existsSync('./min')) {
|
||||
|
@ -26,16 +23,9 @@ export async function buildFront(commitHash, branch) {
|
|||
let params = {
|
||||
"hash": commitHash,
|
||||
"lang": i,
|
||||
"useragent": "pc",
|
||||
"branch": branch
|
||||
}
|
||||
fs.writeFileSync(`./build/pc/${i}.html`, cleanHTML(page(params)));
|
||||
|
||||
params["useragent"] = "iphone os";
|
||||
fs.writeFileSync(`./build/ios/${i}.html`, cleanHTML(page(params)));
|
||||
|
||||
params["useragent"] = "android";
|
||||
fs.writeFileSync(`./build/mob/${i}.html`, cleanHTML(page(params)));
|
||||
fs.writeFileSync(`./build/${i}.html`, cleanHTML(page(params)));
|
||||
}
|
||||
// build js & css
|
||||
await esbuild.build({
|
||||
|
@ -45,7 +35,7 @@ export async function buildFront(commitHash, branch) {
|
|||
loader: { '.js': 'js', '.css': 'css', },
|
||||
charset: 'utf8'
|
||||
})
|
||||
} catch (e) {
|
||||
} catch {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,11 +1,6 @@
|
|||
import { languageList } from "../../localization/manager.js";
|
||||
|
||||
export default function(lang, userAgent) {
|
||||
export default function(lang) {
|
||||
let language = languageList.includes(lang) ? lang : "en";
|
||||
|
||||
let ua = userAgent.toLowerCase();
|
||||
let platform = (ua.match("android") || ua.match("iphone os")) ? "mob" : "pc";
|
||||
if (platform === "mob" && ua.match("iphone os")) platform = "ios";
|
||||
|
||||
return `/build/${platform}/${language}.html`;
|
||||
return `/build/${language}.html`;
|
||||
}
|
||||
|
|
|
@ -47,14 +47,9 @@ for (let i in donations["crypto"]) {
|
|||
}
|
||||
|
||||
export default function(obj) {
|
||||
const t = (str, replace) => { return loc(obj.lang, str, replace) };
|
||||
|
||||
let ua = obj.useragent.toLowerCase();
|
||||
let isIOS = ua.match("iphone os");
|
||||
let isMobile = ua.match("android") || ua.match("iphone os");
|
||||
|
||||
let platform = isMobile ? "m" : "d";
|
||||
if (isMobile && isIOS) platform = "i";
|
||||
const t = (str, replace) => {
|
||||
return loc(obj.lang, str, replace)
|
||||
}
|
||||
|
||||
audioFormats[0]["text"] = t('SettingsAudioFormatBest');
|
||||
|
||||
|
@ -64,7 +59,7 @@ export default function(obj) {
|
|||
<html lang="${obj.lang}">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="viewport-fit=cover, width=device-width, height=device-height, initial-scale=1, maximum-scale=${isIOS ? `1` : `5`}">
|
||||
<meta name="viewport" content="viewport-fit=cover, width=device-width, height=device-height, initial-scale=1, maximum-scale=1">
|
||||
|
||||
<title>${t("AppTitleCobalt")}</title>
|
||||
|
||||
|
@ -103,7 +98,7 @@ export default function(obj) {
|
|||
></script>`
|
||||
: ''}
|
||||
</head>
|
||||
<body id="cobalt-body" ${platform === "d" ? 'class="desktop"' : ''}>
|
||||
<body id="cobalt-body">
|
||||
<noscript>
|
||||
<div style="margin: 2rem;">${t('NoScriptMessage')}</div>
|
||||
</noscript>
|
||||
|
@ -314,7 +309,7 @@ export default function(obj) {
|
|||
closeAria: t('AccessibilityGoBack'),
|
||||
header: {
|
||||
aboveTitle: {
|
||||
text: `v.${version}-${obj.hash}${platform} (${obj.branch})`,
|
||||
text: `v.${version}-${obj.hash} (${obj.branch})`,
|
||||
url: `${repo}/commit/${obj.hash}`
|
||||
},
|
||||
title: `${emoji("⚙️", 30)} ${t('TitlePopupSettings')}`
|
||||
|
@ -562,7 +557,7 @@ export default function(obj) {
|
|||
},
|
||||
body: switcher({
|
||||
name: "download",
|
||||
explanation: `${!isIOS ? t('DownloadPopupDescription') : t('DownloadPopupDescriptionIOS')}`,
|
||||
explanation: t('DownloadPopupDescription'),
|
||||
items: `<a id="pd-download" class="switch full" target="_blank" href="/"><span>${t('Download')}</span></a>
|
||||
<div id="pd-share" class="switch full">${t('ShareURL')}</div>
|
||||
<div id="pd-copy" class="switch full">${t('CopyURL')}</div>`
|
||||
|
@ -656,7 +651,8 @@ export default function(obj) {
|
|||
'DataTransferError',
|
||||
'FilenamePreviewVideoTitle',
|
||||
'FilenamePreviewAudioTitle',
|
||||
'FilenamePreviewAudioAuthor'
|
||||
'FilenamePreviewAudioAuthor',
|
||||
'DownloadPopupDescriptionIOS'
|
||||
])}
|
||||
</script>
|
||||
<script src="cobalt.js"></script>
|
||||
|
|
Loading…
Reference in a new issue