var result = {};
$(function () {
var links1 = $('#navCatLvl1 a'),
index = 0,
observer = new MutationObserver(function (e) {
var nodes = checkInsertion(e[0].addedNodes);
});
observer.observe(document.querySelector('#childCategories'), {
childList: true
});
simulateClick(0);
function simulateClick (index) {
result[links1.eq(index).data('catid')] = {
url: links1.eq(index).data('filter-url'),
text: links1.eq(index).data('text'),
sub: {}
};
links1.eq(index).trigger('click');
}
function checkInsertion (nodes) {
for (var i = 0; i < nodes.length; i++) {
if (nodes[i].nodeType == 1) {
var elems = $(nodes[i]).find('[data-level]');
elems.each(function () {
var $item = $(this);
result[links1.eq(index).data('catid')].sub[$item.data('catid')] = {
url: $item.eq(index).data('filter-url'),
text: $item.eq(index).data('text'),
sub: {}
}
});
index++;
if (links1.eq(index).length) {
//simulateClick(index);
}
}
}
}
console.log(result);
});
var observer = new MutationObserver(
function (e) {
var nodes = e[0].addedNodes;
for (var i = 0; i < nodes.length; i++) {
if (nodes[i].nodeType == 1) {
var elems = $(nodes[i]).find('[data-level]');
elems.each(function () {
var $item = $(this);
console.log($item.data());
});
break;
}
}
}
);
observer.observe(document.querySelector('#childCategories'), {
childList: true
});
Ладно, поставлю себе галочку и вот вам 3 варианта:
1) Правильный
1) Открываем в новом окне (просто новая вкладка)
1) Открываем в окне с заданными размерами
JS
HTML