Re: [Jmol-users] ff3 vs safari.. again.. load

2008-10-05 Thread Robert Hanson
Angel has it exactly. Just to be clear, for ANY browser:

1) Never use jmolScript() during page loading. The applet won't be there.
2) Never run a Jmol script from the body onload event. On most browsers the
applet won't be loaded yet.
3) If possible, put whatever start-up script you want to use in the
jmolApplet() call itself.
4) If that is not possible for some reason, you have to set up the applet
with a callback and have the script in the jmolApplet() notify JavaScript
that it is working or done. That's generally unnecessary, though.

Bob



-- 
Robert M. Hanson
Professor of Chemistry
St. Olaf College
1520 St. Olaf Ave.
Northfield, MN 55057
http://www.stolaf.edu/people/hansonr
phone: 507-786-3107


If nature does not answer first what we want,
it is better to take what answer we get.

-- Josiah Willard Gibbs, Lecture XXX, Monday, February 5, 1900
-
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/___
Jmol-users mailing list
Jmol-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jmol-users


Re: [Jmol-users] ff3 vs safari.. again.. load

2008-10-04 Thread Angel Herráez
On 25 Sep 2008 at 11:09, rob yang wrote:
> That works, although I needed to sleep for 500 instead of 100. the 
> loadLigands() function is fired 
> up by . I am wondering if it's a case of safari 
> browser does 
> something different in executing the  functions. It almost 
> seems to me like 
> loadLigands() was executed before the applet finished initializing. 

My experience is that yes, often the page finishes loading before the applet 
fully loads, so 
that sounds likely to me as the cause of the problem. And that's in Windows 
(mainly Firefox, 
but probably IE too) while I don't know much about threading and am certainly 
doing nothing 
about it on purpose

The safe way is not to do the script upon page load, but to include it the 
jmolApplet() call 
itself. That way, the processes are consecutive. (Not sure it this solution is 
applicable to 
your setup, see below.)

> does not help. Who knows what's going on with all that threading business. 
> But in any case, 
> sleeping is a quick fix to it. Thanks.

The problem there is that the needed amount of sleeping time may depend on the 
connection: not the same in local disk and local server tests than for a user 
getting the page 
and the applet across the ocean.


