You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
58 lines
2.2 KiB
58 lines
2.2 KiB
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Document</title>
|
|
<link rel="stylesheet" href="css/bootstrap.css">
|
|
</head>
|
|
<body>
|
|
<div class="container text-center">
|
|
<h1>Picusum Photos Generator</h1>
|
|
<div class="row justify-content-center">
|
|
<div class="col-md-8">
|
|
<div class="card mt-5">
|
|
<div class="card-body">
|
|
<img id="randomImg" src="" alt="Nahodny obrázek" class="img-fluid">
|
|
<br>
|
|
<button id="nextImg" class="btn btn-outline-primary mt-3">Další obrázek</button>
|
|
<br>
|
|
<a id="downloadImg" class=" mt-2 btn btn-primary" download>Stáhnout náhodný obrázek </a>
|
|
<br>
|
|
<input type="number" name="widthIn" id="widthIn"
|
|
placeholder="Šírka" class="form-control" value="500">
|
|
<input type="number" name="height" id="heightIn"
|
|
placeholder="Výška" class="form-control" value="500">
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
</div>
|
|
<script>
|
|
const randomImg = document.getElementById("randomImg");
|
|
const nextImgBtn = document.getElementById("nextImg");
|
|
const widthIn = document.getElementById("widthIn");
|
|
const heightIn = document.getElementById("heightIn");
|
|
const downloadImg = document.getElementById("downloadImg");
|
|
|
|
function getRandomImg(){
|
|
// ` -> AltGR + ý na České klavesnici
|
|
let width = widthIn.value;
|
|
let height = heightIn.value;
|
|
let newImgUrl= `https://picsum.photos/${width}/${height}?random=${Math.random()}`;
|
|
randomImg.src = newImgUrl;
|
|
|
|
randomImg.onload = function() {
|
|
downloadImg.href = randomImg.src;
|
|
}
|
|
|
|
console.log(newImgUrl);
|
|
}
|
|
nextImgBtn.addEventListener("click",getRandomImg);
|
|
getRandomImg();
|
|
|
|
</script>
|
|
<script src="js/bootstrap.bundle.js"></script>
|
|
</body>
|
|
</html>
|