PageSourceSearch

https://www.allamericanflooring.net/wp-content/plugins/flooring-finder-addon/js/flooringfinder.js?ver=1.3

js allamericanflooring.net collected 2026-10-02 20:24:36 UTC 8,182 bytes, 219 lines download raw bytes

1//floor finder js start here
2addEvent();
3const data = {};
4
5function addEvent(e) {
6    let getActive = document.querySelector(".flooringFinder > section.active");
7    if (getActive) {
8        let getCards = getActive.querySelectorAll(".card:not(.deactivate)");
9        for (let i = 0; i < getCards.length; i++) {
10            getCards[i].addEventListener("click", showNext);
11        }
12    }
13}
14
15function addEventToNextBtn(e) {
16    let getActive = document.querySelector(".flooringFinder section.active .next > a");
17    getActive.addEventListener("click", showNext);
18
19}
20
21bootstrap_alert = function() {}
22bootstrap_alert.warning = function(message) {
23    jQuery('.flooringFinder section.active .next #alert_placeholder').html('<div class="alert alert-danger" role="alert">' + message + '</div>');
24}
25
26function showNext(e) {
27
28   
29    
30    let getSec = document.querySelector(".flooringFinder section.active");
31
32    if (getSec) {
33        let getIndex = getSec.getAttribute("data-index-value");
34        
35        if (getIndex <= 6 && getIndex > 1 && getSec.querySelectorAll("input:checked").length < 1) {
36            return bootstrap_alert.warning('Please Select Any One of Above');
37        } else if (getIndex <= 6 && getIndex > 1) {
38            let inputData = getSec.querySelectorAll("input:checked");
39            let gettype = getSec.getAttribute("data-section");
40            if (getSec.querySelectorAll("input:checked").length > 1) {
41                let arr = [];
42                for (val of inputData) {
43                    arr.push(val.value);
44                }
45                data[gettype] = arr;
46            } else {
47                data[gettype] = inputData[0].value;
48            }
49
50            jQuery('html, body').animate({
51                scrollTop: $("#FlooringFinder").offset().top
52            }, 200);
53        } else if (getIndex == 1) {
54            if (e.currentTarget.getAttribute("data-look") === 'carpet') {
55                let card = [`.card[data-room="bathroom"]`, `.card[data-room="kitchen"]`, `.card[data-room="laundryRoom"]`, `.card[data-color-carpet="reds"]`, `.card[data-color-carpet="violets"]`];
56                let cards = getElements(card);
57                deactivateCard(cards);
58
59                let getActive = document.querySelectorAll(".flooringFinder .typeOfCarpet");
60                getActive.forEach(function(item) {
61                    item.classList.remove('hidden');
62                    item.classList.add('show');
63                });
64                data['typeOfLook'] = 'carpeting';
65
66            } else if (e.currentTarget.getAttribute("data-look") === 'woodLook') {
67                let getActive = document.querySelectorAll(".flooringFinder .typeOfWood");
68                getActive.forEach(function(item) {
69                    item.classList.remove('hidden');
70                    item.classList.add('show');
71                });
72                data['typeOfLook'] = ['hardwood_catalog', 'laminate_catalog', 'luxury_vinyl_tile'];
73
74            } else if (e.currentTarget.getAttribute("data-look") === 'tileOrStone') {
75                let getActive = document.querySelectorAll(".flooringFinder .typeOfTile");
76                getActive.forEach(function(item) {
77                    item.classList.remove('hidden');
78                    item.classList.add('show');
79                });
80                data['typeOfLook'] = 'tile';
81            }
82            jQuery('html, body').animate({
83                scrollTop: $("#FlooringFinder").offset().top
84            }, 200);
85
86        }
87        if (getIndex <= 6) {
88            // alert(getIndex);
89            let nextSection = document.querySelector(`section[data-index-value='${1 + + getIndex}']`);
90            let getActive = document.querySelector(".flooringFinder section.active");
91            getActive.classList.remove('active');
92            if (getIndex < 6) {
93                nextSection.classList.add('active');
94                nextSection.classList.contains('multiselect') ? multiselect() : singleselect();
95                getIndex < 5 ? addEventToNextBtn() : console.log('not applying');
96
97            } else {
98                document.querySelector(".resultWrap").classList.add('active');
99                //console.log(data);
100            }
101            jQuery('html, body').animate({
102                scrollTop: $("#FlooringFinder").offset().top
103            }, 200);
104        }
105    } else {
106        alert('somthing wrong');
107    }
108
109
110    function getElements(ele) {
111        let arr = [];
112        for (let i = 0; i < ele.length; i++) {
113            arr.push(document.querySelector(ele[i]));
114        }
115        return arr;
116    }
117
118    function deactivateCard(cards) {
119        cards.forEach(function(item) {
120            item.classList.add('deactivate');
121        });
122    }
123
124}
125
126function multiselect() {
127    let getActive = document.querySelectorAll(".flooringFinder section.active.multiselect");
128    let getCards = getActive[0].querySelectorAll(".card:not(.deactivate)");
129    for (let i = 0; i < getCards.length; i++) {
130        getCards[i].addEventListener("click", function() {
131            let getChec = getCards[i].querySelector("input[type=checkbox]");
132            if (getChec.checked) {
133                getCards[i].classList.remove('shadow');
134                getChec.checked = false;
135            } else {
136                getCards[i].classList.add('shadow');
137                getChec.checked = true;
138            }
139        });
140    }
141}
142
143function singleselect() {
144    let getActive = document.querySelector(".flooringFinder section.active.singleselect");
145
146    let getCards = getActive.querySelectorAll(".card:not(.deactivate)");
147    for (let i = 0; i < getCards.length; i++) {
148        getCards[i].addEventListener("click", function() {
149
150            let getChec = getCards[i].querySelector("input[type=checkbox]");
151            if (getChec.checked) {
152                getCards[i].classList.remove('shadow');
153                getChec.checked = false;
154            } else {
155                let chec = getActive.querySelectorAll("input:checked");
156                if (chec.length < 1) {
157                    getCards[i].classList.add('shadow');
158                    getChec.checked = true;
159                } else if (chec.length === 1) {
160                    chec[0].checked = false;
161                    chec[0].parentElement.classList.remove('shadow');
162                    getCards[i].classList.add('shadow');
163                    getChec.checked = true;
164                }
165            }
166        });
167    }
168}
169
170    /*store location end*/
171
172    function loadMoreData() {
173        let allPr = document.querySelectorAll(".resultWrap.active .flooringFinderajax > .singlePro");
174        let count = 0;
175        jQuery(allPr).each(function(index, ele) {
176            count++;
177            count > 5 ? jQuery(ele).css("display", "none") : jQuery(ele).css("display", "block");
178
179        });
180
181
182        document.querySelector(".resultWrap.active .flooringFinderajax > .buttonWrap > .button").addEventListener("click", function(e) {
183            let allPr = document.querySelectorAll(".resultWrap.active .flooringFinderajax > .singlePro");
184            jQuery(allPr).each(function(index, ele) {
185                jQuery(ele).css("display", "block");
186            });
187            jQuery(".resultWrap.active .flooringFinderajax > .buttonWrap > .button").css("display", "none");
188        });
189
190
191
192    }
193
194// Get flooring finder data
195
196jQuery('.flooringFinder section .getProData > a').on('click', function() {
197    showNext();
198    var mySelectedData = data;
199
200    jQuery.ajax({
201        type: "POST",
202        url: "/wp-admin/admin-ajax.php",
203        data: 'action=check_out_flooring&product=' + mySelectedData.typeOfLook + '&style=' + mySelectedData.typeOf + '&design_style=' + mySelectedData.designStyle + '&room=' + mySelectedData.room + '&imp_thing=' + mySelectedData.impThing + '&color=' + mySelectedData.color,
204        success: function(data) {
205            jQuery(".flooringFinderajax ").html(data);
206            if (data) {
207                loadMoreData();
208            }
209        }
210
211    });
212
213});
214if(jQuery("#FlooringFinder").length > 0){
215	jQuery('html, body').animate({
216		scrollTop: jQuery("#FlooringFinder").offset().top
217	}, 200);	
218}
219//floor finder js End here

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.