Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var i, valor;
- var p=1;
- var li,cl,c,val;
- function update(element){
- var idx=element.selectedIndex;
- val=element.options[idx].value;
- var content=element.options[idx].innerHTML;
- if(val==1){
- li=1;
- cl=3;
- c=1;
- }
- else if(val==2){
- li=2;
- cl=3;
- c=2;
- }
- else if(val==3){
- li=3;
- cl=3;
- c=3;
- }
- }
- $(document).ready(function(){
- $("button").click(function(){
- var number_of_rows=li;
- var number_of_cols=cl;
- var table='<table border="1">';
- var botao='<input type="submit" value="jogar" onclick="gerar()" style="width: 100px;">'
- var n=1;
- for(var i=0;i<number_of_rows;i++){
- table+='<tr>';
- for(var j=1;j<=number_of_cols;j++){
- table+= '<td id="foto'+n+'">';
- n++;
- table+='</td>';
- }
- table+='</tr>';
- }
- table+='</table>';
- $('#tableDiv').html(table);
- $('#botaoDiv').html(botao);
- });
- });
- function gerar() {
- if(val==1){
- for (i = 1; i <= 3; i = i + 1) {
- valor = Math.floor((Math.random() * 14) + 1);
- var img = valor+ ".jpg";
- document.getElementById("foto" + i).style.background = "url(imagens/" + img + ") no-repeat";
- }
- if(document.getElementById("foto1").style.background==document.getElementById("foto2").style.background && document.getElementById("foto1").style.background== document.getElementById("foto3").style.background){
- alert("GANHOU");
- registo();
- reset();
- p=1;
- }
- }
- if(val==2){
- for (i = 1; i <= 6; i = i + 1) {
- valor = Math.floor((Math.random() * 14) + 1);
- var img = valor+ ".jpg";
- document.getElementById("foto" + i).style.background = "url(imagens/" + img + ") no-repeat";
- }
- if(document.getElementById("foto1").style.background==document.getElementById("foto2").style.background && document.getElementById("foto1").style.background== document.getElementById("foto3").style.background && document.getElementById("foto1").style.background== document.getElementById("foto4").style.background && document.getElementById("foto1").style.background== document.getElementById("foto5").style.background && document.getElementById("foto1").style.background== document.getElementById("foto6").style.background ){
- alert("GANHOU");
- registo();
- reset();
- p=1;
- }
- }
- if(val==3){
- for (i = 1; i <= 9; i = i + 1) {
- valor = Math.floor((Math.random() * 14) + 1);
- var img = valor+ ".jpg";
- document.getElementById("foto" + i).style.background = "url(imagens/" + img + ") no-repeat";
- }
- if(document.getElementById("foto1").style.background==document.getElementById("foto2").style.background && document.getElementById("foto1").style.background== document.getElementById("foto3").style.background && document.getElementById("foto1").style.background== document.getElementById("foto4").style.background && document.getElementById("foto1").style.background== document.getElementById("foto5").style.background && document.getElementById("foto1").style.background== document.getElementById("foto6").style.background && document.getElementById("foto1").style.background== document.getElementById("foto7").style.background && document.getElementById("foto1").style.background== document.getElementById("foto8").style.background && document.getElementById("foto1").style.background== document.getElementById("foto9").style.background){
- alert("GANHOU");
- registo();
- reset();
- p=1;
- }
- }
- }
- /* var c=0;
- var s=0;
- var m=0;
- var h=0;
- var z=0;
- var mytime;
- function myFunction() {
- mytime=setInterval(contagem, 10);
- }
- function contagem(){
- c++;
- if(c==100){
- c=0;
- s++;
- }
- if(s==60){
- s=0;
- m++;
- }
- if (m==60) {
- m=0;
- h++;
- }
- if (h==24) {
- h=0;
- }
- if(c<10){
- document.getElementById('c').innerHTML='0'+c;
- }
- else {
- document.getElementById('c').innerHTML=c;
- }
- if(s<10){
- document.getElementById('s').innerHTML= '0' +s;
- }
- else
- document.getElementById('s').innerHTML=s;
- if (m<10) {
- document.getElementById('m').innerHTML='0'+m;
- }
- else {
- document.getElementById('m').innerHTML=m;
- }
- if (h<10) {
- document.getElementById('h').innerHTML='0'+h;
- }
- else
- document.getElementById('h').innerHTML=h;
- }
- function stop(){
- clearInterval(mytime);
- }
- function registo(){
- z=1
- if(h<10 && m<10 && s<10 && c<10){
- document.getElementById('tmp' + z).innerHTML='0'+h+':'+'0'+m+':'+'0'+s+':'+'0'+c;
- }
- if(h<10 && m<10 && s<10 && c>10){
- document.getElementById('tmp' + z).innerHTML='0'+h+':'+'0'+m+':'+'0'+s+':'+c;
- }
- if(h<10 && m<10 && s>10 && c<10){
- document.getElementById('tmp' +z).innerHTML='0'+h+':'+'0'+m+':'+s+':'+'0'+c;
- }
- if(h<10 && m>10 && s<10 && c<10){
- document.getElementById('tmp' + z).innerHTML='0'+h+':'+m+':'+'0'+s+':'+'0'+c;
- }
- if(h>10 && m<10 && s<10 && c<10){
- document.getElementById('tmp' + z).innerHTML=h+':'+'0'+m+':'+'0'+s+':'+'0'+c;
- }
- if(h<10 && m<10 && s>10 && c>10){
- document.getElementById('tmp' + z).innerHTML='0'+h+':'+'0'+m+':'+s+':'+c;
- }
- if(h<10 && m>10 && s<10 && c>10){
- document.getElementById('tmp' + z).innerHTML='0'+h+':'+m+':'+'0'+s+':'+c;
- }
- if(h>10 && m<10 && s<10 && c>10){
- document.getElementById('tmp' + z).innerHTML=h+':'+'0'+m+':'+'0'+s+':'+c;
- }
- if(h<10 && m>10 && s>10 && c<10){
- document.getElementById('tmp' + z).innerHTML='0'+h+':'+m+':'+s+':'+'0'+c;
- }
- if(h>10 && m<10 && s>10 && c<10){
- document.getElementById('tmp' + z).innerHTML=h+':'+'0'+m+':'+s+':'+'0'+c;
- }
- if(h>10 && m>10 && s<10 && c<10){
- document.getElementById('tmp' + z).innerHTML=h+':'+m+':'+'0'+s+':'+'0'+c;
- }
- if(h<10 && m>10 && s>10 && c>10){
- document.getElementById('tmp' + z).innerHTML='0'+h+':'+m+':'+s+':'+c;
- }
- if(h>10 && m<10 && s>10 && c>10){
- document.getElementById('tmp' + z).innerHTML=h+':'+'0'+m+':'+s+':'+c;
- }
- if(h>10 && m>10 && s<10 && c>10){
- document.getElementById('tmp' + z).innerHTML=h+':'+m+':'+'0'+s+':'+c;
- }
- if(h>10 && m>10 && s>10 && c<10){
- document.getElementById('tmp' + z).innerHTML=h+':'+m+':'+s+':'+'0'+c;
- }
- if(h>10 && m>10 && s>10 && c>10){
- document.getElementById('tmp' + z).innerHTML=h+':'+m+':'+s+':'+c;
- }
- ;
- }
- function reset(){
- h=00;
- m=00;
- s=00;
- c=00;
- document.getElementById('h').innerHTML='0'+h;
- document.getElementById('m').innerHTML='0'+m;
- document.getElementById('s').innerHTML='0'+s;
- document.getElementById('c').innerHTML='0'+c;
- clearInterval(mytime);
- }
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement