Skip to content

Commit

Permalink
MOBILE-4508 h5p: Update H5P lib to 1.26
Browse files Browse the repository at this point in the history
  • Loading branch information
dpalou committed Feb 27, 2024
1 parent 5ef95b6 commit 8021e7e
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
29 changes: 29 additions & 0 deletions src/core/features/h5p/assets/js/h5p.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down
5 changes: 5 additions & 0 deletions src/core/features/h5p/classes/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down

0 comments on commit 8021e7e

Please sign in to comment.