PageSourceSearch

https://www.superbaterias.com/wp-content/plugins/buzz-updater/assets/scripts.js?ver=1790258441

js superbaterias.com collected 2026-09-24 14:01:31 UTC 3,673 bytes, 117 lines download raw bytes

1jQuery(function($){
2
3    $('#filtro-marca').on('change', function() {
4        var marca = $(this).val();
5        fill_filter('$[Marca="'+marca+'"].Modelo', 'filtro-modelo');
6    });
7
8    $('#filtro-modelo').on('change', function() {
9        var modelo = $(this).val();
10        fill_filter('$[Modelo="'+modelo+'"].Año', 'filtro-anyo');
11    });
12
13    $('#filtro-anyo').on('change', function() {
14        var marca = $('#filtro-marca').val();
15        var modelo = $('#filtro-modelo').val();
16        var anyo = $(this).val();
17        get_bci(marca, modelo, anyo);
18    });
19
20});
21
22//Get filter items
23async function fill_filter(filter,id) {
24    const baseUrl = "/wp-content/plugins/buzz-updater/assets/";
25    let  url = baseUrl+'voyager2Articulos_Adicionales.json?ver=123';
26
27    //Verificar si el archivo se descargo correctamente
28    const isValid = await validateJSON(url);
29    if (!isValid ) {
30        
31        url =  baseUrl+'backup.json?ver=1'; //si no usa el backup
32    } 
33
34    try {
35        var dropdown = document.getElementById(id);
36        // Guardar el texto original del primer <option>
37        const originalText = dropdown.options[0].text;
38        dropdown.options[0].text = "Cargando...";        
39
40        // Fetch the JSON from the URL
41        const response = await fetch(url); 
42        if (!response.ok) {
43            throw new Error('Network response was not ok');
44        }
45        const json = await response.json();
46    
47        let array = await jsonata(filter).evaluate(json);
48
49        if (!Array.isArray(array)) {
50            array = [array];
51        }
52
53        while (dropdown.options.length > 1) {
54            dropdown.remove(1);
55        }
56        array = array.filter(function(elem, index, self) {
57            return index === self.indexOf(elem);
58        });
59        array.sort();
60        array.forEach(function(item) {
61            var option = document.createElement("option");
62            option.value = item;
63            option.text = item;
64            dropdown.add(option);
65        });
66
67        dropdown.options[0].text = originalText;
68        // console.log(array);
69    } catch (error) {
70        console.error('There was a problem with the fetch operation:', error);
71    }
72}
73
74//Get BCI
75async function get_bci(marca, modelo, anyo) {
76
77    var url = '/wp-content/plugins/buzz-updater/assets/voyager2Articulos_Adicionales.json';
78
79    //Verificar si el archivo se descargo correctamente
80    const isValid = await validateJSON(url);
81    if (!isValid) {
82        var url = '/wp-content/plugins/buzz-updater/assets/backup.json'; //si no usa el backup
83    } 
84
85    try {
86        // Fetch the JSON from the URL
87        const response = await fetch(url); 
88        if (!response.ok) {
89            throw new Error('Network response was not ok');
90        }
91        const json = await response.json();
92    
93        const BCI = await jsonata('$[Marca="'+marca+'" and Modelo="'+modelo+'" and Año="'+anyo+'"].BCI').evaluate(json);
94
95        document.getElementsByName("BCI")[0].value = BCI;
96
97        //console.log(modelos);
98    } catch (error) {
99        console.error('There was a problem with the fetch operation:', error);
100    }
101}
102
103//Validar archivo
104async function validateJSON(url) {
105    try {
106        const response = await fetch(url);
107        const text = await response.text();
108        
109        // Intentar parsear el texto como JSON
110        let rta= JSON.parse(text);
111        if(rta.Message)  
112            { return false }        
113        return true; // JSON es válido
114    } catch (error) {
115        return false; // JSON no es válido
116    }
117}

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.