forked from rism-digital/verovio.org
-
Notifications
You must be signed in to change notification settings - Fork 0
/
topic04.html
59 lines (49 loc) · 1.64 KB
/
topic04.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
---
next_text: Accessing MEI attributes
next_id: topic05
---
<h3>Accessing MEI elements</h3>
<p>
This example shows how Verovio can load the score at a given point, depending on the id of an element. The selected element always being displayed, even when zooming or resizing the window.
</p>
{% highlight javascript %}
////////////////////////////////////////////////
/* An id of a chord element in the file below */
////////////////////////////////////////////////
id = "chord-L1186F7";
{% endhighlight %}
<p>
[More information]
</p>
{% highlight javascript %}
//////////////////////////////////////////////////////////////////////
/* A function that loads the page where the id is and highlights it */
//////////////////////////////////////////////////////////////////////
function loadPage() {
var elementPage = vrvToolkit.getPageWithElement(id);
if (elementPage == 0) {
console.log("ID not found");
}
else {
page = elementPage;
}
var svg = vrvToolkit.renderToSVG(page, {});
$("#svg_output").html(svg);
///////////////////////////
/* Highlight the element */
///////////////////////////
$("#" + id).attr("fill", "#f00").attr("stroke", "#f00");
};
{% endhighlight %}
<p>
Note that highlighting is just added for clarity, it's not mandatory for this feature.
</p>
{% include html-tutorial.html id="code1" file="topic04-access.html" %}
<div id="code1-xml" style="display: none">
{% highlight html %}
{% include_relative gh-tutorial/topic04-access.html %}
{% endhighlight %}
</div>
<div class="pull-right">
<p><a href="./tutorial.xhtml?id={{ page.next_id }}">{{ page.next_text }}</a> →</p>
</div>