| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185 |
- //Play sound
- $(document).on("click", ".main-sound-play", function (event) {
- console.log("main-sound-play click")
- playSound(this, cache_fcComplete);
- });
- var cache_fcComplete = function(){};
- function playSound(element, endSound = function(){}){
- cache_fcComplete = endSound;
- $(".main-sound-play.sound-active").removeClass('sound-active');
- var elCur = $(element);
- var src = $(element).attr('sound_url');
- var sound = $("#learning-main-audio");
- $(sound).find('source').attr('src', src);
- $(sound)[0].load();
- $(sound)[0].onloadeddata = function(){
- $(sound)[0].play();
- if(!$(elCur).hasClass('sound-active')){
- $(elCur).addClass('sound-active');
- }
- $(sound)[0].onended = function(){
- $(elCur).removeClass('sound-active');
- cache_fcComplete = function(){};
- endSound();
- };
- };
- }
- function soundAnswerRight(){
- $('.testing-answer-group').addClass('answer-right');
-
- $('.testing-answer-text-title').text($('.testing-answer-text-title').attr('right'));
- //Play sound right
- if($("#audio-answer-right").length > 0){
- $("#audio-answer-right")[0].load();
- $("#audio-answer-right")[0].onloadeddata = function(){
- $("#audio-answer-right")[0].play();
- };
- }
- }
- function soundAnswerWrong(){
- $('.testing-answer-group').removeClass('answer-right');
-
- $('.testing-answer-text-title').text($('.testing-answer-text-title').attr('wrong'));
- //Play sound wrong
- if($("#audio-answer-wrong").length > 0){
- $("#audio-answer-wrong")[0].load();
- $("#audio-answer-wrong")[0].onloadeddata = function(){
- $("#audio-answer-wrong")[0].play();
- };
- }
- }
- function isFunction(functionToCheck) {
- return functionToCheck && {}.toString.call(functionToCheck) === '[object Function]';
- }
- $(document).ready(function(){
- $('.btn-learning-pin-word').click(function(){
- var vocabulary = $('#hidden-topicid').val();
- var word = $('.exercise-current').attr('word');
- var definition = $('.exercise-current').attr('definition');
- $.ajax({
- url: urlConfig("pin-word"),
- data: {
- 'vocabulary' : vocabulary,
- 'word' : word,
- 'definition' : definition
- },
- type: "POST"
- }).success(function(data) {
- $('#modal-pin-word').html(data);
- $('#modal-pin-word').modal();
- });
- });
-
- //pin word button
- $(document).on('click','.md-pin-product-button.button-active',function(){
-
- if ($("input[name='rad_vocabulary_name']:checked").val()) {
- $(this).removeClass('button-active');
- var name = $("input[name='rad_vocabulary_name']:checked").val();
- var vocabulary = $('#hidden-topicid').val();
- var word = $('.exercise-current').attr('word');
- var definition = $('.exercise-current').attr('definition');
- $('#notify-word-exits').text('');
- $.ajax({
- url: urlConfig("pin-vocabulary-word"),
- data: {
- 'vocabulary' : vocabulary,
- 'word' : word,
- 'definition' : definition,
- 'name' : name
- },
- type: "POST"
-
- }).success(function(data) {
- if(data[0] == 3){
- $('#notify-word-exits').text(data[1]);
- $('#notify-word-exits').slideDown(200);
- }else{
- $('#modal-pin-word').modal('hide');
- if(data[0] == 0){
- $('#modal-pin-word').html(data);
- $('#modal-pin-word').modal();
- }else{
- $('body').append('<span class="toast-msg">'+data+'</span>');
- $(".toast-msg").fadeIn(400,function(){
- setTimeout(function(){
- $(".toast-msg").fadeOut(function(){
- $(".toast-msg").remove();
- });
- }, 2000);
- });
- }
-
-
-
-
- }
- });
- }
- });
- $(document).on('click','#button-create-product.button-active',function(){
- var name = $('#md-product-name').val();
- var cate = $('#md-product-type').val();
- if(name.trim() != ""){
- $(this).removeClass('button-active');
- var vocabulary = $('#hidden-topicid').val();
- var word = $('.exercise-current').attr('word');
- var definition = $('.exercise-current').attr('definition');
- $.ajax({
- url: urlConfig("pin-word-and-add-vocabulary"),
- data: {
- 'vocabulary' : vocabulary,
- 'word' : word,
- 'definition' : definition,
- 'name' : name,
- 'cate' : cate
- },
- type: "POST"
-
- }).success(function(data) {
-
- if(data[0] == 3){
- $('#notify-word-exits').text(data[1]);
- $('#notify-word-exits').slideDown(200);
- }else{
- $('#modal-pin-word').modal('hide');
- if(data[0] == 0){
- $('#modal-pin-word').html(data);
- $('#modal-pin-word').modal();
- }else{
- $('body').append('<span class="toast-msg">'+data+'</span>');
- $(".toast-msg").fadeIn(400,function(){
- setTimeout(function(){
- $(".toast-msg").fadeOut(function(){
- $(".toast-msg").remove();
- });
- }, 2000);
- });
- }
- }
- });
- }
-
-
-
- });
-
- });
|