Skip to content

Commit

Permalink
its good enough
Browse files Browse the repository at this point in the history
  • Loading branch information
mefinity committed Oct 30, 2023
1 parent 55a481c commit c153923
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 26 deletions.
Binary file added Adoration.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@

<head>
<title>Sword's Nice Emoji</title>
<link rel="icon" href="emoji/Adoration.png">
<link rel="icon" href="Adoration.png">
<meta name="title" content="Sword's Nice Emoji">
<meta name="twitter:image" content="/emoji/Adoration.png">
<meta name="twitter:image" content="Adoration.png">
<meta name="description" content="Unofficial site for easy download of Sword's Nice Emojis">
<meta name="theme-color" content="#F9D02D">
<link rel="stylesheet" type="text/css" href="styles.css">
Expand Down
45 changes: 21 additions & 24 deletions script.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,40 +5,37 @@ document.addEventListener("DOMContentLoaded", function(event) {
function loadImagesFromZip(zipFile) {
JSZip.loadAsync(zipFile)
.then(function (zip) {
const imagePromises = [];

zip.forEach(function (relativePath, file) {
if (file.dir) return;

const imageName = file.name.split('/').pop().split('.')[0];
const fileName = file.name.split('/').pop();
const fileExtension = fileName.split('.').pop();
const imageName = fileName.split('.').slice(0, -1).join('.');

const imageContainer = document.createElement('div');
imageContainer.className = 'image-container';

imagePromises.push(
file.async('blob').then(function (blob) {
const imageUrl = URL.createObjectURL(blob);
file.async('blob').then(function (blob) {
const imageUrl = URL.createObjectURL(blob);

const img = document.createElement('img');
img.src = imageUrl;
img.alt = imageName;
const img = document.createElement('img');
img.src = imageUrl;
img.alt = imageName;

const imageCaption = document.createElement('div');
imageCaption.className = 'image-name';
imageCaption.innerText = imageName;
const imageCaption = document.createElement('div');
imageCaption.className = 'image-name';
imageCaption.innerText = imageName;

imageContainer.appendChild(img);
imageContainer.appendChild(imageCaption);
imageContainer.appendChild(img);
imageContainer.appendChild(imageCaption);

imageGrid.appendChild(imageContainer);
imageGrid.appendChild(imageContainer);

imageContainer.addEventListener('click', () => {
downloadImage(imageUrl, imageName);
});
})
);
imageContainer.addEventListener('click', () => {
downloadImage(imageUrl, fileName, fileExtension);
});
});
});

return Promise.all(imagePromises);
});
}

Expand All @@ -56,10 +53,10 @@ document.addEventListener("DOMContentLoaded", function(event) {
});
}

function downloadImage(url, fileName) {
function downloadImage(url, fileName, fileExtension) {
const a = document.createElement('a');
a.href = url;
a.download = fileName;
a.download = `${fileName}`;
document.body.appendChild(a);
a.click();
document.body.removeChild(a);
Expand Down

0 comments on commit c153923

Please sign in to comment.