login-template/web/myimages.html

29 lines
1011 B
HTML
Raw Normal View History

<!DOCTYPE html>
<html lang="en">
<head>
<title>My Images</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="css/style.css" rel="stylesheet">
</head>
<body>
<div id='images' style='display: none'></div>
<button id='showImages-button' onclick="getImages()">Get Images</button>
</body>
<script defer>
async function getImages(user) {
// get current username
let username = JSON.parse(await (await fetch("/account")).text()).username;
// get images for username
let images = JSON.parse(await (await fetch(`/images/by-user/${username}`)).text())
let imagestrings = [];
for(const img of images) {
imagestrings.push(`${img}<br><img src="/images/${img}.png" alt="${img}" style="max-width: 100%">`)
}
document.getElementById('images').innerHTML = imagestrings.join('<br><br>');
document.getElementById('images').style.display = '';
}
</script>
</html>