diff --git a/app/index.html b/app/index.html index b431c36..0dffa5f 100644 --- a/app/index.html +++ b/app/index.html @@ -26,8 +26,14 @@
diff --git a/app/js/index.js b/app/js/index.js index 0e2bcb4..bbeca1e 100644 --- a/app/js/index.js +++ b/app/js/index.js @@ -97,31 +97,45 @@ if (typeof(sw) == 'undefined') { startGame(); }; - //start app - var w = $.ajax({ - url: sw.apiPrefix + "words.json", - dataType: 'json' - }); - - - w.done(function(words) { - var start = $('.start'); - start.removeClass('disabled'); - start.html(' Start '); - start.animate({ - opacity : 1 - }, 1000, 'linear'); + var loadDictionary = function(dict) { + var w = $.ajax({ + url: sw.apiPrefix + 'words_' + dict + '.json', + dataType: 'json' + }); - sw.words = words.words; - }); + + w.done(function(words) { + var start = $('.start'); + start.removeClass('disabled'); + start.html(' Start '); + start.animate({ + opacity : 1 + }, 1000, 'linear'); + + sw.words = words.words; + }); + + w.fail(function(err) { + console.log(err); + }); + + return w; + }; //events + $(document).on('click', '.dict', function(ev) { + var el = $(ev.currentTarget); + var dict = el.attr('data-dict'); + $('.start-btn').html('views/start-button.ejs', {}); + loadDictionary(dict); + }); + $(document).on('click', '.start', function() { startNewGame(); }); - $(document).on('click', '.word-button', function(ev, el) { - el = $(ev.currentTarget); + $(document).on('click', '.word-button', function(ev) { + var el = $(ev.currentTarget); if (el.hasClass('disabled')) { return; diff --git a/app/words.json b/app/words_en.json similarity index 100% rename from app/words.json rename to app/words_en.json