choose dictionary
This commit is contained in:
@@ -26,8 +26,14 @@
|
|||||||
<div class="hero-unit" style="text-align: center;">
|
<div class="hero-unit" style="text-align: center;">
|
||||||
<h1>Similar Words!</h1>
|
<h1>Similar Words!</h1>
|
||||||
<hr />
|
<hr />
|
||||||
<p>
|
<h2>Dictionary</h2>
|
||||||
<a class="btn btn-primary btn-large disabled start" style="opacity: 0.25;"> Loading... </a>
|
<div class="btn-group">
|
||||||
|
<button class="btn dict btn-large" data-dict="de">Deutsch</button>
|
||||||
|
<button class="btn dict btn-large" data-dict="en">English</button>
|
||||||
|
<button class="btn dict btn-large" data-dict="it">Italiano</button>
|
||||||
|
</div>
|
||||||
|
<hr />
|
||||||
|
<p class="start-btn">
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@@ -97,31 +97,45 @@ if (typeof(sw) == 'undefined') {
|
|||||||
startGame();
|
startGame();
|
||||||
};
|
};
|
||||||
|
|
||||||
//start app
|
var loadDictionary = function(dict) {
|
||||||
var w = $.ajax({
|
var w = $.ajax({
|
||||||
url: sw.apiPrefix + "words.json",
|
url: sw.apiPrefix + 'words_' + dict + '.json',
|
||||||
dataType: 'json'
|
dataType: 'json'
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
w.done(function(words) {
|
w.done(function(words) {
|
||||||
var start = $('.start');
|
var start = $('.start');
|
||||||
start.removeClass('disabled');
|
start.removeClass('disabled');
|
||||||
start.html(' Start ');
|
start.html(' Start ');
|
||||||
start.animate({
|
start.animate({
|
||||||
opacity : 1
|
opacity : 1
|
||||||
}, 1000, 'linear');
|
}, 1000, 'linear');
|
||||||
|
|
||||||
sw.words = words.words;
|
sw.words = words.words;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
w.fail(function(err) {
|
||||||
|
console.log(err);
|
||||||
|
});
|
||||||
|
|
||||||
|
return w;
|
||||||
|
};
|
||||||
|
|
||||||
//events
|
//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() {
|
$(document).on('click', '.start', function() {
|
||||||
startNewGame();
|
startNewGame();
|
||||||
});
|
});
|
||||||
|
|
||||||
$(document).on('click', '.word-button', function(ev, el) {
|
$(document).on('click', '.word-button', function(ev) {
|
||||||
el = $(ev.currentTarget);
|
var el = $(ev.currentTarget);
|
||||||
|
|
||||||
if (el.hasClass('disabled')) {
|
if (el.hasClass('disabled')) {
|
||||||
return;
|
return;
|
||||||
|
Reference in New Issue
Block a user