From 62e93c5970a879c963db0a0b1775022306915d23 Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Tue, 23 Sep 2025 19:02:03 +0000 Subject: [PATCH] Bug 32542: Add 'wait_for_images' to results.js' --- .../intranet-tmpl/prog/js/pages/results.js | 32 +++++++++++++++++-- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/js/pages/results.js b/koha-tmpl/intranet-tmpl/prog/js/pages/results.js index cfe0cd88ba8..a4a50903351 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/pages/results.js +++ b/koha-tmpl/intranet-tmpl/prog/js/pages/results.js @@ -130,9 +130,35 @@ function verify_cover_images() { }); } -$(window).load(function () { - verify_cover_images(); -}); +if (PREF_IntranetCoce && PREF_CoceProviders) { + let counter_wait = 0; + function wait_for_images(cb){ + + var loaded = 1; + counter_wait++; + + if ( loaded ) { + loaded = KOHA.coce.done; + } + + if (!loaded && counter_wait < 50) {// Do not wait more than 5 seconds + window.setTimeout(function(){wait_for_images(cb);}, 100); + } else { + if (counter_wait >= 50 ) { + console.log("Could not retrieve the images") + } + cb(); + } + } + + $(window).load(function() { + wait_for_images(verify_cover_images); + }); +} else { + $(window).load(function() { + verify_cover_images(); + }); +} var toHighlight = {}; var q_array; -- 2.39.5