adding function to reshuffle the front page words at every refresh
This commit is contained in:
parent
08a9507172
commit
093dd28cf9
@ -112,6 +112,7 @@ div.home {
|
|||||||
/* padding: 5em 5em 1em 7.5em; */
|
/* padding: 5em 5em 1em 7.5em; */
|
||||||
text-align: justify;
|
text-align: justify;
|
||||||
font-size: 0.8em;
|
font-size: 0.8em;
|
||||||
|
display: none;
|
||||||
}
|
}
|
||||||
div.homepage{
|
div.homepage{
|
||||||
padding: 0 0 5em 0;
|
padding: 0 0 5em 0;
|
||||||
|
@ -7,6 +7,30 @@
|
|||||||
<link rel="stylesheet" href="{{ url_for('static', filename='/css/style.css') }}">
|
<link rel="stylesheet" href="{{ url_for('static', filename='/css/style.css') }}">
|
||||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
|
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
|
||||||
<script>
|
<script>
|
||||||
|
(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);
|
||||||
|
|
||||||
|
|
||||||
$( document ).ready(function() {
|
$( document ).ready(function() {
|
||||||
var bodyWidth = $(window).width()- $("#generate-button").width();
|
var bodyWidth = $(window).width()- $("#generate-button").width();
|
||||||
var bodyHeight = $(window).height()- $("#generate-button").width();
|
var bodyHeight = $(window).height()- $("#generate-button").width();
|
||||||
@ -25,6 +49,9 @@
|
|||||||
var randPosY = Math.floor(Math.random() * (bodyHeight + 1));
|
var randPosY = Math.floor(Math.random() * (bodyHeight + 1));
|
||||||
$('#generate-button').css('left', randPosX);
|
$('#generate-button').css('left', randPosX);
|
||||||
$('#generate-button').css('top', randPosY);
|
$('#generate-button').css('top', randPosY);
|
||||||
|
|
||||||
|
$('div.home a').shuffle();
|
||||||
|
$('div.home').show();
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
</head>
|
</head>
|
||||||
|
Loading…
Reference in New Issue
Block a user