Archived
1
0
This repository has been archived on 2025-05-13. You can view files and clone it, but cannot push or open issues or pull requests.
Files
inception/srcs/docker/bonus/static-site/kanel.ovh/script.js
2025-02-22 16:56:23 +01:00

24 lines
603 B
JavaScript

function init()
{
var img = document.querySelector("#kanel");
const random = Math.floor(Math.random() * 70) + 1;
img.src = 'img/'+random+'.jpg';
const { naturalWidth, naturalHeight } = img;
const isLandscape = naturalWidth / naturalHeight > 1;
if (isLandscape) {
img.style.width = window.innerWidth+'px';
img.style.height = 'auto';
} else {
img.style.height = window.innerHeight+'px';
img.style.width = 'auto';
}
if (img.src == 'img/70.jpg')
{
img.style.height = 'auto';
img.style.width = '100%';
}
}
init();