Skip to content

Commit

Permalink
improve filters and fix dailyDone button
Browse files Browse the repository at this point in the history
  • Loading branch information
Guillermo committed Aug 30, 2018
1 parent bb70a9d commit 56fd907
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 33 deletions.
11 changes: 5 additions & 6 deletions plugins/Guitlle/habito/Habito.tid
Original file line number Diff line number Diff line change
@@ -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

<div class="habito-coimage"> <span class="amount"> {{!!gold}} </span> <span>{{$:/plugins/Guitlle/habito/images/coin.png}}</span> </div>
<div class="habito-coimage"> <span class="amount"> {{!!xp}} </span> <span> experience</span> </div>



<div class="habito-display">
<$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" />
</div>
23 changes: 12 additions & 11 deletions plugins/Guitlle/habito/dailyDone.tid
Original file line number Diff line number Diff line change
@@ -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='[['/><<dateEntry>><$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><$list filter="[list[!!days_done]titledate:toOffsetFromDate[]!compare:greater{!!days_warn}count[]compare:equal[0]]">habito-daily-warn </$list>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='[['/><<today>><$text text=']]'/>""">
<$wikify name="lastDate" text="""<$list filter="[list[!!days_done]last[]]"><$text text='[['/><<currentTiddler>><$text text=']]'/></$list>""">
<$wikify name="widget_class" text="""<$list filter="[title<lastDate>titledate:toOffsetFromDate[]!compare:greater{!!days_repeat}count[]compare:equal[0]]">habito-daily-missed </$list><$list filter="[title<lastDate>titledate:toOffsetFromDate[]!compare:greater{!!days_warn}count[]compare:equal[0]]">habito-daily-warn </$list>habito-btn-wrapper""">
<div class=<<widget_class>> title="Task done today.">
<$list filter="[list[!!days_done]titledate:toOffsetFromDate[]!compare:greater{!!days_checked}last[]]" variable="i" emptyMessage="""
<$list filter="[title<lastDate>titledate:toOffsetFromDate[]!compare:greater{!!days_checked}]" variable="i" emptyMessage="""
<$button class="habito-btn daily-btn">
<$action-listops $field="days_done" $subfilter=
<<dateEntry_brackets>>/>
<$action-listops $field="days_done" $subfilter="+[append<todayBrackets>]" />
<$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>
""">
<$button class="habito-btn success daily-btn">
<$action-listops $field="days_done" $subfilter="+[remove<dateEntry_brackets>]"/>
<$action-listops $field="days_done" $subfilter="+[remove<lastDate>]"/>
<$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}}
</$button>
</$list>
<$list filter=[list[!!days_done]titledate:toOffsetFromDate[]last[]!compare:equal[NaN]]><span class="habito-btn-caption"><<currentTiddler>></span> </$list>
<$list filter="[title<lastDate>titledate:toOffsetFromDate[]!compare:equal[NaN]]">
<span class="habito-btn-caption"><<currentTiddler>></span> </$list>
</div>
</$wikify></$wikify></$wikify></$list>
</$wikify></$wikify></$wikify></$wikify></$list>
13 changes: 6 additions & 7 deletions plugins/Guitlle/habito/getReward.tid
Original file line number Diff line number Diff line change
@@ -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='[['/><<dateEntry>><$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>((<<cooldown>>==1?2:1)*(<<nofunds>>==1?2:1)*{{!!gold_price}})</$calc>""">
<$wikify name="price_tag" text="""Get this reward by $<<price>>.""">
<$wikify name="widget_class" text="""<$list filter="[<cooldown>compare:equal[1]]">habito-reward-cooldown </$list><$list filter="[<nofunds>compare:equal[1]]"> habito-reward-no-funds</$list> habito-btn-wrapper""">
<div class=<<widget_class>> title=<<price_tag>>>
<$button class="habito-btn reward-btn">
<$action-listops $field="days_rewarded" $subfilter=<<dateEntry_brackets>>/>
<$action-listops $field="days_rewarded" $subfilter=<<dateEntry>>/>
<$action-setfield-mathjs $tiddler="Habito" $field="gold" $eval="gold - price" price=<<price>> />
$
</$button>
</div>
</$wikify></$wikify></$wikify></$wikify></$wikify></$wikify></$wikify></$list>
</$wikify></$wikify></$wikify></$wikify></$wikify></$wikify></$list>
17 changes: 14 additions & 3 deletions plugins/Guitlle/habito/styles.css.tid
Original file line number Diff line number Diff line change
@@ -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 {
Expand All @@ -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,
Expand Down
15 changes: 9 additions & 6 deletions plugins/Guitlle/habito/titledate.js.tid
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
created: 20180825043907936
modified: 20180826043843482
modified: 20180830222314937
module-type: filteroperator
tags:
title: $:/plugins/Guitlle/helpers/titledate.js
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 56fd907

Please sign in to comment.