Skip to content

Commit

Permalink
backstretch shuffle playlist
Browse files Browse the repository at this point in the history
  • Loading branch information
xaoxuu committed Mar 12, 2020
1 parent 1ec6b93 commit d2d4f31
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
5 changes: 3 additions & 2 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -400,13 +400,14 @@ plugins:
enable: true
js: https://cdn.jsdelivr.net/npm/[email protected]/jquery.backstretch.min.js
position: cover # cover: sticky on the cover. fixed: Fixed as background for the site.
shuffle: true # shuffle playlist
duration: 20000 # Duration (ms)
fade: 1500 # fade duration (ms) (Not more than 1500)
white_text: #true # Whether the picture is dark (adjust the text to white)
images: # For personal use only. At your own risk if used for commercial purposes !!!
- https://cdn.jsdelivr.net/gh/xaoxuu/cdn-wallpaper/abstract/41F215B9-261F-48B4-80B5-4E86E165259E.jpeg
# - https://cdn.jsdelivr.net/gh/xaoxuu/cdn-wallpaper/abstract/BBC19066-E176-47C2-9D22-48C81EE5DF6B.jpeg
# - https://cdn.jsdelivr.net/gh/xaoxuu/cdn-wallpaper/abstract/B18FCBB3-67FD-48CC-B4F3-457BA145F17A.jpeg
- https://cdn.jsdelivr.net/gh/xaoxuu/cdn-wallpaper/abstract/BBC19066-E176-47C2-9D22-48C81EE5DF6B.jpeg
- https://cdn.jsdelivr.net/gh/xaoxuu/cdn-wallpaper/abstract/B18FCBB3-67FD-48CC-B4F3-457BA145F17A.jpeg
# - https://cdn.jsdelivr.net/gh/xaoxuu/cdn-wallpaper/abstract/00E0F0ED-9F1C-407A-9AA6-545649D919F4.jpeg
# # Suggest white_text: true
# - https://cdn.jsdelivr.net/gh/xaoxuu/cdn-wallpaper/abstract/67239FBB-E15D-4F4F-8EE8-0F1C9F3C4E7C.jpeg
Expand Down
18 changes: 16 additions & 2 deletions layout/_partial/scripts.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -63,16 +63,30 @@
<%- js(theme.plugins.backstretch.js) %>
<script type="text/javascript">
$(function(){
var imgs=<%- '["' + imgs.join('", "') + '"]' %>;
if ('<%- theme.plugins.backstretch.shuffle %>' == 'true') {
function shuffle(arr){
/*From countercurrent-time*/
var n = arr.length;
while(n--) {
var index = Math.floor(Math.random() * n);
var temp = arr[index];
arr[index] = arr[n];
arr[n] = temp;
}
}
shuffle(imgs);
}
if ('<%- posi %>') {
$('<%- posi %>').backstretch(
<%- '["' + imgs.join('", "') + '"]' %>,
imgs,
{
duration: "<%- theme.plugins.backstretch.duration %>",
fade: "<%- theme.plugins.backstretch.fade %>"
});
} else {
$.backstretch(
<%- '["' + imgs.join('", "') + '"]' %>,
imgs,
{
duration: "<%- theme.plugins.backstretch.duration %>",
fade: "<%- theme.plugins.backstretch.fade %>"
Expand Down

0 comments on commit d2d4f31

Please sign in to comment.