forked from benwilliams337/interactiveArcDiagrams
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
163 lines (157 loc) · 5.31 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
<html>
<head>
<title>Interactive Arc Diagrams</title>
<style type="text/css">
@font-face {
font-family: "Bravura";
src: url("Bravura.eot");
src: local("Bravura"),
url("Bravura.eot?#iefix") format("embedded-opentype"),
url("Bravura.woff") format("woff"),
url("Bravura.otf") format("opentype"),
url("Bravura.svg#Bravura") format("svg");
font-weight: normal;
font-style: normal;
}
.optionsBlock {
text-align:left;
padding: 5px;
}
.bordered {
border: 1px solid black;
border-radius:5px;
}
#divFileUpload {
height: 500px;
padding: 10px;
-webkit-transition:background 0.5s;
-moz-transition:background 0.5s;
-o-transition:background 0.5s;
transition:background 0.5s;
}
.dropZoneReady {
background: #B4FFB4;
}
</style>
</head>
<body>
<!--<div style="font-family:Bravura; font-size:48px;">
 
</div>-->
<div id="canvasWrapper" style="text-align: center;">
<h1>Interactive Arc Diagram Generator</h1>
<div style="width:1160px; display:inline-block">
<div id="divFileUpload" class="bordered">
<p style="font-weight:bold">Drag and drop a humdrum file into this rectangle, or use the button below.</p>
<input type="file" id="fileInput" onChange="fileUploaded(this.files)">
<!--<input type="button" id="btnLoadTest" value="Load Test" onclick="loadTest()"></input>-->
<div>
<div class="optionsBlock">
<b>Match:</b><br/>
<label><input type="radio" name="matchType" value="all" checked> Pitch and Rhythm<br/></label>
<label><input type="radio" name="matchType" value="pitch"> Pitch only<br/></label>
<label><input type="radio" name="matchType" value="rhythm"> Rhythm only<br/></label>
</div>
<div class="optionsBlock">
<b>Pitch Matching Type:</b><br/>
<label><input type="radio" name="pitchType" value="abs" checked> Absolute Pitch<br/></label>
<label><input type="radio" name="pitchType" value="rel"> Relative Pitch<br/></label>
</div>
<div class="optionsBlock">
<label><input id="chkIncludeRests" type="checkbox" checked> Include Rests?</label>
</div>
<div class="optionsBlock">
<label><input id="chkUseColors" type="checkbox" checked> Use colors?</label>
</div>
<!-- <div class="optionsBlock">
<b>Multiple Matches Rule:</b><br/>
<label><input type="radio" name="multipleRule" value="all" checked> Connect Consecutive<br/></label>
<label><input type="radio" name="multipleRule" value="pitch"> Connect to First<br/></label>
<label><input type="radio" name="multipleRule" value="rhythm"> Connect All<br/></label>
</div>-->
</div>
</div>
<table id="diagramTable" style="display:none;">
<tr>
<td style="width:960px">
<div id="canvas" style="text-align:center"></div>
<div>
<table style="width:100%">
<tr>
<td style="width:50%">
<div id="staff1" style="overflow-x:auto; width:480px; text-align:center;"></div>
</td>
<td style="width:50%">
<div id="staff2" style="overflow-x:auto; width:480px; text-align:center;"></div>
</td>
</tr>
</table>
</div>
</td>
<td style="width:200px">
<div id="partsList"></div>
</td>
</tr>
</table>
</div>
</div>
<script src="jquery-2.2.3.min.js"></script>
<script src="d3.min.js"></script>
<script src="http://verovio-script.humdrum.org/scripts/verovio-toolkit.js"></script> <!--TODO: Local fallback (i.e. if user is offline)-->
<script src="parseHumdrum.js"></script>
<script src="main.js"/></script>
<script src="diagram.js"></script>
<script>
function fileUploaded(files) {
var reader = new FileReader();
reader.onload = function(e) {
var data = parseHumdrum(e.target.result);
load(data);
};
reader.readAsText(files[0]);
}
function load(data) {
var comparisonOptions = {
comparePitch: $("input:radio[name='matchType']:checked").val() != "rhythm",
compareRhythm: $("input:radio[name='matchType']:checked").val() != "pitch",
useAbsPitch: $("input:radio[name='pitchType']:checked").val() == "abs"
};
var themes = findThemes(data, {
minLength: 2,
comparisonOptions: comparisonOptions,
includeRests: $("#chkIncludeRests").is(':checked'),
//multipleRule: $("input:radio[name='matchType']:checked").val()
});
var useColors = $("#chkUseColors").is(':checked');
drawArcDiagram("canvas", "partsList", "staff1", "staff2", themes, data.length, useColors);
}
//Drag/drop file uploading
var dropZone = document.getElementById("divFileUpload");
function allowDrag(e) {
e.dataTransfer.dropEffect = 'copy';
e.preventDefault();
}
function showDropZone() {
$("#divFileUpload").addClass("dropZoneReady");
}
function hideDropZone() {
$("#divFileUpload").removeClass("dropZoneReady");
}
window.addEventListener('dragenter', function(e) {
showDropZone();
});
dropZone.addEventListener('dragenter', allowDrag);
dropZone.addEventListener('dragover', allowDrag);
dropZone.addEventListener('dragleave', function(e) {
hideDropZone();
});
dropZone.addEventListener('drop', function(e) {
e.preventDefault();
hideDropZone();
fileUploaded(e.dataTransfer.files);
});
//Instantiate verovio toolkit
var verovioToolkit = new verovio.toolkit();
</script>
</body>
</html>