forked from wwwtyro/speck
/
index.html
332 lines (296 loc) · 14.6 KB
/
index.html
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
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="description" content="WebGL-powered 3D atomic structure renderer">
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0">
<title>Speck - Max Davy</title>
<meta charset="UTF-8">
<link rel="shortcut icon" href="static/favicon.png">
<script src="static/bundle.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<link rel="stylesheet" type="text/css" href="static/index.css">
<link rel="stylesheet" href="/styles/material.css" />
<link rel="stylesheet" href="/styles.css">
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
<link rel="stylesheet" href="./styles.css">
<script>
function hideSecureErrors() {
if (document.getElementById("error-text").innerText.includes("5209")) {
document.getElementById("error").style.display = "none";
}
}
function loadXYZ() {
if ($('#idinputbox').val() != "") {
$('#xyz-data').load('https://cactus.nci.nih.gov/chemical/structure/' + $('#idinputbox').val().replace(' ', '%20') + '/file?format=xyz', function() {
/* When load is done */
if ($('#xyz-data').val() != "") {
document.getElementById("xyz-button").click();
}
});
}
$.getJSON("https://en.wikipedia.org/w/api.php?action=parse&page=" + encodeURIComponent($('#idinputbox').val()) + "&prop=text§ion=0&format=json&callback=?", function(data) {
var text = data.parse.text["*"].split("<p>");
var pText = "No compound selected";
for (i in text) {
paragraph = text[i]
if (!paragraph.includes("wikimedia")) {
pText = paragraph;
break;
}
}
pText = pText.replace(/<(?:.|\n)*?>/gm, ''); //Remove html tags
pText = pText.replace(/[\d+]/g, ""); //Remove reference tags (e.x. [1], [4], etc)
document.getElementById('div_text').innerHTML = pText;
document.getElementById("wikipedialink").href = "https://www.wikiwand.com/en/" + encodeURIComponent($('#idinputbox').val());
});
}
$(document).ready(function() {
hideSecureErrors();
$('#submitname').click(function() {
loadXYZ();
});
$('#idinputbox').on('keydown', function(e) {
if (e.which == 13) {
loadXYZ();
return false;
}
});
setInterval(hideSecureErrors, 1000);
});
window.addEventListener("load", function() {
document.getElementById("loading-page").style.display = "none";
});
</script>
</head>
<body class="spectrum-background dark-background">
<header class="portfolio-header mdl-layout__header mdl-layout__header--scroll mdl-color-text--grey-800 glass-element" style="color: white !important;">
<a role="button" tabindex="0" class="mdl-layout__drawer-button" href="https://max-davy.github.io"><i class="material-icons" style="margin-top: 10px;">home</i></a>
<div class="mdl-layout__header-row">
<span class="mdl-layout__title">Speck</span>
</div>
</header>
<div id="loading-page" style="position: absolute; background-color: #37474f; width: 100%;height: 100%;z-index:1">
<div class="loader"></div>
</div>
<div id="render-container">
<canvas id="renderer-canvas"></canvas>
</div>
<div id="controls-menu">
<button id="menu-button-structure">Structure</button>
<button id="menu-button-render">Render</button>
<button id="menu-button-share">Share</button>
<button id="menu-button-help">Help</button>
<button id="menu-button-about">About</button>
</div>
<div id="controls-container">
<div id="controls-structure">
<h2 style="margin-top:auto">Samples</h2>
<select id="controls-sample"></select>
<h2>Search</h2>
<input type="text" id="idinputbox" placeholder="Structure Identifier">
<button id="submitname">Search</button><br> xyz file data from <a href="https://cactus.nci.nih.gov/" target="_blank">cactus.nci.nih.gov</a>
<h2>Custom</h2>
xyz file data:<br>
<textarea id="xyz-data" rows="4" columns="10"></textarea><br><br>
<button id="xyz-button">Load</button>
<h2>About Structure:</h2>
<p id="div_text">No compound selected</p>
Info from <a id="wikipedialink" href="https://www.wikiwand.com/en/Wikipedia" target="_blank">Wikipedia</a>
</div>
<div id="controls-render">
<table>
<tr>
<td align="right">Preset</td>
<td>
<select id="view-preset">
<option value="default">Default</option>
<option value="stickball">Ball & Stick</option>
<option value="toon">Toon</option>
<option value="licorice">Licorice</option>
</select>
</td>
</tr>
<tr>
<td colspan="10">
<hr>
</td>
</tr>
<tr>
<td align="right">Atom radius</td>
<td><input id="atom-radius" type="range" min="1" max="100" value="50" class="control-width"></td>
<td id="atom-radius-text"></td>
<td class="control-help">a + scrollwheel</td>
</tr>
<tr>
<td align="right">Relative atom radius</td>
<td><input id="relative-atom-radius" type="range" min="0" max="100" value="100" class="control-width"></td>
<td id="relative-atom-radius-text"></td>
<td class="control-help">z + scrollwheel</td>
</tr>
<tr>
<td align="right">Atom shade</td>
<td><input id="atom-shade" type="range" min="0" max="100" value="0" class="control-width"></td>
<td id="atom-shade-text"></td>
<td class="control-help">w + scrollwheel</td>
</tr>
<tr>
<td colspan="10">
<hr>
</td>
</tr>
<tr>
<td align="right">Bonds</td>
<td><input type="checkbox" id="bonds"></td>
</tr>
<tr>
<td align="right">Bond radius</td>
<td><input id="bond-radius" type="range" min="0" max="100" value="50" class="control-width"></td>
<td id="bond-radius-text"></td>
<td class="control-help">b + scrollwheel</td>
</tr>
<tr>
<td align="right">Bond threshold</td>
<td><input type="number" step="0.1" min="0.0" max="2.5" id="bond-threshold" value="1.2" class="control-width"></td>
</tr>
<tr>
<td align="right">Bond shade</td>
<td><input id="bond-shade" type="range" min="0" max="100" value="0" class="control-width"></td>
<td id="bond-shade-text"></td>
<td class="control-help">s + scrollwheel</td>
</tr>
<tr>
<td colspan="10">
<hr>
</td>
</tr>
<tr>
<td align="right">Ambient occlusion</td>
<td><input id="ambient-occlusion" type="range" min="0" max="100" value="50" class="control-width"></td>
<td id="ambient-occlusion-text"></td>
<td class="control-help">o + scrollwheel</td>
</tr>
<tr>
<td align="right">Brightness</td>
<td><input id="brightness" type="range" min="0" max="100" value="50" class="control-width"></td>
<td id="brightness-text"></td>
<td class="control-help">l + scrollwheel</td>
</tr>
<tr>
<td align="right">AO Resolution</td>
<td>
<select id="ao-resolution">
<option value="16">16x16</option>
<option value="32">32x32</option>
<option value="64">64x64</option>
<option value="128">128x128</option>
<option value="256">256x256</option>
<option value="512">512x512</option>
<option value="1024">1024x1024</option>
<option value="2048">2048x2048</option>
</select>
</td>
</tr>
<tr>
<td align="right">Samples per frame</td>
<td>
<select id="samples-per-frame">
<option value="0">0</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="4">4</option>
<option value="8">8</option>
<option value="16">16</option>
<option value="32">32</option>
<option value="64">64</option>
<option value="128">128</option>
<option value="256">256</option>
</select>
</td>
</tr>
<tr>
<td colspan="10">
<hr>
</td>
</tr>
<tr>
<td align="right">Depth of field strength</td>
<td><input id="dof-strength" type="range" min="0" max="100" value="0" class="control-width"></td>
<td id="dof-strength-text"></td>
<td class="control-help">d + scrollwheel</td>
</tr>
<tr>
<td align="right">Depth of field position</td>
<td><input id="dof-position" type="range" min="0" max="100" value="0" class="control-width"></td>
<td id="dof-position-text"></td>
<td class="control-help">p + scrollwheel</td>
</tr>
<tr>
<td colspan="10">
<hr>
</td>
</tr>
<tr>
<td align="right">Outline strength</td>
<td><input id="outline-strength" type="range" min="0" max="100" value="50" class="control-width"></td>
<td id="outline-strength-text"></td>
<td class="control-help">q + scrollwheel</td>
</tr>
<tr>
<td align="right">Antialiasing passes</td>
<td><input type="number" step="1" min="0" max="32" id="fxaa" value="1" class="control-width"></td>
</tr>
<tr>
<td align="right">Resolution</td>
<td>
<select id="resolution">
<option value="256">256x256</option>
<option value="512">512x512</option>
<option value="768">768x768</option>
<option value="1024">1024x1024</option>
<option value="1536">1536x1536</option>
<option value="2048">2048x2048</option>
</select>
</td>
</tr>
</table>
<button id="center-button">Center</button>
</div>
<div id="controls-share">
<button id="share-url-button">Click this</button>then share the url below.<br><br>
<textarea id="share-url" cols="48" rows="8"></textarea><br><br>
<hr><br>
<a href='#' class=button id="download-image-button" download='render.png'>Download</a>as a
<select id="download-image-format-selector">
<option value="png">PNG</option>
<option value="jpg">JPEG</option>
<option value="bmp">BMP</option>
<option value="gif">GIF</option>
<option value="webp">WebP</option>
</select>
<br><br>
</div>
<div id="controls-help">
<p>
Speck has been tested against recent Firefox and Chrome browsers. Performance appears to be significantly better on Chrome.<br><br> To translate your system, use the shift key and click and drag on the rendering. To rotate, click and drag.
To zoom, use the scrollwheel.
</p>
</div>
<div id="controls-about">
<h2>Speck</h2>
High quality atomistic system rendering.<br><br> Author: Rye Terrell | wwwtyro at gmail.com<br><br> Search function added by <a href="https://github.com/Max-Davy" target="_blank">Max Davy</a><br><br> Github: <a href="https://github.com/Max-Davy/speck"
target="_blank">https://github.com/BertrandTheHealer/speck</a><br><br> Original: <a href="https://github.com/wwwtyro/speck" target="_blank">https://github.com/wwwtyro/speck</a>
<h2>Copyright, license, etc.</h2>
<p>
Speck and the images it produces are completely public domain and free to use. Do with it/them what you will. Attribution is appreciated but not required.
</p>
</div>
</div>
<div id="ao-indicator"></div>
<div id="error" style="display:none;background:#37474f !important;">
<div id="error-text"></div>
<br>
<button id="close-error">Continue</button>
</div>
</body>
</html>