-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathVocabularyFoodAdjective.html
More file actions
104 lines (84 loc) · 3.03 KB
/
VocabularyFoodAdjective.html
File metadata and controls
104 lines (84 loc) · 3.03 KB
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
<!DOCTYPE html>
<html>
<head>
<title>
LT Exercise -- Foods Adjectives
</title>
<link rel="stylesheet" href="css/style.css">
<link rel="stylesheet" href="css/ToC.css">
<link rel="stylesheet" href="css/pageStructure.css">
<script type="text/javascript" src="js/Common.js"> </script>
<script type="text/javascript">
ButtonNext_OnPageLoad();
SetupArrayFunctions();
var samplesAsJson = '[{"Lt":"aštrus","En":"spicy"},{"Lt":"brangus","En":"costly"},{"Lt":"didelis","En":"big"},{"Lt":"karštas","En":"hot"},{"Lt":"pigu","En":"cheap"},{"Lt":"rūgštus","En":"sour"},{"Lt":"saldus","En":"sweet"},{"Lt":"šaltas","En":"cold"},{"Lt":"šiltas","En":"warm"},{"Lt":"skanus","En":"tasty"},{"Lt":"sūrus","En":"salty"}]';
// Get arrays of objects {En, Lt}
var content = JSON.parse(samplesAsJson);
var currentSample = content[0];
var notification = {};
function onNextActionButtonClick(){
// Check if it's answer request or next sample request
var isAnswerRequest = false;
var button = document.getElementById('NextActionButton');
if(button.innerText == 'Check answer') {isAnswerRequest = true;}
else {isAnswerRequest = false;}
// Call the respective function based on the request type
if(isAnswerRequest){
onAnswerRequest();
}
else { onNextSampleRequest(); }
}
function onAnswerRequest(){
// Show answer
var answerDiv = document.getElementById('Answer');
answerDiv.innerHTML = currentSample.Lt;
// Amend button text
var button = document.getElementById('NextActionButton');
button.innerText = 'Next';
// Notification
notification.Answer = currentSample.Lt;
}
function onNextSampleRequest(){
// Clean up answer
var answerDiv = document.getElementById('Answer');
answerDiv.innerHTML = '';
// Amend button text
var button = document.getElementById('NextActionButton');
button.innerText = 'Check answer';
// Setup new sample
var randomSample = content.notRepeatingRandom(currentSample);
currentSample = randomSample;
// Setup question div
var divToAmend = document.getElementById('Question');
var question = currentSample.En;
divToAmend.innerHTML = question;
// Notification
notification.Question = question;
notification.Answer = null;
}
</script>
</head>
<body>
<div id='pageStructure' class="pageStructure">
<div id='ToC' class='ToC'></div>
<script type="text/javascript" src="js/ToC.js"> </script>
<script> uploadToC(); </script>
<div id='table' class='content'>
<div id='Question'> aštrus </div>
<div id='Answer'> spicy </div>
<div id='Button'>
<button id='NextActionButton'
onclick="onNextActionButtonClick()">
Next
</button>
</div>
<div class="issueNotificationDiv">
<button id='notifyButton'
onclick="notify(notification.Question, notification.Answer)">
Tell about an error
</button>
</div>
</div>
</div>
</body>
</html>