Jmol Developers

Exciting news. The Jmol/Protein Explorer implementation is coming along 
nicely. Take a look at http://chemapps.stolaf.edu/pe/protexpl and let me 
know what you think. This uses some very advanced techniques inside and 
outside of Jmol. So far I have all the basic stuff working, and I've 
seen at least simple "molSlide"s work just fine, including saving via 
the molslide server or just straight to disk.

Interestingly, the user need not save ANY other file -- because the 
MolSlide created uses the signed applet in 
http://chemapps.stolaf.edu/pe/protexpl/molview and that then loads the 
PDB file from Weizmann or the RCSB. It doesn't matter where the molSlide 
is put, provided there is an internet connection.

This isn't complete by any means, but I'm pretty pleased that it works, 
and works far more simply than what was being used for Chime.

Here's a quiz for you: What does this code do?


<html>
<head>
<script language="javascript" type="text/javascript" 
src="molview/Jmol.js"></script>
<script language="javascript" type="text/javascript">

var func,filename;

function getFileInfo() {
    var q=document.location.search.substring(1) + "&func=&filename=&";
    func = q.split("func=")[1].split("&")[0]
    filename = unescape(q.split("filename=")[1].split("&")[0])
    return (filename.length > 0)
}

function fileData(app,msg) {
 var data = "" + msg
 if (func.length > 0) {
    eval(func)(data);
    setTimeout("window.close()",1000);
    return;
 }
 document.write("<pre>\n" + data.replace(/\</g,"&lt;") + "</pre>")
 document.close()
}

</script>

</head>
<body>
<script language="javascript" type="text/javascript">
if (getFileInfo()) {
    document.write("loading data from " + filename+"<br />")
    jmolInitialize("./molview", "JmolAppletSigned.jar");
    jmolSetCallback("echoCallback","fileData")
    var script = 'echo @{getProperty("fileContents","'+filename+'")}'
    jmolApplet(10,script,"data");
}
</script>
</body>
</html>

---answer below:








































If you said, "hey, that reads and displays the HTML for any file on the 
web. You are correct. It allows reading of any file into the first 
parameter of a designated function. That function can then do anything 
you want it to do with the HTML.

In the case of the Protein Explorer implementation of Jmol I'm using, 
this allows, for example, for Protein Explorer to have a [view] button 
that displays the contents of a PDB file. This solves the problem that 
the signed Jmol applet can't read files off other servers using Jmol 
script commands originating in JavaScript, and JavaScript commands by 
themselves can't read HTML data into variables directly.

Try it at

<http://chemapps.stolaf.edu/pe/protexpl/getdata.htm?func=alert&filename=http://www.stolaf.edu/people/hansonr>

Interestingly, Firefox doesn't allow leaving the function out, but MSIE 
and Opera do:

<http://chemapps.stolaf.edu/pe/protexpl/getdata.htm?filename=http://www.stolaf.edu/people/hansonr>

(does not work in Firefox)


The code I'm proposing for Protein Explorer looks like this:


viewFileTitle = ""
function viewFile(filename,title) {
    viewFileTitle = title
    getFileContents(filename, "popupData")
}

function getFileContents(filename, funcname) {
    var sKey = "func=opener." + funcname + "&filename=" + escape(filename)
    window.open("getdata.htm?" + sKey);
}

function popupData(data) {
 var w = window.open("",viewFileTitle)
 w.document.open()
 w.document.write("<pre>\n" + data.replace(/\</g,"&lt;") + "</pre>")
 w.document.close()
}

Pretty simple! Works for me -- tested on Windows versions of MSIE and 
Firefox


Bob


-- 
Robert M. Hanson
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



-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Jmol-developers mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jmol-developers

Reply via email to