// Generator, by Geoff
$(document).ready(function(){
$.getJSON("lessons.json", function(data) {
var wordsHtml = '';
var sidebarHtml = '';
var lessonIndex = 0;
$.each(data, function(lesson, wordList){
lessonIndex++;
$.each(wordList, function(key, word){
wordsHtml += '
';
wordsHtml += '
';
if('img' in word){
wordsHtml += '
';
} else if ('url' in word) {
wordsHtml += '
';
} else {
wordsHtml += '
';
}
wordsHtml += '
'+ word.name +'
';
if('example' in word){
wordsHtml += '
'+ word.example +'
';
}
wordsHtml += '
';
wordsHtml += '
';
});
sidebarHtml += ''+ lesson +'';
});
$('#words').html(wordsHtml);
$('#lessonIndex').html(sidebarHtml);
swapView(1)
});
});
function swapView(newView){
$(".lesson").hide(1000);
$(".lesson-" + newView).show(1000);
}
function englishSay(textToSay) {
responsiveVoice.speak(textToSay);
}