I know how to make separate bands scroll in unison, this is a given.
Are there any examples out there?
Thanks
Jeff Roehl
tl.getBand(0).band.getCenterVisibleDate();
Back to the back-end in a <form> post. This way I can keep the timeline at the
same location it was when the data was posted. So the user doesn't have to
constantly be scrolling back to the place they where before.
I tried the following, but it doesn't work:
<form method="post"
action="tl3.fwx?todo=editparagraph¶=FHE2V0O81&tl=Y95CC1A21¢er="
onsubmit='return subm_form(this)'>
<script>
function subm_form( frm ) {
frm.action += tl.getBand(0).band.getCenterVisibleDate.value;
return true;
}
</script>
Am I messing up the syntax here?
Thanks
Jeff Roehl
Here's a simple case of two timelines, tl_a and tl_b:
tl_a.getBand(0).addOnScrollListener(function(band) {
var centerDate = band.getCenterVisibleDate();
tl_b.getBand(0).setCenterVisibleDate(centerDate);
});
tl_b.getBand(0).addOnScrollListener(function(band) {
var centerDate = band.getCenterVisibleDate();
tl_a.getBand(0).setCenterVisibleDate(centerDate);
});
When the user scrolls the first band in timeline A, the first band in timeline B will be set to the same date, and vice-versa.
If the timelines contain more sync'ed bands, then those will scroll as well.
--Mike
> --
> You received this message because you are subscribed to the Google Groups "SIMILE Widgets" group.
> To post to this group, send email to simile-...@googlegroups.com.
> To unsubscribe from this group, send email to simile-widget...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/simile-widgets?hl=en.
>
It should be like this:
tl.getBand(0).getCenterVisibleDate().dateFormatAsString()
where dateFormatAsString is a function that takes a Javascript Date object and returns a string like:
"2011-06-23T12:34:00" or whatever format you need to send to your server.
There are many date-formatting libraries available for Javascript. See the DateJS library at: http://www.datejs.com
It has a formatter called .toISOString() which does exactly this.
Since you are submitting via POST rather than GET in your form, you shouldn't be adding parameters to the form's action attribute. Rather, you should be using the form's element values themselves as the data for the post. Include a <input type="hidden" name="center" id="center" value=""/> in your <form>.
Add a scroll listener to automatically update the hidden input anytime the user scrolls:
tl.getBand(0).addOnScrollListener(function(band) {
var centerDate = band.getCenterVisibleDate();
document.getElementById("center").value = centerDate.dateFormatAsString();
});
--Mike
On Jun 22, 2011, at 4:49 PM, Jeff Roehl wrote:
> One thing I need to do is send:
>
> tl.getBand(0).band.getCenterVisibleDate();
>
> Back to the back-end in a <form> post. This way I can keep the timeline at the
> same location it was when the data was posted. So the user doesn't have to
> constantly be scrolling back to the place they where before.
>
> I tried the following, but it doesn't work:
>
>
> <form method="post"
> action="tl3.fwx?todo=editparagraph¶=FHE2V0O81&tl=Y95CC1A21¢er="
*****************************************************************************
Where do I put the ScrollListener?
I have put it at the bottom of the onload function, per the following. Is this
correct?
*****************************************************************************
function onLoad(){ var bandInfos = [ Timeline.createHotZoneBandInfo({ zones: [
{ start: "Jan 02 1939 00:00:00 GMT-0500", end: "Dec 31 1945 00:00:00
GMT-0500", magnify: 39, unit: Timeline.DateTime.MONTH}, { start: "Jan 01
1917 00:00:00 GMT-0500", end: "Jan 01 1939 00:00:00 GMT-0500", magnify: 4,
unit: Timeline.DateTime.YEAR}, { start: "Apr 01 1945 00:00:00 GMT-0500",
end: "May 01 1945 00:00:00 GMT-0500", magnify: 10, unit:
Timeline.DateTime.WEEK} ], eventSource: Y95CC1A21, date: "Jan 01 1945
00:00:00 GMT-0500", width: "90%", layout: "original", intervalUnit:
Timeline.DateTime.DECADE, intervalPixels: 180 }) ,
Timeline.createHotZoneBandInfo({ zones: [ { start: "Jan 01 1930 00:00:00
GMT-0500", end: "Dec 29 1946 00:00:00 GMT-0500", magnify: 5, unit:
Timeline.DateTime.YEAR}, ], eventSource: Y95CC1A21, date: "Jan 01 1945
00:00:00 GMT-0500", width: "10%", layout: "overview", intervalUnit:
Timeline.DateTime.DECADE, intervalPixels: 80 }) ]; bandInfos[1].syncWith = 0;
bandInfos[1].highlight = true; tl =
Timeline.create(document.getElementById("timeline"), bandInfos);
Timeline.loadXML("xml/NUAAW0Z81.xml", function(xml, url) {
Y95CC1A21.loadXML(xml, url); }); };
tl.getBand(0).addOnScrollListener(function(band) { var centerDate =
band.getCenterVisibleDate(); document.getElementById("center").value =
centerDate.dateFormatAsString(); });
Thanks
Jeff Roehl
Trailing commas inside array definitions like this },] cause Internet Explorer to choke and fail. Avoid them because they are very difficult to find by visual inspection, and cause IE to fail spectacularly without any sort of helpful error message.
--Mike
> Jeff Roehl\