$(document).ready(inicializarEventos); var mesSelec = -1; var anoSelec = -1; var tipoSelec = -1; var idioma=''; function inicializarEventos(){ leerXMLEventosLACNIC(); $('#tipoEvento').val(3); leerXMLEventosOTROS(); $('#tipoEvento').change(leerXMLEventosOTROS); } function cargarValores(){ mesSelec = 0; anoSelec = 0; if(tipoSelec !=-1){ tipoSelec = $('#tipoEvento').val(); }else{ tipoSelec = 3; } } function DeterminarURL(){ //var dirURL = "http://lacnic.net/cgi-bin/eventos/leerXML.cgi"; var dirURL; actual= location.href; div1=actual.split("/"); //idioma idioma=div1[3]; var dirURL = "http://"+div1[2]+"/cgi-bin/eventos/leerXML.cgi"; return dirURL; } function MostrarError(msj){ alert(msj); } /*--- EVENTOS LACNIC ---*/ function leerXMLEventosLACNIC(){ mesSelec = 0; anoSelec = 0; tipoSelec = 1; var dir = DeterminarURL(); $.ajax({ type: "GET",//GET url: dir, cache: false, dataType: "html/text", data: ({ms : mesSelec, as : anoSelec, ts : tipoSelec, lag : idioma}), beforeSend: MostrarEsperaLACNIC, success: MostrarXMLeventosLACNIC, error: MostrarError }); } function MostrarEsperaLACNIC(){ //vacio el contenedor de los eventos $('#container1').empty(); $('#container1').append('

'); $('#container1').append('

Cargando...

'); } function MostrarXMLeventosLACNIC(datos){ //vacio el contenedor de los eventos $('#container1').empty(); //MostrarError(datos); //Si no mostre nungún evento, muestro mensaje if(datos==0){ $('#container1').append('

No hay eventos para esta selección...

'); }else{//sino muestro datos $('#container1').append(datos); } } /*--- EVENTOS LACNIC ---*/ /*--- OTROS EVENTOS LACNIC ---*/ function leerXMLEventosOTROS(){ cargarValores(); var dir = DeterminarURL(); $.ajax({ type: "GET",//GET url: dir, cache: false, dataType: "html/text", data: ({ms : mesSelec, as : anoSelec, ts : tipoSelec, lag : idioma}), beforeSend: MostrarEsperaOTROS, success: MostrarXMLeventosOTROS, error: MostrarError }); } function MostrarEsperaOTROS(){ //vacio el contenedor de los eventos $('#container2').empty(); $('#container2').append('

'); $('#container2').append('

Cargando...

'); } function MostrarXMLeventosOTROS(datos){ //vacio el contenedor de los eventos $('#container2').empty(); //MostrarError(datos); //Si no mostre nungún evento, muestro mensaje if(datos==0){ $('#container2').append('

No hay eventos para esta selección...

'); }else{//sino muestro datos $('#container2').append(datos); } } /*--- OTROS EVENTOS LACNIC ---*/ function leerXMLMeses(){ $.ajax({ type: "GET", url: "http://lacnic.net/sp/eventos/meses.xml", cache: false, dataType: "xml", success: cargarComboMeses, error: MostrarError }); } function cargarComboMeses(xml){ var comboMeses = ''; $(xml).find('mes').each(function(){ var id = $(this).attr('id'); var mes = $(this).text(); comboMeses += ''; }); $('#meses').append(comboMeses); $('#meses')[0].selectedIndex = 0; //$('#meses')[0].selectedIndex = obtiene_mes(); } function leerXMLAnos(){ $.ajax({ type: "GET", url: "anos.xml", cache: false, dataType: "xml", success: cargarComboAnos, error: MostrarError }); } function cargarComboAnos(xml){ var comboAnos = ''; $(xml).find('ano').each(function(){ var id = $(this).attr('id'); var ano = $(this).text(); comboAnos += ''; }); $('#anos').append(comboAnos); //$('#anos')[0].selectedIndex = 0; //$('#anos')[0].selectedIndex = obtiene_ano(); $('#anos').val(obtiene_ano()); } function leerXMLTipoEventos(){ $.ajax({ type: "GET", url: "tipoEventos.xml", cache: false, dataType: "xml", success: cargarComboTipoEventos, error: MostrarError }); } function cargarComboTipoEventos(xml){ var comboTipos = ''; $(xml).find('tipo').each(function(){ var id = $(this).attr('id'); var desc = $(this).text(); comboTipos += ''; }); $('#tipoEvento').append(comboTipos); $('#tipoEvento')[0].selectedIndex = 0; } function obtiene_mes() { var fecha_actual = new Date(); var mes = fecha_actual.getMonth() + 1; if (mes < 10){ mes = 0 +''+ mes; } return (mes); } function obtiene_ano() { var fecha_actual = new Date(); var anio = fecha_actual.getFullYear(); return anio; }