mirror of
https://github.com/imputnet/cobalt.git
synced 2025-07-21 12:48:28 +00:00
minor formatting overhaul (semicolons, removal of curly brackets, etc)
This commit is contained in:
parent
149e4dcf10
commit
5530ef6661
@ -26,14 +26,14 @@ const webMode = process.env.webURL && process.env.apiURL;
|
||||
|
||||
if (apiMode) {
|
||||
const { runAPI } = await import('./core/api.js');
|
||||
runAPI(express, app, gitCommit, gitBranch, __dirname)
|
||||
runAPI(express, app, gitCommit, gitBranch, __dirname);
|
||||
} else if (webMode) {
|
||||
const { runWeb } = await import('./core/web.js');
|
||||
await runWeb(express, app, gitCommit, gitBranch, __dirname)
|
||||
await runWeb(express, app, gitCommit, gitBranch, __dirname);
|
||||
} else {
|
||||
console.log(
|
||||
Red(`cobalt wasn't configured yet or configuration is invalid.\n`)
|
||||
+ Bright(`please run the setup script to fix this: `)
|
||||
+ Green(`npm run setup`)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
@ -119,7 +119,7 @@ export function runAPI(express, app, gitCommit, gitBranch, __dirname) {
|
||||
switch (req.params.type) {
|
||||
case 'stream':
|
||||
if (req.query.t && req.query.h && req.query.e && req.query.t.toString().length === 21
|
||||
&& req.query.h.toString().length === 64 && req.query.e.toString().length === 13) {
|
||||
&& req.query.h.toString().length === 64 && req.query.e.toString().length === 13) {
|
||||
let streamInfo = verifyStream(req.query.t, req.query.h, req.query.e);
|
||||
if (streamInfo.error) {
|
||||
return res.status(streamInfo.status).json(apiJSON(0, { t: streamInfo.error }).body);
|
||||
@ -132,8 +132,8 @@ export function runAPI(express, app, gitCommit, gitBranch, __dirname) {
|
||||
return stream(res, streamInfo);
|
||||
} else {
|
||||
let j = apiJSON(0, {
|
||||
t: "stream token, hmac, or expiry timestamp is missing"
|
||||
})
|
||||
t: "stream token, hmac, or expiry timestamp is missing",
|
||||
});
|
||||
return res.status(j.status).json(j.body);
|
||||
}
|
||||
case 'serverInfo':
|
||||
@ -149,7 +149,7 @@ export function runAPI(express, app, gitCommit, gitBranch, __dirname) {
|
||||
default:
|
||||
let j = apiJSON(0, {
|
||||
t: "unknown response type"
|
||||
})
|
||||
});
|
||||
return res.status(j.status).json(j.body);
|
||||
}
|
||||
} catch (e) {
|
||||
@ -160,13 +160,13 @@ export function runAPI(express, app, gitCommit, gitBranch, __dirname) {
|
||||
}
|
||||
});
|
||||
app.get('/api/status', (req, res) => {
|
||||
res.status(200).end()
|
||||
res.status(200).end();
|
||||
});
|
||||
app.get('/favicon.ico', (req, res) => {
|
||||
res.sendFile(`${__dirname}/src/front/icons/favicon.ico`)
|
||||
res.sendFile(`${__dirname}/src/front/icons/favicon.ico`);
|
||||
});
|
||||
app.get('/*', (req, res) => {
|
||||
res.redirect('/api/json')
|
||||
res.redirect('/api/json');
|
||||
});
|
||||
|
||||
app.listen(process.env.apiPort || 9000, () => {
|
||||
@ -175,6 +175,6 @@ export function runAPI(express, app, gitCommit, gitBranch, __dirname) {
|
||||
`Start time: ${Bright(`${startTime.toUTCString()} (${startTimestamp})`)}\n\n` +
|
||||
`URL: ${Cyan(`${process.env.apiURL}`)}\n` +
|
||||
`Port: ${process.env.apiPort || 9000}\n`
|
||||
)
|
||||
);
|
||||
});
|
||||
}
|
||||
|
@ -31,49 +31,48 @@ export async function runWeb(express, app, gitCommit, gitBranch, __dirname) {
|
||||
case "0":
|
||||
r = changelogHistory();
|
||||
j = r ? apiJSON(3, { t: r }) : apiJSON(0, {
|
||||
t: "couldn't render this block, please try again!"
|
||||
})
|
||||
t: "couldn't render this block, please try again!",
|
||||
});
|
||||
break;
|
||||
// celebrations emoji
|
||||
case "1":
|
||||
r = celebrationsEmoji();
|
||||
j = r ? apiJSON(3, { t: r }) : false
|
||||
j = r ? apiJSON(3, { t: r }) : false;
|
||||
break;
|
||||
default:
|
||||
j = apiJSON(0, {
|
||||
t: "couldn't find a block with this id"
|
||||
})
|
||||
});
|
||||
break;
|
||||
}
|
||||
if (j.body) {
|
||||
if (j.body)
|
||||
return res.status(j.status).json(j.body);
|
||||
} else {
|
||||
else
|
||||
return res.status(204).end();
|
||||
}
|
||||
} else {
|
||||
return res.status(400).json({
|
||||
status: "error",
|
||||
text: "couldn't render this block, please try again!"
|
||||
text: "couldn't render this block, please try again!",
|
||||
});
|
||||
}
|
||||
} catch (e) {
|
||||
return res.status(400).json({
|
||||
status: "error",
|
||||
text: "couldn't render this block, please try again!"
|
||||
})
|
||||
text: "couldn't render this block, please try again!",
|
||||
});
|
||||
}
|
||||
});
|
||||
app.get("/status", (req, res) => {
|
||||
return res.status(200).end()
|
||||
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), req.header('user-agent') ? req.header('user-agent') : genericUserAgent)}`);
|
||||
});
|
||||
app.get("/favicon.ico", (req, res) => {
|
||||
return res.sendFile(`${__dirname}/src/front/icons/favicon.ico`)
|
||||
return res.sendFile(`${__dirname}/src/front/icons/favicon.ico`);
|
||||
});
|
||||
app.get("/*", (req, res) => {
|
||||
return res.redirect('/')
|
||||
return res.redirect('/');
|
||||
});
|
||||
|
||||
app.listen(process.env.webPort || 9001, () => {
|
||||
@ -82,6 +81,6 @@ export async function runWeb(express, app, gitCommit, gitBranch, __dirname) {
|
||||
`Start time: ${Bright(`${startTime.toUTCString()} (${startTimestamp})`)}\n\n` +
|
||||
`URL: ${Cyan(`${process.env.webURL}`)}\n` +
|
||||
`Port: ${process.env.webPort || 9001}\n`
|
||||
)
|
||||
})
|
||||
);
|
||||
});
|
||||
}
|
||||
|
@ -1018,7 +1018,7 @@ button:active,
|
||||
/* adapt the page according to screen size */
|
||||
@media screen and (max-width: 1550px) {
|
||||
.popup.small {
|
||||
width: 25%
|
||||
width: 25%;
|
||||
}
|
||||
.popup {
|
||||
width: 40%;
|
||||
@ -1026,7 +1026,7 @@ button:active,
|
||||
}
|
||||
@media screen and (max-width: 1440px) {
|
||||
.popup.small {
|
||||
width: 30%
|
||||
width: 30%;
|
||||
}
|
||||
.popup {
|
||||
width: 45%;
|
||||
@ -1039,7 +1039,7 @@ button:active,
|
||||
}
|
||||
@media screen and (max-width: 1200px) {
|
||||
.popup.small {
|
||||
width: 35%
|
||||
width: 35%;
|
||||
}
|
||||
.popup {
|
||||
width: 55%;
|
||||
@ -1047,7 +1047,7 @@ button:active,
|
||||
}
|
||||
@media screen and (max-width: 1025px) {
|
||||
.popup.small {
|
||||
width: 40%
|
||||
width: 40%;
|
||||
}
|
||||
.popup {
|
||||
width: 60%;
|
||||
|
@ -42,23 +42,23 @@ const pageQuery = new URLSearchParams(window.location.search);
|
||||
let store = {};
|
||||
|
||||
function fixApiUrl(url) {
|
||||
return url.endsWith('/') ? url.slice(0, -1) : url
|
||||
return url.endsWith('/') ? url.slice(0, -1) : url;
|
||||
}
|
||||
|
||||
let apiURL = fixApiUrl(defaultApiUrl);
|
||||
|
||||
function changeApi(url) {
|
||||
apiURL = fixApiUrl(url);
|
||||
return true
|
||||
return true;
|
||||
}
|
||||
function eid(id) {
|
||||
return document.getElementById(id)
|
||||
return document.getElementById(id);
|
||||
}
|
||||
function sGet(id) {
|
||||
return localStorage.getItem(id)
|
||||
return localStorage.getItem(id);
|
||||
}
|
||||
function sSet(id, value) {
|
||||
localStorage.setItem(id, value)
|
||||
localStorage.setItem(id, value);
|
||||
}
|
||||
function enable(id) {
|
||||
eid(id).dataset.enabled = "true";
|
||||
@ -75,40 +75,39 @@ function opposite(state) {
|
||||
function changeDownloadButton(action, text) {
|
||||
switch (action) {
|
||||
case 0:
|
||||
eid("download-button").disabled = true
|
||||
eid("download-button").disabled = true;
|
||||
if (sGet("alwaysVisibleButton") === "true") {
|
||||
eid("download-button").value = text
|
||||
eid("download-button").style.padding = '0 1rem'
|
||||
eid("download-button").value = text;
|
||||
eid("download-button").style.padding = '0 1rem';
|
||||
} else {
|
||||
eid("download-button").value = ''
|
||||
eid("download-button").style.padding = '0'
|
||||
eid("download-button").value = '';
|
||||
eid("download-button").style.padding = '0';
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
eid("download-button").disabled = false
|
||||
eid("download-button").value = text
|
||||
eid("download-button").style.padding = '0 1rem'
|
||||
eid("download-button").disabled = false;
|
||||
eid("download-button").value = text;
|
||||
eid("download-button").style.padding = '0 1rem';
|
||||
break;
|
||||
case 2:
|
||||
eid("download-button").disabled = true
|
||||
eid("download-button").value = text
|
||||
eid("download-button").style.padding = '0 1rem'
|
||||
eid("download-button").disabled = true;
|
||||
eid("download-button").value = text;
|
||||
eid("download-button").style.padding = '0 1rem';
|
||||
break;
|
||||
}
|
||||
}
|
||||
document.addEventListener("keydown", (event) => {
|
||||
if (event.key === "Tab") {
|
||||
eid("download-button").value = '>>'
|
||||
eid("download-button").style.padding = '0 1rem'
|
||||
eid("download-button").value = '>>';
|
||||
eid("download-button").style.padding = '0 1rem';
|
||||
}
|
||||
})
|
||||
});
|
||||
function button() {
|
||||
let regexTest = regex.test(eid("url-input-area").value);
|
||||
if ((eid("url-input-area").value).length > 0) {
|
||||
if ((eid("url-input-area").value).length > 0)
|
||||
eid("url-clear").style.display = "block";
|
||||
} else {
|
||||
else
|
||||
eid("url-clear").style.display = "none";
|
||||
}
|
||||
regexTest ? changeDownloadButton(1, '>>') : changeDownloadButton(0, '>>');
|
||||
}
|
||||
function clearInput() {
|
||||
@ -127,35 +126,32 @@ async function share(url) {
|
||||
function detectColorScheme() {
|
||||
let theme = "auto";
|
||||
let localTheme = sGet("theme");
|
||||
if (localTheme) {
|
||||
if (localTheme)
|
||||
theme = localTheme;
|
||||
} else if (!window.matchMedia) {
|
||||
theme = "dark"
|
||||
}
|
||||
else if (!window.matchMedia)
|
||||
theme = "dark";
|
||||
document.documentElement.setAttribute("data-theme", theme);
|
||||
}
|
||||
function changeTab(evnt, tabId, tabClass) {
|
||||
function changeTab(event, tabId, tabClass) {
|
||||
if (tabId === "tab-settings-other") updateFilenamePreview();
|
||||
|
||||
let tabcontent = document.getElementsByClassName(`tab-content-${tabClass}`);
|
||||
let tablinks = document.getElementsByClassName(`tab-${tabClass}`);
|
||||
|
||||
for (let i = 0; i < tabcontent.length; i++) {
|
||||
for (let i = 0; i < tabcontent.length; i++)
|
||||
tabcontent[i].dataset.enabled = "false";
|
||||
}
|
||||
for (let i = 0; i < tablinks.length; i++) {
|
||||
for (let i = 0; i < tablinks.length; i++)
|
||||
tablinks[i].dataset.enabled = "false";
|
||||
}
|
||||
|
||||
evnt.currentTarget.dataset.enabled = "true";
|
||||
event.currentTarget.dataset.enabled = "true";
|
||||
eid(tabId).dataset.enabled = "true";
|
||||
eid(tabId).parentElement.scrollTop = 0;
|
||||
|
||||
if (tabId === "tab-about-changelog" && sGet("changelogStatus") !== `${version}`) notificationCheck("changelog");
|
||||
if (tabId === "tab-about-about" && !sGet("seenAbout")) notificationCheck("about");
|
||||
}
|
||||
function expandCollapsible(evnt) {
|
||||
let classlist = evnt.currentTarget.parentNode.classList;
|
||||
function expandCollapsible(event) {
|
||||
let classlist = event.currentTarget.parentNode.classList;
|
||||
let c = "expanded";
|
||||
!classlist.contains(c) ? classlist.add(c) : classlist.remove(c);
|
||||
}
|
||||
@ -166,7 +162,7 @@ function notificationCheck(type) {
|
||||
sSet("seenAbout", "true");
|
||||
break;
|
||||
case "changelog":
|
||||
sSet("changelogStatus", version)
|
||||
sSet("changelogStatus", version);
|
||||
break;
|
||||
default:
|
||||
changed = false;
|
||||
@ -174,8 +170,8 @@ function notificationCheck(type) {
|
||||
if (changed && sGet("changelogStatus") === `${version}` || type === "disable") {
|
||||
setTimeout(() => {
|
||||
eid("about-footer").innerHTML = eid("about-footer").innerHTML.replace(notification, '');
|
||||
eid("tab-button-about-changelog").innerHTML = eid("tab-button-about-changelog").innerHTML.replace(notification, '')
|
||||
}, 900)
|
||||
eid("tab-button-about-changelog").innerHTML = eid("tab-button-about-changelog").innerHTML.replace(notification, '');
|
||||
}, 900);
|
||||
}
|
||||
if (sGet("disableChangelog") !== "true") {
|
||||
if (!sGet("seenAbout") && !eid("about-footer").innerHTML.includes(notification)) eid("about-footer").innerHTML = `${notification}${eid("about-footer").innerHTML}`;
|
||||
@ -187,9 +183,8 @@ function notificationCheck(type) {
|
||||
}
|
||||
function hideAllPopups() {
|
||||
let filter = document.getElementsByClassName('popup');
|
||||
for (let i = 0; i < filter.length; i++) {
|
||||
for (let i = 0; i < filter.length; i++)
|
||||
filter[i].classList.remove("visible");
|
||||
}
|
||||
eid("popup-backdrop").classList.remove("visible");
|
||||
store.isPopupOpen = false;
|
||||
|
||||
@ -237,7 +232,7 @@ function popup(type, action, text) {
|
||||
isIOS ? `onClick="share('${text.arr[i]["url"]}')"` : `href="${text.arr[i]["url"]}" target="_blank"`
|
||||
}>` +
|
||||
`<img class="picker-image" src="${text.arr[i]["url"]}" onerror="this.parentNode.style.display='none'">` +
|
||||
`</a>`
|
||||
`</a>`;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
@ -251,7 +246,7 @@ function popup(type, action, text) {
|
||||
`<div class="picker-element-name">${text.arr[i].type}</div>` +
|
||||
(text.arr[i].type === 'photo' ? '' : '<div class="imageBlock"></div>') +
|
||||
`<img class="picker-image" src="${text.arr[i]["thumb"]}" onerror="this.style.display='none'">` +
|
||||
`</a>`
|
||||
`</a>`;
|
||||
}
|
||||
eid("picker-download").classList.remove("visible");
|
||||
break;
|
||||
@ -265,7 +260,7 @@ function popup(type, action, text) {
|
||||
if (type === "picker") {
|
||||
eid("picker-download").href = '/';
|
||||
eid("picker-download").classList.remove("visible");
|
||||
eid("picker-holder").innerHTML = ''
|
||||
eid("picker-holder").innerHTML = '';
|
||||
}
|
||||
}
|
||||
if (bottomPopups.includes(type)) eid(`popup-${type}-container`).classList.toggle("visible");
|
||||
@ -277,18 +272,16 @@ function changeSwitcher(li, b) {
|
||||
if (b) {
|
||||
if (!switchers[li].includes(b)) b = switchers[li][0];
|
||||
sSet(li, b);
|
||||
for (let i in switchers[li]) {
|
||||
(switchers[li][i] === b) ? enable(`${li}-${b}`) : disable(`${li}-${switchers[li][i]}`)
|
||||
}
|
||||
for (let i in switchers[li])
|
||||
(switchers[li][i] === b) ? enable(`${li}-${b}`) : disable(`${li}-${switchers[li][i]}`);
|
||||
if (li === "theme") detectColorScheme();
|
||||
if (li === "filenamePattern") updateFilenamePreview();
|
||||
} else {
|
||||
let pref = switchers[li][0];
|
||||
if (isMobile && exceptions[li]) pref = exceptions[li];
|
||||
sSet(li, pref);
|
||||
for (let i in switchers[li]) {
|
||||
(switchers[li][i] === pref) ? enable(`${li}-${pref}`) : disable(`${li}-${switchers[li][i]}`)
|
||||
}
|
||||
for (let i in switchers[li])
|
||||
(switchers[li][i] === pref) ? enable(`${li}-${pref}`) : disable(`${li}-${switchers[li][i]}`);
|
||||
}
|
||||
}
|
||||
function checkbox(action) {
|
||||
@ -303,7 +296,7 @@ function checkbox(action) {
|
||||
function changeButton(type, text) {
|
||||
switch (type) {
|
||||
case 0: //error
|
||||
eid("url-input-area").disabled = false
|
||||
eid("url-input-area").disabled = false;
|
||||
eid("url-clear").style.display = "block";
|
||||
changeDownloadButton(2, '!!');
|
||||
popup("error", 1, text);
|
||||
@ -312,18 +305,18 @@ function changeButton(type, text) {
|
||||
case 1: //enable back
|
||||
changeDownloadButton(1, '>>');
|
||||
eid("url-clear").style.display = "block";
|
||||
eid("url-input-area").disabled = false
|
||||
eid("url-input-area").disabled = false;
|
||||
break;
|
||||
case 2: //enable back + information popup
|
||||
popup("error", 1, text);
|
||||
changeDownloadButton(1, '>>');
|
||||
eid("url-clear").style.display = "block";
|
||||
eid("url-input-area").disabled = false
|
||||
eid("url-input-area").disabled = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
function internetError() {
|
||||
eid("url-input-area").disabled = false
|
||||
eid("url-input-area").disabled = false;
|
||||
changeDownloadButton(2, '!!');
|
||||
setTimeout(() => { changeButton(1); }, 2500);
|
||||
popup("error", 1, loc.ErrorNoInternet);
|
||||
@ -361,11 +354,10 @@ async function download(url) {
|
||||
filenamePattern: sGet("filenamePattern"),
|
||||
dubLang: false
|
||||
}
|
||||
if (sGet("dubLang") === "auto") {
|
||||
req.dubLang = true
|
||||
} else if (sGet("dubLang") === "custom") {
|
||||
req.dubLang = true
|
||||
}
|
||||
if (sGet("dubLang") === "auto")
|
||||
req.dubLang = true;
|
||||
else if (sGet("dubLang") === "custom")
|
||||
req.dubLang = true;
|
||||
if (sGet("vimeoDash") === "true") req.vimeoDash = true;
|
||||
if (sGet("audioMode") === "true") {
|
||||
req.isAudioOnly = true;
|
||||
@ -388,14 +380,14 @@ async function download(url) {
|
||||
}).then((r) => { return r.json() }).catch((e) => { return false });
|
||||
if (!j) {
|
||||
internetError();
|
||||
return
|
||||
return;
|
||||
}
|
||||
|
||||
if (j && j.status !== "error" && j.status !== "rate-limit") {
|
||||
if (j.text && (!j.url || !j.picker)) {
|
||||
if (j.status === "success") {
|
||||
changeButton(2, j.text)
|
||||
} else changeButton(0, loc.ErrorNoUrlReturned);
|
||||
if (j.status === "success")
|
||||
changeButton(2, j.text);
|
||||
else changeButton(0, loc.ErrorNoUrlReturned);
|
||||
}
|
||||
switch (j.status) {
|
||||
case "redirect":
|
||||
@ -412,27 +404,23 @@ async function download(url) {
|
||||
changeDownloadButton(2, '>>>');
|
||||
popup('picker', 1, { arr: j.picker, type: j.pickerType });
|
||||
setTimeout(() => { changeButton(1) }, 2500);
|
||||
} else {
|
||||
changeButton(0, loc.ErrorNoUrlReturned);
|
||||
}
|
||||
} else changeButton(0, loc.ErrorNoUrlReturned);
|
||||
break;
|
||||
case "stream":
|
||||
changeDownloadButton(2, '?..')
|
||||
changeDownloadButton(2, '?..');
|
||||
fetch(`${j.url}&p=1`).then(async (res) => {
|
||||
let jp = await res.json();
|
||||
if (jp.status === "continue") {
|
||||
changeDownloadButton(2, '>>>');
|
||||
if (sGet("downloadPopup") === "true") {
|
||||
popup('download', 1, j.url)
|
||||
} else {
|
||||
if (isMobile || isSafari) {
|
||||
if (sGet("downloadPopup") === "true")
|
||||
popup('download', 1, j.url);
|
||||
else {
|
||||
if (isMobile || isSafari)
|
||||
window.location.href = j.url;
|
||||
} else window.open(j.url, '_blank');
|
||||
else window.open(j.url, '_blank');
|
||||
}
|
||||
setTimeout(() => { changeButton(1) }, 2500);
|
||||
} else {
|
||||
changeButton(0, jp.text);
|
||||
}
|
||||
} else changeButton(0, jp.text);
|
||||
}).catch((error) => internetError());
|
||||
break;
|
||||
case "success":
|
||||
@ -442,17 +430,14 @@ async function download(url) {
|
||||
changeButton(0, loc.ErrorUnknownStatus);
|
||||
break;
|
||||
}
|
||||
} else if (j && j.text) {
|
||||
changeButton(0, j.text);
|
||||
}
|
||||
} else if (j && j.text) changeButton(0, j.text);
|
||||
}
|
||||
async function loadCelebrationsEmoji() {
|
||||
let bac = eid("about-footer").innerHTML;
|
||||
try {
|
||||
let j = await fetch(`/onDemand?blockId=1`).then((r) => { if (r.status === 200) { return r.json() } else { return false } }).catch(() => { return false });
|
||||
if (j && j.status === "success" && j.text) {
|
||||
if (j && j.status === "success" && j.text)
|
||||
eid("about-footer").innerHTML = eid("about-footer").innerHTML.replace('<img class="emoji" draggable="false" height="22" width="22" alt="🐲" src="emoji/dragon_face.svg" loading="lazy">', j.text);
|
||||
}
|
||||
} catch (e) {
|
||||
eid("about-footer").innerHTML = bac;
|
||||
}
|
||||
@ -463,9 +448,9 @@ async function loadOnDemand(elementId, blockId) {
|
||||
eid(elementId).innerHTML = `<div class="loader">...</div>`;
|
||||
|
||||
try {
|
||||
if (store.historyContent) {
|
||||
if (store.historyContent)
|
||||
j = store.historyContent;
|
||||
} else {
|
||||
else {
|
||||
await fetch(`/onDemand?blockId=${blockId}`).then(async(r) => {
|
||||
j = await r.json();
|
||||
if (j && j.status === "success") {
|
||||
@ -473,12 +458,12 @@ async function loadOnDemand(elementId, blockId) {
|
||||
} else throw new Error();
|
||||
}).catch(() => { throw new Error() });
|
||||
}
|
||||
if (j.text) {
|
||||
if (j.text)
|
||||
eid(elementId).innerHTML = `<button class="switch bottom-margin" onclick="restoreUpdateHistory()">${loc.ChangelogPressToHide}</button>${j.text}`;
|
||||
} else throw new Error()
|
||||
else throw new Error();
|
||||
} catch (e) {
|
||||
eid(elementId).innerHTML = store.historyButton;
|
||||
internetError()
|
||||
internetError();
|
||||
}
|
||||
}
|
||||
function restoreUpdateHistory() {
|
||||
@ -491,20 +476,20 @@ function unpackSettings(b64) {
|
||||
let currentSettings = JSON.parse(JSON.stringify(localStorage));
|
||||
for (let s in settingsToImport) {
|
||||
if (checkboxes.includes(s) && (settingsToImport[s] === "true" || settingsToImport[s] === "false")
|
||||
&& currentSettings[s] !== settingsToImport[s]) {
|
||||
&& currentSettings[s] !== settingsToImport[s]) {
|
||||
sSet(s, settingsToImport[s]);
|
||||
changed = true
|
||||
changed = true;
|
||||
}
|
||||
if (switchers[s] && switchers[s].includes(settingsToImport[s])
|
||||
&& currentSettings[s] !== settingsToImport[s]) {
|
||||
&& currentSettings[s] !== settingsToImport[s]) {
|
||||
sSet(s, settingsToImport[s]);
|
||||
changed = true
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
changed = false;
|
||||
}
|
||||
return changed
|
||||
return changed;
|
||||
}
|
||||
function updateFilenamePreview() {
|
||||
let videoFilePreview = ``;
|
||||
@ -523,55 +508,50 @@ function updateFilenamePreview() {
|
||||
switch(sGet("filenamePattern")) {
|
||||
case "classic":
|
||||
videoFilePreview = `youtube_yPYZpwSpKmA_${resMatch[sGet('vQuality')]}_${sGet('vCodec')}`
|
||||
+ `${sGet("muteAudio") === "true" ? "_mute" : ""}.${sGet('vCodec') === "vp9" ? 'webm' : 'mp4'}`;
|
||||
+ `${sGet("muteAudio") === "true" ? "_mute" : ""}.${sGet('vCodec') === "vp9" ? 'webm' : 'mp4'}`;
|
||||
audioFilePreview = `youtube_yPYZpwSpKmA_audio.${sGet('aFormat') !== "best" ? sGet('aFormat') : 'opus'}`;
|
||||
break;
|
||||
case "pretty":
|
||||
videoFilePreview =
|
||||
`${loc.FilenamePreviewVideoTitle} `
|
||||
+ `(${sGet('vQuality') === "max" ? "2160p" : `${sGet('vQuality')}p`}, ${sGet('vCodec')}, `
|
||||
+ `${sGet("muteAudio") === "true" ? "mute, " : ""}youtube).${sGet('vCodec') === "vp9" ? 'webm' : 'mp4'}`;
|
||||
+ `(${sGet('vQuality') === "max" ? "2160p" : `${sGet('vQuality')}p`}, ${sGet('vCodec')}, `
|
||||
+ `${sGet("muteAudio") === "true" ? "mute, " : ""}youtube).${sGet('vCodec') === "vp9" ? 'webm' : 'mp4'}`;
|
||||
audioFilePreview = `${loc.FilenamePreviewAudioTitle} - ${loc.FilenamePreviewAudioAuthor} (soundcloud).${sGet('aFormat') !== "best" ? sGet('aFormat') : 'opus'}`;
|
||||
break;
|
||||
case "basic":
|
||||
videoFilePreview =
|
||||
`${loc.FilenamePreviewVideoTitle} `
|
||||
+ `(${sGet('vQuality') === "max" ? "2160p" : `${sGet('vQuality')}p`}, ${sGet('vCodec')}${sGet("muteAudio") === "true" ? " mute" : ""}).${sGet('vCodec') === "vp9" ? 'webm' : 'mp4'}`;
|
||||
+ `(${sGet('vQuality') === "max" ? "2160p" : `${sGet('vQuality')}p`}, ${sGet('vCodec')}${sGet("muteAudio") === "true" ? " mute" : ""}).${sGet('vCodec') === "vp9" ? 'webm' : 'mp4'}`;
|
||||
audioFilePreview = `${loc.FilenamePreviewAudioTitle} - ${loc.FilenamePreviewAudioAuthor}.${sGet('aFormat') !== "best" ? sGet('aFormat') : 'opus'}`;
|
||||
break;
|
||||
case "nerdy":
|
||||
videoFilePreview =
|
||||
`${loc.FilenamePreviewVideoTitle} `
|
||||
+ `(${sGet('vQuality') === "max" ? "2160p" : `${sGet('vQuality')}p`}, ${sGet('vCodec')}, `
|
||||
+ `${sGet("muteAudio") === "true" ? "mute, " : ""}youtube, yPYZpwSpKmA).${sGet('vCodec') === "vp9" ? 'webm' : 'mp4'}`;
|
||||
+ `(${sGet('vQuality') === "max" ? "2160p" : `${sGet('vQuality')}p`}, ${sGet('vCodec')}, `
|
||||
+ `${sGet("muteAudio") === "true" ? "mute, " : ""}youtube, yPYZpwSpKmA).${sGet('vCodec') === "vp9" ? 'webm' : 'mp4'}`;
|
||||
audioFilePreview = `${loc.FilenamePreviewAudioTitle} - ${loc.FilenamePreviewAudioAuthor} (soundcloud, 1242868615).${sGet('aFormat') !== "best" ? sGet('aFormat') : 'opus'}`;
|
||||
break;
|
||||
}
|
||||
eid("video-filename-text").innerHTML = videoFilePreview
|
||||
eid("audio-filename-text").innerHTML = audioFilePreview
|
||||
eid("video-filename-text").innerHTML = videoFilePreview;
|
||||
eid("audio-filename-text").innerHTML = audioFilePreview;
|
||||
}
|
||||
function loadSettings() {
|
||||
if (sGet("alwaysVisibleButton") === "true") {
|
||||
eid("alwaysVisibleButton").checked = true;
|
||||
eid("download-button").value = '>>'
|
||||
eid("download-button").value = '>>';
|
||||
eid("download-button").style.padding = '0 1rem';
|
||||
}
|
||||
if (sGet("downloadPopup") === "true" && !isIOS) {
|
||||
if (sGet("downloadPopup") === "true" && !isIOS)
|
||||
eid("downloadPopup").checked = true;
|
||||
}
|
||||
if (sGet("reduceTransparency") === "true" || isOldFirefox) {
|
||||
if (sGet("reduceTransparency") === "true" || isOldFirefox)
|
||||
eid("cobalt-body").classList.add('no-transparency');
|
||||
}
|
||||
if (sGet("disableAnimations") === "true") {
|
||||
if (sGet("disableAnimations") === "true")
|
||||
eid("cobalt-body").classList.add('no-animation');
|
||||
}
|
||||
for (let i = 0; i < checkboxes.length; i++) {
|
||||
for (let i = 0; i < checkboxes.length; i++)
|
||||
if (sGet(checkboxes[i]) === "true") eid(checkboxes[i]).checked = true;
|
||||
}
|
||||
for (let i in switchers) {
|
||||
changeSwitcher(i, sGet(i))
|
||||
}
|
||||
updateFilenamePreview()
|
||||
for (let i in switchers)
|
||||
changeSwitcher(i, sGet(i));
|
||||
updateFilenamePreview();
|
||||
}
|
||||
window.onload = () => {
|
||||
loadCelebrationsEmoji();
|
||||
@ -587,22 +567,22 @@ window.onload = () => {
|
||||
eid("downloadPopup-chkbx").style.display = "none";
|
||||
}
|
||||
|
||||
eid("home").style.visibility = 'visible';
|
||||
eid("home").style.visibility = "visible";
|
||||
eid("home").classList.toggle("visible");
|
||||
|
||||
if (pageQuery.has("u") && regex.test(pageQuery.get("u"))) {
|
||||
eid("url-input-area").value = pageQuery.get("u");
|
||||
button()
|
||||
button();
|
||||
}
|
||||
if (pageQuery.has("migration")) {
|
||||
if (pageQuery.has("settingsData") && !sGet("migrated")) {
|
||||
let setUn = unpackSettings(pageQuery.get("settingsData"));
|
||||
if (setUn !== null) {
|
||||
if (setUn) {
|
||||
sSet("migrated", "true")
|
||||
eid("desc-migration").innerHTML += `<br><br>${loc.DataTransferSuccess}`
|
||||
sSet("migrated", "true");
|
||||
eid("desc-migration").innerHTML += `<br><br>${loc.DataTransferSuccess}`;
|
||||
} else {
|
||||
eid("desc-migration").innerHTML += `<br><br>${loc.DataTransferError}`
|
||||
eid("desc-migration").innerHTML += `<br><br>${loc.DataTransferError}`;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -615,16 +595,15 @@ window.onload = () => {
|
||||
notificationCheck();
|
||||
|
||||
// fix for animations not working in Safari
|
||||
if (isIOS) {
|
||||
if (isIOS)
|
||||
document.addEventListener('touchstart', () => {}, true);
|
||||
}
|
||||
}
|
||||
eid("url-input-area").addEventListener("keydown", (e) => {
|
||||
button();
|
||||
})
|
||||
});
|
||||
eid("url-input-area").addEventListener("keyup", (e) => {
|
||||
if (e.key === 'Enter') eid("download-button").click();
|
||||
})
|
||||
});
|
||||
document.onkeydown = (e) => {
|
||||
if (!store.isPopupOpen) {
|
||||
if (e.metaKey || e.ctrlKey || e.key === "/") eid("url-input-area").focus();
|
||||
@ -642,7 +621,5 @@ document.onkeydown = (e) => {
|
||||
if (e.key === "N") popup('about', 1, 'changelog'); // open changelog
|
||||
if (e.key === "M") popup('settings', 1);
|
||||
|
||||
} else {
|
||||
if (e.key === "Escape") hideAllPopups();
|
||||
}
|
||||
} else if (e.key === "Escape") hideAllPopups();
|
||||
}
|
||||
|
@ -11,7 +11,7 @@ export async function loadLoc() {
|
||||
const files = await fs.promises.readdir(locPath).catch((e) => { return [] });
|
||||
files.forEach(file => {
|
||||
loc[file.split('.')[0]] = loadJSON(`${locPath}/${file}`);
|
||||
languages.push(file.split('.')[0])
|
||||
languages.push(file.split('.')[0]);
|
||||
});
|
||||
}
|
||||
|
||||
@ -24,27 +24,27 @@ export function replaceBase(s) {
|
||||
.replace(/\*;/g, "•");
|
||||
}
|
||||
export function replaceAll(lang, str, string, replacement) {
|
||||
let s = replaceBase(str[string])
|
||||
let s = replaceBase(str[string]);
|
||||
if (replacement) s = s.replace(/{s}/g, replacement);
|
||||
if (s.match('{')) {
|
||||
Object.keys(loc[lang]["substrings"]).forEach(sub => {
|
||||
s = replaceBase(s.replace(`{${sub}}`, loc[lang]["substrings"][sub]))
|
||||
s = replaceBase(s.replace(`{${sub}}`, loc[lang]["substrings"][sub]));
|
||||
});
|
||||
}
|
||||
return s
|
||||
return s;
|
||||
}
|
||||
export default function(lang, string, replacement) {
|
||||
try {
|
||||
if (!Object.keys(loc).includes(lang)) lang = 'en';
|
||||
let str = loc[lang]["strings"];
|
||||
if (str && str[string]) {
|
||||
return replaceAll(lang, str, string, replacement)
|
||||
return replaceAll(lang, str, string, replacement);
|
||||
} else {
|
||||
str = loc["en"]["strings"];
|
||||
return replaceAll(lang, str, string, replacement)
|
||||
return replaceAll(lang, str, string, replacement);
|
||||
}
|
||||
} catch (e) {
|
||||
return `!!${string}!!`
|
||||
return `!!${string}!!`;
|
||||
}
|
||||
}
|
||||
export const languageList = languages;
|
||||
|
@ -26,8 +26,8 @@ export async function getJSON(url, lang, obj) {
|
||||
return apiJSON(0, { t: errorUnsupported(lang) });
|
||||
}
|
||||
|
||||
return await match(host, patternMatch, url, lang, obj)
|
||||
return await match(host, patternMatch, url, lang, obj);
|
||||
} catch (e) {
|
||||
return apiJSON(0, { t: loc(lang, 'ErrorSomethingWentWrong') })
|
||||
return apiJSON(0, { t: loc(lang, 'ErrorSomethingWentWrong') });
|
||||
}
|
||||
}
|
||||
|
@ -44,7 +44,7 @@ export async function buildFront(commitHash, branch) {
|
||||
minify: true,
|
||||
loader: { '.js': 'js', '.css': 'css', },
|
||||
charset: 'utf8'
|
||||
})
|
||||
});
|
||||
} catch (e) {
|
||||
return;
|
||||
}
|
||||
|
@ -7,10 +7,10 @@ const servicesConfigJson = loadJSON("./src/modules/processing/servicesConfig.jso
|
||||
Object.values(servicesConfigJson.config).forEach(service => {
|
||||
service.patterns = service.patterns.map(
|
||||
pattern => new UrlPattern(pattern, {
|
||||
segmentValueCharset: UrlPattern.defaultOptions.segmentValueCharset + '@\\.'
|
||||
segmentValueCharset: UrlPattern.defaultOptions.segmentValueCharset + '@\\.',
|
||||
})
|
||||
)
|
||||
})
|
||||
});
|
||||
|
||||
export const
|
||||
services = servicesConfigJson.config,
|
||||
@ -26,4 +26,4 @@ export const
|
||||
supportedAudio = config.supportedAudio,
|
||||
celebrations = config.celebrations,
|
||||
links = config.links,
|
||||
sponsors = config.sponsors
|
||||
sponsors = config.sponsors;
|
||||
|
@ -62,5 +62,5 @@ export default function(emoji, size, disablePadding, fluent) {
|
||||
|
||||
let filePath = `emoji/${names[emoji]}.svg`;
|
||||
if (fluent) filePath = `emoji/3d/${names[emoji]}.svg`;
|
||||
return `<img class="emoji" draggable=false height="${size}" width="${size}" ${padding ? `style="${padding}" ` : ''}alt="${emoji}" src="${filePath}" loading="lazy">`
|
||||
return `<img class="emoji" draggable=false height="${size}" width="${size}" ${padding ? `style="${padding}" ` : ''}alt="${emoji}" src="${filePath}" loading="lazy">`;
|
||||
}
|
||||
|
@ -8,18 +8,20 @@ export const backButtonSVG = `<svg width="22" height="22" viewBox="0 0 32 32" fi
|
||||
|
||||
export const dropdownSVG = `<svg width="18" height="18" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M28 12.0533L16 24L4 12.0533L6.03571 10L14.7188 18.4104L16.25 19.9348L17.7813 18.4104L25.9375 10L28 12.0533Z" fill="#E1E1E1"/>
|
||||
</svg>`
|
||||
</svg>`;
|
||||
|
||||
export const linkSVG = '<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 256 256"><path fill="currentColor" d="M137.54 186.36a8 8 0 0 1 0 11.31l-9.94 10a56 56 0 0 1-79.22-79.27l24.12-24.12a56 56 0 0 1 76.81-2.28a8 8 0 1 1-10.64 12a40 40 0 0 0-54.85 1.63L59.7 139.72a40 40 0 0 0 56.58 56.58l9.94-9.94a8 8 0 0 1 11.32 0Zm70.08-138a56.08 56.08 0 0 0-79.22 0l-9.94 9.95a8 8 0 0 0 11.32 11.31l9.94-9.94a40 40 0 0 1 56.58 56.58l-24.12 24.14a40 40 0 0 1-54.85 1.6a8 8 0 1 0-10.64 12a56 56 0 0 0 76.81-2.26l24.12-24.12a56.08 56.08 0 0 0 0-79.24Z"/></svg>'
|
||||
export const linkSVG = `<svg width="32" height="32" viewBox="0 0 256 256" xmlns="http://www.w3.org/2000/svg">
|
||||
<path fill="currentColor" d="M137.54 186.36a8 8 0 0 1 0 11.31l-9.94 10a56 56 0 0 1-79.22-79.27l24.12-24.12a56 56 0 0 1 76.81-2.28a8 8 0 1 1-10.64 12a40 40 0 0 0-54.85 1.63L59.7 139.72a40 40 0 0 0 56.58 56.58l9.94-9.94a8 8 0 0 1 11.32 0Zm70.08-138a56.08 56.08 0 0 0-79.22 0l-9.94 9.95a8 8 0 0 0 11.32 11.31l9.94-9.94a40 40 0 0 1 56.58 56.58l-24.12 24.14a40 40 0 0 1-54.85 1.6a8 8 0 1 0-10.64 12a56 56 0 0 0 76.81-2.26l24.12-24.12a56.08 56.08 0 0 0 0-79.24Z"/>
|
||||
</svg>`;
|
||||
|
||||
export function switcher(obj) {
|
||||
let items = ``;
|
||||
if (obj.name === "download") {
|
||||
if (obj.name === "download")
|
||||
items = obj.items;
|
||||
} else {
|
||||
else {
|
||||
for (let i = 0; i < obj.items.length; i++) {
|
||||
let classes = obj.items[i]["classes"] ? obj.items[i]["classes"] : [];
|
||||
items += `<button id="${obj.name}-${obj.items[i]["action"]}" class="switch${classes.length > 0 ? ' ' + classes.join(' ') : ''}" onclick="changeSwitcher('${obj.name}', '${obj.items[i]["action"]}')">${obj.items[i]["text"] ? obj.items[i]["text"] : obj.items[i]["action"]}</button>`
|
||||
items += `<button id="${obj.name}-${obj.items[i]["action"]}" class="switch${classes.length > 0 ? ' ' + classes.join(' ') : ''}" onclick="changeSwitcher('${obj.name}', '${obj.items[i]["action"]}')">${obj.items[i]["text"] ? obj.items[i]["text"] : obj.items[i]["action"]}</button>`;
|
||||
}
|
||||
}
|
||||
|
||||
@ -28,7 +30,7 @@ export function switcher(obj) {
|
||||
${obj.subtitle ? `<div class="subtitle">${obj.subtitle}</div>` : ``}
|
||||
<div class="switches">${items}</div>
|
||||
${obj.explanation ? `<div class="explanation">${obj.explanation}</div>` : ``}
|
||||
</div>`
|
||||
</div>`;
|
||||
}
|
||||
export function checkbox(obj) {
|
||||
let paddings = ["bottom-margin", "top-margin", "no-margin", "top-margin-only"];
|
||||
@ -39,12 +41,12 @@ export function checkbox(obj) {
|
||||
checkboxes += `<label id="${obj[i].action}-chkbx" class="checkbox${paddingClass}">
|
||||
<input id="${obj[i].action}" type="checkbox" aria-label="${obj[i].aria ? obj[i].aria : obj[i].name}" onclick="checkbox('${obj[i].action}')">
|
||||
<span>${obj[i].name}</span>
|
||||
</label>`
|
||||
</label>`;
|
||||
}
|
||||
return checkboxes
|
||||
return checkboxes;
|
||||
}
|
||||
export function sep(paddingType) {
|
||||
let paddingClass = ``
|
||||
let paddingClass = ``;
|
||||
switch(paddingType) {
|
||||
case 0:
|
||||
paddingClass += ` top-margin`;
|
||||
@ -56,14 +58,13 @@ export function popup(obj) {
|
||||
let classes = obj.classes ? obj.classes : [];
|
||||
let body = obj.body;
|
||||
if (Array.isArray(obj.body)) {
|
||||
body = ``
|
||||
body = ``;
|
||||
for (let i = 0; i < obj.body.length; i++) {
|
||||
if (obj.body[i]["text"].length > 0) {
|
||||
classes = obj.body[i]["classes"] ?? []
|
||||
if (i !== obj.body.length - 1 && !obj.body[i]["nopadding"]) {
|
||||
classes.push("desc-padding")
|
||||
}
|
||||
body += obj.body[i]["raw"] ? obj.body[i]["text"] : `<div class="${['popup-desc', ...classes].join(' ')}">${obj.body[i]["text"]}</div>`
|
||||
classes = obj.body[i]["classes"] ?? [];
|
||||
if (i !== obj.body.length - 1 && !obj.body[i]["nopadding"])
|
||||
classes.push("desc-padding");
|
||||
body += obj.body[i]["raw"] ? obj.body[i]["text"] : `<div class="${['popup-desc', ...classes].join(' ')}">${obj.body[i]["text"]}</div>`;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -82,7 +83,7 @@ export function popup(obj) {
|
||||
${body}${obj.buttonOnly ? `<button class="close-error switch" onclick="popup('${obj.name}', 0)">${obj.buttonText}</button>` : ''}
|
||||
</div>
|
||||
${classes.includes("small") ? `<div class="glass-bkg small"></div>` : ''}
|
||||
${obj.standalone ? `</div>` : ''}`
|
||||
${obj.standalone ? `</div>` : ''}`;
|
||||
}
|
||||
|
||||
export function multiPagePopup(obj) {
|
||||
@ -93,8 +94,8 @@ export function multiPagePopup(obj) {
|
||||
|
||||
let tabContent = ``;
|
||||
for (let i = 0; i < obj.tabs.length; i++) {
|
||||
tabs += `<button id="tab-button-${obj.name}-${obj.tabs[i]["name"]}" class="switch tab tab-${obj.name}" onclick="changeTab(event, 'tab-${obj.name}-${obj.tabs[i]["name"]}', '${obj.name}')">${obj.tabs[i]["title"]}</button>`
|
||||
tabContent += `<div id="tab-${obj.name}-${obj.tabs[i]["name"]}" class="popup-tab-content tab-content-${obj.name}">${obj.tabs[i]["content"]}</div>`
|
||||
tabs += `<button id="tab-button-${obj.name}-${obj.tabs[i]["name"]}" class="switch tab tab-${obj.name}" onclick="changeTab(event, 'tab-${obj.name}-${obj.tabs[i]["name"]}', '${obj.name}')">${obj.tabs[i]["title"]}</button>`;
|
||||
tabContent += `<div id="tab-${obj.name}-${obj.tabs[i]["name"]}" class="popup-tab-content tab-content-${obj.name}">${obj.tabs[i]["content"]}</div>`;
|
||||
}
|
||||
|
||||
return `
|
||||
@ -112,7 +113,7 @@ export function multiPagePopup(obj) {
|
||||
<div class="switches popup-tabs-child">${tabs}</div>
|
||||
<div class="glass-bkg alone"></div>
|
||||
</div>
|
||||
</div>`
|
||||
</div>`;
|
||||
}
|
||||
export function collapsibleList(arr) {
|
||||
let items = ``;
|
||||
@ -125,7 +126,7 @@ export function collapsibleList(arr) {
|
||||
<div class="collapse-indicator">${dropdownSVG}</div>
|
||||
</div>
|
||||
<div id="${arr[i]["name"]}-body" class="collapse-body">${arr[i]["body"]}</div>
|
||||
</div>`
|
||||
</div>`;
|
||||
}
|
||||
return items;
|
||||
}
|
||||
@ -133,11 +134,10 @@ export function popupWithBottomButtons(obj) {
|
||||
let tabs = `
|
||||
<button class="back-button switch tab-${obj.name}" onclick="popup('${obj.name}', 0)" ${obj.closeAria ? `aria-label="${obj.closeAria}"` : ''}>
|
||||
${backButtonSVG}
|
||||
</button>`
|
||||
</button>`;
|
||||
|
||||
for (let i = 0; i < obj.buttons.length; i++) {
|
||||
tabs += obj.buttons[i]
|
||||
}
|
||||
for (let i = 0; i < obj.buttons.length; i++)
|
||||
tabs += obj.buttons[i];
|
||||
return `
|
||||
<div id="popup-${obj.name}" class="popup center box scrollable">
|
||||
<div class="popup-content">
|
||||
@ -154,30 +154,29 @@ export function popupWithBottomButtons(obj) {
|
||||
<div id="picker-buttons" class="switches popup-tabs-child">${tabs}</div>
|
||||
<div class="glass-bkg alone"></div>
|
||||
</div>
|
||||
</div>`
|
||||
</div>`;
|
||||
}
|
||||
export function socialLink(emji, name, url) {
|
||||
return `<div class="cobalt-support-link">${emji} <a class="text-backdrop link" href="${url}" target="_blank">${name}</a></div>`
|
||||
return `<div class="cobalt-support-link">${emji} <a class="text-backdrop link" href="${url}" target="_blank">${name}</a></div>`;
|
||||
}
|
||||
export function socialLinks(lang) {
|
||||
let links = authorInfo.support[lang] ? authorInfo.support[lang] : authorInfo.support.default;
|
||||
let r = ``;
|
||||
for (let i in links) {
|
||||
for (let i in links)
|
||||
r += socialLink(
|
||||
emoji(links[i].emoji), links[i].name, links[i].url
|
||||
)
|
||||
}
|
||||
return r
|
||||
);
|
||||
return r;
|
||||
}
|
||||
export function settingsCategory(obj) {
|
||||
return `<div id="settings-${obj.name}" class="settings-category">
|
||||
<div class="category-title">${obj.title ?? obj.name}</div>
|
||||
<div class="category-content">${obj.body}</div>
|
||||
</div>`
|
||||
</div>`;
|
||||
}
|
||||
|
||||
export function footerButtons(obj) {
|
||||
let items = ``
|
||||
let items = ``;
|
||||
for (let i = 0; i < obj.length; i++) {
|
||||
let buttonName = obj[i]["context"] ? `${obj[i]["name"]}-${obj[i]["context"]}` : obj[i]["name"],
|
||||
context = obj[i]["context"] ? `, '${obj[i]["context"]}'` : '',
|
||||
@ -196,11 +195,10 @@ export function footerButtons(obj) {
|
||||
</div>`;
|
||||
i++;
|
||||
}
|
||||
return `
|
||||
<div id="footer-buttons">${items}</div>`
|
||||
return `<div id="footer-buttons">${items}</div>`;
|
||||
}
|
||||
export function explanation(text) {
|
||||
return `<div class="explanation">${text}</div>`
|
||||
return `<div class="explanation">${text}</div>`;
|
||||
}
|
||||
export function celebrationsEmoji() {
|
||||
try {
|
||||
@ -209,16 +207,16 @@ export function celebrationsEmoji() {
|
||||
let f = Object.keys(celebrations).includes(dm) ? celebrations[dm] : "🐲";
|
||||
return f != "🐲" ? emoji(f, 22) : false;
|
||||
} catch (e) {
|
||||
return false
|
||||
return false;
|
||||
}
|
||||
}
|
||||
export function urgentNotice(obj) {
|
||||
if (obj.visible) {
|
||||
return `<div id="urgent-notice" class="urgent-notice explanation">` +
|
||||
`<span class="urgent-text" onclick="${obj.action}">${emoji(obj.emoji, 18)} ${obj.text}</span>` +
|
||||
`</div>`
|
||||
`</div>`;
|
||||
}
|
||||
return ``
|
||||
return ``;
|
||||
}
|
||||
export function keyboardShortcuts(arr) {
|
||||
let base = `<div id="keyboard-shortcuts" class="explanation">`;
|
||||
@ -228,10 +226,10 @@ export function keyboardShortcuts(arr) {
|
||||
for (let c = 0; c < arr[i].items.length; c++) {
|
||||
let combo = arr[i].items[c].combo.split('+').map(
|
||||
key => `<span class="text-backdrop key">${key}</span>`
|
||||
).join("+")
|
||||
base += `<div class="shortcut">${combo}: ${arr[i].items[c].name}</div>`
|
||||
).join("+");
|
||||
base += `<div class="shortcut">${combo}: ${arr[i].items[c].name}</div>`;
|
||||
}
|
||||
base += `</div>`
|
||||
base += `</div>`;
|
||||
}
|
||||
base += `</div>`;
|
||||
|
||||
@ -239,15 +237,14 @@ export function keyboardShortcuts(arr) {
|
||||
}
|
||||
export function webLoc(t, arr) {
|
||||
let base = ``;
|
||||
for (let i = 0; i < arr.length; i++) {
|
||||
base += `${arr[i]}:` + "`" + t(arr[i]) + "`" + `,`
|
||||
}
|
||||
for (let i = 0; i < arr.length; i++)
|
||||
base += `${arr[i]}:` + "`" + t(arr[i]) + "`" + `,`;
|
||||
return `{${base}};`
|
||||
}
|
||||
|
||||
export function sponsoredList() {
|
||||
let base = ``;
|
||||
let altText = ``
|
||||
let altText = ``;
|
||||
for (let i = 0; i < sponsors.length; i++) {
|
||||
let s = sponsors[i];
|
||||
let loadedLogo = loadFile(`./src/front/sponsors/${s.name}.svg`);
|
||||
@ -258,11 +255,11 @@ export function sponsoredList() {
|
||||
href="${s.url}" target="_blank"
|
||||
style="width: calc(${s.logo.width}px / ${s.logo.scale}); height: calc(${s.logo.height}px / ${s.logo.scale});">
|
||||
${loadedLogo}
|
||||
</a>`
|
||||
</a>`;
|
||||
}
|
||||
return `<div id="sponsored-logos" aria-label="${altText.slice(0, -2)}">${base}</div>`
|
||||
return `<div id="sponsored-logos" aria-label="${altText.slice(0, -2)}">${base}</div>`;
|
||||
}
|
||||
|
||||
export function betaTag() {
|
||||
return process.env.isBeta ? '<span class="logo-sub">β</span>' : ''
|
||||
return process.env.isBeta ? '<span class="logo-sub">β</span>' : '';
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
import changelogManager from "../changelog/changelogManager.js"
|
||||
import { cleanHTML } from "../sub/utils.js";
|
||||
|
||||
let cache = {}
|
||||
let cache = {};
|
||||
|
||||
export function changelogHistory() { // blockId 0
|
||||
if (cache['0']) return cache['0'];
|
||||
@ -25,7 +25,7 @@ export function changelogHistory() { // blockId 0
|
||||
</div>` : ''}
|
||||
<div class="popup-desc changelog-tags">${history[i]["version"]}</div>
|
||||
<div class="popup-desc changelog-subtitle">${history[i]["title"]}</div>
|
||||
<div class="popup-desc desc-padding">${history[i]["content"]}</div>`
|
||||
<div class="popup-desc desc-padding">${history[i]["content"]}</div>`;
|
||||
}
|
||||
render = cleanHTML(render);
|
||||
cache['0'] = render;
|
||||
|
@ -8,22 +8,21 @@ import changelogManager from "../changelog/changelogManager.js";
|
||||
let com = getCommitInfo();
|
||||
|
||||
let enabledServices = Object.keys(s).filter(p => s[p].enabled).sort().map((p) => {
|
||||
return `<br>• ${s[p].alias ? s[p].alias : p}`
|
||||
}).join('').substring(4)
|
||||
return `<br>• ${s[p].alias ? s[p].alias : p}`;
|
||||
}).join('').substring(4);
|
||||
|
||||
let donate = ``
|
||||
let donateLinks = ``
|
||||
let donate = ``;
|
||||
let donateLinks = ``;
|
||||
let audioFormats = supportedAudio.map((p) => {
|
||||
return { "action": p }
|
||||
return { "action": p };
|
||||
})
|
||||
audioFormats.unshift({ "action": "best" })
|
||||
for (let i in donations["links"]) {
|
||||
donateLinks += `<a id="don-${i}" class="switch autowidth" href="${donations["links"][i]}" target="_blank">REPLACEME ${i}</a>`
|
||||
}
|
||||
let extr = ''
|
||||
audioFormats.unshift({ "action": "best" });
|
||||
for (let i in donations["links"])
|
||||
donateLinks += `<a id="don-${i}" class="switch autowidth" href="${donations["links"][i]}" target="_blank">REPLACEME ${i}</a>`;
|
||||
let extr = '';
|
||||
for (let i in donations["crypto"]) {
|
||||
donate += `<div class="subtitle${extr}">${i} (REPLACEME)</div><div id="don-${i}" class="text-to-copy" onClick="copy('don-${i}')">${donations["crypto"][i]}</div>`
|
||||
extr = ' top-margin'
|
||||
donate += `<div class="subtitle${extr}">${i} (REPLACEME)</div><div id="don-${i}" class="text-to-copy" onClick="copy('don-${i}')">${donations["crypto"][i]}</div>`;
|
||||
extr = ' top-margin';
|
||||
}
|
||||
|
||||
export default function(obj) {
|
||||
@ -650,7 +649,7 @@ export default function(obj) {
|
||||
<script src="cobalt.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
`
|
||||
`;
|
||||
} catch (err) {
|
||||
return `${t('ErrorPageRenderFail', obj.hash)}`;
|
||||
}
|
||||
|
@ -131,5 +131,5 @@ export default async function(o) {
|
||||
}
|
||||
}
|
||||
|
||||
return { error: 'ErrorYTTryOtherCodec' }
|
||||
return { error: 'ErrorYTTryOtherCodec' };
|
||||
}
|
||||
|
@ -14,9 +14,8 @@ let rl = createInterface({ input: process.stdin, output: process.stdout });
|
||||
let final = () => {
|
||||
if (existsSync(envPath)) unlinkSync(envPath);
|
||||
|
||||
for (let i in ob) {
|
||||
appendFileSync(envPath, `${i}=${ob[i]}\n`)
|
||||
}
|
||||
for (let i in ob)
|
||||
appendFileSync(envPath, `${i}=${ob[i]}\n`);
|
||||
console.log(Bright("\nAwesome! I've created a fresh .env file for you."));
|
||||
console.log(`${Bright("Now I'll run")} ${Cyan("npm install")} ${Bright("to install all dependencies. It shouldn't take long.\n\n")}`);
|
||||
execSync('npm install', { stdio: [0, 1, 2] });
|
||||
@ -28,7 +27,7 @@ let final = () => {
|
||||
|
||||
console.log(
|
||||
`${Cyan(`Hey, this is cobalt v.${version}!`)}\n${Bright("Let's start by creating a new ")}${Cyan(".env")}${Bright(" file. You can always change it later.")}`
|
||||
)
|
||||
);
|
||||
|
||||
function setup() {
|
||||
console.log(Bright("\nWhat kind of server will this instance be?\nOptions: api, web."));
|
||||
@ -59,8 +58,8 @@ function setup() {
|
||||
|
||||
rl.question(q, apiCors => {
|
||||
let answCors = apiCors.toLowerCase().trim();
|
||||
if (answCors !== "y" && answCors !== "yes") ob['cors'] = '0'
|
||||
final()
|
||||
if (answCors !== "y" && answCors !== "yes") ob['cors'] = '0';
|
||||
final();
|
||||
})
|
||||
})
|
||||
});
|
||||
@ -90,7 +89,7 @@ function setup() {
|
||||
ob['apiURL'] = `https://${apiURL.toLowerCase()}/`;
|
||||
if (apiURL.includes(':')) ob['apiURL'] = `http://${apiURL.toLowerCase()}/`;
|
||||
if (!apiURL) ob['apiURL'] = "https://co.wuk.sh/";
|
||||
final()
|
||||
final();
|
||||
})
|
||||
});
|
||||
|
||||
@ -98,8 +97,8 @@ function setup() {
|
||||
break;
|
||||
default:
|
||||
console.log(Bright("\nThis is not an option. Try again."));
|
||||
setup()
|
||||
setup();
|
||||
}
|
||||
})
|
||||
});
|
||||
}
|
||||
setup()
|
||||
setup();
|
||||
|
Loading…
Reference in New Issue
Block a user