Last active
August 29, 2015 14:09
-
-
Save griffiths/48fe9bc6b93735776c7e to your computer and use it in GitHub Desktop.
Randomness Example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var dogs = ["http://i.imgur.com/UW8X8XR.jpg","http://i.imgur.com/IXQzsGR.jpg","http://i.imgur.com/MfzdrQY.jpg","http://i.imgur.com/EyzGE8U.jpg","http://i.imgur.com/4yh1FSM.jpg","http://i.imgur.com/JVExNi3.jpg","http://i.imgur.com/xMJj7xb.jpg"]; | |
var texts = ["Ne suavitate deterruisset pro, quo solum interpretaris ei.", "Qui ad omnes efficiendi, vis accusata referrentur cu.", "No ius tale rationibus, ut lorem probatus pri, nec in ferri mundi honestatis.", "Eam mollis viderer elaboraret id, no has sapientem tincidunt.", "Impedit blandit qui ut, cu duis putent sit.", "Mei diam nihil discere id."]; | |
$(".button").click(function() { | |
for (var increment = 0; increment < 100; increment++) { | |
$("body").append("<div class='dot'></div>"); | |
} | |
$(".dot").each(function() { | |
var topval = Math.floor(Math.random()*($(window).height()-50)) + "px"; | |
var leftval = Math.floor(Math.random()*($(window).width()-50)) + "px"; | |
var sizeval = (Math.floor(Math.random()*60) + 20) + "px"; | |
$(this).css("top",topval).css("left",leftval); | |
$(this).css("width",sizeval).css("height",sizeval); | |
}); | |
var textOrImage = Math.floor(Math.random()*10); | |
if (textOrImage < 5) { | |
$(".dog").html("<img src='" + dogs[Math.floor(Math.random()*dogs.length)] + "'>"); | |
} else { | |
$(".text").html(texts[Math.floor(Math.random()*texts.length)]); | |
} | |
//do stuff | |
console.log("clicked.."); | |
$(".number").html(Math.floor(Math.random()*10)); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment