PageSourceSearch

https://www.clubtalleres.com.ar/wp-content/plugins/fixture-talleres/assets/js/main.js?ver=1.0

js clubtalleres.com.ar collected 2026-10-02 04:26:49 UTC 5,434 bytes, 124 lines download raw bytes

1// Asignar las funciones al objeto global
2
3
4obtenerPartidos = async function (pass,idequipo,cantidad,torneo) {
5    let partidos = await obtenerFixture(pass,idequipo,cantidad,torneo);
6    return partidos;
7};
8
9
10
11
12obtenerFixture = async function (pass,idequipo,cantidad,torneo) {
13    let idFiltro = idequipo.toString();
14    let passT = pass.toString();
15    let response = await fetch(`https://feed.datafactory.la/index.php?ppaass=${passT}&canal=deportes.futbol.${torneo}.fixture`, {
16        headers: {
17            'Accept-Charset': 'ISO-8859-1',
18            'Content-Type': 'application/json'
19        }
20    }); 
21    let buffer = await response.arrayBuffer();  // Obtener los datos binarios de la respuesta
22    let decoder = new TextDecoder('ISO-8859-1');  // Decodificar en UTF-8
23    let xmlText = decoder.decode(buffer);  // Convertir los datos binarios a texto en UTF-8
24    let parser = new DOMParser();
25    let xmlDoc = parser.parseFromString(xmlText, 'text/xml');
26    let json = xmlToJson(xmlDoc);
27
28    const partidosFiltradosbyId = json.fixture.fecha
29        .flatMap(item => item.partido) // Desenrollamos los partidos en un solo array
30        .filter(partido => {
31            const idLocal = partido.local?.['@attributes']?.id;
32            const idVisitante = partido.visitante?.['@attributes']?.id;
33            return idLocal === idFiltro || idVisitante === idFiltro; // Filtra por id
34        })
35        .map(partido => {
36            partido.campeonato = json.fixture.campeonatoNombreAlternativo?.['#text'] || '';
37            renombrarPropiedadesConflictuosas(partido); // Renombramos las propiedades
38            return partido;
39        });
40
41    const partidosFinalizados = partidosFiltradosbyId
42    .filter(partido => partido.estado._hash_text === "Finalizado") // Filtra los partidos finalizados
43    .sort((a, b) => {
44        const fechaA = new Date(`${a._at_attributes.fecha} ${a._at_attributes.hora}`);
45        const fechaB = new Date(`${b._at_attributes.fecha} ${b._at_attributes.hora}`);
46        return fechaB - fechaA; // Orden descendente por fecha
47    })
48    .reverse().slice(0, 2).reverse(); 
49
50    // Filtramos los partidos que aún no están "Finalizados", "Suspendido" o "Postergado"
51    const partidosNoFinalizados = partidosFiltradosbyId.filter(partido => 
52        partido.estado._hash_text !== "Finalizado" && partido.estado._hash_text !== "Suspendido" && partido.estado._hash_text !== "Postergado");    // Concatenamos los partidos finalizados con los no finalizados
53    const partidosOrdenados = [...partidosFinalizados, ...partidosNoFinalizados];
54
55    return cantidad ? partidosOrdenados.slice(0, cantidad) : partidosOrdenados;
56}
57
58
59function renombrarPropiedadesConflictuosas(obj) {
60    for (let key in obj) {
61        if (obj.hasOwnProperty(key)) {
62            // Si la propiedad contiene un '@', lo reemplazamos por un guion bajo '_'
63            if (key.includes('@')) {
64                const newKey = key.replace('@', '_at_');  // Reemplaza el '@' por '_at_'
65                obj[newKey] = obj[key];                    // Asigna el valor con el nuevo nombre
66                delete obj[key];                           // Elimina la propiedad original
67            }
68
69            // Si la propiedad contiene un '#', lo reemplazamos por un guion bajo '_'
70            if (key.includes('#')) {
71                const newKey = key.replace('#', '_hash_');  // Reemplaza el '#' por '_hash_'
72                obj[newKey] = obj[key];                    // Asigna el valor con el nuevo nombre
73                delete obj[key];                           // Elimina la propiedad original
74            }
75
76            // Si el valor es un objeto o array, aplicar recursión
77            if (typeof obj[key] === "object" && obj[key] !== null) {
78                renombrarPropiedadesConflictuosas(obj[key]);
79            }
80        }
81    }
82}
83
84const obtenerFechaFormatoYYYYMMDD = (diasOffset = 0) => {
85    const fecha = new Date();
86    fecha.setDate(fecha.getDate() + diasOffset); // Ajusta los días (+ o -)
87    const anio = fecha.getFullYear();
88    const mes = String(fecha.getMonth() + 1).padStart(2, '0'); // Los meses empiezan en 0
89    const dia = String(fecha.getDate()).padStart(2, '0');
90    return `${anio}${mes}${dia}`;
91};
92const truncarFecha = (fecha) => fecha.substring(0, 8); // Solo el formato YYYYMMDD
93
94function xmlToJson(xml) {
95    let obj = {};
96    if (xml.nodeType === 1) { // Element
97        if (xml.attributes.length > 0) {
98            obj['@attributes'] = {};
99            for (let j = 0; j < xml.attributes.length; j++) {
100                let attribute = xml.attributes.item(j);
101                obj['@attributes'][attribute.nodeName] = attribute.nodeValue;
102            }
103        }
104    } else if (xml.nodeType === 3) { // Text
105        obj = xml.nodeValue;
106    }
107
108    if (xml.hasChildNodes()) {
109        for (let i = 0; i < xml.childNodes.length; i++) {
110            let child = xml.childNodes.item(i);
111            let nodeName = child.nodeName;
112            if (typeof obj[nodeName] === 'undefined') {
113                obj[nodeName] = xmlToJson(child);
114            } else {
115                if (!Array.isArray(obj[nodeName])) {
116                    obj[nodeName] = [obj[nodeName]];
117                }
118                obj[nodeName].push(xmlToJson(child));
119            }
120        }
121    }
122
123    return obj;
124}

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.