-
Notifications
You must be signed in to change notification settings - Fork 3
/
ATypeVerbsVocabulary.html
159 lines (128 loc) · 7.96 KB
/
ATypeVerbsVocabulary.html
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
<!DOCTYPE html>
<html>
<head>
<title>
LT Exercise -- A-Type Verbs -- Vocabulary
</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 = '[{"Infinitive":"būti","Present":"yra","Past":"buvo","Translation":"to be"},{"Infinitive":"gyventi","Present":"gyvena","Past":"gyveno","Translation":"to live somewhere"},{"Infinitive":"dirbti","Present":"dirba","Past":"dirbo","Translation":"to work"},{"Infinitive":"suprasti","Present":"supranta","Past":"suprato","Translation":"to understand"},{"Infinitive":"eiti","Present":"eina","Past":"ėjo","Translation":"to go"},{"Infinitive":"duoti","Present":"duoda","Past":"davė","Translation":"to give"},{"Infinitive":"imti","Present":"ima","Past":"ėmė","Translation":"to take"},{"Infinitive":"dėti","Present":"deda","Past":"dėjo","Translation":"to put"},{"Infinitive":"mėgti","Present":"mėgsta","Past":"mėgo","Translation":"to like"},{"Infinitive":"patikti","Present":"patinka","Past":"patiko","Translation":"to like"},{"Infinitive":"susitikti","Present":"susitinka","Past":"susitiko","Translation":"to meet"},{"Infinitive":"važiuoti","Present":"važiuoja","Past":"važiavo","Translation":"to drive"},{"Infinitive":"vėluoti","Present":"vėluoja","Past":"vėlavo","Translation":"to be late"},{"Infinitive":"skubėti","Present":"skuba","Past":"skubėjo","Translation":"to hurry"},{"Infinitive":"kalbėti","Present":"kalba","Past":"kalbėjo","Translation":"to speak"},{"Infinitive":"studijuoti","Present":"studijuoja","Past":"studijavo","Translation":"to learn"},{"Infinitive":"skambinti","Present":"skambina","Past":"skambino","Translation":"to call"},{"Infinitive":"susipažinti","Present":"susipažįsta","Past":"susipažino","Translation":"to familiarize"},{"Infinitive":"kainuoti","Present":"kainuoja","Past":"kainavo","Translation":"to cost"},{"Infinitive":"mokėti","Present":"moka","Past":"mokėjo","Translation":"to know/to pay"},{"Infinitive":"parduoti","Present":"parduoda","Past":"pardavė","Translation":"to sell"},{"Infinitive":"pirkti","Present":"perka","Past":"pirko","Translation":"to buy"},{"Infinitive":"gerti","Present":"geria","Past":"gėrė","Translation":"to drink"},{"Infinitive":"laukti","Present":"laukia","Past":"laukė","Translation":"to wait"},{"Infinitive":"žaisti","Present":"žaidžia","Past":"žaidė","Translation":"to play"},{"Infinitive":"kviesti","Present":"kviečia","Past":"kvietė","Translation":"to invite"},{"Infinitive":"reikėti","Present":"reikia","Past":"reikėjo","Translation":"to need/must"},{"Infinitive":"pasiilgti","Present":"pasiilgsta","Past":"pasiilgo","Translation":"to miss"},{"Infinitive":"atostogauti","Present":"atostogauja","Past":"atostogavo","Translation":"to go on vacation"},{"Infinitive":"ragauti","Present":"ragauja","Past":"ragavo","Translation":"to taste"},{"Infinitive":"pusryčiauti","Present":"pusryčiauja","Past":"pusryčiavo","Translation":"to have breakfast"},{"Infinitive":"pietauti","Present":"pietauja","Past":"pietavo","Translation":"to eat"},{"Infinitive":"vakarieniauti","Present":"vakarieniauja","Past":"vakarieniavo","Translation":"to have dinner"},{"Infinitive":"virti","Present":"verda","Past":"virė","Translation":"to cook"},{"Infinitive":"kepti","Present":"kepa","Past":"kepė","Translation":"to fry"},{"Infinitive":"gaminti","Present":"gamina","Past":"gamino","Translation":"to produce"}]';
// Setup leveller, content and buttons
var samples = JSON.parse(samplesAsJson).filter(verb => !!verb.Past);
samples = samples
.map(sample => ({...sample, Level:(1 + Math.floor(samples.indexOf(sample) / 9))}));
var samples1 = samples.filter(sample => sample.Level === 1);
var samples2 = samples.filter(sample => sample.Level === 2);
var samples3 = samples.filter(sample => sample.Level === 3);
var samples4 = samples.filter(sample => sample.Level === 4);
var samples5 = [...samples1, ...samples2, ...samples3, ...samples4]
.map(sample => ({...sample, Level:5}));
samples = [...samples1, ...samples2, ...samples3, ...samples4, ...samples5];
var leveller = CreateLevelledArray(
samples,
elem => elem.Level
);
var content = leveller.GetContent();
var fullButtonsElementHtml = leveller.RegenerateButtons();
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(); }
}
// Returns a string containing HTML like <div> Infinitive, Present, Past</div>
function BuildAnswer(sample){
var infinitive = "<span style='margin-right:30px'>" + sample.Infinitive + '</span>';
var present = "<span style='margin-right:30px'>" + sample.Present + '</span>';
var past = "<span>" + sample.Past + '</span>';
var content = '<div>' + infinitive + present + past + '</div>';
return content;
}
// Returns a string containing HTML like <div> Verb in Ennglish </div>
function BuildQuestion(sample){
return '<div>' + sample.Translation + '</div>';
}
function onAnswerRequest(){
// Show answer
var answerDiv = document.getElementById('Answer');
answerDiv.innerHTML = BuildAnswer(currentSample);
// Amend button text
var button = document.getElementById('NextActionButton');
button.innerText = 'Next';
// Amend notification
notification.Answer = answerDiv.innerHTML;
}
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');
divToAmend.innerHTML = BuildQuestion(currentSample);
// Amend notification
notification.Answer = null;
notification.Question = divToAmend.innerHTML;
}
function OnLevelButtonClick(button){
// Setup level
leveller.SetupLevel(button.value);
// Update innerHtml for level buttons div
let newHtml = leveller.RegenerateButtons("OnLevelButtonClick");
var buttonsElement = document.getElementById("levelButtonsDiv");
buttonsElement.innerHTML = newHtml;
// Update content
content = leveller.GetContent()
.filter(elem => elem.Level == leveller.CurrentLevel);
}
</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="exercise" class="exercise">
<div id='table' class='content'>
<div id='Question'> to wait </div>
<div id='Answer'> laukti laukia laukė </div>
<div id='Button'>
<button id='NextActionButton'
onclick="onNextActionButtonClick()">
Next
</button>
</div>
</div>
<div id="levelButtonsDiv" class="levelButtonsDiv"></div>
<script>
var buttonsElement = document.getElementById("levelButtonsDiv");
buttonsElement.innerHTML = leveller.RegenerateButtons("OnLevelButtonClick");
</script>
<div class="issueNotificationDiv">
<button id='notifyButton'
onclick="notify(notification.Question, notification.Answer)">
Tell about an error
</button>
</div>
</div>
</div>
</body>
</html>