Skip to content

Commit

Permalink
fix lang parameter and add info on error msg
Browse files Browse the repository at this point in the history
  • Loading branch information
SeymourSchlong committed May 27, 2024
1 parent 094bc87 commit bab7ed6
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const load = () => {
return ['USen','EUnl','USfr','EUfr','EUde','EUit','EUru','USes','EUes', 'KRko'].indexOf(language) !== -1;
}

const language = params.get("lang") || 'USen';
let language = params.get("lang") || 'USen';

if (Object.keys(lang).indexOf(language) === -1) {
language = 'USen';
Expand Down Expand Up @@ -132,8 +132,12 @@ const load = () => {
const textCtx = textCanvas.getContext('2d');
textCtx.scale(textScale, textScale);

const textFont = `Splat-text${lang[language].font?','+lang[language].font[0]:''}`;
const titleFont = `Splat-title${lang[language].font?','+lang[language].font[1]:''}`;
const textFontList = ['Splat-text'];
if (lang[language].font) textFontList.push(lang[language].font[0]);
const titleFontList = ['Splat-title'];
if (lang[language].font) titleFontList.push(lang[language].font[1]);
const textFont = textFontList.join(',');
const titleFont = titleFontList.join(',');

// please dont use this unless you receive permission :(
let forceDisableWatermark = false;
Expand Down Expand Up @@ -929,11 +933,6 @@ const load = () => {

const urlComponents = [];

// Language
if (language !== 'USen') {
urlComponents.push('lang=' + language);
}

// Name
urlComponents.push('n=' + encodeURIComponent(tag.name));

Expand Down Expand Up @@ -1204,8 +1203,14 @@ const load = () => {
{
elm: shareButton,
run: () => {
//generateUrlParams();
const urlParams = generateUrlParams();

// Language
if (language !== 'USen') {
urlParams.unshift('lang=' + language);
}
navigator.clipboard.writeText(location.origin + location.pathname + '?' + generateUrlParams().join('&'));
alert("Link copied to clipboard!");
//navigator.clipboard.writeText('localhost:8080/?' + generateUrlParams().join('&'));
}
},
Expand Down Expand Up @@ -1414,7 +1419,7 @@ const load = () => {
Object.assign(assetIDs.lang, structuredClone(data));
loadedLanguage();
}).catch(err => {
alert('Something went wrong when loading...\nMaybe try refreshing?\n\nIf this problem keeps occurring, contact @spaghettitron on Twitter!');
alert(`Something went wrong when loading...\nMaybe try refreshing?\n\nIf this problem keeps occurring, contact @spaghettitron on Twitter!\n\n${err.stack}`);
console.log(err);
});
});
Expand Down

0 comments on commit bab7ed6

Please sign in to comment.