Hi, I'm trying to get timeplot to work "locally" (local webserver
context) instead of loading resources from static.simile.mit.edu.

Short question:

I was able to get timeplot to load all of the javascript resources
from my local server at a relative context path, however it appears
that the code which is in Subversion causes a javascript error.  When
I replace the Subversion code with a copy from static.simile.mit.edu
then timeplot magically works locally.

The javascript error (when bundle=false) is: "Null value
http://localhost:8080/myapp/js/timeplot/api/1.0/scripts/timeplot.js
(line 410)"

Is there a bug in the subversion trunk (revision 9462)?


Longer notes about getting local resources loaded with a relative
context which may be useful for someone else:

The directions on the wiki to load locally or offline didn't quite
work for me: http://simile.mit.edu/wiki/How_to_Run_Timeplot_Off-line
but here is what I got to work:

(Note: I have a grails application, and all files come from a
contextualized path on the server, e.g. "/myapp/..."  I want
Javascript resources to load from a directory named "/myapp/js". This
is where grails puts js resources by default.)

> cd ./web-app/js
> svn co http://simile.mit.edu/repository/timeplot/trunk/src/webapp/api/ 
> timeplot/api/1.0
> svn co http://simile.mit.edu/repository/timeline/trunk/src/webapp/api/ 
> timeline/api-2.0
> svn co http://simile.mit.edu/repository/ajax/trunk/src/webapp/api/     
> ajax/api-2.0

(now the js resources are all available under the URL "http://
localhost:8080/myapp/js" )

Timeplot if set to "local" mode attempts to load the SimileAjax and
Timeline from an absolute location ("/ajax" or "/timeline") on the
server, which I don't want.

To avoid having Timeplot try to load Timeline and SimileAjax from the
root context of the web server, I explicitly load those applications
first and they determine their own relative locations just fine as
long as the script element is inside the head element (perhaps
Timeplot can use this technique?).

    <script type="text/javascript" src="/myapp/js/ajax/api-2.0/simile-
ajax-api.js"></script>
    <script type="text/javascript" src="/myapp/js/timeline/api-2.0/
timeline-api.js"></script>

However, looking at the timeplot-api.js, it seems that "local" mode
causes it to load itself from an absolute web path ("/timeplot"),
however I want it to load from "/myapp/js/timeplot", so I don't want
"local" mode. timeplot-api.js also determines that it is loading
locally if the word "local" is in the URL at any location, which
unfortunately also matches when the host is named "localhost".  So I
have to either patch timeplot-api.js (see patch at the bottom) or
change to use the hostname "127.0.0.1" when running locally.

To get Timeplot to play nice I can then define the Timeplot_urlPrefix
variable to point to the location it is in:

    <script type="text/javascript">
        var Timeplot_urlPrefix="/myapp/js/timeplot/api/1.0/";
    </script>

Then I can load timeplot:

    <script type="text/javascript" src="/myapp/js/timeplot/api/1.0/
timeplot-api.js"></script>


After loading the page with "http://127.0.0.1/..."; instead of "http://
localhost/..." all of the JS resources appear to load correctly.   The
problem then is that there is an error in scripts/timeplot.js:410 .

Replacing the timeplot-bundle.js from static.simile.mit.edu fixes that
problem when in bundle mode.

here is a patch for timeplot-api.js to be cleaner about picking local
mode:

Index: timeplot-api.js
===================================================================
--- timeplot-api.js     (revision 9462)
+++ timeplot-api.js     (working copy)
@@ -28,8 +28,8 @@
             while (node != null) {
                 if (node.nodeType == 1 && node.tagName.toLowerCase()
== "script") {
                     var url = node.src;
-                    if (url.indexOf("timeplot-api") >= 0) {
-                        local = (url.indexOf("local") >= 0);
+                    if (url.indexOf("timeplot-api") >= 0 &&
url.indexOf("?")>=0) {
+                        local = (url.indexOf("local") >= url.indexOf
("?"));
                     }
                 }
                 node = node.nextSibling;


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"SIMILE Widgets" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/simile-widgets?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to