SC CODE: Function InitializePrivate() Uint64
10 IF init() == 0 THEN GOTO 30
20 RETURN 1
30 STORE("nameHdr", "main-utils.js")
31 STORE("descrHdr", "Utility functions and data caching")
32 STORE("iconURLHdr", "")
33 STORE("dURL", "explorer.tela")
34 STORE("docType", "TELA-JS-1")
35 STORE("subDir", "")
36 STORE("fileCheckC", "2c2cfdce29f7c9fb6a36193980ad3edea7801480fafa83d983d1e656b0605b9d")
37 STORE("fileCheckS", "2e20e8fab95d8df841e21ee707383c1cfa3017731c0629d953c6644e03856afa")
100 RETURN 0
End Function
Function init() Uint64
10 IF EXISTS("owner") == 0 THEN GOTO 30
20 RETURN 1
30 STORE("owner", address())
50 STORE("docVersion", "1.0.0")
60 STORE("hash", HEX(TXID()))
70 STORE("likes", 0)
80 STORE("dislikes", 0)
100 RETURN 0
End Function
Function address() String
10 DIM s as String
20 LET s = SIGNER()
30 IF IS_ADDRESS_VALID(s) THEN GOTO 50
40 RETURN "anon"
50 RETURN ADDRESS_STRING(s)
End Function
Function Rate(r Uint64) Uint64
10 DIM addr as String
15 LET addr = address()
16 IF r < 100 && EXISTS(addr) == 0 && addr != "anon" THEN GOTO 30
20 RETURN 1
30 STORE(addr, ""+r+"_"+BLOCK_HEIGHT())
40 IF r < 50 THEN GOTO 70
50 STORE("likes", LOAD("likes")+1)
60 RETURN 0
70 STORE("dislikes", LOAD("dislikes")+1)
100 RETURN 0
End Function
/*
// TELA Explorer - Utilities Module (Production - < 18KB)
// Live blocks, caching, and utility functions
var bl={e:!1,h:0,i:null,r:0,m:3,u:!1,d:18000,t(){this.e=!this.e;this.b();this.e?this.s():this.x()},b(){var b=document.getElementById('blocks-live-toggle');if(b){b.innerHTML=this.e?'● LIVE':'○ LIVE';b.style.background=this.e?'rgba(74,222,128,0.1)':'rgba(139,139,139,0.1)';b.style.borderColor=this.e?'#4ade80':'#8b8b8b';b.style.color=this.e?'#4ade80':'#8b8b8b'}},s(){if(this.i)return;this.r=0;this.d=18000;this.i=setInterval(async()=>{if(window.r==='home'&&window.xswd&&window.connectionStatus==='connected'&&!this.u)await this.su()},this.d)},x(){if(this.i){clearInterval(this.i);this.i=null}this.r=0;this.u=!1},async su(){if(this.u)return;this.u=!0;try{if(window.lbe)await window.lbe();this.r=0;this.d=18000}catch(e){this.r++;if(this.r>=this.m){this.d=Math.min(60000,this.d*1.5);this.r=0}}finally{this.u=!1}},async sb(n){try{var c=await window.lm('blocks-core');if(!c)return;var ct=document.getElementById('blocks-rows-container');if(!ct)return;var nn=n-this.h;if(nn<=0)return;var nb=[];for(var h=this.h+1;h<=n;h++){try{var bd=await window.gx('DERO.GetBlock',{height:h});if(bd&&bd.block_header)nb.push({data:bd,height:h})}catch(e){}}requestAnimationFrame(async()=>{var f=document.createDocumentFragment();for(var i=nb.length-1;i>=0;i--){var nr=await this.cr(nb[i].data,nb[i].height);nr.classList.add('new-block-highlight');nr.style.cssText+='background:rgba(74,222,128,0.1);border-left:3px solid #4ade80;';f.appendChild(nr)}ct.insertBefore(f,ct.firstChild);while(ct.children.length>8)ct.removeChild(ct.lastChild);setTimeout(()=>{var hl=ct.querySelectorAll('.new-block-highlight');hl.forEach((row,idx)=>{setTimeout(()=>{row.style.transition='all 0.8s ease';row.style.background='transparent';row.style.borderLeft='1px solid rgba(255,255,255,0.05)';setTimeout(()=>row.classList.remove('new-block-highlight'),800)},2000+idx*100)})},100)});this.h=n;var st='• Live feed active • New block detected!';var il=document.getElementById('blocks-info-line');if(il)il.innerHTML='Latest blocks mined on the DERO blockchain • Height: <span style="color:#52c8db;font-weight:600;">'+n.toLocaleString()+'</span><span style="color:#4ade80;font-size:0.8rem;">'+st+'</span>';setTimeout(()=>{var st='• Live feed active';var il=document.getElementById('blocks-info-line');if(il)il.innerHTML='Latest blocks mined on the DERO blockchain • Height: <span style="color:#52c8db;font-weight:600;">'+n.toLocaleString()+'</span><span style="color:#888;font-size:0.8rem;">'+st+'</span>'},3000)}catch(e){this.h=n;throw e}},async cr(bd,h){var bh=bd.block_header,now=Date.now()/1000,bt=bh.timestamp||0;if(bt>1e12)bt/=1000;var age=Math.abs(now-bt),ad='';if(age<60)ad=Math.floor(age)+'s';else if(age<3600)ad=Math.floor(age/60)+'m';else if(age<86400)ad=Math.floor(age/3600)+'h';else if(age<86400*7)ad=Math.floor(age/86400)+'d';else ad='7d+';var bs=bh.block_size||0,sd='';if(bs<1024)sd=bs+'B';else if(bs<1024*1024)sd=Math.round(bs/1024)+'KB';else sd=Math.round(bs/(1024*1024))+'MB';var m=bh.miners?.length||bd.miners?.length||1,d=(bh.difficulty||0).toLocaleString(),fh=bh.hash||'N/A',r=document.createElement('div');r.style.cssText='display:grid;grid-template-columns:180px 1fr 70px 80px 100px 70px;gap:0.8rem;padding:0.75rem;border-bottom:1px solid rgba(255,255,255,0.05);align-items:center;font-size:0.85rem;cursor:pointer;';r.onmouseover=function(){if(!this.classList.contains('new-block-highlight'))this.style.background='rgba(255,255,255,0.02)'};r.onmouseout=function(){if(!this.classList.contains('new-block-highlight'))this.style.background='transparent'};r.onclick=function(){window.location.hash='block/'+h};r.innerHTML='<div><div style="color:#52c8db;font-weight:600;font-size:1rem;">'+h.toLocaleString()+'</div><div style="color:#888;font-size:0.75rem;margin-top:0.2rem;">Block Height</div></div><div style="font-family:monospace;color:#b959b6;font-size:0.75rem;line-height:1.1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;">'+fh+'</div><div style="color:#888;text-align:center;">'+ad+'</div><div style="color:#fbbf24;text-align:center;font-weight:500;">'+sd+'</div><div style="color:#4ade80;text-align:center;font-size:0.8rem;">'+d+'</div><div style="color:#888;text-align:right;font-size:0.8rem;">'+m+'</div>';return r}};
window.blocksLive=bl;
window.toggleBlocksLive=function(){bl.t()};
// Load blocks explorer function
var lbeHtml={err:'<div class="card"><div class="section-header"><h2>XSWD Connection Required</h2></div><div class="error-card"><p>Block explorer requires connection to DERO daemon via XSWD protocol. <button onclick="window.location.reload()" style="background:rgba(82,200,219,0.1);border:1px solid #52c8db;color:#52c8db;padding:0.3rem 0.8rem;border-radius:4px;cursor:pointer;margin-left:0.5rem;">Reconnect</button></p></div></div>',main:'<div class="enhanced-card" id="blocks-container-stable"><div class="card-header"><h2 style="color:#fff;font-size:1.6rem;font-weight:700;margin:0;">Recent Blocks</h2><div class="actions"><button onclick="window.loadBlocksIncremental()" style="background:rgba(82,200,219,0.1);border:1px solid #52c8db;color:#52c8db;padding:0.5rem 1rem;border-radius:6px;cursor:pointer;transition:all 0.2s ease;font-size:0.9rem;margin-right:0.5rem;">View All Blocks</button><button id="blocks-live-toggle" onclick="window.toggleBlocksLive?window.toggleBlocksLive():null" style="background:rgba(74,222,128,0.1);border:1px solid #4ade80;color:#4ade80;padding:0.5rem 1rem;border-radius:6px;cursor:pointer;transition:all 0.2s ease;font-size:0.8rem;font-weight:500;">● LIVE</button></div></div><div class="card-content"><div class="section-info" id="blocks-info-line" style="color:#b3b3b3;font-size:0.9rem;margin-bottom:1.5rem;">Latest blocks mined on the DERO blockchain</div><div id="blocks-data-container" style="background:rgba(0,0,0,0.2);border:1px solid rgba(82,200,219,0.3);border-radius:8px;overflow:hidden;min-height:400px;position:relative;"><div style="display:grid;grid-template-columns:180px 1fr 70px 80px 100px 70px;gap:0.8rem;padding:1rem;border-bottom:2px solid rgba(82,200,219,0.3);font-weight:600;font-size:0.9rem;color:#52c8db;background:rgba(82,200,219,0.1);position:sticky;top:0;z-index:10;"><div>Block Height</div><div>Hash</div><div style="text-align:center;">Age</div><div style="text-align:center;">Size</div><div style="text-align:center;">Difficulty</div><div style="text-align:right;">Miners</div></div><div id="blocks-rows-container" style="position:relative;"><div class="loading-indicator"><div class="loading-text">Loading blockchain data...</div></div></div></div></div></div>'};
async function lbe(){var d=document.getElementById('homepage-block-explorer');if(!d)return;var t=Date.now();try{if(!window.xswd||window.connectionStatus==='disconnected'||!window.xswd.isConnected){d.innerHTML=lbeHtml.err;if(bl.e)bl.x();return}if(!document.getElementById('blocks-container-stable'))d.innerHTML=lbeHtml.main;var c=await window.lm('blocks-core');if(c){var i=await window.gx('DERO.GetInfo');if(i&&i.height>0){var ct=document.getElementById('blocks-rows-container'),li=ct&&ct.innerHTML.includes('Loading blockchain data'),fl=!bl.h||li,nd=i.height>bl.h;if(fl){var h=await c.renderRecentBlocksList(window.gx,i.height,8),lt=Date.now()-t,st=bl.e?' • Live feed active':'';document.getElementById('blocks-info-line').innerHTML='Latest blocks mined on the DERO blockchain • Height: <span style="color:#52c8db;font-weight:600;">'+i.height.toLocaleString()+'</span><span style="color:#888;font-size:0.8rem;">'+st+' ('+lt+'ms)</span>';document.getElementById('blocks-rows-container').innerHTML=h;bl.h=i.height;if(window.initResponsiveHashes)window.initResponsiveHashes()}else if(nd&&bl.e){await bl.sb(i.height);if(window.initResponsiveHashes)window.initResponsiveHashes()}else if(!bl.e){var h=await c.renderRecentBlocksList(window.gx,i.height,8);document.getElementById('blocks-rows-container').innerHTML=h;bl.h=i.height;if(window.initResponsiveHashes)window.initResponsiveHashes()}bl.b();if(nd&&!bl.e){bl.e=!0;bl.b();bl.s()}}else throw new Error('Unable to retrieve blockchain height')}else throw new Error('Unable to load blocks module')}catch(e){var em=e.message||'Unknown error',rb=bl.e?'<button onclick="window.blocksLive.safeUpdate()" style="background:rgba(255,193,7,0.1);border:1px solid #ffc107;color:#ffc107;padding:0.3rem 0.8rem;border-radius:4px;cursor:pointer;margin-left:0.5rem;font-size:0.8rem;">Retry</button>':'';d.innerHTML='<div class="enhanced-card" id="blocks-container-stable"><div class="card-header"><h2 style="color:#fff;font-size:1.6rem;font-weight:700;margin:0;">Recent Blocks</h2><div class="actions"><button onclick="window.loadBlocksIncremental()" style="background:rgba(82,200,219,0.1);border:1px solid #52c8db;color:#52c8db;padding:0.5rem 1rem;border-radius:6px;cursor:pointer;transition:all 0.2s ease;font-size:0.9rem;margin-right:0.5rem;">View All Blocks</button><button id="blocks-live-toggle" onclick="window.toggleBlocksLive?window.toggleBlocksLive():null" style="background:rgba(139,139,139,0.1);border:1px solid #8b8b8b;color:#8b8b8b;padding:0.5rem 1rem;border-radius:6px;cursor:pointer;transition:all 0.2s ease;font-size:0.8rem;font-weight:500;">○ LIVE</button></div></div><div class="card-content"><div class="error-card"><h3>'+em+'</h3><p style="font-size:0.9rem;color:#888;">Connection issue or temporary network problem'+rb+'</p></div></div></div>';bl.b()}}
window.lbe=lbe;
// Enhanced data caching system
var dataCache=new Map();var cacheTimeout={default:15000,blocks:8000,network:5000,transactions:10000};var maxCacheSize=50;
window.getCachedData=function(key,fetchFn,ttl){var now=Date.now();var cached=dataCache.get(key);var timeout=ttl||cacheTimeout[key.split('.')[0]]||cacheTimeout.default;if(cached&&(now-cached.timestamp)<timeout){cached.hits=(cached.hits||0)+1;return Promise.resolve(cached.data)}return fetchFn().then(function(data){if(dataCache.size>=maxCacheSize){var oldest=null;var oldestTime=now;dataCache.forEach(function(value,key){if(value.timestamp<oldestTime){oldest=key;oldestTime=value.timestamp}});if(oldest)dataCache.delete(oldest)}dataCache.set(key,{data:data,timestamp:now,hits:1});return data}).catch(function(err){if(err.message.includes('XSWD not connected')||err.message.includes('Timeout')){setTimeout(function(){window.smartReconnectXSWD()},2000)}if(cached){cached.hits=(cached.hits||0)+1;return cached.data}throw err})};
window.clearCache=function(pattern){if(pattern){dataCache.forEach(function(value,key){if(key.includes(pattern))dataCache.delete(key)})}else{dataCache.clear()}};
window.getCacheStats=function(){var stats={size:dataCache.size,entries:[]};dataCache.forEach(function(value,key){stats.entries.push({key:key,age:Date.now()-value.timestamp,hits:value.hits||0})});return stats};
// Search functionality
async function performSearch(){
const i=document.getElementById('search-input');
if(i&&i.value.trim()){
const u=await window.lm('search');
if(u&&u.performSearch){
window.searchModule = u;
window.TelaSearch = u;
u.performSearch();
}else{
window.location.hash='search/'+encodeURIComponent(i.value.trim());
}
}
}
function initResponsiveHashes(){function checkHashDisplay(){const width=window.innerWidth;const isCompact=width<1200;const hashContainers=document.querySelectorAll('.hash-container');hashContainers.forEach(container=>{if(isCompact){container.classList.add('compact')}else{container.classList.remove('compact')}})}checkHashDisplay();let resizeTimeout;window.addEventListener('resize',()=>{clearTimeout(resizeTimeout);resizeTimeout=setTimeout(checkHashDisplay,100)});document.addEventListener('DOMContentLoaded',checkHashDisplay);window.checkHashDisplay=checkHashDisplay}
if(typeof window!=='undefined'){window.initResponsiveHashes=initResponsiveHashes;initResponsiveHashes()}
window.performSearch=performSearch;
*/ |
SC Arguments: [Name:SC_ACTION Type:uint64 Value:'1' Name:SC_CODE Type:string Value:'Function InitializePrivate() Uint64
10 IF init() == 0 THEN GOTO 30
20 RETURN 1
30 STORE("nameHdr", "main-utils.js")
31 STORE("descrHdr", "Utility functions and data caching")
32 STORE("iconURLHdr", "")
33 STORE("dURL", "explorer.tela")
34 STORE("docType", "TELA-JS-1")
35 STORE("subDir", "")
36 STORE("fileCheckC", "2c2cfdce29f7c9fb6a36193980ad3edea7801480fafa83d983d1e656b0605b9d")
37 STORE("fileCheckS", "2e20e8fab95d8df841e21ee707383c1cfa3017731c0629d953c6644e03856afa")
100 RETURN 0
End Function
Function init() Uint64
10 IF EXISTS("owner") == 0 THEN GOTO 30
20 RETURN 1
30 STORE("owner", address())
50 STORE("docVersion", "1.0.0")
60 STORE("hash", HEX(TXID()))
70 STORE("likes", 0)
80 STORE("dislikes", 0)
100 RETURN 0
End Function
Function address() String
10 DIM s as String
20 LET s = SIGNER()
30 IF IS_ADDRESS_VALID(s) THEN GOTO 50
40 RETURN "anon"
50 RETURN ADDRESS_STRING(s)
End Function
Function Rate(r Uint64) Uint64
10 DIM addr as String
15 LET addr = address()
16 IF r < 100 && EXISTS(addr) == 0 && addr != "anon" THEN GOTO 30
20 RETURN 1
30 STORE(addr, ""+r+"_"+BLOCK_HEIGHT())
40 IF r < 50 THEN GOTO 70
50 STORE("likes", LOAD("likes")+1)
60 RETURN 0
70 STORE("dislikes", LOAD("dislikes")+1)
100 RETURN 0
End Function
/*
// TELA Explorer - Utilities Module (Production - < 18KB)
// Live blocks, caching, and utility functions
var bl={e:!1,h:0,i:null,r:0,m:3,u:!1,d:18000,t(){this.e=!this.e;this.b();this.e?this.s():this.x()},b(){var b=document.getElementById('blocks-live-toggle');if(b){b.innerHTML=this.e?'● LIVE':'○ LIVE';b.style.background=this.e?'rgba(74,222,128,0.1)':'rgba(139,139,139,0.1)';b.style.borderColor=this.e?'#4ade80':'#8b8b8b';b.style.color=this.e?'#4ade80':'#8b8b8b'}},s(){if(this.i)return;this.r=0;this.d=18000;this.i=setInterval(async()=>{if(window.r==='home'&&window.xswd&&window.connectionStatus==='connected'&&!this.u)await this.su()},this.d)},x(){if(this.i){clearInterval(this.i);this.i=null}this.r=0;this.u=!1},async su(){if(this.u)return;this.u=!0;try{if(window.lbe)await window.lbe();this.r=0;this.d=18000}catch(e){this.r++;if(this.r>=this.m){this.d=Math.min(60000,this.d*1.5);this.r=0}}finally{this.u=!1}},async sb(n){try{var c=await window.lm('blocks-core');if(!c)return;var ct=document.getElementById('blocks-rows-container');if(!ct)return;var nn=n-this.h;if(nn<=0)return;var nb=[];for(var h=this.h+1;h<=n;h++){try{var bd=await window.gx('DERO.GetBlock',{height:h});if(bd&&bd.block_header)nb.push({data:bd,height:h})}catch(e){}}requestAnimationFrame(async()=>{var f=document.createDocumentFragment();for(var i=nb.length-1;i>=0;i--){var nr=await this.cr(nb[i].data,nb[i].height);nr.classList.add('new-block-highlight');nr.style.cssText+='background:rgba(74,222,128,0.1);border-left:3px solid #4ade80;';f.appendChild(nr)}ct.insertBefore(f,ct.firstChild);while(ct.children.length>8)ct.removeChild(ct.lastChild);setTimeout(()=>{var hl=ct.querySelectorAll('.new-block-highlight');hl.forEach((row,idx)=>{setTimeout(()=>{row.style.transition='all 0.8s ease';row.style.background='transparent';row.style.borderLeft='1px solid rgba(255,255,255,0.05)';setTimeout(()=>row.classList.remove('new-block-highlight'),800)},2000+idx*100)})},100)});this.h=n;var st='• Live feed active • New block detected!';var il=document.getElementById('blocks-info-line');if(il)il.innerHTML='Latest blocks mined on the DERO blockchain • Height: <span style="color:#52c8db;font-weight:600;">'+n.toLocaleString()+'</span><span style="color:#4ade80;font-size:0.8rem;">'+st+'</span>';setTimeout(()=>{var st='• Live feed active';var il=document.getElementById('blocks-info-line');if(il)il.innerHTML='Latest blocks mined on the DERO blockchain • Height: <span style="color:#52c8db;font-weight:600;">'+n.toLocaleString()+'</span><span style="color:#888;font-size:0.8rem;">'+st+'</span>'},3000)}catch(e){this.h=n;throw e}},async cr(bd,h){var bh=bd.block_header,now=Date.now()/1000,bt=bh.timestamp||0;if(bt>1e12)bt/=1000;var age=Math.abs(now-bt),ad='';if(age<60)ad=Math.floor(age)+'s';else if(age<3600)ad=Math.floor(age/60)+'m';else if(age<86400)ad=Math.floor(age/3600)+'h';else if(age<86400*7)ad=Math.floor(age/86400)+'d';else ad='7d+';var bs=bh.block_size||0,sd='';if(bs<1024)sd=bs+'B';else if(bs<1024*1024)sd=Math.round(bs/1024)+'KB';else sd=Math.round(bs/(1024*1024))+'MB';var m=bh.miners?.length||bd.miners?.length||1,d=(bh.difficulty||0).toLocaleString(),fh=bh.hash||'N/A',r=document.createElement('div');r.style.cssText='display:grid;grid-template-columns:180px 1fr 70px 80px 100px 70px;gap:0.8rem;padding:0.75rem;border-bottom:1px solid rgba(255,255,255,0.05);align-items:center;font-size:0.85rem;cursor:pointer;';r.onmouseover=function(){if(!this.classList.contains('new-block-highlight'))this.style.background='rgba(255,255,255,0.02)'};r.onmouseout=function(){if(!this.classList.contains('new-block-highlight'))this.style.background='transparent'};r.onclick=function(){window.location.hash='block/'+h};r.innerHTML='<div><div style="color:#52c8db;font-weight:600;font-size:1rem;">'+h.toLocaleString()+'</div><div style="color:#888;font-size:0.75rem;margin-top:0.2rem;">Block Height</div></div><div style="font-family:monospace;color:#b959b6;font-size:0.75rem;line-height:1.1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;">'+fh+'</div><div style="color:#888;text-align:center;">'+ad+'</div><div style="color:#fbbf24;text-align:center;font-weight:500;">'+sd+'</div><div style="color:#4ade80;text-align:center;font-size:0.8rem;">'+d+'</div><div style="color:#888;text-align:right;font-size:0.8rem;">'+m+'</div>';return r}};
window.blocksLive=bl;
window.toggleBlocksLive=function(){bl.t()};
// Load blocks explorer function
var lbeHtml={err:'<div class="card"><div class="section-header"><h2>XSWD Connection Required</h2></div><div class="error-card"><p>Block explorer requires connection to DERO daemon via XSWD protocol. <button onclick="window.location.reload()" style="background:rgba(82,200,219,0.1);border:1px solid #52c8db;color:#52c8db;padding:0.3rem 0.8rem;border-radius:4px;cursor:pointer;margin-left:0.5rem;">Reconnect</button></p></div></div>',main:'<div class="enhanced-card" id="blocks-container-stable"><div class="card-header"><h2 style="color:#fff;font-size:1.6rem;font-weight:700;margin:0;">Recent Blocks</h2><div class="actions"><button onclick="window.loadBlocksIncremental()" style="background:rgba(82,200,219,0.1);border:1px solid #52c8db;color:#52c8db;padding:0.5rem 1rem;border-radius:6px;cursor:pointer;transition:all 0.2s ease;font-size:0.9rem;margin-right:0.5rem;">View All Blocks</button><button id="blocks-live-toggle" onclick="window.toggleBlocksLive?window.toggleBlocksLive():null" style="background:rgba(74,222,128,0.1);border:1px solid #4ade80;color:#4ade80;padding:0.5rem 1rem;border-radius:6px;cursor:pointer;transition:all 0.2s ease;font-size:0.8rem;font-weight:500;">● LIVE</button></div></div><div class="card-content"><div class="section-info" id="blocks-info-line" style="color:#b3b3b3;font-size:0.9rem;margin-bottom:1.5rem;">Latest blocks mined on the DERO blockchain</div><div id="blocks-data-container" style="background:rgba(0,0,0,0.2);border:1px solid rgba(82,200,219,0.3);border-radius:8px;overflow:hidden;min-height:400px;position:relative;"><div style="display:grid;grid-template-columns:180px 1fr 70px 80px 100px 70px;gap:0.8rem;padding:1rem;border-bottom:2px solid rgba(82,200,219,0.3);font-weight:600;font-size:0.9rem;color:#52c8db;background:rgba(82,200,219,0.1);position:sticky;top:0;z-index:10;"><div>Block Height</div><div>Hash</div><div style="text-align:center;">Age</div><div style="text-align:center;">Size</div><div style="text-align:center;">Difficulty</div><div style="text-align:right;">Miners</div></div><div id="blocks-rows-container" style="position:relative;"><div class="loading-indicator"><div class="loading-text">Loading blockchain data...</div></div></div></div></div></div>'};
async function lbe(){var d=document.getElementById('homepage-block-explorer');if(!d)return;var t=Date.now();try{if(!window.xswd||window.connectionStatus==='disconnected'||!window.xswd.isConnected){d.innerHTML=lbeHtml.err;if(bl.e)bl.x();return}if(!document.getElementById('blocks-container-stable'))d.innerHTML=lbeHtml.main;var c=await window.lm('blocks-core');if(c){var i=await window.gx('DERO.GetInfo');if(i&&i.height>0){var ct=document.getElementById('blocks-rows-container'),li=ct&&ct.innerHTML.includes('Loading blockchain data'),fl=!bl.h||li,nd=i.height>bl.h;if(fl){var h=await c.renderRecentBlocksList(window.gx,i.height,8),lt=Date.now()-t,st=bl.e?' • Live feed active':'';document.getElementById('blocks-info-line').innerHTML='Latest blocks mined on the DERO blockchain • Height: <span style="color:#52c8db;font-weight:600;">'+i.height.toLocaleString()+'</span><span style="color:#888;font-size:0.8rem;">'+st+' ('+lt+'ms)</span>';document.getElementById('blocks-rows-container').innerHTML=h;bl.h=i.height;if(window.initResponsiveHashes)window.initResponsiveHashes()}else if(nd&&bl.e){await bl.sb(i.height);if(window.initResponsiveHashes)window.initResponsiveHashes()}else if(!bl.e){var h=await c.renderRecentBlocksList(window.gx,i.height,8);document.getElementById('blocks-rows-container').innerHTML=h;bl.h=i.height;if(window.initResponsiveHashes)window.initResponsiveHashes()}bl.b();if(nd&&!bl.e){bl.e=!0;bl.b();bl.s()}}else throw new Error('Unable to retrieve blockchain height')}else throw new Error('Unable to load blocks module')}catch(e){var em=e.message||'Unknown error',rb=bl.e?'<button onclick="window.blocksLive.safeUpdate()" style="background:rgba(255,193,7,0.1);border:1px solid #ffc107;color:#ffc107;padding:0.3rem 0.8rem;border-radius:4px;cursor:pointer;margin-left:0.5rem;font-size:0.8rem;">Retry</button>':'';d.innerHTML='<div class="enhanced-card" id="blocks-container-stable"><div class="card-header"><h2 style="color:#fff;font-size:1.6rem;font-weight:700;margin:0;">Recent Blocks</h2><div class="actions"><button onclick="window.loadBlocksIncremental()" style="background:rgba(82,200,219,0.1);border:1px solid #52c8db;color:#52c8db;padding:0.5rem 1rem;border-radius:6px;cursor:pointer;transition:all 0.2s ease;font-size:0.9rem;margin-right:0.5rem;">View All Blocks</button><button id="blocks-live-toggle" onclick="window.toggleBlocksLive?window.toggleBlocksLive():null" style="background:rgba(139,139,139,0.1);border:1px solid #8b8b8b;color:#8b8b8b;padding:0.5rem 1rem;border-radius:6px;cursor:pointer;transition:all 0.2s ease;font-size:0.8rem;font-weight:500;">○ LIVE</button></div></div><div class="card-content"><div class="error-card"><h3>'+em+'</h3><p style="font-size:0.9rem;color:#888;">Connection issue or temporary network problem'+rb+'</p></div></div></div>';bl.b()}}
window.lbe=lbe;
// Enhanced data caching system
var dataCache=new Map();var cacheTimeout={default:15000,blocks:8000,network:5000,transactions:10000};var maxCacheSize=50;
window.getCachedData=function(key,fetchFn,ttl){var now=Date.now();var cached=dataCache.get(key);var timeout=ttl||cacheTimeout[key.split('.')[0]]||cacheTimeout.default;if(cached&&(now-cached.timestamp)<timeout){cached.hits=(cached.hits||0)+1;return Promise.resolve(cached.data)}return fetchFn().then(function(data){if(dataCache.size>=maxCacheSize){var oldest=null;var oldestTime=now;dataCache.forEach(function(value,key){if(value.timestamp<oldestTime){oldest=key;oldestTime=value.timestamp}});if(oldest)dataCache.delete(oldest)}dataCache.set(key,{data:data,timestamp:now,hits:1});return data}).catch(function(err){if(err.message.includes('XSWD not connected')||err.message.includes('Timeout')){setTimeout(function(){window.smartReconnectXSWD()},2000)}if(cached){cached.hits=(cached.hits||0)+1;return cached.data}throw err})};
window.clearCache=function(pattern){if(pattern){dataCache.forEach(function(value,key){if(key.includes(pattern))dataCache.delete(key)})}else{dataCache.clear()}};
window.getCacheStats=function(){var stats={size:dataCache.size,entries:[]};dataCache.forEach(function(value,key){stats.entries.push({key:key,age:Date.now()-value.timestamp,hits:value.hits||0})});return stats};
// Search functionality
async function performSearch(){
const i=document.getElementById('search-input');
if(i&&i.value.trim()){
const u=await window.lm('search');
if(u&&u.performSearch){
window.searchModule = u;
window.TelaSearch = u;
u.performSearch();
}else{
window.location.hash='search/'+encodeURIComponent(i.value.trim());
}
}
}
function initResponsiveHashes(){function checkHashDisplay(){const width=window.innerWidth;const isCompact=width<1200;const hashContainers=document.querySelectorAll('.hash-container');hashContainers.forEach(container=>{if(isCompact){container.classList.add('compact')}else{container.classList.remove('compact')}})}checkHashDisplay();let resizeTimeout;window.addEventListener('resize',()=>{clearTimeout(resizeTimeout);resizeTimeout=setTimeout(checkHashDisplay,100)});document.addEventListener('DOMContentLoaded',checkHashDisplay);window.checkHashDisplay=checkHashDisplay}
if(typeof window!=='undefined'){window.initResponsiveHashes=initResponsiveHashes;initResponsiveHashes()}
window.performSearch=performSearch;
*/'] |