1// Only these four entry scripts may be requested by our code. TradingView owns 2// the embedded service and its subsequent network requests; see the privacy copy. 3const scripts = Object.freeze({ 4 ticker:'https://widgets.tradingview-widget.com/w/en/tv-ticker-tape.js', 5 stock:'https://s3.tradingview.com/external-embedding/embed-widget-stock-heatmap.js', 6 crypto:'https://s3.tradingview.com/external-embedding/embed-widget-crypto-coins-heatmap.js', 7 forex:'https://widgets.tradingview-widget.com/w/en/tv-forex-table.js' 8}); 9const ar=document.documentElement.dir==='rtl'; 10for(const section of document.querySelectorAll('[data-market-widget]')) { 11 const kind=section.dataset.marketWidget; 12 if(!Object.hasOwn(scripts,kind))continue; 13 const status=section.querySelector('.market-status'); 14 const host=kind==='ticker'?section:section.querySelector('.tradingview-widget-container'); 15 const script=document.createElement('script'); 16 script.src=scripts[kind];script.async=true; 17 const fail=()=>{status.hidden=false;status.textContent=status.dataset.failure;section.dataset.state='failed';}; 18 // Keep a useful local fallback visible while the optional third-party widget 19 // initializes; a slow service must never leave a permanent "Loading" label. 20 status.textContent=status.dataset.failure; 21 const timeout=setTimeout(fail,15000); 22 const ready=()=>{clearTimeout(timeout);status.hidden=true;section.dataset.state='ready';}; 23 script.addEventListener('error',()=>{clearTimeout(timeout);fail();},{once:true}); 24 if(kind==='ticker') { 25 script.type='module'; 26 // Registration means the native component can render, not that quotes arrived. 27 // A late definition may recover from a slow network timeout. 28 customElements.whenDefined('tv-ticker-tape').then(ready,()=>{clearTimeout(timeout);fail();}); 29 } else if(kind==='forex') { 30 script.type='module'; 31 script.addEventListener('load',()=>{ 32 customElements.whenDefined('tv-forex-table').then(()=>{ 33 // Element registration is not evidence that price data arrived. Keep a 34 // local availability note; the element handles its own data-loading state. 35 clearTimeout(timeout);status.textContent=ar?'إذا ÙÙ ØªØ¸ÙØ± Ø§ÙØ£Ø³Ø¹Ø§Ø±Ø استخد٠٠عÙÙ٠ات Ø§ÙØµÙØØ© اÙ٠ستÙÙØ© Ø¹Ù Ø§ÙØ£Ø¯Ø§Ø©.':'If prices do not appear, the page information remains available without the widget.'; 36 section.dataset.state='registered'; 37 }); 38 },{once:true}); 39 } else { 40 const base={width:'100%',height:440,locale:ar?'ar':'en',colorTheme:'light'}; 41 const config=kind==='stock'?{...base,dataSource:'SPX500',blockSize:'market_cap_basic',blockColor:'change',grouping:'sector',exchanges:[],hasTopBar:false,isDataSetEnabled:false,isZoomEnabled:true,hasSymbolTooltip:true,isMonoSize:false,symbolUrl:''}: 42 {...base,dataSource:'Crypto',blockSize:'market_cap_calc',blockColor:'change',hasTopBar:false,isDataSetEnabled:false,isZoomEnabled:true,hasSymbolTooltip:true,isMonoSize:false,symbolUrl:''}; 43 // Non-executable JSON consumed by TradingView's external loader. 44 script.textContent=JSON.stringify(config); 45 const observer=new MutationObserver(()=>{ 46 const frame=host.querySelector('iframe'); 47 if(!frame)return; 48 frame.title=section.getAttribute('aria-label'); 49 frame.addEventListener('load',ready,{once:true}); 50 frame.addEventListener('error',fail,{once:true}); 51 observer.disconnect(); 52 }); 53 observer.observe(host,{childList:true,subtree:true}); 54 setTimeout(()=>observer.disconnect(),16000); 55 } 56 host.append(script); 57}
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.