-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
210 lines (192 loc) · 9.89 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
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Edify Music</title>
<link rel="stylesheet" href="css/font-awesome.min.css"/>
<link rel="stylesheet" href="css/bootstrap.min.css"/>
<link href="css/abcjs-midi.css" media="all" rel="stylesheet" type="text/css" />
<script src="js/abcjs_editor_midi_3.1.1-min.js" type="text/javascript"></script>
<style>
.abcjs-inline-midi {
max-width: 960px;
}
textarea {
display: block;
width: 100%;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
</style>
</head>
<body>
<!-- Static navbar -->
<nav class="navbar navbar-default navbar-static-top">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#"><span color="blue">edify</span> Music <i class="fa fa-music" aria-hidden="true"></i></a>
</div>
<div id="navbar" class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li class="active"><a href="#">Home</a></li>
<li><a href="about.html">About</a></li>
<li><a href="help.html">Help</a></li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Sample Songs <span class="caret"></span></a>
<ul class="dropdown-menu">
<li><a id="ode_to_joy" href="#">Ode to Joy</a></li>
<li><a id="menuet" href="#">Menuet</a></li>
<li><a id="cooleys" href="#">Cooley's</a></li>
<li><a id="prelude" href="#">Prelude</a></li>
<li role="separator" class="divider"></li>
<li class="dropdown-header">National Anthems</li>
<li><a id="ghana_anthem" href="#">Ghana</a></li>
<li><a id="liberia_anthem" href="#">Liberia</a></li>
</ul>
</li>
</ul>
</div><!--/.nav-collapse -->
</div>
</nav>
<div class="container">
<div class="alert alert-info alert-dismissible fade in" role="alert">
Type or paste an abc tune in the area below and see it rendered as you type. Also notice that you can click on the drawn notes and
see the place in the text where that note is defined.
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="row">
<div class="col-md-6">Upload ABC notation text file: <input type="file" id="file" name="file" enctype="multipart/form-data" /></div>
<div class="col-md-6"><div id="abc-file-download"><button type="button" class="btn btn-success" value="save" id="save"><i class="fa fa-file-text-o"></i> Download as text file.</button></div></div>
</div>
<textarea name="abc" id="abc" rows="15">
X:1
T:Ode to Joy
C:L. Van Beethoven
M:4/4
L:1/4
K:D
F F G A | A G F E | D D E F | F>E E2 |
F F G A | A G F E | D D E F | E>D D2 |
|:E E F D | E F/2G/2 F D | E F/2G/2 F E | D E A,2 |
F F G A | A G F E | D D E F | E>D D2 :|
</textarea>
<div id="midi"></div>
<div id="midi-download"></div>
<div id="warnings"></div>
<div id="music"></div>
<div id="paper0"></div>
<div id="paper1"></div>
<div id="paper2"></div>
<div id="paper3"></div>
<div id="selection"></div>
</div> <!-- /container -->
<script src="js/jquery.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<script type="text/javascript">
function selectionCallback(abcelem) {
var note = {};
for (var key in abcelem) {
if (abcelem.hasOwnProperty(key) && key !== "abselem")
note[key] = abcelem[key];
}
console.log(abcelem);
var el = document.getElementById("selection");
el.innerHTML = "<b>selectionCallback parameter:</b><br>" + JSON.stringify(note);
}
function initEditor() {
abc_editor = new ABCJS.Editor("abc", { paper_id: "paper0",
generate_midi: true,
midi_id:"midi",
midi_download_id: "midi-download",
generate_warnings: true,
warnings_id:"warnings",
midi_options: {
generateDownload: false
},
render_options: {
listener: { highlight: selectionCallback }
}
});
};
window.addEventListener("load", initEditor, false);
function saveTextAsFile() {
var textToWrite = document.getElementById('abc').value;
var textFileAsBlob = new Blob([ textToWrite ], { type: 'text/plain' });
var fileNameToSaveAs = "song.txt";
var downloadLink = document.createElement("a");
downloadLink.download = fileNameToSaveAs;
downloadLink.innerHTML = "Download as .abc File";
if (window.URL != null) {
// Chrome allows the link to be clicked without actually adding it to the DOM.
downloadLink.href = window.URL.createObjectURL(textFileAsBlob);
} else {
// Firefox requires the link to be added to the DOM before it can be clicked.
downloadLink.href = window.URL.createObjectURL(textFileAsBlob);
downloadLink.onclick = destroyClickedElement;
downloadLink.style.display = "none";
document.body.appendChild(downloadLink);
}
downloadLink.click();
}
var button = document.getElementById('save');
button.addEventListener('click', saveTextAsFile);
function destroyClickedElement(event) {
// remove the link from the DOM
document.body.removeChild(event.target);
}
$(document).ready(function(){
$("#ghana_anthem").click(function(){
$('#abc').text('X: 1\nT: God Bless Our Homeland Ghana\nC: Philip Gbeho\nZ:Reuben Thiessen\nM: C\nL: 1/4\nQ: 1/4=70\nK: Ab\nc c3/4c/8 e (A3/4A/8)|d2 c3/2 A/2|f e d c|B B B2|\nw: God bless our home-land|Gha-na And|make our na-tion|great and strong,|\nc c3/4c/8 e A|d2 c3/2 c/2|B e (3(e/2f/2)e/2 (3(=d/2c/2)d/2|e3 (3(E/2F/2)G/2|\nw: Bold to de-fend for-|e-ver The|cause of Freedom and|Right; Fill our|\nA (A3/4B/4) c (c3/4B/4)|=A (B3/4c/4) d (3(F/2G/2)=A/2|B (B3/4c/4) d =d|e (e3/4d/4) c3/2 A/2|\nw: hearts with true hu-|mi-li-ty, Make us|che-rish fear-less|ho-nes-ty, And|\nf e d c|B3/4A/4 G3/4F/4 E3/4E/4 F3/4G/4|A c (3(c/2d/2c/2) (3(B/2A/2)B/2|(A3 A3/4)A/4|\nw: help us to re-|sist op-pres-sors\' rule With all our|will and mi g ht e- ver-|more. And|\nf e d c|B3/4A/4 G3/4F/4 E3/4E/4 F3/4G/4|A c (3(c/2d/2c/2) (3(B/2A/2)B/2|A4|]\nw: help us to re-|sist op-pres-sors\' rule With all our|will and mi g ht e- ver-|more.|');
$("#abc").focus();
abc_editor.fireChanged();
});
$("#liberia_anthem").click(function(){
$("#abc").text('X: 2\nT: All Hail, Liberia, Hail!\nC: Olmstead Luca & Daniel Bashiel Warner\nZ:Reuben Thiessen\nM: 4/4\nL: 1/4\nQ: 1/4=100\nK: Bb\nz1 F|B3/2 B/2 B B|B3 F|c3/2 c/2 c c|c6/2 c|\nw: All |hail, Li-be-ria,| hail! All|hail, Li-be-ria,|hail! This|\nd3/2 d/2 d d|c3/2 B/2 A B| A2 G2| F2 z F|\nw: glo-rious land of|lib-er-ty shall|long be|ours Tho\'|\nF G A B|c d e c|d c B d|(f4|(f4)|(f4)|\nw: new her name, Green|be her fame, And|migh-ty be her|powers,|\n(f4)|f3)d|c d c d|(c4|(c4)|(c4)|c3)z|\nw: . And| migh-ty be her|powers.|\nM: 2/4\nL: 1/8\nz2 z1 F|F3 G|F3 G|F d c3/2 B/2|B2 A G|\nw: In|joy and|glad-ness|With our hears u-|ni-ted, We\'ll|\nF3 G|F3 G|F e d c|^c2 d2|g2 g3/2 g/2|f3 f|\nw: shout the|free-dom|of a race be-|night-ed,|Long live Li-|be-ria,|\ne3 e|d2 z d|c =B c d| e f e c|B2 c2|\nw: hap-py|land! A|home of glo-rious|li-ber-ty, By|God\'s com-|\nd3 d|c =B c d| e f e c|B2 A2|B2 z|]\nw: -mand! A|home of glo-rious|li-ber-ty, By|God\'s com-|mand!|');
$("#abc").focus();
abc_editor.fireChanged();
});
$("#ode_to_joy").click(function(){
$("#abc").text('X:3\nT:Ode to Joy\nC:L. Van Beethoven\nM:4/4\nL:1/4\nK:D\nF F G A | A G F E | D D E F | F>E E2 |\nF F G A | A G F E | D D E F | E>D D2 |\n|:E E F D | E F/2G/2 F D | E F/2G/2 F E | D E A,2 |\nF F G A | A G F E | D D E F | E>D D2 :|');
$("#abc").focus();
abc_editor.fireChanged();
});
$("#cooleys").click(function(){
$("#abc").text('X:4\nT: Cooley\'s\nM: 4/4\nL: 1/8\nR: reel\nK: Emin\n|:D2|EB{c}BA B2 EB|~B2 AB dBAG|FDAD BDAD|FDAD dAFD|\nEBBA B2 EB|B2 AB defg|afe^c dBAF|DEFD E2:|\n|:gf|eB B2 efge|eB B2 gedB|A2 FA DAFA|A2 FA defg|\neB B2 eBgB|eB B2 defg|afe^c dBAF|DEFD E2:|');
$("#abc").focus();
abc_editor.fireChanged();
});
$("#menuet").click(function(){
$("#abc").text('X:190\nT:103. Menuet\nC:trad.\nN:Van Bolhuis, manuscript 3, 1739, transcriptie Ad Kwakernaat\nM:3/4\nL:1/8\nQ:1/4=180\nK:D\ndA eA fA |g2 fg e2 |a2 gf ed |c2 Bc A2 |dA eA fA |g2 fg e2 |a2 A2 dc |\nd6 ::af fa a=c |B2 AB G2 |bg gb bd |c2 Bc A2 |dA eA fA |g2 (3gfe f2 |\ndA eA fA |g2 (3gfe f2 |dA AF FD |dA AF FD |dA AF FD |d2 e2 dc |d6 :|');
$("#abc").focus();
abc_editor.fireChanged();
});
$("#prelude").click(function(){
$("#abc").text('X:5\nT:Prelude\nT:Op. 28 no. 7\nC:Frederic Chopin\nZ:Transcribed by Frank Nordberg - http://www.musicaviva.com\nM:3/4\nL:1/8\nQ:"Andantino"\n\K:G\nD2|B>cA2A2|A4e2|^c>dg2g2|g4B2|\n^G>Ac2c2|c4F2|F>GB2B2|B4D2|\nB>cA2A2|A4e2|^c>db2b2|b4B2|\nB>ce2e2|e4F2|A>Gg2g2|g4z2|]');
$("#abc").focus();
abc_editor.fireChanged();
});
});
document.getElementById('file').addEventListener('change', readFile, false);
function readFile (evt) {
var files = evt.target.files;
var file = files[0];
var reader = new FileReader();
reader.onload = function(event) {
$('#abc').val(event.target.result);
abc_editor.fireChanged();
}
reader.readAsText(file)
};
</script>
</body>
</html>