-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathsample4.html
227 lines (206 loc) · 6.64 KB
/
sample4.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
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=9; IE=8; IE=7; IE=EDGE" />
<title>ChordialJS</title>
<link href="http://netdna.bootstrapcdn.com/bootswatch/2.3.2/cerulean/bootstrap.min.css" rel="stylesheet">
<style type="text/css">
body {
padding-top: 60px;
padding-bottom: 40px;
}
.sidebar-nav {
padding: 9px 0;
}
select {
width: auto;
}
label {
display: inline-block;
margin-left: 1em;
}
legend {
width: auto;
margin-bottom: auto;
border: none;
}
fieldset {
border: 1px solid #E5E5E5;
display: inline;
padding: 5px;
}
</style>
</head>
<body>
<div class="navbar navbar-fixed-top">
<div class="navbar-inner">
<div class="container">
<a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</a>
<div style='float:right'>
<div class="">
<ul class="nav">
<li><a href="/">laher.net.nz</a></li>
</ul>
</div>
</div>
<a class="brand" href="index.html">ChordialJS</a>
<div class="nav-collapse collapse">
<ul class="nav">
<li><a href="index.html">Home</a></li>
<li><a href="samples.html">Samples</a></li>
<li><a href="https://www.github.com/laher/ChordialJS/">Code</a></li>
<li><a href="https://www.github.com/laher/ChordialJS/wiki">Wiki</a></li>
<li><a href="https://www.github.com/laher/ChordialJS/issues">Issues</a></li>
<li><a href="mailto:[email protected]">Contact</a></li>
</ul>
</div><!--/.nav-collapse -->
</div>
</div>
</div>
<!-- body partial, used for adding pages to layout -->
<div class="container-fluid">
<div class="row-fluid">
<div class="span3">
<div class="well sidebar-nav">
<ul class="nav nav-pills nav-stacked">
<li class="nav-header">Samples</li>
<li><a href="samples.html">1. Common Progressions</a></li>
<li><a href="sample2.html">2. Chord Families</a></li>
<li><a href="sample3.html">3. Chords by Root Note</a></li>
<li><a href="sample4.html">4. Custom Progressions</a></li>
</ul>
</div><!--/.well -->
</div><!--/span-->
<div class="span9">
<script type='text/javascript'>
//some shared code for the samples
function sess_save(c_name, id) {
var el = document.getElementById(id);
if (el.type && el.type == 'checkbox') {
var val = el.checked;
} else {
var val = el.value;
}
console.log('saving '+c_name+'='+val);
setCookie(c_name, val, 30);
}
function sess_load(c_name, id) {
var el = document.getElementById(id);
var val = getCookie(c_name);
if (val != null) {
console.log('loading '+id+'='+val);
if(el.options != null) {
for (var i = 0; i < el.options.length; i++) {
if (el.options[i].value == val) {
el.options.selectedIndex = i;
break;
}
}
} else if (el.type && el.type === 'checkbox') {
if (val == 'true' || val == 'on') {
el.checked = true;
} else {
el.checked = false;
}
} else {
//otherwise assume textbox ..
el.value = val;
}
}
}
//get/set cookies functions taken from w3cschools
function setCookie(c_name,value,exdays)
{
var exdate=new Date();
exdate.setDate(exdate.getDate() + exdays);
var c_value=escape(value) + ((exdays==null) ? "" : "; expires="+exdate.toUTCString());
document.cookie=c_name + "=" + c_value;
}
function getCookie(c_name)
{
var c_value = document.cookie;
var c_start = c_value.indexOf(" " + c_name + "=");
if (c_start == -1)
{
c_start = c_value.indexOf(c_name + "=");
}
if (c_start == -1)
{
c_value = null;
}
else
{
c_start = c_value.indexOf("=", c_start) + 1;
var c_end = c_value.indexOf(";", c_start);
if (c_end == -1)
{
c_end = c_value.length;
}
c_value = unescape(c_value.substring(c_start,c_end));
}
return c_value;
}
</script>
<h2>4. Custom progressions</h2>
<p>This example parses a series of chord names. It could be extended to a 'tab parser' or similar.</p>
<fieldset>
<legend>Options</legend>
<textarea id="parser_input" onchange="change_parser();">A D E7</textarea>
<button onclick="change_parser(); return false">OK</button>
</fieldset>
<fieldset style='vertical-align: top'>
<legend>Instrument Options</legend>
<label for="parser_lefty">
Lefty?</label>
<input type="checkbox" id="parser_lefty" onchange="sess_save('lefty','parser_lefty');change_parser();">
<label for="parser_instrument">
Instrument
</label>
<select id="parser_instrument" onchange="sess_save('instrument','parser_instrument');change_parser();">
<option value="standard">Guitar</option>
<option value="ukulele">Ukulele</option>
</select>
</fieldset>
<div style='clear:both'></div>
<div id='parser_output'></div>
<div style='clear:both'></div>
</div>
</div>
</div>
<script type="text/javascript">//<![CDATA[
window.onload= function(){
sess_load('lefty', 'parser_lefty');
sess_load('instrument', 'parser_instrument');
change_parser();
};
var do_parser= function(input,lefty,tuning) {
var size=3;
var el= document.getElementById('parser_output');
var progression= ChordialJS.parseProgression(input,
{ size: size, lefty: lefty, tuning : tuning });
ChordialJS.renderChords(el,progression);
};
var change_parser= function(){
var text= document.getElementById('parser_input').value;
var lefty= document.getElementById('parser_lefty').checked;
var tuning= document.getElementById('parser_instrument').value;
do_parser(text,lefty,tuning);
};
//]]>
</script>
</div>
<hr>
<div class="container">
<footer>
<p>© <a href='http://laher.github.com/'>Am Laher 2012</a></p>
</footer>
</div> <!-- /container -->
<!-- twitter bootstrap requires jquery. Otherwise jquery is unused in this site -->
<script src="http://code.jquery.com/jquery-1.10.0.min.js"></script>
<script src="http://netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/js/bootstrap.min.js"></script>
<script src="dist/Chordial-0.0.14.js"></script>
</body>
</html>