style: make comments consistent by placing them on their own line

This commit is contained in:
Wessel Tip
2021-03-17 15:41:50 +01:00
parent 895973e95b
commit 67562c7297
18 changed files with 93 additions and 49 deletions

View File

@@ -16,7 +16,8 @@ export default class Background extends React.PureComponent {
return style;
}
setBackground(url, colour, credit) { // Sets the attributes of the background image
// Sets the attributes of the background image
setBackground(url, colour, credit) {
let gradientSettings = '';
try {
gradientSettings = JSON.parse(colour);
@@ -42,8 +43,9 @@ export default class Background extends React.PureComponent {
`${background}; -webkit-filter: blur(${localStorage.getItem('blur')}px) brightness(${brightness}%);`
);
// Hide the credit
if (credit === 'false' && document.querySelector('#credits')) {
document.querySelector('#credits').style.display = 'none'; // Hide the credit
document.querySelector('#credits').style.display = 'none';
}
}
@@ -58,22 +60,27 @@ export default class Background extends React.PureComponent {
document.getElementById('photographerCard').textContent = credit;
}
doOffline() { // Handles setting the background if the user is offline
// Handles setting the background if the user is offline
doOffline() {
const offlineImages = require('./offline_images.json');
const photographers = Object.keys(offlineImages); // Get all photographers from the keys in offlineImages.json
const photographer = photographers[Math.floor(Math.random() * photographers.length)]; // Select a random photographer from the keys
// Get all photographers from the keys in offlineImages.json
const photographers = Object.keys(offlineImages);
// Select a random photographer from the keys
const photographer = photographers[Math.floor(Math.random() * photographers.length)];
// Select a random image
const randomImage = offlineImages[photographer].photo[
Math.floor(Math.random() * offlineImages[photographer].photo.length)
]; // Select a random image
];
const url = `./offline-images/${randomImage}.jpg`;
this.setBackground(url);
this.setCredit(photographer);
//document.querySelector('#backgroundCredits').style.display = 'none'; // Hide the location icon
// Hide the location icon
//document.querySelector('#backgroundCredits').style.display = 'none';
}
async determineMode() {
@@ -113,30 +120,37 @@ export default class Background extends React.PureComponent {
<source src='${customBackground}'/>
</video>`;
} else {
this.setBackground(customBackground, null, 'false'); // Local
// Local
this.setBackground(customBackground, null, 'false');
}
} else { // Online
// Online
} else {
if (offlineMode === 'true') {
return this.doOffline();
}
try { // First we try and get an image from the API...
// First we try and get an image from the API...
try {
let requestURL;
switch (localStorage.getItem('backgroundAPI')) {
case 'unsplash':
requestURL = `${Constants.UNSPLASH_URL}/getImage`;
break;
default: // Defaults to Mue
// Defaults to Mue
default:
requestURL = `${Constants.API_URL}/getImage?category=Outdoors`;
break;
}
const data = await (await fetch(requestURL)).json(); // Fetch JSON data from requestURL
// Fetch JSON data from requestURL
const data = await (await fetch(requestURL)).json();
// If we hit the rate limit, fallback to local images
if (data.statusCode === 429) {
this.doOffline(); // If we hit the rate limit, fallback to local images
} else { // Otherwise, set the background and credit from remote data
this.doOffline();
// Otherwise, set the background and credit from remote data
} else {
this.setBackground(data.file);
if (localStorage.getItem('backgroundAPI') === 'unsplash') {
@@ -152,16 +166,19 @@ export default class Background extends React.PureComponent {
return document.querySelector('#backgroundCredits').style.display = 'none';
}
document.getElementById('location').innerText = `${data.location.replace('null', '')}`; // Set the location tooltip
} catch (e) { // ..and if that fails we load one locally
// Set the location tooltip
document.getElementById('location').innerText = `${data.location.replace('null', '')}`;
// ..and if that fails we load one locally
} catch (e) {
this.doOffline();
}
}
}
componentDidMount() {
// Hide the credit
if (localStorage.getItem('background') === 'false') {
return document.querySelector('.photoInformation').style.display = 'none'; // Hide the credit
return document.querySelector('.photoInformation').style.display = 'none';
}
if (localStorage.getItem('customBackgroundColour') !== 'Disabled') {

View File

@@ -18,7 +18,8 @@ export default class View extends React.PureComponent {
}
viewStuff() {
const elements = ['#searchBar', '.navbar-container', '.clock', '.greeting', '.quotediv', 'time']; // elements to hide
// elements to hide
const elements = ['#searchBar', '.navbar-container', '.clock', '.greeting', '.quotediv', 'time'];
elements.forEach((element) => {
try {

View File

@@ -19,12 +19,15 @@ export default class Greeting extends React.PureComponent {
const month = time.getMonth();
const date = time.getDate();
// If it's December 25th, set the greeting string to "Merry Christmas"
if (month === 11 && date === 25) {
message = this.props.language.christmas; // If it's December 25th, set the greeting string to "Merry Christmas"
message = this.props.language.christmas;
// If the date is January 1st, set the greeting string to "Happy new year"
} else if (month === 0 && date === 1) {
message = this.props.language.newyear; // If the date is January 1st, set the greeting string to "Happy new year"
message = this.props.language.newyear;
// If it's October 31st, set the greeting string to "Happy Halloween"
} else if (month === 9 && date === 31) {
message = this.props.language.halloween; // If it's October 31st, set the greeting string to "Happy Halloween"
message = this.props.language.halloween;
}
return message;
@@ -34,11 +37,14 @@ export default class Greeting extends React.PureComponent {
const now = new Date();
const hour = now.getHours();
let message = this.props.language.evening; // Set the default greeting string to "Good evening"
// Set the default greeting string to "Good evening"
let message = this.props.language.evening;
// If it's before 12am, set the greeting string to "Good morning"
if (hour < 12) {
message = this.props.language.morning; // If it's before 12am, set the greeting string to "Good morning"
message = this.props.language.morning;
// If it's before 6pm, set the greeting string to "Good afternoon"
} else if (hour < 18) {
message = this.props.language.afternoon; // If it's before 6pm, set the greeting string to "Good afternoon"
message = this.props.language.afternoon;
}
// Events

View File

@@ -11,7 +11,8 @@ import * as Constants from '../../../modules/constants';
import './scss/index.scss';
const Notes = React.lazy(() => import('./Notes')); // the user probably won't use the notes feature every time so we lazy load
// the user probably won't use the notes feature every time so we lazy load
const Notes = React.lazy(() => import('./Notes'));
const renderLoader = () => <div></div>;
export default class Navbar extends React.PureComponent {

View File

@@ -26,12 +26,13 @@ export default class Quote extends React.PureComponent {
doOffline() {
const quotes = require('./offline_quotes.json');
const quote = quotes[Math.floor(Math.random() * quotes.length)]; // Get a random quote from our local package
// Get a random quote from our local package
const quote = quotes[Math.floor(Math.random() * quotes.length)];
// Set the quote
this.setState({
quote: '"' + quote.quote + '"',
author: quote.author
}); // Set the quote
});
}
getQuotePack() {
@@ -80,11 +81,13 @@ export default class Quote extends React.PureComponent {
return this.doOffline();
}
try { // First we try and get a quote from the API...
// First we try and get a quote from the API...
try {
const data = await (await fetch(Constants.API_URL + '/getQuote?language=' + localStorage.getItem('quotelanguage'))).json();
// If we hit the ratelimit, we fallback to local quotes
if (data.statusCode === 429) {
return this.doOffline(); // If we hit the ratelimit, we fallback to local quotes
return this.doOffline();
}
this.setState({
@@ -92,7 +95,8 @@ export default class Quote extends React.PureComponent {
author: data.author,
authorlink: `https://${this.props.languagecode}.wikipedia.org/wiki/${data.author.split(' ').join('_')}`
});
} catch (e) { // ..and if that fails we load one locally
} catch (e) {
// ..and if that fails we load one locally
this.doOffline();
}
}
@@ -121,8 +125,9 @@ export default class Quote extends React.PureComponent {
}
componentDidMount() {
// todo: fix (localStorage.getItem('favouriteQuoteEnabled') === 'false')
this.setState({
favourited: localStorage.getItem('favouriteQuote') ? <StarIcon className='copyButton' onClick={() => this.favourite()} /> : null, // todo: fix (localStorage.getItem('favouriteQuoteEnabled') === 'false')
favourited: localStorage.getItem('favouriteQuote') ? <StarIcon className='copyButton' onClick={() => this.favourite()} /> : null,
copy: (localStorage.getItem('copyButton') === 'false') ? null : this.state.copy,
tweet: (localStorage.getItem('tweetButton') === 'false') ? null: this.state.tweet
});

View File

@@ -28,7 +28,8 @@ export default class Clock extends React.PureComponent {
// Analog clock
if (localStorage.getItem('analog') === 'true') {
require('react-clock/dist/Clock.css'); // load analog clock css
// load analog clock css
require('react-clock/dist/Clock.css');
this.setState({
time: now

View File

@@ -32,8 +32,9 @@ export default class DateWidget extends React.PureComponent {
day = dateYear;
year = dateDay;
break;
// DMY
default:
break; // DMY
break;
}
let format;