deepanime.ai
Deep Anime
AI Art Generator
function decodeURIComponent(s) {
return "https://storage.googleapis.com/tensorcraft1/" + s.replace('/image/', '');
}
function loadJob(jobId) {
document.getElementById("subtitle").innerHTML = "Images created by Deep Anime";
console.log("loading job " + jobId);
url = "https://api.tensorcraft.com/job_images2/" + jobId;
var xhr = new XMLHttpRequest();
xhr.open('GET', url, true);
xhr.responseType = 'json';
xhr.onload = function () {
var status = xhr.status;
if (status === 200) {
loadJobImages(xhr.response);
}
};
xhr.send();
};
function loadJobImages(jobData) {
for (var i = 0; i < jobData.images.length; i++) {
var img = document.createElement("img");
img.src = jobData.images[jobData.images.length-i-1].uri;
img.className += " anime-image";
document.getElementById("image-container").appendChild(img);
if (i % 2 == 1) {
var br = document.createElement("br");
document.getElementById("image-container").appendChild(br);
}
}
}
function loadFrontPage() {
const imageContainer = document.getElementById('image-container');
const img = document.createElement('img');
img.src = "https://deepanime.ai/assets/assets/promo.png";
imageContainer.appendChild(img);
};
function loadImage() {
document.getElementById("subtitle").innerHTML = "Image created by Deep Anime";
const urlFragment = window.location.hash.substr(1);
if (urlFragment) {
const imageUrl = decodeURIComponent(urlFragment);
const imageContainer = document.getElementById('image-container');
const img = document.createElement('img');
img.src = imageUrl;
img.alt = 'Dynamic Image';
imageContainer.appendChild(img);
} else {
alert('No image URL provided. Please add an image URL after the hash in the address bar.');
}
}
function loadFromHash() {
const urlFragment = window.location.hash.substr(1);
if (urlFragment) {
if (urlFragment.startsWith('/image/')) {
loadImage(urlFragment);
} else if (urlFragment.startsWith('/job/')) {
loadJob(urlFragment.replace('/job/', ''));
} else {
loadFrontPage();
}
}else {
loadFrontPage();
}
}
document.addEventListener('DOMContentLoaded', loadFromHash);