1const ctn = document.querySelector('#alerta'); 2const ctnMsg = document.querySelector('#alerta .msg'); 3const ctnAct = document.querySelector('#alerta .act'); 4let timer; 5 6const abre = (msg, seg = 3600, ...acoes) => { 7 clearTimeout(timer); 8 if (!seg) seg = 3600; 9 ctnMsg.textContent = msg; 10 ctnAct.innerHTML = ''; 11 acoes.forEach(act => { 12 if (typeof act == 'string') { 13 const a = document.createElement('a'); 14 a.textContent = act; 15 a.addEventListener('click', fecha); 16 ctnAct.appendChild(a); 17 return; 18 } 19 if (!Array.isArray(act)) throw 'alerta: ação inválida'; 20 const a = document.createElement('a'); 21 a.textContent = act[0]; 22 if (typeof act[1] == 'string') { 23 a.href = act[1]; 24 if (act[2]) { 25 a.target = '_blank'; 26 } 27 a.addEventListener('click', fecha); 28 ctnAct.appendChild(a); 29 return; 30 } 31 a.addEventListener('click', () => { 32 fecha(); 33 act[1](); 34 }); 35 ctnAct.appendChild(a); 36 }); 37 ctnAct.style.display = ctnAct.childNodes.length ? 'flex' : 'none'; 38 ctn.style.bottom = -(ctn.offsetHeight) + 'px'; 39 setTimeout(() => { 40 ctn.style.bottom = '0'; 41 ctn.classList.add('aberto'); 42 timer = setTimeout(fecha, 1000 * seg); 43 }, 0); 44}; 45 46const abreOK = (msg, seg = 3600) => { 47 abre(msg, seg, 'OK'); 48}; 49 50const fecha = () => { 51 clearTimeout(timer); 52 setTimeout(() => { 53 ctn.style.bottom = -(ctn.offsetHeight) + 'px'; 54 ctn.classList.remove('aberto'); 55 }, 0); 56}; 57 58export { abre, fecha, abreOK };
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.