forked from mbaezpy/trentose2015-midterm1
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
55 lines (40 loc) · 1.21 KB
/
app.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
/* your code should go in this file */
/*
* The data is available in the array *data*
* Each element of the array has the following structure:
* {
* phrase_en : "I'm a man", // sentence in english
* phrase_de : "Ich bin ein Mann" // sentence in german
* }
*/
var tmpl = ' <li id="ID">' +
' <h3>SENTENCE</h3>' +
' </li> ';
var total_sentences = 0;
var solved_sentences = 0;
var current_sentece = 0;
$(document).ready(function(){
total_sentences = data.length;
$.each(data, function(index){
var sentence = tmpl.replace("ID", index);
sentence = sentence.replace("SENTENCE", this.phrase_en);
console.log(sentence);
$('.sentences').append(sentence);
})
$('.sentences li:first-child').addClass('current');
$('.opt-continue').click(function() {
current_sentece++;
console.log('current:' + current_sentece + ' total:' + total_sentences);
if(current_sentece < total_sentences)
next();
else {
$('.pratice').attr('hidden','');
//$('.final').attr('','');
}
});
});
function next() {
var current_id = $('.current').attr('id');
$('.current').removeClass('current');
var next = $('#'+ (++current_id)).addClass('current');
}