<$button to="<$list filter="[tag[Widgets]] pick-at-random="1">">Go To Random Widget Tiddler</$button><$button to="<pick-at-random from="<$list filter="[tag[Widgets]]">">">Go To Random Widget Tiddler</$button><$list filter="[tag[Widgets]random[]limit[1]]" variable="randomTiddler">
<$button to=<<randomTiddler>> >Go To Random Widget Tiddler</$button>
</$list>source(function(tiddler,title) {
results.push(title);
});is it a list/array of arbitrary objects, indexed by title?Is it a list/array of only tiddlers, indexed by title?The codesource(function(tiddler,title) {
results.push(title);
});is some thing I don't understand well. What is the name given to the javascript concept used here?, which I suspect is transforming the object source in to another object results
.
Here comes the random filter (to limit to n results), as attached.usage : [tag[Widgets]random[1]]
Philip Coltharp:That's something I wouldn't have thought of. Thanks
--
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 tiddlywiki+...@googlegroups.com.
To post to this group, send email to tiddl...@googlegroups.com.
Visit this group at http://groups.google.com/group/tiddlywiki.
For more options, visit https://groups.google.com/d/optout.
Then we'd add a new filter "choose" that would be used like this:[tag[Widgets]choose{$:/info/random}]
There is a potential issue with this approach. It means that each time the filter is evaluated it might return different results, even if the tiddler store hasn't changed. This is contrary to the expectations of the rest of the system; it means, for example, that content could change unexpectedly whenever there is a refresh cycle. In many situations this might not matter, of course.A better approach would be to generate a random number and store it in a tiddler, and then use that tiddler value to choose a tiddler to display. That would mean that the entire state of the UI is once more represented by the tiddler store.
Still a random filter(s) might be used on lists, yes? One could think of four such filters, pick N at random, remove N at random, pick N at random with replacement, and randomize .
The action of the 'choose' filter would be to modulo the operand by the number of entries in the current list, and then use the result as an index to choose a value from the current list.
in editions/tw5.com/tiddlers/ActionNavigateWidget.tid:The ''action-navigate'' widget is invisible. Any content within it is ignored.
I think it can be done without modifying the navigator widget though, by introducing a "randomly choose from filter" action widget:
<$action-chooserandom filter="[is[tiddler]]" tiddler="$:/config/randomtiddler"/>
There is a potential issue with this approach. It means that each time the filter is evaluated it might return different results, even if the tiddler store hasn't changed. This is contrary to the expectations of the rest of the system; it means, for example, that content could change unexpectedly whenever there is a refresh cycle. In many situations this might not matter, of course.
A better approach would be to generate a random number and store it in a tiddler, and then use that tiddler value to choose a tiddler to display. That would mean that the entire state of the UI is once more represented by the tiddler store.
So, in outline, we introduce a tiddler '$:/info/random' that is initialised with a random number at startup. We'd also add a "tm-generate-random" message so that the random value could be regenerated by the user after startup.
Then we'd add a new filter "choose" that would be used like this:[tag[Widgets]choose{$:/info/random}]
The action of the 'choose' filter would be to modulo the operand by the number of entries in the current list, and then use the result as an index to choose a value from the current list.
Then we'd add a new filter "choose" that would be used like this:[tag[Widgets]choose{$:/info/random}]That I really don't get. What is important is that each instance of a [random[]] filter or a filter making use of a random number needs to persist the initial draw until a page reload.
Widgets can be redrawn at any time, if the core detects changes in the tiddler store. So whenever a tiddler, or a section of a tiddler is redrawn and it contains the [random[]] filter, you'll get a new result. But that's not what you want.
Perhaps it would be helpful if I understood your underlying use case. What are you trying to achieve with random number generation?
I don't see the problem on randomly update the random number. I mean, on any refresh cycle of the wiki.
a random number generator opens a tiddler, depending on the number, in the story view.
So with every keystroke you may get a new / different tiddler.
While there may be cases where we want that, I'd be confused by this behaviour.
but one thing I find rather confusing is that open draft tiddlers end up directly updating and showing up in lists. While that may have its benefits to see the result before commiting, it adds to the number of not really needed refreshes.
If you don't like drafts in your list you need to add !has[draft.of] to your filter expression
If you don't like drafts in your list you need to add !has[draft.of] to your filter expressionThat's not quite the point, though. The point would be to ask: Do we want tw to update the document with things that we're currently just about editing and not even done with? Here's a no to that from my side.
The TW core concept is, that basically every keystroke gets saved back to the TW internal store as a draft tiddler.
If you switch on the "reflow highlighting" in chrome debug tools, you'll see what's going on with every keystroke.
Draft tiddlers are also saved back to the server if there is one. Saving is done, if you stop typing for some time.
So TW core will update drafts and I'm pretty sure, that's not going to be changed.
I envision a widget defined like so.. a list in side a button like so. ( Imagine this was put in a tiddler on http://tiddlywiki.com/)<$button to="<$list filter="[tag[Widgets]] pick-at-random="1">">Go To Random Widget Tiddler</$button>OR<$button to="<pick-at-random from="<$list filter="[tag[Widgets]]">">">Go To Random Widget Tiddler</$button>The ideal is to get a button to send a user to a tiddler picked at random from a list.I could do this in Classic Tiddlywiki but I want to learn Tiddlywiki5. How might one do this in TW5 differently than in TWC?
--
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 tiddlywiki+...@googlegroups.com.
To post to this group, send email to tiddl...@googlegroups.com.
Visit this group at http://groups.google.com/group/tiddlywiki.
For more options, visit https://groups.google.com/d/optout.
The notation is essentially the same as Jeremy's suggestion, except I used attribute names with the $ prefix (is there a good reason for the inconsistency on use of $ in different widgets? I often get errors due to guessing wrongly, and sometimes these can be data-deleting errors)
<$action-chooserandom $filter={{SearchText}} $tiddler="SearchResults" $field="randomlist" $pick=5/>
<$action-setfield $tiddler=SomeTiddler tiddler=hi/>
Action widgets use $ for the parameters, I am assuming that is because you can pass (some of) them lists of name=value pairs, like the setfield widget. The $ in needed to distinguish between things like in this example<$action-setfield $tiddler=SomeTiddler tiddler=hi/>
which sets the field called tiddler of SomeTiddler to hi. I am assuming that $ was picked because it isn't a valid symbol in a field name.
I like it, it is far simpler than how I was doing it, which for something that seems to have as much interest as this does is a very good thing. Could you add an option to pick how many tiddlers are returned? Like<$action-chooserandom $filter={{SearchText}} $tiddler="SearchResults" $field="randomlist" $pick=5/>
to return a list of 5 random tiddlers you could put in a list widget?
If the $ is needed in some cases, is there an argument for allowing it for all widget parameters to improve consistency?
As an example of the result of the confusion caused by inconsistency, a couple of times I have neglected the $ in the $tiddler and $field parameters of a $action-setfield widget, with the result that, when activated, the action defaulted to the text field of the current tiddler, overwriting all the text I was working on! That's extremely annoying, and quite difficult to debug when you no longer have the wikitext that caused the problem!