-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathwith-molstar-demo.html
More file actions
128 lines (105 loc) · 3.86 KB
/
Copy pathwith-molstar-demo.html
File metadata and controls
128 lines (105 loc) · 3.86 KB
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
<!DOCTYPE html>
<html>
<head>
<style>
.vis-container {
display: flex;
}
#pdb-rna-viewer {
width: 500px;
height: 500px;
}
#pdb-molstar {
width: 400px;
height: 300px;
position: relative;
margin: 20px;
}
#mainMenu {
width: 502px;
}
.controls {
display: flex;
width: 500px;
margin: 10px 0;
}
button {
margin-right: 10px;
padding: 6px 12px;
cursor: pointer;
}
</style>
<!-- PDB RNA Viewer CSS -->
<link rel="stylesheet" type="text/css" href="build/pdb-rna-viewer-0.3.0.css">
<!-- CSS -->
<link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/pdbe-molstar@latest/build/pdbe-molstar.css" />
</head>
<body>
<h4>PDB RNA Viewer with Molstar Plugin Demo</h4>
<div class="vis-container">
<!-- PDB RNA Viewer container -->
<div id="pdb-rna-viewer"></div>
<!-- PDB Molstar container -->
<div id="pdb-molstar"></div>
</div>
<!-- Test controls -->
<div class="controls">
<button id="simulateClick1">Simulate protvista-click (1–5)</button>
<button id="simulateClick">Simulate protvista-click (1–30)</button>
<button id="simulateHover">Simulate protvista-mouseover (1–30)</button>
<button id="simulateHoverOut">Simulate protvista-mouseout</button>
</div>
<!-- PDB RNA Viewer JS -->
<script type="text/javascript" src="build/pdb-rna-viewer-plugin-0.3.0.js"></script>
<!-- PDB Molstar Viewer JS -->
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/pdbe-molstar@latest/build/pdbe-molstar-plugin.js"></script>
<script>
//Create plugin instance
const pluginInstance = new PdbRnaViewerPlugin();
//Get element from HTML/Template to place the view
const viewContainer = document.getElementById('pdb-rna-viewer');
const options = {
pdbId: '1y26',
entityId: '1',
chainId: 'X',
subscribeEvents: true
}
//Call render method to display the 2D view
pluginInstance.render(viewContainer, options);
// Create plugin instance for Molstar
const molstarViewerInstance = new PDBeMolstarPlugin();
// Set options (All the available options are listed below in the documentation)
const molstarOptions = {
moleculeId: '1y26',
subscribeEvents: true
};
// Get element from HTML/Template to place the viewer
const viewerContainer = document.getElementById('pdb-molstar');
// Call render method to display the 3D view
molstarViewerInstance.render(viewerContainer, molstarOptions);
// --- Test buttons ---
document.getElementById("simulateClick1").addEventListener("click", () => {
const event = new CustomEvent('protvista-click', {
detail: { start: 1, end: 5 }
});
document.dispatchEvent(event);
});
document.getElementById("simulateClick").addEventListener("click", () => {
const event = new CustomEvent('protvista-click', {
detail: { start: 1, end: 30 }
});
document.dispatchEvent(event);
});
document.getElementById("simulateHover").addEventListener("click", () => {
const event = new CustomEvent('protvista-mouseover', {
detail: { start: 1, end: 30 }
});
document.dispatchEvent(event);
});
document.getElementById("simulateHoverOut").addEventListener("click", () => {
const event = new CustomEvent('protvista-mouseout', {} );
document.dispatchEvent(event);
});
</script>
</body>
</html>