Thanks for the quick replies.

I think I've got it most of the way there, but I don't see the event on my
timeline.

Here's how I set up the timeline:

var tl;

function onPageLoad () {
var timelineBands = [
             Timeline.createBandInfo( {
             eventSource: timelineEvents,
             width: "100%",
             intervalUnit: Timeline.DateTime.DAY,
              intervalPixels: 100
        })
   ];
tl = Timeline.create (document.getElementById("timeline-div"),
timelineBands);
}


Then, I add an event like so:

/*
  'time' is a string of the form "MM-DD-YYYY hh:mm"

  According to this:
http://code.google.com/p/simile-widgets/wiki/Timeline_EventSourceJSON_jsDate

  I can use Date() objects in the JSON (which might be a lie... I don't
know.)
*/
       var dateString = time.substring(0, idx);
        var timeString = time.substring(idx+1, time.length);
        var tmp = dateString.split('-');
        var arr = timeString.split(':');

        debug_out("tmp[2] = "+tmp[2]+" tmp[1] = "+tmp[1]+" tmp[0] =
"+tmp[0]);

        var d = new Date(Number(tmp[2]), Number(tmp[0])-1, Number(tmp[1]),
Number(arr[0]), Number(arr[1]));
        debug_out(d);
        var evt = new Timeline.DefaultEventSource.Event ({
                'id': 'F',
                'start': new Date(Number(tmp[2]), Number(tmp[0])-1,
Number(tmp[1]), Number(arr[0]), Number(arr[1])),
                'end': new Date(Number(tmp[2]), Number(tmp[0])-1,
Number(tmp[1]), Number(arr[0]), Number(arr[1])),
                'title': 'TEST EVENT ',
                'dateTimeFormat': 'iso8601',
                'durationEvent': false
            });
        tl.getBand(0).getEventSource().add(evt);

I don't see any errors in Firefox's error console, but I also don't see the
event on the timeline.  Incidentally, I've only been using Javascript for a
whole 1.5 weeks so I could just be doing something stupid there...

Thanks
-matthew





On Thu, Sep 17, 2009 at 11:27 AM, Michael Nosal <[email protected]> wrote:

> Matthew,This is relatively straightforward to do. Events on the timeline
> come from the EventSource objects for the timeline. Adding another event to
> the timeline just requires you to create the Event object, add it to the
> appropriate EventSource and repaint on the Timeline. (fire the "onAddOne"
> event for the EventSource). Same thing for removing events from the
> timeline. Just find the event you want in the EventSource's array of events
> and remove it from the array.
>
> Example:
> Suppose tl is my Timeline object and I want to add a new event to the first
> band:
> var newEvt = new Timeline.DefaultEventSource.Event(...); // fill in id,
> start, end, etc
> tl.getBand(0).getEventSource().add(newEvt);
>
> If you want to remember these changes, you'll just need to save your events
> back to your server/database. A little bit of forms and ajax processing is
> all it takes, but you'll need to have something on the backend of your
> server to store it.
>
> --Mike
>
> On Sep 17, 2009, at 11:01 AM, shyam kumar wrote:
>
> Hi Mathew,
> I had implemented this scenario where the user wants to add / remove
> certain events as per his convinience.
> For this i have implemented a servlet which is calling by xmlhttprequest
> (response will be xml/json) to get what the events dynamically whatever user
> wants to display in timeline.
>
> Hope this helps you to get basic idea.... Its not big trick but its tedious
> process..
>
> ~Shyam
>
> On Thu, Sep 17, 2009 at 7:55 PM, matthew <[email protected]>wrote:
>
>>
>> I am working on web page where the user will be able to add or remove
>> individual events from a timeline but I'm not sure how to implement
>> this.  I've found code examples where all events are loaded from XML
>> or JSON but no examples where a single event is added or removed.
>>
>> Does this library support this?  Can someone point me in the right
>> direction?
>>
>> Thanks for the help
>> -matthew
>>
>>
>>
>>
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"SIMILE Widgets" group.
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/simile-widgets?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to