This project is read-only.
1
Vote

Doesn't support secure pages and funky logic for ScriptSourceLocation

description

Hi Rob,
 
The logic for determining where to load the timeline script from seems very funky looking for a literal in head of the page. If I set a value for ScriptSourceLocation to Local and I specify a path for LocalTimelineJSFolder, it should assume the files will be there and not do this funky search for a literal in head, the script will not typically be loaded in head using Page.ClientScript.RegisterClientScriptBlock so its a bad assumption that the script is not loaded if not found there.
 
I changed the logic in OnInit in my copy as follows so that it will load the script locally and support ssl if the page is secure.
 
if (Page.Request.IsSecureConnection)
            protocol = "https";
 
        if (this.ScriptSourceLocation == ScriptSourceLocations.Remote)
        {
            Page.ClientScript.RegisterClientScriptBlock(
                typeof(Timeline),
                "timelineapi", "\n<script type=\"text/javascript\" src=\""
                + protocol + "://simile.mit.edu/timeline/api/timeline-api.js"
                + "\" ></script>");
        }
        else
        {
            Page.ClientScript.RegisterClientScriptBlock(
               typeof(Timeline),
               "simile-ajax-api", "\n<script type=\"text/javascript\">var timelinebaseUrl = '" + Page.ResolveUrl(LocalTimelineJSFolder) + "'; </script>");
 
            Page.ClientScript.RegisterClientScriptBlock(
                typeof(Timeline),
                "timelineapi", "\n<script type=\"text/javascript\" src=\""
                + Page.ResolveUrl(LocalTimelineJSFolder + "api/timeline-api.js?i=0&amp;timeline-use-local-resources=true")
                + "\" ></script>");
 
        }
 
 
        if (EnableSearchAndFilter)
        {
            Page.ClientScript.RegisterClientScriptBlock(
                typeof(Timeline),
                "timelineapi", "\n<script type=\"text/javascript\" src=\""
                + Page.ClientScript.GetWebResourceUrl(resType, "TimelineNet.js.timeline.timelineSearchFilter.js")
                + "\" ></script>");
 
        }
 
        this.Page.ClientScript.RegisterClientScriptResource(resType, "TimelineNet.js.timeline.InitTimeline.js");
 
        isSafeToRender = true;
 
Best,
 
Joe Audette

comments