Showing the changes to assets/javascripts/views (5 of 5 files). Show all
Unified · Split
| @@ -1,23 +1,11 @@ | ||
| 1 | −// TODO: This file was created by bulk-decaffeinate. | |
| 2 | −// Sanity-check the conversion and remove this comment. | |
| 3 | −/* | |
| 4 | − * decaffeinate suggestions: | |
| 5 | − * DS101: Remove unnecessary use of Array.from | |
| 6 | − * DS102: Remove unnecessary code created because of implicit returns | |
| 7 | − * DS205: Consider reworking code to avoid use of IIFEs | |
| 8 | − * DS206: Consider reworking classes to avoid initClass | |
| 9 | − * Full docs: https://github.com/decaffeinate/decaffeinate/blob/main/docs/suggestions.md | |
| 10 | − */ | |
| 11 | 1 | //= require views/misc/notif |
| 12 | 2 | |
| 13 | 3 | app.views.News = class News extends app.views.Notif { |
| 14 | − static initClass() { | |
| 15 | − this.className += " _notif-news"; | |
| 4 | + static className = "_notif _notif-news"; | |
| 16 | 5 | |
| 17 | − this.defautOptions = { autoHide: 30000 }; | |
| 18 | − } | |
| 6 | + static defaultOptions = { autoHide: 30000 }; | |
| 19 | 7 | |
| 20 | − init() { | |
| 8 | + init0() { | |
| 21 | 9 | this.unreadNews = this.getUnreadNews(); |
| 22 | 10 | if (this.unreadNews.length) { |
| 23 | 11 | this.show(); |
| @@ -30,21 +18,19 @@ app.views.News = class News extends app.views.Notif { · 6 unmodified lines | ||
| 30 | 18 | } |
| 31 | 19 | |
| 32 | 20 | getUnreadNews() { |
| 33 | − let time; | |
| 34 | − if (!(time = this.getLastReadTime())) { | |
| 21 | + let time = this.getLastReadTime(); | |
| 22 | + if (!time) { | |
| 35 | 23 | return []; |
| 36 | 24 | } |
| 37 | 25 | |
| 38 | − return (() => { | |
| 39 | − const result = []; | |
| 40 | − for (var news of Array.from(app.news)) { | |
| 41 | − if (new Date(news[0]).getTime() <= time) { | |
| 42 | − break; | |
| 43 | − } | |
| 44 | − result.push(news); | |
| 26 | + const result = []; | |
| 27 | + for (var news of app.news) { | |
| 28 | + if (new Date(news[0]).getTime() <= time) { | |
| 29 | + break; | |
| 45 | 30 | } |
| 46 | − return result; | |
| 47 | − })(); | |
| 31 | + result.push(news); | |
| 32 | + } | |
| 33 | + return result; | |
| 48 | 34 | } |
| 49 | 35 | |
| 50 | 36 | getLastNewsTime() { |
| @@ -59,4 +45,3 @@ app.views.News = class News extends app.views.Notif { · 8 unmodified lines | ||
| 59 | 45 | app.settings.set("news", this.getLastNewsTime()); |
| 60 | 46 | } |
| 61 | 47 | }; |
| 62 | −app.views.News.initClass(); | |
| @@ -1,15 +1,6 @@ | ||
| 1 | −// TODO: This file was created by bulk-decaffeinate. | |
| 2 | −// Sanity-check the conversion and remove this comment. | |
| 3 | −/* | |
| 4 | − * decaffeinate suggestions: | |
| 5 | − * DS206: Consider reworking classes to avoid initClass | |
| 6 | − * Full docs: https://github.com/decaffeinate/decaffeinate/blob/main/docs/suggestions.md | |
| 7 | − */ | |
| 8 | 1 | app.views.Notice = class Notice extends app.View { |
| 9 | − static initClass() { | |
| 10 | − this.className = "_notice"; | |
| 11 | − this.attributes = { role: "alert" }; | |
| 12 | − } | |
| 2 | + static className = "_notice"; | |
| 3 | + static attributes = { role: "alert" }; | |
| 13 | 4 | |
| 14 | 5 | constructor(type, ...args) { |
| 15 | 6 | super(); |
| @@ -44,4 +35,3 @@ app.views.Notice = class Notice extends app.View { · 28 unmodified lines | ||
| 44 | 35 | $.remove(this.el); |
| 45 | 36 | } |
| 46 | 37 | }; |
| 47 | −app.views.Notice.initClass(); | |
| @@ -1,29 +1,21 @@ | ||
| 1 | −// TODO: This file was created by bulk-decaffeinate. | |
| 2 | −// Sanity-check the conversion and remove this comment. | |
| 3 | −/* | |
| 4 | − * decaffeinate suggestions: | |
| 5 | − * DS206: Consider reworking classes to avoid initClass | |
| 6 | − * DS207: Consider shorter variations of null checks | |
| 7 | − * Full docs: https://github.com/decaffeinate/decaffeinate/blob/main/docs/suggestions.md | |
| 8 | − */ | |
| 9 | 1 | app.views.Notif = class Notif extends app.View { |
| 10 | − static initClass() { | |
| 11 | − this.className = "_notif"; | |
| 12 | − this.activeClass = "_in"; | |
| 13 | − this.attributes = { role: "alert" }; | |
| 2 | + static className = "_notif"; | |
| 3 | + static activeClass = "_in"; | |
| 4 | + static attributes = { role: "alert" }; | |
| 14 | 5 | |
| 15 | − this.defaultOptions = { autoHide: 15000 }; | |
| 6 | + static defaultOptions = { autoHide: 15000 }; | |
| 16 | 7 | |
| 17 | − this.events = { click: "onClick" }; | |
| 18 | − } | |
| 8 | + static events = { click: "onClick" }; | |
| 19 | 9 | |
| 20 | 10 | constructor(type, options) { |
| 21 | 11 | super(); |
| 22 | 12 | this.type = type; |
| 23 | 13 | this.options = $.extend({}, this.constructor.defaultOptions, options || {}); |
| 14 | + this.init0(); // needs this.options | |
| 15 | + this.refreshElements(); | |
| 24 | 16 | } |
| 25 | 17 | |
| 26 | − init() { | |
| 18 | + init0() { | |
| 27 | 19 | this.show(); |
| 28 | 20 | } |
| 29 | 21 | |
| @@ -55,7 +47,7 @@ app.views.Notif = class Notif extends app.View { · 25 unmodified lines | ||
| 55 | 47 | } |
| 56 | 48 | |
| 57 | 49 | position() { |
| 58 | − const notifications = $$(`.${app.views.Notif.className}`); | |
| 50 | + const notifications = $$(`.${Notif.className}`); | |
| 59 | 51 | if (notifications.length) { |
| 60 | 52 | const lastNotif = notifications[notifications.length - 1]; |
| 61 | 53 | this.el.style.top = |
| @@ -77,4 +69,3 @@ app.views.Notif = class Notif extends app.View { · 15 unmodified lines | ||
| 77 | 69 | } |
| 78 | 70 | } |
| 79 | 71 | }; |
| 80 | −app.views.Notif.initClass(); | |
| @@ -1,21 +1,11 @@ | ||
| 1 | −// TODO: This file was created by bulk-decaffeinate. | |
| 2 | −// Sanity-check the conversion and remove this comment. | |
| 3 | −/* | |
| 4 | − * decaffeinate suggestions: | |
| 5 | − * DS206: Consider reworking classes to avoid initClass | |
| 6 | − * Full docs: https://github.com/decaffeinate/decaffeinate/blob/main/docs/suggestions.md | |
| 7 | − */ | |
| 8 | 1 | //= require views/misc/notif |
| 9 | 2 | |
| 10 | 3 | app.views.Tip = class Tip extends app.views.Notif { |
| 11 | − static initClass() { | |
| 12 | − this.className = "_notif _notif-tip"; | |
| 4 | + static className = "_notif _notif-tip"; | |
| 13 | 5 | |
| 14 | − this.defautOptions = { autoHide: false }; | |
| 15 | − } | |
| 6 | + static defautOptions = { autoHide: false }; | |
| 16 | 7 | |
| 17 | 8 | render() { |
| 18 | 9 | this.html(this.tmpl(`tip${this.type}`)); |
| 19 | 10 | } |
| 20 | 11 | }; |
| 21 | −app.views.Tip.initClass(); | |
| @@ -1,23 +1,11 @@ | ||
| 1 | −// TODO: This file was created by bulk-decaffeinate. | |
| 2 | −// Sanity-check the conversion and remove this comment. | |
| 3 | −/* | |
| 4 | − * decaffeinate suggestions: | |
| 5 | − * DS101: Remove unnecessary use of Array.from | |
| 6 | − * DS102: Remove unnecessary code created because of implicit returns | |
| 7 | − * DS205: Consider reworking code to avoid use of IIFEs | |
| 8 | − * DS206: Consider reworking classes to avoid initClass | |
| 9 | − * Full docs: https://github.com/decaffeinate/decaffeinate/blob/main/docs/suggestions.md | |
| 10 | − */ | |
| 11 | 1 | //= require views/misc/notif |
| 12 | 2 | |
| 13 | 3 | app.views.Updates = class Updates extends app.views.Notif { |
| 14 | − static initClass() { | |
| 15 | − this.className += " _notif-news"; | |
| 4 | + static className = "_notif _notif-news"; | |
| 16 | 5 | |
| 17 | − this.defautOptions = { autoHide: 30000 }; | |
| 18 | − } | |
| 6 | + static defautOptions = { autoHide: 30000 }; | |
| 19 | 7 | |
| 20 | − init() { | |
| 8 | + init0() { | |
| 21 | 9 | this.lastUpdateTime = this.getLastUpdateTime(); |
| 22 | 10 | this.updatedDocs = this.getUpdatedDocs(); |
| 23 | 11 | this.updatedDisabledDocs = this.getUpdatedDisabledDocs(); |
| @@ -46,18 +34,16 @@ app.views.Updates = class Updates extends app.views.Notif { · 22 unmodified lines | ||
| 46 | 34 | if (!this.lastUpdateTime) { |
| 47 | 35 | return []; |
| 48 | 36 | } |
| 49 | − return (() => { | |
| 50 | − const result = []; | |
| 51 | − for (var doc of Array.from(app.disabledDocs.all())) { | |
| 52 | − if ( | |
| 53 | − doc.mtime > this.lastUpdateTime && | |
| 54 | − app.docs.findBy("slug_without_version", doc.slug_without_version) | |
| 55 | − ) { | |
| 56 | − result.push(doc); | |
| 57 | − } | |
| 37 | + const result = []; | |
| 38 | + for (var doc of Array.from(app.disabledDocs.all())) { | |
| 39 | + if ( | |
| 40 | + doc.mtime > this.lastUpdateTime && | |
| 41 | + app.docs.findBy("slug_without_version", doc.slug_without_version) | |
| 42 | + ) { | |
| 43 | + result.push(doc); | |
| 58 | 44 | } |
| 59 | − return result; | |
| 60 | − })(); | |
| 45 | + } | |
| 46 | + return result; | |
| 61 | 47 | } |
| 62 | 48 | |
| 63 | 49 | getLastUpdateTime() { |
| @@ -73,4 +59,3 @@ app.views.Updates = class Updates extends app.views.Notif { · 9 unmodified lines | ||
| 73 | 59 | ); |
| 74 | 60 | } |
| 75 | 61 | }; |
| 76 | −app.views.Updates.initClass(); | |