Thanks, I will use your advice (and will supply the code for event- removal in case I write such)
On Mar 17, 11:53 pm, Larry Kluger <[email protected]> wrote: > Hi Ora, > > To add an event at runtime, just do the following: > > var eventSource1 = new Timeline.DefaultEventSource(); > > Use eventSource1 as an argument to create band. It will supply event > information to the band. > > var evt = new Timeline.DefaultEventSource.Event({event details...}); > eventSource1 ._events.add(evt); > > After adding all of your events at a given time, call > eventSource1._fire("onAddMany", []); > and > tl.layout(); > > Re removing an event > Events are stored in a SimileAjax.EventIndex data structure. > It is defined in file ajax/api/scripts/data-structure > > Currently it does NOT include a remove function, only a removeAll function. > > Thus your options are: > 1) Write a remove function for the SimileAjax.EventIndex data structure. If > you also write a test and an example that uses the new feature, then I'd be > happy to add the new software to the Timeline source. > 2) Instead of removing the event, mark the event as "deleted" -- remember > that you can add your own private attributes to an event object as long as > long as the attribute names don't clash with any others. Then write a filter > function for Timeline's filtering mechanism that will never show the > "deleted" events. > > Regards, > > Larry > ps. Don't use "event" as a local variable name. It is a reserved word in > Javascript and breaks IE. Use evnt or something instead. > > ________________________________ > From: ora <[email protected]> > To: SIMILE Widgets <[email protected]> > Sent: Tuesday, March 17, 2009 3:43:03 AM > Subject: add and remove events in runtime > > Hi everyone, > > I am totaly new with Simile and I am trying to find the best way to > add/remove events from the time line on runtime. > In the API I didnt find remove&add methods but looking at the source > code, I can try and do something similar to what is done in the > LoadXml/loadJson methods. > "add" will look something like this: > function addDummyEvent(){ > var event ={'start': 'May 28 2006 09:00:00 GMT', > 'end': 'Jun 15 2006 09:00:00 GMT', > 'title': 'added event', > 'description': 'added event', > 'image': 'http://imagecache2.allposters.com/images/BRGPOD/ > 102770_b.jpg', > 'link': 'http://www.allposters.com/-sp/Portrait-of-Horace- > Brodsky-Posters_i1584413_.htm' > } > var url = '.'; > var dateTimeFormat = null; > var base = eventSource._getBaseURL(url); > var parseDateTimeFunction = eventSource._events.getUnit().getParser > (dateTimeFormat); > var evt = new Timeline.DefaultEventSource.Event({ > id: ("id" in event) ? event.id : undefined, > start: parseDateTimeFunction(event.start), > end: parseDateTimeFunction(event.end), > latestStart: parseDateTimeFunction > (event.latestStart), > earliestEnd: parseDateTimeFunction > (event.earliestEnd), > instant: event.isDuration || false, > text: event.title, > description: event.description, > image: eventSource._resolveRelativeURL > (event.image, base), > link: eventSource._resolveRelativeURL > (event.link, base), > icon: eventSource._resolveRelativeURL > (event.icon, base), > color: event.color, > textColor: event.textColor, > hoverText: event.hoverText, > classname: event.classname, > tapeImage: event.tapeImage, > tapeRepeat: event.tapeRepeat, > caption: event.caption, > eventID: event.eventID > }); > > Timeline.DefaultEventSource.prototype.add.call(eventSource,evt); > tl.layout(); > debugger; > > } > > and I guess I can do something like this for removal (assuming I add > eventId): > function removeEvent(id){ > > eventSource._events.remove(id);}; > > Note: the eventSource source used in the methods above is a global > variavle in which I store my eventsource. > > Do you think these methods are ok?, any other suggestions? > > Thanks > Ora --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