It could be like this:

  
        
      jmolInitialize("/submit/jmol-11.6.RC15/", "JmolAppletSigned.jar");
      jmolSetCallback("messageCallback","messageCallback");
      jmolApplet([600, 450],  'load 
"file:///Library/WebServer/Documents/toy/vs_analysis/result0.mol2"; select all; 
spacefill 
20%; wireframe 0.35; ' );
        


or, if you need to keep it dynamic by using the function:
  
        
      jmolInitialize("/submit/jmol-11.6.RC15/", "JmolAppletSigned.jar");
      jmolSetCallback("messageCallback","messageCallback");
      jmolApplet([600, 450],  
loadLigands('file:///Library/WebServer/Documents/toy/vs_analysis/result0.mol2') 
);
        

with
  function loadLigands(structure) {
    var load_script = "load " + structure + ";select all; spacefill 20%; 
wireframe 0.35;";
    return load_script;
  }

-
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
___
Jmol-users mailing list
Jmol-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jmol-users


Re: [Jmol-users] ff3 vs safari.. again.. load

2008-10-04 Thread rob yang

Okay, so it's a safari issue. Onload timing is messed up that doesn't wait for 
the page to actually finishing loading. 
http://ajaxian.com/archives/safari-3-onload-firing-and-bad-timing

Heh, who'd thunk that geeksquad's darling browser runs too fast for even itself?

Date: Thu, 25 Sep 2008 10:52:35 -0500
From: [EMAIL PROTECTED]
To: jmol-users@lists.sourceforge.net
Subject: Re: [Jmol-users] ff3 vs safari.. again.. load

no kidding! What's firing the loadLigands() function? A button? A callback 
(that could be the problem -- not good to run jmolScript from a callback on 
some platforms, I think).

Try using

setTimeout("loadLigands('')",100)


in whatever call is doing that. I know the quotes are pain there. You might 
implement it this way:

  function loadLigands(structure, trigger) {
if (!trigger) {
   setTimeout("loadLigands('"+structure+"',1)",100)

   return
}
var load_script = "load " + structure + ";select all; spacefill 20%; 
wireframe 0.35;";
jmolScript(load_script);
  }

This starts a new thread so that the thread involved in the user clicking can 
complete, and the load can go by a different thread.


But really, that's very odd.

Bob


On Thu, Sep 25, 2008 at 10:32 AM, rob yang <[EMAIL PROTECTED]> wrote:






Hi all,
So here's something new that's confusing me. I am loading a multi-structure 
mol2 file. That's as simple as it gets, right? That's what I thought too till 
safari spoke. In Firefox3, the molecule loads no problem. In safari, it 
doesn't.. *unless* I put in an alert message right before the load command. 
Below is the barebone of my code. It seems like something is out of sync in 
safari that I need to slow it down (alert message) for the script to catch up. 
Help. Thanks.


-Rob



  


  function loadLigands(structure) {

  var load_script = "load " + structure + ";select all; spacefill 20%; 
wireframe 0.35;";

 //alert(load_script); // --UNCOMMENT THIS ALERT MESSAGE TO GET IT 
TO WORK IN SAFARI-

  
jmolScript(load_script);
  }
  function messageCallback(app, msg) {
msg = "" + msg+"";/* convert callback message into string (recommended 
by other Jmol users) */

  if (msg.match(/ScriptException/)) {alert("=== Jmol SCRIPT ERROR ===\n" + 
msg);}
  else if (msg.match(/java\.security\.AccessControlException/)) {alert("=== 
Java Error ===\nA Java error prevented loading of the structure");}

  else if (msg.indexOf("ERROR")>=0 && msg.indexOf("load >>") >= 0) 
{alert(msg);}
  }






  
  

  jmolInitialize("/submit/jmol-11.6.RC15/", "JmolAppletSigned.jar");
  jmolSetCallback("messageCallback","messageCallback");

  jmolApplet([600, 450]);









Get your information fix on your phone. With MSN Mobile you get regular news, 
sports and  finance updates. Try it today!


-

This SF.Net email is sponsored by the Moblin Your Move Developer's challenge

Build the coolest Linux based applications with Moblin SDK & win great prizes

Grand prize is a trip for two to an Open Source event anywhere in the world

http://moblin-contest.org/redirect.php?banner_id=100&url=/
___

Jmol-users mailing list

Jmol-users@lists.sourceforge.net

https://lists.sourceforge.net/lists/listinfo/jmol-users




-- 
Robert M. Hanson
Professor of Chemistry
St. Olaf College
1520 St. Olaf Ave.
Northfield, MN 55057
http://www.stolaf.edu/people/hansonr

phone: 507-786-3107


If nature does not answer first what we want,
it is better to take what answer we get. 

-- Josiah Willard Gibbs, Lecture XXX, Monday, February 5, 1900



_

-
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/___
Jmol-users mailing list
Jmol-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jmol-users


Re: [Jmol-users] ff3 vs safari.. again.. load

2008-10-04 Thread rob yang

Bob,
That works, although I needed to sleep for 500 instead of 100. the 
loadLigands() function is fired up by . I am 
wondering if it's a case of safari browser does something different in 
executing the  functions. It almost seems to me like 
loadLigands() was executed before the applet finished initializing. Commenting 
out callbacks does not help. Who knows what's going on with all that threading 
business. But in any case, sleeping is a quick fix to it. Thanks.

-Rob

Date: Thu, 25 Sep 2008 10:52:35 -0500
From: [EMAIL PROTECTED]
To: jmol-users@lists.sourceforge.net
Subject: Re: [Jmol-users] ff3 vs safari.. again.. load

no kidding! What's firing the loadLigands() function? A button? A callback 
(that could be the problem -- not good to run jmolScript from a callback on 
some platforms, I think).

Try using

setTimeout("loadLigands('')",100)


in whatever call is doing that. I know the quotes are pain there. You might 
implement it this way:

  function loadLigands(structure, trigger) {
if (!trigger) {
   setTimeout("loadLigands('"+structure+"',1)",100)

   return
}
var load_script = "load " + structure + ";select all; spacefill 20%; 
wireframe 0.35;";
jmolScript(load_script);
  }

This starts a new thread so that the thread involved in the user clicking can 
complete, and the load can go by a different thread.


But really, that's very odd.

Bob


On Thu, Sep 25, 2008 at 10:32 AM, rob yang <[EMAIL PROTECTED]> wrote:






Hi all,
So here's something new that's confusing me. I am loading a multi-structure 
mol2 file. That's as simple as it gets, right? That's what I thought too till 
safari spoke. In Firefox3, the molecule loads no problem. In safari, it 
doesn't.. *unless* I put in an alert message right before the load command. 
Below is the barebone of my code. It seems like something is out of sync in 
safari that I need to slow it down (alert message) for the script to catch up. 
Help. Thanks.


-Rob



  


  function loadLigands(structure) {

  var load_script = "load " + structure + ";select all; spacefill 20%; 
wireframe 0.35;";

 //alert(load_script); // --UNCOMMENT THIS ALERT MESSAGE TO GET IT 
TO WORK IN SAFARI-

  
jmolScript(load_script);
  }
  function messageCallback(app, msg) {
msg = "" + msg+"";/* convert callback message into string (recommended 
by other Jmol users) */

  if (msg.match(/ScriptException/)) {alert("=== Jmol SCRIPT ERROR ===\n" + 
msg);}
  else if (msg.match(/java\.security\.AccessControlException/)) {alert("=== 
Java Error ===\nA Java error prevented loading of the structure");}

  else if (msg.indexOf("ERROR")>=0 && msg.indexOf("load >>") >= 0) 
{alert(msg);}
  }






  
  

  jmolInitialize("/submit/jmol-11.6.RC15/", "JmolAppletSigned.jar");
  jmolSetCallback("messageCallback","messageCallback");

  jmolApplet([600, 450]);









Get your information fix on your phone. With MSN Mobile you get regular news, 
sports and  finance updates. Try it today!


-

This SF.Net email is sponsored by the Moblin Your Move Developer's challenge

Build the coolest Linux based applications with Moblin SDK & win great prizes

Grand prize is a trip for two to an Open Source event anywhere in the world

http://moblin-contest.org/redirect.php?banner_id=100&url=/
___

Jmol-users mailing list

Jmol-users@lists.sourceforge.net

https://lists.sourceforge.net/lists/listinfo/jmol-users




-- 
Robert M. Hanson
Professor of Chemistry
St. Olaf College
1520 St. Olaf Ave.
Northfield, MN 55057
http://www.stolaf.edu/people/hansonr

phone: 507-786-3107


If nature does not answer first what we want,
it is better to take what answer we get. 

-- Josiah Willard Gibbs, Lecture XXX, Monday, February 5, 1900



_

-
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/___
Jmol-users mailing list
Jmol-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jmol-users


Re: [Jmol-users] ff3 vs safari.. again.. load

2008-09-25 Thread Robert Hanson
no kidding! What's firing the loadLigands() function? A button? A callback
(that could be the problem -- not good to run jmolScript from a callback on
some platforms, I think).

Try using

setTimeout("loadLigands('')",100)

in whatever call is doing that. I know the quotes are pain there. You might
implement it this way:

  function loadLigands(structure, trigger) {
if (!trigger) {
   setTimeout("loadLigands('"+structure+"',1)",100)
   return
}
var load_script = "load " + structure + ";select all; spacefill 20%;
wireframe 0.35;";
jmolScript(load_script);
  }

This starts a new thread so that the thread involved in the user clicking
can complete, and the load can go by a different thread.

But really, that's very odd.

Bob


On Thu, Sep 25, 2008 at 10:32 AM, rob yang <[EMAIL PROTECTED]> wrote:

>  Hi all,
> So here's something new that's confusing me. I am loading a multi-structure
> mol2 file. That's as simple as it gets, right? That's what I thought too
> till safari spoke. In Firefox3, the molecule loads no problem. In safari, it
> doesn't.. *unless* I put in an alert message right before the load command.
> Below is the barebone of my code. It seems like something is out of sync in
> safari that I need to slow it down (alert message) for the script to catch
> up. Help. Thanks.
>
> -Rob
>
> 
> 
>   
> 
> 
>   function loadLigands(structure) {
>   var load_script = "load " + structure + ";select all; spacefill
> 20%; wireframe 0.35;";
>
>  //alert(load_script); // --UNCOMMENT THIS ALERT MESSAGE TO GET
> IT TO WORK IN SAFARI-
>
> jmolScript(load_script);
>   }
>   function messageCallback(app, msg) {
> msg = "" + msg+"";/* convert callback message into string
> (recommended by other Jmol users) */
>   if (msg.match(/ScriptException/)) {alert("=== Jmol SCRIPT ERROR
> ===\n" + msg);}
>   else if (msg.match(/java\.security\.AccessControlException/))
> {alert("=== Java Error ===\nA Java error prevented loading of the
> structure");}
>   else if (msg.indexOf("ERROR")>=0 && msg.indexOf("load >>") >= 0)
> {alert(msg);}
>   }
> 
>
> 
> 
>  onload="loadLigands('file:///Library/WebServer/Documents/toy/vs_analysis/result0.mol2');">
>
>
> 
>   jmolInitialize("/submit/jmol-11.6.RC15/",
> "JmolAppletSigned.jar");
>   jmolSetCallback("messageCallback","messageCallback");
>   jmolApplet([600, 450]);
> 
> 
>
> 
>
>
>
>
>
> --
> Get your information fix on your phone. With MSN Mobile you get regular
> news, sports and  finance updates. Try it today! 
>
> -
> This SF.Net email is sponsored by the Moblin Your Move Developer's
> challenge
> Build the coolest Linux based applications with Moblin SDK & win great
> prizes
> Grand prize is a trip for two to an Open Source event anywhere in the world
> http://moblin-contest.org/redirect.php?banner_id=100&url=/
> ___
> Jmol-users mailing list
> Jmol-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/jmol-users
>
>


-- 
Robert M. Hanson
Professor of Chemistry
St. Olaf College
1520 St. Olaf Ave.
Northfield, MN 55057
http://www.stolaf.edu/people/hansonr
phone: 507-786-3107


If nature does not answer first what we want,
it is better to take what answer we get.

-- Josiah Willard Gibbs, Lecture XXX, Monday, February 5, 1900
-
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/___
Jmol-users mailing list
Jmol-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jmol-users