PageSourceSearch

https://wildthingsafaris.com/static/js/cascaded.js

js wildthingsafaris.com collected 2026-10-02 13:18:44 UTC 2,677 bytes, 81 lines download raw bytes

1function filter_cascade_by_id (id, vals) {
2    var element = document.getElementById(id);
3    if (!element) { return };
4
5    if ( element.tagName == 'SELECT' ) {
6        var complete_select = document.getElementById(id + "-Complete" );
7        filter_cascade_select(element, complete_select, vals );
8        if ( jQuery(element).hasClass('chosen') ) {
9            jQuery(element).trigger('chosen:updated');
10        }
11    }
12    else {
13        if ( !( vals instanceof Array ) ) {
14            vals = [vals];
15        }
16
17        if ( vals.length == 0 || (vals.length == 1 && vals[0] == '') ) {
18            // no category, leave it empty
19            jQuery(element).find('div').hide();
20        }
21        else {
22            jQuery(element).find('div').hide().find('input').prop('disabled', true);
23            jQuery(element).find('div[data-name=]').show().find('input').prop('disabled', false);
24            jQuery(element).find('div.none').show().find('input').prop('disabled',false);
25            for ( var j = 0; j < vals.length; j++ ) {
26                var match = jQuery(element).find('div[data-name]').filter(function(){
27                    return jQuery(this).data('name').indexOf(vals[j]) == 0
28                });
29                match.show().find('input').prop('disabled', false);
30            }
31        }
32    }
33}
34
35function filter_cascade_select (select, complete_select, vals) {
36    if ( !( vals instanceof Array ) ) {
37        vals = [vals];
38    }
39
40    if (!select) { return };
41    var i;
42    var children = select.childNodes;
43
44    jQuery(select).children().remove();
45
46    var complete_children = jQuery(complete_select).children();
47
48    var cloned_labels = {};
49    var cloned_empty_label;
50    for ( var j = 0; j < vals.length; j++ ) {
51        var val = vals[j];
52        if ( val == '' ) {
53            // no category, leave this set of options empty
54        }
55        else {
56            var labels_to_clone = {};
57            complete_children.each( function() {
58                var label = jQuery(this).attr('label');
59                var need_clone;
60                if ( !label ) {
61                    if ( !cloned_empty_label ) {
62                        need_clone = true;
63                    }
64                }
65                else if ( label == val ) {
66                    if ( !cloned_labels[label] ) {
67                        need_clone = true;
68                    }
69                }
70
71                if ( need_clone ) {
72                    jQuery(select).append(jQuery(this).clone());
73                    cloned_labels[label] = true;
74                }
75            });
76
77            if ( !cloned_empty_label )
78                cloned_empty_label = true;
79        }
80    }
81}

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.