From 7d390b4fa52759e1bcb7292b1dac229450e7c495 Mon Sep 17 00:00:00 2001 From: syuilo Date: Sat, 11 Nov 2017 14:27:39 +0900 Subject: [PATCH] :v: --- locales/en.yml | 6 ++ locales/ja.yml | 6 ++ .../desktop/tags/home-widgets/timemachine.tag | 100 ++++++++++++++---- 3 files changed, 94 insertions(+), 18 deletions(-) diff --git a/locales/en.yml b/locales/en.yml index 4eae82507..639219d2d 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 82589aadf..513194afe 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 b6c53e028..75e9f3a33 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); };