PageSourceSearch

https://www.florsheim.com/shop/style/resources/js/autoComplete.js

js florsheim.com collected 2026-10-02 04:29:52 UTC 5,157 bytes, 142 lines download raw bytes

1function setAutoFlag(textSrcFlag) {
2  //console.log('setAutoFlag(' + textSrcFlag + ')');
3  var formId = jQuery("#wrapper-header").closest("form").attr("id");
4  $("#" + formId + "\\:textSrc").val(textSrcFlag);
5}
6
7$(document).click(function (e) {
8    var formId = jQuery("#wrapper-header").closest("form").attr("id");
9    var input = formId + ":txtSearchbox";
10    var inputMobile = formId + ":txtSearchboxMobile";
11
12    //hide / show autocomplete list (desktop)
13    var isList = (e.target.className === 'sList');	
14    var isTextClass = (e.target.className === 'search-field visible-lg visible-md visible-sm');
15    var isTextId = (e.target.id === input);
16
17    if ((!isTextClass && !isTextId) || !isList) {
18        $('#sList').hide();
19    }
20
21    if ((isTextClass && isTextId) && $('#sList').length === 1) {
22        $('#sList').show();
23    }
24
25    //hide / show autocomplete list (mobile)
26    var isListMobile = (e.target.className === 'sListMobileD');
27    var isTextClassMobile = (e.target.className === 'form-control');
28    var isTextIdMobile = (e.target.id === inputMobile);
29
30    if ((!isTextClassMobile && !isTextIdMobile) || !isListMobile) {
31        $('#sListMobileD').hide();
32    }
33
34    if ((isTextClassMobile && isTextIdMobile) && $('#sListMobileD').length === 1) {
35        $('#sListMobileD').show();
36    }
37});
38
39function onAutoKeydown(e) {
40    e.preventDefault();
41    setAutoFlag("auto");
42    
43    //puts cursor focus on the search input box if the user presses the up arrow button at the top of the result list
44    if (e.keyCode === 38) {
45        var val1 = document.activeElement.getAttribute('data-value');
46        var val2 = document.getElementById("sList").children[0].getAttribute('data-value');
47        if (val1 === val2) {
48            var formId = jQuery("#wrapper-header").closest("form").attr("id");
49            var input = $("#" + formId + "\\:txtSearchbox");
50            input.focus();
51        } else { //navigates result list via up arrow key
52            var prev = $('#sList').find("li.selected").prev();
53            $("#sList li.selected").removeClass("selected");
54            prev.focus().addClass("selected");
55        }
56    }
57
58    //navigates result list via down arrow key
59    if (e.keyCode === 40) {
60        if ($("#sList li.selected").length !== 0) {
61            var next = $('#sList').find("li.selected").next();
62            $("#sList li.selected").removeClass("selected");
63            next.focus().addClass("selected");
64        }
65    }
66
67    //submits the search based on autocomplete results (tab and enter buttons)
68    if (e.keyCode === 13 || e.keyCode === 9) {
69        e.preventDefault();
70        var selected = document.activeElement.innerText;
71        var formId = jQuery("#wrapper-header").closest("form").attr("id");
72        var input = $("#" + formId + "\\:txtSearchbox");
73        var searchButton = $("#" + formId + "\\:searchButton");
74        input.val(selected);
75        searchButton.click();
76    }
77}
78
79//puts focus on autocomplete result list if user presses the down arrow button from the search input box
80function selectDropDown() {
81    var list = $('#sList');
82    list.find("li:first").focus().addClass("selected");
83    setAutoFlag("free");
84}
85
86//submits desktop autocomplete via mouseclick
87function submitAuto(e) {
88    var target = e.target;
89    if (target.tagName.toLowerCase() === "b") {
90      target = target.parentElement;
91    }
92    var selected = target.innerText;	
93    var formId = jQuery("#wrapper-header").closest("form").attr("id");
94    var input = $("#" + formId + "\\:txtSearchbox");
95    var searchButton = $("#" + formId + "\\:searchButton");
96    setAutoFlag("auto");
97    input.val(selected);
98    searchButton.click();
99}
100
101//submits mobile autocomplete
102function submitAutoMobile(e) {
103    var target = e.target;
104    if (target.tagName.toLowerCase() === "b") {
105     target = target.parentElement;
106    }
107    var selected = target.innerText;	
108    var formId = jQuery("#wrapper-header").closest("form").attr("id");
109    var input = $("#" + formId + "\\:txtSearchboxMobile");
110    var searchButton = $("#" + formId + "\\:searchButtonMobile");
111    setAutoFlag("auto");
112    input.val(selected);
113    searchButton.click();
114
115}
116
117//determines if device is mobile or not (or just in mobile view on a desktop)
118//this determines appropriate css to display
119function isMobile() {
120    var mobile = !!navigator.userAgent.match(/iphone|android|blackberry/ig) || false;
121    var list = $('.sListMobileClass');
122    var listId = $('.sListMobileClass').attr('id');
123    var li = list.find('li');
124    var liClass = li.attr('class');
125
126    if (mobile) {
127        if (listId === 'sListMobileD') {
128            list.attr('id', 'sListMobile');
129        }
130        if (liClass === 'auto-mobile-option-d') {
131            li.attr('class', 'auto-mobile-option');
132
133        }
134    } else if (!mobile) {
135        if (listId === 'sListMobile') {
136            list.attr('id', 'sListMobileD');
137        }
138        if (liClass === 'auto-mobile-option') {
139            li.attr('class', 'auto-mobile-option-d');
140        }
141    }
142}

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.