mirror of
https://github.com/mue/mue.git
synced 2026-07-10 05:55:17 +02:00
make codacy happy
This commit is contained in:
11
src/App.jsx
11
src/App.jsx
@@ -10,9 +10,9 @@ import './css/index.css';
|
||||
|
||||
//* Functions
|
||||
const getCookie = (cookiename) => {
|
||||
let cookiestring = RegExp('' + cookiename + '[^;]+').exec(document.cookie);
|
||||
const cookiestring = RegExp('' + cookiename + '[^;]+').exec(document.cookie);
|
||||
return unescape(!!cookiestring ? cookiestring.toString().replace(/^[^=]+./,'') : '');
|
||||
}
|
||||
};
|
||||
|
||||
const randomInt = (min, max) => { return Math.floor(Math.random() * (max - min + 1)) + min; };
|
||||
|
||||
@@ -35,12 +35,12 @@ export default class App extends React.Component {
|
||||
|
||||
// Set background: Attempt to get one from the API first, and if that fails then use the offline ones.
|
||||
async getAndSetBackground() {
|
||||
let root = document.getElementById('root');
|
||||
const root = document.getElementById('root');
|
||||
try {
|
||||
let data = await Fetch('https://api.muetab.xyz/getImage?category=Outdoors');
|
||||
data = await data.json();
|
||||
|
||||
let checkRepeat = getCookie('backgroundimageurl');
|
||||
const checkRepeat = getCookie('backgroundimageurl');
|
||||
document.getElementById('photographer').innerText = `Photo by ${data.photographer}`;
|
||||
let location = data.location;
|
||||
if (data.location === 'Lake') location = 'Lake District';
|
||||
@@ -57,8 +57,7 @@ export default class App extends React.Component {
|
||||
document.cookie = `backgroundimageurl=${data.file}`;
|
||||
}
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
document.getElementById('backgroundCredits').style.display = "none";
|
||||
document.getElementById('backgroundCredits').style.display = 'none';
|
||||
document.getElementById('photographer').innerText = 'Photo from Pexels';
|
||||
root.style.backgroundImage = `url(../offline-images/${randomInt(1, 25)}.jpeg)`;
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@ import ReactDOM from 'react-dom';
|
||||
import './index.css';
|
||||
import App from './App.jsx';
|
||||
import * as serviceWorker from './serviceWorker';
|
||||
//import './i18n.jsx';
|
||||
|
||||
ReactDOM.render(
|
||||
<App />,
|
||||
|
||||
@@ -3,7 +3,7 @@ import React from 'react';
|
||||
const checkTime = (i) => {
|
||||
if (i < 10) i = '0' + i;
|
||||
return i;
|
||||
}
|
||||
};
|
||||
|
||||
export default class Clock extends React.Component {
|
||||
constructor(...args) {
|
||||
@@ -16,9 +16,9 @@ export default class Clock extends React.Component {
|
||||
|
||||
startTime() {
|
||||
const today = new Date();
|
||||
let h = today.getHours();
|
||||
let ampm = h >= 12 ? 'PM' : 'AM';
|
||||
const m = checkTime(today.getMinutes());
|
||||
let h = today.getHours();
|
||||
const ampm = h >= 12 ? 'PM' : 'AM';
|
||||
const m = checkTime(today.getMinutes());
|
||||
// const s = checkTime(today.getSeconds());
|
||||
|
||||
if (h > 12) h = h - 12;
|
||||
|
||||
@@ -10,7 +10,6 @@ export default class Search extends React.Component {
|
||||
<h1 id='photographer'></h1>
|
||||
<div id='backgroundCredits' class='tooltip'><RoomIcon classname='locationicon'/>
|
||||
<span class='tooltiptext' id='location'></span>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
||||
@@ -9,9 +9,9 @@ export default class Greeting extends React.Component {
|
||||
}
|
||||
|
||||
getGreeting() {
|
||||
const h = new Date().getHours();
|
||||
let t = 'Good evening'; // Set the default time string to "Good evening"
|
||||
if (h < 12) t = 'Good morning'; // If it's before 12am, set the time string to "Good morning"
|
||||
const h = new Date().getHours();
|
||||
let t = 'Good evening'; // Set the default time string to "Good evening"
|
||||
if (h < 12) t = 'Good morning'; // If it's before 12am, set the time string to "Good morning"
|
||||
else if (h < 18) t = 'Good afternoon'; // If it's before 6pm, set the time string to "Good afternoon"
|
||||
this.setState({ greeting: t }); // Set the state to the time string
|
||||
}
|
||||
|
||||
@@ -18,8 +18,8 @@ export default class Quote extends React.Component {
|
||||
this.setState({ quote: data.quote, author: data.author });
|
||||
} catch (e) {
|
||||
const randomInt = (min, max) => { return Math.floor(Math.random() * (max - min + 1)) + min; };
|
||||
const num = randomInt(1, 20);
|
||||
this.setState({ quote: quotes[num].quote, author: quotes[num].author })
|
||||
const num = randomInt(1, 20);
|
||||
this.setState({ quote: quotes[num].quote, author: quotes[num].author });
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ export default class Search extends React.Component {
|
||||
<div id='searchBar' className='search-bar'>
|
||||
<form id='searchBar' className='searchbarform' action='https://duckduckgo.com/' onSubmit={('search()')}>
|
||||
<input type='text' placeholder='Search' name='q' id='searchText'className='searchText' />
|
||||
<div class="blursearcbBG" />
|
||||
<div class='blursearcbBG' />
|
||||
</form>
|
||||
</div>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user