diff --git a/src/components/Widgets/CryptoPriceChart.vue b/src/components/Widgets/CryptoPriceChart.vue
index 5d220105..2f966c41 100644
--- a/src/components/Widgets/CryptoPriceChart.vue
+++ b/src/components/Widgets/CryptoPriceChart.vue
@@ -28,7 +28,7 @@ export default {
/* Number of days worth of history to fetch and display */
numDays() {
const userChoice = this.options.numDays;
- if (!Number.isNaN(userChoice) && userChoice < 30 && userChoice > 0.15) {
+ if (typeof usersChoice === 'number' && userChoice < 30 && userChoice > 0.15) {
return userChoice;
}
return 7;
@@ -42,7 +42,7 @@ export default {
/* The number of data points to render on the chart */
dataPoints() {
const userChoice = this.options.dataPoints;
- if (!Number.isNaN(userChoice) && userChoice < 100 && userChoice > 5) {
+ if (typeof usersChoice === 'number' && userChoice < 100 && userChoice > 5) {
return userChoice;
}
return 30;
diff --git a/src/components/Widgets/CveVulnerabilities.vue b/src/components/Widgets/CveVulnerabilities.vue
index 80f48dd8..0599e90c 100644
--- a/src/components/Widgets/CveVulnerabilities.vue
+++ b/src/components/Widgets/CveVulnerabilities.vue
@@ -141,8 +141,8 @@ export default {
return 'fg-grey';
},
makeScoreColor(inputScore) {
- if (!inputScore || Number.isNaN(parseFloat(inputScore, 10))) return 'bg-grey';
- const score = parseFloat(inputScore, 10);
+ if (!inputScore || Number.isNaN(parseFloat(inputScore))) return 'bg-grey';
+ const score = parseFloat(inputScore);
if (score >= 9) return 'bg-red';
if (score >= 7) return 'bg-orange';
if (score >= 4) return 'bg-yellow';
diff --git a/src/components/Widgets/EmbedWidget.vue b/src/components/Widgets/EmbedWidget.vue
index ffcffe70..633b74e2 100644
--- a/src/components/Widgets/EmbedWidget.vue
+++ b/src/components/Widgets/EmbedWidget.vue
@@ -36,7 +36,7 @@ export default {
},
beforeDestroy() {
if (this.eventListener) {
- document.removeEventListener(this.eventListener);
+ window.removeEventListener(this.eventListener);
}
},
data: () => ({
diff --git a/src/components/Widgets/GitHubTrending.vue b/src/components/Widgets/GitHubTrending.vue
index cb65702a..9a4c217b 100644
--- a/src/components/Widgets/GitHubTrending.vue
+++ b/src/components/Widgets/GitHubTrending.vue
@@ -148,7 +148,6 @@ export default {
}
}
}
- .repo-stats {}
&:not(:last-child) {
border-bottom: 1px dashed var(--widget-text-color);
}
diff --git a/src/components/Widgets/PiHoleTopQueries.vue b/src/components/Widgets/PiHoleTopQueries.vue
index ab9d518a..d3334eb7 100644
--- a/src/components/Widgets/PiHoleTopQueries.vue
+++ b/src/components/Widgets/PiHoleTopQueries.vue
@@ -36,7 +36,7 @@ export default {
},
count() {
const usersChoice = this.options.count;
- if (usersChoice && !Number.isNaN(usersChoice)) return usersChoice;
+ if (usersChoice && typeof usersChoice === 'number') return usersChoice;
return 10;
},
endpoint() {
diff --git a/src/components/Widgets/RssFeed.vue b/src/components/Widgets/RssFeed.vue
index 12359eb7..ef24df31 100644
--- a/src/components/Widgets/RssFeed.vue
+++ b/src/components/Widgets/RssFeed.vue
@@ -80,8 +80,7 @@ export default {
formatDate(timestamp) {
const localFormat = navigator.language;
const dateFormat = { weekday: 'short', day: 'numeric', month: 'short' };
- const date = new Date(timestamp).toLocaleDateString(localFormat, dateFormat);
- return date;
+ return new Date(timestamp).toLocaleDateString(localFormat, dateFormat);
},
formatAuthor(author) {
return author ? `by ${author}` : '';
@@ -162,7 +161,6 @@ export default {
display: flex;
align-items: center;
text-decoration: none;
- .post-title-wrap {}
p.post-title {
margin: 0;
font-size: 1rem;
diff --git a/src/components/Widgets/StockPriceChart.vue b/src/components/Widgets/StockPriceChart.vue
index 2513491d..15a3829c 100644
--- a/src/components/Widgets/StockPriceChart.vue
+++ b/src/components/Widgets/StockPriceChart.vue
@@ -40,7 +40,7 @@ export default {
/* The number of data points to render on the chart */
dataPoints() {
const userChoice = this.options.dataPoints;
- if (!Number.isNaN(userChoice) && userChoice < 100 && userChoice > 5) {
+ if (typeof usersChoice === 'number' && userChoice < 100 && userChoice > 5) {
return userChoice;
}
return 30;
@@ -137,8 +137,7 @@ export default {
formatDate(timestamp) {
const localFormat = navigator.language;
const dateFormat = { weekday: 'short', day: 'numeric', month: 'short' };
- const date = new Date(timestamp).toLocaleDateString(localFormat, dateFormat);
- return date;
+ return new Date(timestamp).toLocaleDateString(localFormat, dateFormat);
},
/* Format the price, rounding to given number of decimal places */
formatPrice(priceStr) {
diff --git a/src/components/Widgets/WidgetBase.vue b/src/components/Widgets/WidgetBase.vue
index ffc4b065..62811217 100644
--- a/src/components/Widgets/WidgetBase.vue
+++ b/src/components/Widgets/WidgetBase.vue
@@ -320,7 +320,7 @@ export default {
/* Returns either `false` or a number in ms to continuously update widget data */
updateInterval() {
const usersInterval = this.widget.updateInterval;
- if (!usersInterval) return false;
+ if (!usersInterval) return 0;
// If set to `true`, then default to 30 seconds
if (typeof usersInterval === 'boolean') return 30 * 1000;
// If set to a number, and within valid range, return user choice
@@ -329,7 +329,7 @@ export default {
&& usersInterval < 7200) {
return usersInterval * 1000;
}
- return false;
+ return 0;
},
},
methods: {
diff --git a/src/components/Widgets/WidgetError.vue b/src/components/Widgets/WidgetError.vue
deleted file mode 100644
index 189624a0..00000000
--- a/src/components/Widgets/WidgetError.vue
+++ /dev/null
@@ -1,18 +0,0 @@
-
-
-
-
-
-
-
diff --git a/src/components/Widgets/XkcdComic.vue b/src/components/Widgets/XkcdComic.vue
index 5ddd8468..f42f6eae 100644
--- a/src/components/Widgets/XkcdComic.vue
+++ b/src/components/Widgets/XkcdComic.vue
@@ -31,10 +31,8 @@ export default {
return 'latest';
} else if (usersChoice === 'random') {
return Math.abs(Math.floor(Math.random() * (1 - 2553)));
- } else if (usersChoice) {
- return usersChoice;
}
- return 'latest';
+ return usersChoice;
},
endpoint() {
return `${widgetApiEndpoints.xkcdComic}?comic=${this.comicNumber}`;
diff --git a/src/mixins/ChartingMixin.js b/src/mixins/ChartingMixin.js
index ce27d22c..82dca5de 100644
--- a/src/mixins/ChartingMixin.js
+++ b/src/mixins/ChartingMixin.js
@@ -1,10 +1,9 @@
/**
* Mixin for helper functions, used for making chart widgets
*/
-// import ErrorHandler from '@/utils/ErrorHandler';
import { Chart } from 'frappe-charts/dist/frappe-charts.min.esm';
-const WidgetMixin = {
+const ChartingMixin = {
props: {},
computed: {
chartHeight() {
@@ -29,15 +28,13 @@ const WidgetMixin = {
formatDate(timestamp) {
const localFormat = navigator.language;
const dateFormat = { weekday: 'short', day: 'numeric', month: 'short' };
- const date = new Date(timestamp).toLocaleDateString(localFormat, dateFormat);
- return date;
+ return new Date(timestamp).toLocaleDateString(localFormat, dateFormat);
},
/* Format the time for a given time stamp */
formatTime(timestamp) {
const localFormat = navigator.language;
const timeFormat = { hour: 'numeric', minute: 'numeric', second: 'numeric' };
- const time = Intl.DateTimeFormat(localFormat, timeFormat).format(timestamp);
- return time;
+ return Intl.DateTimeFormat(localFormat, timeFormat).format(timestamp);
},
/* Given an array of numbers, returns the average of all */
average(array) {
@@ -46,4 +43,4 @@ const WidgetMixin = {
},
};
-export default WidgetMixin;
+export default ChartingMixin;
diff --git a/src/mixins/HomeMixin.js b/src/mixins/HomeMixin.js
index 8c9895ac..4a0f04fd 100644
--- a/src/mixins/HomeMixin.js
+++ b/src/mixins/HomeMixin.js
@@ -1,7 +1,6 @@
/**
* Mixin for all homepages (default home, minimal home, workspace, etc)
*/
-// import ErrorHandler from '@/utils/ErrorHandler';
import Defaults, { localStorageKeys, iconCdns } from '@/utils/defaults';
import { searchTiles } from '@/utils/Search';
@@ -48,16 +47,14 @@ const HomeMixin = {
},
/* Checks if any sections or items use icons from a given CDN */
checkIfIconLibraryNeeded(prefix) {
- let isNeeded = false;
if (!this.sections) return false;
+ let isNeeded = false; // Will be set to true if prefix found in icon name
this.sections.forEach((section) => {
- if (section) {
- if (section.icon && section.icon.includes(prefix)) isNeeded = true;
- if (section.items) {
- section.items.forEach((item) => {
- if (item.icon && item.icon.includes(prefix)) isNeeded = true;
- });
- }
+ if (section && section.icon && section.icon.includes(prefix)) isNeeded = true;
+ if (section && section.items) {
+ section.items.forEach((item) => {
+ if (item.icon && item.icon.includes(prefix)) isNeeded = true;
+ });
}
});
return isNeeded;
diff --git a/src/utils/MiscHelpers.js b/src/utils/MiscHelpers.js
index ad68301a..d2998497 100644
--- a/src/utils/MiscHelpers.js
+++ b/src/utils/MiscHelpers.js
@@ -66,8 +66,7 @@ export const timestampToDate = (timestamp) => {
export const timestampToTime = (timestamp) => {
const localFormat = navigator.language;
const timeFormat = { hour: 'numeric', minute: 'numeric', second: 'numeric' };
- const time = Intl.DateTimeFormat(localFormat, timeFormat).format(new Date(timestamp));
- return time;
+ return Intl.DateTimeFormat(localFormat, timeFormat).format(new Date(timestamp));
};
/* Given a timestamp, returns both human Date and Time */
@@ -134,12 +133,13 @@ export const capitalize = (str) => {
/* Round price to appropriate number of decimals */
export const roundPrice = (price) => {
if (Number.isNaN(price)) return price;
- let decimals = 2;
+ let decimals;
if (price > 1000) decimals = 0;
else if (price > 1) decimals = 2;
else if (price > 0.1) decimals = 3;
else if (price > 0.01) decimals = 4;
else if (price <= 0.01) decimals = 5;
+ else decimals = 2;
return price.toFixed(decimals);
};