-
+
document.getElementById('file-input').click()}>{this.props.language.sideload}
{this.props.language.added}
{content}
diff --git a/src/components/modals/tabs/Marketplace.jsx b/src/components/modals/tabs/Marketplace.jsx
index 738de35f..27830d19 100644
--- a/src/components/modals/tabs/Marketplace.jsx
+++ b/src/components/modals/tabs/Marketplace.jsx
@@ -8,59 +8,48 @@ import * as Constants from '../../../modules/constants';
import Items from '../marketplace/Items';
export default class Marketplace extends React.PureComponent {
- constructor(...args) {
- super(...args);
- this.state = {
- themes: [],
- settings: [],
- photo_packs: [],
- quote_packs: [],
- see_more: [],
- see_more_type: '',
- current_data: {
- type: '',
- name: '',
- content: {}
- },
- button: '',
- featured: {},
- done: false,
- item_data: {
- name: 'Name',
- author: 'Author',
- description: 'Description',
- updated: '???',
- version: '1.0.0',
- icon: ''
- }
+ constructor(...args) {
+ super(...args);
+ this.state = {
+ settings: [],
+ photo_packs: [],
+ quote_packs: [],
+ see_more: [],
+ see_more_type: '',
+ current_data: {
+ type: '',
+ name: '',
+ content: {}
+ },
+ button: '',
+ featured: {},
+ done: false,
+ item_data: {
+ name: 'Name',
+ author: 'Author',
+ description: 'Description',
+ updated: '???',
+ version: '1.0.0',
+ icon: ''
}
-
- this.offlineHTML =
-
-
-
{this.props.language.offline.title}
-
{this.props.language.offline.description}
-
-
;
+ }
+ this.buttons = {
+ uninstall:
this.manage('uninstall')}>{this.props.language.product.buttons.remove} ,
+ install:
this.manage('install')}>{this.props.language.product.buttons.addtomue}
+ }
}
- async toggle(type, type2, data) {
- if (type === 'seemore') {
+ async toggle(type, type2, data) {
+ switch (type) {
+ case 'seemore':
document.getElementById('marketplace').style.display = 'none';
document.getElementById('seemore').style.display = 'block';
- return this.setState({
- see_more: this.state[type2],
- see_more_type: type2
- });
- }
-
- if (type === 'item') {
+ this.setState({ see_more: this.state[type2], see_more_type: type2 });
+ break;
+ case 'item':
let info;
- try {
- info = await (await fetch(`${Constants.MARKETPLACE_URL}/item/${type2}/${data}`)).json();
- } catch (e) {
- return toast(this.props.toastLanguage.error);
- }
+ try { info = await (await fetch(`${Constants.MARKETPLACE_URL}/item/${type2}/${data}`)).json(); }
+ catch (e) { return toast(this.props.toastLanguage.error); }
this.setState({
current_data: { type: type2, name: data, content: info },
@@ -74,111 +63,117 @@ export default class Marketplace extends React.PureComponent {
}
});
+ let button = this.buttons.install;
+ const installed = JSON.parse(localStorage.getItem('installed'));
+ if (installed.some(item => item.name === data)) button = this.buttons.uninstall;
+ this.setState({ button: button });
+
document.getElementById('marketplace').style.display = 'none';
document.getElementById('seemore').style.display = 'none';
document.getElementById('item').style.display = 'block';
-
- let button =
this.install()}>{this.props.language.product.buttons.addtomue} ;
- const installed = JSON.parse(localStorage.getItem('installed'));
- if (installed.some(item => item.name === data)) button =
this.uninstall()}>{this.props.language.product.buttons.remove} ;
- this.setState({ button: button });
- } else {
+ break;
+ default:
document.getElementById('marketplace').style.display = 'block';
document.getElementById('item').style.display = 'none';
document.getElementById('seemore').style.display = 'none';
+ break;
}
}
- async getItems() {
- const data = await (await fetch(Constants.MARKETPLACE_URL + '/all')).json();
- const featured = await (await fetch(Constants.MARKETPLACE_URL + '/featured')).json();
- this.setState({
- themes: data.data.themes,
- settings: data.data.settings,
- photo_packs: data.data.photo_packs,
- quote_packs: data.data.quote_packs,
- see_more: data.data.photo_packs,
- featured: featured.data,
- done: true
- });
- }
+ async getItems() {
+ const data = await (await fetch(Constants.MARKETPLACE_URL + '/all')).json();
+ const featured = await (await fetch(Constants.MARKETPLACE_URL + '/featured')).json();
+ this.setState({
+ settings: data.data.settings,
+ photo_packs: data.data.photo_packs,
+ quote_packs: data.data.quote_packs,
+ see_more: data.data.photo_packs,
+ featured: featured.data,
+ done: true
+ });
+ }
- install() {
- let button;
- MarketplaceFunctions.install(this.state.current_data.type, this.state.current_data.content.data);
- toast(this.props.toastLanguage.installed);
- button =
this.uninstall()}>{this.props.language.product.buttons.remove} ;
- this.setState({ button: button });
+ manage(type) {
+ switch (type) {
+ case 'install': MarketplaceFunctions.install(this.state.current_data.type, this.state.current_data.content.data); break;
+ case 'uninstall': MarketplaceFunctions.uninstall(this.state.current_data.content.data.name, this.state.current_data.type); break;
+ default: break;
}
+ toast(this.props.toastLanguage[type + 'ed']);
+ let button = this.buttons.install;
+ if (type === 'install') button = this.buttons.uninstall;
+ this.setState({ button: button });
+ }
- uninstall() {
- MarketplaceFunctions.uninstall(this.state.current_data.name, this.state.current_data.type);
- toast(this.props.toastLanguage.removed);
- this.setState({
- button:
this.install()}>{this.props.language.product.buttons.addtomue}
- });
- }
-
- componentDidMount() {
- if (navigator.onLine === false) return;
- this.getItems();
- }
+ componentDidMount() {
+ if (navigator.onLine === false) return;
+ this.getItems();
+ }
render() {
- if (navigator.onLine === false) return this.offlineHTML;
- if (this.state.done === false) {
+ const returnMessage = (msg) => {
return (
-
{this.props.updateLanguage.loading}
+ {msg}
);
}
+ if (navigator.onLine === false) {
+ return returnMessage(
+
+
+ {this.props.language.offline.title}
+ {this.props.language.offline.description}
+
+ );
+ }
+
+ if (this.state.done === false) return returnMessage(
{this.props.updateLanguage.loading} )
+
return (
-
+
{this.state.featured.title}
{this.state.featured.name}
window.location.href = this.state.featured.buttonLink}>{this.state.featured.buttonText}
-
-
+ this.toggle('item', 'photo_packs', input)}
seeMoreFunction={() => this.toggle('seemore', 'photo_packs')} />
- this.toggle('item', 'settings', input)}
seeMoreFunction={() => this.toggle('seemore', 'settings')} />
- this.toggle('item', 'quote_packs', input)}
seeMoreFunction={() => this.toggle('seemore', 'quote_packs')} />
-
-
-
+
- this.toggle()} language={this.props.language.product}
- />
-
+ function={() => this.toggle()} language={this.props.language.product} />
+
this.toggle()} />
this.toggle('item', this.state.see_more_type, input)}
- items={this.state.see_more}
- />
-
+ items={this.state.see_more} />
+
- )
+ );
}
}
\ No newline at end of file
diff --git a/src/components/widgets/Date.jsx b/src/components/widgets/Date.jsx
index 879a3e1f..6d0fd5a9 100644
--- a/src/components/widgets/Date.jsx
+++ b/src/components/widgets/Date.jsx
@@ -63,6 +63,6 @@ export default class DateWidget extends React.PureComponent {
}
render() {
- return {this.state.date}
+ return {this.state.date}
}
}
\ No newline at end of file
diff --git a/src/modules/helpers/background/hexToRgb.js b/src/modules/helpers/background/hexToRgb.js
index 4e458912..1d7e92b5 100644
--- a/src/modules/helpers/background/hexToRgb.js
+++ b/src/modules/helpers/background/hexToRgb.js
@@ -10,7 +10,6 @@ export default function hexToRgb(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');
const red = parseInt(value.substr(0, 2), 16);
diff --git a/src/modules/helpers/background/rgbToHsv.js b/src/modules/helpers/background/rgbToHsv.js
index a5c02bb6..5738d639 100644
--- a/src/modules/helpers/background/rgbToHsv.js
+++ b/src/modules/helpers/background/rgbToHsv.js
@@ -1,16 +1,14 @@
export default function rgbToHSv({ red, green, blue }) {
- let rr;
- let gg;
- let bb;
- let h;
- let s;
+ let rr, gg, bb, h, s;
const rabs = red / 255;
const gabs = green / 255;
const babs = blue / 255;
+
const v = Math.max(rabs, gabs, babs);
const diff = v - Math.min(rabs, gabs, babs);
const diffc = c => (v - c) / 6 / diff + 1 / 2;
+
if (diff === 0) {
h = 0;
s = 0;
@@ -20,18 +18,11 @@ 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 {
diff --git a/src/modules/helpers/background/setRgba.js b/src/modules/helpers/background/setRgba.js
index e93c26c6..b1efcad5 100644
--- a/src/modules/helpers/background/setRgba.js
+++ b/src/modules/helpers/background/setRgba.js
@@ -10,9 +10,7 @@ export default function setRGBA(red, green, blue, alpha) {
blue: blue | 0,
};
- if (isValidRGBValue(alpha) === true) {
- color.alpha = alpha | 0;
- }
+ if (isValidRGBValue(alpha) === true) color.alpha = alpha | 0;
// RGBToHSL(color.r, color.g, color.b);
diff --git a/src/modules/helpers/marketplace.js b/src/modules/helpers/marketplace.js
index aa4a6e64..ac284b0e 100644
--- a/src/modules/helpers/marketplace.js
+++ b/src/modules/helpers/marketplace.js
@@ -7,39 +7,31 @@ export default class MarketplaceFunctions {
}
static uninstall(name, type) {
- let installed = JSON.parse(localStorage.getItem('installed'));
-
- const uninstallStuff = () => {
- for (let i = 0; i < installed.length; i++) {
- if (installed[i].name === name) {
- installed.splice(i, 1);
- break;
- }
- }
- localStorage.setItem('installed', JSON.stringify(installed));
- };
-
switch (type) {
case 'settings':
const oldSettings = JSON.parse(localStorage.getItem('backup_settings'));
localStorage.clear();
oldSettings.forEach(item => localStorage.setItem(item.name, item.value));
- uninstallStuff();
break;
case 'quote_packs':
- localStorage.removeItem('quote_packs');
- localStorage.removeItem('quote_api');
- uninstallStuff();
- break;
+ localStorage.removeItem('quote_packs');
+ localStorage.removeItem('quote_api');
+ break;
default:
- try {
- localStorage.removeItem(type);
- uninstallStuff();
- } catch (e) {
+ try { localStorage.removeItem(type); }
+ catch (e) {
toast('Failed to uninstall addon, check the console');
console.error(e);
}
- }
+ }
+ let installed = JSON.parse(localStorage.getItem('installed'));
+ for (let i = 0; i < installed.length; i++) {
+ if (installed[i].name === name) {
+ installed.splice(i, 1);
+ break;
+ }
+ }
+ localStorage.setItem('installed', JSON.stringify(installed));
}
static install(type, input, sideload) {
@@ -54,9 +46,6 @@ export default class MarketplaceFunctions {
case 'photo_packs':
localStorage.setItem('photo_packs', JSON.stringify(input.photos));
break;
- case 'theme':
- localStorage.setItem('theme', input.theme);
- break;
case 'quote_packs':
if (input.quote_api) localStorage.setItem('quote_api', JSON.stringify(input.quote_api));
localStorage.setItem('quote_packs', JSON.stringify(input.quotes));
diff --git a/src/translations/en.json b/src/translations/en.json
index 73f30d8a..1a95a599 100644
--- a/src/translations/en.json
+++ b/src/translations/en.json
@@ -90,7 +90,7 @@
"quote": "Quote Copied",
"reset": "Reset successfully",
"installed": "Successfully installed",
- "removed": "Successfully removed",
+ "uninstalled": "Successfully removed",
"error": "Something went wrong",
"imported": "Successfully imported"
},
@@ -142,5 +142,13 @@
"title": "Notes",
"placeholder": "Type here"
}
+ },
+ "welcome": {
+ "title": "Welcome to",
+ "information": "Information",
+ "thankyoumessage1": "Thank you for downloading Mue Tab,",
+ "thankyoumessage2": "we hope you enjoy your time with our extension.",
+ "support": "Support",
+ "close": "Close"
}
}
\ No newline at end of file