Advertisement
Guest User

Untitled

a guest
Jun 18th, 2019
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. $(document).ready(function() {
  2.  
  3. //four variables representing its button effects
  4. //button blue effect
  5. var blueButtonEffect = code here;
  6.  
  7. var greenButtonEffect = code here;
  8.  
  9. var redButtonEffect = code here;
  10.  
  11. var yellowButtonEffect = code here;
  12.  
  13. //to be used on the buttonEffects()/clickByItself()
  14. var arr = [blueButtonEffect, redButtonEffect, greenButtonEffect, yellowButtonEffect];
  15. let enabled = true;
  16. let times = 0;
  17. //makes button effects play itself randomly
  18. function clickByItself() {
  19. let random = Math.floor(Math.random() * arr.length);
  20. $(arr[random]).click();
  21. if (++times < 10) {
  22. setTimeout(function() { clickByItself(times); }, 1000);
  23. }
  24. }
  25. clickByItself();
  26.  
  27. function turnOnTurnOff() {
  28. if (enabled == true) { //TRYING TO TURN ON/OFF THE FUNCTION ON BUTTON CLICK..
  29. $(startButton).on('click', clickByItself);
  30. }
  31. else(enabled != false) {
  32. $(startButton).on('click', clickByItself);
  33. }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement