This took me a while, but I found a way to create a message of the day 
generator which changes the message given on how many messages you have and 
what day of the month it is. 

You add the messages in [[]] and the code will do the rest :D

The current 'bug' is that it will only allow you to have about 30 messages, 
as it cannot display more messages of the day than there are days in the 
month.

Copy/paste this Tiddler and see what message of the day you get!

<style>
.message-of-the-day {
  color: red;
}
</style>

<$wikify mode="inline" name="dayofmonth_val" text=<<now DD>> >
<$set name="messages" filter="


[[Message 1]] 


[[Message 2]]


[[Message 3]]


[[Message 4]]


">
<$set name="list_length" filter="[enlist<messages>count[]]">
<$set name="list_index" filter="[<dayofmonth_val>remainder<list_length>]">
<$list variable="result" filter="
[enlist<messages>nth<list_index>]">
<h1><span class="message-of-the-day">Message of the day: 
<<result>></span></h1>
</$list>
</$set>
</$set>
</$set>
</$wikify>


My question here is: is there any way to do this more efficient?
In JavaScript this is the equivalent of: 

var messages = ["Message 1", "Message 2", "Message 3", "Message 4"]
var result = messages[new Date().getDate() % messages.length]
//and then display the result var in anyway you see fit

-- 
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/68165798-1990-42f2-897c-21d5a3275b57%40googlegroups.com.

Reply via email to