Avoid parsing state multiple times.
parent
e153acbf3e
commit
24fa34f9c2
11
js/h5p.js
11
js/h5p.js
|
@ -57,6 +57,12 @@ H5P.init = function (target) {
|
|||
if (contentData === undefined) {
|
||||
return H5P.error('No data for content id ' + contentId + '. Perhaps the library is gone?');
|
||||
}
|
||||
if (contentData.contentUserDatas && contentData.contentUserDatas.state) {
|
||||
try {
|
||||
contentData.contentUserDatas.state = JSON.parse(contentData.contentUserDatas.state);
|
||||
}
|
||||
catch (err) {}
|
||||
}
|
||||
var library = {
|
||||
library: contentData.library,
|
||||
params: JSON.parse(contentData.jsonContent),
|
||||
|
@ -612,13 +618,10 @@ H5P.newRunnable = function (library, contentId, $attachTo, skipResize) {
|
|||
|
||||
var contentExtrasWrapper;
|
||||
if (library.userDatas && library.userDatas.state) {
|
||||
try {
|
||||
contentExtrasWrapper = {
|
||||
previousState: JSON.parse(library.userDatas.state)
|
||||
previousState: library.userDatas.state
|
||||
};
|
||||
}
|
||||
catch (err) {}
|
||||
}
|
||||
|
||||
var instance = new constructor(library.params, contentId, contentExtrasWrapper);
|
||||
|
||||
|
|
Loading…
Reference in New Issue