-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
40 lines (36 loc) · 1.26 KB
/
script.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// Wait for body to load, set event handlers
$(document).ready(function() {
// Prevent IE from treating ajax requests as regular web requests
$.ajaxSetup({ cache: false });
// Show the other side of the flashcard (kanji or translation).
$('#flip').click(function(e) {
if ($('#showing').html().indexOf('Kanji') != -1) {
$('#english').show();
$('#kanji').hide();
$('#showing').html('Currently showing English translation');
} else {
$('#english').hide();
$('#kanji').show();
$('#showing').html('Currently showing Kanji');
}
});
// Show the pronunciation in katakana/hiragana
$('#show_pronunciation').click(function(e) {
if ($('#show_pronunciation').val().indexOf('Show') != -1) {
$('#pronunciation').show();
$('#show_pronunciation').val('Hide pronunciation');
} else {
$('#pronunciation').hide();
$('#show_pronunciation').val('Show pronunciation');
}
});
// Show a new flashcard.
$('#new').click(function(e) {
$.getJSON('show_new.php', function(data) {
$('#kanji').html(data['kanji']);
$('#english').html(data['english_translation']);
$('#pronunciation').html(data['pronunciation']);
$('#link').attr('href', data['link']);
});
});
});