// Se incicializa el men� de forma programada.
var menu;
var checkExist = setInterval(function() {
if (document.getElementById('cbp-tm-menu') != undefined) {
console.log("Exists!");
menu = new cbpTooltipMenu(document.getElementById('cbp-tm-menu'));
clearInterval(checkExist);
}
}, 100);
setTimeout(function(){ clearInterval(checkExist); }, 1000);
// M�todo que inicializa el traductor de google.
function googleTranslateElementInit() {
new google.translate.TranslateElement(
{
pageLanguage : 'es',
includedLanguages: 'es,ca,eu,gl,en' ,
layout : google.translate.TranslateElement.InlineLayout.SIMPLE,
autoDisplay : false
}, 'google_translate_element');
}
// Se incorpora el script del traductor de google.
$(function () {
var googleTranslateScript = document.createElement('script');
googleTranslateScript.type = 'text/javascript';
googleTranslateScript.async = true;
googleTranslateScript.src = 'https://translate.google.com/translate_a/element.js?cb=googleTranslateElementInit';
( document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0] ).appendChild(googleTranslateScript);
});
$(function () {
// Remove Search if user Resets Form or hits Escape!
$('body, .navbar-collapse form[role="search"] button[type="reset"]').on('click keyup', function(event) {
console.log(event.currentTarget);
if (event.which == 27 && $('.navbar-collapse form[role="search"]').hasClass('active') ||
$(event.currentTarget).attr('type') == 'reset') {
closeSearch();
}
});
function closeSearch() {
var $form = $('.navbar-collapse form[role="search"].active')
$form.find('input').val('');
$form.removeClass('active');
}
// Show Search if form is not active // event.preventDefault() is
// important, this prevents the form from submitting
$(document).on('click', '.navbar-collapse form[role="search"]:not(.active) button[type="submit"]', function(event) {
event.preventDefault();
var $form = $(this).closest('form'),
$input = $form.find('input');
$form.addClass('active');
$input.focus();
});
// ONLY FOR DEMO // Please use $('form').submit(function(event)) to
// track from submission
// if your form is ajax remember to call `closeSearch()` to close the
// search container
$(document).on('click', '.navbar-collapse form[role="search"].active button[type="submit"]', function(event) {
event.preventDefault();
var $form = $(this).closest('form'),
$input = $form.find('input');
$('#showSearchTerm').text($input.val());
closeSearch()
});
});
function loadDataTable(table) {
var dt = table.DataTable({
"iDisplayLength": 10,
"bFilter": false,
"bLengthChange" : false,
"ordering" : false,
"language": {
"sProcessing": "Procesando...",
"sLengthMenu": "Mostrar _MENU_ ",
"sZeroRecords": "No se han encontrado resultados",
"sEmptyTable": "No se han encontrado resultados",
"sInfo": "_TOTAL_ resultados",
"sInfoEmpty": "",
"sInfoFiltered": "(filtrado de un total de _MAX_ registros)",
"sInfoPostFix": "",
"sSearch": "",
"sUrl": "",
"sInfoThousands": ",",
"sLoadingRecords": "Cargando...",
"oPaginate": {
"sFirst": "Primero",
"sLast": "Último",
"sNext": "Siguiente",
"sPrevious": "Anterior"
},
"oAria": {
"sSortAscending": ": Activar para ordenar la columna de manera ascendente",
"sSortDescending": ": Activar para ordenar la columna de manera descendente"
}
},
"fnDrawCallback": function() {
if ($(".paginate_button").length > 3) {
// Se muestran los botones de paginación.
$(".dataTables_paginate")[0].style.display = "block";
} else {
// Se ocultan los botones de paginación.
$(".dataTables_paginate")[0].style.display = "none";
}
}
});
}
function ticket(parametros) {
var form = document.createElement("form");
var element = document.createElement("input");
form.method = "POST";
form.action = "/opencms/sede";
if (parametros.area) {
element.id="area";
element.name="area";
element.type="hidden"
element.value=parametros.area;
form.appendChild(element);
}
if (parametros.procedure) {
element.id="procedure";
element.name="procedure";
element.type="hidden"
element.value=parametros.procedure;
form.appendChild(element);
}
if (parametros.others) {
element.id="others";
element.name="others";
element.type="hidden"
element.value=parametros.others;
form.appendChild(element);
}
if (parametros.identifier) {
element.id="identifier";
element.name="identifier";
element.type="hidden"
element.value=parametros.identifier;
form.appendChild(element);
}
element = document.createElement("input");
element.id="action";
element.name="action";
element.type="hidden"
element.value="generaTicket";
form.appendChild(element);
document.body.appendChild(form);
form.submit();
}
var dayarray = days.split(",");
var montharray = months.split(",");
var serverDate;
var baseClientDate;
function updateDate() {
clientDate = new Date();
deltaTime = clientDate.getTime() - baseClientDate.getTime();
shownDate = new Date (serverDate.getTime() + deltaTime);
var year = shownDate.getYear();
if (year < 1000){
year += 1900;
}
var day = shownDate.getDay();
var month = shownDate.getMonth();
var daym = shownDate.getDate();
var hours = shownDate.getHours();
var minutes = shownDate.getMinutes();
var seconds = shownDate.getSeconds();
var dn = "AM";
if (minutes <= 9){
minutes = "0" + minutes;
}
if (seconds <= 9){
seconds = "0" + seconds;
}
var cdate = "" + hours + ":" + minutes
+ " "
+ dayarray[day] + " " + daym + " " + montharray[month]
+ " " + year + "";
document.getElementById('clock').innerHTML = cdate;
}
function initializeDate() {
// Se recupera la fecha del servidor.
xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
serverDate = new Date(Number(xmlhttp.responseText));
baseClientDate = new Date();
}
}
xmlhttp.open("GET", "/opencms/api/public/date");
xmlhttp.send();
setInterval("updateDate()", 1000);
}
initializeDate();