PageSourceSearch

https://canestrato.ru/templates/vizzel/js/nx-finish.js?v=20260921-canestrato1

js canestrato.ru collected 2026-10-08 23:58:42 UTC 8,782 bytes, 29 lines download raw bytes

1(function(){
2 'use strict';
3 function priceAndMode(){document.querySelectorAll('.nx-detail-price,.nx-price').forEach(function(el){var currency=el.querySelector('.currency');if(currency&&currency.textContent.trim()==='₽'&&el.children.length===1){el.textContent=el.textContent.replace(/₽\s*([\d][\d\s.,]*)/,'$1 ₽').replace(/\s+₽/,' ₽').trim();}});var result=document.querySelector('[data-nx-ai-result]');if(result)document.querySelectorAll('[data-nx-ai-mode]').forEach(function(el){el.textContent=result.dataset.nxAiResult==='1'?'✦ AI-поиск':'Обычный поиск';});}priceAndMode();document.addEventListener('nx:results-updated',priceAndMode);
4 // A progressive tree replaces the long select; the original submitted value survives.
5 var select=document.querySelector('[data-nx-category-select]');
6 if(select){
7  var rows=[],stack=[];Array.from(select.options).forEach(function(o){var prefix=(o.textContent.match(/^(?:— )*/)||[''])[0],depth=prefix.length/2,name=o.textContent.slice(prefix.length);if(o.value==='0')return;rows.push({id:o.value,name:name,count:o.dataset.count,parent:depth?stack[depth-1]:'0'});stack[depth]=o.value;});
8  var byId=new Map(rows.map(function(r){return [r.id,r];})),current=select.value,level=current==='0'?'0':byId.get(current)?.parent||'0';
9  var trigger=document.createElement('button');trigger.type='button';trigger.className='nx-category-picker-button';trigger.setAttribute('aria-haspopup','dialog');trigger.textContent=(byId.get(current)?.name||'Все категории')+' ⌄';select.hidden=true;select.after(trigger);
10  var dialog=document.createElement('dialog');dialog.className='nx-category-dialog';dialog.innerHTML='<header><div><small>КАТЕГОРИЯ ПОИСКА</small><h2>Выберите категорию</h2></div><button type="button" data-close aria-label="Закрыть выбор категории">×</button></header><input type="search" placeholder="Найти категорию" aria-label="Найти категорию"><nav></nav><div class="nx-category-choices"></div><footer><span role="status"></span><button type="button" data-apply>Выбрать</button></footer>';document.body.append(dialog);
11  var query=dialog.querySelector('input'),list=dialog.querySelector('.nx-category-choices'),nav=dialog.querySelector('nav');
12  function ancestors(id){var names=[],seen=new Set();while(id!=='0'&&byId.has(id)&&!seen.has(id)){seen.add(id);var r=byId.get(id);names.unshift(r.name);id=r.parent;}return names.join(' › ');}
13  function button(label,action){var b=document.createElement('button');b.type='button';b.textContent=label;b.addEventListener('click',action);return b;}
14  function render(){nav.replaceChildren();list.replaceChildren();nav.append(button('Все категории',function(){level='0';current='0';query.value='';render();}));if(level!=='0')nav.append(button('← '+ancestors(level),function(){level=byId.get(level)?.parent||'0';query.value='';render();}));var q=query.value.trim().toLowerCase();var found=rows.filter(function(r){return r.count!=='0'&&(q?r.name.toLowerCase().includes(q):r.parent===level);}).slice(0,80);found.forEach(function(r){var row=document.createElement('div');row.className='nx-category-choice'+(current===r.id?' active':'');var choose=button(r.name,function(){current=r.id;if(rows.some(function(c){return c.parent===r.id;})){level=r.id;query.value='';}render();});choose.title=ancestors(r.id);if(r.count!==undefined&&r.count!==''){var count=document.createElement('small');count.className='nx-category-count';count.textContent=r.count;count.title='Объявлений в выбранном регионе';choose.append(count);}row.append(choose);if(rows.some(function(c){return c.parent===r.id;}))row.append(button('›',function(){level=r.id;current=r.id;query.value='';render();}));list.append(row);});if(!found.length)list.textContent=q?'Категории не найдены.':'Подкатегорий нет. Подтвердите выбранную категорию.';dialog.querySelector('[role=status]').textContent='Выбрано: '+(ancestors(current)||'Все категории');}
15  trigger.addEventListener('click',function(){current=select.value;level=byId.get(current)?.parent||'0';query.value='';render();dialog.showModal();query.focus();});query.addEventListener('input',render);dialog.querySelector('[data-close]').onclick=function(){dialog.close();};dialog.addEventListener('click',function(e){if(e.target===dialog)dialog.close();});dialog.addEventListener('close',function(){trigger.focus();});dialog.querySelector('[data-apply]').onclick=function(){select.value=current;trigger.textContent=(byId.get(current)?.name||'Все категории')+' ⌄';dialog.close();select.dispatchEvent(new Event('change',{bubbles:true}));};
16 }
17 function compactFields(){document.querySelectorAll('.nx-facet-grid > [data-field-id]').forEach(function(item){if(item.dataset.nxCompact)return;item.dataset.nxCompact='1';var title=item.dataset.bsbTitle||item.querySelector('.list-title')?.textContent||'';if(!item.querySelector('.list-title')){var label=document.createElement('div');label.className='list-title';label.textContent=title;item.prepend(label);}var range=item.querySelector('.slider-inputs');if(range){var details=document.createElement('details');details.className='nx-range-field';var summary=document.createElement('summary');summary.textContent='Любое значение';details.append(summary);var pane=document.createElement('div');pane.className='nx-range-options';range.before(details);pane.append(range);var disable=item.querySelector('.slider-disabler');if(disable)pane.append(disable);details.append(pane);
17function update(){var inactive=range.classList.contains('slider-disabled');summary.textContent=inactive?'Любое значение':(range.querySelector('.from')?.value||'От')+' — '+(range.querySelector('.to')?.value||'До');}new MutationObserver(update).observe(range,{attributes:true,attributeFilter:['class']});item.addEventListener('change',update);update();}
18 var nativeSelect=item.querySelector('select');if(nativeSelect&&nativeSelect.options[0]&&nativeSelect.options[0].value==='')nativeSelect.options[0].textContent='Любое значение';
19 });}
20 var advanced=document.querySelector('.block_search_bottom_ajax');if(advanced)new MutationObserver(compactFields).observe(advanced,{childList:true});compactFields();
21 // Keep native coordinate fields and geocoder events; only the visible map changes.
22 function editors(){document.querySelectorAll('[data-nx-map-editor]').forEach(function(root){if(root.dataset.ready)return;root.dataset.ready='1';var input=root.querySelector('input[data-nx-map-value]'),canvas=root.querySelector('[data-nx-osm-editor]'),details=root.querySelector('details'),status=root.querySelector('[role=status]');var last='';
23  function point(){var p=input.value.split(',');return {lat:p[0],lng:p[1],zoom:p[2]};}
24  function describe(){status.textContent=input.value?'✓ Точка установлена: '+input.value.split(',').slice(0,2).join(', '):'Укажите адрес и поставьте точку на карте.';root.querySelector('[data-clear]').hidden=!input.value;}
25  function mount(){if(!details.open||!window.NxOSM)return;NxOSM.picker(canvas,input.value?point():null,function(lat,lng,zoom){input.value=lat.toFixed(7)+','+lng.toFixed(7)+','+zoom;last=input.value;input.dispatchEvent(new Event('change',{bubbles:true}));describe();},status);last=input.value;describe();}
26  try{details.open=localStorage.getItem('nx-map-editor-open')==='1';}catch(e){}details.addEventListener('toggle',function(){try{localStorage.setItem('nx-map-editor-open',details.open?'1':'0');}catch(e){}mount();});input.addEventListener('change',function(){describe();if(input.value!==last){last=input.value;if(details.open)NxOSM.setPoint(canvas,point());}});root.querySelector('[data-clear]').onclick=function(){input.value='';last='';mount();input.dispatchEvent(new Event('change',{bubbles:true}));};root.querySelector('[data-locate]').onclick=function(){if(!navigator.geolocation){status.textContent='Автоопределение недоступно.';return;}navigator.geolocation.getCurrentPosition(function(p){input.value=p.coords.latitude.toFixed(7)+','+p.coords.longitude.toFixed(7)+',14';details.open=true;mount();input.dispatchEvent(new Event('change',{bubbles:true}));},function(){status.textContent='Не удалось определить место. Поставьте точку вручную.';},{timeout:10000});};describe();mount();
27 });}
28 var pending=false;new MutationObserver(function(){if(pending)return;pending=true;queueMicrotask(function(){pending=false;editors();});}).observe(document.body,{childList:true,subtree:true});editors();
29})();

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.