RevLetObject — An easy way to embed Revlets in your web page

This source code is released under the terms of the MIT License.

What it is

RevLetObject will help you load revlets and detect the plugin. Include it in your homepage with:

<script src="revletobject.js"></script>

To detect the plugin use the revletobject.pluginloaded() function, it will return true or false.

To load a revlet use the revletobject.load() function, this will accept a JSON object.

Example:
<div id="main"></div>
<div id="samples"></div>
<script type="text/javascript">
if (revletobject.pluginloaded()) {
revletobject.load({
width: 655,
height: 530,
src: "labone.revlet",
stack: "labone",
instanceID: "1",
id: "main"});

revletobject.load({
width: 227,
height: 227,
src: "labone.revlet",
stack: "samples",
instanceID: "1",
id: "samples"});
} else {
document.write("plugin not loaded.");
}
</script>

Let us take a closer look into the load call:
revletobject.load({
width: 227,
height: 227,
src: "labone.revlet",
stack: "samples",
instanceID: "1",
id: "samples"});

As you can see, the members of the inline object passed as parameter are the same as the ones used by the embed/object tags. The id should point to a HTML Node ID, this element innerHTML will be replaced by the revlet. In our previous example we replace div#main and div#samples.

if you want to pass your own parameters to the revlet, use a key named params with a json of its own, such as:

revletobject.load({
width: 655,
height: 530,
src: "aagrevletobject.revlet",
stack: "aagrevletobject",
instanceID: "2",
id: "params",
params: {
test: "this is a test",
color: "blue"}
}
);

As you can see on line 8, there is a key named params, and the value of this key is in itself a object, each key/value pair of this params object becomes another param to the embed/object tags.

Have fun!

Download: RevLetObject is offered thru BitBucket Mercurial repositories. Use the link in the side menu to go to the repository or click here to download an up to date copy.