Fixed issue #2397891 (drupal.org), and made jshint a little happier

namespaces
Pål Jørgensen 2014-12-30 10:54:26 +01:00
parent cc455f2b2d
commit ec4678bf0b
2 changed files with 23 additions and 23 deletions

View File

@ -90,7 +90,7 @@ var H5P = H5P || (function () {
loadContent(contentId, h5ps[i]);
contentId++;
}
};
}
/**
* Return integration object

View File

@ -164,21 +164,21 @@ H5P.xAPIListener = function(event) {
H5P.setFinished(contentId, score, maxScore);
}
}
}
};
H5P.xAPIEmitter = function (event) {
if (event.statement !== undefined) {
for (var i = 0; i < H5P.xAPIListeners.length; i++) {
H5P.xAPIListeners[i](event.statement)
H5P.xAPIListeners[i](event.statement);
}
}
}
};
H5P.xAPIListeners = [];
H5P.onXAPI = function(listener) {
H5P.xAPIListeners.push(listener);
}
};
H5P.onXAPI(function(statement) {
console.log(statement);
@ -449,7 +449,7 @@ H5P.EventEnabled.prototype.on = function(type, listener) {
}
this.listeners[type].push(listener);
}
}
};
H5P.EventEnabled.prototype.off = function (type, listener) {
if (this.listeners[type] !== undefined) {
@ -458,7 +458,7 @@ H5P.EventEnabled.prototype.off = function (type, listener) {
listeners[type].splice(removeIndex, 1);
}
}
}
};
H5P.EventEnabled.prototype.trigger = function (type, event) {
if (event === null) {
@ -469,16 +469,16 @@ H5P.EventEnabled.prototype.trigger = function (type, event) {
this.listeners[type][i](event);
}
}
}
};
H5P.Event = function() {
// We're going to add bubbling, propagation and other features here later
}
};
H5P.XAPIEvent = function() {
H5P.Event.call(this);
this.statement = {};
}
};
H5P.XAPIEvent.prototype = Object.create(H5P.Event.prototype);
H5P.XAPIEvent.prototype.constructor = H5P.XAPIEvent;
@ -490,8 +490,8 @@ H5P.XAPIEvent.prototype.setScoredResult = function(score, maxScore) {
'max': maxScore,
'raw': score
}
}
}
};
};
H5P.XAPIEvent.prototype.setVerb = function(verb) {
if (H5P.jQuery.inArray(verb, H5P.XAPIEvent.allowedXAPIVerbs) !== -1) {
@ -500,13 +500,13 @@ H5P.XAPIEvent.prototype.setVerb = function(verb) {
'display': {
'en-US': verb
}
}
};
}
else {
console.log('illegal verb');
}
// Else: Fail silently...
}
};
H5P.XAPIEvent.prototype.setObject = function(instance) {
this.statement.object = {
@ -514,17 +514,17 @@ H5P.XAPIEvent.prototype.setObject = function(instance) {
'id': window.location.origin + Drupal.settings.basePath + 'node/' + instance.contentId,
//'contentId': instance.contentId,
'objectType': 'Activity'
}
}
};
};
H5P.XAPIEvent.prototype.setActor = function() {
this.statement.actor = H5P.getActor();
}
};
H5P.EventEnabled.prototype.triggerXAPI = function(verb, extra) {
var event = this.createXAPIEventTemplate(verb, extra);
this.trigger('xAPI', event);
}
};
H5P.EventEnabled.prototype.createXAPIEventTemplate = function(verb, extra) {
var event = new H5P.XAPIEvent();
@ -540,17 +540,17 @@ H5P.EventEnabled.prototype.createXAPIEventTemplate = function(verb, extra) {
event.setObject(this);
}
return event;
}
};
H5P.getActor = function() {
var user = H5PIntegration.getUser();
return {
'name': user.name,
'mbox': 'mailto:' . user.mail,
'mbox': 'mailto:' + user.mail,
'objectType': 'Agent'
}
}
};
};
H5P.XAPIEvent.allowedXAPIVerbs = [
'answered',
@ -578,7 +578,7 @@ H5P.XAPIEvent.allowedXAPIVerbs = [
'suspended',
'terminated',
'voided'
]
];
/**
* Used to print useful error messages.