diff --git a/locales/en.yml b/locales/en.yml index 4eae825074..639219d2de 100644 --- a/locales/en.yml +++ b/locales/en.yml @@ -378,6 +378,12 @@ desktop: title: "Channel" settings: "Widget settings" + mk-timemachine-home-widget: + title: "{1} / {2}" + prev: "Previous month" + next: "Next month" + go: "Click to travel" + mk-repost-form: quote: "Quote..." cancel: "Cancel" diff --git a/locales/ja.yml b/locales/ja.yml index 82589aadff..513194afe8 100644 --- a/locales/ja.yml +++ b/locales/ja.yml @@ -378,6 +378,12 @@ desktop: title: "チャンネル" settings: "ウィジェットの設定" + mk-timemachine-home-widget: + title: "{1}月 {2}日" + prev: "先月" + next: "来月" + go: "クリックして時間遡行" + mk-repost-form: quote: "引用する..." cancel: "キャンセル" diff --git a/src/web/app/desktop/tags/home-widgets/timemachine.tag b/src/web/app/desktop/tags/home-widgets/timemachine.tag index b6c53e0284..75e9f3a339 100644 --- a/src/web/app/desktop/tags/home-widgets/timemachine.tag +++ b/src/web/app/desktop/tags/home-widgets/timemachine.tag @@ -1,12 +1,20 @@ - -

{ year }/{ month }

- + +

{ '%i18n:desktop.tags.mk-timemachine-home-widget.title%'.replace('{1}', year).replace('{2}', month) }

+
-
{ weekdayText[i] }
+
{ weekdayText[i] }
-
{ i + 1 }
+
{ i + 1 }
@@ -97,6 +142,7 @@ this.today = new Date(); this.year = this.today.getFullYear(); this.month = this.today.getMonth() + 1; + this.selected = this.today; this.weekdayText = [ '%i18n:common.weekday-short.sunday%', '%i18n:common.weekday-short.monday%', @@ -115,6 +161,19 @@ return this.year == this.today.getFullYear() && this.month == this.today.getMonth() + 1 && day == this.today.getDate(); }; + this.isSelected = day => { + return this.year == this.selected.getFullYear() && this.month == this.selected.getMonth() + 1 && day == this.selected.getDate(); + }; + + this.isFuture = day => { + return (new Date(this.year, this.month - 1, day)).getTime() > this.today.getTime(); + }; + + this.isDonichi = day => { + const weekday = (new Date(this.year, this.month - 1, day)).getDay(); + return weekday == 0 || weekday == 6; + }; + this.calc = () => { let days = eachMonthDays[this.month - 1]; @@ -159,7 +218,12 @@ }; this.go = day => { - this.opts.tl.warp(new Date(this.year, this.month - 1, day, 23, 59, 59, 999)); + if (this.isFuture(day)) return; + const date = new Date(this.year, this.month - 1, day, 23, 59, 59, 999); + this.update({ + selected: date + }); + this.opts.tl.warp(date); };