1'use strict'; 2 3function $(id) { return document.getElementById(id); } 4 5var toastTimer; 6function toast(msg, type) { 7 var el = $('toast'); 8 if (!el) return; 9 el.textContent = msg; 10 el.style.borderColor = type==='error'?'rgba(239,68,68,0.5)':type==='warn'?'rgba(245,158,11,0.5)':'rgba(34,211,238,0.4)'; 11 el.classList.add('show'); 12 clearTimeout(toastTimer); 13 toastTimer = setTimeout(function(){ el.classList.remove('show'); }, 4500); 14} 15 16function esc(s) { return String(s == null ? '' : s).replace(/[&<>"']/g, function (m) { return {'&':'&','<':'<','>':'>','"':'"',"'":'''}[m]; }); } 17function uatomToAtom(u) { return (parseInt(u||0)/1000000).toFixed(2) + ' ATOM'; } 18function atomToUatom(a) { return Math.floor(parseFloat(a||0)*1000000); } 19function formatAtomPriceFromUatom(uatom) { 20 var amount = parseInt(uatom || 0, 10); 21 if (!isFinite(amount) || amount < 0) amount = 0; 22 return (amount / 1000000).toFixed(2) + ' ATOM'; 23} 24 25function setPriceSliderValue(prefix, uatom) { 26 var amount = parseInt(uatom || 1000000, 10); 27 if (!isFinite(amount) || amount <= 0) amount = 1000000; 28 var atom = amount / 1000000; 29 var slider = $(prefix + 'PriceSlider'); 30 var atomInput = $(prefix + 'PriceAtom'); 31 var uatomInput = $(prefix + 'Price'); 32 var atomDisplay = $(prefix + 'PriceAtomDisplay'); 33 var uatomDisplay = $(prefix + 'PriceUatomDisplay'); 34 if (slider) slider.value = Math.min(Math.max(atom, parseFloat(slider.min || '0.1')), parseFloat(slider.max || '100')); 35 if (atomInput) atomInput.value = Number(atom.toFixed(6)); 36 if (uatomInput) uatomInput.value = String(amount); 37 if (atomDisplay) atomDisplay.textContent = formatAtomPriceFromUatom(amount); 38 if (uatomDisplay) uatomDisplay.textContent = String(amount) + ' uatom'; 39} 40 41function debounce(fn, ms) { 42 var timer; 43 return function() { 44 var args = arguments, ctx = this; 45 clearTimeout(timer); 46 timer = setTimeout(function() { fn.apply(ctx, args); }, ms || 300); 47 }; 48} 49window.debounce = debounce; 50 51function toastTx(txhash, label) { 52 var el = document.getElementById('txToast'); 53 if (!el) return; 54 var nameEl = el.querySelector('#txToastName'); 55 var linkEl = el.querySelector('#txToastLink'); 56 if (nameEl) nameEl.textContent = label || 'Transaction confirmed'; 57 if (linkEl) { 58 linkEl.href = 'https://www.mintscan.io/cosmos/tx/' + encodeURIComponent(txhash); 59 linkEl.textContent = txhash.slice(0, 10) + '...' + txhash.slice(-6); 60 } 61 el.classList.add('show'); 62 clearTimeout(window.txToastTimer); 63 window.txToastTimer = setTimeout(function() { el.classList.remove('show'); }, 9000); 64} 65window.toastTx = toastTx; 66 67function bindPriceSlider(prefix) { 68 var slider = $(prefix + 'PriceSlider'); 69 var atomInput = $(prefix + 'PriceAtom'); 70 var uatomInput = $(prefix + 'Price'); 71 if (!slider || !atomInput || !uatomInput) return; 72 73 slider.addEventListener('input', function(){ 74 var atom = parseFloat(slider.value || '1'); 75 setPriceSliderValue(prefix, Math.round(atom * 1000000)); 76 }); 77 78 atomInput.addEventListener('input', function(){ 79 var atom = parseFloat(atomInput.value || '0'); 80 if (!isFinite(atom) || atom <= 0) return; 81 setPriceSliderValue(prefix, Math.round(atom * 1000000)); 82 }); 83 84 uatomInput.addEventListener('input', function(){ 85 var amount = parseInt(uatomInput.value || '0', 10); 86 if (!isFinite(amount) || amount <= 0) return; 87 setPriceSliderValue(prefix, amount); 88 }); 89 90 setPriceSliderValue(prefix, uatomInput.value || 1000000); 91}
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.