Spaces:
Runtime error
Runtime error
Upload 13 files
Browse files- index.html +63 -43
index.html
CHANGED
|
@@ -1666,21 +1666,19 @@
|
|
| 1666 |
}
|
| 1667 |
return;
|
| 1668 |
}
|
| 1669 |
-
|
| 1670 |
-
|
| 1671 |
-
|
| 1672 |
-
|
| 1673 |
-
|
| 1674 |
-
|
| 1675 |
-
}
|
| 1676 |
-
}
|
| 1677 |
-
|
| 1678 |
-
|
| 1679 |
-
|
| 1680 |
-
|
| 1681 |
-
|
| 1682 |
-
Database.update(item.id, { thumb }).catch(() => {});
|
| 1683 |
-
}
|
| 1684 |
|
| 1685 |
if ('requestIdleCallback' in window) {
|
| 1686 |
requestIdleCallback(processNext);
|
|
@@ -1797,15 +1795,38 @@
|
|
| 1797 |
}
|
| 1798 |
};
|
| 1799 |
|
| 1800 |
-
|
| 1801 |
-
|
| 1802 |
-
|
| 1803 |
-
|
| 1804 |
-
|
| 1805 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1806 |
}
|
| 1807 |
-
}
|
| 1808 |
-
}
|
|
|
|
|
|
|
| 1809 |
const preloader = new Image();
|
| 1810 |
preloader.onload = () => {
|
| 1811 |
if (AppState.currentModalItem === item) {
|
|
@@ -2382,19 +2403,18 @@
|
|
| 2382 |
}
|
| 2383 |
return;
|
| 2384 |
}
|
| 2385 |
-
|
| 2386 |
-
|
| 2387 |
-
|
| 2388 |
-
|
| 2389 |
-
|
| 2390 |
-
|
| 2391 |
-
|
| 2392 |
-
|
| 2393 |
-
const
|
| 2394 |
-
|
| 2395 |
-
|
| 2396 |
-
|
| 2397 |
-
}
|
| 2398 |
|
| 2399 |
if ('requestIdleCallback' in window) {
|
| 2400 |
requestIdleCallback(processNext);
|
|
@@ -3005,19 +3025,19 @@
|
|
| 3005 |
if (Device.isMobile && previewImage.startsWith('data:image') && previewImage.length > 900000) {
|
| 3006 |
const reduceTask = async () => {
|
| 3007 |
try {
|
| 3008 |
-
|
| 3009 |
-
|
| 3010 |
-
|
| 3011 |
-
|
| 3012 |
}
|
| 3013 |
if (!newItem.thumb) {
|
| 3014 |
-
const newThumb = await ImageHandler.createThumbnail(
|
| 3015 |
-
if (newThumb && newThumb !==
|
| 3016 |
newItem.thumb = newThumb;
|
| 3017 |
}
|
| 3018 |
}
|
| 3019 |
if (AppState.db && newItem.id && !String(newItem.id).startsWith('temp-')) {
|
| 3020 |
-
Database.update(newItem.id, {
|
| 3021 |
}
|
| 3022 |
GalleryManager.render();
|
| 3023 |
} catch (error) {
|
|
|
|
| 1666 |
}
|
| 1667 |
return;
|
| 1668 |
}
|
| 1669 |
+
const source = item.image || item.imageUrl;
|
| 1670 |
+
let sourceForThumb = source;
|
| 1671 |
+
if (Device.isMobile && sourceForThumb && sourceForThumb.startsWith('data:image') && sourceForThumb.length > 900000) {
|
| 1672 |
+
const reduced = await ImageHandler.reduceImageForMobile(sourceForThumb);
|
| 1673 |
+
if (reduced) {
|
| 1674 |
+
sourceForThumb = reduced;
|
| 1675 |
+
}
|
| 1676 |
+
}
|
| 1677 |
+
const thumb = await ImageHandler.createThumbnail(sourceForThumb, maxWidth, quality);
|
| 1678 |
+
if (thumb && thumb !== source) {
|
| 1679 |
+
item.thumb = thumb;
|
| 1680 |
+
Database.update(item.id, { thumb }).catch(() => {});
|
| 1681 |
+
}
|
|
|
|
|
|
|
| 1682 |
|
| 1683 |
if ('requestIdleCallback' in window) {
|
| 1684 |
requestIdleCallback(processNext);
|
|
|
|
| 1795 |
}
|
| 1796 |
};
|
| 1797 |
|
| 1798 |
+
const setFullFromBase64 = () => {
|
| 1799 |
+
if (AppState.currentModalItem === item) {
|
| 1800 |
+
this.imgEl.src = item.image;
|
| 1801 |
+
}
|
| 1802 |
+
};
|
| 1803 |
+
|
| 1804 |
+
if (item.image && item.image.startsWith('data:image') && !fullUrl) {
|
| 1805 |
+
if (item.image.length > 1200000) {
|
| 1806 |
+
ImageHandler.dataUrlToObjectUrlAsync(item.image).then((url) => {
|
| 1807 |
+
if (url) {
|
| 1808 |
+
item.displayUrl = url;
|
| 1809 |
+
if (AppState.currentModalItem === item) {
|
| 1810 |
+
this.imgEl.src = url;
|
| 1811 |
+
}
|
| 1812 |
+
return;
|
| 1813 |
+
}
|
| 1814 |
+
if ('requestIdleCallback' in window) {
|
| 1815 |
+
requestIdleCallback(setFullFromBase64);
|
| 1816 |
+
} else {
|
| 1817 |
+
setTimeout(setFullFromBase64, 0);
|
| 1818 |
+
}
|
| 1819 |
+
});
|
| 1820 |
+
} else if (initialSrc !== item.image) {
|
| 1821 |
+
if ('requestIdleCallback' in window) {
|
| 1822 |
+
requestIdleCallback(setFullFromBase64);
|
| 1823 |
+
} else {
|
| 1824 |
+
setTimeout(setFullFromBase64, 0);
|
| 1825 |
}
|
| 1826 |
+
}
|
| 1827 |
+
}
|
| 1828 |
+
|
| 1829 |
+
if (fullUrl && initialSrc !== fullUrl) {
|
| 1830 |
const preloader = new Image();
|
| 1831 |
preloader.onload = () => {
|
| 1832 |
if (AppState.currentModalItem === item) {
|
|
|
|
| 2403 |
}
|
| 2404 |
return;
|
| 2405 |
}
|
| 2406 |
+
const source = item.image || item.imageUrl;
|
| 2407 |
+
let sourceForThumb = source;
|
| 2408 |
+
if (sourceForThumb && sourceForThumb.startsWith('data:image') && sourceForThumb.length > 900000) {
|
| 2409 |
+
const reduced = await ImageHandler.reduceImageForMobile(sourceForThumb);
|
| 2410 |
+
if (reduced) {
|
| 2411 |
+
sourceForThumb = reduced;
|
| 2412 |
+
}
|
| 2413 |
+
}
|
| 2414 |
+
const thumb = await ImageHandler.createThumbnail(sourceForThumb, maxWidth, quality);
|
| 2415 |
+
if (thumb && thumb !== source) {
|
| 2416 |
+
item.thumb = thumb;
|
| 2417 |
+
}
|
|
|
|
| 2418 |
|
| 2419 |
if ('requestIdleCallback' in window) {
|
| 2420 |
requestIdleCallback(processNext);
|
|
|
|
| 3025 |
if (Device.isMobile && previewImage.startsWith('data:image') && previewImage.length > 900000) {
|
| 3026 |
const reduceTask = async () => {
|
| 3027 |
try {
|
| 3028 |
+
let sourceForThumb = previewImage;
|
| 3029 |
+
const reduced = await ImageHandler.reduceImageForMobile(sourceForThumb);
|
| 3030 |
+
if (reduced) {
|
| 3031 |
+
sourceForThumb = reduced;
|
| 3032 |
}
|
| 3033 |
if (!newItem.thumb) {
|
| 3034 |
+
const newThumb = await ImageHandler.createThumbnail(sourceForThumb, 360, 0.6);
|
| 3035 |
+
if (newThumb && newThumb !== sourceForThumb) {
|
| 3036 |
newItem.thumb = newThumb;
|
| 3037 |
}
|
| 3038 |
}
|
| 3039 |
if (AppState.db && newItem.id && !String(newItem.id).startsWith('temp-')) {
|
| 3040 |
+
Database.update(newItem.id, { thumb: newItem.thumb }).catch(() => {});
|
| 3041 |
}
|
| 3042 |
GalleryManager.render();
|
| 3043 |
} catch (error) {
|