Random Backgrond Image

- Randomly picks from list of images
- TODO: Incorporate File System so that user can easilt add new pictures
This commit is contained in:
DrElyk
2018-03-23 20:17:56 -04:00
parent be32d010d8
commit 4ed1d81086
37 changed files with 20 additions and 11 deletions
BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 167 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 455 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 349 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 6.4 MiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 43 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 422 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 356 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 650 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 123 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 MiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 190 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 89 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 353 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 454 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 101 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 93 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 195 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 651 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 252 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 220 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 132 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 86 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 372 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 217 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 MiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Before

Width:  |  Height:  |  Size: 331 KiB

After

Width:  |  Height:  |  Size: 331 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 630 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 556 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 MiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 406 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 MiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 598 KiB

+5
View File
@@ -8,6 +8,11 @@
<html> <html>
<div id = "background">
<script src = "jquery-3.1.1.js"></script>
<script src = "background.js"></script>
</div>
<head> <head>
<Title>Homepage</Title> <Title>Homepage</Title>
<link href = "styleHomepage.css" type = "text/css" rel = "stylesheet"> <link href = "styleHomepage.css" type = "text/css" rel = "stylesheet">
+15 -9
View File
@@ -1,13 +1,19 @@
function background() function main()
{ {
var img = $(".boxes > img").each(function() { // for each img found //var fs = require('fs');
var src = $(this).attr("src"); // get the src //var fileList = fs.readdirSync('/Background/');
var path = src.substring(0,src.lastIndexOf('/')); // get the path from the src
var fileName = src.substring(src.lastIndexOf('/')); // and filename
var newSrc = path + "/large" + fileName; // re-assemble
$(this).attr("src",newSrc); var fileList = ['1.jpg', '2.jpg', '3.jpg', '4.jpg', '5.jpg', '6.jpg', '7.jpg', '8.png', '9.jpg',
}); '10.jpg', '11.jpg', '12.jpg', '13.png', '14.jpg', '15.jpg', '16.jpg', '17.jpg',
'18.jpg', '19.jpg', '20.jpg', '21.jpg', '22.jpg', '23.png', '24.jpg', '25.jpg',
'26.jpg', '27.jpg', '28.jpg', '29.jpg', '30.jpg', '31.jpg', '32.jpg', '33.jpg',
'34.jpg'];
var len = fileList.length;
var index = Math.floor(Math.random() * len);
var filePath = 'Background/' + fileList[index];
document.body.style.backgroundImage = 'url("'+filePath+'")';
} }
$(document).ready(background); $(document).ready(main);
-2
View File
@@ -9,9 +9,7 @@
html html
{ {
background-image: url('Pictures/Qb8b9UC.jpg');
background-size: cover; background-size: cover;
/* background-color: #2d333d; */
} }
#clock #clock