Changeset 2456250
- Timestamp:
- 01/14/2021 11:29:11 AM (5 years ago)
- Location:
- dial-voyants
- Files:
-
- 2 edited
-
tags/2.7/assets/js/voyant.js (modified) (1 diff)
-
trunk/assets/js/voyant.js (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
dial-voyants/tags/2.7/assets/js/voyant.js
r2456235 r2456250 1 1 (function($){ 2 // consulter voyant 3 $('button.libre').on('click',function(){ 4 var consultType = $(this).data('type'); 5 $("input[name='typeConsult']").val(consultType); 6 $('#form').submit(); 7 }); 8 9 $('#forfait').on('click',function(){ 10 $("input[name='typeConsult']").val("tel-forfait"); 11 $('#form').submit(); 12 }); 13 14 15 function VoyantEtat(){ 16 var idVoyant = $('#form').data('id'); 17 var data = {_ajax_nonce: ajax.nonce_field, //nonce 18 action: "load_etat_voyant", 19 idVoyant:idVoyant 20 21 }; 22 23 $.ajax({ 24 type: "POST", 25 url: ajax.ajax_url, 26 cache:false, 27 data: data, 28 success: function(data){ 29 if(data.etat){ 30 var elems = $('.btn-consultation:not([data-type="email"])'); 31 elems.each(function(index,item){ 32 33 if(data.etat=="libre" || data.etat=="occupe"){ 34 35 item.className = "btn-consultation "+data.etat; 36 if(data.etat=="occupe"){ 37 item.innerText = "En consultation"; 38 }else{ 39 if(item.getAttribute('data-type')==="chat"){ 40 item.innerText = "Voyance par tchat"; 41 }else{ 42 item.innerText = "Lancer l'appel"; 43 } 44 } 45 }else{ 46 item.className = "btn-consultation hors-ligne"; 47 } 48 }); 49 if($("#button-disp").length){ 50 51 var button = $("#button-disp"); 52 if(data.etat=="libre" || data.etat=="occupe") { 53 54 button.attr("class","d-block w-50 voyant-status mb-2 p-1 "+data.etat); 55 if(data.etat=="occupe"){ 56 button.text("En consultation"); 57 }else{ 58 button.text("Disponible"); 59 } 60 61 } 62 else{ 63 button.text(data.etat); 64 65 button.attr("class","d-block w-50 voyant-status mb-2 p-1 hors-ligne"); 66 } 67 } 68 69 } 70 71 }, 72 error:function( XHR, textStatus, errorThrown){ 73 console.log(errorThrown,textStatus,errorThrown); 74 } 75 76 }); 77 } 78 setInterval(VoyantEtat,30000); 79 80 // sidebar pagination 81 function arrowCheck(index,length){ 82 83 if(index==0){ 84 $('.arrow.left').addClass('d-none'); 85 }else{ 86 $('.arrow.left').removeClass('d-none'); 87 } 88 if(index==length-1){ 89 $('.arrow.right').addClass('d-none'); 90 }else{ 91 $('.arrow.right').removeClass('d-none'); 92 } 93 } 94 95 if($('.sidebar-block-voyants').length!=0){ 96 $('.sidebar-block-voyants:not(:first)').addClass('d-none'); 97 $('.sidebar-block-voyants').first().addClass('d-block'); 98 var index = $('.sidebar-block-voyants.d-block').index(); 99 var length = $('.sidebar-block-voyants').length; 100 arrowCheck(index,length); 101 102 // right arrow 103 $('.sidebar-pagination .arrow.right').on('click',function(){ 104 var current = $('.sidebar-block-voyants.d-block'); 105 var index = $('.sidebar-block-voyants.d-block').index(); 106 current.removeClass('d-block').addClass('d-none'); 107 $('.sidebar-block-voyants').eq(index+1).removeClass('d-none').addClass('d-block'); 108 var newindex = $('.sidebar-block-voyants.d-block').index(); 109 arrowCheck(newindex,length); 110 111 }); 112 113 // left arrow 114 $('.sidebar-pagination .arrow.left').on('click',function(){ 115 var current = $('.sidebar-block-voyants.d-block'); 116 var index = $('.sidebar-block-voyants.d-block').index(); 117 current.removeClass('d-block').addClass('d-none'); 118 $('.sidebar-block-voyants').eq(index-1).removeClass('d-none').addClass('d-block'); 119 var newindex = $('.sidebar-block-voyants.d-block').index(); 120 arrowCheck(newindex,length); 121 122 }); 123 124 125 } 126 127 /* forfait voyance */ 128 var packs= ['73','64','65','66','67','70']; 129 $('#forfaits-blocks .forfait-block img').each(function(index,item){ 130 item.dataset.id =packs[index]; 131 }); 132 $('#forfaits-blocks .forfait-block img').click(function(){ 133 var id = $(this).data('id'); 134 $("#forfaitForm input[name='forfait']").val(id); 135 $('#forfaitForm').submit(); 136 }); 137 138 /* audio controls */ 139 var audio = $('audio')[0]; 140 141 audio.addEventListener('timeupdate',function(e){ 142 var time = MediaTime(e.target); 143 $('#audio-time').text(time); 144 }); 145 146 147 audio.addEventListener('ended',function(e){ 148 console.log('ended'); 149 audio.currentTime=0; 150 $('#audio-control').removeClass('dashicons-controls-pause').addClass('dashicons-controls-play'); 151 $('#audio-time').text( MediaTime(e.target)); 2 // consulter voyant 3 $('button.libre').on('click',function(){ 4 var consultType = $(this).data('type'); 5 $("input[name='typeConsult']").val(consultType); 6 $('#form').submit(); 152 7 }); 153 8 154 $('#audio-control').on('click',function(){ 155 156 if($(this).hasClass('dashicons-controls-play')){ 157 $(this).removeClass('dashicons-controls-play').addClass('dashicons-controls-pause'); 158 audio.play(); 159 console.log(audio.currentTime); 160 }else{ 161 $(this).removeClass('dashicons-controls-pause').addClass('dashicons-controls-play'); 162 audio.pause(); 9 $('#forfait').on('click',function(){ 10 $("input[name='typeConsult']").val("tel-forfait"); 11 $('#form').submit(); 12 }); 13 14 15 function VoyantEtat(){ 16 var idVoyant = $('#form').data('id'); 17 var data = {_ajax_nonce: ajax.nonce_field, //nonce 18 action: "load_etat_voyant", 19 idVoyant:idVoyant 20 21 }; 22 23 $.ajax({ 24 type: "POST", 25 url: ajax.ajax_url, 26 cache:false, 27 data: data, 28 success: function(data){ 29 if(data.etat){ 30 var elems = $('.btn-consultation:not([data-type="email"])'); 31 elems.each(function(index,item){ 32 33 if(data.etat=="libre" || data.etat=="occupe"){ 34 35 item.className = "btn-consultation "+data.etat; 36 if(data.etat=="occupe"){ 37 item.innerText = "En consultation"; 38 }else{ 39 if(item.getAttribute('data-type')==="chat"){ 40 item.innerText = "Voyance par tchat"; 41 }else{ 42 item.innerText = "Lancer l'appel"; 43 } 44 } 45 }else{ 46 item.className = "btn-consultation hors-ligne"; 47 } 48 }); 49 if($("#button-disp").length){ 50 51 var button = $("#button-disp"); 52 if(data.etat=="libre" || data.etat=="occupe") { 53 54 button.attr("class","d-block w-50 voyant-status mb-2 p-1 "+data.etat); 55 if(data.etat=="occupe"){ 56 button.text("En consultation"); 57 }else{ 58 button.text("Disponible"); 59 } 60 61 } 62 else{ 63 button.text(data.etat); 64 65 button.attr("class","d-block w-50 voyant-status mb-2 p-1 hors-ligne"); 66 } 67 } 68 69 } 70 71 }, 72 error:function( XHR, textStatus, errorThrown){ 73 console.log(errorThrown,textStatus,errorThrown); 74 } 75 76 }); 163 77 } 78 setInterval(VoyantEtat,30000); 79 80 // sidebar pagination 81 function arrowCheck(index,length){ 82 83 if(index==0){ 84 $('.arrow.left').addClass('d-none'); 85 }else{ 86 $('.arrow.left').removeClass('d-none'); 87 } 88 if(index==length-1){ 89 $('.arrow.right').addClass('d-none'); 90 }else{ 91 $('.arrow.right').removeClass('d-none'); 92 } 93 } 94 95 if($('.sidebar-block-voyants').length!=0){ 96 $('.sidebar-block-voyants:not(:first)').addClass('d-none'); 97 $('.sidebar-block-voyants').first().addClass('d-block'); 98 var index = $('.sidebar-block-voyants.d-block').index(); 99 var length = $('.sidebar-block-voyants').length; 100 arrowCheck(index,length); 101 102 // right arrow 103 $('.sidebar-pagination .arrow.right').on('click',function(){ 104 var current = $('.sidebar-block-voyants.d-block'); 105 var index = $('.sidebar-block-voyants.d-block').index(); 106 current.removeClass('d-block').addClass('d-none'); 107 $('.sidebar-block-voyants').eq(index+1).removeClass('d-none').addClass('d-block'); 108 var newindex = $('.sidebar-block-voyants.d-block').index(); 109 arrowCheck(newindex,length); 110 111 }); 112 113 // left arrow 114 $('.sidebar-pagination .arrow.left').on('click',function(){ 115 var current = $('.sidebar-block-voyants.d-block'); 116 var index = $('.sidebar-block-voyants.d-block').index(); 117 current.removeClass('d-block').addClass('d-none'); 118 $('.sidebar-block-voyants').eq(index-1).removeClass('d-none').addClass('d-block'); 119 var newindex = $('.sidebar-block-voyants.d-block').index(); 120 arrowCheck(newindex,length); 121 122 }); 123 124 125 } 126 127 /* forfait voyance */ 128 var packs= ['73','64','65','66','67','70']; 129 $('#forfaits-blocks .forfait-block img').each(function(index,item){ 130 item.dataset.id =packs[index]; 131 }); 132 $('#forfaits-blocks .forfait-block img').click(function(){ 133 var id = $(this).data('id'); 134 $("#forfaitForm input[name='forfait']").val(id); 135 $('#forfaitForm').submit(); 136 }); 137 138 /* audio controls */ 139 140 var audio = $('audio')[0]; 141 if(audio.length){ 142 audio.addEventListener('timeupdate',function(e){ 143 var time = MediaTime(e.target); 144 $('#audio-time').text(time); 145 }); 146 147 148 audio.addEventListener('ended',function(e){ 149 console.log('ended'); 150 audio.currentTime=0; 151 $('#audio-control').removeClass('dashicons-controls-pause').addClass('dashicons-controls-play'); 152 $('#audio-time').text( MediaTime(e.target)); 153 }); 164 154 165 }); 166 167 168 function MediaTime(audio) { 169 var minutes = Math.floor(audio.currentTime / 60); 170 var seconds = Math.floor(audio.currentTime - minutes * 60); 171 var minuteValue; 172 var secondValue; 173 174 if (minutes < 10) { 175 minuteValue = '0' + minutes; 176 } else { 177 minuteValue = minutes; 155 $('#audio-control').on('click',function(){ 156 157 if($(this).hasClass('dashicons-controls-play')){ 158 $(this).removeClass('dashicons-controls-play').addClass('dashicons-controls-pause'); 159 audio.play(); 160 console.log(audio.currentTime); 161 }else{ 162 $(this).removeClass('dashicons-controls-pause').addClass('dashicons-controls-play'); 163 audio.pause(); 164 } 165 166 }); 178 167 } 179 180 if (seconds < 10) { 181 secondValue = '0' + seconds; 182 } else { 183 secondValue = seconds; 184 } 185 186 var mediaTime = minuteValue + ':' + secondValue; 187 return mediaTime; 188 } 189 190 }(jQuery)); 168 169 170 function MediaTime(audio) { 171 var minutes = Math.floor(audio.currentTime / 60); 172 var seconds = Math.floor(audio.currentTime - minutes * 60); 173 var minuteValue; 174 var secondValue; 175 176 if (minutes < 10) { 177 minuteValue = '0' + minutes; 178 } else { 179 minuteValue = minutes; 180 } 181 182 if (seconds < 10) { 183 secondValue = '0' + seconds; 184 } else { 185 secondValue = seconds; 186 } 187 188 var mediaTime = minuteValue + ':' + secondValue; 189 return mediaTime; 190 } 191 192 }(jQuery)); -
dial-voyants/trunk/assets/js/voyant.js
r2456235 r2456250 137 137 138 138 /* audio controls */ 139 139 140 var audio = $('audio')[0]; 140 141 if(audio.length){ 141 142 audio.addEventListener('timeupdate',function(e){ 142 143 var time = MediaTime(e.target); … … 164 165 165 166 }); 167 } 166 168 167 169
Note: See TracChangeset
for help on using the changeset viewer.