File tree Expand file tree Collapse file tree 2 files changed +22
-1
lines changed
Resources/Public/JavaScript/PageView Expand file tree Collapse file tree 2 files changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -832,7 +832,7 @@ dlfViewer.prototype.displayHighlightWord = function(highlightWords = null) {
832832 */
833833dlfViewer . prototype . init = function ( controlNames ) {
834834
835- if ( this . imageUrls . length <= 0 )
835+ if ( ! dlfUtils . hasContent ( this . imageUrls ) )
836836 throw new Error ( 'Missing image source objects.' ) ;
837837
838838 this . initLayer ( this . imageUrls )
Original file line number Diff line number Diff line change @@ -532,6 +532,27 @@ dlfUtils.getUrlParam = function (param) {
532532 return null ;
533533} ;
534534
535+ /**
536+ * Check if an array (possibly nested) contains at least one non-empty value.
537+ *
538+ * @param {Array } arr - The array to check (may be nested).
539+ * @returns {boolean } True if at least one non-empty value exists, false otherwise.
540+ */
541+ dlfUtils . hasContent = function ( arr ) {
542+ if ( ! Array . isArray ( arr ) ) {
543+ return false ;
544+ }
545+
546+ return arr . some ( item => {
547+ if ( Array . isArray ( item ) ) {
548+ // Recurse into nested arrays
549+ return dlfUtils . hasContent ( item ) ;
550+ }
551+ // Check primitive values: must not be null/undefined/empty-string
552+ return item !== null && item !== undefined && String ( item ) . trim ( ) !== "" ;
553+ } ) ;
554+ } ;
555+
535556/**
536557 * Returns true if the specified value is null.
537558 * @param {? } val
You can’t perform that action at this time.
0 commit comments