mirror of
https://github.com/mue/mue.git
synced 2026-07-16 13:34:03 +02:00
cleanup
This commit is contained in:
@@ -55,8 +55,7 @@ export default class MainModal extends React.PureComponent {
|
||||
settingsActive: ''
|
||||
});
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -73,6 +72,6 @@ export default class MainModal extends React.PureComponent {
|
||||
<br/>
|
||||
{this.state.tab}
|
||||
</div>
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
import React from 'react';
|
||||
import * as Constants from '../../modules/constants';
|
||||
import * as Constants from '../../modules/Constants';
|
||||
|
||||
export default class Update extends React.PureComponent {
|
||||
constructor(...args) {
|
||||
|
||||
@@ -21,7 +21,7 @@ export default class Welcome extends React.PureComponent {
|
||||
<br/>
|
||||
<button className='close' onClick={this.props.modalClose}>{this.props.language.close}</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
import React from 'react';
|
||||
import SettingsFunctions from '../../../modules/helpers/settings';
|
||||
import SettingsFunctions from '../../../modules/helpers/Settings';
|
||||
import CheckboxUI from '@material-ui/core/Checkbox';
|
||||
import FormControlLabel from '@material-ui/core/FormControlLabel';
|
||||
|
||||
|
||||
@@ -13,29 +13,27 @@ export default class Section extends React.PureComponent {
|
||||
|
||||
toggleSection() {
|
||||
const display = (this.state.display === 'none') ? 'block': 'none';
|
||||
const transform = (this.state.transform === 'rotate(0)') ? 'rotate(-180deg)' : 'rotate(0)';
|
||||
|
||||
this.setState({
|
||||
display: display,
|
||||
transform: transform
|
||||
transform: (this.state.transform === 'rotate(0)') ? 'rotate(-180deg)' : 'rotate(0)'
|
||||
});
|
||||
|
||||
if (this.props.onToggle) {
|
||||
this.props.onToggle(display);
|
||||
}
|
||||
if (this.props.onToggle) this.props.onToggle(display);
|
||||
}
|
||||
|
||||
render() {
|
||||
let extraHTML, expandMore, slider, noDropdown;
|
||||
|
||||
if (this.props.children) {
|
||||
extraHTML = <li className='extraSettings'>{this.props.children}</li>
|
||||
expandMore = <ExpandMore
|
||||
style={{ 'transition': 'all 0.5s ease 0s', 'transform': this.state.transform }}
|
||||
className={`expandIcons`}
|
||||
onClick={() => this.toggleSection()}
|
||||
/>;
|
||||
expandMore = (
|
||||
<ExpandMore
|
||||
style={{ 'transition': 'all 0.5s ease 0s', 'transform': this.state.transform }}
|
||||
className={`expandIcons`}
|
||||
onClick={() => this.toggleSection()} />
|
||||
);
|
||||
}
|
||||
|
||||
if (this.props.slider !== false) slider = <Slider name={this.props.name} />;
|
||||
if (this.props.noDropdown) noDropdown = 'nodropdown';
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import React from 'react';
|
||||
import SettingsFunctions from '../../../modules/helpers/settings';
|
||||
import SettingsFunctions from '../../../modules/helpers/Settings';
|
||||
|
||||
export default class Slider extends React.PureComponent {
|
||||
constructor(...args) {
|
||||
|
||||
@@ -7,6 +7,9 @@ import { ColorPicker } from 'react-color-gradient-picker';
|
||||
import hexToRgb from '../../../../modules/helpers/background/hexToRgb';
|
||||
import rgbToHex from '../../../../modules/helpers/background/rgbToHex';
|
||||
|
||||
import 'react-color-gradient-picker/dist/index.css';
|
||||
import '../../../../scss/react-color-picker-gradient-picker-custom-styles.scss';
|
||||
|
||||
export default class BackgroundSettings extends React.PureComponent {
|
||||
DefaultGradientSettings = { "angle": "180", "gradient": [{ "colour": this.props.language.background.disabled, "stop": 0 }], "type": "linear" };
|
||||
GradientPickerInitalState = undefined;
|
||||
@@ -171,7 +174,8 @@ export default class BackgroundSettings extends React.PureComponent {
|
||||
<div key={i}>
|
||||
<input id={'colour_' + i} type='color' name='colour' className='colour' onChange={(event) => this.onGradientChange(event, i)} value={g.colour}></input>
|
||||
<label htmlFor={'colour_' + i} className='customBackgroundHex'>{g.colour}</label>
|
||||
</div>);
|
||||
</div>
|
||||
);
|
||||
});
|
||||
}
|
||||
colourSettings = (
|
||||
@@ -180,7 +184,8 @@ export default class BackgroundSettings extends React.PureComponent {
|
||||
{this.state.gradientSettings.gradient[0].colour !== this.props.language.background.disabled &&
|
||||
!gradientHasMoreThanOneColour ? (<button type='button' className='add' onClick={this.addColour}>{this.props.language.background.add_colour}</button>) : null
|
||||
}
|
||||
</div>);
|
||||
</div>
|
||||
);
|
||||
}
|
||||
return (
|
||||
<React.Fragment>
|
||||
|
||||
@@ -9,8 +9,7 @@ export default class LanguageSettings extends React.PureComponent {
|
||||
<Dropdown
|
||||
name='language'
|
||||
id='language'
|
||||
onChange={() => localStorage.setItem('language', document.getElementById('language').value)}
|
||||
>
|
||||
onChange={() => localStorage.setItem('language', document.getElementById('language').value)} >
|
||||
<option className='choices' value='en'>English</option>
|
||||
<option className='choices' value='es'>Español</option>
|
||||
<option className='choices' value='fr'>Français</option>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import React from 'react';
|
||||
import SettingsFunctions from '../../../../modules/helpers/settings';
|
||||
import SettingsFunctions from '../../../../modules/helpers/Settings';
|
||||
import { toast } from 'react-toastify';
|
||||
import Section from '../Section';
|
||||
import Dropdown from '../Dropdown';
|
||||
@@ -31,8 +31,7 @@ export default class SearchSettings extends React.PureComponent {
|
||||
<Dropdown label={this.props.language.searchbar.search_engine}
|
||||
name='searchEngine'
|
||||
id='searchEngine'
|
||||
onChange={() => SettingsFunctions.setSearchEngine(document.getElementById('searchEngine').value)}
|
||||
>
|
||||
onChange={() => SettingsFunctions.setSearchEngine(document.getElementById('searchEngine').value)} >
|
||||
{searchEngines.map((engine) =>
|
||||
<option key={engine.name} className='choices' value={engine.settingsName}>{engine.name}</option>
|
||||
)}
|
||||
|
||||
@@ -3,13 +3,13 @@ import LocalMallIcon from '@material-ui/icons/LocalMall';
|
||||
import { toast } from 'react-toastify';
|
||||
import Item from '../marketplace/Item';
|
||||
import Items from '../marketplace/Items';
|
||||
import MarketplaceFunctions from '../../../modules/helpers/marketplace';
|
||||
import MarketplaceFunctions from '../../../modules/helpers/Marketplace';
|
||||
|
||||
export default class Addons extends React.PureComponent {
|
||||
constructor(...args) {
|
||||
super(...args);
|
||||
this.state = {
|
||||
installed: [],
|
||||
installed: JSON.parse(localStorage.getItem('installed')),
|
||||
current_data: {
|
||||
type: '',
|
||||
name: '',
|
||||
@@ -26,7 +26,7 @@ export default class Addons extends React.PureComponent {
|
||||
button: ''
|
||||
}
|
||||
this.buttons = {
|
||||
uninstall: <button className='removeFromMue' onClick={() => this.uninstall()}>{this.props.marketplaceLanguage.product.buttons.remove}</button>,
|
||||
uninstall: <button className='removeFromMue' onClick={() => this.manage('uninstall')}>{this.props.marketplaceLanguage.product.buttons.remove}</button>,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,38 +55,24 @@ export default class Addons extends React.PureComponent {
|
||||
this.setState({ button: this.buttons.uninstall });
|
||||
}
|
||||
|
||||
uninstall() {
|
||||
let type, data = this.state.current_data.content.type;
|
||||
switch (data) {
|
||||
case 'photos': type = 'photo_packs'; break;
|
||||
case 'quotes': type = 'quote_packs'; break;
|
||||
default: type = this.state.current_data.type; break;
|
||||
}
|
||||
MarketplaceFunctions.uninstall(this.state.current_data.name, type);
|
||||
toast(this.props.toastLanguage.uninstalled);
|
||||
this.setState({
|
||||
button: '',
|
||||
installed: JSON.parse(localStorage.getItem('installed'))
|
||||
});
|
||||
}
|
||||
|
||||
install(input) {
|
||||
MarketplaceFunctions.install(input.type, input, true);
|
||||
toast(this.props.toastLanguage.installed);
|
||||
this.setState({
|
||||
button: this.buttons.uninstall,
|
||||
installed: JSON.parse(localStorage.getItem('installed'))
|
||||
});
|
||||
manage(type, input) {
|
||||
switch (type) {
|
||||
case 'install': MarketplaceFunctions.install(input.type, input, true); break;
|
||||
case 'uninstall': MarketplaceFunctions.uninstall(this.state.current_data.name, this.state.current_data.content.type); break;
|
||||
default: break;
|
||||
}
|
||||
toast(this.props.toastLanguage[type + 'ed']);
|
||||
let button = '';
|
||||
if (type === 'install') button = this.buttons.uninstall;
|
||||
this.setState({ button: button, installed: JSON.parse(localStorage.getItem('installed')) });
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
document.getElementById('file-input').onchange = (e) => {
|
||||
const reader = new FileReader();
|
||||
reader.readAsText(e.target.files[0], 'UTF-8');
|
||||
reader.onload = (readerEvent) => this.install(JSON.parse(readerEvent.target.result));
|
||||
reader.onload = (readerEvent) => this.manage('install', JSON.parse(readerEvent.target.result));
|
||||
};
|
||||
|
||||
this.setState({ installed: JSON.parse(localStorage.getItem('installed')) });
|
||||
}
|
||||
|
||||
render() {
|
||||
@@ -96,25 +82,25 @@ export default class Addons extends React.PureComponent {
|
||||
content = (
|
||||
<div className='items'>
|
||||
<div className='emptyMessage'>
|
||||
<LocalMallIcon/>
|
||||
<h1>{this.props.language.empty.title}</h1>
|
||||
<p className='description'>{this.props.language.empty.description}</p>
|
||||
<button className='goToMarket' onClick={this.props.openMarketplace}>{this.props.language.empty.button}</button>
|
||||
<LocalMallIcon/>
|
||||
<h1>{this.props.language.empty.title}</h1>
|
||||
<p className='description'>{this.props.language.empty.description}</p>
|
||||
<button className='goToMarket' onClick={this.props.openMarketplace}>{this.props.language.empty.button}</button>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<div>
|
||||
<div id='marketplace'>
|
||||
<React.Fragment>
|
||||
<div id='marketplace'>
|
||||
<input id='file-input' type='file' name='name' className='hidden' accept='application/json' />
|
||||
<button className='addToMue sideload' onClick={() => document.getElementById('file-input').click()}>{this.props.language.sideload}</button>
|
||||
<h1>{this.props.language.added}</h1>
|
||||
{content}
|
||||
</div>
|
||||
<Item button={this.state.button} data={this.state.item_data} function={() => this.toggle()} language={this.props.marketplaceLanguage.product} />
|
||||
</div>
|
||||
);
|
||||
</div>
|
||||
<Item button={this.state.button} data={this.state.item_data} function={() => this.toggle()} language={this.props.marketplaceLanguage.product} />
|
||||
</React.Fragment>
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,8 +3,8 @@ import WifiOffIcon from '@material-ui/icons/WifiOff';
|
||||
import ArrowBackIcon from '@material-ui/icons/ArrowBack';
|
||||
import { toast } from 'react-toastify';
|
||||
import Item from '../marketplace/Item';
|
||||
import MarketplaceFunctions from '../../../modules/helpers/marketplace';
|
||||
import * as Constants from '../../../modules/constants';
|
||||
import MarketplaceFunctions from '../../../modules/helpers/Marketplace';
|
||||
import * as Constants from '../../../modules/Constants';
|
||||
import Items from '../marketplace/Items';
|
||||
|
||||
export default class Marketplace extends React.PureComponent {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import React from 'react';
|
||||
import SettingsFunctions from '../../../modules/helpers/settings';
|
||||
import SettingsFunctions from '../../../modules/helpers/Settings';
|
||||
import Checkbox from '../settings/Checkbox';
|
||||
import Section from '../settings/Section';
|
||||
import { toast } from 'react-toastify';
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import React from 'react';
|
||||
import * as Constants from '../../modules/constants';
|
||||
import * as Constants from '../../modules/Constants';
|
||||
|
||||
export default class Background extends React.PureComponent {
|
||||
gradientStyleBuilder(gradientSettings) {
|
||||
@@ -80,11 +80,10 @@ export default class Background extends React.PureComponent {
|
||||
this.setBackground(randomPhoto.url.default, null, randomPhoto.photographer);
|
||||
this.setCredit(randomPhoto.photographer);
|
||||
document.getElementById('location').textContent = randomPhoto.location;
|
||||
} else if (customBackgroundColour) {
|
||||
this.setBackground(null, customBackgroundColour, 'false');
|
||||
} else if (customBackground !== '') { // Local
|
||||
this.setBackground(customBackground, null, 'false');
|
||||
} else if (customBackgroundVideo) {
|
||||
}
|
||||
else if (customBackgroundColour) this.setBackground(null, customBackgroundColour, 'false');
|
||||
else if (customBackground !== '') this.setBackground(customBackground, null, 'false'); // Local
|
||||
else if (customBackgroundVideo) {
|
||||
document.getElementById('backgroundImage').innerHTML = `
|
||||
<video autoplay muted loop id="backgroundVideo">
|
||||
<source src="${customBackgroundVideo}"/>
|
||||
|
||||
@@ -34,14 +34,9 @@ export default class DateWidget extends React.PureComponent {
|
||||
|
||||
let format;
|
||||
switch (localStorage.getItem('shortFormat')) {
|
||||
case 'dash':
|
||||
format = `${day}-${month}-${year}`;
|
||||
break;
|
||||
case 'gaps':
|
||||
format = `${day} - ${month} - ${year}`;
|
||||
break;
|
||||
default:
|
||||
format = `${day}/${month}/${year}`;
|
||||
case 'dash': format = `${day}-${month}-${year}`; break;
|
||||
case 'gaps': format = `${day} - ${month} - ${year}`; break;
|
||||
default: format = `${day}/${month}/${year}`;
|
||||
}
|
||||
|
||||
this.setState({ date: format });
|
||||
|
||||
@@ -17,7 +17,7 @@ export default class View extends React.PureComponent {
|
||||
}
|
||||
|
||||
viewStuff() {
|
||||
const elements = ['#searchBar', '.navbar-container', '.clock', '.greeting', '.quotediv', 'time'];
|
||||
const elements = ['#searchBar', '.navbar-container', '.clock', '.greeting', '.quotediv', 'time']; // elements to hide
|
||||
elements.forEach((element) => {
|
||||
try {
|
||||
(this.state.hidden === false) ? document.querySelector(element).style.display = 'none' : document.querySelector(element).style.display = 'block';
|
||||
|
||||
@@ -19,8 +19,7 @@ export default class Notes extends React.PureComponent {
|
||||
|
||||
pin() {
|
||||
document.getElementById('noteContainer').classList.toggle('visibilityshow');
|
||||
if (localStorage.getItem('notesPinned') === 'true') localStorage.setItem('notesPinned', false);
|
||||
else localStorage.setItem('notesPinned', true);
|
||||
(localStorage.getItem('notesPinned') === 'true') ? localStorage.setItem('notesPinned', false) : localStorage.setItem('notesPinned', true);
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
|
||||
@@ -2,7 +2,7 @@ import React from 'react';
|
||||
import Quotes from '@muetab/quotes';
|
||||
import FileCopy from '@material-ui/icons/FilterNone';
|
||||
import { toast } from 'react-toastify';
|
||||
import * as Constants from '../../modules/constants';
|
||||
import * as Constants from '../../modules/Constants';
|
||||
import TwitterIcon from '@material-ui/icons/Twitter';
|
||||
import StarIcon from '@material-ui/icons/Star';
|
||||
import StarIcon2 from '@material-ui/icons/StarBorder';
|
||||
|
||||
@@ -14,7 +14,6 @@ export default class Search extends React.PureComponent {
|
||||
}
|
||||
|
||||
startSpeechRecognition() {
|
||||
if (localStorage.getItem('voiceSearch') === 'false') return;
|
||||
const voiceSearch = new window.webkitSpeechRecognition();
|
||||
voiceSearch.start();
|
||||
voiceSearch.onresult = (event) => document.getElementById('searchtext').value = event.results[0][0].transcript;
|
||||
@@ -34,8 +33,7 @@ export default class Search extends React.PureComponent {
|
||||
if (info.query) query = info.query;
|
||||
}
|
||||
|
||||
const custom = localStorage.getItem('customSearchEngine');
|
||||
if (custom) url = custom;
|
||||
if (setting === 'custom') url = localStorage.getItem('customSearchEngine');
|
||||
|
||||
const searchButton = () => {
|
||||
const value = document.getElementById('searchtext').value || 'mue fast';
|
||||
|
||||
Reference in New Issue
Block a user