Gerador de números para Mega-Sena
Publicado por Marcelo Oliver (última atualização em 28/06/2022)
[ Hits: 18.312 ]
Download 6361.MEGA_SENA-VOL.html
Download MEGA_SENA-V01-Jun_2022.html (versão 2)
Como o próprio título diz, gera 06 dezenas.
Comecei a ler um tutorial sobre JavaScript e tive a ideia de fazer esse "sorteador". Bastante simples. Gera um número, verifica se o mesmo já foi gerado anteriormente. Se SIM, despreza. Se NÃO, armazena e mostra.
Utilizo a quantidade de elementos da ARRAY como contador.
É isso...
Versão 2 - Enviado por Marcelo Oliver em 16/06/2022
Changelog: Dia desses encontrei esse meu "script", foi o meu primeiro em JS.....
Resolvi atualizar......
Download MEGA_SENA-V01-Jun_2022.html
<!DOCTYPE html> <meta content='text/html; charset=UTF-8' http-equiv='Content-Type'/> <!-- Marcelo Oliver | Fevereiro/2016--> <html> <head> <title>MEGASENA</title> <style> div { width: 50%; margin: auto; border: 7.5px ridge yellow; } .msg { width: 90%; margin: auto; border: 0px ridge yellow; } .num { width: 90%; margin: auto; border: 0px ridge yellow; } .mod { background-color:black; color:yellow; text-align:center; float: left; margin: 7.5px; padding: 7.5px; width: 25px; border: 2.5px ridge yellow; } .button { background-color: white; border: double; color: black; padding: 2px 6px; text-align: center; text-decoration: none; display: inline-block; font-size: 16px; margin: 4px 2px; -webkit-transition-duration: 0.4s; /* Safari */ transition-duration: 0.5s; cursor: pointer; } .button1 { border-radius: 25px; } .button:hover { background-color: #555555; color: white; } .button:active { background-color: #555555; box-shadow: 0 5px #666; transform: translateY(4px); } a:link { color: yellow; background-color: transparent; text-decoration: none; } a:visited { color: yellow; background-color: transparent; text-decoration: none; } a:active { color: yellow; background-color: transparent; text-decoration: underline; } </style> </head> <body onload="GeraDez()"> <script> //DECLARAÇÃO DAS VAR's :) var NUM = [], stt, NEA, NN, str, STATUS, X = 6; function INICIO() { if (NEA) { document.getElementById("XX00").innerHTML = "AGUARDE . . ."; setTimeout(RELOAD, 1500); } else { MEGA();} } function GeraDez() { var W; var txt = " "; var NMR = [6,7,8,9,10,11,12,13,14,15]; for (W = 0; W < NMR.length; W++) { if (NMR[W] < 10) { NMR[W] = "0" + NMR[W]; } txt += "<div class='mod'>"+"<a href=javascript:pegadez("+NMR[W]+")>" + NMR[W] + "</a>" + "</div>"; } document.getElementById("00").innerHTML = txt; document.getElementById("XX00").innerHTML = " QUANTAS DEZENAS? "; } function pegadez(dez) { X = dez; } //INICIO MEGA function MEGA() { NN = (Math.floor(Math.random() * 60)+1); if (NN < 10) { NN = "0" + NN; } //CONVERTE ARRAY P/ STRING => se não usar o get, da erro... str = document.getElementById("H00").innerHTML = NUM.toString(); //LIMPA H00 document.getElementById("H00").innerHTML = ""; //VERIFICA SE NN JÁ FOI SORTEADO => pos É A POSIÇÃO DA STRING NA ARRAY, -1 É QDO NÃO ENCONTRA var pos = str.search(NN); if (pos == -1) { //ARMAZENA EM "ARRAY NUM" NUM.push(NN) //ENVIA PRA TELA document.getElementById("H01").innerHTML += "<hr>"+NN; //Nº de ARRAYS NEA = NUM.length; } if (NEA < X) { STATUS = "ON"; var LOOPING = setTimeout(MEGA, 750); } else { STATUS = "OFF"; var FIM = setTimeout(LHORIZ, 1000); } document.getElementById("00").innerHTML = " GERANDO PALPITES "; document.getElementById("XX00").innerHTML = " " + NEA + "ª " + "DEZENA"; } //FIM MEGA function RELOAD() { window.location.reload(true); } function LHORIZ() { document.getElementById("H01").innerHTML += "<hr>"; document.getElementById("XX00").innerHTML = "* BOA SORTE! *"; document.getElementById("XX01").innerHTML = "Se Ganhar, não esqueça do MSOLIVER. :)"; document.getElementById("00").innerHTML = ""; } </script> <br> <div align="center"> <h2 ID="XX00" style="color:black;"></h2> <!--h2 ID="XX00" style="color:black;">GERA PALPITES P/ MEGASENA</h2--> <div class='num'> <h3 id="00" align="center"></h3> </div> <!--p></p> <p></p--> <div class='msg'> <h2 ID="XX01" style="color:blue;"></h2> </div> <button class="button button1" onclick="INICIO()"><b>INICIAR</b></button> </div> <p id="H00"></p> <h1 id="H01" align="center"></h1> <h3 id="01" align="left" style="color:black;"></h3> </body> </html>
Passagem automática de imagens com efeito Opacity
Assinatura nas postagens no Viva o Linux
Javascript addDay(): Cálculo de data!
Servidor de Backup com Ubuntu Server 24.04 LTS, RAID e Duplicati (Dell PowerEdge T420)
Visualizar câmeras IP ONVIF no Linux sem necessidade de instalar aplicativos
Atualizar Debian Online de uma Versão para outra
Instalar driver Nvidia no Debian 13
Redimensionando, espelhando, convertendo e rotacionando imagens com script
Debian 13 Trixie para Iniciantes
Convertendo pacotes DEB que usam ZSTD (Padrão Novo) para XZ (Padrão Antigo)
Layout do teclado KDE Palsma 5.27.5 com x11 (1)
O que você está ouvindo agora? [2] (216)