Hi Bob,
Your debugging email was very helpful, but I thought that I’d respond to this
thread as there are two issues from below that I want to address:
1. XHTML
2. Info.messageCallback
I’ve got things working so that I can move forward, but my current fixes seem
more like workarounds than solutions (see below).
Many thanks,
—Chuck
===================
1. XHTML
===================
from my code:
Jmol.setXHTML(model.ids.id_jsmol);
from your response:
there is no need for the XHTML business. Really that's there just because it
was in Jmol 11, and actually it was almost never used. XHTML was just too too
difficult all around. HTML5 is way better.
The HTML structure for my app looks like:
<div> app
<div> menubar </div>
<div>
<div> tabs </div>
<div\> jmol </div>
</div
</dib>
With no setXHTML Jmol puts the image over the top of the app <div> (i.e. the
menubar and the tabs are hidden).
With setXHTML Jmol puts the image in the jmol <div> (i.e. the menubar and the
tabs are visible).
I need whatever setXHTML is doing to put the Jmol image where I want it to go.
I’m not sure how to do that without calling setXHTML.
===================
2. Info.messageCallback
===================
The debugging technique of setting messageCallback to “alert” broke the ice for
me.
Info.messageCallback = “alert”; // worked
My problem was that Jmol couldn’t see my function name.
Info.messagerCallback = “myMessageCallback”; // didn’t work
There is a lot of namespace closure going on with my stuff and the stuff that
calls my stuff. I needed a function/variable that Jmol could see.
So, I created a window variable.
window.myvariable = myMessageCallback;
Info.messageCallback = “window.myvariable”; // worked - Yeah!
This explains why Jmol could see:
Info.readyFunction = myReadyFunction;
but could not see:
Info.messageCallback = “myMessageCallback”;
Jmol gets an address to myReadyFunction, but only the name of
myMessageCallback. So, Jmol can call readyFunction, but doesn’t have enough
information about where myMessageCallbac function is to find it and call it.
It would be nice if Jmol treated Info.messageCallback the same way that it
treats Info.readyFunction. Maybe there is already a way to do that, and I just
missed it.
There also must be a jQuery way to give Jmol the name of myMessageCallback, but
I haven’t yet asked Google the right question.
===================
On Feb 8, 2014, at 7:02 PM, Robert Hanson
<[email protected]<mailto:[email protected]>> wrote:
Great, so if that is all you are doing, there is no need for the XHTML
business. Really that's there just because it was in Jmol 11, and actually it
was almost never used. XHTML was just too too difficult all around. HTML5 is
way better.
So what you would do to populate a div in the jQuery way is simply this, as
used in supersimple.htm:
$(document).ready(function() {
Info = {
width: 400,
height: 400,
debug: false,
color: "0xC0C0C0",
disableJ2SLoadMonitor: true,
disableInitialConsole: true,
addSelectionOptions: true,
serverURL: "your server...../jsmol/php/jsmol.php",
use: "HTML5",
readyFunction: null,
script: "load $caffeine"
}
$("#mydiv").html(Jmol.getAppletHtml("jmolApplet0",Info))
});
That's it. It's really that simple. jQuery and JSmol take care of everything
else for you.
Info.serverURL will only be necessary if you are delivering binary files or if
you are allowing users to save images and states.
I think perhaps you were still using the old Jmol2.js, and unless you have
hundreds of pages that were extant back before JSmol arrived, you should get
rid of that dependency. Life will be easier.
... more in another more general thread...
Bob
On Sat, Feb 8, 2014 at 4:11 PM, Charles Harrison Shubert
<[email protected]<mailto:[email protected]>> wrote:
Thanks, Bob! I’ll download the latest build this weekend.
My app calls several initialization functions and init_jsmol is one of them. I
initialize my UI (view), the state of my app (controller and model), then I
initialize jsmol. I want to use the callbacks to populate the model. The
model.is.is<http://model.is.is/>_jsmol is the id of the div where I want Jmol
to render the image. It certainly seems reasonable in hindsight to look at an
example called images.htm. Wish I’d thought of that.
—Chuck
On Feb 8, 2014, at 1:40 PM, Robert Hanson
<[email protected]<mailto:[email protected]>> wrote:
Jmol.setXHTML = function(id)
is almost never used and hasn't been tested much. This is an HTML5 app, not
XHTML.
What is calling init_jsmol(state), and when?
With jQuery now, it's much easier. Check some of the examples in jsmol.zip.
http://chemapps.stolaf.edu/jmol/jsmol/images.htm
is a good example that uses jQuery for the applet construction and also uses
callbacks.
On Fri, Feb 7, 2014 at 1:38 PM, Charles Harrison Shubert
<[email protected]<mailto:[email protected]>> wrote:
Hi,
I'm clearly not reading the documentation correctly and I'm missing something.
I want to use the JSmol callback functionality. What am I doing wrong?
Thanks,
--Chuck
My javascript:
function init_jsmol(state) {
// … other initialization
Jmol.setXHTML(model.ids.id_jsmol);
var Info = {};
Info.script = session.modelControl.getActiveScript(state);
Info.j2sPath = model.jsmol.j2sPath;
Info.disableInitialConsole = true;
Info.disableJ2SLoadMonitor = true;
jmolObject = Jmol.getApplet(model.ids.id_jsmol, Info);
// … other initialization
}
function myMessageCallback(one, two) {
console.info<http://console.info/>("I'm in myMessageCallback: " + one);
console.info<http://console.info/>("I'm in myMessageCallback: " + two);
}
function getJSmolInfo(state) { // called from another part of my code.
try {
console.info<http://console.info/>("getJSmolInfo entry");
script(";set messageCallback 'myMessageCallback';");
script(";define chucksel '[ALA]1:A.O or [ALA]1:A.C'; select
chucksel; color atoms pink;");
script("message 'hi ho';");
console.info<http://console.info/>("getJSmolInfo exit");
return Jmol.getPropertyAsArray(jmolObject, "orientationInfo");
} catch (err) {
console.info<http://console.info/>("ERR getJSmolOrientationInfo
xxx");
console.info<http://console.info/>(err);
}
return null;
}
function script(script) {
try {
jmolObject._script(script);
} catch (err) {
console.info<http://console.info/>("ERR scriptWait");
console.info<http://console.info/>(err);
}
}
What I see: the Alanine that I loaded has the A.O and A.C colored pink. I
also see the "orientationInfo" when I look at the return from getJSmolInfo.
The "state" argument to getJSmolInfo is for later use.
What I didn't see: "hi ho" in the console or any evidence that
myMessageCallback is called.
Chrome Console:
getJSmolInfo entry
jsmolControl.js:89<http://localhost:8002/StarBiochem/sb_controller/jsmolControl.js>
getJSmolInfo exit
jsmolControl.js:93<http://localhost:8002/StarBiochem/sb_controller/jsmolControl.js>
exec _jsmol loadClazz null -- OK VM592:250
exec _jsmol start applet null -- OK VM592:250
event.returnValue is deprecated. Please use the standard event.preventDefault()
instead. VM592:110
------------------------------------------------------------------------------
Managing the Performance of Cloud-Based Applications
Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
Read the Whitepaper.
http://pubads.g.doubleclick.net/gampad/clk?id=121051231&iu=/4140/ostg.clktrk
_______________________________________________
Jmol-users mailing list
[email protected]<mailto:[email protected]>
https://lists.sourceforge.net/lists/listinfo/jmol-users
--
Robert M. Hanson
Larson-Anderson Professor of Chemistry
St. Olaf College
Northfield, MN
http://www.stolaf.edu/people/hansonr
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
------------------------------------------------------------------------------
Managing the Performance of Cloud-Based Applications
Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
Read the Whitepaper.
http://pubads.g.doubleclick.net/gampad/clk?id=121051231&iu=/4140/ostg.clktrk_______________________________________________
Jmol-users mailing list
[email protected]<mailto:[email protected]>
https://lists.sourceforge.net/lists/listinfo/jmol-users
------------------------------------------------------------------------------
Managing the Performance of Cloud-Based Applications
Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
Read the Whitepaper.
http://pubads.g.doubleclick.net/gampad/clk?id=121051231&iu=/4140/ostg.clktrk
_______________________________________________
Jmol-users mailing list
[email protected]<mailto:[email protected]>
https://lists.sourceforge.net/lists/listinfo/jmol-users
--
Robert M. Hanson
Larson-Anderson Professor of Chemistry
St. Olaf College
Northfield, MN
http://www.stolaf.edu/people/hansonr
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
------------------------------------------------------------------------------
Managing the Performance of Cloud-Based Applications
Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
Read the Whitepaper.
http://pubads.g.doubleclick.net/gampad/clk?id=121051231&iu=/4140/ostg.clktrk_______________________________________________
Jmol-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jmol-users
------------------------------------------------------------------------------
Managing the Performance of Cloud-Based Applications
Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
Read the Whitepaper.
http://pubads.g.doubleclick.net/gampad/clk?id=121051231&iu=/4140/ostg.clktrk
_______________________________________________
Jmol-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jmol-users