Skip to content

Commit 30feeaa

Browse files
V1.4: hide not found files
1 parent d1b5741 commit 30feeaa

1 file changed

Lines changed: 28 additions & 15 deletions

File tree

viewer.html

Lines changed: 28 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
Modestly updated by https://github.com/toutjavascript
1111
https://www.toutjavascript.com
1212
13-
File Version 2024-01-12/A1
13+
File Version 2024-01-18/A1
1414
-->
1515

1616
<html lang="us">
@@ -44,10 +44,9 @@
4444
{item: "displayMetaBlock", type:"checkbox", label:"View Meta Detail on Zoomed Image", value: true},
4545
{item: "nbColumns", type:"integer", label:"Number of columns in the grid", value: 3},
4646
{item: "nbImagePerPage", type:"integer", label:"Number of images displayed per page", value: 32},
47-
48-
49-
5047
];
48+
var workingDates=[], detailDates=[];
49+
var nbImageNotFoundByBatches=[]; /* Number of images not found by batch (deleted by user) : use to display on each batch block */
5150

5251

5352

@@ -112,8 +111,18 @@
112111
});
113112
}
114113

115-
/* Create an empty image */
116-
function getNotFoundImg() {
114+
/* Create an empty image
115+
Update batch label error
116+
*/
117+
function getNotFoundImg(batchNumber) {
118+
if (typeof nbImageNotFoundByBatches[batchNumber]=="undefined") {
119+
nbImageNotFoundByBatches[batchNumber]=0;
120+
}
121+
nbImageNotFoundByBatches[batchNumber]++;
122+
123+
$("span#batchNumber-"+batchNumber).html(" / "+nbImageNotFoundByBatches[batchNumber]+" not found").attr("title", "Probably deleted by user");
124+
125+
/* Generate image not found */
117126
let svgElement = document.createElementNS("http://www.w3.org/2000/svg", 'svg'); // Create a new SVG element
118127
svgElement.setAttribute('width', '500'); // Set the width and height of the SVG canvas
119128
svgElement.setAttribute('height', '500');
@@ -170,8 +179,6 @@
170179
return autoReload;
171180
});
172181
React.useEffect(() => {
173-
console.log("autorelod=")
174-
console.log(autoReload)
175182
localStorage.setItem("autoReload", autoReload.toString());
176183
}, [autoReload]);
177184

@@ -270,7 +277,6 @@
270277
React.useEffect(fetchData, [date]);
271278

272279
React.useEffect(() => {
273-
setPlaySound(getParam("playSound")=="true"?true:false);
274280

275281
if (autoReload) {
276282
const interval = setInterval(() => {
@@ -512,6 +518,7 @@
512518
const batchData = getBatchData(sortedData);
513519

514520
React.useEffect(() => {
521+
nbImageNotFoundByBatches=[];
515522

516523
setShowDetail(getParam("displayDetails")=="true"?true:false);
517524
setShowDiff(getParam("displayDiff")=="true"?true:false);
@@ -676,7 +683,7 @@
676683
<p className="flex justify-between">
677684
<span className="text-base mb-0">
678685
<strong>Batch {batch.batchNumber}</strong> ({numBatchImages}{" "}
679-
Images)
686+
Images<span id={"batchNumber-"+batch.batchNumber} class="batchError"></span>)
680687
</span>
681688
<span>{batch.timeStr}</span>
682689
</p>
@@ -753,10 +760,11 @@
753760
data-name={data.src}
754761
data-json={JSON.stringify(data)}
755762
data-error="false"
763+
data-batch={batch.batchNumber}
756764
onError={ (evt => {
757-
console.log("error on "+evt.target.src);
758765
evt.target.dataset.error="true";
759-
evt.target.src=getNotFoundImg();
766+
evt.target.src=getNotFoundImg(evt.target.dataset.batch);
767+
$(evt.target).parent().hide();
760768
}) }
761769
width="100%"
762770
/>
@@ -1437,9 +1445,10 @@
14371445
i.addEventListener("load", function() {
14381446
image.setAttribute("data-width", i.width)
14391447
image.setAttribute("data-height", i.height)
1440-
$(image).addClass("cursor-zoom-in");
1441-
if (typeof image.dataset.onclick == "undefined") {
1448+
if ((typeof image.dataset.onclick == "undefined")&&(image.dataset.error=="false")) {
14421449
/* Add only one eventClickListener, necessary because multiple calls*/
1450+
/* Add only if image is not broken */
1451+
$(image).addClass("cursor-zoom-in");
14431452
image.setAttribute("data-onclick", "1");
14441453
image.addEventListener("click", function(evt) {
14451454
zoomImage(evt.target);
@@ -1663,7 +1672,6 @@
16631672

16641673

16651674
/* Get all outputs directory working dates */
1666-
var workingDates=[], detailDates=[];
16671675
function calendarGeneration() {
16681676
console.log("Working date calendar generation");
16691677
getAllDates();
@@ -2024,6 +2032,11 @@
20242032
}
20252033
}
20262034

2035+
span.batchError {
2036+
color:#f33;
2037+
font-weight: bold;
2038+
}
2039+
20272040

20282041
.jBox-TooltipDark .jBox-content {
20292042
background-color: #ba00bd !important;

0 commit comments

Comments
 (0)