Files
purplebored.pl/oldprojects/neko/index.html
2024-07-27 00:25:21 +02:00

99 lines
3.1 KiB
HTML
Executable File

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Neko Images</title>
<link rel="stylesheet" href="https://envs.net/css/css_style.css">
<!-- Set the background color, font, and spacing of the body -->
<style>
body {
background-color: #1d1d1d;
color: #f1f1f1;
font-family: 'Fira Code', monospace;
font-size: 18px;
line-height: 1.6;
margin: 0;
padding: 0;
}
/* Center the container on the page */
.container {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
height: 100vh;
}
/* Style the header text */
h1 {
color: #f1f1f1;
font-weight: bold;
line-height: 1.2;
margin-top: 0;
}
/* Style the neko image */
img {
max-width: 100%;
max-height: 500px;
margin-bottom: 1rem;
display: none; /* Hide the image initially */
}
/* Style the "Show another Neko image" button */
button.show-another {
display: none; /* Hide the button initially */
margin-top: 1rem;
padding: 0.5rem 1rem;
font-size: 1rem;
background-color: #2e7bff;
color: #f1f1f1;
border: none;
border-radius: 0.5rem;
cursor: pointer;
}
/* Set the button background color on hover */
button.show-another:hover {
background-color: #0056b3;
}
</style>
</head>
<body>
<div class="container">
<!-- Add the heading text -->
<h1>Neko Images</h1>
<!-- Add the neko image with an initial blank source -->
<img src="" alt="Neko image">
<!-- Add the "Show another Neko image" button -->
<button class="show-another" onclick="showNeko()">Show another Neko image</button>
</div>
<!-- JS SHIT UNDER-->
<script>
window.onload = function() {
var nekoImg = document.querySelector('img');
var showAnother = document.querySelector('.show-another');
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function() {
if (xhr.readyState === 4 && xhr.status === 200) {
nekoImg.style.display = 'block';
showAnother.style.display = 'block';
var jsonResponse = JSON.parse(xhr.responseText);
nekoImg.src = jsonResponse.url;
}
}
xhr.open('GET', 'https://nekos.life/api/v2/img/neko');
xhr.send();
}
function showNeko() {
var nekoImg = document.querySelector('img');
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function() {
if (xhr.readyState === 4 && xhr.status === 200) {
var jsonResponse = JSON.parse(xhr.responseText);
nekoImg.src = jsonResponse.url;
}
}
xhr.open('GET', 'https://nekos.life/api/v2/img/neko');
xhr.send();
}
</script>
</body>
</html>