function parse_query_string(query) { var vars = query.split("&"); var query_string = {}; for (var i = 0; i < vars.length; i++) { var pair = vars[i].split("="); var key = decodeURIComponent(pair.shift()); var value = decodeURIComponent(pair.join("=")); // If first entry with this name if (typeof query_string[key] === "undefined") { query_string[key] = value; // If second entry with this name } else if (typeof query_string[key] === "string") { var arr = [query_string[key], value]; query_string[key] = arr; // If third or later entry with this name } else { query_string[key].push(value); } } return query_string; } //var query = window.location.search.substring(1); var query = window.location.hash.substring(1);; console.log('query HASH',query); var qs = {}; if (query) { // var qs = parse_query_string(query); const q = query.split('='); const q1 = q[0]; const q2 = q[1]; if (q1=='pavilon') { qs.pavilon = q2; } if (q1=='sekcia') { qs.sekcia = q2; } console.log('qs hash',q,qs); } //console.log(qs.pavilon); //console.log(qs.sekcia); var Zoznam = document.getElementById("ZOZNAM_VYSTAVOVATELOV"); Zoznam.innerHTML = '
Umiestnenie expozície: FM1M2M3M4M5všetky
Zameranie expozície: TRAVELKLUBYCARAVANVANYOVERLANDOUTDOORANDBIKEvšetky
'; //alert('skript je spusteny'); var myFunction = function() { var hash = this.getAttribute('data-href'); console.log('clicked on '+hash); qs = {}; const q = hash.split('-'); const q1 = q[0]; const q2 = q[1]; if (q1=='pavilon') { qs.pavilon = q2; } if (q1=='sekcia') { qs.sekcia = q2; } RefreshData(); return false; } var elements = document.getElementsByClassName("linkFilter"); for (var i = 0; i < elements.length; i++) { elements[i].addEventListener('click', myFunction, false); } function RefreshData() { var link; var items = document.querySelectorAll('.companyItem'); if (qs) { console.log('filter',qs); [].forEach.call(items, function(item) { if (!qs.pavilon && !qs.sekcia) { item.style.display = 'list-item';; } else { item.style.display = 'none';; } }); var items = document.querySelectorAll('.linkFilter span'); [].forEach.call(items, function(item) { item.style.fontWeight = "normal";; item.style.color = "#000000";; }); if (qs.pavilon) { link = document.querySelector('#linkPavilon'+qs.pavilon+' span'); link.style.fontWeight = "bold"; link.style.color = "#c81f1d"; //style.fontWeight='bold'; var items = document.querySelectorAll('.itemPavilon'+qs.pavilon); [].forEach.call(items, function(item) { item.style.display = 'list-item';; }); } if (qs.sekcia) { link = document.querySelector('#linkSekcia'+qs.sekcia+' span'); link.style.fontWeight = "bold"; link.style.color = "#c81f1d"; var items = document.querySelectorAll('.itemSekcia'+qs.sekcia); [].forEach.call(items, function(item) { item.style.display = 'list-item';; }); } } else { console.log('no filter'); [].forEach.call(items, function(item) { item.style.display = 'list-item'; }); } } RefreshData();