|
|
|
|
@ -4947,6 +4947,7 @@ function build_filters_period () { |
|
|
|
|
function submit_search_form () { |
|
|
|
|
var $form = $('.filter_form'), |
|
|
|
|
params = $form.serialize(), |
|
|
|
|
paramsForTop = $form.serializeArray(), |
|
|
|
|
filters_url = $form.data('formurl'), |
|
|
|
|
results_url = $form.data('resultsurl'), |
|
|
|
|
$loader = $('#wait-ajax'); |
|
|
|
|
@ -4960,7 +4961,7 @@ function submit_search_form () { |
|
|
|
|
$.getJSON(results_url, params, function(data) { |
|
|
|
|
if (data.success) { |
|
|
|
|
|
|
|
|
|
$('.page-body').html(data.results); |
|
|
|
|
$('.page-body').html(data.results).prepend('<div id="expo_top_events"></div>'); |
|
|
|
|
build_sidebar(); |
|
|
|
|
$loader.hide(); |
|
|
|
|
} |
|
|
|
|
@ -4974,6 +4975,105 @@ function submit_search_form () { |
|
|
|
|
build_filters_period(); |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
var API_URL_ROOT = "/expo-b/get-tops/"; |
|
|
|
|
var PARENT_ID = "expo_top_events"; |
|
|
|
|
|
|
|
|
|
var getUrl = function () { |
|
|
|
|
var search = []; |
|
|
|
|
|
|
|
|
|
var parts = /^\/([^\/]+)(?:\/|$)/i.exec(location.pathname); |
|
|
|
|
if (parts) { |
|
|
|
|
search.push("catalog=" + encodeURIComponent(parts[1])); |
|
|
|
|
} else { |
|
|
|
|
search.push("catalog="); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
var data = window.sendData, theme = []; |
|
|
|
|
$.each(paramsForTop, function(i,val){ |
|
|
|
|
if(val.name === 'theme') { |
|
|
|
|
theme.push(parseInt(val.value)); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
data.theme = theme; |
|
|
|
|
console.log('NEW:',data); |
|
|
|
|
if (data instanceof Object) { |
|
|
|
|
for (var key in data) { |
|
|
|
|
if (data.hasOwnProperty(key)) { |
|
|
|
|
var value = data[key]; |
|
|
|
|
|
|
|
|
|
if (value instanceof Array) { |
|
|
|
|
for (var i = 0, l = value.length; i < l; i++) { |
|
|
|
|
search.push(encodeURIComponent(key) + "=" + encodeURIComponent(value[i])); |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
search.push(encodeURIComponent(key) + "=" + encodeURIComponent(value)); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return API_URL_ROOT + "?" + search.join("&"); |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
var runCallback = function (callback, arg) { |
|
|
|
|
try { |
|
|
|
|
callback(arg); |
|
|
|
|
} catch (error) { |
|
|
|
|
// do nothing
|
|
|
|
|
} |
|
|
|
|
// console.info('callback Done');
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
var getTops = function (url, callback) { |
|
|
|
|
var xhr = new XMLHttpRequest(); |
|
|
|
|
xhr.open("GET", url, true); |
|
|
|
|
|
|
|
|
|
xhr.onreadystatechange = function (event) { |
|
|
|
|
if (event.target.readyState === 4) { |
|
|
|
|
if (event.target.status === 200) { |
|
|
|
|
if (document.readyState === "loading" && !window.marker_DOMtopjsElementInserted) { |
|
|
|
|
// console.info('setting DOMContentLoaded event listener');
|
|
|
|
|
// console.info('setting DOMtopjsElementInserted event listener');
|
|
|
|
|
// document.addEventListener("DOMContentLoaded", function() {
|
|
|
|
|
|
|
|
|
|
document.addEventListener("DOMtopjsElementInserted", function() { |
|
|
|
|
runCallback(callback, event.target.responseText); |
|
|
|
|
}); |
|
|
|
|
} else { |
|
|
|
|
runCallback(callback, event.target.responseText); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
xhr.send(); |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
var removeDublicates = function () { |
|
|
|
|
$('div#' + PARENT_ID + ' ul li.cl-item').each(function(index, el) { |
|
|
|
|
$('div.page-body ul.cat-list li.cl-item[data-slug=\'' + $(el).data('slug') + '\']').not(el).remove(); |
|
|
|
|
}); |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
var insertTops = function (text) { |
|
|
|
|
var parent = document.getElementById(PARENT_ID); |
|
|
|
|
|
|
|
|
|
if (parent) { |
|
|
|
|
parent.innerHTML = text; |
|
|
|
|
// $(document).ready(function () {
|
|
|
|
|
// removeDublicates();
|
|
|
|
|
// });
|
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
var main = function () { |
|
|
|
|
getTops(getUrl(), insertTops); |
|
|
|
|
}; |
|
|
|
|
// main();
|
|
|
|
|
// window.addEventListener("load", main);
|
|
|
|
|
// document.addEventListener("DOMContentLoaded", main);
|
|
|
|
|
main(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$(document).ready(function () { |
|
|
|
|
|