-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathtest_parser.html
More file actions
29 lines (29 loc) · 877 Bytes
/
test_parser.html
File metadata and controls
29 lines (29 loc) · 877 Bytes
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
<!doctype html>
<html>
<head>
<meta charset="utf-8" />
<title>Test CIF parser</title>
<script src="js/xtal.js"></script>
<script src="js/xtal.cif.js"></script>
</head>
<body>
<h1>mmCIF JavaScript Parser</h1>
<div id="out">...</div>
<script>
function getParameterByName(name) {
name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
results = regex.exec(location.search);
return results == null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
}
var model_id = getParameterByName("model_id") || "1YJP.cif";
var reader = new xtal.cif.Reader();
reader.load('data/' + model_id, function(model){
var block = model.first_block();
console.log(block);
var atoms = block.loop_dict('_atom_site');
console.log(atoms);
})
</script>
</body>
</html>