-
Notifications
You must be signed in to change notification settings - Fork 27
/
scripts.js
34 lines (29 loc) · 833 Bytes
/
scripts.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
// https://css-tricks.com/snippets/jquery/shuffle-dom-elements/
(function($){
$.fn.shuffle = function() {
var allElems = this.get(),
getRandom = function(max) {
return Math.floor(Math.random() * max);
},
shuffled = $.map(allElems, function(){
var random = getRandom(allElems.length),
randEl = $(allElems[random]).clone(true)[0];
allElems.splice(random, 1);
return randEl;
});
this.each(function(i){
$(this).replaceWith($(shuffled[i]));
});
return $(shuffled);
};
})(jQuery);
function shuffle() {
$('li').shuffle();
}
function showAll() {
$('li').addClass('visible');
$('.tools').hide();
}
$( document ).ready(function() {
shuffle();
});