Skip to content

Commit

Permalink
Add meals vocabulary. TBD: fill gaps, reorganize grouping, review, ad…
Browse files Browse the repository at this point in the history
…d to ToC.
  • Loading branch information
Oxoron committed Mar 3, 2024
1 parent 46ea995 commit a056212
Showing 1 changed file with 147 additions and 0 deletions.
147 changes: 147 additions & 0 deletions VocabularyMeals.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
<!DOCTYPE html>
<html>
<head>
<title>
LT Exercise -- Meals -- 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 = '[{"Meals":"agurkas","En":"cucumber","Category":"daržovės"},{"Meals":"burokelis","En":"beetroot","Category":"daržovės"},{"Meals":"česnakas","En":"garlic","Category":"daržovės"},{"Meals":"kopūstas","En":"cabbage","Category":"daržovės"},{"Meals":"morka","En":"carrot","Category":"daržovės"},{"Meals":"paprika","En":"paprika","Category":"daržovės"},{"Meals":"pomidoras","En":"tomato","Category":"daržovės"},{"Meals":"svogūnas","En":"onion","Category":"daržovės"},{"Meals":"pupelė","En":"bean","Category":"daržovės"},{"Meals":"bulvė","En":"potato","Category":"daržovės"},{"Meals":"salota","En":"salad","Category":"daržovės"},{"Meals":"ryžiai","En":"rice","Category":"daržovės"},{"Meals":"banbelė","En":"bun/pastry","Category":"duonos produktai"},{"Meals":"duona","En":"bread","Category":"duonos produktai"},{"Meals":"makaronai","En":"","Category":"duonos produktai"},{"Meals":"miltai","En":"","Category":"duonos produktai"},{"Meals":"arbata","En":"tea","Category":"gėrimai"},{"Meals":"kava","En":"coffee","Category":"gėrimai"},{"Meals":"vanduo","En":"water","Category":"gėrimai"},{"Meals":"sultys","En":"juice","Category":"gėrimai"},{"Meals":"vynas","En":"wine","Category":"gėrimai"},{"Meals":"aliejus","En":"oil","Category":"kiti produktai"},{"Meals":"druska","En":"salt","Category":"kiti produktai"},{"Meals":"kiaušinias","En":"egg","Category":"kiti produktai"},{"Meals":"padažas","En":"","Category":"kiti produktai"},{"Meals":"sriuba","En":"soup","Category":"kiti produktai"},{"Meals":"pipirai","En":"pepper","Category":"kiti produktai"},{"Meals":"jautiena","En":"beef","Category":"mėsa"},{"Meals":"kalakutiena","En":"turkey","Category":"mėsa"},{"Meals":"kepsnys","En":"steak, roast","Category":"mėsa"},{"Meals":"kiauliena","En":"pork","Category":"mėsa"},{"Meals":"kotletas","En":"meatball","Category":"mėsa"},{"Meals":"kumpis","En":"ham","Category":"mėsa"},{"Meals":"mėsa","En":"meat","Category":"mėsa"},{"Meals":"vištiena","En":"chicken","Category":"mėsa"},{"Meals":"žuvis","En":"fish","Category":"mėsa"},{"Meals":"dešra","En":"sausage","Category":"mėsa"},{"Meals":"grietinė","En":"sour cream","Category":"pieno produktai"},{"Meals":"grietinėlė","En":"cream","Category":"pieno produktai"},{"Meals":"jogurtas","En":"yoghurt","Category":"pieno produktai"},{"Meals":"ledai","En":"ice cream","Category":"pieno produktai"},{"Meals":"pienas","En":"milk","Category":"pieno produktai"},{"Meals":"sūris","En":"cheese","Category":"pieno produktai"},{"Meals":"sviestas","En":"butter","Category":"pieno produktai"},{"Meals":"varškė","En":"cottage cheese","Category":"pieno produktai"},{"Meals":"kremas","En":"","Category":"saldumynai ir konditerija"},{"Meals":"saldainis","En":"candies","Category":"saldumynai ir konditerija"},{"Meals":"sausainis","En":"bisquit, cookie","Category":"saldumynai ir konditerija"},{"Meals":"šokoladas","En":"chocolate","Category":"saldumynai ir konditerija"},{"Meals":"tortas","En":"cake","Category":"saldumynai ir konditerija"},{"Meals":"uogienė","En":"jam","Category":"saldumynai ir konditerija"},{"Meals":"cukrus","En":"sugar","Category":"saldumynai ir konditerija"},{"Meals":"medus","En":"honey","Category":"saldumynai ir konditerija"},{"Meals":"pyragas","En":"pie","Category":"saldumynai ir konditerija"},{"Meals":"braške","En":"strawberry","Category":"uogos"},{"Meals":"vyšnia","En":"cherry","Category":"uogos"},{"Meals":"vynuogė","En":"grape","Category":"uogos"},{"Meals":"apelsinas","En":"orange","Category":"vaisiai"},{"Meals":"bananas","En":"banana","Category":"vaisiai"},{"Meals":"citrina","En":"lemon","Category":"vaisiai"},{"Meals":"kriaušė","En":"pear","Category":"vaisiai"},{"Meals":"mandarinas","En":"tangerine","Category":"vaisiai"},{"Meals":"obuolys","En":"apple","Category":"vaisiai"},{"Meals":"persikas","En":"peach","Category":"vaisiai"},{"Meals":"slyva","En":"plum","Category":"vaisiai"}]';

// Setup leveller, content and buttons
var samples = JSON.parse(samplesAsJson);
var categories = samples.map((sample) => sample.Category);
var uniqueCategories = categories.filter((value, index, categories) => index === categories.indexOf(value));

var categoriesDict = uniqueCategories
.reduce((prev, current, index) => {
prev[current] = index;
return prev;
},
{});

uniqueCategories = uniqueCategories
.map((category) => ({Category: category, Level: uniqueCategories.indexOf(category)}));
samples = samples
.map((sample) => ({...sample, Level:categoriesDict[sample.Category]}));

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(); }
}

function onAnswerRequest(){
// Show answer
var answerDiv = document.getElementById('Answer');
answerDiv.innerHTML = currentSample.En;

// 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 = currentSample.Meals;

// 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'> vynuogė </div>
<div id='Answer'> grape </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>


0 comments on commit a056212

Please sign in to comment.