Whispeak: Add custom timer - refs BT#17415

pull/3648/head
Angel Fernando Quiroz Campos 5 years ago
parent a2192668ba
commit 91de17615c
  1. 1
      plugin/whispeakauth/Controller/AuthenticationController.php
  2. 1
      plugin/whispeakauth/Controller/EnrollmentController.php
  3. 53
      plugin/whispeakauth/assets/js/RecordAudio.js

@ -348,7 +348,6 @@ class AuthenticationController extends BaseController
$htmlHeadXtra[] = api_get_js('rtc/RecordRTC.js');
$htmlHeadXtra[] = api_get_js_simple(api_get_path(WEB_PLUGIN_PATH).'whispeakauth/assets/js/RecordAudio.js');
$htmlHeadXtra[] = api_get_js('epiclock/javascript/jquery.epiclock.min.js');
$pageTitle = $this->plugin->get_title();

@ -98,7 +98,6 @@ class EnrollmentController extends BaseController
$htmlHeadXtra[] = api_get_js('rtc/RecordRTC.js');
$htmlHeadXtra[] = api_get_js_simple(api_get_path(WEB_PLUGIN_PATH).'whispeakauth/assets/js/RecordAudio.js');
$htmlHeadXtra[] = api_get_js('epiclock/javascript/jquery.epiclock.min.js');
$pageTitle = $this->plugin->get_lang('EnrollmentTitle');

@ -1,6 +1,53 @@
/* For licensing terms, see /license.txt */
window.RecordAudio = (function () {
var timerInterval = 0,
$txtTimer = null;
function startTimer() {
stopTimer();
$txtTimer = $('#txt-timer');
$txtTimer.text('00:00').css('visibility', 'visible');
var timerData = {
hour: 0,
minute: 0,
second: 0
};
timerInterval = setInterval(function(){
timerData.second++;
if (timerData.second >= 60) {
timerData.second = 0;
timerData.minute++;
}
$txtTimer.text(
function () {
var txtSeconds = timerData.minute < 10 ? '0' + timerData.minute : timerData.minute,
txtMinutes = timerData.second < 10 ? '0' + timerData.second : timerData.second;
return txtSeconds + ':' + txtMinutes;
}
);
}, 1000);
}
function stopTimer() {
if (timerInterval) {
clearInterval(timerInterval);
}
if ($txtTimer) {
$txtTimer.css('visibility', 'hidden');
}
}
function useRecordRTC(rtcInfo) {
$(rtcInfo.blockId).show();
@ -87,7 +134,8 @@ window.RecordAudio = (function () {
tagAudio.removeClass('show').parents('#audio-wrapper').addClass('hidden');
$('.fa-microphone').addClass('text-danger');
$('#txt-timer').epiclock({mode: $.epiclock.modes.countup, format: 'e:s'});
startTimer();
}
function errorCallback(error) {
@ -115,7 +163,8 @@ window.RecordAudio = (function () {
}
$('.fa-microphone').removeClass('text-danger');
$('#txt-timer').text('');
stopTimer();
recordRTC.stopRecording(function (audioURL) {
tagAudio.prop('src', audioURL);

Loading…
Cancel
Save