Skip to content

Instantly share code, notes, and snippets.

@xaiki
Created February 12, 2013 23:44
Show Gist options
  • Save xaiki/4774587 to your computer and use it in GitHub Desktop.
Save xaiki/4774587 to your computer and use it in GitHub Desktop.
trenes para todos
this.Horarios = {};
var trenesObj = {
estaciones: '',
proximoMoreno: function (e) { return estaciones[e][0]; },
siguienteMoreno: function (e) { return estaciones[e][1]; },
proximoOnce: function(e) { return estaciones[e][3];},
siguienteOnce: function(e) { return estaciones[e][4];}
}
var Horarios = function () {
var keyRaw = "w#1WW1MCdERWMw#hlQt5EVkFXWqRmj#PdEbwklj#Oh2I0JDbt1ERZNyZ";
var key = encodeURIComponent(keyRaw); //Cada key esta enlazada con el PHPSESSID
var url = "http://trenes.mininterior.gov.ar/ajax_arribos_sarmiento.php?callback=?&rnd=1&key="+key;
document.cookie = 'PHPSESSID=rigfgvb9ee10s89lptc8j0hoa6; '; //Hardcoding a full
Horarios.prototype.actualizar = function (cb) {
$.when($.ajax({url: url, dataType: "text", headers: {Accept: '*/*', Referer: 'http://trenes.mininterior.gov.ar'}, context: document.body}), $.getJSON('../lib/estaciones.json')).then(function (minint, json) {
console.log (minint);
var body = minint[0];
var estaciones = json[0];
var horarios = body.split("_");
var k = 1;
var step = 6;
for (estacion in estaciones) {
for(var i = k; i < (k+step); i++) {
estaciones[estacion].push(horarios[i]);
}
k += step;
}
var trenes = Object.create(trenesObj);
trenes.estaciones = estaciones;
cb(trenes);
});
};
}
this.Horarios = Horarios;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment