Adding Exhibit data sets programatically?

46 views
Skip to first unread message

Eric

unread,
Sep 16, 2008, 10:33:29 AM9/16/08
to SIMILE Widgets
Is it possible to add/load data sets "directly" (i.e. rather than a
separate linked JSON file or other source)? Instead of having for
example:

<link href="nobelists.js" type="application/json" rel="exhibit/data"/>

I would like to be able to do something along the lines of:

<script>
var data = { "items" : [ { label : "Burton Richter",
discipline : "Physics",
shared : "yes",
} ] };

Exhibit.load(data);
</script>

David R. Karger

unread,
Sep 16, 2008, 12:25:40 PM9/16/08
to simile-...@googlegroups.com
I'm not sure whether embedding javascript data possible, but Johan
Sundstrom demoed placing the data inside an html TABLE in the main page:
http://ecmanaut.googlepages.com/choir-events.html
I've always thought this is a really great idea, as it completely solves
the problem of non-js browsers and also of google indexing the exhibits.

Although it worked well in the past, it appears not to be running at the
moment. But if you look in the source you can see all the exhibit bits
are still there. I'm not sure what Johan's plans for it are.

-David

Eric

unread,
Sep 17, 2008, 7:27:53 AM9/17/08
to SIMILE Widgets
Thanks, interesting stuff. I was able to find an example of how to
use inline javascript from an older post in this group actually;
basically

1) Load in the exhibit script appending the "autoCreate=false"
parameter, i.e.:

<script type="text/javascript" src="http://static.simile.mit.edu/
exhibit/api-2.0/exhibit-api.js?autoCreate=false"></script>

2) Then, in an onLoad handler, do this:

var myData = { "items" : .... json stuff here };

window.database = Exhibit.Database.create();
window.database.loadData(myData);
window.exhibit = Exhibit.create();
window.exhibit.configureFromDOM();
> > </script>- Hide quoted text -
>
> - Show quoted text -

David Karger

unread,
Sep 17, 2008, 7:49:09 AM9/17/08
to simile-...@googlegroups.com
If you have a chance to do the experiment, it would be nice to know if
google indexes your data inside the script tags. I am guessing not.

It would also be a nice addition to exhibit to allow what you've done
(specification of data inline) to happen without deactivating the
autocreate---ie, to have the autocreating exhibit check for a predefined
items variable in addition to loading data files. I guess one way would
be to embed the data definition in an "internal callback"---

function Items() {


var myData = { "items" : .... json stuff here };

return myData
}

Then have exhibit call the Items() function if it is defined. This
could combine with loading data from elsewhere.

Reply all
Reply to author
Forward
0 new messages