Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Oxoron committed Jan 27, 2024
2 parents 7e54c8d + f2f334e commit bce4a84
Showing 1 changed file with 141 additions and 0 deletions.
141 changes: 141 additions & 0 deletions VocabularyPlacesInTheCity.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
<!DOCTYPE html>
<html>
<head>
<title>
LT Exercise -- Places in the City -- EnLt
</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 samplesAsJson1 = '[{"En":"embassy", "Lt":"ambasada"},{"En":"bank", "Lt":"bankas"},{"En":"centre", "Lt":"centras"},{"En":"excursion", "Lt":"ekskursija"},{"En":"fountain", "Lt":"fontanas"},{"En":"cathedral", "Lt":"katedra"},{"En":"cafe", "Lt":"kavinė"},{"En":"club", "Lt":"klubas"},{"En":"museum", "Lt":"muziejus"},{"En":"park", "Lt":"parkas"},{"En":"post office", "Lt":"paštas"},{"En":"restaurant", "Lt":"restoranas"},{"En":"sports klub", "Lt":"sporto klubas"},{"En":"theatre", "Lt":"teatras"}]';
var samplesAsJson2 = '[{"En":"bus station", "Lt":"autobusu stotis"},{"En":"castle", "Lt":"pilis"},{"En":"monument", "Lt":"paminklas"},{"En":"shop", "Lt":"parduotuvė"},{"En":"bus stop", "Lt":"stotelė"},{"En":"way", "Lt":"kelias"},{"En":"bridge", "Lt":"tiltas"},{"En":"river", "Lt":"upė"},{"En":"church", "Lt":"bažnyčia"},{"En":"zoo", "Lt":"zoological sodas"},{"En":"train station", "Lt":"geležinkelio stotis"},{"En":"hotel", "Lt":"viešbutis"},{"En":"market", "Lt":"turgus"},{"En":"sea", "Lt":"jūra"},{"En":"village", "Lt":"kaimas"}]';
var samplesAsJson3 = '[{"En":"bookshop", "Lt":"knygynas"},{"En":"town hall", "Lt":"rotušė"},{"En":"room", "Lt":"kambarys"},{"En":"bakery", "Lt":"kepyklėlė"},{"En":"cinema", "Lt":"kina teatras"},{"En":"hospital", "Lt":"ligoninė"},{"En":"school", "Lt":"mokykla"},{"En":"dormitory", "Lt":"bendrabutis"},{"En":"pool", "Lt":"baseinas"},{"En":"crossroad", "Lt":"sankryža"},{"En":"traffic lights", "Lt":"šviesoforas"},{"En":"library", "Lt":"biblioteka"},{"En":"office", "Lt":"biuras"}]';

// Get arrays of objects {En, Lt, Level}
var samples1 = JSON.parse(samplesAsJson1)
.map((elem)=>({...elem, Level:1}));
var samples2 = JSON.parse(samplesAsJson2)
.map((elem)=>({...elem, Level:2}));
var samples3 = JSON.parse(samplesAsJson3)
.map((elem)=>({...elem, Level:3}));
var samples4 = [...samples1, ...samples2, ...samples3]
.map((elem) => ({...elem, Level:4}));
var samples = [...samples1, ...samples2, ...samples3, ...samples4];

var leveller = CreateLevelledArray(
samples,
elem => elem.Level
);
var content = leveller.GetContent();
var fullButtonsElementHtml = leveller.RegenerateButtons();

var currentSample = samples1[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;
}

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='table' class='content'>
<div id='Question'> Theater </div>
<div id='Answer'> Teatras </div>
<div id='Button'>
<button id='NextActionButton'
onclick="onNextActionButtonClick()">
Next
</button>
</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 bce4a84

Please sign in to comment.