var urlROOT = "https://www.slidesacademy.com";
function removeAccents(strAccents) {
var strAccents = strAccents.split('');
var strAccentsOut = new Array();
var strAccentsLen = strAccents.length;
var accents = 'ÀÁÂÃÄÅàáâãäåÒÓÔÕÕÖØòóôõöøÈÉÊËèéêëðÇçÐÌÍÎÏìíîïÙÚÛÜùúûüÑñŠšŸÿýŽž';
var accentsOut = "AAAAAAaaaaaaOOOOOOOooooooEEEEeeeeeCcDIIIIiiiiUUUUuuuuNnSsYyyZz";
for (var y = 0; y < strAccentsLen; y++) {
if (accents.indexOf(strAccents[y]) != -1) {
strAccentsOut[y] = accentsOut.substr(accents.indexOf(strAccents[y]), 1);
} else {
strAccentsOut[y] = strAccents[y];
}
}
strAccentsOut = strAccentsOut.join('');
console.log(strAccentsOut);
return strAccentsOut;
}
function doLogin(){
var username = $("#username").val();
var password = $("#password").val();
var data = "u="+username+"&p="+password;
$.ajax({
type: "POST",
url: urlROOT+"/admin/doLogin.php",
data: data,
success:function(obj){
document.location.href = 'https://www.slidesacademy.com/admin';
},
});
}
function doLogout(){
var data = 'ac=LOGOUT';
$.ajax({
data:data,
url: urlROOT+'/ajax.php',
type:'post',
async:'false',
success:function(obj){
document.location.href = urlROOT;
},
error:function(){}
});
}
function updSlideDownloads(){
var id = $("#idSlide").val();
var data = 'ac=SETDWNLSLIDE&id='+id;
$.ajax({
data:data,
url: urlROOT+'/ajax.php',
type:'post',
async:'false',
success:function(obj){},
error:function(){}
});
}
function doCleanCache(){
var data = 'ac=CLCACHE';
$.ajax({
data:data,
url: urlROOT+'/ajax.php',
type:'post',
async:'false',
success:function(obj){},
error:function(){}
});
}
function doSaveSlide(id) {
if($('#titulo_es').val()==''){
alert('El título no puede estar vacío');
}else{
if($('#categoriesSlide').val()==''){
alert('Hay que seleccionar al menos 1 categoría');
}else{
if($('#imagenSlide').val()=='' && $('#imgSlideAct').val()==''){
alert('La imagen no puede estar vacía');
}else{
if(($('#pptSlide').val()=='' && $('#pptSlideAct').val()=='') && $('#slide').val()==''){
alert('El ppt y el slide no pueden estar vacíos');
}else{
var form = $('#frm_'+id)[0];
var data = new FormData(form);
$.ajax({
type: "POST",
enctype: 'multipart/form-data',
url: urlROOT+"/admin/admin_upload.php",
data: data,
processData: false,
contentType: false,
cache: false,
success: function (data) {
if(data == '0'){
alert('error al modificar un slide');
location.reload();
}else{
document.location.href = "https://www.slidesacademy.com/admin?id="+data;
}
},
error: function(requestObject, error, errorThrown) {
alert(error);
alert(errorThrown);
location.reload();
}
});
}
}
}
}
}
function doRemove(id){
var data = "ac=REMOVE&id="+id;
$.ajax({
type: "POST",
url: urlROOT+"/ajax.php",
data: data,
success: function(obj){
location.reload();
},
});
}
function replaceSelTextDeepl(){
var dictionary= {
"":"(tag_12)",
"":"(tag__12)"
};
for( var ptrn in dictionary){
$('#descripcion_es').val( $( '#descripcion_es' ).val().replace(new RegExp(ptrn ,"g"), dictionary[ptrn] ) );
$('#descripcion_en').val( $( '#descripcion_en' ).val().replace(new RegExp(ptrn ,"g"), dictionary[ptrn] ) );
$('#descripcion_de').val( $( '#descripcion_de' ).val().replace(new RegExp(ptrn ,"g"), dictionary[ptrn] ) );
$('#descripcion_fr').val( $( '#descripcion_fr' ).val().replace(new RegExp(ptrn ,"g"), dictionary[ptrn] ) );
$('#descripcion_it').val( $( '#descripcion_it' ).val().replace(new RegExp(ptrn ,"g"), dictionary[ptrn] ) );
$('#descripcion_nl').val( $( '#descripcion_nl' ).val().replace(new RegExp(ptrn ,"g"), dictionary[ptrn] ) );
$('#descripcion_pl').val( $( '#descripcion_pl' ).val().replace(new RegExp(ptrn ,"g"), dictionary[ptrn] ) );
$('#descripcion_pt').val( $( '#descripcion_pt' ).val().replace(new RegExp(ptrn ,"g"), dictionary[ptrn] ) );
$('#descripcion_ru').val( $( '#descripcion_ru' ).val().replace(new RegExp(ptrn ,"g"), dictionary[ptrn] ) );
}
}
function replaceSelText(tag,id){
var element = $("#"+id)[0];
var start = element.selectionStart;
var finish = element.selectionEnd;
var allText = element.value;
var sel = allText.substring(start, finish);
var newText = '';
if(sel.length){
if(tag=='b'){
newText=allText.substring(0, start)+""+sel+""+allText.substring(finish, allText.length);
}
element.value=newText;
}
}
function replaceSelTextBlog(tag,id){
var element = $("#"+id)[0];
var start = element.selectionStart;
var finish = element.selectionEnd;
var allText = element.value;
var allLength = element.value.length;
var sel = allText.substring(start, finish);
var newText = '';
if(sel.length){
if(tag=='b'){
newText=allText.substring(0, start)+""+sel+""+allText.substring(finish, allText.length);
}else if(tag=='h2'){
newText=allText.substring(0, start)+"
"+sel+"
"+allText.substring(finish, allText.length);
}else if(tag=='h3'){
newText=allText.substring(0, start)+""+sel+"
"+allText.substring(finish, allText.length);
}
element.value=newText;
}else{
if(tag=='shortcut'){
var start = element.selectionStart;
var finish = allLength;
var sel = allText.substring(0,start);
element.value=sel + '[fibonapps id="000" gallery="1"]' + ' ' + allText.substring(start,finish);
}else if(tag=='hr'){
var start = element.selectionStart;
var finish = allLength;
var sel = allText.substring(0,start);
element.value=sel + '
' + ' ' + allText.substring(start,finish);
}else if(tag=='iframe'){
var start = element.selectionStart;
var finish = allLength;
var sel = allText.substring(0,start);
element.value=sel + '' + ' ' + allText.substring(start,finish);
}else if(tag=='a'){
var start = element.selectionStart;
var finish = allLength;
var sel = allText.substring(0,start);
element.value=sel + '000' + ' ' + allText.substring(start,finish);
}else if(tag=='img'){
var start = element.selectionStart;
var finish = allLength;
var sel = allText.substring(0,start);
element.value=sel + '
' + ' ' + allText.substring(start,finish);
}
}
}
function doSave(id){
f = document.blog_post;
f.submit();
}
function doAltaManual(){
var idApp = "";
var tipoApp = ($("#tipoAppAlta").val()).trim();
var idGPlay = ($("#idGPlay").val()).trim();
var urlAlta = '';
if((idGPlay==='') || (tipoApp==='')){
alert('Faltan datos');
return;
}else{
urlAlta = urlROOT+"/crons/altaManual.php?id="+idApp+"&tipo="+tipoApp+"&idPlayStore="+idGPlay;
document.location.href = urlAlta;
}
}
function doAltaManual2(id,idGPlay){
var idApp = id;
var idGplay = idGPlay;
var tipoApp = ($("#tipoAppAlta_"+idApp).val()).trim();
var idGPlay = idGPlay.trim();
var urlAlta = '';
if((idGPlay==='') || (tipoApp==='')){
alert('Faltan datos');
return;
}else{
urlAlta = urlROOT+"/crons/altaManual.php?id="+idApp+"&tipo="+tipoApp+"&idPlayStore="+idGPlay;
document.location.href = urlAlta;
}
}
function doUpdate(existeEnGooglePlay){
var deeplChecked = $('#deeplChecked').prop('checked');
var adsChecked = $('#adsChecked').prop('checked');
var idFibo = $('#id_fibo').val();
var appExisteGPlay = existeEnGooglePlay;
var idFechaCreacion = $('#fecha_creacion').val();
var lastOldIDFibo = $('#lastOldIDFibo').val();
var url_android = $('#url_android').val();
var url_ios = $('#url_ios').val();
var url_windows = $('#url_windows').val();
var url_apk = $('#url_apk').val();
var url_amz = $('#url_amz').val();
var video_trailer = $('#video_trailer').val();
var video_trucos = $('#video_trucos').val();
var titulo_en = $('#titulo_en').val();
var descripcion_en = $('#descripcion_en').val();
var novedades_en = $('#novedades_en').val();
var titulo_es = $('#titulo_es').val();
var descripcion_es = $('#descripcion_es').val();
var novedades_es = $('#novedades_es').val();
var titulo_de = $('#titulo_de').val();
var descripcion_de = $('#descripcion_de').val();
var novedades_de = $('#novedades_de').val();
var titulo_fr = $('#titulo_fr').val();
var descripcion_fr = $('#descripcion_fr').val();
var novedades_fr = $('#novedades_fr').val();
var titulo_it = $('#titulo_it').val();
var descripcion_it = $('#descripcion_it').val();
var novedades_it = $('#novedades_it').val();
var titulo_pl = $('#titulo_pl').val();
var descripcion_pl = $('#descripcion_pl').val();
var novedades_pl = $('#novedades_pl').val();
var titulo_nl = $('#titulo_nl').val();
var descripcion_nl = $('#descripcion_nl').val();
var novedades_nl = $('#novedades_nl').val();
var titulo_pt = $('#titulo_pt').val();
var descripcion_pt = $('#descripcion_pt').val();
var novedades_pt = $('#novedades_pt').val();
var titulo_ru = $('#titulo_ru').val();
var descripcion_ru = $('#descripcion_ru').val();
var novedades_ru = $('#novedades_ru').val();
// si es nueva tiene que tener el titulo en ingles lleno
if(titulo_en.trim()==='' && parseInt(idFibo)>parseInt(lastOldIDFibo)){
alert("Es una APP nueva (en Inglés) y el título está vacío");
}else{
// si es antigua tiene que tener el título en español lleno
if(titulo_es.trim()==='' && parseInt(idFibo)<=parseInt(lastOldIDFibo)){
alert("Es una APP antigua (en Español) y el título está vacío");
}else{
var deepL = "";
if(deeplChecked==true){
deepL = 1;
}else{
deepL = 0;
}
var data = 'ac=MODIFICARAPP&deeplChecked='+deepL+'&idFibo='+idFibo+'&adsChecked='+adsChecked+'&appExisteGPlay='+appExisteGPlay+'&idFechaCreacion='+idFechaCreacion+'&url_android='+url_android+'&url_ios='+url_ios+'&url_windows='+url_windows+'&url_apk='+url_apk+'&url_amz='+url_amz+'&video_trailer='+video_trailer+'&video_trucos='+video_trucos+'&titulo_en='+encodeURIComponent(titulo_en)+'&descripcion_en='+encodeURIComponent(descripcion_en)+'&novedades_en='+encodeURIComponent(novedades_en)+'&titulo_es='+encodeURIComponent(titulo_es)+'&descripcion_es='+encodeURIComponent(descripcion_es)+'&novedades_es='+encodeURIComponent(novedades_es)+'&titulo_de='+encodeURIComponent(titulo_de)+'&descripcion_de='+encodeURIComponent(descripcion_de)+'&novedades_de='+encodeURIComponent(novedades_de)+'&titulo_fr='+encodeURIComponent(titulo_fr)+'&descripcion_fr='+encodeURIComponent(descripcion_fr)+'&novedades_fr='+encodeURIComponent(novedades_fr)+'&titulo_it='+encodeURIComponent(titulo_it)+'&descripcion_it='+encodeURIComponent(descripcion_it)+'&novedades_it='+encodeURIComponent(novedades_it)+'&titulo_pl='+encodeURIComponent(titulo_pl)+'&descripcion_pl='+encodeURIComponent(descripcion_pl)+'&novedades_pl='+encodeURIComponent(novedades_pl)+'&titulo_nl='+encodeURIComponent(titulo_nl)+'&descripcion_nl='+encodeURIComponent(descripcion_nl)+'&novedades_nl='+encodeURIComponent(novedades_nl)+'&titulo_pt='+encodeURIComponent(titulo_pt)+'&descripcion_pt='+encodeURIComponent(descripcion_pt)+'&novedades_pt='+encodeURIComponent(novedades_pt)+'&titulo_ru='+encodeURIComponent(titulo_ru)+'&descripcion_ru='+encodeURIComponent(descripcion_ru)+'&novedades_ru='+encodeURIComponent(novedades_ru);
console.log(data);
$.ajax({
data:data,
url: urlROOT+'/ajax.php',
type:'post',
async:'false',
success:function(obj){
location.reload();
},
error:function(){
alert('Error al modificar la APP');
}
});
}
}
}
function renewApp(id){
var idApp = id;
var data = "ac=RA&idApp="+idApp;
$.ajax({
type: "POST",
url: urlROOT+"/ajax.php",
data: data,
success: function(obj){},
});
}
function loadURL(){
$('#pTIT').val($('#search').val());
$('#pORD').val($('#order').val());
var idioma = $('#sIDI').val();
var generoSel = '';
if(($("#genres").length > 0)){
generoSel = $('#genres').val();
}
var tipoSel = '';
if(($("#pTIP").length > 0) && $('#pPAGE').val()!="H"){
tipoSel = $('#pTIP').val();
}
var titulo = $('#pTIT').val();
var orden = $('#pORD').val();
var pagina = $('#pPAG').val();
var url = urlROOT;
//if(idioma!=='' && idioma!='es'){ url += '/'+idioma; }
if(($("#genres").val() != "")){
tipoSel = $('#pTIP').val();
}
url = '/';
if(idioma!=='' && idioma!='es'){ url += idioma+'/'; }
/*
if($('#pPAGE').val()!='D') {
url += tipoSel;
}
*/
//alert(url);
/*
if($('#pPAGE').val()=='H' || $('#pPAGE').val()=='D' || $('#pPAGE').val()=='AC' || $('#pPAGE').val()=='CO' || $('#pPAGE').val()=='PR' || $('#pPAGE').val()=='CK') {
tipoSel = $('#pTIP').val();
url += tipoSel;
}
*/
tipoSel = $('#pTIP').val();
url += tipoSel;
//alert(url);
if(generoSel!==''){ url += '-'+generoSel; }
//alert(url);
if(titulo!==''){
url += '?pTit='+titulo;
if(orden!='' && orden!='FE'){
url += '&pOrd='+orden;
if(pagina!==''){
url += '&pPag='+pagina;
}
}else{
if(pagina!==''){
url += '&pPag='+pagina;
}
}
}else{
if(orden!='' && orden!='FE'){
url += '?pOrd='+orden;
if(pagina!==''){
url += '&pPag='+pagina;
}
}else{
if(pagina!==''){
url += '?pPag='+pagina;
}
}
}
url = removeAccents(url);
document.location.href = url;
}
function loadURL404(){
$('#pTIT').val($('#search404').val());
$('#pORD').val($('#order').val());
var idioma = $('#sIDI').val();
var generoSel = '';
if(($("#genres").length > 0)){
tipoSel = $('#pTIP').val();
generoSel = $('#genres').val();
}
var tipoSel = '';
if(($("#pTIP").length > 0) && $('#pPAGE').val()!="H"){
tipoSel = $('#pTIP').val();
}
var titulo = $('#pTIT').val();
var orden = $('#pORD').val();
var pagina = $('#pPAG').val();
var url = urlROOT;
//if(idioma!=='' && idioma!='es'){ url += '/'+idioma; }
if(($("#genres").val() != "")){
tipoSel = $('#pTIP').val();
}
url = '/';
if(idioma!=='' && idioma!='es'){ url += idioma+'/'; }
/*
if($('#pPAGE').val()!='D') {
url += tipoSel;
}
*/
/*
if($('#pPAGE').val()=='H' || $('#pPAGE').val()=='D') {
tipoSel = $('#pTIP').val();
url += tipoSel;
}
*/
tipoSel = $('#pTIP').val();
url += tipoSel;
if(generoSel!==''){ url += '-'+generoSel; }
if(titulo!==''){
url += '?pTit='+titulo;
if(orden!='' && orden!='FE'){
url += '&pOrd='+orden;
if(pagina!==''){
url += '&pPag='+pagina;
}
}else{
if(pagina!==''){
url += '&pPag='+pagina;
}
}
}else{
if(orden!='' && orden!='FE'){
url += '?pOrd='+orden;
if(pagina!==''){
url += '&pPag='+pagina;
}
}else{
if(pagina!==''){
url += '?pPag='+pagina;
}
}
}
url = removeAccents(url);
document.location.href = url;
}
function doFltRsp(){
loadURLM()
}
function loadURLM(){
$('#pTIT').val($('#searchM').val());
$('#pORD').val($('#orderM').val());
var idioma = $('#sIDI').val();
var generoSel = '';
if(($("#genresM").length > 0)){
tipoSel = $('#pTIP').val();
generoSel = $('#genresM').val();
}
var tipoSel = '';
if(($("#pTIP").length > 0) && $('#pPAGE').val()!="H"){
tipoSel = $('#pTIP').val();
}
var titulo = $('#pTIT').val();
var orden = $('#pORD').val();
var pagina = $('#pPAG').val();
var url = urlROOT;
//if(idioma!=='' && idioma!='es'){ url += '/'+idioma; }
if(($("#genres").val() != "")){
tipoSel = $('#pTIP').val();
}
url = '/';
if(idioma!=='' && idioma!='es'){ url += idioma+'/'; }
/*
if($('#pPAGE').val()!='D') {
url += tipoSel;
}
*/
/*
if($('#pPAGE').val()=='H' || $('#pPAGE').val()=='D') {
tipoSel = $('#pTIP').val();
url += tipoSel;
}
*/
tipoSel = $('#pTIP').val();
url += tipoSel;
if(generoSel!==''){ url += '-'+generoSel; }
if(titulo!==''){
url += '?pTit='+titulo;
if(orden!='' && orden!='FE'){
url += '&pOrd='+orden;
if(pagina!==''){
url += '&pPag='+pagina;
}
}else{
if(pagina!==''){
url += '&pPag='+pagina;
}
}
}else{
if(orden!='' && orden!='FE'){
url += '?pOrd='+orden;
if(pagina!==''){
url += '&pPag='+pagina;
}
}else{
if(pagina!==''){
url += '?pPag='+pagina;
}
}
}
url = removeAccents(url);
document.location.href = url;
}
function doContact(lg){
var nombre = ($("#nameContact").val()).trim();
var email = ($("#emailContact").val()).trim();
var comment = ($("#commentContact").val()).trim();
if(nombre!=="" && emailCheck(email)===true && comment!==""){
$(".msgEnvio").html("");
var data = "accion=DO_CONTACT&nm="+encodeURIComponent(nombre)+"&em="+encodeURIComponent(email)+"&cm="+encodeURIComponent(comment);
$.ajax({
type: "POST",
url: urlROOT+"/common/ajax.php",
data: data,
success: function(obj){
if(obj==1){
if(lg=='' || lg=='es'){
$(".msgEnvio").html("Comentario enviado correctamente");
}else{
$(".msgEnvio").html("Comment successfully sent");
}
setTimeout(function() { location.reload(); }, 3000);
}else{
if(lg=='' || lg=='es'){
$(".msgEnvio").html("No se ha enviado el comentario correctamente");
}else{
$(".msgEnvio").html("The comment has not been sent correctly");
}
setTimeout(function() { location.reload(); }, 3000);
}
},
error: function(){
if(lg=='' || lg=='es'){
$(".msgEnvio").html("No se ha enviado el comentario correctamente");
}else{
$(".msgEnvio").html("The comment has not been sent correctly");
}
setTimeout(function() { location.reload(); }, 3000);
}
});
}else{
if(lg=='' || lg=='es'){
$(".msgEnvio").html("Faltan datos o datos incorrectos");
}else{
$(".msgEnvio").html("Missing or incorrect data");
}
}
}
function emailCheck(emailStr) {
var emailPat=/^(.+)@(.+)$/
var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]"
var validChars="\[^\\s" + specialChars + "\]"
var quotedUser="(\"[^\"]*\")"
var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/
var atom=validChars + '+'
var word="(" + atom + "|" + quotedUser + ")"
var userPat=new RegExp("^" + word + "(\\." + word + ")*$")
var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$")
var matchArray=emailStr.match(emailPat)
if (matchArray==null) {
return false;
}
var user=matchArray[1];
var domain=matchArray[2];
if (user.match(userPat)==null) {
return false;
}
var IPArray=domain.match(ipDomainPat);
if (IPArray!=null) {
for (var i=1;i<=4;i++) {
if (IPArray[i]>255) {
return false;
}
}
return true;
}
var domainArray=domain.match(domainPat);
if (domainArray==null) {
return false
}
var atomPat=new RegExp(atom,"g");
var domArr=domain.match(atomPat);
var len=domArr.length;
if (domArr[domArr.length-1].length<2 || domArr[domArr.length-1].length>4) {
return false;
}
if (len<2) {
return false;
}
return true;
}
jQuery(document).keydown(
function(event) {
if((event.ctrlKey || event.metaKey) && event.altKey) {
event.preventDefault();
replaceSelText('b','descripcion_en');
replaceSelText('b','descripcion_es');
replaceSelText('b','descripcion_de');
replaceSelText('b','descripcion_fr');
replaceSelText('b','descripcion_it');
replaceSelText('b','descripcion_nl');
replaceSelText('b','descripcion_pl');
replaceSelText('b','descripcion_pt');
replaceSelText('b','descripcion_ru');
return false;
}
}
);
$('document').ready(function(){
$('#deeplTag12').on('click',function(){
replaceSelTextDeepl();
});
$('a[name="lSEL"]').on('click', function(){
var lang = $(this).attr('id');
var data = 'accion=SEL_LANG&lang='+lang;
$.ajax({
data: data,
url: urlROOT+'/common/ajax.php',
type: 'post',
async: 'false',
success: function(res){
var result = res;
result = result.replace(/(?:\r\n|\r|\n)/g, '');
if(result=='es'){
urlLang = urlROOT;
}else{
urlLang = urlROOT+'/'+result+'/';
}
document.location.href = urlLang;
},
error:function(){}
});
});
$('#lSELm').on('change', function(){
var lang = $('#lSELm').val();
if(lang!=""){
var data = 'accion=SEL_LANG&lang='+lang;
$.ajax({
data: data,
url: urlROOT+'/common/ajax.php',
type: 'post',
async: 'false',
success:function(res){
var result = res;
result = result.replace(/(?:\r\n|\r|\n)/g, '');
if(result=='es'){
urlLang = urlROOT;
}else{
urlLang = urlROOT+'/'+result+'/';
}
document.location.href = urlLang;
},
error:function(){}
});
}
});
$('#genres').on('change',function(){
loadURL();
});
$('#order').on('change',function(){
loadURL();
});
/*
$('#btnSearch').on('click',function(){
if($('#pPAGE').val()!='B' && $('#pPAGE').val()!='BD'){
loadURL();
}else{
loadURLBlog();
}
});
$('#btnSearch404').on('click',function(){
loadURL404();
});
*/
$('#genresM').on('change',function(){
loadURLM();
});
$('#orderM').on('change',function(){
loadURLM();
});
$("#search").keypress(function(event){
if(event.which == 13){
event.preventDefault();
loadURL();
/*
if($('#pPAGE').val()!='D'){
loadURL();
}else{
loadURLBlog();
}
*/
}
});
$("#search404").keypress(function(event){
if(event.which == 13){
event.preventDefault();
loadURL404();
}
});
$("#searchM").keypress(function(event){
if(event.which == 13){
event.preventDefault();
loadURLM();
/*
if($('#pPAGE').val()!='B' && $('#pPAGE').val()!='BD'){
loadURLM();
}else{
loadURLMBlog();
}
*/
}
});
$("#password").keypress(function(event){
if(event.which == 13){
event.preventDefault();
doLogin();
}
});
if(localStorage.getItem('slideCookies')!='1'){
$('.footerCookies').show();
$('.footerCookiesClose').click(function(){
$(".footerCookies").hide();
localStorage.setItem('slideCookies','1');
});
}else{
$('.footerCookies').hide();
}
$("#viewPPT").on('mouseup',function(){
updSlideDownloads();
});
$("#viewSlide").on('mouseup',function(){
updSlideDownloads();
});
})