After a lot of tinkering and experimenting with javascript snippets found
online I have finally decided that the simplest way is the best way.
I decided to do away with event_year, event_month, event_date fields.
Instead just kept a field event_when. And in the associated textbox I take
care to enter the value as yyyy,mm,dd so that this string when retrieved
can be directly used to create a javascript Date object using new
Date(DateString) syntax.
So I have put this code in a tiddler and tagged it with systemConfig:
var sortNestedFieldDate = function (arr) {
arr.sort(function (a, b) {
var valueA = new Date(a.fields.event_when);
var valueB = new Date(b.fields.event_when);
if (valueA < valueB) {
return -1;
} else if (valueA > valueB) {
return 1;
} else {
return 0;
}
});
};
And then in a separate tiddler I call this code as inline script (within
script tags):
<script>
var events= store.getTaggedTiddlers("Event");
sortNestedFieldDate(events);
events.sort();
var out=[];
for (var i=0;i<events.length;i++){
out.push(events[i].fields.event_when.toString()+":
[["+events[i].title+"]]");
}
return out.join("\n");
</script>
This prints out a list of tiddler sorted on date (field event_when) of the
event. Hope this helps some future TW user.
As a side note I was a little bit disappointed that there is no DatePicker
plugin available in TW world. There is one interwined in mGSD TW but for me
it is near impossible to create a decent workable independent code out of
it.
--
You received this message because you are subscribed to the Google Groups
"TiddlyWiki" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/tiddlywiki/-/9ah6uxErbfMJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/tiddlywiki?hl=en.