choose dictionary

This commit is contained in:
s2
2013-04-12 22:31:16 +02:00
parent 065cced4f0
commit 16187e8bd2
3 changed files with 40 additions and 20 deletions

View File

@@ -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;