2019-09-20 00:16:23 +02:00
|
|
|
// 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 += ' <div style="display: none;" class="col-md-4 lesson lesson-' + lessonIndex + '">';
|
|
|
|
|
wordsHtml += ' <div class="service-item">';
|
|
|
|
|
if('img' in word){
|
2019-09-20 15:28:26 +02:00
|
|
|
wordsHtml += ' <div class="icon" onclick="englishSay(\''+ word.name +'\')" style="background-image:url(assets/images/'+ word.img +');"></div>';
|
2019-09-20 00:16:23 +02:00
|
|
|
} else if ('url' in word) {
|
2019-09-20 15:28:26 +02:00
|
|
|
wordsHtml += ' <div class="icon" onclick="englishSay(\''+ word.name +'\')" style="background-image:url('+ word.url +');"></div>';
|
2019-09-20 00:16:23 +02:00
|
|
|
} else {
|
2019-09-20 15:28:26 +02:00
|
|
|
wordsHtml += ' <div class="icon" onclick="englishSay(\''+ word.name +'\')" style="background-image:url(http://img.icons8.com/'+ word.name +'.png);"></div>';
|
2019-09-20 00:16:23 +02:00
|
|
|
}
|
2019-09-20 15:28:26 +02:00
|
|
|
wordsHtml += ' <h4 class="clickSay" onclick="englishSay(\''+ word.name +'\')">'+ word.name +'</h4>';
|
2019-09-20 00:16:23 +02:00
|
|
|
if('example' in word){
|
2019-09-20 16:24:22 +02:00
|
|
|
wordsHtml += ' <p class="clickSay" onclick="englishSay(\''+ word.example +'\')">'+ word.example +'</p>';
|
2019-09-20 00:16:23 +02:00
|
|
|
}
|
|
|
|
|
wordsHtml += ' </div>';
|
|
|
|
|
wordsHtml += ' </div>';
|
|
|
|
|
});
|
|
|
|
|
sidebarHtml += '<li><a href="#" onclick="swapView('+ lessonIndex +')">'+ lesson +'</a></li>';
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
$('#words').html(wordsHtml);
|
|
|
|
|
$('#lessonIndex').html(sidebarHtml);
|
|
|
|
|
swapView(1)
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
function swapView(newView){
|
|
|
|
|
$(".lesson").hide(1000);
|
|
|
|
|
$(".lesson-" + newView).show(1000);
|
|
|
|
|
}
|
2019-09-20 15:28:26 +02:00
|
|
|
|
|
|
|
|
function englishSay(textToSay) {
|
|
|
|
|
responsiveVoice.speak(textToSay);
|
|
|
|
|
}
|
|
|
|
|
|