File: index.html

package info (click to toggle)
pymol 2.4.0%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 43,312 kB
  • sloc: cpp: 480,106; python: 79,860; ansic: 28,343; javascript: 6,792; sh: 47; makefile: 30; csh: 8
file content (69 lines) | stat: -rw-r--r-- 2,252 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<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>