Guest User

Untitled

a guest
Sep 7th, 2015
94
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var count = 0;
  2. var someObj = new Array();
  3.  
  4. $('.herocontent1').children().each(function () {
  5.     var idName = $(this).attr('id');
  6.     someObj.push(idName);
  7. })
  8. var uniqueRandoms = [];
  9. var numRandoms = 3;
  10.  
  11. function makeUniqueRandom() {
  12.     // refill the array if needed
  13.     if (!uniqueRandoms.length) {
  14.         for (var i = 0; i < numRandoms; i++) {
  15.             uniqueRandoms.push(i);
  16.         }
  17.     }
  18.     var index = Math.floor(Math.random() * uniqueRandoms.length);
  19.     var val = uniqueRandoms[index];
  20.  
  21.     // now remove that value from the array
  22.     uniqueRandoms.splice(index, 1);
  23.  
  24.     return val;
  25.  
  26. }
  27. var randomnumber = makeUniqueRandom();
  28.  
  29.  
  30. function doFade() {
  31.     console.log('random # is: ' + randomnumber + ' which will play div id: ' + someObj[randomnumber]);
  32.     $('#' + someObj[randomnumber]).fadeIn(1000).queue(function () {
  33.         soundManager.play(someObj[randomnumber]);
  34.         $(this).dequeue();
  35.     }).delay(1000).fadeOut(3000, function () {
  36.         randomnumber = makeUniqueRandom();
  37.         count++;
  38.         if (count >= 3) { //someObj.length){
  39.             //alert('finished');
  40.             return;
  41.         } else {
  42.             doFade();
  43.         }
  44.     })
  45. }
  46.  
  47. repeatXI(doFade(), 1000, 3, true);
RAW Paste Data