From 8021e7ef5a9b9afdd098c7af75c7003ce05f7e59 Mon Sep 17 00:00:00 2001 From: Dani Palou Date: Tue, 27 Feb 2024 12:22:58 +0100 Subject: [PATCH] MOBILE-4508 h5p: Update H5P lib to 1.26 --- src/core/features/h5p/assets/js/h5p.js | 29 ++++++++++++++++++++++++++ src/core/features/h5p/classes/core.ts | 5 +++++ 2 files changed, 34 insertions(+) diff --git a/src/core/features/h5p/assets/js/h5p.js b/src/core/features/h5p/assets/js/h5p.js index 53ebbb4ec..72c0b810f 100644 --- a/src/core/features/h5p/assets/js/h5p.js +++ b/src/core/features/h5p/assets/js/h5p.js @@ -2168,6 +2168,35 @@ H5P.trim = function (value) { // So should we make this function deprecated? }; +/** + * Recursive function that detects deep empty structures. + * + * @param {*} value + * @returns {bool} + */ +H5P.isEmpty = value => { + if (!value && value !== 0 && value !== false) { + return true; // undefined, null, NaN and empty strings. + } + else if (Array.isArray(value)) { + for (let i = 0; i < value.length; i++) { + if (!H5P.isEmpty(value[i])) { + return false; // Array contains a non-empty value + } + } + return true; // Empty array + } + else if (typeof value === 'object') { + for (let prop in value) { + if (value.hasOwnProperty(prop) && !H5P.isEmpty(value[prop])) { + return false; // Object contains a non-empty value + } + } + return true; // Empty object + } + return false; +}; + /** * Check if JavaScript path/key is loaded. * diff --git a/src/core/features/h5p/classes/core.ts b/src/core/features/h5p/classes/core.ts index 111fcae7a..70e2c9f29 100644 --- a/src/core/features/h5p/classes/core.ts +++ b/src/core/features/h5p/classes/core.ts @@ -31,6 +31,11 @@ import { CorePath } from '@singletons/path'; */ export class CoreH5PCore { + static readonly API_VERSION = { + majorVersion: 1, + minorVersion: 26, + }; + static readonly STYLES = [ 'styles/h5p.css', 'styles/h5p-confirmation-dialog.css',