Skip to content

Commit

Permalink
TIMELINE: Added attribute synonyms for json event data files. The fol…
Browse files Browse the repository at this point in the history
…lowing attribute names are interchangable.

  The shorter names enable smaller load files. If both are present for an event, the longer attribute name
  wins. Rationale: decrease load times for large event data sets that use json. 
  Changed example2 to use the shorter names. 
     eid -- eventID
       s -- start
       e -- end
      ls -- latestStart
      ee -- earliestEnd
       d -- description
      de -- durationEvent
       t -- title,
       c -- classname


git-svn-id: http://simile-widgets.googlecode.com/svn/timeline/trunk@1954 579c892a-5248-0410-a714-2bcf037eb5bf
  • Loading branch information
larrykluger committed Mar 27, 2009
1 parent 7672342 commit ebf6e83
Show file tree
Hide file tree
Showing 7 changed files with 1,454 additions and 1,410 deletions.
15 changes: 14 additions & 1 deletion CHANGES.txt
Expand Up @@ -18,7 +18,20 @@ Version pre 2.4.0
* Added a test for timezones. -- David H
* Turned the highlight rectangle of a band into an overview of the band it's
synced with (i.e., indicating the visible offset and extent). -- David H rev 1921

* Added attribute synonyms for json event data files. The following attribute names are interchangable.
The shorter names enable smaller load files. If both are present for an event, the longer attribute name
wins. Rationale: decrease load times for large event data sets that use json.
Changed example2 to use the shorter names.
eid -- eventID
s -- start
e -- end
ls -- latestStart
ee -- earliestEnd
d -- description
de -- durationEvent
t -- title,
c -- classname
-- LarryK rev 1954

Version 2.3.1
* timeline-api.js now uses
Expand Down
60 changes: 37 additions & 23 deletions src/webapp/api/scripts/sources.js
Expand Up @@ -98,35 +98,49 @@ Timeline.DefaultEventSource.prototype.loadJSON = function(data, url) {
var parseDateTimeFunction = this._events.getUnit().getParser(dateTimeFormat);

for (var i=0; i < data.events.length; i++){
var event = data.events[i];
var evnt = data.events[i];

// New feature: attribute synonyms. The following attribute names are interchangable.
// The shorter names enable smaller load files.
// eid -- eventID
// s -- start
// e -- end
// ls -- latestStart
// ee -- earliestEnd
// d -- description
// de -- durationEvent
// t -- title,
// c -- classname

// Fixing issue 33:
// instant event: default (for JSON only) is false. Or use values from isDuration or durationEvent
// isDuration was negated (see issue 33, so keep that interpretation
var instant = event.isDuration || (event.durationEvent != null && !event.durationEvent);

var instant = evnt.isDuration ||
(('durationEvent' in evnt) && !evnt.durationEvent) ||
(('de' in evnt) && !evnt.de);
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),
id: ("id" in evnt) ? evnt.id : undefined,
start: parseDateTimeFunction(evnt.start || evnt.s),
end: parseDateTimeFunction(evnt.end || evnt.e),
latestStart: parseDateTimeFunction(evnt.latestStart || evnt.ls),
earliestEnd: parseDateTimeFunction(evnt.earliestEnd || evnt.ee),
instant: instant,
text: event.title,
description: event.description,
image: this._resolveRelativeURL(event.image, base),
link: this._resolveRelativeURL(event.link , base),
icon: this._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,
trackNum: event.trackNum
text: evnt.title || evnt.t,
description: evnt.description || evnt.d,
image: this._resolveRelativeURL(evnt.image, base),
link: this._resolveRelativeURL(evnt.link , base),
icon: this._resolveRelativeURL(evnt.icon , base),
color: evnt.color,
textColor: evnt.textColor,
hoverText: evnt.hoverText,
classname: evnt.classname || evnt.c,
tapeImage: evnt.tapeImage,
tapeRepeat: evnt.tapeRepeat,
caption: evnt.caption,
eventID: evnt.eventID || evnt.eid,
trackNum: evnt.trackNum
});
evt._obj = event;
evt._obj = evnt;
evt.getProperty = function(name) {
return this._obj[name];
};
Expand Down

0 comments on commit ebf6e83

Please sign in to comment.