$(document).ready(function(){
cargarNoticia();
});
var noticia = new Object();
function cargarNoticia () {
$.ajax({
dataType: "json",
type: "POST",
url: "ControlIntranetJSON",
data: {
tabla: 4,
estado: 2,
id_noticia: $('#id-noticia').val()
},
success: function (response) {
noticia = response;
pintarNoticia();
},
error: function (response) {
console.log("Error en la petición");
console.log(response);
}
});
}
function pintarNoticia () {
if ($.isEmptyObject(noticia)) {
document.location.href = 'noticias.jsp';
} else {
var descripcion = escapeHtml(noticia.not_corta);
$('.contenedor-redes-sociales .facebook').attr('href', 'http://www.facebook.com/sharer.php?u=' + noticia.meta_canonical);
$('.contenedor-redes-sociales .twitter').attr('href', 'https://twitter.com/intent/tweet?text=' + noticia.meta_canonical);
$('.contenedor-redes-sociales .linkedin').attr('href', 'https://www.linkedin.com/shareArticle?mini=true&url=' + noticia.meta_canonical);
$('.contenedor-redes-sociales .whatsapp').attr('href', 'whatsapp://send?text=' + noticia.meta_canonical);
var imagen = new String();
if (noticia.ima_gra.length > 0) {
imagen = 'imagenes_noticias/' + noticia.ima_gra;
} else {
imagen = 'img/logo.png';
}
$("#noticia .contenedor-imagen img").attr({
src: imagen,
alt: noticia.titulo
});
$('#noticia .fecha-publicacion .fecha').text(noticia.fec_alta);
$('#noticia .titulo').html(noticia.titulo);
$('#noticia .contenido-noticia .subtitulo').html(noticia.not_corta);
$('#noticia .contenido-noticia .noticia-larga').append(noticia.not_larga);
if (noticia.fuente.length > 0) {
if (noticia.fue_denominacion.length > 0) {
$('#noticia .contenido-noticia .fuente').html('Ver enlace: ' + noticia.fue_denominacion + '');
} else {
$('#noticia .contenido-noticia .fuente').html('Ver enlace');
}
$('#noticia .contenido-noticia .fuente').show();
}
$('#noticia .con-noticia, #noticia .btn-volver').show();
}
}
function metaNoticias () {
var titulo = escapeHtml(noticia.titulo) + ' - ADR Service';
$('title').text(titulo);
// $('#noticia .titulo').text(titulo);
$('meta[property="og:title"]').attr('content', titulo);
var htmlMeta = new String();
// Canonical
if ($('meta[itemprop="url"]').length > 0) {
$('meta[itemprop="url"]').attr('content', noticia.meta_canonical);
} else {
htmlMeta = htmlMeta + '';
}
if ($('link[rel="canonical"]').length > 0) {
$('link[rel="canonical"]').attr('href', noticia.meta_canonical);
} else {
htmlMeta = htmlMeta + '';
}
if ($('meta[property="og:url"]').length > 0) {
$('meta[property="og:url"]').attr('content', noticia.meta_canonical);
} else {
htmlMeta = htmlMeta + '';
}
// Ruta imagen
if ($('meta[itemprop="image"]').length > 0) {
$('meta[itemprop="image"]').attr('content', noticia.ima_ruta + noticia.ima_peq);
} else {
htmlMeta = htmlMeta + '';
}
if ($('meta[name="twitter:image"]').length > 0) {
$('meta[name="twitter:image"]').attr('content', noticia.ima_ruta + noticia.ima_peq);
} else {
htmlMeta = htmlMeta + '';
}
if ($('meta[property="og:image"]').length > 0) {
$('meta[property="og:image"]').attr('content', noticia.ima_ruta + noticia.ima_peq);
} else {
htmlMeta = htmlMeta + '';
}
// Ancho imagen
if ($('meta[name="twitter:image:width"]').length > 0) {
$('meta[name="twitter:image:width"]').attr('content', noticia.ima_peq_ancho);
} else {
htmlMeta = htmlMeta + '';
}
if ($('meta[property="og:image:width"]').length > 0) {
$('meta[property="og:image:width"]').attr('content', noticia.ima_peq_ancho);
} else {
htmlMeta = htmlMeta + '';
}
// Alto imagen
if ($('meta[name="twitter:image:height"]').length > 0) {
$('meta[name="twitter:image:height"]').attr('content', noticia.ima_peq_alto);
} else {
htmlMeta = htmlMeta + '';
}
if ($('meta[property="og:image:height"]').length > 0) {
$('meta[property="og:image:height"]').attr('content', noticia.ima_peq_alto);
} else {
htmlMeta = htmlMeta + '';
}
$('head').append(htmlMeta);
}
// $('#noticia .contenedor-otras-noticias .noticias').slick({
// slidesToShow: 1,
// slidesToScroll: 1,
// autoplay: true,
// autoplaySpeed: 5000,
// dots: true,
// arrows: false,
// responsive: [
// {
// breakpoint: 1200,
// settings: {
// slidesToShow: 1,
// slidesToScroll: 1
// }
// },
// {
// breakpoint: 992,
// settings: {
// slidesToShow: 2,
// slidesToScroll: 2
// }
// },
// {
// breakpoint: 768,
// settings: {
// slidesToShow: 1,
// slidesToScroll: 1
// }
// }
// ]
// });