diff --git a/src/components/Background.jsx b/src/components/Background.jsx index 5987f489..eaf03fb6 100644 --- a/src/components/Background.jsx +++ b/src/components/Background.jsx @@ -2,9 +2,6 @@ import React from 'react'; import Fetch from 'unfetch'; -// Pick random number -const randomInt = (min, max) => { return Math.floor(Math.random() * (max - min + 1)) + min; }; - export default class Background extends React.Component { async getAndSetBackground() { try { // First we try and get an image from the API... @@ -17,7 +14,7 @@ export default class Background extends React.Component { } catch (e) { // ..and if that fails we load one locally document.getElementById('backgroundCredits').style.display = 'none'; document.getElementById('photographer').innerText = 'Photo from Pexels'; - document.getElementById('root').style.backgroundImage = `url(../offline-images/${randomInt(1, 25)}.jpeg)`; + document.getElementById('root').style.backgroundImage = `url(../offline-images/${Math.floor(Math.random() * (20 - 1 + 1)) + 1})`; } } diff --git a/src/components/Clock.jsx b/src/components/Clock.jsx index 41046ed1..1869d296 100644 --- a/src/components/Clock.jsx +++ b/src/components/Clock.jsx @@ -13,13 +13,11 @@ export default class Clock extends React.Component { startTime() { const today = new Date(); // Get the current date let h = today.getHours(); // Get hours - const ampm = h >= 12 ? 'PM' : 'AM'; // Set AM/PM - const m = today.getMinutes(); // Get minutes // const s = today.getSeconds(); if (h > 12) h = h - 12; - this.setState({ date: `${('0' + h).slice(-2)}:${('0' + m).slice(-2)}`, ampm: ampm }); + this.setState({ date: `${('0' + h).slice(-2)}:${('0' + today.getMinutes()).slice(-2)}`, ampm: h >= 12 ? 'PM' : 'AM' }); this.timeout = setTimeout(() => this.startTime(), 500); } diff --git a/src/components/Credit.jsx b/src/components/Credit.jsx index 6d538814..8b57c4fa 100644 --- a/src/components/Credit.jsx +++ b/src/components/Credit.jsx @@ -7,10 +7,11 @@ export default class Search extends React.Component { render() { return (