1/* 2 <script type='module' language='JavaScript' src='https://lleo.me/extended/identicon/identicon.js'></script> 3 4 or: 5 6<input type='button' value='Load Module' 7 onclick="var d=document,s=d.createElement('script');s.src='https://lleo.me/extended/identicon/identicon.js';s.type='module';d.head.append(s);"> 8 9*/ 10 11function identicon_init(e) { if(!e) e=document; 12 // add identicon to all DIV with class "identicon" 13 e.querySelectorAll('DIV[identicon]').forEach(function(p){ 14 if(p.classList.contains('identicon_done')) return; 15 var adr=p.getAttribute('identicon'); // attribute identicon="5GbgpMNkENaf4rZmioBtPmkb7UZb4YSozVPdWp9fa2CtdKdZ" 16 if(!adr||adr=='') { // if no attribute identicon, try to find address in classList 17 adr=false; 18 for(var c of p.classList) if(c.length==48 || c.startsWith('0x') || 1*c) { adr=c; break; } 19 } 20 if(adr==false) adr=p.innerHTML; // if no address in classList, take address in innerHTML 21 p.innerHTML="<div style='display:inline-block; width:"+p.offsetHeight+"px;height:"+p.offsetHeight+"px'>"+window.identicon(adr)+"</div> "+p.innerHTML; 22 p.classList.add('identicon_done'); 23 }); 24 25 // add identicon to radio buttons (in blocks with class "identicon") 26 e.querySelectorAll(".identicon input[type='radio']").forEach(function(p){ 27 if(p.classList.contains('identicon_done')) return; 28 var c=p.value; 29 var next=p.nextSibling; 30 if(next) { 31 if(!next.innerHTML) { 32 // create div inline instead of text node 33 var div = document.createElement('div'); 34 div.innerHTML = next.nodeValue; 35 div.style.display = 'inline-block'; 36 next.parentNode.insertBefore(div, next); 37 next.parentNode.removeChild(next); 38 next = div; 39 } 40 var cc = next.innerHTML; 41 if(c.length!=48 && !c.startsWith('0x') && !(1*c)) c=cc; 42 next.innerHTML = "<div style='display:inline-block; width:"+next.offsetHeight+"px;height:"+next.offsetHeight+"px'>"+window.identicon(c)+"</div> "+cc; 43 } 44 p.classList.add('identicon_done'); 45 }); 46} 47 48import init, {identicon,adr2west,adr0x} from 'https://lleo.me/extended/identicon/wasm.js'; 49async function run() { await init('https://lleo.me/extended/identicon/wasm.wasm'); identicon_init(); window.identicon_ready=1; } run(); 50window.identicon=identicon; 51window.adr2west=adr2west; 52window.adr0x=adr0x; 53window.identicon_init=identicon_init;
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.