Skip to content

Commit

Permalink
Dict list and currently loaded dict are now always in sync.
Browse files Browse the repository at this point in the history
Previously, one dict might have been loaded on startup while another one was
shown as active in the dropdown dict selector.
  • Loading branch information
valderman committed Jan 17, 2012
1 parent 21b5ffb commit 5d21cdc
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
14 changes: 12 additions & 2 deletions assets/js/exquisitioner.js
Expand Up @@ -10,12 +10,15 @@ function Exquisitioner(list){
this.dictList = $("#dictList");

var that = this;

// On dictionary list change, change the current dictionary.
this.dictList.change(function() {
that.loadList(that.dictList[0].value);
});

// Refresh the list of dictionaries the user can choose from
this.refreshLists = function() {
// Initialize the list, setting
this.init = function(defaultList) {
// Refresh the dict list
$.ajax({
url: 'api.php?do=getDicts',
error: function(a, b) {
Expand All @@ -29,6 +32,12 @@ function Exquisitioner(list){
var elem = $('<option value="'+v+'">'+v+'</option>');
that.dictList.append(elem);
}

// Load the default dictionary
var ll = ListLoader.getSingleton();
ll.load(defaultList, false, function() {
that.loadList(defaultList);
});
}
});
}
Expand All @@ -41,6 +50,7 @@ function Exquisitioner(list){
ll.load(listName, false, function() {
var list = this.list = ll.get(listName);
if(list) {
that.dictList.val(listName);
that.list = list;
that.startup();
} else {
Expand Down
3 changes: 1 addition & 2 deletions assets/js/ready.js
@@ -1,6 +1,5 @@
$(document).ready(function (){
var quiz = new Exquisitioner();
quiz.loadList('hiragana');
quiz.refreshLists();
quiz.init('hiragana');
quiz.setAnsField($("#answer"));
});

0 comments on commit 5d21cdc

Please sign in to comment.