Update timeline-api.js to support non-MIT ajax file location

14 views
Skip to first unread message

LarryK

unread,
Sep 1, 2008, 2:25:21 PM9/1/08
to SIMILE Widgets
Hi,

The current timeline-api.js enables setting of js global variables to
set options and the location of the Timeline js root. But the script
then still loads the Simile Ajax library from the MIT servers. It is
often not appropriate to refer to MIT servers in production code.

The following patch updates timeline-api.js to look at global js
variable Timeline_ajax_url if it does not exits, nothing changes. If
it does exist, it is used as the location of the simile-ajax-api.js
library.

I also added usage notes.

If someone has svn permission, please look this over and then check it
in.

Thanks and regards,

Larry

~~~~~~~~~~~~~~~~~

*** timeline-api.stock.js 2008-09-01 10:18:22.000000000 -0400
--- timeline-api.js 2008-09-01 13:09:42.000000000 -0400
***************
*** 12,17 ****
--- 12,38 ----
*==================================================
*/

+ /*==================================================
+ *
+ * To run from your own server:
+ *
+ * Set global js variables used to send parameters to this script.
+ * eg your html page would include
+ *
+ * <script>
+ * Timeline_ajax_url="http://YOUR_SERVER/javascripts/timeline/
timeline_ajax/simile-ajax-api.js";
+ * Timeline_urlPrefix='http://YOUR_SERVER/javascripts/timeline/
timeline_js/';
+ * Timeline_parameters='bundle=true';
+ * </script>
+ * <script src="http://YOUR_SERVER/javascripts/timeline/
timeline_js/timeline-api.js"
+ * type="text/javascript">
+ * </script>
+ *
+ *
+ *==================================================
+ */
+
+
(function() {
var useLocalResources = false;
if (document.location.search.length > 0) {
***************
*** 202,207 ****
--- 223,232 ----
var url = useLocalResources ?
"http://127.0.0.1:9999/ajax/api/simile-ajax-api.js?
bundle=false" :
"http://static.simile.mit.edu/ajax/api-2.0/simile-ajax-
api.js";
+ if (typeof Timeline_ajax_url == "string") {
+ url = Timeline_ajax_url;
+ }
+
var createScriptElement = function() {
var script = document.createElement("script");
script.type = "text/javascript";


David Erickson

unread,
Sep 1, 2008, 8:00:48 PM9/1/08
to simile-...@googlegroups.com
Alternatively you can just include the local api libraries from your
pages and it will not attempt to reload them from the MIT address.

-David

LarryK

unread,
Sep 2, 2008, 12:21:15 AM9/2/08
to SIMILE Widgets
Hi David,

My concern with including the simile-ajax libraries is that the
timeline-api.js file makes use of the simile-ajax "onload" method. You
(appear) to chance a race-condition of having the dom not be ready if
you just include the simile ajax and then include and invoke the
Timeline js.

Of course, I could call the onload method myself, but I figured it
would be easier and less of a change to use the already developed code
that deals with the onload issues already, the timeline-api code. --
Just telling it to use my server instead of MIT.

Regards,

Larry

Mike

unread,
Sep 2, 2008, 12:44:11 PM9/2/08
to SIMILE Widgets
Hi Larry,

Can you clarify all the needed pieces for this patch to work?

It looks like you need both a local copy of timeline AND the simile-
ajax-api in your site.

If this is the case, this sounds like exactly what I need, as it looks
like I'll need to modify simile-ajax-api to fix a display error with
Firefox 3.

Thanks,
Mike

LarryK

unread,
Sep 2, 2008, 2:30:02 PM9/2/08
to SIMILE Widgets
Hi Mike,

> Can you clarify all the needed pieces for this patch to work?
>
> It looks like you need both a local copy of timeline AND the simile-
> ajax-api in your site.
>

Correct. Download (export) the Timeline source tree. The export
command will also (auto-magically) drag in two other project's source:
simile-ajax and the build tools.

eg
cd some-working-directory
svn export http://simile-widgets.googlecode.com/svn/timeline/trunk
timeline # will create timeline subdirectory

Next, modify the ajax source
*** Please send an email with your patch to the group so we can
benefit from your time and experience.

Next, rebuild the bundle files. This is done by using ant. If you are
on Linux or MacOS, there should be a package for ant that will also
bring in the dependencies. On my Linux system I did
sudo yum install ant

cd some-working-directory/timeline
ant # this will build the
default targets which is what you want

Next, use my install script (see other thread mentioned below) to copy
over just the minimum from your local copy to your javascript
directory on your web server.
Or just copy over the entire source tree to your javascript directory
on your web server.

Update your html file to use the local files and you're good to go.
This thread (see my posts in it) has detail about using a local copy
(on your own server) of the Timeline and Simile-Ajax libraries. I'd
advise using the patch shown above to enable the timeline-api.js file
to load your simile-ajax library. Reason: avoid potential for a race-
condition.

http://groups.google.com/group/simile-widgets/browse_thread/thread/d7c99ead4728c745/5cd5b4e25bbd1591

*** Please start a separate email thread with the problem you're
running into on FF3 and your solution.

Thanks and regards from NYC,

Larry

Oli Howson

unread,
Sep 2, 2008, 2:44:35 PM9/2/08
to simile-...@googlegroups.com
I followed the destructions, but they're still there :'(
http://www.badllama.net/timeline/

thanks

Oli

Michael Osterman

unread,
Sep 2, 2008, 5:55:49 PM9/2/08
to simile-...@googlegroups.com

Hi Larry,

Thanks for the detailed response. I'll give this a try shortly.

The FF3 issue is at this previous forum thread:

http://groups.google.com/group/simile-widgets/browse_thread/thread/51d3c99a5eb6b757


From how I read this, the change needs to be made in the simile-ajax-api.

Cheers!
Mike

Reply all
Reply to author
Forward
0 new messages