Optional feedback, timer and counter

pull/41/head
Jørgen Follestad 2019-02-17 23:53:09 +01:00 committed by GitHub
parent db6a3c33da
commit 8eaf7512b6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 24 additions and 11 deletions

View File

@ -37,7 +37,7 @@ H5P.MemoryGame = (function (EventDispatcher, $) {
feedback: 'Good work!', feedback: 'Good work!',
tryAgain: 'Reset', tryAgain: 'Reset',
closeLabel: 'Close', closeLabel: 'Close',
label: 'Memory Game. Find the matching cards.', label: 'Memory Game. Find the matching cards.',
done: 'All of the cards have been found.', done: 'All of the cards have been found.',
cardPrefix: 'Card %num: ', cardPrefix: 'Card %num: ',
cardUnturned: 'Unturned.', cardUnturned: 'Unturned.',
@ -458,19 +458,32 @@ H5P.MemoryGame = (function (EventDispatcher, $) {
appendTo: $bottom appendTo: $bottom
}); });
$feedback = $('<div class="h5p-feedback">' + parameters.l10n.feedback + '</div>').appendTo($bottom); $feedback = $('<div class="h5p-feedback">' + '<div class="h5p-statusLine" id="h5p-showFeedback" hidden="true">' + parameters.l10n.feedback + '</div>'+ '</div>').appendTo($bottom);
if(parameters.behaviour && parameters.behaviour.showFeedback){
$feedback.find('div#h5p-showFeedback').show();
}
// Add status bar // Add status bar
var $status = $('<dl class="h5p-status">' + var $status = $('<dl class="h5p-status">' + '<div class="h5p-statusLine" id="h5p-showTime" hidden="true">' +
'<dt>' + parameters.l10n.timeSpent + ':</dt>' + '<dt>' + parameters.l10n.timeSpent + ':</dt>' +
'<dd class="h5p-time-spent"><time role="timer" datetime="PT0M0S">0:00</time><span class="h5p-memory-hidden-read">.</span></dd>' + '<dd class="h5p-time-spent"><time role="timer" datetime="PT0M0S">0:00</time><span class="h5p-memory-hidden-read">.</span></dd>' +
'<dt>' + parameters.l10n.cardTurns + ':</dt>' + '</div>' + '<div class="h5p-statusLine" id="h5p-showTurns" hidden="true">' + '<dt>' + parameters.l10n.cardTurns + ':</dt>' +
'<dd class="h5p-card-turns">0<span class="h5p-memory-hidden-read">.</span></dd>' + '<dd class="h5p-card-turns">0<span class="h5p-memory-hidden-read">.</span></dd>' +
'</dl>').appendTo($bottom); '</div>' + '</dl>').appendTo($bottom);
timer = new MemoryGame.Timer($status.find('time')[0]); timer = new MemoryGame.Timer($status.find('time')[0]);
counter = new MemoryGame.Counter($status.find('.h5p-card-turns')); counter = new MemoryGame.Counter($status.find('.h5p-card-turns'));
popup = new MemoryGame.Popup($container, parameters.l10n); popup = new MemoryGame.Popup($container, parameters.l10n);
if (parameters.behaviour){
if(parameters.behaviour.showTime){
$status.find('div#h5p-showTime').show();
}
if(parameters.behaviour.showTurns){
$status.find('div#h5p-showTurns').show();
}
}
$container.click(function () { $container.click(function () {
popup.close(); popup.close();