callback function not working?

426 views
Skip to first unread message

PKIDNA

unread,
Jan 14, 2015, 1:27:48 PM1/14/15
to igv-...@googlegroups.com
using Version 2.3.40 (48)

for local side interactions, this used to work....

"http://localhost:60151/goto?locus=" + locusString + "&callback=callBack();";

where the callback handler was used to prevent loading of a new IGV session

function callBack() {
    clearTimeout(timeoutVar);
}

However, recently it seems that while the current session relocates fine, a new session it loaded again showing that the callback is never activated

Has there been a recent change that may have disrupted this functionality?  Maybe a change in syntax?

thanks


Jim Robinson

unread,
Jan 14, 2015, 5:57:02 PM1/14/15
to igv-...@googlegroups.com
Hi,

I'm not understanding what you mean by "new session".   Could you elaborate?  This should never load a new session, callback or not
So what exactly is happening?

Jim

--

---
You received this message because you are subscribed to the Google Groups "igv-help" group.
To unsubscribe from this group and stop receiving emails from it, send an email to igv-help+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/igv-help/f8cd1f1c-d1eb-4385-a473-41befb0579d0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

PKIDNA

unread,
Jan 14, 2015, 10:49:38 PM1/14/15
to igv-...@googlegroups.com
The callback is used to terminate the javascript timeoutHandler that is used to initiate the download of the jnlp  if no response locally.  What happens then is while the local instance responds, a new download is initiated launching another session, thus you end up with another instance of IGV running.  This used to work fine, but recently it does not with Firefox.  Something has changed recently and I am not sure what.  This was derived from example code

function timeoutHandler(locusStr) {
    // created in PERL code above
    var webstart_url = '/pwa/igv.php?locus=&sessionURL=${urlbase}/xtmp/${userRoot}/${OUT}';
    // determine if webstart is available - code taken from sun site
    var userAgent = navigator.userAgent.toLowerCase();
    // user is running windows
    if (userAgent.indexOf("msie") != -1 && userAgent.indexOf("win") != -1) {
        document.write("<OBJECT " +
            "codeBase=http://java.sun.com/update/1.5.0/jinstall-1_5_0_05-windows-i586.cab " +
            "classid=clsid:5852F5ED-8BF4-11D4-A245-0080C6F74284 height=0 width=0>");
        document.write("<PARAM name=app VALUE=" + webstart_url + ">");
        document.write("<PARAM NAME=back VALUE=true>");
        // alternate html for browsers which cannot instantiate the object
        document.write("<A href='http://java.sun.com/j2se/1.5.0/download.html'>Download Java WebStart</A>");
        document.write("</OBJECT>");
    }
    // user is not running windows
    else if (webstartVersionCheck("1.6")) {
        window.location = webstart_url;
    }
    // user does not have jre installed or lacks appropriate version - direct them to sun download site
    else {
        window.open("http://jdl.sun.com/webapps/getjava/BrowserRedirect?locale=en&host=java.com",
            "needdownload");
    }

function callBack() {
    clearTimeout(timeoutVar);
}

function appRequest(locusString) {
    // be good and remove the previous script element
    // although, based on debugging, im not sure this really does anything
    var oldScript = document.getElementById(SCRIPT_ELEMENT_ID);
    if (oldScript) { oldScript.parentNode.removeChild(oldScript); }
    // alert('Relocate to ' + locusString);
    var localURLrelo = "http://localhost:60151/goto?locus=" + locusString + "&callback=callBack();";
     // create new script
    var newScript = document.createElement("script");
    newScript.id = SCRIPT_ELEMENT_ID;
    newScript.setAttribute("type", "text/javascript");
    newScript.setAttribute("src", localURLrelo);
    // add new script to document (head section)
    var head = document.getElementsByTagName("head")[0];
    head.appendChild(newScript);
    // disable link
    // we do this because some browsers
    // will not fetch data if the url has been fetched in the past
    //disableLink("1");
    // set timeout - handler for when IGV is not running
    timeoutVar = setTimeout("timeoutHandler('" + locusString +"')", 3000);
}

Maybe there is a different mechanism for detecting a locally running copy that is more accurate?  As it stands, every update to the local instance ends up initiating a jnlp download…the code is from a bit back.



edward

Jim Robinson

unread,
Jan 14, 2015, 10:53:12 PM1/14/15
to igv-...@googlegroups.com
OK, thanks for clarifying.  I just tested the example code and its still working for me on Chrome and Firefox (Mac Mountain Lion).  Nothing has changed on our end.  Are you accessing the page with the javascript via https?  This can complicate things.

Jim

Jim Robinson

unread,
Jan 14, 2015, 10:55:47 PM1/14/15
to igv-...@googlegroups.com
Also,  I see you derived this from old example code, you might pull again and study the updated webstart.js file and associated "DynamicLinkExamples.html" in the web folder.

PKIDNA

unread,
Jan 14, 2015, 10:59:48 PM1/14/15
to igv-...@googlegroups.com
Yes, this is over HTTPS (which requires you to disable mixed mode blocking on Firefox using the settings in about:config), but I am having the same problem internally with straight up HTTP, so not the HTTPS per se.  I will look at the updated examples.

Jim Robinson

unread,
Jan 14, 2015, 11:02:03 PM1/14/15
to igv-...@googlegroups.com
The updated code handles https,  its a hack but not everyone can or want to disable mixed mode.  In fact on my Mac that is not even an option.   The updated webstart.js "handles" it by opening a new page with http protocol that makes the actual request to IGV.

See if you can successfully use the links in DynamicLinksExample.html
Yes, this is over HTTPS (which requires you to disable mixed mode blocking on Firefox using the settings in about:config), but I am having the same problem internally with straight up HTTP, so not the HTTPS per se.  I will look at the updated examples.
--

---
You received this message because you are subscribed to the Google Groups "igv-help" group.
To unsubscribe from this group and stop receiving emails from it, send an email to igv-help+u...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages