Make UUID creator available for everyone

semantics-font
Svein-Tore Griff With 2015-03-21 14:16:31 +01:00
parent b04756a520
commit 76b0fc04f8
2 changed files with 13 additions and 4 deletions

View File

@ -111,10 +111,7 @@ H5P.XAPIEvent.prototype.setActor = function() {
uuid = localStorage.H5PUserUUID;
}
else {
uuid = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(char) {
var random = Math.random()*16|0, newChar = char === 'x' ? random : (random&0x3|0x8);
return newChar.toString(16);
});
uuid = H5P.createUUID();
localStorage.H5PUserUUID = uuid;
}
this.data.statement.actor = {

View File

@ -1391,6 +1391,18 @@ H5P.on = function(instance, eventType, handler) {
}
};
/**
* Create UUID
*
* @returns {String} UUID
*/
H5P.createUUID = function() {
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(char) {
var random = Math.random()*16|0, newChar = char === 'x' ? random : (random&0x3|0x8);
return newChar.toString(16);
});
};
H5P.jQuery(document).ready(function () {
if (!H5P.preventInit) {