1(function(){ 2 'use strict'; 3 var cfg = window.SomehTables || {}; 4 5 function qsa(root, sel){ try{return Array.prototype.slice.call((root||document).querySelectorAll(sel));}catch(e){return [];} } 6 function countCols(table){ 7 var row = table.querySelector('thead tr') || table.querySelector('tr'); 8 return row && row.children ? row.children.length : 0; 9 } 10 function addLabels(table){ 11 var heads=qsa(table,'thead tr:first-child th, thead tr:first-child td').map(function(el){return (el.textContent||'').replace(/\s+/g,' ').trim();}); 12 if(!heads.length){heads=qsa(table,'tr:first-child th').map(function(el){return (el.textContent||'').replace(/\s+/g,' ').trim();});} 13 if(!heads.length)return; 14 qsa(table,'tbody tr').forEach(function(row){qsa(row,'td').forEach(function(td,i){if(!td.getAttribute('data-label')&&heads[i])td.setAttribute('data-label',heads[i]);});}); 15 } 16 function ensureWrap(table){ 17 if(table.closest('.someh-table-wrap'))return table.closest('.someh-table-wrap'); 18 var wrap=document.createElement('div'); 19 wrap.className='someh-table-wrap someh-table-theme-'+(cfg.theme||1)+' someh-table-mobile-fit someh-table-density-'+(cfg.density||'normal'); 20 if(table.parentNode){table.parentNode.insertBefore(wrap,table);wrap.appendChild(table);} 21 return wrap; 22 } 23 function shouldTarget(table){ 24 if(!table||table.closest('.wp-admin'))return false; 25 if(table.classList.contains('someh-table')||table.classList.contains('mtable')||table.classList.contains('price-table')||table.classList.contains('rtbl'))return true; 26 if(!cfg.applyAll)return false; 27 return !!table.closest('article,.entry-content,.post-content,.site-main,.elementor-widget-theme-post-content,.woocommerce-Tabs-panel,.wp-block-post-content'); 28 } 29 30 function applyColumnWidths(table){ 31 var cols=countCols(table); if(cols<2||cols>8)return; 32 var widths=[]; 33 if(cols===2)widths=[35,65]; 34 else if(cols===3)widths=[32,38,30]; 35 else if(cols===4)widths=[25,25,25,25]; 36 else {for(var i=0;i<cols;i++)widths.push(100/cols);} 37 var cg=table.querySelector('colgroup[data-someh-cols]'); 38 if(!cg){cg=document.createElement('colgroup');cg.setAttribute('data-someh-cols','1');table.insertBefore(cg,table.firstChild);} 39 while(cg.children.length<cols)cg.appendChild(document.createElement('col')); 40 for(var j=0;j<cg.children.length;j++)cg.children[j].style.width=j<cols?(Math.round(widths[j]*1000)/1000)+'%':''; 41 table.style.tableLayout='fixed'; 42 } 43 44 function markMobile(table,wrap){ 45 var cols=countCols(table); 46 table.setAttribute('data-someh-cols',String(cols||0)); 47 wrap.setAttribute('data-someh-cols',String(cols||0)); 48 var mobileFont = cols >= 9 ? 7.4 : cols === 8 ? 8.2 : cols === 7 ? 8.7 : cols === 6 ? 9.2 : cols === 5 ? 9.8 : cols === 4 ? 10.5 : cols === 3 ? 11.5 : 12.5; 49 wrap.style.setProperty('--someh-mobile-cell-font', mobileFont + 'px'); 50 wrap.classList.remove('someh-table-mobile-smart','someh-table-mobile-card','someh-table-mobile-scroll'); 51 wrap.classList.add('someh-table-mobile-fit'); 52 wrap.setAttribute('data-someh-mobile-resolved','fit'); 53 } 54 55 function enforceDesktopFit(table,wrap){ 56 if(!table||!wrap)return; 57 table.style.width='100%'; 58 table.style.maxWidth='100%'; 59 table.style.minWidth='0'; 60 table.style.tableLayout='fixed'; 61 wrap.style.maxWidth='100%'; 62 wrap.style.overflowX='hidden'; 63 } 64 65 function normalizeTable(table){ 66 if(!shouldTarget(table))return; 67 table.classList.add('someh-table','someh-table-theme-'+(cfg.theme||1),'someh-table-density-'+(cfg.density||'normal')); 68 if(cfg.hideCaption){qsa(table,'caption').forEach(function(c){c.remove();});} 69 addLabels(table); 70 applyColumnWidths(table); 71 var wrap=ensureWrap(table); markMobile(table,wrap); enforceDesktopFit(table,wrap); 72 if(cfg.priceHelper)processPrices(table); 73 } 74 75 function normalizeDigitsForParse(s){ 76 return String(s||'').replace(/[Û°-Û¹]/g,function(d){return String('Û°Û±Û²Û³Û´ÛµÛ¶Û·Û¸Û¹'.indexOf(d));}).replace(/[Ù -Ù©]/g,function(d){return String('٠١٢٣٤٥٦٧٨٩'.indexOf(d));}).replace(/[Ù¬,]/g,',').replace(/Ù«/g,'.').replace(/[\u200e\u200f\u061c]/g,''); 77 } 78 function priceRange(text){ 79 var raw=String(text||'').replace(/\u200c/g,' ').replace(/\s+/g,' ').trim(); 80 if(raw.indexOf('تا')===-1 || !/(Ù ÛÙÛØ§Ø±Ø¯\s*تÙ٠اÙ|Ù ÛÙÛÙÙ\s*تÙ٠اÙ|ÙØ²Ø§Ø±\s*تÙ٠اÙ|تÙ٠اÙ|Ø±ÛØ§Ù)/.test(raw))return null; 81 if(/(Ø±ÙØ²(?:\s*کارÛ)?|ÙÙØªÙ|٠اÙ|ساعت)/.test(raw))return null; 82 var m=raw.match(/([0-9Û°-Û¹Ù -Ù©]+(?:[\/\.,٫٬][0-9Û°-Û¹Ù -Ù©]+)*)\s*تا\s*([0-9Û°-Û¹Ù -Ù©]+(?:[\/\.,٫٬][0-9Û°-Û¹Ù -Ù©]+)*)/); 83 var cur=raw.match(/(Ù ÛÙÛØ§Ø±Ø¯\s*تÙ٠اÙ|Ù ÛÙÛÙÙ\s*تÙ٠اÙ|ÙØ²Ø§Ø±\s*تÙ٠اÙ|تÙ٠اÙ|Ø±ÛØ§Ù)/); 84 return m&&cur?{min:m[1],max:m[2],currency:cur[0]}:null; 85 } 86 function formatRange(el,parts){ 87 if(!el||el.getAttribute('data-someh-price-ready')==='1')return; 88 var wrap=document.createElement('span'); wrap.className='someh-price-range'; wrap.setAttribute('dir','rtl'); 89 [['min',parts.min],['sep',' تا '],['max',parts.max],['currency',' '+parts.currency]].forEac
89h(function(pair){var s=document.createElement('span');s.className=pair[0];s.textContent=pair[1];wrap.appendChild(s);}); 90 el.textContent='';el.appendChild(wrap);el.setAttribute('data-someh-price-ready','1'); 91 var numeric=normalizeDigitsForParse(parts.min).replace(/[^0-9.]/g,''); if(numeric)el.setAttribute('data-someh-price-min',numeric); 92 } 93 function processPrices(table){ 94 qsa(table,'.price-badge,td,th').forEach(function(el){ 95 if(el.querySelector&&el.querySelector('.someh-price-range'))return; 96 var p=priceRange(el.textContent||''); if(!p)return; 97 if(el.matches('.price-badge'))formatRange(el,p); 98 else { 99 var badge=el.querySelector('.price-badge'); 100 if(badge)formatRange(badge,p); 101 else if((el.textContent||'').trim().length<100)formatRange(el,p); 102 } 103 }); 104 } 105 106 function scan(root){qsa(root||document,'table').forEach(normalizeTable);} 107 function run(){scan(document);} 108 if(document.readyState==='loading')document.addEventListener('DOMContentLoaded',run);else run(); 109 window.addEventListener('load',run,{once:true}); 110 111 var timer=null; 112 if(window.MutationObserver){ 113 try{ 114 new MutationObserver(function(list){ 115 var relevant=false; 116 for(var i=0;i<list.length&&!relevant;i++){ 117 for(var j=0;j<list[i].addedNodes.length;j++){ 118 var n=list[i].addedNodes[j]; 119 if(n&&n.nodeType===1&&(n.tagName==='TABLE'||(n.querySelector&&n.querySelector('table')))){relevant=true;break;} 120 } 121 } 122 if(!relevant)return; 123 clearTimeout(timer);timer=setTimeout(run,90); 124 }).observe(document.body||document.documentElement,{childList:true,subtree:true}); 125 }catch(e){} 126 } 127 window.SomehTablesRefresh=run; 128})();
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.