On Saturday, June 26, 2021 at 8:05:15 PM UTC-7 Soren Bjornstad wrote:

> Has anyone found a way to make TiddlyWiki re-render a part of the page 
> template periodically?

I'd like to have a section in my page template that does a calculation 
> based on the current time, and would love if I didn't have to click a 
> button all the time to update it. 

Maybe some kind of event that's scheduled in JavaScript and fires every 
> minute?


My TiddlyTools Timer functions can do this.

1) Copy the $action-timeout widget from 
   http://tiddlytools.com/timer.html#TiddlyTools%2FTime%2Faction-timeout.js 
<http://tiddlytools.com/timer.html#TiddlyTools%2FTime%2Faction-timeout.js>

2) Create a "MinuteTickerStartup" tiddler, tagged with 
*$:/tags/StartupAction*, containing:
\define minute_ticker() <$action-setfield 
$tiddler="$:/temp/time/minuteticker" text=<<now [UTC]0hh0mm0ss>> />
<$action-timeout interval=60000 actions=<<minute_ticker>> />

3) In a tiddler tagged with *$:/tags/PageTemplate*, put the content you 
want to automatically re-render each minute, like this:
<$vars ticker={{$:/temp/time/minuteticker}}>
   *** content you want to re-render ***
</$vars>

Notes:
1) MinuteTickerStartup is invoked *once* when you load your TiddlyWiki and 
sets up an javascript "interval" timer that is triggered every minute 
(60000 milliseconds)
2) The ticker action updates the contents of *$:/temp/time/minuteticker* to 
contain the current time (0hh0mm0ss)
3) The $vars "wrapper" in the page template tiddler creates a refresh 
dependency associated with the current value in *$:/temp/time/minuteticker*

The result is that whatever content is in your page template will be 
re-rendered once per minute.  Q.E.D.

enjoy,
-e

-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/ea9e9a25-1b61-444e-a53c-89b174057bacn%40googlegroups.com.

Reply via email to