Sfoglia il codice sorgente

Use const, use arrow callbacks

Simon Legner 1 anno fa
parent
commit
9f87a459eb

+ 3 - 3
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;

+ 2 - 2
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() {

+ 2 - 2
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];

+ 1 - 1
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);
         }

+ 1 - 1
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 = "";
         }

+ 1 - 1
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();
       }

+ 1 - 1
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();
       });

+ 1 - 1
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 [];
     }

+ 1 - 1
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;