mirror of
https://github.com/mue/mue.git
synced 2026-07-09 13:35:35 +02:00
soon
This commit is contained in:
@@ -9,8 +9,13 @@ export default function hexToRgb(value) {
|
||||
const valid = hexRegexp.test(value);
|
||||
|
||||
if (valid) {
|
||||
if (value[0] === '#') value = value.slice(1, value.length);
|
||||
if (value.length === 3) value = value.replace(regexp, '$1$1$2$2$3$3');
|
||||
if (value[0] === '#') {
|
||||
value = value.slice(1, value.length);
|
||||
}
|
||||
|
||||
if (value.length === 3){
|
||||
value = value.replace(regexp, '$1$1$2$2$3$3');
|
||||
}
|
||||
|
||||
const red = parseInt(value.substr(0, 2), 16);
|
||||
const green = parseInt(value.substr(2, 2), 16);
|
||||
|
||||
@@ -3,9 +3,17 @@ export default function rgbToHex(red, green, blue) {
|
||||
let g16 = green.toString(16);
|
||||
let b16 = blue.toString(16);
|
||||
|
||||
if (red < 16) r16 = `0${r16}`;
|
||||
if (green < 16) g16 = `0${g16}`;
|
||||
if (blue < 16) b16 = `0${b16}`;
|
||||
if (red < 16) {
|
||||
r16 = `0${r16}`;
|
||||
}
|
||||
|
||||
if (green < 16) {
|
||||
g16 = `0${g16}`;
|
||||
}
|
||||
|
||||
if (blue < 16) {
|
||||
b16 = `0${b16}`;
|
||||
}
|
||||
|
||||
return r16 + g16 + b16;
|
||||
}
|
||||
|
||||
@@ -18,11 +18,19 @@ export default function rgbToHSv({ red, green, blue }) {
|
||||
gg = diffc(gabs);
|
||||
bb = diffc(babs);
|
||||
|
||||
if (rabs === v) h = bb - gg;
|
||||
else if (gabs === v) h = (1 / 3) + rr - bb;
|
||||
else if (babs === v) h = (2 / 3) + gg - rr;
|
||||
if (h < 0) h += 1;
|
||||
else if (h > 1) h -= 1;
|
||||
if (rabs === v){
|
||||
h = bb - gg;
|
||||
} else if (gabs === v) {
|
||||
h = (1 / 3) + rr - bb;
|
||||
} else if (babs === v) {
|
||||
h = (2 / 3) + gg - rr;
|
||||
}
|
||||
|
||||
if (h < 0) {
|
||||
h += 1;
|
||||
} else if (h > 1) {
|
||||
h -= 1;
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
|
||||
@@ -10,8 +10,10 @@ export default function setRGBA(red, green, blue, alpha) {
|
||||
blue: blue | 0,
|
||||
};
|
||||
|
||||
if (isValidRGBValue(alpha) === true) color.alpha = alpha | 0;
|
||||
// RGBToHSL(color.r, color.g, color.b);
|
||||
if (isValidRGBValue(alpha) === true) {
|
||||
color.alpha = alpha | 0;
|
||||
}
|
||||
|
||||
return color;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,8 +18,9 @@ export default class MarketplaceFunctions {
|
||||
localStorage.removeItem('quoteAPI');
|
||||
break;
|
||||
default:
|
||||
try { localStorage.removeItem(type); }
|
||||
catch (e) {
|
||||
try {
|
||||
localStorage.removeItem(type);
|
||||
} catch (e) {
|
||||
toast('Failed to uninstall addon, check the console');
|
||||
console.error(e);
|
||||
}
|
||||
@@ -39,17 +40,32 @@ export default class MarketplaceFunctions {
|
||||
switch (type) {
|
||||
case 'settings':
|
||||
localStorage.removeItem('backup_settings');
|
||||
|
||||
let oldSettings = [];
|
||||
for (const key of Object.keys(localStorage)) oldSettings.push({ name: key, value: localStorage.getItem(key) });
|
||||
for (const key of Object.keys(localStorage)) {
|
||||
oldSettings.push({
|
||||
name: key,
|
||||
value: localStorage.getItem(key)
|
||||
});
|
||||
}
|
||||
|
||||
localStorage.setItem('backup_settings', JSON.stringify(oldSettings));
|
||||
input.settings.forEach(element => localStorage.setItem(element.name, element.value));
|
||||
break;
|
||||
case 'photo_packs': localStorage.setItem('photo_packs', JSON.stringify(input.photos)); break;
|
||||
|
||||
case 'photo_packs':
|
||||
localStorage.setItem('photo_packs', JSON.stringify(input.photos));
|
||||
break;
|
||||
|
||||
case 'quote_packs':
|
||||
if (input.quote_api) localStorage.setItem('quoteAPI', JSON.stringify(input.quote_api));
|
||||
if (input.quote_api) {
|
||||
localStorage.setItem('quoteAPI', JSON.stringify(input.quote_api));
|
||||
}
|
||||
|
||||
localStorage.setItem('quote_packs', JSON.stringify(input.quotes));
|
||||
break;
|
||||
default: break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
let installed = JSON.parse(localStorage.getItem('installed'));
|
||||
|
||||
@@ -18,7 +18,9 @@ const saveFile = (data, filename = 'file') => {
|
||||
export default class SettingsFunctions {
|
||||
static exportSettings() {
|
||||
let settings = {};
|
||||
for (const key of Object.keys(localStorage)) settings[key] = localStorage.getItem(key);
|
||||
for (const key of Object.keys(localStorage)) {
|
||||
settings[key] = localStorage.getItem(key);
|
||||
}
|
||||
saveFile(settings, 'mue-settings.json');
|
||||
}
|
||||
|
||||
@@ -27,8 +29,13 @@ export default class SettingsFunctions {
|
||||
let val = true;
|
||||
|
||||
if (old !== null && !value) {
|
||||
if (old === 'true') val = false;
|
||||
if (old === 'false') val = true;
|
||||
if (old === 'true') {
|
||||
val = false;
|
||||
}
|
||||
|
||||
if (old === 'false') {
|
||||
val = true;
|
||||
}
|
||||
}
|
||||
|
||||
localStorage.setItem(key, val);
|
||||
@@ -69,8 +76,11 @@ export default class SettingsFunctions {
|
||||
defaultSettings.forEach((element) => localStorage.setItem(element.name, element.value));
|
||||
|
||||
// Set theme depending on user preferred
|
||||
if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) localStorage.setItem('darkTheme', true);
|
||||
else localStorage.setItem('darkTheme', false);
|
||||
if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) {
|
||||
localStorage.setItem('darkTheme', true);
|
||||
} else {
|
||||
localStorage.setItem('darkTheme', false);
|
||||
}
|
||||
|
||||
// Languages
|
||||
const languages = ['nl', 'no', 'fr', 'ru', 'es'];
|
||||
@@ -79,9 +89,13 @@ export default class SettingsFunctions {
|
||||
if (languages.includes(browserLanguage)) {
|
||||
localStorage.setItem('language', browserLanguage);
|
||||
document.documentElement.lang = browserLanguage;
|
||||
} else localStorage.setItem('language', 'en');
|
||||
} else {
|
||||
localStorage.setItem('language', 'en');
|
||||
}
|
||||
|
||||
if (reset) localStorage.setItem('showWelcome', false);
|
||||
if (reset) {
|
||||
localStorage.setItem('showWelcome', false);
|
||||
}
|
||||
|
||||
// Finally we set this to true so it doesn't run the function on every load
|
||||
localStorage.setItem('firstRun', true);
|
||||
|
||||
Reference in New Issue
Block a user