70 lines
2.2 KiB
HTML
70 lines
2.2 KiB
HTML
<html>
|
|
<head>
|
|
<meta http-equiv="Pragma" content="no-cache"/>
|
|
<meta http-equiv="Cache-Control" content="no-cache"/>
|
|
<meta http-equiv="Expires" content="-1" />
|
|
<title>Web Services - Sample 02: Using a IFRAME with JavaScript </title>
|
|
|
|
<style><!--
|
|
a{text-decoration:none;
|
|
padding: 1px;
|
|
background-color: #dddddd}
|
|
--></style>
|
|
<script type="text/javascript">
|
|
|
|
// convenience function for issuing PyMOL methods (one per javascript event);
|
|
|
|
function cmd(suffix) {
|
|
document.getElementById("pymol_response_iframe").src =
|
|
"/apply/pymol.cmd." + suffix +
|
|
( suffix.indexOf('?') < 0 ? '?' : '&') +
|
|
"_ts=" + new Date().getTime(); // cache avoidance
|
|
}
|
|
|
|
// for toggling visibility of the IFRAME
|
|
|
|
function toggle() {
|
|
var iframe = document.getElementById("pymol_response_iframe");
|
|
if (iframe.width!=0) {
|
|
iframe.width=0; iframe.height=0; iframe.frameBorder=0;
|
|
} else {
|
|
iframe.width="100%"; iframe.height=100; iframe.frameBorder=1;
|
|
}
|
|
}
|
|
</script>
|
|
</head>
|
|
<body>
|
|
<h3>Web Services - Sample 02: Using an IFRAME with JavaScript</h3>
|
|
|
|
<a href="javascript:void(0)" onclick="toggle()">toggle iframe</a>
|
|
|
|
<a href="/apply/_quit">quit pymol</a>
|
|
|
|
(FireFox only: <a href="javascript:void(0)" onclick="window.open('view-source:' + location.href)">view page source</a>)
|
|
|
|
<p>Here we use a JavaScript function:
|
|
<pre>function cmd(suffix) {
|
|
document.getElementById("pymol_response_iframe").src =
|
|
"/apply/pymol.cmd." + suffix +
|
|
( suffix.indexOf('?') < 0 ? '?' : '&') +
|
|
"_ts=" + new Date().getTime(); // cache avoidance
|
|
}
|
|
</pre>
|
|
to convert our query suffix into a unique URL and the populate the IFRAME src field, thereby generating a pymol method request. PyMOL's response ends up in the IFRAME. </p>
|
|
|
|
<pre>
|
|
load: <a href="javascript:void(0)" onclick="cmd('load?filename=$PYMOL_PATH/test/dat/1tii.pdb')">cmd('load?filename=$PYMOL_PATH/test/dat/1tii.pdb')</a>
|
|
|
|
count_atoms: <a href="javascript:void(0)" onclick="cmd('count_atoms')">cmd('count_atoms')</a>
|
|
|
|
reinitialize: <a href="javascript:void(0)" onclick="cmd('reinitialize')">cmd('reinitialize')</a>
|
|
</pre>
|
|
|
|
<pre></pre>
|
|
<iframe id="pymol_response_iframe"
|
|
src="/apply"
|
|
width="100%" height="100" frameborder="1"
|
|
scrolling="auto"></iframe>
|
|
</body>
|
|
</html>
|