Advertisement
EduzZiTo

f5refresh js

Feb 21st, 2019
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.01 KB | None | 0 0
  1. var i, valor;
  2. var p=1;
  3. var li,cl,c,val;
  4. function update(element){
  5. var idx=element.selectedIndex;
  6. val=element.options[idx].value;
  7. var content=element.options[idx].innerHTML;
  8. if(val==1){
  9. li=1;
  10. cl=3;
  11. c=1;
  12. }
  13. else if(val==2){
  14. li=2;
  15. cl=3;
  16. c=2;
  17. }
  18. else if(val==3){
  19. li=3;
  20. cl=3;
  21. c=3;
  22. }
  23. }
  24. $(document).ready(function(){
  25. $("button").click(function(){
  26. var number_of_rows=li;
  27. var number_of_cols=cl;
  28. var table='<table border="1">';
  29. var botao='<input type="submit" value="jogar" onclick="gerar()" style="width: 100px;">'
  30. var n=1;
  31. for(var i=0;i<number_of_rows;i++){
  32. table+='<tr>';
  33.  
  34. for(var j=1;j<=number_of_cols;j++){
  35. table+= '<td id="foto'+n+'">';
  36. n++;
  37. table+='</td>';
  38. }
  39. table+='</tr>';
  40. }
  41.  
  42.  
  43. table+='</table>';
  44. $('#tableDiv').html(table);
  45. $('#botaoDiv').html(botao);
  46. });
  47. });
  48.  
  49.  
  50.  
  51. function gerar() {
  52. if(val==1){
  53. for (i = 1; i <= 3; i = i + 1) {
  54. valor = Math.floor((Math.random() * 14) + 1);
  55. var img = valor+ ".jpg";
  56. document.getElementById("foto" + i).style.background = "url(imagens/" + img + ") no-repeat";
  57. }
  58. if(document.getElementById("foto1").style.background==document.getElementById("foto2").style.background && document.getElementById("foto1").style.background== document.getElementById("foto3").style.background){
  59. alert("GANHOU");
  60. registo();
  61. reset();
  62. p=1;
  63. }
  64. }
  65. if(val==2){
  66. for (i = 1; i <= 6; i = i + 1) {
  67. valor = Math.floor((Math.random() * 14) + 1);
  68. var img = valor+ ".jpg";
  69. document.getElementById("foto" + i).style.background = "url(imagens/" + img + ") no-repeat";
  70. }
  71. 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 ){
  72. alert("GANHOU");
  73. registo();
  74. reset();
  75. p=1;
  76. }
  77. }
  78. if(val==3){
  79. for (i = 1; i <= 9; i = i + 1) {
  80. valor = Math.floor((Math.random() * 14) + 1);
  81. var img = valor+ ".jpg";
  82. document.getElementById("foto" + i).style.background = "url(imagens/" + img + ") no-repeat";
  83. }
  84. 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){
  85. alert("GANHOU");
  86. registo();
  87. reset();
  88. p=1;
  89. }
  90. }
  91. }
  92.  
  93.  
  94.  
  95.  
  96.  
  97.  
  98.  
  99.  
  100.  
  101.  
  102.  
  103.  
  104.  
  105.  
  106.  
  107.  
  108. /* var c=0;
  109. var s=0;
  110. var m=0;
  111. var h=0;
  112. var z=0;
  113. var mytime;
  114. function myFunction() {
  115. mytime=setInterval(contagem, 10);
  116.  
  117. }
  118. function contagem(){
  119. c++;
  120. if(c==100){
  121. c=0;
  122. s++;
  123. }
  124. if(s==60){
  125. s=0;
  126. m++;
  127. }
  128. if (m==60) {
  129. m=0;
  130. h++;
  131. }
  132. if (h==24) {
  133. h=0;
  134. }
  135.  
  136.  
  137. if(c<10){
  138. document.getElementById('c').innerHTML='0'+c;
  139. }
  140. else {
  141. document.getElementById('c').innerHTML=c;
  142. }
  143.  
  144. if(s<10){
  145. document.getElementById('s').innerHTML= '0' +s;
  146. }
  147. else
  148. document.getElementById('s').innerHTML=s;
  149. if (m<10) {
  150. document.getElementById('m').innerHTML='0'+m;
  151. }
  152. else {
  153. document.getElementById('m').innerHTML=m;
  154. }
  155. if (h<10) {
  156. document.getElementById('h').innerHTML='0'+h;
  157. }
  158. else
  159. document.getElementById('h').innerHTML=h;
  160.  
  161. }
  162.  
  163. function stop(){
  164. clearInterval(mytime);
  165. }
  166. function registo(){
  167. z=1
  168.  
  169. if(h<10 && m<10 && s<10 && c<10){
  170. document.getElementById('tmp' + z).innerHTML='0'+h+':'+'0'+m+':'+'0'+s+':'+'0'+c;
  171. }
  172. if(h<10 && m<10 && s<10 && c>10){
  173. document.getElementById('tmp' + z).innerHTML='0'+h+':'+'0'+m+':'+'0'+s+':'+c;
  174. }
  175. if(h<10 && m<10 && s>10 && c<10){
  176. document.getElementById('tmp' +z).innerHTML='0'+h+':'+'0'+m+':'+s+':'+'0'+c;
  177. }
  178. if(h<10 && m>10 && s<10 && c<10){
  179. document.getElementById('tmp' + z).innerHTML='0'+h+':'+m+':'+'0'+s+':'+'0'+c;
  180. }
  181. if(h>10 && m<10 && s<10 && c<10){
  182. document.getElementById('tmp' + z).innerHTML=h+':'+'0'+m+':'+'0'+s+':'+'0'+c;
  183. }
  184. if(h<10 && m<10 && s>10 && c>10){
  185. document.getElementById('tmp' + z).innerHTML='0'+h+':'+'0'+m+':'+s+':'+c;
  186. }
  187. if(h<10 && m>10 && s<10 && c>10){
  188. document.getElementById('tmp' + z).innerHTML='0'+h+':'+m+':'+'0'+s+':'+c;
  189. }
  190. if(h>10 && m<10 && s<10 && c>10){
  191. document.getElementById('tmp' + z).innerHTML=h+':'+'0'+m+':'+'0'+s+':'+c;
  192. }
  193. if(h<10 && m>10 && s>10 && c<10){
  194. document.getElementById('tmp' + z).innerHTML='0'+h+':'+m+':'+s+':'+'0'+c;
  195. }
  196. if(h>10 && m<10 && s>10 && c<10){
  197. document.getElementById('tmp' + z).innerHTML=h+':'+'0'+m+':'+s+':'+'0'+c;
  198. }
  199. if(h>10 && m>10 && s<10 && c<10){
  200. document.getElementById('tmp' + z).innerHTML=h+':'+m+':'+'0'+s+':'+'0'+c;
  201. }
  202. if(h<10 && m>10 && s>10 && c>10){
  203. document.getElementById('tmp' + z).innerHTML='0'+h+':'+m+':'+s+':'+c;
  204. }
  205. if(h>10 && m<10 && s>10 && c>10){
  206. document.getElementById('tmp' + z).innerHTML=h+':'+'0'+m+':'+s+':'+c;
  207. }
  208. if(h>10 && m>10 && s<10 && c>10){
  209. document.getElementById('tmp' + z).innerHTML=h+':'+m+':'+'0'+s+':'+c;
  210. }
  211. if(h>10 && m>10 && s>10 && c<10){
  212. document.getElementById('tmp' + z).innerHTML=h+':'+m+':'+s+':'+'0'+c;
  213. }
  214. if(h>10 && m>10 && s>10 && c>10){
  215. document.getElementById('tmp' + z).innerHTML=h+':'+m+':'+s+':'+c;
  216. }
  217. ;
  218. }
  219. function reset(){
  220. h=00;
  221. m=00;
  222. s=00;
  223. c=00;
  224. document.getElementById('h').innerHTML='0'+h;
  225. document.getElementById('m').innerHTML='0'+m;
  226. document.getElementById('s').innerHTML='0'+s;
  227. document.getElementById('c').innerHTML='0'+c;
  228. clearInterval(mytime);
  229. }
  230. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement