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/kanelovh/script.js
2025-02-22 17:11:06 +01:00

25 lines
634 B
JavaScript

function init()
{
var img = document.querySelector("#kanel");
const random = Math.floor(Math.random() * 70) + 1;
img.src = 'https://kanel.ovh/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 == 'https://kanel.ovh/img/70.jpg')
{
img.style.height = 'auto';
img.style.width = '100%';
}
}
init();