From 31ddbd83794539c431f6cc7ae8eacea02655cc9b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A5l=20J=C3=B8rgensen?= Date: Wed, 2 Apr 2014 00:10:30 +0200 Subject: [PATCH] Made getCopyrights work with empty optional fields --- js/questionset.js | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/js/questionset.js b/js/questionset.js index 3985f57..ec4de30 100644 --- a/js/questionset.js +++ b/js/questionset.js @@ -385,7 +385,7 @@ H5P.QuestionSet = function (options, contentId) { var info = new H5P.ContentCopyrights(); // Background - if (params.backgroundImage.copyright !== undefined) { + if (params.backgroundImage !== undefined && params.backgroundImage.copyright !== undefined) { var background = new H5P.MediaCopyright(params.backgroundImage.copyright); background.setThumbnail(new H5P.Thumbnail(H5P.getPath(params.backgroundImage.path, contentId), params.backgroundImage.width, params.backgroundImage.height)); info.addMedia(background); @@ -404,15 +404,19 @@ H5P.QuestionSet = function (options, contentId) { } // Success video - var video = params.endGame.successVideo[0]; - if (video.copyright !== undefined) { - info.addMedia(new H5P.MediaCopyright(video.copyright)); + if (params.endGame.successVideo !== undefined && params.endGame.successVideo.length > 0) { + var video = params.endGame.successVideo[0]; + if (video.copyright !== undefined) { + info.addMedia(new H5P.MediaCopyright(video.copyright)); + } } // Fail video - video = params.endGame.failVideo[0]; - if (video.copyright !== undefined) { - info.addMedia(new H5P.MediaCopyright(video.copyright)); + if (params.endGame.failVideo !== undefined && params.endGame.failVideo.length > 0) { + video = params.endGame.failVideo[0]; + if (video.copyright !== undefined) { + info.addMedia(new H5P.MediaCopyright(video.copyright)); + } } return info;