-
Notifications
You must be signed in to change notification settings - Fork 36
Expand file tree
/
Copy pathstatic-demo.html
More file actions
215 lines (180 loc) · 5.9 KB
/
Copy pathstatic-demo.html
File metadata and controls
215 lines (180 loc) · 5.9 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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
<title>PDBe Molstar</title>
<!-- Molstar CSS & JS -->
<link rel="stylesheet" type="text/css" href="build/pdbe-molstar-light.css">
<script type="text/javascript" src="build/pdbe-molstar-plugin.js"></script>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
padding: 30px;
}
h2 {
margin-bottom: 20px;
}
h3 {
margin-bottom: 2px;
}
h4 {
margin-top: 6px;
margin-bottom: 2px;
}
h4:first-child {
margin-top: 0px;
}
.content {
display: flex;
flex-direction: column;
gap: 30px;
}
.controlsSection {
width: 300px;
}
.controlBox {
border: 1px solid lightgray;
padding: 10px;
margin-bottom: 20px;
}
.molstar-frozen #myViewer {
position: relative;
inset: 0px;
width: 250px;
height: 250px;
}
#myViewer {
position: fixed;
inset: 20px;
}
#myViewerCover {
width: 250px;
height: 250px;
position: absolute;
z-index: 1;
/* background-color: rgba(255, 128, 128, .25); */
display: none;
}
.molstar-frozen #myViewerCover {
display: flex;
flex-direction: column;
justify-content: end;
align-items: center;
}
.button {
font-family: sans-serif;
cursor: pointer;
padding: 5px;
text-decoration: underline dotted;
}
#myViewerCloseButton {
position: fixed;
top: 8px;
right: 10px;
font-family: sans-serif;
font-weight: bold;
font-size: 150%;
width: 1em;
height: 1em;
text-align: center;
cursor: pointer;
}
.molstar-frozen #myViewerCloseButton {
display: none;
}
#viewButtons {
width: 250px;
padding: 10px;
align-content: center;
justify-content: center;
text-align: center;
font-family: sans-serif;
}
button {
margin-right: 8px;
margin-bottom: 8px;
padding: 1px;
padding-inline: 4px;
}
.molstar-frozen .msp-viewport-controls-buttons,
.molstar-frozen .msp-viewport-controls-panel,
.molstar-frozen .msp-viewport-top-left-controls {
display: none;
}
button:last-child {
margin-bottom: 0px;
}
</style>
</head>
<body>
<h2>PDBe Molstar</h2>
<div class="content">
<div id="viewerSection" class="molstar-frozen">
<h3>Static (image-like) plugin demo</h3>
<div id="myViewerCover">
<div id="openFullscreen" class="button" onclick="openFullscreen()">
Open 3D
</div>
</div>
<!-- Molstar container -->
<div id="myViewer"></div>
<div id="myViewerCloseButton" onclick="closeFullscreen()">X</div>
<div id="viewButtons">
View:
<span class="button" onclick="viewerInstance.visual.setViewDirection('front', { durationMs: 500 })">Front</span>
<span class="button" onclick="viewerInstance.visual.setViewDirection('right', { durationMs: 500 })">Right</span>
<span class="button" onclick="viewerInstance.visual.setViewDirection('top', { durationMs: 500 })">Top</span>
</div>
</div>
<div class="controlsSection">
<div>
<h3>Options</h3>
<div class="controlBox">
<pre id="options"></pre>
</div>
</div>
</div>
</div>
<script>
function getJsonParam(paramName) {
const paramString = new URL(window.location).searchParams.get(paramName);
const param = JSON.parse(paramString);
return param ?? undefined;
}
function openFullscreen() {
document.getElementById('viewerSection')?.classList.remove('molstar-frozen');
}
function closeFullscreen() {
document.getElementById('viewerSection')?.classList.add('molstar-frozen');
viewerInstance.visual.setViewDirection('front', { durationMs: 0 });
}
// Create plugin instance
const viewerInstance = new PDBeMolstarPlugin();
// Set default options (Checkout available options list in the documentation)
const defaultOptions = {
customData: {
// url: 'http://127.0.0.1:1338/tmp/2e2n_updated.cif',
url: 'https://alphafold.ebi.ac.uk/files/AF-O15552-F1-model_v6.bcif',
format: 'cif',
binary: true,
},
alphafoldView: true,
bgColor: 'white',
hideControls: true,
hideCanvasControls: ['expand', 'controlToggle'],
};
const options = { ...defaultOptions, ...getJsonParam('options') };
const optionsDiv = document.getElementById('options');
optionsDiv.innerHTML = JSON.stringify(options, undefined, 2).replace(/"(\w+)":/g, '$1:');
// Get element from HTML/Template to place the viewer
const viewerContainer = document.getElementById('myViewer');
// Call render method to display the 3D view
viewerInstance.render(viewerContainer, options);
</script>
</body>
</html>