Detecting wether timelines has been loaded

89 views
Skip to first unread message

Jeff Roehl

unread,
Sep 25, 2012, 7:31:29 PM9/25/12
to simile-...@googlegroups.com
In jQuery, I can detect whether jQuery has been loaded and what version is running with:

if (window.jQuery === undefined || window.jQuery.fn.jquery !== '1.8.1')

Is there something similar I can do with Simile Timelines?
 

Michael Nosal

unread,
Sep 25, 2012, 7:48:54 PM9/25/12
to simile-...@googlegroups.com
if (window.Timeline === undefined) {
console.log("Timeline not loaded")
}
else {
console.log("Timeline.version = " + Timeline.version)

Jeremy Boggs

unread,
Sep 25, 2012, 7:54:37 PM9/25/12
to simile-...@googlegroups.com
On Sep 25, 2012, at 7:31 PM, Jeff Roehl wrote:

> In jQuery, I can detect whether jQuery has been loaded and what version is running with:
>
> if (window.jQuery === undefined || window.jQuery.fn.jquery !== '1.8.1')
>
> Is there something similar I can do with Simile Timelines?

You can check to see if the Timeline object is undefined, or if the 'version' property on it doesn't equal a specific version. Something like this should do the same thing as the jQuery example you provided:

if (window.Timeline === undefined || window.Timeline.version !== '2.3.1')

If you'd like to easily see all the other properties available on the Timeline object, just do console.debug(Timeline); in a browser console. Most modern browsers have good developer tools for doing stuff like this, or have plugins available for it. (I use Chrome and its developer tools.)

Best,
Jeremy

--
Jeremy Boggs
Design Architect
Digital Research and Scholarship, University of Virginia Library

David Karger

unread,
Sep 26, 2012, 8:35:39 PM9/26/12
to simile-...@googlegroups.com, Jeremy Boggs
Careful, note that the timeline object gets defined when timeline
_begins_ to load; using this heuristic might lead you to invoke timeline
before it _finishes_ loading the various supporting scripts.
Reply all
Reply to author
Forward
0 new messages