1/** 2 * Checks if a value is empty. 3 * 4 * Empty values are: 5 * - undefined 6 * - null 7 * - NaN 8 * - empty strings 9 * - empty arrays 10 * - empty objects 11 * 12 * @param {*} value 13 * @returns {boolean} 14 */ 15H5P.isEmpty = (value) => { 16 if (!value && value !== 0 && value !== false) { 17 return true; // undefined, null, NaN and empty strings. 18 } else if (Array.isArray(value)) { 19 for (let i = 0; i < value.length; i++) { 20 if (!H5P.isEmpty(value[i])) { 21 return false; // Array contains a non-empty value 22 } 23 } 24 return true; // Empty array 25 } else if (typeof value === "object") { 26 for (let prop in value) { 27 if (value.hasOwnProperty(prop) && !H5P.isEmpty(value[prop])) { 28 return false; // Object contains a non-empty value 29 } 30 } 31 return true; // Empty object 32 } 33 return false; 34}; 35 36H5P.setFinished = async function (contentId, score, maxScore, time) { 37 var validScore = typeof score === 'number' || score instanceof Number; 38 if (validScore && H5PIntegration.postUserStatistics === true) { 39 /** 40 * Return unix timestamp for the given JS Date. 41 * 42 * @private 43 * @param {Date} date 44 * @returns {Number} 45 */ 46 var toUnix = function (date) { 47 return Math.round(date.getTime() / 1000); 48 }; 49 50 const data = { 51 contentId: contentId, 52 score: score, 53 maxScore: maxScore, 54 opened: toUnix(H5P.opened[contentId]), 55 finished: toUnix(new Date()), 56 time: time 57 }; 58 const abc= await fetch(H5PIntegration.ajax.setFinished, { 59 method: 'POST', 60 credentials: 'include', // This is the key part 61 body: JSON.stringify(data) 62 }).catch((e) => { 63 console.log(e,'loveleet') 64 }); 65 } 66};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.