Satisfy JSHint and prevent crashing.

d6
Frode Petterson 2015-02-20 10:26:33 +01:00
parent 688b00f55e
commit 971a55df58
3 changed files with 22 additions and 23 deletions

View File

@ -2,7 +2,7 @@ var H5P = H5P || {};
/** /**
* Constructor for xAPI events * Constructor for xAPI events
* *
* @class * @class
*/ */
H5P.XAPIEvent = function() { H5P.XAPIEvent = function() {
@ -14,7 +14,7 @@ H5P.XAPIEvent.prototype.constructor = H5P.XAPIEvent;
/** /**
* Helperfunction to set scored result statements * Helperfunction to set scored result statements
* *
* @param {int} score * @param {int} score
* @param {int} maxScore * @param {int} maxScore
*/ */
@ -30,7 +30,7 @@ H5P.XAPIEvent.prototype.setScoredResult = function(score, maxScore) {
/** /**
* Helperfunction to set a verb. * Helperfunction to set a verb.
* *
* @param {string} verb * @param {string} verb
* Verb in short form, one of the verbs defined at * Verb in short form, one of the verbs defined at
* http://adlnet.gov/expapi/verbs/ * http://adlnet.gov/expapi/verbs/
@ -45,14 +45,13 @@ H5P.XAPIEvent.prototype.setVerb = function(verb) {
}; };
} }
else { else {
console.log('illegal verb'); H5P.error('illegal verb');
} }
// Else: Fail silently...
}; };
/** /**
* Helperfunction to get the statements verb id * Helperfunction to get the statements verb id
* *
* @param {boolean} full * @param {boolean} full
* if true the full verb id prefixed by http://adlnet.gov/expapi/verbs/ will be returned * if true the full verb id prefixed by http://adlnet.gov/expapi/verbs/ will be returned
* @returns {string} - Verb or null if no verb with an id has been defined * @returns {string} - Verb or null if no verb with an id has been defined
@ -68,13 +67,13 @@ H5P.XAPIEvent.prototype.getVerb = function(full) {
else { else {
return null; return null;
} }
} };
/** /**
* Helperfunction to set the object part of the statement. * Helperfunction to set the object part of the statement.
* *
* The id is found automatically (the url to the content) * The id is found automatically (the url to the content)
* *
* @param {object} instance - the H5P instance * @param {object} instance - the H5P instance
*/ */
H5P.XAPIEvent.prototype.setObject = function(instance) { H5P.XAPIEvent.prototype.setObject = function(instance) {
@ -109,7 +108,7 @@ H5P.XAPIEvent.prototype.setActor = function() {
/** /**
* Get the max value of the result - score part of the statement * Get the max value of the result - score part of the statement
* *
* @returns {int} the max score, or null if not defined * @returns {int} the max score, or null if not defined
*/ */
H5P.XAPIEvent.prototype.getMaxScore = function() { H5P.XAPIEvent.prototype.getMaxScore = function() {
@ -118,7 +117,7 @@ H5P.XAPIEvent.prototype.getMaxScore = function() {
/** /**
* Get the raw value of the result - score part of the statement * Get the raw value of the result - score part of the statement
* *
* @returns {int} the max score, or null if not defined * @returns {int} the max score, or null if not defined
*/ */
H5P.XAPIEvent.prototype.getScore = function() { H5P.XAPIEvent.prototype.getScore = function() {
@ -127,7 +126,7 @@ H5P.XAPIEvent.prototype.getScore = function() {
/** /**
* Figure out if a property exists in the statement and return it * Figure out if a property exists in the statement and return it
* *
* @param {array} keys * @param {array} keys
* List describing the property we're looking for. For instance * List describing the property we're looking for. For instance
* ['result', 'score', 'raw'] for result.score.raw * ['result', 'score', 'raw'] for result.score.raw
@ -146,7 +145,7 @@ H5P.XAPIEvent.prototype.getVerifiedStatementValue = function(keys) {
/** /**
* List of verbs defined at http://adlnet.gov/expapi/verbs/ * List of verbs defined at http://adlnet.gov/expapi/verbs/
* *
* @type Array * @type Array
*/ */
H5P.XAPIEvent.allowedXAPIVerbs = [ H5P.XAPIEvent.allowedXAPIVerbs = [
@ -175,4 +174,4 @@ H5P.XAPIEvent.allowedXAPIVerbs = [
'suspended', 'suspended',
'terminated', 'terminated',
'voided' 'voided'
]; ];

View File

@ -11,7 +11,7 @@ if (window.top !== window.self && window.top.H5P !== undefined && window.top.H5P
/** /**
* Helper function for triggering xAPI added to the EventDispatcher * Helper function for triggering xAPI added to the EventDispatcher
* *
* @param {string} verb - the short id of the verb we want to trigger * @param {string} verb - the short id of the verb we want to trigger
* @param {oject} extra - extra properties for the xAPI statement * @param {oject} extra - extra properties for the xAPI statement
*/ */
@ -21,10 +21,10 @@ H5P.EventDispatcher.prototype.triggerXAPI = function(verb, extra) {
/** /**
* Helper function to create event templates added to the EventDispatcher * Helper function to create event templates added to the EventDispatcher
* *
* Will in the future be used to add representations of the questions to the * Will in the future be used to add representations of the questions to the
* statements. * statements.
* *
* @param {string} verb - verb id in short form * @param {string} verb - verb id in short form
* @param {object} extra - Extra values to be added to the statement * @param {object} extra - Extra values to be added to the statement
* @returns {Function} - XAPIEvent object * @returns {Function} - XAPIEvent object
@ -55,11 +55,11 @@ H5P.EventDispatcher.prototype.triggerXAPICompleted = function(score, maxScore) {
var event = this.createXAPIEventTemplate('completed'); var event = this.createXAPIEventTemplate('completed');
event.setScoredResult(score, maxScore); event.setScoredResult(score, maxScore);
this.trigger(event); this.trigger(event);
} };
/** /**
* Internal H5P function listening for xAPI completed events and stores scores * Internal H5P function listening for xAPI completed events and stores scores
* *
* @param {function} event - xAPI event * @param {function} event - xAPI event
*/ */
H5P.xAPICompletedListener = function(event) { H5P.xAPICompletedListener = function(event) {
@ -72,4 +72,4 @@ H5P.xAPICompletedListener = function(event) {
H5P.setFinished(contentId, score, maxScore); H5P.setFinished(contentId, score, maxScore);
} }
} }
}; };

View File

@ -548,7 +548,7 @@ H5P.newRunnable = function (library, contentId, $attachTo, skipResize) {
* @returns {undefined} * @returns {undefined}
*/ */
H5P.error = function (err) { H5P.error = function (err) {
if (window['console'] !== undefined && console.error !== undefined) { if (window.console !== undefined && console.error !== undefined) {
console.error(err); console.error(err);
} }
}; };
@ -1244,7 +1244,7 @@ H5P.trigger = function(instance, eventType) {
} }
// Try deprecated event system // Try deprecated event system
else if (instance.$ !== undefined && instance.$.trigger !== undefined) { else if (instance.$ !== undefined && instance.$.trigger !== undefined) {
instance.$.trigger(eventType) instance.$.trigger(eventType);
} }
}; };
@ -1268,6 +1268,6 @@ H5P.on = function(instance, eventType, handler) {
} }
// Try deprecated event system // Try deprecated event system
else if (instance.$ !== undefined && instance.$.on !== undefined) { else if (instance.$ !== undefined && instance.$.on !== undefined) {
instance.$.on(eventType, handler) instance.$.on(eventType, handler);
} }
}; };