More bug fixes

This commit is contained in:
David Ralph
2020-09-21 22:23:04 +01:00
parent d1b998da12
commit 2dd0e9150b
4 changed files with 12 additions and 6 deletions

View File

@@ -43,17 +43,17 @@ export default class Background extends React.PureComponent {
const customBackground = localStorage.getItem('customBackground');
const favourited = JSON.parse(localStorage.getItem('favourite'));
if (photoPack) {
if (favourited) {
this.setBackground(favourited.url, null, 'true');
this.setCredit(favourited.credit);
document.getElementById('location').textContent = favourited.location;
} else if (photoPack) {
const randomPhoto = photoPack[Math.floor(Math.random() * photoPack.length)];
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 (favourited) {
this.setBackground(favourited.url, null, 'true');
this.setCredit(favourited.credit);
document.getElementById('location').textContent = favourited.location;
} else if (customBackground !== '') { // Local
this.setBackground(customBackground, null, 'false');
} else { // Online

View File

@@ -35,6 +35,7 @@ export default class Clock extends React.PureComponent {
if (localStorage.getItem('24hour') === 'true') {
let time = '';
if (zero === 'false') time = `${now.getHours()}:${now.getMinutes()}${sec}`;
else time = `${('00' + now.getHours()).slice(-2)}:${('00' + now.getMinutes()).slice(-2)}${sec}`;
this.setState({
time: time
@@ -51,6 +52,7 @@ export default class Clock extends React.PureComponent {
let time = '';
if (zero === 'false') time = `${hours}:${now.getMinutes()}${sec}`;
else time = `${('00' + hours).slice(-2)}:${('00' + now.getMinutes()).slice(-2)}${sec}`;
this.setState({
time: time,
ampm: ampm

View File

@@ -19,7 +19,7 @@ export default class View extends React.PureComponent {
}
viewStuff() {
const elements = ['#searchBar', '.navbar-container', '.clock', '.greeting', '.quotediv'];
const elements = ['#searchBar', '.navbar-container', '.clock', '.greeting', '.quotediv', 'time'];
elements.forEach((element) => {
try {
(this.state.hidden === false) ? document.querySelector(element).style.display = 'none' : document.querySelector(element).style.display = 'block';

View File

@@ -206,4 +206,8 @@ select {
select#language {
float: right;
}
#customBackgroundColour {
cursor: pointer;
}