ar dt = allAudios[position].duration; if(ct / dt >= 0.25 && arrayV25Audio[position]==false){ //console.log("25% reached " + allAudios[position].id); arrayV25Audio[position]=true; // $.get( "event.php?category=" + documentPath +"&action="+ allAudios[position].id + "&label=percentage_25", function( data ) { // }); } if(ct / dt >= 0.50 && arrayV50Audio[position]==false){ //console.log("50% reached " + allAudios[position].id); arrayV50Audio[position]=true; // $.get( "event.php?category=" + documentPath +"&action="+ allAudios[position].id + "&label=percentage_50", function( data ) { // }); } if(ct / dt >= 0.75 && arrayV75Audio[position]==false){ //console.log("75% reached " + allAudios[position].id); arrayV75Audio[position]=true; // $.get( "event.php?category=" + documentPath +"&action="+ allAudios[position].id + "&label=percentage_75", function( data ) { // }); } } //Functions of videos function videoPlay (position) { if(arrayFirstPlayVideo[position] == true){ // $.get( "event.php?category=" + documentPath +"&action=" + allVideos[position].id + "&label=play", function( data ) { // }); arrayFirstPlayVideo[position] = false; } else{ // $.get( "event.php?category=" + documentPath +"&action=" + allVideos[position].id + "&label=resume", function( data ) { // }); } } function videoEnd (position) { // $.get( "event.php?category=" + documentPath +"&action=" + allVideos[position].id + "&label=finished", function( data ) { // }); } function videoTimeUpdate (position) { var ct = allVideos[position].currentTime; var dt = allVideos[position].duration; if(ct / dt >= 0.25 && arrayV25Video[position]==false){ //console.log("25% reached " + allAudios[position].id); arrayV25Video[position]=true; // $.get( "event.php?category=" + documentPath +"&action=" + allVideos[position].id + "&label=percentage_25", function( data ) { // }); } if(ct / dt >= 0.50 && arrayV50Video[position]==false){ //console.log("50% reached " + allAudios[position].id); arrayV50Video[position]=true; // $.get( "event.php?category=" + documentPath +"&action=" + allVideos[position].id + "&label=percentage_50", function( data ) { // }); } if(ct / dt >= 0.75 && arrayV75Video[position]==false){ //console.log("75% reached " + allAudios[position].id); arrayV75Video[position]=true; // $.get( "event.php?category=" + documentPath +"&action=" + allVideos[position].id + "&label=percentage_75", function( data ) { // }); } } function preparePhone (phone) { phone = phone || ""; // if null, then replace with blank phone = phone.trim(); if (phone.length == 8) { // assuming the phone number doesn't have the area code phone = "502" + phone; } if (phone.length == 11 && phone.startsWith("502")) { // if the phone is correct return phone; } return null; } function myFunction(){ var phone = ""; phone = preparePhone(phone); if (phone != null) { return submitForm({phone:phone}); } var pfid = ""; if (pfid != "") { return submitForm({pfid:pfid}); } } function submitForm(params) { // $.post( "event.php", params) // .done(function(data) { // alert("Te has suscrito exitosamente!" ); // }) // .fail(function(data) { // alert("Estamos teniendo problemas, intenta de nuevo más tarde" ); // }); } function checkIfHasInternet() { $.get("https://www.google.com/", function(data, status){ console.log(data); console.log(status); }); return false; } // checkIfHasInternet();