Skip to content

Commit

Permalink
fix: safety check and logging for showParts()
Browse files Browse the repository at this point in the history
  • Loading branch information
timotheeg committed Feb 9, 2025
1 parent 3ebdf94 commit 3ddc107
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions public/ocr/ocr_main.js
Original file line number Diff line number Diff line change
Expand Up @@ -896,13 +896,6 @@ function resetShowPartsTimer() {
hide_show_parts_timer = setTimeout(hideParts, 45000); // parts stop showing after 45s of static config
}

function loadImage(img, src) {
return new Promise(resolve => {
img.onload = resolve;
img.src = src;
});
}

function updatePaletteList() {
palette_selector.innerHTML = '';

Expand Down Expand Up @@ -1548,11 +1541,19 @@ async function showParts(data) {
if (config.palette && name.startsWith('color')) continue;

const task = config.tasks[name];
const scale_factor = name.startsWith('color') ? 4 : 2;

if (!task) continue;

const holder = document.querySelector(`fieldset.${name} div.results`);

if (!holder) {
console.warn(
`Config controls for [${name}] are not present on page, skipping showing part.`
);
continue;
}

const scale_factor = name.startsWith('color') ? 4 : 2;
let separator;

if (!task.crop_canvas_ctx) {
Expand Down

0 comments on commit 3ddc107

Please sign in to comment.