-
Notifications
You must be signed in to change notification settings - Fork 6
/
meta.html
77 lines (67 loc) · 2.3 KB
/
meta.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
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Verovio App demo</title>
<style>
html, body {
width: 100%;
height: 100%;
margin: 0;
}
.header {
padding: 20px;
}
#app {
height: auto;
width: 100%;
position: absolute;
top: 160px;
bottom: 0;
}
</style>
</head>
<body>
<div class="header" id="meta"></div>
<div id="app">Verovio is loading...</div>
<script type="module">
import 'https://www.verovio.org/javascript/app/verovio-app.js';
const options = {
defaultView: 'responsive', // default is 'responsive', alternative is 'document'
defaultZoom: 3, // 0-7, default is 4
enableResponsive: true, // default is true
enableDocument: true // default is true
}
// A MusicXML file
var file = 'data/example.mei';
// A MEI file
//var file = 'https://www.verovio.org/editor/brahms.mei';
const app = new Verovio.App(document.getElementById("app"), options);
fetch(file)
.then(function(response) {
return response.text();
})
.then(function(text) {
app.loadData(text);
});
</script>
<script>
var xhr = new XMLHttpRequest()
xhr.open('GET', 'data/example.mei') // change this to the right file
xhr.send(null)
/* Deal with the response */
xhr.onreadystatechange = function () {
var DONE = 4
var OK = 200
if (xhr.readyState === DONE) {
if (xhr.status === OK) {
var parser = new DOMParser()
var meiDoc = parser.parseFromString(xhr.responseText,"text/xml")
document.querySelector("#meta").innerHTML += "<h1>" + meiDoc.querySelector("[*|id='title12345']").textContent + "</h1>"
document.querySelector("#meta").innerHTML += "<p><strong>Composer:</strong> <a href=\"" + meiDoc.querySelector("[*|id='pers12345']").getAttribute('authURI') + "\">" + meiDoc.querySelector("[*|id='pers12345']").textContent + "</a></p>"
}
}
}
</script>
</body>
</html>