-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
66 lines (52 loc) · 1.5 KB
/
main.js
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
$( document ).ready(function() {
$('#existe').hide();
$('#afaire').hide();
for (var i = 0; i < blagues.length; i++) {
var dpt = blagues[i].id;
$('path[name='+dpt+']').attr("class", "dpt done");
};
counting();
});
$('.dpt').click(function(e) {
e.preventDefault();
clearAll();
dptid = $(this).attr('name');
$('#nomDpt').text(dptid);
$('#theImg').remove();
pic = 'images/travolta.gif';
existe = false;
// iterate over each element in the array
for (var i = 0; i < blagues.length; i++) {
// look for the entry with a matching `code` value
if (blagues[i].id == dptid) {
// we found it
// obj[i].name is the matched result
nom = blagues[i].nom;
pic = blagues[i].pic;
credits = blagues[i].credits;
$('#picDpt').prepend('<img id="theImg" alt="'+ nom +'" class="img-fluid" src='+ pic +' />')
$('#creditsDpt').text('@'+credits);
$('#creditsDpt').attr('href','https://twitter.com/'+credits);
$('#existe').show();
existe = true;
$(this).attr("class", "dpt done active");
// $('#creditsDpt').text(credits);
}
} // end for
if (existe == false) {
$('#afaire').show();
$(this).attr("class", "dpt active");
}
})
function counting() {
dpts = $('.dpt').length;
done = blagues.length;
$('#progress').attr("aria-valuenow" , done);
$("#progress").css("width", done/dpts*100+'%');
$('#progress').text(done+'/'+dpts+' départements');
}
function clearAll() {
$('#lancement').hide();
$('#existe').hide();
$('#afaire').hide();
}