PageSourceSearch

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

js clubtalleres.com.ar collected 2026-10-02 04:26:51 UTC 6,870 bytes, 157 lines download raw bytes

1// Asignar las funciones al objeto global
2
3
4obtenerPartidosCA = async function (pass, idequipo, cantidad) {
5    let partidos = await obtenerFixtureCA(pass, idequipo, cantidad);
6    return partidos;
7};
8
9
10
11inicializarPartidosCA = function (pass, idequipo, cantidad) {
12    return {
13        partidos: obtenerPartidosCA(pass, idequipo, cantidad)
14    };
15};
16
17obtenerFixtureCA = async function (pass, idequipo, cantidad) {
18    let idFiltro = idequipo.toString();
19    let response = await fetch('https://feed.datafactory.la/index.php?ppaass=C1u8T4113r35&canal=deportes.futbol.copaargentina.fixture', {
20        headers: {
21            'Accept-Charset': 'ISO-8859-1',
22            'Content-Type': 'application/json'
23        }
24    }); 
25    let buffer = await response.arrayBuffer();  // Obtener los datos binarios de la respuesta
26    let decoder = new TextDecoder('ISO-8859-1');  // Decodificar en UTF-8
27    let xmlText = decoder.decode(buffer);  // Convertir los datos binarios a texto en UTF-8
28    let parser = new DOMParser();
29    let xmlDoc = parser.parseFromString(xmlText, 'text/xml');
30    let json = xmlToJson(xmlDoc);
31    const partidosFiltradosbyId = json.fixture.fecha
32        .flatMap(item => item.partido) // Desenrollamos los partidos en un solo array
33        .filter(partido => {
34            const idLocal = partido.local?.['@attributes']?.id;
35            const idVisitante = partido.visitante?.['@attributes']?.id;
36            return idLocal === idFiltro || idVisitante === idFiltro; // Filtra por id
37        })
38        .map(partido => {
39            partido.campeonato = json.fixture.campeonatoNombreAlternativo?.['#text'] || '';
40            renombrarPropiedadesConflictuosas(partido); // Renombramos las propiedades
41            return partido;
42        });
43
44    const partidosFinalizados = partidosFiltradosbyId
45        .filter(partido => partido.estado._hash_text === "Finalizado") // Filtra los partidos finalizados
46        .sort((a, b) => {
47            const fechaA = new Date(`${a._at_attributes.fecha} ${a._at_attributes.hora}`);
48            const fechaB = new Date(`${b._at_attributes.fecha} ${b._at_attributes.hora}`);
49            return fechaB - fechaA; // Orden descendente por fecha
50        })
51        .reverse().slice(0, 2).reverse();
52
53    // Filtramos los partidos que aún no están "Finalizados"
54    const partidosNoFinalizados = partidosFiltradosbyId.filter(partido => partido.estado._hash_text !== "Finalizado");
55    // Concatenamos los partidos finalizados con los no finalizados
56    const partidosOrdenados = [...partidosFinalizados, ...partidosNoFinalizados];
57
58    return cantidad ? partidosOrdenados.slice(0, cantidad) : partidosOrdenados;
59}
60function renombrarPropiedadesConflictuosasCA(obj) {
61    for (let key in obj) {
62        if (obj.hasOwnProperty(key)) {
63            // Si la propiedad contiene un '@', lo reemplazamos por un guion bajo '_'
64            if (key.includes('@')) {
65                const newKey = key.replace('@', '_at_');  // Reemplaza el '@' por '_at_'
66                obj[newKey] = obj[key];                    // Asigna el valor con el nuevo nombre
67                delete obj[key];                           // Elimina la propiedad original
68            }
69
70            // Si la propiedad contiene un '#', lo reemplazamos por un guion bajo '_'
71            if (key.includes('#')) {
72                const newKey = key.replace('#', '_hash_');  // Reemplaza el '#' por '_hash_'
73                obj[newKey] = obj[key];                    // Asigna el valor con el nuevo nombre
74                delete obj[key];                           // Elimina la propiedad original
75            }
76
77            // Si el valor es un objeto o array, aplicar recursión
78            if (typeof obj[key] === "object" && obj[key] !== null) {
79                renombrarPropiedadesConflictuosasCA(obj[key]);
80            }
81        }
82    }
83}
84const obtenerFechaFormatoYYYYMMDDCA = (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 convertirFechaYYYYMMDDaDDMMYYYY = (fechaStr) => {
93    if (!fechaStr || fechaStr.length !== 8) {
94        throw new Error("La fecha debe estar en el formato YYYYMMDD");
95    }
96
97    const anio = fechaStr.substring(0, 4);
98    const mes = parseInt(fechaStr.substring(4, 6)) - 1;
98 // Convertimos a número y restamos 1 para usar en el objeto Date
99    const dia = fechaStr.substring(6, 8);
100    let fechaObjeto = new Date(anio, mes, dia); // Mes es 0-indexado en JavaScript, por eso restamos 1
101
102    // Array de nombres de los días de la semana
103    const diasSemana = ["Domingo", "Lunes", "Martes", "Miércoles", "Jueves", "Viernes", "Sábado"];
104
105    // Array de nombres de los meses en español
106    const meses = ["Enero", "Febrero", "Marzo", "Abril", "Mayo", "Junio", "Julio", "Agosto", "Septiembre", "Octubre", "Noviembre", "Diciembre"];
107
108    // Obtener el día de la semana (0-6, donde 0 es Domingo, 1 es Lunes, etc.)
109    let diaSemana = diasSemana[fechaObjeto.getDay()];
110
111    // Obtener el nombre del mes en español
112    let nombreMes = meses[mes];
113
114    // Formatear la fecha con nombre de mes
115    let fechaFormateada = `${dia} de ${nombreMes} de ${anio}`;
116
117    // Ahora la fecha está lista para mostrar en el HTML
118    fecha = `${diaSemana} ${fechaFormateada}`;
119
120    return fecha;
121};
122const formatearHora = (hora) =>{
123    return hora ? hora.split(':').slice(0, 2).join(':') : '--:--';
124}
125const truncarFechaCA = (fecha) => fecha.substring(0, 8); // Solo el formato YYYYMMDD
126
127function xmlToJson(xml) {
128    let obj = {};
129    if (xml.nodeType === 1) { // Element
130        if (xml.attributes.length > 0) {
131            obj['@attributes'] = {};
132            for (let j = 0; j < xml.attributes.length; j++) {
133                let attribute = xml.attributes.item(j);
134                obj['@attributes'][attribute.nodeName] = attribute.nodeValue;
135            }
136        }
137    } else if (xml.nodeType === 3) { // Text
138        obj = xml.nodeValue;
139    }
140
141    if (xml.hasChildNodes()) {
142        for (let i = 0; i < xml.childNodes.length; i++) {
143            let child = xml.childNodes.item(i);
144            let nodeName = child.nodeName;
145            if (typeof obj[nodeName] === 'undefined') {
146                obj[nodeName] = xmlToJson(child);
147            } else {
148                if (!Array.isArray(obj[nodeName])) {
149                    obj[nodeName] = [obj[nodeName]];
150                }
151                obj[nodeName].push(xmlToJson(child));
152            }
153        }
154    }
155
156    return obj;
157}

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.