| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381 |
- window.history.forward();
- $(document).ready(function () {
- updateProcess();
- });
- function updateProcess() {
- var total = parseInt($(".theory-data-list").attr('total'));
- var indexCur = parseInt($(".theory-data-list .theory-data-item.item-current").attr('index'));
- $(".theory-data-paginate .paginate-number.paginate-active").removeClass('paginate-active');
- $(".theory-data-paginate .paginate-item.paginate-current .paginate-number[index='" + indexCur + "']").addClass('paginate-active');
- $(".theory-data-list .theory-data-item.item-current").css('display', 'block');
- $(".theory-data-paginate .paginate-item.paginate-current").css('display', 'block');
- if (total > 0) {
- $(".theory-process .theory-process-bar").width((indexCur + 1) * 100 / total + '%');
- }
- if ($(".theory-data-list .theory-data-item.item-current .icon-sound").length > 0) {
- setTimeout(function () {
- playSound($(".theory-data-list .theory-data-item.item-current .icon-sound"));
- }, 700);
- }
- }
- $(document).on('click', '.icon-sound', function () {
- playSound($(this), cache_fcComplete);
- });
- var cache_fcComplete = function () { };
- var checkLoadAudio;
- function playSound(element, fcComplete = function () { }) {
- // Set function callback to function temp
- cache_fcComplete = fcComplete;
- stopSound();
- // Get link audio and element audio
- var src = $(element).attr('sound_url');
- var speaker = $('.speaker-audio-1')[0];
- if (src != undefined && src != "") {
- $(".exe-icon-sound").removeClass('sound-active');
- // Load audio
- $(speaker).attr('src', src);
- speaker.load();
- // Check audio load after 3s
- checkLoadAudio = setTimeout(function () {
- // Run callback
- fcComplete();
- // Remove function callback temp
- cache_fcComplete = function () { };
- }, 3000);
- // If audoo load success
- speaker.onloadeddata = function () {
- // Remove timeout
- clearTimeout(checkLoadAudio);
- // Play audio
- speaker.play();
- element.addClass('sound-active');
- // End audio
- speaker.onended = function () {
- element.removeClass('sound-active');
- // Run callback
- fcComplete();
- // Remove function callback temp
- cache_fcComplete = function () { };
- };
- };
- }
- }
- function stopSound() {
- $('.icon-sound.sound-active').removeClass('sound-active');
- ($('.speaker-audio-1')[0]).pause();
- clearTimeout(checkLoadAudio);
- }
- var checkClickNext = 1;
- // Button NEXT
- $(document).on('click', '.theory-bottom .button.button-next', function () {
- stopSound();
- if (checkClickNext == 1) {
- checkClickNext = 0;
- var divCurrent = $(".theory-data-item.item-current");
- var indexCur = parseInt($(divCurrent).attr('index'));
- var indexNext = indexCur + 1;
- console.log(indexNext);
- changeQuestion(divCurrent, indexNext);
- }
- });
- // Button PREV
- $(document).on('click', '.theory-bottom .button.button-prev', function () {
- stopSound();
- if (checkClickNext == 1) {
- checkClickNext = 0;
- var divCurrent = $(".theory-data-item.item-current");
- var indexCur = parseInt($(divCurrent).attr('index'));
- var indexPrev = indexCur - 1;
- changeQuestion(divCurrent, indexPrev);
- }
- });
- function changeQuestion(divCurrent, indexNext) {
- var total = parseInt($(".theory-data-list").attr('total'));
- var indexCur = parseInt($(divCurrent).attr('index'));
- if (indexNext >= 0 && indexNext < total && indexNext != indexCur) {
- var divShow = $(".theory-data-item[index='" + indexNext + "']");
- //if(divShow.length > 0){
- $(divShow).addClass('item-current');
- $(divCurrent).removeClass('item-current');
- var isPrev = 0;
- if (indexNext < indexCur) {
- isPrev = 1;
- }
- if (isPrev == 0) {
- $(divShow).removeClass('theory-hide-question prev');
- $(divCurrent).removeClass('theory-show-question prev');
- $(divShow).addClass('theory-show-question');
- $(divCurrent).addClass('theory-hide-question');
- } else {
- $(divShow).removeClass('theory-hide-question prev');
- $(divCurrent).removeClass('theory-show-question prev');
- $(divCurrent).addClass('theory-hide-question prev');
- $(divShow).addClass('theory-show-question prev');
- }
- // Show number paginate
- var typeDataNext = parseInt($(divShow).attr('typeData'));
- var paginateItemNext = $('.theory-data-paginate .paginate-item[typeData="' + typeDataNext + '"]');
- var paginateItemCur = $('.theory-data-paginate .paginate-item.paginate-current');
- var typeDataCur = parseInt($(paginateItemCur).attr('typeData'));
- if (typeDataNext != typeDataCur) {
- $(paginateItemNext).addClass('paginate-current');
- $(paginateItemCur).removeClass('paginate-current');
- if (isPrev == 0) {
- $(paginateItemNext).find('.paginate-item-cover').removeClass('theory-hide-question prev');
- $(paginateItemCur).find('.paginate-item-cover').removeClass('theory-show-question prev');
- $(paginateItemNext).find('.paginate-item-cover').addClass('theory-show-question');
- $(paginateItemCur).find('.paginate-item-cover').addClass('theory-hide-question');
- } else {
- $(paginateItemNext).find('.paginate-item-cover').removeClass('theory-hide-question prev');
- $(paginateItemCur).find('.paginate-item-cover').removeClass('theory-show-question prev');
- $(paginateItemCur).find('.paginate-item-cover').addClass('theory-hide-question prev');
- $(paginateItemNext).find('.paginate-item-cover').addClass('theory-show-question prev');
- }
- }
- setTimeout(function () {
- $(divCurrent).hide();
- if (typeDataNext != typeDataCur) {
- $(paginateItemCur).hide();
- }
- checkClickNext = 1;
- }, 600);
- updateProcess();
- //}else{
- // getDataTheory(indexNext, function(result){
- // if(result.length == 2){
- // if(result[0] == 'true'){
- // $(".theory-data-list").append(result[1]);
- // changeQuestion(divCurrent, indexNext);
- // }else if(result[0] == 'false'){
- // window.location.href = result[1];
- // }
- // }
- // });
- //}
- } else if (indexNext >= total) {
- window.location.href = $("#learning-theory-complete").val();
- } else {
- checkClickNext = 1;
- }
- }
- function getDataTheory(indexNext, fcGetdata) {
- $.ajaxSetup({
- headers: {
- 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
- }
- });
- $.ajax({
- url: $("#learning-theory-data").val(),
- type: "POST",
- data: {
- index: indexNext
- },
- success: function (result) {
- console.log(result);
- fcGetdata(result);
- }
- });
- }
- $(document).on('click', '.theory-data-paginate .paginate-number,.bullet-item ', function () {
- stopSound();
- if (checkClickNext == 1) {
- checkClickNext = 0;
- var divCurrent = $(".theory-data-item.item-current");
- var indexNext = parseInt($(this).attr('index'));
- changeQuestion(divCurrent, indexNext);
- }
- });
- $(document).ready(function () {
- //feedback
- //click feedback cancel button
- $('.cancel-fault').click(function () {
- $('.txt-fault').val('');
- $('#feedback-fault').modal('hide');
- });
- var checkOption = 1;
- $('.slt-fault').click(function (e) {
- checkOption = 0;
- $('.slt-fault-option').slideToggle();
- setTimeout(function () {
- checkOption = 1;
- }, 500);
- });
- $('#feedback-fault .modal-body').click(function () {
- if (checkOption == 1) {
- $('.slt-fault-option').slideUp();
- }
- });
- $('.slt-item').click(function () {
- var val = $(this).attr('value');
- $('.slt-fault span').attr('value', val);
- $('.slt-fault span').text($(this).text());
- });
- //feedback fault
- $('.send-fault').click(function () {
- var contentFault = $('.txt-fault').val();
- var fault = $('.slt-fault span').attr('value');
- var url = $(this).attr('link');
- if (contentFault.trim() == "") {
- return;
- }
- $('.txt-fault').val('');
- $.ajaxSetup({
- headers: {
- 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
- }
- });
- $.ajax({
- url: url,
- type: "POST",
- data: {
- 'fault_id': fault,
- 'content': contentFault
- },
- success: function (result) {
- if (result == 1) {
- $('.modal-content-feedback').css('display', 'none');
- $('.modal-content-thanks').css('display', 'block');
- $('.txt-fault').val('');
- setTimeout(function () {
- $('#feedback-fault').modal('hide')
- $('.modal-content-thanks').css('display', 'none');
- $('.modal-content-feedback').css('display', 'block');
- }, 3000);
- }
- }
- });
- });
- });
- // MORE SAMPLE
- //$(document).on('click', '.theory-data-content .data-button-more', function () {
- // var index = $(this).attr('index');
- // var link = $('#learning-theory-more-sample').val();
- // var modal = $("#more-sample-modal");
- // var modalIndex = $(modal).attr('index');
- // if (modalIndex == index) {
- // $("#more-sample-modal").modal();
- // } else {
- // $(modal).attr('index', index);
- // $.ajaxSetup({
- // headers: {
- // 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
- // }
- // });
- // $.ajax({
- // url: link,
- // type: "POST",
- // data: {
- // 'index': index
- // },
- // success: function (result) {
- // console.log(result);
- // if (result[0] == 'true') {
- // $(modal).html(result[1]);
- // modal.modal();
- // } else if (result[0] == 'false') {
- // window.location.href = result[1];
- // }
- // }
- // });
- // }
- //});
|