PageSourceSearch

https://www.tangol.com/js/keyword-form.7fqipngjz7.js

js tangol.com collected 2026-10-01 13:52:48 UTC 2,317 bytes, 58 lines download raw bytes

1// Cascada client-side para el form de Keywords:
2//   Categoría -> filtra Tipos por data-cat
3//   Tipo      -> filtra SubTipos por data-tip
4//   País      -> filtra Destinos por data-pais
5// Rehace las <option> desde un snapshot para preservar la selección actual.
6function initKeywordForm() {
7    var cat = document.getElementById('Input_Categoria');
8    var tipo = document.getElementById('Input_TipId');
9    var subtipo = document.getElementById('Input_SubtipId');
10    var pais = document.getElementById('Input_Pais');
11    var destino = document.getElementById('Input_DesId');
12    if (!cat || !tipo || !subtipo || !pais || !destino) return;
13
14    var snap = function (sel, attr) {
15        return Array.prototype.map.call(sel.options, function (o) {
16            return { v: o.value, t: o.text, key: attr ? (o.dataset[attr] || '') : '' };
17        });
18    };
19    var tipoAll = snap(tipo, 'cat');
20    var subAll = snap(subtipo, 'tip');
21    var desAll = snap(destino, 'pais');
22
23    var rebuild = function (sel, items, attr) {
24        var cur = sel.value;
25        sel.innerHTML = '';
26        items.forEach(function (it) {
27            var o = document.createElement('option');
28            o.value = it.v;
29            o.text = it.t;
30            if (attr && it.key !== undefined) o.dataset[attr] = it.key;
31            sel.appendChild(o);
32        });
33        sel.value = cur;
34        if (sel.selectedIndex < 0) sel.value = '';
35    };
36
37    var filterSubtipos = function () {
38        var t = tipo.value;
39        rebuild(subtipo, subAll.filter(function (x) { return !x.v || !x.key || x.key === t; }), 'tip');
40    };
41    var filterTipos = function () {
42        var c = cat.value;
43        rebuild(tipo, tipoAll.filter(function (x) { return !x.v || !x.key || x.key === c; }), 'cat');
44        filterSubtipos();
45    };
46    var filterDestinos = function () {
47        var p = pais.value;
48        rebuild(destino, desAll.filter(function (x) { return !x.v || !x.key || x.key === p; }), 'pais');
49    };
50
51    cat.addEventListener('change', filterTipos);
52    tipo.addEventListener('change', filterSubtipos);
53    pais.addEventListener('change', filterDestinos);
54
55    // Filtrado inicial preservando lo que venga seleccionado (edición).
56    filterTipos();
57    filterDestinos();
58}

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.