-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathlist_hugo.html
168 lines (154 loc) · 9.57 KB
/
list_hugo.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Concise Handlebars.js</title>
<!-- 0a. CSS -->
<link rel='stylesheet' href='./css/bootstrap.min.css'><!-- main.css -->
<link rel="stylesheet" href="./css/style.css">
<!-- 0a. JS -->
<!-- <script src="//code.jquery.com/jquery-2.0.3.min.js"></script><!-- online jquery.js -->
<!-- <script src="//cdnjs.cloudflare.com/ajax/libs/handlebars.js/1.1.2/handlebars.min.js"></script><!-- online handlebars.js-->
<script src="js/jquery-2.0.3.min.js"></script><!-- online jquery.js -->
<script src="js/handlebars.min.js"></script>
<script rel='script' src='./js/howler.js'></script>
<!-- Twiter CSS -->
<!-- howler or html5 audio -->
</head>
<style>
</style>
<body>
<!-- ###################### -->
<!-- 1. Data (json format!) -->
<script>
var url='data.json'; // relative url : 'data.json'; protocole-relative absolute url: '//website.org/path/to/data.json';
var jsonData = {"item": [
{ "latin":"Glaucidium cuculoides", "name":"Asian_barred_owlet", "key":"1", "ecosystem":"Mid-storey_or_capony", "iucn":"LC"},
{ "latin":"Eurystomus orientalis", "name":"Asian_dollarbird", "key":"", "ecosystem":"Mid-storey_or_capony", "iucn":"LC"},
{ "latin":"Irena puella", "name":"Asian_fairy_bluebird", "key":"", "ecosystem":"Mid-storey_or_capony", "iucn":"LC"},
{ "latin":"Threskiornis melanocephalus", "name":"Black-headed_ibis", "key":"2", "ecosystem":"River", "iucn":"LC"},
{ "latin":"Oriolus xanthornus", "name":"Black-hooded_oriole", "key":"3", "ecosystem":"Mid-storey_or_capony", "iucn":"LC"},
{ "latin":"Dinopium benghalense", "name":"Black-rumped_flameback", "key":"4", "ecosystem":"Mid-storey_or_capony", "iucn":"LC"},
{ "latin":"Amauornis bicolour", "name":"Black-tailed_crake", "key":"5", "ecosystem":"River", "iucn":"LC"},
{ "latin":"Limosa limosa", "name":"Black-tailed_godwit", "key":"", "ecosystem":"River", "iucn":"LC"},
{ "latin":"Megalaima asiatica", "name":"Blue-throated_barbet", "key":"6", "ecosystem":"Mid-storey_or_capony", "iucn":"LC"},
{ "latin":"Cissa chinensis", "name":"Common_green_magpie", "key":"7", "ecosystem":"Ground_dwelling_or_understorey", "iucn":"LC"},
{ "latin":"Alcedo althis", "name":"Common_kingfisher", "key":"8", "ecosystem":"River", "iucn":"LC"},
{ "latin":"Mergus merganser", "name":"Common_merganser", "key":"9", "ecosystem":"River", "iucn":"LC"},
{ "latin":"Ceryle lugubris", "name":"Crested_kingfisher", "key":"0", "ecosystem":"River", "iucn":"LC"},
{ "latin":"Spilornis cheela", "name":"Crested_serpent_eagle", "key":"-", "ecosystem":"Sky", "iucn":"LC"},
{ "latin":"Surniculus lugubris", "name":"Cuckoo_drongo", "key":"q", "ecosystem":"Mid-storey_or_capony", "iucn":"LC"},
{ "latin":"Phalacrocorax carbo", "name":"Great_cormorant", "key":"w", "ecosystem":"River", "iucn":"LC"},
{ "latin":"Mulleripicus pulverulentus", "name":"Great_slaty_woodpecker", "key":"e", "ecosystem":"Mid-storey_or_capony", "iucn":"LC"},
{ "latin":"Polyplectron bicalcaratum", "name":"Grey_peacock-pheasant", "key":"r", "ecosystem":"Ground_dwelling_or_understorey", "iucn":"LC"},
{ "latin":"Motacilla cinerea", "name":"Grey_wagtail", "key":"t", "ecosystem":"River", "iucn":"LC"},
{ "latin":"Gracula religiosa", "name":"Myna_hill", "key":"a", "ecosystem":"Mid-storey_or_capony", "iucn":"LC"},
{ "latin":"Pycnonotus leucogenys", "name":"Himalayan_bulbul", "key":"y", "ecosystem":"Mid-storey_or_capony", "iucn":"LC"},
{ "latin":"Ibidorhyncha struthersii", "name":"Ibisbill", "key":"u", "ecosystem":"River", "iucn":"LC"},
{ "latin":"Lophura leucomelana lathami", "name":"Kalij_pheasant", "key":"i", "ecosystem":"Ground_dwelling_or_understorey", "iucn":"LC"},
{ "latin":"Leptoptilos javanicus", "name":"Lesser_adjutant", "key":"o", "ecosystem":"River", "iucn":"LC"},
{ "latin":"Pericrocotus ethologus", "name":"Long-tailed_minivet", "key":"p", "ecosystem":"Mid-storey_or_capony", "iucn":"LC"},
{ "latin":"Anhinga melanogaster", "name":"Oriental_darter", "key":"s", "ecosystem":"River", "iucn":"LC"},
{ "latin":"Streptopelia orientalis", "name":"Oriental_turtle_dove", "key":"", "ecosystem":"Ground_dwelling_or_understorey", "iucn":"LC"},
{ "latin":"Haliaeetus leucoryphus", "name":"Pallas", "key":"", "ecosystem":"Sky", "iucn":"LC"},
{ "latin":"Ceryle rudis", "name":"Pied_kingfisher", "key":"d", "ecosystem":"River", "iucn":"LC"},
{ "latin":"Rhyacornis fuliginosa", "name":"Plumbeous_water_redstart", "key":"f", "ecosystem":"River", "iucn":"LC"},
{ "latin":"Gallus gallus", "name":"Red_junglefowl", "key":"h", "ecosystem":"Ground_dwelling_or_understorey", "iucn":"LC"},
{ "latin":"Psittacula alexandri", "name":"Red-breasted_parakeet", "key":"g", "ecosystem":"Mid-storey_or_capony", "iucn":"LC"},
{ "latin":"Vanellus indicus", "name":"Red-wattled_lapwing", "key":"j", "ecosystem":"River", "iucn":"LC"},
{ "latin":"Vanellus duvaucelii", "name":"River_lapwing", "key":"k", "ecosystem":"River", "iucn":"LC"},
{ "latin":"Sterna aurantia", "name":"River_tern_bhadra", "key":"l", "ecosystem":"River", "iucn":"LC"},
{ "latin":"Anthreptes singalensis", "name":"Ruby-cheeked_sunbird", "key":"z", "ecosystem":"Mid-storey_or_capony", "iucn":"LC"},
{ "latin":"Leiothrix argentauris", "name":"Silver-eared_mesia", "key":"", "ecosystem":"Ground_dwelling_or_understorey", "iucn":"LC"},
{ "latin":"Enicurus schistaceus", "name":"Slaty-backed_forktail", "key":"x", "ecosystem":"River", "iucn":"LC"},
{ "latin":"Dicrurus bracteatus", "name":"Spangled_drongo", "key":"c", "ecosystem":"Mid-storey_or_capony", "iucn":"LC"},
{ "latin":"Streptopelia chinensis", "name":"Spotted_dove", "key":"v", "ecosystem":"Ground_dwelling_or_understorey", "iucn":"LC"},
{ "latin":"Arachnothera magna", "name":"Streaked_spiderhunter", "key":"b", "ecosystem":"Mid-storey_or_capony", "iucn":"LC"},
{ "latin":"Treron sphenurus", "name":"Wedge-tailed_green_pigeon", "key":"n", "ecosystem":"Mid-storey_or_capony", "iucn":"LC"},
{ "latin":"Arborophiila atrogularis", "name":"White-cheeked_partridge", "key":"m", "ecosystem":"Ground_dwelling_or_understorey", "iucn":"LC"},
{ "latin":"Garrulax leucolophus", "name":"White-crested_laughingthrush", "key":"", "ecosystem":"Ground_dwelling_or_understorey", "iucn":"LC"},
{ "latin":"Gyps bengalensis", "name":"", "key":"", "ecosystem":"Sky", "iucn":"LC"},
{ "latin":"Halcyon smyrnensis", "name":"White-throated_kingfisher", "key":"", "ecosystem":"River", "iucn":"LC"},
{ "latin":"Carina scutulata", "name":"", "key":"", "ecosystem":"River", "iucn":"LC"},
{ "latin":"", "name":"White-naped_vulture", "key":"", "ecosystem":"Sky", "iucn":"LC"}
]};
</script>
<!-- ###################### -->
<!-- ##### HTML BODY ##### -->
<!-- ###################### -->
<div class="container">
<div class="row">
<div class="col-md-6">
1. Put cursor into form field.<br />
2. It's ready to work !<br />
3. Test the <b>Interactive Bird Voices Panel</b> (IBVP) by pressing a touch with your hand
</div>
<div class="col-md-6">
<form>
<fieldset>
<label for="target">Put mouse's </label>
<input id="input" placeholder=" cursor here !" type="text" autofocus><!-- visibility hidden -->
</fieldset>
</form>
</div>
</div>
<!-- 2. Anchor -->
<div class="row" id="anchor">This div is the <b>#anchor</b>.<br /></div>
<!-- 3. Template -->
<script id="tpl" type="text/template">
{{#item}}
<button class="tpl bird sound {{ecosystem}} col-md-2 col-xs-4" data-key="{{key}}" data-name="{{name}}" data-iucn="{{iucn}}" style='background-image:url("./img/photo/{{name}}.jpg");background-size: 100% 100%;'>
<!-- <img src="img/photo/{{name}}.jpg" /><br /> -->
{{#if key}} <a href="./audio/{{name}}.mp3">{{key}}</a> — {{/if}}
{{name}}
{{#if latin}} (<a href="http://en.wikipedia.org/wiki/{{latin}}">{{latin}}</a>){{/if}}.
<img src="img/iucn/Status_iucn3.1_{{iucn}}.png" width="240px" />
<audio src="./audio/{{name}}.mp3" controlsNO autoplaysNO loop preload="auto" ></audio>
</button>
{{/item}}
</script>
<!-- ###################### -->
<!-- ### INTERACTIVE JS ### -->
<!-- ###################### -->
<!--4. Handlebars.js slingshot -->
<script>
//4a.function creation
var slingshot = function (data, tplId, anchor) {
//$.getJSON(url, function(data) {
var template = $(tplId).html();
var stone = Handlebars.compile(template)(data);
$(anchor).append(stone);
// });
}
//4b.function firing
slingshot(jsonData, '#tpl', '#anchor'); // since url = 'data.json' , we can use both notations.
</script>
<!--5a. INTERACTIONS -->
<script id="interactive_player">
var playSound = function ($this) {
console.log("♪+1");// edited
// get phonetic properties
var pho = $this.attr("data-name");
var key = $this.attr("data-key");
$this.addClass("playing");
// playing
var sound = new Howl({
// console.log("♪+2");// edited
urls: ['./audio/'+pho+'.mp3'],
onend: function() { $this.removeClass("playing"); }
}).play();
console.log("♪+; pho: "+pho+"; name: "+ key);// edited
}; // end
$(document).ready(function() {
$(".sound").click(function(){
playSound( $(this) );
});
$("#input").on("keyup", function () {
var input = $("#input").val().slice(-1);
playSound( $(".bird[data-key="+input+"]") );
$("#input").val(""); // clean up field!
});
});
</script>
</body>
</html>