voidpage/setbg.js

44 lines
942 B
JavaScript

$(document).ready(function() {
var bgArray = [
['bg_image_1'],
['bg_image_2'],
['bg_image_3'],
['bg_image_4'],
['bg_image_5'],
['bg_image_6'],
['bg_image_7'],
['bg_image_8'],
['bg_image_9'],
['bg_image_10'],
['bg_image_11'],
['bg_image_12'],
['bg_image_13'],
['bg_image_14'],
['bg_image_15'],
['bg_image_16'],
['bg_image_17'],
['bg_image_18']
];
var i = Math.floor(Math.random() * bgArray.length);
var bg = bgArray[i][0];
var cls = bgArray[i][1];
var path = '/images/';
$('body').css('background-image', 'url(' + path + bg + '.webp)');
$('body').css('background-position', cls);
// Execute server-side script to generate color palette and copy colors.css
$.ajax({
url: '/wallpaper.php',
data: {
background: bg
},
success: function(data) {
console.log('Color palette generated and colors.css copied');
}
});
});