On Jun 14, 5:37 am, HansBKK <
hans...@gmail.com> wrote:
> Very cool, we're getting there. Now to be able to create multiple sets and
> control the ordering. . .
>
> Neither of the below work, because (obviously) me have no JS.
but the spirit :)
try this.
http://pastebin.com/ihKjWYgY
If you are interested, what's going on, read the following.
Otherwise just have fun! :)
====
some info, what's going on.
store.getMatchingTiddlers() returns an array of objects
eg:
[ {title: "New Tiddler", modified: 20110614120000, created ...},
{title: "New Tiddler1", modified: 20110614120000, created ...} ]
====
.reverse(); .. reverses the sort order
store.getMatchingTiddlers("default","-modified") .. does the same :)
see the minus in front of "-modified".
====
so tids1 and tids2 are arrays of objects
we can combine two arrays with concat().
var tids = []
tids = tids.concat(tids1,tids2);
====
map() function can manipulate arrays. In our case it returns the title
of the tids objects.
The following line is very hacky, because it converts the "object
tids" into an "array tids". Sorry for this, but it saves a variable.
tids = tids.map(function(elem){return elem.title})
====
join() can take arrays and create a string
["text 1", "text 2"].join(']] [[') creates
"text 1]] [[text 2"
'[[' + join() + ']]' ... fixes the front and the end of the string
et voila:
config.shadowTiddlers["DefaultTiddlers"] = '[[' + tids.join(']] [[') +
']]';
hope this helps
-m