From 9f87a459ebcf7e6499f8ff9ac80fdf669d5b086b Mon Sep 17 00:00:00 2001 From: Simon Legner Date: Sat, 6 Jan 2024 17:23:46 +0100 Subject: [PATCH] Use const, use arrow callbacks --- assets/javascripts/app/db.js | 6 +++--- assets/javascripts/app/serviceworker.js | 4 ++-- assets/javascripts/collections/docs.js | 4 ++-- assets/javascripts/lib/events.js | 2 +- assets/javascripts/lib/page.js | 2 +- assets/javascripts/views/layout/document.js | 2 +- assets/javascripts/views/layout/settings.js | 2 +- assets/javascripts/views/misc/news.js | 2 +- assets/javascripts/views/search/search.js | 2 +- 9 files changed, 13 insertions(+), 13 deletions(-) diff --git a/assets/javascripts/app/db.js b/assets/javascripts/app/db.js index 450efa4c..c0260c74 100644 --- a/assets/javascripts/app/db.js +++ b/assets/javascripts/app/db.js @@ -265,7 +265,7 @@ app.DB = class DB { } version(doc, fn) { - let version = this.cachedVersion(doc); + const version = this.cachedVersion(doc); if (version != null) { fn(version); return; @@ -302,7 +302,7 @@ app.DB = class DB { } versions(docs, fn) { - let versions = this.cachedVersions(docs); + const versions = this.cachedVersions(docs); if (versions) { fn(versions); return; @@ -324,7 +324,7 @@ app.DB = class DB { const store = txn.objectStore("docs"); var result = {}; - docs.forEach(function (doc) { + docs.forEach((doc) => { const req = store.get(doc.slug); req.onsuccess = function () { result[doc.slug] = req.result; diff --git a/assets/javascripts/app/serviceworker.js b/assets/javascripts/app/serviceworker.js index b168214d..865d8e24 100644 --- a/assets/javascripts/app/serviceworker.js +++ b/assets/javascripts/app/serviceworker.js @@ -21,7 +21,7 @@ app.ServiceWorker = class ServiceWorker extends Events { return; } this.notifyUpdate = true; - return this.registration.update().catch(function () {}); + return this.registration.update().catch(() => {}); } updateInBackground() { @@ -29,7 +29,7 @@ app.ServiceWorker = class ServiceWorker extends Events { return; } this.notifyUpdate = false; - return this.registration.update().catch(function () {}); + return this.registration.update().catch(() => {}); } reload() { diff --git a/assets/javascripts/collections/docs.js b/assets/javascripts/collections/docs.js index 25d8c007..d4aa9c84 100644 --- a/assets/javascripts/collections/docs.js +++ b/assets/javascripts/collections/docs.js @@ -13,7 +13,7 @@ app.collections.Docs = class Docs extends app.Collection { ); } sort() { - return this.models.sort(function (a, b) { + return this.models.sort((a, b) => { if (a.name === b.name) { if ( !a.version || @@ -81,7 +81,7 @@ app.collections.Docs = class Docs extends app.Collection { } getInstallStatuses(callback) { - app.db.versions(this.models, function (statuses) { + app.db.versions(this.models, (statuses) => { if (statuses) { for (var key in statuses) { var value = statuses[key]; diff --git a/assets/javascripts/lib/events.js b/assets/javascripts/lib/events.js index 33d338b8..d735a3d5 100644 --- a/assets/javascripts/lib/events.js +++ b/assets/javascripts/lib/events.js @@ -34,7 +34,7 @@ class Events { this.eventInProgress = { name: event, args }; const callbacks = this._callbacks?.[event]; if (callbacks) { - for (let callback of callbacks.slice(0)) { + for (const callback of callbacks.slice(0)) { if (typeof callback === "function") { callback(...args); } diff --git a/assets/javascripts/lib/page.js b/assets/javascripts/lib/page.js index f5fde7e1..f368fbba 100644 --- a/assets/javascripts/lib/page.js +++ b/assets/javascripts/lib/page.js @@ -215,7 +215,7 @@ var pathToRegexp = function (path, keys) { .replace(/\/\(/g, "(?:/") .replace( /(\/)?(\.)?:(\w+)(?:(\(.*?\)))?(\?)?/g, - function (_, slash, format, key, capture, optional) { + (_, slash, format, key, capture, optional) => { if (slash == null) { slash = ""; } diff --git a/assets/javascripts/views/layout/document.js b/assets/javascripts/views/layout/document.js index a0588ff2..f3dfc448 100644 --- a/assets/javascripts/views/layout/document.js +++ b/assets/javascripts/views/layout/document.js @@ -58,7 +58,7 @@ app.views.Document = class Document extends app.View { if (this.el.visibilityState !== "visible") { return; } - this.delay(function () { + this.delay(() => { if (app.isMobile() !== app.views.Mobile.detect()) { location.reload(); } diff --git a/assets/javascripts/views/layout/settings.js b/assets/javascripts/views/layout/settings.js index 68733106..52546dd9 100644 --- a/assets/javascripts/views/layout/settings.js +++ b/assets/javascripts/views/layout/settings.js @@ -72,7 +72,7 @@ app.views.Settings = class Settings extends app.View { return result; })(), ); - disabledDocs.uninstall(function () { + disabledDocs.uninstall(() => { app.db.migrate(); return app.reload(); }); diff --git a/assets/javascripts/views/misc/news.js b/assets/javascripts/views/misc/news.js index 339cc386..23d4f119 100644 --- a/assets/javascripts/views/misc/news.js +++ b/assets/javascripts/views/misc/news.js @@ -18,7 +18,7 @@ app.views.News = class News extends app.views.Notif { } getUnreadNews() { - let time = this.getLastReadTime(); + const time = this.getLastReadTime(); if (!time) { return []; } diff --git a/assets/javascripts/views/search/search.js b/assets/javascripts/views/search/search.js index 708d921e..6cfcb4cb 100644 --- a/assets/javascripts/views/search/search.js +++ b/assets/javascripts/views/search/search.js @@ -207,7 +207,7 @@ app.views.Search = class Search extends app.View { } extractHashValue() { - let value = this.getHashValue(); + const value = this.getHashValue(); if (value != null) { app.router.replaceHash(); return value;