Files
Alcea 40222cd970 Add files via upload
Post php to post directly without update sync
2025-07-20 14:03:22 +02:00

172 lines
5.0 KiB
HTML

<!-- last--used--shorthands -->
[<a target="_blank" href="https://alceawis.de/other/extra/scripts/fakesocialmedia/lastshorthands.html#https://codepen.io/ryedai1/pen/EaYQmqz" style=color:blue>s</a>]
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Emoji Viewer</title>
<style>
img.emoji {
width: 25px;
height: 25px;
object-fit: contain;
cursor: pointer;
}
</style>
</head>
<body>
<!-- Supported emojis will be shown here -->
<div id="shorthand-images"></div>
<!-- Unsupported emojis will be shown here -->
<div id="unsupported-images"></div>
<!-- Download Button -->
<button id="download-btn">Download All Emojis</button>
<!-- JSZip & FileSaver -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.10.1/jszip.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/FileSaver.js/2.0.5/FileSaver.min.js"></script>
<script>
async function fetchAndProcessJSON() {
try {
const response = await fetch('https://alceawis.de/other/extra/scripts/fakesocialmedia/data_alcea.json');
const data = await response.json();
const { shorthands, unsupported } = extractShorthands(data);
// Remove unsupported from supported list
const filteredShorthands = shorthands.filter(s => !unsupported.includes(s));
displayShorthandImages(filteredShorthands);
displayUnsupportedShorthands(unsupported);
} catch (error) {
console.error('Error fetching or processing JSON:', error);
}
}
function extractShorthands(data) {
const shorthandPattern = /:\w+:/g;
let shorthands = new Set();
let unsupported = new Set([
':confused_dog:',
':RJ_RedJohn_TheMentalist:',
':rofl:',
':plc:',
':34:',
':40:',
':20:',
':18:',
':awesome:',
':sweat:',
':00:',
':08:',
':i:',
':35:',
':baa:',
':immeasurable_sadness:'
]);
function searchInObject(obj) {
for (let key in obj) {
if (typeof obj[key] === 'string') {
const matches = obj[key].match(shorthandPattern);
if (matches) {
matches.forEach(match => shorthands.add(match));
}
} else if (typeof obj[key] === 'object' && obj[key] !== null) {
searchInObject(obj[key]);
}
}
}
searchInObject(data);
return {
shorthands: Array.from(shorthands),
unsupported: Array.from(unsupported)
};
}
function createEmojiImage(shorthand, containerId) {
const shorthandKey = shorthand.replace(/:/g, '');
const imgUrl = `https://alcea-wisteria.de/z_files/emoji/${shorthandKey}.gif`;
const imgElement = document.createElement('img');
imgElement.src = imgUrl;
imgElement.alt = shorthandKey;
imgElement.title = shorthand;
imgElement.classList.add('emoji');
imgElement.onerror = () => {
imgElement.src = "";
imgElement.alt = "";
};
imgElement.onclick = () => {
parent.postMessage({ type: 'shorthandSelected', shorthand: shorthand }, '*');
};
document.getElementById(containerId).appendChild(imgElement);
}
function displayShorthandImages(shorthands) {
const container = document.getElementById('shorthand-images');
shorthands.forEach(shorthand => createEmojiImage(shorthand, 'shorthand-images'));
}
function displayUnsupportedShorthands(unsupported) {
const container = document.getElementById('unsupported-images');
container.innerHTML = '<h3>Unsupported Emojis</h3>';
unsupported.forEach(shorthand => createEmojiImage(shorthand, 'unsupported-images'));
}
// Download supported emojis only
document.addEventListener("DOMContentLoaded", () => {
document.getElementById('download-btn').addEventListener('click', async () => {
const images = document.querySelectorAll('#shorthand-images img.emoji');
if (!images.length) {
alert("No images to download.");
return;
}
const zip = new JSZip();
const folder = zip.folder("emojis");
for (const img of images) {
const url = img.src;
let filename = img.alt;
if (!filename) filename = 'emoji';
if (!filename.endsWith('.gif')) filename += '.gif';
try {
const response = await fetch(url);
if (!response.ok) {
console.warn(`Failed to fetch ${filename}`);
continue;
}
const blob = await response.blob();
folder.file(filename, blob);
} catch (e) {
console.warn(`Error fetching ${filename}:`, e);
}
}
zip.generateAsync({ type: "blob" }).then(content => {
saveAs(content, "emoji_images.zip");
});
});
});
// Handle postMessage from parent
window.addEventListener('message', (event) => {
if (event.origin !== window.location.origin) return;
if (event.data.type === 'changeBackgroundColor') {
document.body.style.backgroundColor = event.data.color;
}
});
// Init
fetchAndProcessJSON();
</script>
</body>
</html>