From 56fd907f28bfce72a507b1041d12086a98b2d094 Mon Sep 17 00:00:00 2001 From: Guillermo Date: Thu, 30 Aug 2018 17:28:36 -0600 Subject: [PATCH] improve filters and fix dailyDone button --- plugins/Guitlle/habito/Habito.tid | 11 +++++------ plugins/Guitlle/habito/dailyDone.tid | 23 ++++++++++++----------- plugins/Guitlle/habito/getReward.tid | 13 ++++++------- plugins/Guitlle/habito/styles.css.tid | 17 ++++++++++++++--- plugins/Guitlle/habito/titledate.js.tid | 15 +++++++++------ 5 files changed, 46 insertions(+), 33 deletions(-) diff --git a/plugins/Guitlle/habito/Habito.tid b/plugins/Guitlle/habito/Habito.tid index 60f1b8f..6f8458f 100644 --- a/plugins/Guitlle/habito/Habito.tid +++ b/plugins/Guitlle/habito/Habito.tid @@ -1,14 +1,13 @@ created: 20180826045249890 -gold: 270 -modified: 20180828072357213 -tags: habito-display +gold: 110 +modified: 20180830232446552 title: Habito type: application/x-tiddler -xp: 17 +xp: -4
{{!!gold}} {{$:/plugins/Guitlle/habito/images/coin.png}}
{{!!xp}} experience
- - +
<$macrocall $name="tabs" tabsList="$:/plugins/Guitlle/habito/habitsView $:/plugins/Guitlle/habito/dailiesView $:/plugins/Guitlle/habito/rewardsView" default="$:/plugins/Guitlle/habito/dailiesView" state="$:/state/tab/habito" /> +
\ No newline at end of file diff --git a/plugins/Guitlle/habito/dailyDone.tid b/plugins/Guitlle/habito/dailyDone.tid index 2cb21ac..15c41ca 100644 --- a/plugins/Guitlle/habito/dailyDone.tid +++ b/plugins/Guitlle/habito/dailyDone.tid @@ -1,31 +1,32 @@ created: 20180824222515632 list-before: $:/core/ui/ViewTemplate/title -modified: 20180828065243613 +modified: 20180830232136117 tags: $:/tags/ViewTemplate title: $:/plugins/Guitlle/habito/dailyDone type: application/x-tiddler -<$list filter="[all[current]tag[Daily]]" variable="tag_name"> -<$wikify name="dateEntry" text="""<$macrocall $name="now" format="YYYY-MM-DD"/>"""> -<$wikify name="dateEntry_brackets" text="""<$text text='[['/><><$text text=']]'/>"""> -<$wikify name="widget_class" text="""<$list filter="[list[!!days_done]titledate:toOffsetFromDate[]!compare:greater{!!days_repeat}count[]compare:equal[0]]">habito-daily-missed <$list filter="[list[!!days_done]titledate:toOffsetFromDate[]!compare:greater{!!days_warn}count[]compare:equal[0]]">habito-daily-warn habito-btn-wrapper"""> +<$list filter="[all[current]tag[Daily]]" variable="tag_name"> + <$wikify name="today" text="""<$macrocall $name="now" format="YYYY-MM-DD"/>"""> + <$wikify name="todayBrackets" text="""<$text text='[['/><><$text text=']]'/>"""> + <$wikify name="lastDate" text="""<$list filter="[list[!!days_done]last[]]"><$text text='[['/><><$text text=']]'/>"""> + <$wikify name="widget_class" text="""<$list filter="[titletitledate:toOffsetFromDate[]!compare:greater{!!days_repeat}count[]compare:equal[0]]">habito-daily-missed <$list filter="[titletitledate:toOffsetFromDate[]!compare:greater{!!days_warn}count[]compare:equal[0]]">habito-daily-warn habito-btn-wrapper""">
> title="Task done today."> -<$list filter="[list[!!days_done]titledate:toOffsetFromDate[]!compare:greater{!!days_checked}last[]]" variable="i" emptyMessage=""" +<$list filter="[titletitledate:toOffsetFromDate[]!compare:greater{!!days_checked}]" variable="i" emptyMessage=""" <$button class="habito-btn daily-btn"> - <$action-listops $field="days_done" $subfilter= - <>/> + <$action-listops $field="days_done" $subfilter="+[append]" /> <$action-setfield-mathjs $tiddler="Habito" $field="gold" $eval="reward+gold" reward={{!!gold_reward}} /> <$action-setfield-mathjs $tiddler="Habito" $field="xp" $eval="xp+1" reward={{!!xp_reward}} /> {{$:/core/images/close-button}} """> <$button class="habito-btn success daily-btn"> - <$action-listops $field="days_done" $subfilter="+[remove]"/> + <$action-listops $field="days_done" $subfilter="+[remove]"/> <$action-setfield-mathjs $tiddler="Habito" $field="gold" $eval="gold-reward" reward={{!!gold_reward}} /> <$action-setfield-mathjs $tiddler="Habito" $field="xp" $eval="xp-1" /> {{$:/core/images/done-button}} -<$list filter=[list[!!days_done]titledate:toOffsetFromDate[]last[]!compare:equal[NaN]]><> +<$list filter="[titletitledate:toOffsetFromDate[]!compare:equal[NaN]]"> + <>
- \ No newline at end of file + \ No newline at end of file diff --git a/plugins/Guitlle/habito/getReward.tid b/plugins/Guitlle/habito/getReward.tid index b90bb9c..c85d919 100644 --- a/plugins/Guitlle/habito/getReward.tid +++ b/plugins/Guitlle/habito/getReward.tid @@ -1,23 +1,22 @@ created: 20180826065511097 list-before: $:/core/ui/ViewTemplate/title -modified: 20180828074341563 +modified: 20180830231421596 tags: $:/tags/ViewTemplate title: $:/plugins/Guitlle/habito/getReward type: application/x-tiddler <$list filter="[all[current]tag[Reward]]" variable="tag_name"> -<$wikify name="dateEntry" text="""<$macrocall $name="now" format="YYYY-0MM-DD 0hh:0mm:0ss"/>"""> -<$wikify name="dateEntry_brackets" text="""<$text text='[['/><><$text text=']]'/>"""> -<$wikify name="cooldown" text="""{{{[list[!!days_rewarded]titledate:toOffsetFromDate[]!compare:greater{!!days_cooldown}first[]count[]]}}}"""> -<$wikify name="nofunds" text="""{{{[{Habito!!gold}!compare:greater{!!gold_price}count[]]}}}"""> +<$wikify name="dateEntry" text="""<$text text='[['/><$macrocall $name="now" format="YYYY-0MM-DD 0hh:0mm:0ss"/><$text text=']]'/>"""> +<$wikify name="cooldown" text="""{{{[list[!!days_rewarded]last[]titledate:toOffsetFromDate[]!compare:greater{!!days_cooldown}first[]count[]]}}}"""> +<$wikify name="nofunds" text="""{{{[{Habito!!gold}!compare:greater{!!gold_price}count[]]}}}"""> <$wikify name="price" text="""<$calc>((<>==1?2:1)*(<>==1?2:1)*{{!!gold_price}})"""> <$wikify name="price_tag" text="""Get this reward by $<>."""> <$wikify name="widget_class" text="""<$list filter="[compare:equal[1]]">habito-reward-cooldown <$list filter="[compare:equal[1]]"> habito-reward-no-funds habito-btn-wrapper""">
> title=<>> <$button class="habito-btn reward-btn"> - <$action-listops $field="days_rewarded" $subfilter=<>/> + <$action-listops $field="days_rewarded" $subfilter=<>/> <$action-setfield-mathjs $tiddler="Habito" $field="gold" $eval="gold - price" price=<> /> $
- \ No newline at end of file + \ No newline at end of file diff --git a/plugins/Guitlle/habito/styles.css.tid b/plugins/Guitlle/habito/styles.css.tid index 81ef8de..a93d53d 100644 --- a/plugins/Guitlle/habito/styles.css.tid +++ b/plugins/Guitlle/habito/styles.css.tid @@ -1,11 +1,11 @@ created: 20180824233146484 makebackup: 1 -modified: 20180828074016305 +modified: 20180830232459495 tags: $:/tags/Stylesheet title: $:/plugins/Guitlle/habito/styles.css type: text/css -[data-tags*="habito-display"] .tc-tab-buttons button { +.habito-display .tc-tab-buttons button { font-size: 14pt; } .habito-btn-wrapper { @@ -24,8 +24,19 @@ type: text/css text-align: center; border: 2px dashed #777777; } + +.habito-btn-wrapper.habito-habit-positive .habit-btn { + background: #BFA; +} +.habito-btn-wrapper.habito-habit-negative .habit-btn { + background: #F7B3B2; +} +.habito-btn-wrapper.habito-habit-negative.habito-habit-cooldown .habit-btn { + background: #E73332; +} .habito-btn-wrapper .habito-btn.success, -.habito-btn-wrapper .habito-btn.reward-btn { +.habito-btn-wrapper .habito-btn.reward-btn, +.habito-btn-wrapper.habito-habit-positive.habito-habit-cooldown .habit-btn { background: #57ee55; } .habito-btn-wrapper.habito-daily-missed .habito-btn, diff --git a/plugins/Guitlle/habito/titledate.js.tid b/plugins/Guitlle/habito/titledate.js.tid index 5e3ed90..6bc6b34 100644 --- a/plugins/Guitlle/habito/titledate.js.tid +++ b/plugins/Guitlle/habito/titledate.js.tid @@ -1,5 +1,5 @@ created: 20180825043907936 -modified: 20180826043843482 +modified: 20180830222314937 module-type: filteroperator tags: title: $:/plugins/Guitlle/helpers/titledate.js @@ -56,11 +56,14 @@ exports.titledate = function(source,operator,options) { from = new Date(); } source(function(tiddler,title) { - try { - results.push(String(Math.floor((from - (new Date(title)))/(24*60*60*1000)))); - } - catch (e) { - results.push("NaT"); + if (title.substr(0,2) ==="[[") title = title.substr(2, title.length - 4); + if (title !== "") { + try { + results.push(String(Math.floor((from - (new Date(title)))/(24*60*60*1000)))); + } + catch (e) { + results.push("NaT"); + } } }); break;