diff --git a/amd/build/form.min.js b/amd/build/form.min.js index 62d5a20688b1137279c52c8252668260e499b15a..e10f1f0bd71c4543e000f4050f4cb1dfbee4fe43 100644 --- a/amd/build/form.min.js +++ b/amd/build/form.min.js @@ -1 +1 @@ -define(["jquery"],function(a){var b={init:function(){a("#ltiLaunchForm").submit(function(b){b.preventDefault(),alert("im submitted"),a.ajax({url:"http://localhost:8080/lti",crossDomain:!0,type:"post",xhrFields:{withCredentials:!0},data:a("#ltiLaunchForm").serialize(),complete:function(){a("iframe").each(function(){a(this).attr("src",a(this).data("framesrc"))})}})}),a("#ltiLaunchForm").submit()}};return b}); \ No newline at end of file +define(["jquery"],function(a){var b={init:function(){a("#ltiLaunchForm").submit(function(b){b.preventDefault(),a.ajax({url:"http://localhost:8080/lti",crossDomain:!0,type:"post",xhrFields:{withCredentials:!0},data:a("#ltiLaunchForm").serialize(),complete:function(){a("iframe").each(function(){a(this).attr("src",a(this).data("framesrc"))})}})}),a("#ltiLaunchForm").submit()}};return b}); \ No newline at end of file diff --git a/amd/src/form.js b/amd/src/form.js index 487b4452aae84ed285655512e55d4bbef47cd14d..35df3b2fe97068dc7c6d426b4fe230af95c23b4b 100644 --- a/amd/src/form.js +++ b/amd/src/form.js @@ -24,6 +24,9 @@ define(['jquery'], function ($) { var t = { + /* + * Submits lti form and updates the source attribute of the video iframes + */ init: function () { $('#ltiLaunchForm').submit(function (e) { e.preventDefault(); @@ -43,6 +46,5 @@ define(['jquery'], function ($) { $('#ltiLaunchForm').submit(); } }; - return t; }); diff --git a/filter.php b/filter.php index e61cf43afbe3df017e8fd5c9cf0cc4631ae6ffc4..3a1d8e5e8278c90b3fa8bbdec93162247c680513 100644 --- a/filter.php +++ b/filter.php @@ -39,10 +39,8 @@ require_once($CFG->libdir . '/oauthlib.php'); */ class filter_opencast extends moodle_text_filter { - public function filter($text, array $options = array()) { global $CFG, $PAGE; - //Checks momentarily only for videos embedded in <video> tag if (stripos($text, '</video>') === false) { // Performance shortcut - if there are no </video> tags, nothing can match. @@ -53,8 +51,14 @@ class filter_opencast extends moodle_text_filter { $matches = preg_split('/(<[^>]*>)/i', $text, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE); if ($matches) { - // Get me.json - filter_opencast_load_meInfo(); + + // Login if user is not logged in yet. + $loggedIn = true; + if(!isset($_COOKIE['JSESSIONID'])) { + // Login and set cookie. + filter_opencast_login(); + $loggedIn = false; + } $video = false; @@ -64,14 +68,37 @@ class filter_opencast extends moodle_text_filter { } else if ($video) { $video = false; if (substr($match, 0, 7) === "<source") { - // Extract id + // Get apiurl from opencast tool. + $apiurl = get_config('tool_opencast', 'apiurl'); + + // Check if video is from opencast. + if(strpos($match, $apiurl) === false) { + continue; + } + + if(strpos($apiurl, 'http') !== 0) { + $apiurl = 'http://' . $apiurl; + } + + // Extract id. $id = substr($match, strpos($match, 'api/') + 4, 36); + $src = $CFG->wwwroot . '/filter/opencast/player/core.html?id='.$id.'&ocurl='.urlencode($apiurl); - $player = '<iframe src="" data-frameSrc="' . $CFG->wwwroot . '/filter/opencast/player/core.html?id='.$id.'" width="80%" height="450px" class="ocplayer"></iframe>'; - $link = get_config('filter_opencast', 'baseurlapi') . '/engage/theodul/ui/core.html?id=' . $id; - $newtext = $player . '<a style="display:block;" href="' . $link . '">Zum Video</a>'; - $text = preg_replace('/<video.*<\/video>/', $newtext, $text, 1); + if($loggedIn) { + // Set the source attribute directly. + $player = '<iframe src="'. $src .'" width="95%" height="455px" class="ocplayer"></iframe>'; + } + else { + // Set the source attribute after login. + $player = '<iframe src="" data-frameSrc="' . $src .'" width="95%" height="455px" class="ocplayer"></iframe>'; + } + + $link = $apiurl . '/engage/theodul/ui/core.html?id=' . $id; + // Add link to video. + $newtext = $player . '<a style="display:block;" target="_blank" href="' . $link . '">Zum Video</a>'; + // Replace video tag. + $text = preg_replace('/<video.*<\/video>/', $newtext, $text, 1); } } } diff --git a/lang/en/filter_opencast.php b/lang/en/filter_opencast.php index c1b263ba9e62c5d3a533d0a3686f1d26ede24048..cd97c6d351baa651c1cbc7ad4d76403fdb34bd17 100644 --- a/lang/en/filter_opencast.php +++ b/lang/en/filter_opencast.php @@ -25,7 +25,7 @@ defined('MOODLE_INTERNAL') || die(); $string['filtername'] = 'Opencast'; $string['pluginname'] = 'Opencast Filter'; -$string['setting_issuer'] = 'Issuer'; -$string['setting_issuer_desc'] = 'Issuer Desc'; -$string['setting_baseurlapi'] = 'Opencast API url'; -$string['setting_baseurlapi_desc'] = 'Setup the base url of the Opencast system, for example: opencast.example.com'; \ No newline at end of file +$string['setting_consumerkey'] = 'Consumer key'; +$string['setting_consumerkey_desc'] = 'LTI Consumer key'; +$string['setting_consumersecret'] = 'Consumer secret'; +$string['setting_consumersecret_desc'] = 'LTI Consumer secret'; \ No newline at end of file diff --git a/lib.php b/lib.php index a02bb578961c250dadd89a713ca8f2f5bbf8f47f..df83dec8b1a71df3f2f8d7fb6a37a05964bc9c8f 100644 --- a/lib.php +++ b/lib.php @@ -13,8 +13,8 @@ // // You should have received a copy of the GNU General Public License // along with Moodle. If not, see <http://www.gnu.org/licenses/>. - require_once($CFG->dirroot.'/mod/lti/locallib.php'); +require_once($CFG->dirroot.'/lib/oauthlib.php'); /** * Opencast library functions. @@ -27,76 +27,70 @@ require_once($CFG->dirroot.'/mod/lti/locallib.php'); defined('MOODLE_INTERNAL') || die(); -function filter_opencast_load_meInfo() { - global $CFG, $PAGE; - - $urlparts = parse_url($CFG->wwwroot); - $orgid = $urlparts['host']; - - $endpoint = 'http://localhost:8080/lti'; - - $instance = new stdClass(); - $instance->course = 2; - $instance->typeid = 2; - $instance->launchcontainer = 1; - $instance->id = 101; - $instance->name = 'Opencast'; - $instance->servicesalt = '5a685957417926.81276553'; - - $typeid = 2; - $tool = new stdClass(); - $tool->baseurl = 'http://localhost:8080/lti'; - $tool->tooldomain = 'localhost:8080'; - $tool->state = 1; - $tool->course = 2; - $tool->coursevisible = 1; - - $typeconfig = array(); - $typeconfig['resourcekey'] = 'myconsumerkey'; - $typeconfig['password'] = 'myconsumersecret'; - $typeconfig['sendname'] = 1; - $typeconfig['sendemailaddr'] = 1; - $typeconfig['acceptgrades'] = 1; +/** + * Use lti to login and retrieve cookie from opencast. + */ +function filter_opencast_login() { + global $CFG, $PAGE, $COURSE, $USER; + // Get api url of opencast. + $endpoint = get_config('tool_opencast', 'apiurl'); + if (strpos($endpoint, 'http') !== 0) { + $endpoint = 'http://' . $endpoint; + } + $endpoint .= '/lti'; + + // Get consumerkey and consumersecret. + $consumerkey = get_config('filter_opencast', 'consumerkey'); + $consumersecret = get_config('filter_opencast', 'consumersecret'); + + $helper = new oauth_helper(array('oauth_consumer_key' => $consumerkey, + 'oauth_consumer_secret' => $consumersecret)); + + // Set all necessary parameters. + $params = array(); + $params['oauth_version'] = '1.0'; + $params['oauth_nonce'] = $helper->get_nonce(); + $params['oauth_timestamp'] = $helper->get_timestamp(); + $params['oauth_consumer_key'] = $consumerkey; + $params['user_id'] = $USER->id; + $params['roles'] = lti_get_ims_role($USER, null, $COURSE->id, false); + $params['context_id'] = $COURSE->id; + $params['context_label'] = trim($COURSE->shortname); + $params['context_title'] = trim($COURSE->fullname); + $params['resource_link_title'] = 'Opencast'; + $params['context_type'] = ($COURSE->format == 'site') ? 'Group' : 'CourseSection'; + $params['lis_person_name_given'] = $USER->firstname; + $params['lis_person_name_family'] = $USER->lastname; + $params['lis_person_name_full'] = $USER->firstname . ' ' . $USER->lastname; + $params['ext_user_username'] = $USER->username; + $params['lis_person_contact_email_primary'] = $USER->email; + $params['launch_presentation_locale'] = current_language(); + $params['ext_lms'] = 'moodle-2'; + $params['tool_consumer_info_product_family_code'] = 'moodle'; + $params['tool_consumer_info_version'] = strval($CFG->version); + $params['oauth_callback'] = 'about:blank'; + $params['lti_version'] = 'LTI-1p0'; + $params['lti_message_type'] = 'basic-lti-launch-request'; $urlparts = parse_url($CFG->wwwroot); - $typeconfig['organizationid'] = $urlparts['host']; - - $key = $typeconfig['resourcekey']; - $secret = $typeconfig['password']; - $endpoint = $tool->baseurl; - $orgid = $typeconfig['organizationid']; - $course = $PAGE->course; - $islti2 = isset($tool->toolproxyid); + $params['tool_consumer_instance_guid'] = $urlparts['host']; - $requestparams = lti_build_request($instance, $typeconfig, $course); - $requestparams = array_merge($requestparams, lti_build_standard_request($instance, $orgid, $islti2)); - $launchcontainer = lti_get_launch_container($instance, $typeconfig); - - $target = ''; - switch($launchcontainer) { - case LTI_LAUNCH_CONTAINER_EMBED: - case LTI_LAUNCH_CONTAINER_EMBED_NO_BLOCKS: - $target = 'iframe'; - break; - case LTI_LAUNCH_CONTAINER_REPLACE_MOODLE_WINDOW: - $target = 'frame'; - break; - case LTI_LAUNCH_CONTAINER_WINDOW: - $target = 'window'; - break; - } - if (!empty($target)) { - $requestparams['launch_presentation_document_target'] = $target; + if (!empty($CFG->mod_lti_institution_name)) { + $params['tool_consumer_instance_name'] = trim(html_to_text($CFG->mod_lti_institution_name, 0)); + } else { + $params['tool_consumer_instance_name'] = get_site()->shortname; } + $params['tool_consumer_instance_description'] = trim(html_to_text(get_site()->fullname, 0)); - $requestparams['launch_presentation_return_url'] = $PAGE->url->out(); - $parms = lti_sign_parameters($requestparams, $endpoint, "POST", $key, $secret); + $params['launch_presentation_document_target'] = 'iframe'; + $params['oauth_signature_method'] = 'HMAC-SHA1'; + $params['oauth_signature'] = $helper->sign("POST", $endpoint, $params, $consumersecret.'&'); $content = "<form action=\"" . $endpoint . "\" name=\"ltiLaunchForm\" id=\"ltiLaunchForm\" method=\"post\" encType=\"application/x-www-form-urlencoded\">\n"; - // Contruct html for the launch parameters. - foreach ($parms as $key => $value) { + // Construct html form for the launch parameters. + foreach ($params as $key => $value) { $key = htmlspecialchars($key); $value = htmlspecialchars($value); $content .= "<input type=\"hidden\" name=\"{$key}\""; @@ -107,13 +101,6 @@ function filter_opencast_load_meInfo() { $content .= "</form>\n"; echo $content; + // Submit form. $PAGE->requires->js_call_amd('filter_opencast/form','init'); -} - -function filter_opencast_load_episode($service, $id) { - global $CFG; - // Get episode.json - $params = ['id' => $id]; - $episode = $service->call('episode', $params); - file_put_contents($CFG->dirroot . '\filter\opencast\info\episode.json', $episode); } \ No newline at end of file diff --git a/player/css/core_desktop_style_bottom.css b/player/css/core_desktop_style_bottom.css index bd11bf8b6f2ac9312dc8518d128c59dc6d3162d9..63f6317874a7b12a77364cd496f304a62dcb67f9 100644 --- a/player/css/core_desktop_style_bottom.css +++ b/player/css/core_desktop_style_bottom.css @@ -24,16 +24,16 @@ h1, h2, h3 { } #engage_content { - width: 98%; - margin: 10px auto; + margin: 0px auto; min-width: 750px; + height: 450px; } #engage_video { margin: 0 auto; - margin-top: 5px; min-width: 600px; float: none; + height: 80%; } #engage_controls { diff --git a/player/js/engage/core.js b/player/js/engage/core.js index 61746c6ef8049d1c33f2696498135398348b0173..f829b0080b48471b63413dc924cb954af61dd4c8 100644 --- a/player/js/engage/core.js +++ b/player/js/engage/core.js @@ -21,856 +21,876 @@ /*jslint browser: true, nomen: true*/ /*global define, CustomEvent*/ define(["require", "jquery", "underscore", "backbone", "mousetrap", "bowser", "basil", "bootbox", "mousewheel", "engage/models/engage", "engage/event"], function (require, $, _, Backbone, Mousetrap, Bowser, Basil, Bootbox, Mousewheel, EngageModel, EngageEvent) { - "use strict"; + "use strict"; - var events = { - plugin_load_done: new EngageEvent("Core:plugin_load_done", "when the core loaded the event successfully", "both"), - coreInit: new EngageEvent("Core:init", "", "trigger"), - nextChapter: new EngageEvent("Video:nextChapter", "", "trigger"), - fullscreenEnable: new EngageEvent("Video:fullscreenEnable", "", "trigger"), - fullscreenCancel: new EngageEvent("Video:fullscreenCancel", "", "trigger"), - seek: new EngageEvent("Video:seek", "seek video to a given position in seconds", "trigger"), - previousChapter: new EngageEvent("Video:previousChapter", "", "trigger"), - playPause: new EngageEvent("Video:playPause", "", "trigger"), - muteToggle: new EngageEvent("Video:muteToggle", "", "trigger"), - volumeUp: new EngageEvent("Video:volumeUp", "", "trigger"), - volumeDown: new EngageEvent("Video:volumeDown", "", "trigger"), - customSuccess: new EngageEvent("Notification:customSuccess", "a custom success message", "trigger"), - customError: new EngageEvent("Notification:customError", "an error occurred", "trigger"), - seekLeft: new EngageEvent("Video:seekLeft", "", "trigger"), - seekRight: new EngageEvent("Video:seekRight", "", "trigger"), - playbackRateIncrease: new EngageEvent("Video:playbackRateIncrease", "", "trigger"), - playbackRateDecrease: new EngageEvent("Video:playbackRateDecrease", "", "trigger"), - autoplay: new EngageEvent("Video:autoplay", "", "trigger"), - initialSeek: new EngageEvent("Video:initialSeek", "", "trigger"), - mediaPackageModelError: new EngageEvent("MhConnection:mediaPackageModelError", "", "handler"), - focusVideo: new EngageEvent("Video:focusVideo", "increases the size of one video", "handler"), - movePiP: new EngageEvent("Video:movePiP", "moves the smaller picture over the larger to the different corners", "handler"), - togglePiP: new EngageEvent("Video:togglePiP", "switches between PiP and next to each other layout", "handler"), - moveUp: new EngageEvent("Video:moveUp", "moves video up", "trigger"), - moveDown: new EngageEvent("Video:moveDown", "moves video down", "trigger"), - moveLeft: new EngageEvent("Video:moveLeft", "moves video left", "trigger"), - moveRight: new EngageEvent("Video:moveRight", "moves video right", "trigger"), - moveHorizontal: new EngageEvent("Video:moveHorizontal", "move video horizontal", "trigger"), - moveVertical: new EngageEvent("Video:moveVertical", "move video vertical", "trigger"), - zoomIn: new EngageEvent("Video:zoomIn", "zooms in video", "trigger"), - zoomOut: new EngageEvent("Video:zoomOut", "zooms out video", "trigger") - }; + var events = { + plugin_load_done: new EngageEvent("Core:plugin_load_done", "when the core loaded the event successfully", "both"), + coreInit: new EngageEvent("Core:init", "", "trigger"), + nextChapter: new EngageEvent("Video:nextChapter", "", "trigger"), + fullscreenEnable: new EngageEvent("Video:fullscreenEnable", "", "trigger"), + fullscreenCancel: new EngageEvent("Video:fullscreenCancel", "", "trigger"), + seek: new EngageEvent("Video:seek", "seek video to a given position in seconds", "trigger"), + previousChapter: new EngageEvent("Video:previousChapter", "", "trigger"), + playPause: new EngageEvent("Video:playPause", "", "trigger"), + muteToggle: new EngageEvent("Video:muteToggle", "", "trigger"), + volumeUp: new EngageEvent("Video:volumeUp", "", "trigger"), + volumeDown: new EngageEvent("Video:volumeDown", "", "trigger"), + customSuccess: new EngageEvent("Notification:customSuccess", "a custom success message", "trigger"), + customError: new EngageEvent("Notification:customError", "an error occurred", "trigger"), + seekLeft: new EngageEvent("Video:seekLeft", "", "trigger"), + seekRight: new EngageEvent("Video:seekRight", "", "trigger"), + playbackRateIncrease: new EngageEvent("Video:playbackRateIncrease", "", "trigger"), + playbackRateDecrease: new EngageEvent("Video:playbackRateDecrease", "", "trigger"), + autoplay: new EngageEvent("Video:autoplay", "", "trigger"), + initialSeek: new EngageEvent("Video:initialSeek", "", "trigger"), + mediaPackageModelError: new EngageEvent("MhConnection:mediaPackageModelError", "", "handler"), + focusVideo: new EngageEvent("Video:focusVideo", "increases the size of one video", "handler"), + movePiP: new EngageEvent("Video:movePiP", "moves the smaller picture over the larger to the different corners", "handler"), + togglePiP: new EngageEvent("Video:togglePiP", "switches between PiP and next to each other layout", "handler"), + moveUp: new EngageEvent("Video:moveUp", "moves video up", "trigger"), + moveDown: new EngageEvent("Video:moveDown", "moves video down", "trigger"), + moveLeft: new EngageEvent("Video:moveLeft", "moves video left", "trigger"), + moveRight: new EngageEvent("Video:moveRight", "moves video right", "trigger"), + moveHorizontal: new EngageEvent("Video:moveHorizontal", "move video horizontal", "trigger"), + moveVertical: new EngageEvent("Video:moveVertical", "move video vertical", "trigger"), + zoomIn: new EngageEvent("Video:zoomIn", "zooms in video", "trigger"), + zoomOut: new EngageEvent("Video:zoomOut", "zooms out video", "trigger") + }; - /* change these variables */ - var browser_minVersion_firefox = 24; - var browser_minVersion_chrome = 30; - var browser_minVersion_opera = 20; - var browser_minVersion_safari = 7; - var browser_minVersion_msie = 11; - var browser_minVersion_msedge = 13; - var zoom_wasd_step_size = 15; + /* change these variables */ + var browser_minVersion_firefox = 24; + var browser_minVersion_chrome = 30; + var browser_minVersion_opera = 20; + var browser_minVersion_safari = 7; + var browser_minVersion_msie = 11; + var browser_minVersion_msedge = 13; + var zoom_wasd_step_size = 15; - /* don't change these variables */ - var MeInfoModel; - var setCustomError = false; // just for displaying purposes! - var pluginControlsInserted = false; - var pluginVideoInserted = false; - var pluginTabInserted = false; - var pluginDescriptionInserted = false; - var pluginTimelineInserted = false; - var id_str_error = "str_error"; - var id_customError_str = "customError_str"; - var id_str_reloadPage = "str_reloadPage"; - var id_str_login = "str_login"; - var id_engage_view = "engage_view"; - var id_loading1 = "loading1"; - var id_loading2 = "loading2"; - var id_loadingProgressbar2 = "loadingProgressbar2"; - var id_browserWarning = "browserWarning"; - var id_volumeSlider = "volumeSlider"; - var id_btn_reloadPage = "btn_reloadPage"; - var id_btn_login = "btn_login"; - var id_btn_tryAnyway = "btn_tryAnyway"; - var id_customError = "customError"; - var id_min_firefox_version = "min-firefox-version"; - var id_min_chrome_version = "min-chrome-version"; - var id_min_opera_version = "min-opera-version"; - var id_min_safari_version = "min-safari-version"; - var id_min_msie_version = "min-msie-version"; - var id_min_msedge_version = "min-msedge-version"; - var class_loading = "loading"; - var plugins_loaded = {}; - var loadingDelay1 = 500; - var loadingDelay2 = 1000; - var errorCheckDelay = 15000; - var mediapackageError = false; - var numberOfPlugins = 0; - var translationData = null; - var loggedIn = false; - var username = "Anonymous"; - var pip = true; - var pipPos = "left"; - var askedForLogin = false; - var springSecurityLoginURL = "/j_spring_security_check"; - var springLoggedInStrCheck = "<title>Opencast – Login Page</title>"; - // shortcuts - var shortcut_playPause = "controls.playPause"; - var shortcut_seekLeft = "controls.seekLeft"; - var shortcut_seekRight = "controls.seekRight"; - var shortcut_playbackrateIncrease = "playbackrate.increase"; - var shortcut_playbackrateDecrease = "playbackrate.decrease"; - var shortcut_muteToggle = "volume.muteToggle"; - var shortcut_volDown = "volume.down"; - var shortcut_volUp = "volume.up"; - var shortcut_fullscreenEnable = "fullscreen.enable"; - var shortcut_fullscreenCancel = "fullscreen.cancel"; - var shortcut_jumpToBegin = "controls.jumpToBegin"; - var shortcut_prevChapter = "controls.prevChapter"; - var shortcut_nextChapter = "controls.nextChapter"; - var shortcut_prevFocus = "layout.focusPrev"; - var shortcut_nextFocus = "layout.focusNext"; - var shortcut_movePiP = "layout.movePiP"; - var shortcut_togglePiP = "layout.togglePiP"; - var shortcut_moveLeft = "zoom.moveLeft"; - var shortcut_moveRight = "zoom.moveRight"; - var shortcut_moveUp = "zoom.moveUp"; - var shortcut_moveDown = "zoom.moveDown"; - var shortcut_zoomIn = "zoom.in"; - var shortcut_zoomOut = "zoom.out"; + /* don't change these variables */ + var MeInfoModel; + var setCustomError = false; // just for displaying purposes! + var pluginControlsInserted = false; + var pluginVideoInserted = false; + var pluginTabInserted = false; + var pluginDescriptionInserted = false; + var pluginTimelineInserted = false; + var id_str_error = "str_error"; + var id_customError_str = "customError_str"; + var id_str_reloadPage = "str_reloadPage"; + var id_str_login = "str_login"; + var id_engage_view = "engage_view"; + var id_loading1 = "loading1"; + var id_loading2 = "loading2"; + var id_loadingProgressbar2 = "loadingProgressbar2"; + var id_browserWarning = "browserWarning"; + var id_volumeSlider = "volumeSlider"; + var id_btn_reloadPage = "btn_reloadPage"; + var id_btn_login = "btn_login"; + var id_btn_tryAnyway = "btn_tryAnyway"; + var id_customError = "customError"; + var id_min_firefox_version = "min-firefox-version"; + var id_min_chrome_version = "min-chrome-version"; + var id_min_opera_version = "min-opera-version"; + var id_min_safari_version = "min-safari-version"; + var id_min_msie_version = "min-msie-version"; + var id_min_msedge_version = "min-msedge-version"; + var class_loading = "loading"; + var plugins_loaded = {}; + var loadingDelay1 = 500; + var loadingDelay2 = 1000; + var errorCheckDelay = 15000; + var mediapackageError = false; + var numberOfPlugins = 0; + var translationData = null; + var loggedIn = false; + var username = "Anonymous"; + var pip = true; + var pipPos = "left"; + var askedForLogin = false; + var springSecurityLoginURL = "/j_spring_security_check"; + var springLoggedInStrCheck = "<title>Opencast – Login Page</title>"; + // shortcuts + var shortcut_playPause = "controls.playPause"; + var shortcut_seekLeft = "controls.seekLeft"; + var shortcut_seekRight = "controls.seekRight"; + var shortcut_playbackrateIncrease = "playbackrate.increase"; + var shortcut_playbackrateDecrease = "playbackrate.decrease"; + var shortcut_muteToggle = "volume.muteToggle"; + var shortcut_volDown = "volume.down"; + var shortcut_volUp = "volume.up"; + var shortcut_fullscreenEnable = "fullscreen.enable"; + var shortcut_fullscreenCancel = "fullscreen.cancel"; + var shortcut_jumpToBegin = "controls.jumpToBegin"; + var shortcut_prevChapter = "controls.prevChapter"; + var shortcut_nextChapter = "controls.nextChapter"; + var shortcut_prevFocus = "layout.focusPrev"; + var shortcut_nextFocus = "layout.focusNext"; + var shortcut_movePiP = "layout.movePiP"; + var shortcut_togglePiP = "layout.togglePiP"; + var shortcut_moveLeft = "zoom.moveLeft"; + var shortcut_moveRight = "zoom.moveRight"; + var shortcut_moveUp = "zoom.moveUp"; + var shortcut_moveDown = "zoom.moveDown"; + var shortcut_zoomIn = "zoom.in"; + var shortcut_zoomOut = "zoom.out"; - var basilOptions = { - namespace: "mhStorage" - }; - Basil = new window.Basil(basilOptions); + var basilOptions = { + namespace: "mhStorage" + }; + Basil = new window.Basil(basilOptions); - function browserSupported() { - if ((Basil.get("overrideBrowser") != null) && Basil.get("overrideBrowser")) { - return true; + function browserSupported() { + if ((Basil.get("overrideBrowser") != null) && Basil.get("overrideBrowser")) { + return true; + } + return (Bowser.firefox && Bowser.version >= browser_minVersion_firefox) || + (Bowser.chrome && Bowser.version >= browser_minVersion_chrome) || + (Bowser.opera && Bowser.version >= browser_minVersion_opera) || + (Bowser.safari && Bowser.version >= browser_minVersion_safari) || + (Bowser.msedge && Bowser.version >= browser_minVersion_msedge) || + (Bowser.msie && Bowser.version >= browser_minVersion_msie) || + (Bowser.mobile) || (Bowser.ios); } - return (Bowser.firefox && Bowser.version >= browser_minVersion_firefox) || - (Bowser.chrome && Bowser.version >= browser_minVersion_chrome) || - (Bowser.opera && Bowser.version >= browser_minVersion_opera) || - (Bowser.safari && Bowser.version >= browser_minVersion_safari) || - (Bowser.msedge && Bowser.version >= browser_minVersion_msedge) || - (Bowser.msie && Bowser.version >= browser_minVersion_msie) || - (Bowser.mobile) || (Bowser.ios); - } - function setMinBrowserVersions() { - $("#" + id_min_firefox_version).text(browser_minVersion_firefox); - $("#" + id_min_chrome_version).text(browser_minVersion_chrome); - $("#" + id_min_opera_version).text(browser_minVersion_opera); - $("#" + id_min_safari_version).text(browser_minVersion_safari); - $("#" + id_min_msedge_version).text(browser_minVersion_msedge); - $("#" + id_min_msie_version).text(browser_minVersion_msie); - } + function setMinBrowserVersions() { + $("#" + id_min_firefox_version).text(browser_minVersion_firefox); + $("#" + id_min_chrome_version).text(browser_minVersion_chrome); + $("#" + id_min_opera_version).text(browser_minVersion_opera); + $("#" + id_min_safari_version).text(browser_minVersion_safari); + $("#" + id_min_msedge_version).text(browser_minVersion_msedge); + $("#" + id_min_msie_version).text(browser_minVersion_msie); + } - function detectLanguage() { - return navigator.language || navigator.userLanguage || navigator.browserLanguage || navigator.systemLanguage || "en"; - } + function detectLanguage() { + return navigator.language || navigator.userLanguage || navigator.browserLanguage || navigator.systemLanguage || "en"; + } - function getDefaultLanguage(language) { - switch (language) { - case "en": return "en-US"; - case "de": return "de-DE"; - case "es": return "es-ES"; - case "fr": return "fr-FR"; - case "gl": return "gl-ES"; - case "nl": return "nl-NL"; - case "fi": return "fi-FI"; - case "it": return "it-IT"; - case "ja": return "ja-JA"; - case "tlh": return "tlh-AA"; - case "no": return "no-NO"; - case "pl": return "pl-PL"; - case "pt": return "pt-BR"; - case "ru": return "ru-RU"; - case "sv": return "sv-SE"; - case "tr": return "tr-TR"; - case "zh": return "zh-CN"; - case "el": return "el-GR"; - default: return null; - } - } + function getDefaultLanguage(language) { + switch (language) { + case "en": + return "en-US"; + case "de": + return "de-DE"; + case "es": + return "es-ES"; + case "fr": + return "fr-FR"; + case "gl": + return "gl-ES"; + case "nl": + return "nl-NL"; + case "fi": + return "fi-FI"; + case "it": + return "it-IT"; + case "ja": + return "ja-JA"; + case "tlh": + return "tlh-AA"; + case "no": + return "no-NO"; + case "pl": + return "pl-PL"; + case "pt": + return "pt-BR"; + case "ru": + return "ru-RU"; + case "sv": + return "sv-SE"; + case "tr": + return "tr-TR"; + case "zh": + return "zh-CN"; + case "el": + return "el-GR"; + default: + return null; + } + } - function initTranslate(language) { - var jsonstr = ""; - var selectedLanguage = language; - if (getDefaultLanguage(language) !== null) { - selectedLanguage = getDefaultLanguage(language); + function initTranslate(language) { + var jsonstr = ""; + var selectedLanguage = language; + if (getDefaultLanguage(language) !== null) { + selectedLanguage = getDefaultLanguage(language); + } + console.log("Controls: selecting language " + selectedLanguage); + jsonstr += "language/" + selectedLanguage + ".json"; + $.ajax({ + url: jsonstr, + dataType: "json", + success: function (data) { + if (data) { + data.value_locale = selectedLanguage; + translationData = data; + engageCore.model.set("language", selectedLanguage); + } + } + }).fail(function (msg) { + engageCore.log("No language file found for " + selectedLanguage + "."); + if (language !== getDefaultLanguage(language.replace(/\-.*/, '')) && language !== language.replace(/\-.*/, '')) { + initTranslate(language.replace(/\-.*/, '')); + } + }); } - console.log("Controls: selecting language " + selectedLanguage); - jsonstr += "language/" + selectedLanguage + ".json"; - $.ajax({ - url: jsonstr, - dataType: "json", - success: function (data) { - if (data) { - data.value_locale = selectedLanguage; - translationData = data; - engageCore.model.set("language", selectedLanguage); + + function translateCoreHTML() { + $("#" + id_str_error).html(translate("error", "Error")); + if (!setCustomError) { + $("#" + id_customError_str).html(translate("error_unknown", "An error occurred. Please reload the page.")); + setCustomError = false; } - } - }).fail(function(msg) { - engageCore.log("No language file found for " + selectedLanguage + "."); - if (language !== getDefaultLanguage(language.replace(/\-.*/, '')) && language !== language.replace(/\-.*/, '')) { - initTranslate(language.replace(/\-.*/, '')); + $("#" + id_str_reloadPage).html(translate("reloadPage", "Reload page")); + $("#" + id_str_login).html(translate("login", "Log in")); + } + + function translate(str, strIfNotFound) { + if (!str || (str.length <= 0)) { + return strIfNotFound; } - }); - } + return ((translationData != null) && (translationData[str] != undefined)) ? translationData[str] : strIfNotFound; + } + + function login() { + if (!askedForLogin) { + askedForLogin = true; + var username = "User"; + var password = "Password"; - function translateCoreHTML() { - $("#" + id_str_error).html(translate("error", "Error")); - if (!setCustomError) { - $("#" + id_customError_str).html(translate("error_unknown", "An error occurred. Please reload the page.")); - setCustomError = false; + Bootbox.dialog({ + title: translate("loginInformation", "Log in"), + message: '<form class="form-signin">' + + '<h2 class="form-signin-heading">' + translate("enterUsernamePassword", "Please enter your username and password") + '</h2>' + + '<input id="username" type="text" class="form-control form-control-custom" name="username" placeholder="' + translate("username", "Username") + '" required="true" autofocus="" />' + + '<input id="password" type="password" class="form-control form-control-custom" name="password" placeholder="' + translate("password", "Password") + '" required="true" />' + + '<label class="checkbox">' + + '<input type="checkbox" value="' + translate("rememberMe", "Remember me") + '" id="rememberMe" name="rememberMe" checked> ' + translate("rememberMe", "Remember me") + + '</label>' + + '</form>', + buttons: { + cancel: { + label: translate("cancel", "Cancel"), + className: "btn-default", + callback: function () { + askedForLogin = false; + } + }, + login: { + label: translate("login", "Log in"), + className: "btn-success", + callback: function () { + var username = $("#username").val().trim(); + var password = $("#password").val().trim(); + if ((username !== null) && (username.length > 0) && (password !== null) && (password.length > 0)) { + $.ajax({ + type: "POST", + url: springSecurityLoginURL, + data: { + "j_username": username, + "j_password": password, + "_spring_security_remember_me": $("#rememberMe").is(":checked") + } + }).done(function (msg) { + password = ""; + if (msg.indexOf(springLoggedInStrCheck) === -1) { + engageCore.trigger(events.customSuccess.getName(), translate("loginSuccessful", "Successfully logged in. Please reload the page if the page does not reload automatically.")); + $("#" + id_btn_login).hide(); + $("#" + id_btn_reloadPage).click(function (e) { + e.preventDefault(); + location.reload(); + }); + $("#" + id_btn_reloadPage).show(); + location.reload(); + } else { + engageCore.trigger(events.customError.getName(), translate("loginFailed", "Failed to log in.")); + setCustomError = true; + } + askedForLogin = false; + }).fail(function () { + password = ""; + engageCore.trigger(events.customError.getName(), translate("loginFailed", "Failed to log in.")); + setCustomError = true; + askedForLogin = false; + }); + } else { + askedForLogin = false; + } + } + } + }, + className: "usernamePassword-modal", + onEscape: function () { + askedForLogin = false; + }, + closeButton: false + }); + } } - $("#" + id_str_reloadPage).html(translate("reloadPage", "Reload page")); - $("#" + id_str_login).html(translate("login", "Log in")); - } - function translate(str, strIfNotFound) { - if (!str || (str.length <= 0)) { - return strIfNotFound; + function getLoginStatus() { + if (engageCore.model.get("infoMe")) { + if (engageCore.model.get("infoMe").loggedIn) { + loggedIn = true; + username = engageCore.model.get("infoMe").username; + } else { + loggedIn = false; + username = "Anonymous"; + } + return loggedIn ? 1 : 0; + } + return -1; } - return ((translationData != null) && (translationData[str] != undefined)) ? translationData[str] : strIfNotFound; - } - function login() { - if (!askedForLogin) { - askedForLogin = true; - var username = "User"; - var password = "Password"; + // binds configured shortcuts (see MH org config) to corresponding events + function bindShortcutsToEvents() { - Bootbox.dialog({ - title: translate("loginInformation", "Log in"), - message: '<form class="form-signin">' + - '<h2 class="form-signin-heading">' + translate("enterUsernamePassword", "Please enter your username and password") + '</h2>' + - '<input id="username" type="text" class="form-control form-control-custom" name="username" placeholder="' + translate("username", "Username") + '" required="true" autofocus="" />' + - '<input id="password" type="password" class="form-control form-control-custom" name="password" placeholder="' + translate("password", "Password") + '" required="true" />' + - '<label class="checkbox">' + - '<input type="checkbox" value="' + translate("rememberMe", "Remember me") + '" id="rememberMe" name="rememberMe" checked> ' + translate("rememberMe", "Remember me") + - '</label>' + - '</form>', - buttons: { - cancel: { - label: translate("cancel", "Cancel"), - className: "btn-default", - callback: function () { - askedForLogin = false; + // disable scrolling when pressing the space bar + $(document).keydown(function (e) { + // space = 32, backspace = 8, page up = 73, page down = 33, enter = 13 + if (((e.keyCode === 32) + || (e.keyCode === 8) + || (e.keyCode === 33) + || (e.keyCode === 34) + || (e.keyCode === 13)) + && ((e.target !== $("input#username")[0]) + && (e.target !== $("input#password")[0]) + && (e.target !== $("input#navigation_time_current")[0]))) { + return false; } - }, - login: { - label: translate("login", "Log in"), - className: "btn-success", - callback: function () { - var username = $("#username").val().trim(); - var password = $("#password").val().trim(); - if ((username !== null) && (username.length > 0) && (password !== null) && (password.length > 0)) { - $.ajax({ - type: "POST", - url: springSecurityLoginURL, - data: { - "j_username": username, - "j_password": password, - "_spring_security_remember_me": $("#rememberMe").is(":checked") - } - }).done(function (msg) { - password = ""; - if (msg.indexOf(springLoggedInStrCheck) === -1) { - engageCore.trigger(events.customSuccess.getName(), translate("loginSuccessful", "Successfully logged in. Please reload the page if the page does not reload automatically.")); - $("#" + id_btn_login).hide(); - $("#" + id_btn_reloadPage).click(function (e) { - e.preventDefault(); - location.reload(); + }); + // process hardcoded keys + $.each(MeInfoModel.get("shortcuts"), function (i, val) { + switch (val.name) { + case shortcut_seekLeft: + Mousetrap.bind(val.key, function () { + engageCore.trigger(events.seekLeft.getName()); }); - $("#" + id_btn_reloadPage).show(); - location.reload(); - } else { - engageCore.trigger(events.customError.getName(), translate("loginFailed", "Failed to log in.")); - setCustomError = true; - } - askedForLogin = false; - }).fail(function () { - password = ""; - engageCore.trigger(events.customError.getName(), translate("loginFailed", "Failed to log in.")); - setCustomError = true; - askedForLogin = false; - }); - } else { - askedForLogin = false; - } + break; + case shortcut_seekRight: + Mousetrap.bind(val.key, function () { + engageCore.trigger(events.seekRight.getName()); + }); + break; + case shortcut_playbackrateIncrease: + Mousetrap.bind(val.key, function () { + engageCore.trigger(events.playbackRateIncrease.getName()); + }); + break; + case shortcut_playbackrateDecrease: + Mousetrap.bind(val.key, function () { + engageCore.trigger(events.playbackRateDecrease.getName()); + }); + break; + case shortcut_nextChapter: + Mousetrap.bind(val.key, function () { + engageCore.trigger(events.nextChapter.getName()); + }); + break; + case shortcut_fullscreenEnable: + Mousetrap.bind(val.key, function () { + engageCore.trigger(events.fullscreenEnable.getName()); + }); + break; + case shortcut_fullscreenCancel: + Mousetrap.bind(val.key, function () { + engageCore.trigger(events.fullscreenCancel.getName()); + }); + break; + case shortcut_jumpToBegin: + Mousetrap.bind(val.key, function () { + engageCore.trigger(events.seek.getName(), 0); + }); + break; + case shortcut_prevChapter: + Mousetrap.bind(val.key, function () { + engageCore.trigger(events.previousChapter.getName()); + }); + break; + case shortcut_playPause: + Mousetrap.bind(val.key, function () { + engageCore.trigger(events.playPause.getName()); + }); + break; + case shortcut_muteToggle: + Mousetrap.bind(val.key, function () { + engageCore.trigger(events.muteToggle.getName()); + }); + break; + case shortcut_volDown: + Mousetrap.bind(val.key, function () { + engageCore.trigger(events.volumeDown.getName()); + }); + break; + case shortcut_volUp: + Mousetrap.bind(val.key, function () { + engageCore.trigger(events.volumeUp.getName()); + }); + break; + case shortcut_nextFocus: + Mousetrap.bind(val.key, function () { + engageCore.trigger(events.focusVideo.getName(), "focus.next"); + }); + break; + case shortcut_prevFocus: + Mousetrap.bind(val.key, function () { + engageCore.trigger(events.focusVideo.getName(), "focus.prev"); + }); + break; + case shortcut_movePiP: + Mousetrap.bind(val.key, function () { + if (pip) { + if (pipPos === "left") { + pipPos = "right"; + } else { + pipPos = "left"; + } + engageCore.trigger(events.movePiP.getName(), pipPos); + } + }); + break; + case shortcut_togglePiP: + Mousetrap.bind(val.key, function () { + pip = !pip; + engageCore.trigger(events.togglePiP.getName(), pip); + }); + break; + case shortcut_moveLeft: + Mousetrap.bind(val.key, function () { + engageCore.trigger(events.moveHorizontal.getName(), zoom_wasd_step_size); + }); + break; + case shortcut_moveRight: + Mousetrap.bind(val.key, function () { + engageCore.trigger(events.moveHorizontal.getName(), -zoom_wasd_step_size); + }); + break; + case shortcut_moveUp: + Mousetrap.bind(val.key, function () { + engageCore.trigger(events.moveVertical.getName(), zoom_wasd_step_size); + }); + break; + case shortcut_moveDown: + Mousetrap.bind(val.key, function () { + engageCore.trigger(events.moveVertical.getName(), -zoom_wasd_step_size); + }); + break; + case shortcut_zoomIn: + Mousetrap.bind(val.key, function () { + engageCore.trigger(events.zoomIn.getName(), true); + }); + break; + case shortcut_zoomOut: + Mousetrap.bind(val.key, function () { + engageCore.trigger(events.zoomOut.getName(), true); + }); + break; + default: + break; } - } - }, - className: "usernamePassword-modal", - onEscape: function () { - askedForLogin = false; - }, - closeButton: false - }); + }); } - } - function getLoginStatus() { - if (engageCore.model.get("infoMe")) { - if (engageCore.model.get("infoMe").loggedIn) { - loggedIn = true; - username = engageCore.model.get("infoMe").username; - } else { - loggedIn = false; - username = "Anonymous"; - } - return loggedIn ? 1 : 0; + function checkAllPluginsloaded() { + var all_plugins_loaded = true; + $.each(plugins_loaded, function (plugin_index, plugin_value) { + if (plugin_value === false) { + all_plugins_loaded = false; + } + }); + return all_plugins_loaded; } - return -1; - } - // binds configured shortcuts (see MH org config) to corresponding events - function bindShortcutsToEvents() { + function loadTemplate(plugin, plugin_name, plugin_path) { + if (plugin.template !== "none") { + // load template asynchronously + $.get("engage/theodul/" + plugin_path + plugin.template, function (template) { + var template_data = {}; + // add template data if not undefined + if (plugin.template_data !== undefined) { + template_data = plugin.template_data; + } + // add full plugin path to the template data + template_data.plugin_path = "engage/theodul/" + plugin_path; + // process the template using underscore and set it in the plugin obj + var _template = _.template(template); + plugin.templateProcessed = _template(template_data); + plugin.template = template; + plugin.pluginPath = "engage/theodul/" + plugin_path; + if (plugin.insertIntoDOM) { + // load the compiled HTML into the component + engageCore.pluginView.insertPlugin(plugin, plugin_name, translationData); + if (engageCore.model.desktop) { + if (engageCore.pluginView.isControlsPlugin(plugin.type)) { + pluginControlsInserted = true; + } + if (engageCore.pluginView.isVideoPlugin(plugin.type)) { + pluginVideoInserted = true; + } + if (engageCore.pluginView.isTabPlugin(plugin.type)) { + pluginTabInserted = true; + } + if (engageCore.pluginView.isDescriptionPlugin(plugin.type)) { + pluginDescriptionInserted = true; + } + if (engageCore.pluginView.isTimelinePlugin(plugin.type)) { + pluginTimelineInserted = true; + } + } + } + plugins_loaded[plugin_name] = true; + // check if all plugins are ready + if (checkAllPluginsloaded()) { + engageCore.pluginView.allPluginsLoaded(); + engageCore.trigger(events.plugin_load_done.getName()); + } + }); + } else { + plugins_loaded[plugin_name] = true; + // check if all plugins are ready + if (checkAllPluginsloaded()) { + engageCore.pluginView.allPluginsLoaded(); + engageCore.trigger(events.plugin_load_done.getName()); + } + } + } - // disable scrolling when pressing the space bar - $(document).keydown(function (e) { - // space = 32, backspace = 8, page up = 73, page down = 33, enter = 13 - if (((e.keyCode === 32) - || (e.keyCode === 8) - || (e.keyCode === 33) - || (e.keyCode === 34) - || (e.keyCode === 13)) - && ((e.target !== $("input#username")[0]) - && (e.target !== $("input#password")[0]) - && (e.target !== $("input#navigation_time_current")[0]))) { - return false; - } - }); - // process hardcoded keys - $.each(MeInfoModel.get("shortcuts"), function (i, val) { - switch (val.name) { - case shortcut_seekLeft: - Mousetrap.bind(val.key, function () { - engageCore.trigger(events.seekLeft.getName()); - }); - break; - case shortcut_seekRight: - Mousetrap.bind(val.key, function () { - engageCore.trigger(events.seekRight.getName()); - }); - break; - case shortcut_playbackrateIncrease: - Mousetrap.bind(val.key, function () { - engageCore.trigger(events.playbackRateIncrease.getName()); - }); - break; - case shortcut_playbackrateDecrease: - Mousetrap.bind(val.key, function () { - engageCore.trigger(events.playbackRateDecrease.getName()); - }); - break; - case shortcut_nextChapter: - Mousetrap.bind(val.key, function () { - engageCore.trigger(events.nextChapter.getName()); - }); - break; - case shortcut_fullscreenEnable: - Mousetrap.bind(val.key, function () { - engageCore.trigger(events.fullscreenEnable.getName()); - }); - break; - case shortcut_fullscreenCancel: - Mousetrap.bind(val.key, function () { - engageCore.trigger(events.fullscreenCancel.getName()); - }); - break; - case shortcut_jumpToBegin: - Mousetrap.bind(val.key, function () { - engageCore.trigger(events.seek.getName(), 0); - }); - break; - case shortcut_prevChapter: - Mousetrap.bind(val.key, function () { - engageCore.trigger(events.previousChapter.getName()); - }); - break; - case shortcut_playPause: - Mousetrap.bind(val.key, function () { - engageCore.trigger(events.playPause.getName()); - }); - break; - case shortcut_muteToggle: - Mousetrap.bind(val.key, function () { - engageCore.trigger(events.muteToggle.getName()); - }); - break; - case shortcut_volDown: - Mousetrap.bind(val.key, function () { - engageCore.trigger(events.volumeDown.getName()); - }); - break; - case shortcut_volUp: - Mousetrap.bind(val.key, function () { - engageCore.trigger(events.volumeUp.getName()); - }); - break; - case shortcut_nextFocus: - Mousetrap.bind(val.key, function () { - engageCore.trigger(events.focusVideo.getName(), "focus.next"); - }); - break; - case shortcut_prevFocus: - Mousetrap.bind(val.key, function () { - engageCore.trigger(events.focusVideo.getName(), "focus.prev"); - }); - break; - case shortcut_movePiP: - Mousetrap.bind(val.key, function () { - if (pip) { - if (pipPos === "left") { - pipPos = "right"; - } else { - pipPos = "left"; + function loadPlugin(plugin_path, plugin_name) { + require([plugin_path + "main"], function (plugin) { + // load styles in link tags via jquery + if ($.isArray(plugin.styles)) { + $.each(plugin.styles, function (style_index, style_path) { + if (style_path !== "") { + var link = $("<link>"); + link.attr({ + type: "text/css", + rel: "stylesheet", + href: "engage/theodul/" + plugin_path + style_path + }); + $("head").append(link); + } + }); + } else { + if (plugin.styles !== "") { + var link = $("<link>"); + link.attr({ + type: "text/css", + rel: "stylesheet", + href: "engage/theodul/" + plugin_path + plugin.styles + }); + $("head").append(link); } - engageCore.trigger(events.movePiP.getName(), pipPos); } - }); - break; - case shortcut_togglePiP: - Mousetrap.bind(val.key, function () { - pip = !pip; - engageCore.trigger(events.togglePiP.getName(), pip); - }); - break; - case shortcut_moveLeft: - Mousetrap.bind(val.key, function () { - engageCore.trigger(events.moveHorizontal.getName(), zoom_wasd_step_size); - }); - break; - case shortcut_moveRight: - Mousetrap.bind(val.key, function () { - engageCore.trigger(events.moveHorizontal.getName(), -zoom_wasd_step_size); - }); - break; - case shortcut_moveUp: - Mousetrap.bind(val.key, function () { - engageCore.trigger(events.moveVertical.getName(), zoom_wasd_step_size); - }); - break; - case shortcut_moveDown: - Mousetrap.bind(val.key, function () { - engageCore.trigger(events.moveVertical.getName(), -zoom_wasd_step_size); - }); - break; - case shortcut_zoomIn: - Mousetrap.bind(val.key, function () { - engageCore.trigger(events.zoomIn.getName(), true); - }); - break; - case shortcut_zoomOut: - Mousetrap.bind(val.key, function () { - engageCore.trigger(events.zoomOut.getName(), true); - }); - break; - default: - break; - } - }); - } - function checkAllPluginsloaded() { - var all_plugins_loaded = true; - $.each(plugins_loaded, function (plugin_index, plugin_value) { - if (plugin_value === false) { - all_plugins_loaded = false; - } - }); - return all_plugins_loaded; - } + // we have to change that in the future... this is only for loading a second controls template to put above the video if the player controls are below it + if (plugin.template_topIfBottom && plugin.template_topIfBottom !== "none") { + // load template asynchronously + $.get("engage/theodul/" + plugin_path + plugin.template_topIfBottom, function (template) { + var template_data = {}; + // add template data if not undefined + if (plugin.template_data_topIfBottom !== undefined) { + template_data = plugin.template_data_topIfBottom; + } + // add full plugin path to the template data + template_data.plugin_path = "engage/theodul/" + plugin_path; + // process the template using underscore and set it in the plugin obj + var _template = _.template(template); + plugin.templateProcessed_topIfBottom = _template(template_data); + plugin.template_topIfBottom = template; + plugin.pluginPath_topIfBottom = "engage/theodul/" + plugin_path; + loadTemplate(plugin, plugin_name, plugin_path); + }); + } else { + loadTemplate(plugin, plugin_name, plugin_path); + } + }); + } - function loadTemplate(plugin, plugin_name, plugin_path) { - if (plugin.template !== "none") { - // load template asynchronously - $.get("engage/theodul/" + plugin_path + plugin.template, function (template) { - var template_data = {}; - // add template data if not undefined - if (plugin.template_data !== undefined) { - template_data = plugin.template_data; + function throwEvents() { + if (engageCore.model.get("autoplay")) { + engageCore.trigger(events.autoplay.getName()); + } + if (engageCore.model.get("time")) { + engageCore.trigger(events.initialSeek.getName(), engageCore.model.get("time")); } - // add full plugin path to the template data - template_data.plugin_path = "engage/theodul/" + plugin_path; - // process the template using underscore and set it in the plugin obj - var _template = _.template(template); - plugin.templateProcessed = _template(template_data); - plugin.template = template; - plugin.pluginPath = "engage/theodul/" + plugin_path; - if (plugin.insertIntoDOM) { - // load the compiled HTML into the component - engageCore.pluginView.insertPlugin(plugin, plugin_name, translationData); - if (engageCore.model.desktop) { - if (engageCore.pluginView.isControlsPlugin(plugin.type)) { - pluginControlsInserted = true; + } + + var EngageCore = Backbone.View.extend({ + el: $("#" + id_engage_view), + Event: EngageEvent, + // bind a key event as a string to given event + bindKeyToEvent: function (shortcuts, event) { + // only for EngageEvent objects + if (event instanceof EngageEvent) { + Mousetrap.bind(shortcut, function () { + engageCore.trigger(event); + }); + } + }, + on: function (event, handler, context) { + if (event instanceof EngageEvent) { + this.dispatcher.on(event.getName(), handler, context); + } else { + this.dispatcher.on(event, handler, context); } - if (engageCore.pluginView.isVideoPlugin(plugin.type)) { - pluginVideoInserted = true; + }, + trigger: function (event, data) { + if (event instanceof EngageEvent) { + this.dispatcher.trigger(event.getName(), data); + } else { + this.dispatcher.trigger(event, data); } - if (engageCore.pluginView.isTabPlugin(plugin.type)) { - pluginTabInserted = true; + }, + log: function (data) { + if (this.model.get("isDebug") && window.console) { + console.log(data); } - if (engageCore.pluginView.isDescriptionPlugin(plugin.type)) { - pluginDescriptionInserted = true; + }, + group: function (block) { + if (this.model.get("isDebug") && window.console) { + console.group(block); } - if (engageCore.pluginView.isTimelinePlugin(plugin.type)) { - pluginTimelineInserted = true; + }, + groupEnd: function () { + if (this.model.get("isDebug") && window.console) { + console.groupEnd(); } - } - } - plugins_loaded[plugin_name] = true; - // check if all plugins are ready - if (checkAllPluginsloaded()) { - engageCore.pluginView.allPluginsLoaded(); - engageCore.trigger(events.plugin_load_done.getName()); - } - }); - } else { - plugins_loaded[plugin_name] = true; - // check if all plugins are ready - if (checkAllPluginsloaded()) { - engageCore.pluginView.allPluginsLoaded(); - engageCore.trigger(events.plugin_load_done.getName()); - } - } - } - - function loadPlugin(plugin_path, plugin_name) { - require([plugin_path + "main"], function (plugin) { - // load styles in link tags via jquery - if ($.isArray(plugin.styles)) { - $.each(plugin.styles, function (style_index, style_path) { - if (style_path !== "") { - var link = $("<link>"); - link.attr({ - type: "text/css", - rel: "stylesheet", - href: "engage/theodul/" + plugin_path + style_path + }, + getPluginPath: function (pluginName) { + var evaluated_plugin_path = ""; + var pluginsInfos = engageCore.model.get("pluginsInfo"); + if (pluginsInfos) { + var pluginList = pluginsInfos.get("pluginlist"); + if (pluginList && pluginList.plugins !== undefined) { + var plugins = pluginList.plugins; + if ($.isArray(plugins)) { + $.each(plugins, function (index, value) { + if (value["name"] === pluginName) { + evaluated_plugin_path = "../../plugin/" + value["static-path"] + "/"; + } + }); + } else { + evaluated_plugin_path = "../../plugin/" + plugins["static-path"] + "/"; + } + } + } + return evaluated_plugin_path; + }, + loadInfoMeModel: function (func) { + require(["engage/models/meInfo"], function (me) { + MeInfoModel = new me(); + // wait that me infos are loaded + var intv = window.setInterval(function () { + if (MeInfoModel.ready()) { + window.clearInterval(intv); + if (func && (typeof func === "function")) { + func(); + } + } + }, 15); }); - $("head").append(link); - } - }); - } else { - if (plugin.styles !== "") { - var link = $("<link>"); - link.attr({ - type: "text/css", - rel: "stylesheet", - href: "engage/theodul/" + plugin_path + plugin.styles - }); - $("head").append(link); - } - } - - // we have to change that in the future... this is only for loading a second controls template to put above the video if the player controls are below it - if (plugin.template_topIfBottom && plugin.template_topIfBottom !== "none") { - // load template asynchronously - $.get("engage/theodul/" + plugin_path + plugin.template_topIfBottom, function (template) { - var template_data = {}; - // add template data if not undefined - if (plugin.template_data_topIfBottom !== undefined) { - template_data = plugin.template_data_topIfBottom; - } - // add full plugin path to the template data - template_data.plugin_path = "engage/theodul/" + plugin_path; - // process the template using underscore and set it in the plugin obj - var _template = _.template(template); - plugin.templateProcessed_topIfBottom = _template(template_data); - plugin.template_topIfBottom = template; - plugin.pluginPath_topIfBottom = "engage/theodul/" + plugin_path; - loadTemplate(plugin, plugin_name, plugin_path); - }); - } else { - loadTemplate(plugin, plugin_name, plugin_path); - } - }); - } - - function throwEvents() { - if (engageCore.model.get("autoplay")) { - engageCore.trigger(events.autoplay.getName()); - } - if (engageCore.model.get("time")) { - engageCore.trigger(events.initialSeek.getName(), engageCore.model.get("time")); - } - } + }, + loadCoreUI: function () { + // switch view template and css rules for current player mode + // link tag for css file + var cssLinkTag = $("<link>"); + var cssAttr = { + type: "text/css", + rel: "stylesheet" + }; + engageCore.controls_top = MeInfoModel.getPositionControls() === "top"; // bottom else + engageCore.log("Core: Position of the controls is " + (engageCore.controls_top ? "top" : "bottom")); - var EngageCore = Backbone.View.extend({ - el: $("#" + id_engage_view), - Event: EngageEvent, - // bind a key event as a string to given event - bindKeyToEvent: function (shortcuts, event) { - // only for EngageEvent objects - if (event instanceof EngageEvent) { - Mousetrap.bind(shortcut, function () { - engageCore.trigger(event); - }); - } - }, - on: function (event, handler, context) { - if (event instanceof EngageEvent) { - this.dispatcher.on(event.getName(), handler, context); - } else { - this.dispatcher.on(event, handler, context); - } - }, - trigger: function (event, data) { - if (event instanceof EngageEvent) { - this.dispatcher.trigger(event.getName(), data); - } else { - this.dispatcher.trigger(event, data); - } - }, - log: function (data) { - if (this.model.get("isDebug") && window.console) { - console.log(data); - } - }, - group: function (block) { - if (this.model.get("isDebug") && window.console) { - console.group(block); - } - }, - groupEnd: function () { - if (this.model.get("isDebug") && window.console) { - console.groupEnd(); - } - }, - getPluginPath: function (pluginName) { - var evaluated_plugin_path = ""; - var pluginsInfos = engageCore.model.get("pluginsInfo"); - if (pluginsInfos) { - var pluginList = pluginsInfos.get("pluginlist"); - if (pluginList && pluginList.plugins !== undefined) { - var plugins = pluginList.plugins; - if ($.isArray(plugins)) { - $.each(plugins, function (index, value) { - if (value["name"] === pluginName) { - evaluated_plugin_path = "../../plugin/" + value["static-path"] + "/"; - } - }); - } else { - evaluated_plugin_path = "../../plugin/" + plugins["static-path"] + "/"; - } - } - } - return evaluated_plugin_path; - }, - loadInfoMeModel: function (func) { - require(["engage/models/meInfo"], function (me) { - MeInfoModel = new me(); - // wait that me infos are loaded - var intv = window.setInterval(function () { - if (MeInfoModel.ready()) { - window.clearInterval(intv); - if (func && (typeof func === "function")) { - func(); + // template obj + var core_template = "none"; + // path to the require module with the view logic + var view_logic_path = ""; + switch (engageCore.model.get("mode")) { + case "embed": + cssAttr.href = "css/core_embed_style.css"; + core_template = "templates/core_embed.html"; + view_logic_path = "engage/views/embed"; + engageCore.model.embed = true; + break; + case "mobile": + cssAttr.href = "css/core_mobile_style.css"; + core_template = "templates/core_mobile.html"; + view_logic_path = "engage/views/mobile"; + engageCore.model.mobile = true; + break; + case "desktop": + default: + cssAttr.href = engageCore.controls_top ? "css/core_desktop_style_top.css" : "css/core_desktop_style_bottom.css"; + core_template = engageCore.controls_top ? "templates/core_desktop_top.html" : "templates/core_desktop_bottom.html"; + view_logic_path = "engage/views/desktop"; + engageCore.model.desktop = true; + break; } - } - }, 15); - }); - }, - loadCoreUI: function () { - // switch view template and css rules for current player mode - // link tag for css file - var cssLinkTag = $("<link>"); - var cssAttr = { - type: "text/css", - rel: "stylesheet" - }; - engageCore.controls_top = MeInfoModel.getPositionControls() === "top"; // bottom else - engageCore.log("Core: Position of the controls is " + (engageCore.controls_top ? "top" : "bottom")); + cssLinkTag.attr(cssAttr); + // add css to DOM + $("head").append(cssLinkTag); + // load js view logic via require, see files in views/ + require([view_logic_path], function (pluginView) { + // link view logic to the core + engageCore.pluginView = pluginView; + engageCore.loadCoreTemplate(core_template); + }); + }, + loadCoreTemplate: function (core_template) { + // get core template + $.get(core_template, function (template) { + // set template, render it and add it to DOM + engageCore.template = template; + $(engageCore.el).html(_.template(template)).trigger("create"); // variables do not work in here! + // run init function of the view + engageCore.pluginView.initView(); + if (engageCore.model.get("pluginsInfo") && engageCore.model.browserSupported) { + engageCore.loadPlugins(); + bindShortcutsToEvents(); // bind configured shortcuts to events + } else { + engageCore.trigger(events.plugin_load_done.getName()); + } + }); + }, + loadPlugins: function () { + engageCore.model.get("pluginsInfo").fetch({ + success: function (pluginInfos) { + if ((pluginInfos.get("pluginlist").plugins !== undefined) && pluginInfos.get("pluginlist")) { + numberOfPlugins = pluginInfos.get("pluginlist").plugins.length; + if ($.isArray(pluginInfos.get("pluginlist").plugins)) { + $.each(pluginInfos.get("pluginlist").plugins, function (index, value) { + var plugin_name = value["name"]; + plugins_loaded[plugin_name] = false; + }); + $.each(pluginInfos.get("pluginlist").plugins, function (index, value) { + var plugin_name = value["name"]; + engageCore.log("Core: Loading plugin '" + plugin_name + "' from '" + ("../../../plugin/" + value["static-path"] + "/") + "'..."); + loadPlugin("../../plugin/" + value["static-path"] + "/", plugin_name); + }); + } else { + var plugin_name = pluginInfos.get("pluginlist").plugins["name"]; + plugins_loaded[plugin_name] = false; + engageCore.log("Core: Loading plugin '" + plugin_name + "' from '" + ("../../../plugin/" + pluginInfos.get("pluginlist").plugins["static-path"] + "/") + "'..."); + loadPlugin("../../plugin/" + pluginInfos.get("pluginlist").plugins["static-path"] + "/", plugin_name); + } + } + } + }); + }, + initialize: function () { + $("." + class_loading).show(); + $("#" + id_loading1).show(); + initTranslate(detectLanguage()); + setMinBrowserVersions(); - // template obj - var core_template = "none"; - // path to the require module with the view logic - var view_logic_path = ""; - switch (engageCore.model.get("mode")) { - case "embed": - cssAttr.href = "css/core_embed_style.css"; - core_template = "templates/core_embed.html"; - view_logic_path = "engage/views/embed"; - engageCore.model.embed = true; - break; - case "mobile": - cssAttr.href = "css/core_mobile_style.css"; - core_template = "templates/core_mobile.html"; - view_logic_path = "engage/views/mobile"; - engageCore.model.mobile = true; - break; - case "desktop": - default: - cssAttr.href = engageCore.controls_top ? "css/core_desktop_style_top.css" : "css/core_desktop_style_bottom.css"; - core_template = engageCore.controls_top ? "templates/core_desktop_top.html" : "templates/core_desktop_bottom.html"; - view_logic_path = "engage/views/desktop"; - engageCore.model.desktop = true; - break; - } - cssLinkTag.attr(cssAttr); - // add css to DOM - $("head").append(cssLinkTag); - // load js view logic via require, see files in views/ - require([view_logic_path], function (pluginView) { - // link view logic to the core - engageCore.pluginView = pluginView; - engageCore.loadCoreTemplate(core_template); - }); - }, - loadCoreTemplate: function (core_template) { - // get core template - $.get(core_template, function (template) { - // set template, render it and add it to DOM - engageCore.template = template; - $(engageCore.el).html(_.template(template)).trigger("create"); // variables do not work in here! - // run init function of the view - engageCore.pluginView.initView(); - if (engageCore.model.get("pluginsInfo") && engageCore.model.browserSupported) { - engageCore.loadPlugins(); - bindShortcutsToEvents(); // bind configured shortcuts to events - } else { - engageCore.trigger(events.plugin_load_done.getName()); - } - }); - }, - loadPlugins: function () { - engageCore.model.get("pluginsInfo").fetch({ - success: function (pluginInfos) { - if ((pluginInfos.get("pluginlist").plugins !== undefined) && pluginInfos.get("pluginlist")) { - numberOfPlugins = pluginInfos.get("pluginlist").plugins.length; - if ($.isArray(pluginInfos.get("pluginlist").plugins)) { - $.each(pluginInfos.get("pluginlist").plugins, function (index, value) { - var plugin_name = value["name"]; - plugins_loaded[plugin_name] = false; - }); - $.each(pluginInfos.get("pluginlist").plugins, function (index, value) { - var plugin_name = value["name"]; - engageCore.log("Core: Loading plugin '" + plugin_name + "' from '" + ("../../../plugin/" + value["static-path"] + "/") + "'..."); - loadPlugin("../../plugin/" + value["static-path"] + "/", plugin_name); - }); - } else { - var plugin_name = pluginInfos.get("pluginlist").plugins["name"]; - plugins_loaded[plugin_name] = false; - engageCore.log("Core: Loading plugin '" + plugin_name + "' from '" + ("../../../plugin/" + pluginInfos.get("pluginlist").plugins["static-path"] + "/") + "'..."); - loadPlugin("../../plugin/" + pluginInfos.get("pluginlist").plugins["static-path"] + "/", plugin_name); - } - } - } - }); - }, - initialize: function () { - $("." + class_loading).show(); - $("#" + id_loading1).show(); - initTranslate(detectLanguage()); - setMinBrowserVersions(); - // the main core is our global event system - this.dispatcher = _.clone(Backbone.Events); - // link to the engage model - this.model = new EngageModel(); - // listen to all events - this.dispatcher.on("all", function (name) { - if (engageCore.model.get("isEventDebug") && window.console) { - console.log("[Core:Event] '" + name + "'"); - } - }); - this.model.browserSupported = browserSupported(); - this.model.desktop = false; - this.model.embed = false; - this.model.mobile = false; - // core init event - this.dispatcher.on(events.coreInit.getName(), function () { - engageCore.loadInfoMeModel(engageCore.loadCoreUI); - }); - // load plugins done, hide loading and show content - this.dispatcher.on(events.mediaPackageModelError.getName(), function (str) { - mediapackageError = true; - $("." + class_loading).hide().detach(); - $("#" + id_engage_view).hide().detach(); - $("#" + id_btn_reloadPage).hide(); - $("#" + id_customError_str).html(str); - setCustomError = true; - if (getLoginStatus() === 0) { - $("#" + id_btn_login).click(login); - $("#" + id_customError + ", #" + id_btn_login).show(); - } else { - // TODO: Logged in as... - $("#" + id_btn_login).hide(); - } - }); - // load plugins done, hide loading and show content - this.dispatcher.on(events.plugin_load_done.getName(), function () { - if (engageCore.model.desktop) { - if (!pluginControlsInserted) { - engageCore.log("Core: No controls plugin inserted. Removing the container."); - engageCore.pluginView.removeControls(); - } - if (!pluginVideoInserted) { - engageCore.log("Core: No video plugin inserted. Removing the container."); - engageCore.pluginView.removeVideo(); - } - if (!pluginTabInserted) { - engageCore.log("Core: No tab plugin inserted. Removing the container."); - engageCore.pluginView.removeTab(); - } - if (!pluginDescriptionInserted) { - engageCore.log("Core: No description plugin inserted. Removing the container."); - engageCore.pluginView.removeDescription(); - } - if (!pluginTimelineInserted) { - engageCore.log("Core: No timeline plugin inserted. Removing the container."); - engageCore.pluginView.removeTimeline(); - } - } + // the main core is our global event system + this.dispatcher = _.clone(Backbone.Events); + // link to the engage model + this.model = new EngageModel(); + // listen to all events + this.dispatcher.on("all", function (name) { + if (engageCore.model.get("isEventDebug") && window.console) { + console.log("[Core:Event] '" + name + "'"); + } + }); + this.model.browserSupported = browserSupported(); + this.model.desktop = false; + this.model.embed = false; + this.model.mobile = false; + // core init event + this.dispatcher.on(events.coreInit.getName(), function () { + engageCore.loadInfoMeModel(engageCore.loadCoreUI); + }); + // load plugins done, hide loading and show content + this.dispatcher.on(events.mediaPackageModelError.getName(), function (str) { + mediapackageError = true; + $("." + class_loading).hide().detach(); + $("#" + id_engage_view).hide().detach(); + $("#" + id_btn_reloadPage).hide(); + $("#" + id_customError_str).html(str); + setCustomError = true; + if (getLoginStatus() === 0) { + $("#" + id_btn_login).click(login); + $("#" + id_customError + ", #" + id_btn_login).show(); + } else { + // TODO: Logged in as... + $("#" + id_btn_login).hide(); + } + }); + // load plugins done, hide loading and show content + this.dispatcher.on(events.plugin_load_done.getName(), function () { + if (engageCore.model.desktop) { + if (!pluginControlsInserted) { + engageCore.log("Core: No controls plugin inserted. Removing the container."); + engageCore.pluginView.removeControls(); + } + if (!pluginVideoInserted) { + engageCore.log("Core: No video plugin inserted. Removing the container."); + engageCore.pluginView.removeVideo(); + } + if (!pluginTabInserted) { + engageCore.log("Core: No tab plugin inserted. Removing the container."); + engageCore.pluginView.removeTab(); + } + if (!pluginDescriptionInserted) { + engageCore.log("Core: No description plugin inserted. Removing the container."); + engageCore.pluginView.removeDescription(); + } + if (!pluginTimelineInserted) { + engageCore.log("Core: No timeline plugin inserted. Removing the container."); + engageCore.pluginView.removeTimeline(); + } + } - $("#" + id_loading1).hide().detach(); - $("#" + id_loading2).show(); - window.setTimeout(function () { - $("#" + id_loadingProgressbar2).css("width", "100%"); - window.setTimeout(function () { - $("." + class_loading).hide().detach(); - if (engageCore.model.browserSupported) { - $("#" + id_browserWarning).hide().detach(); - $("#" + id_engage_view).show(); - translateCoreHTML(); - if (engageCore.model.desktop) { + $("#" + id_loading1).hide().detach(); + $("#" + id_loading2).show(); window.setTimeout(function () { - if ($("#" + id_volumeSlider).html() === undefined) { - $("#" + id_btn_reloadPage).click(function (e) { - e.preventDefault(); - location.reload(); - }); - $("#" + id_engage_view).hide().detach(); - $("body").css("min-width", ""); - $("#" + id_customError).show(); - } else { - $("#" + id_customError + ", #" + id_btn_login).hide().detach(); - throwEvents(); - } - }, errorCheckDelay); - } - // TODO: Error/loading checks for embed and mobile - } else { - $("#" + id_engage_view + ", #" + id_customError).hide().detach(); - $("body").css("min-width", ""); - $("#" + id_browserWarning).show(); - $("#" + id_btn_tryAnyway).click(function (e) { - e.preventDefault(); - window.location.href = window.location.href + "&browser=all"; - }); - } - }, loadingDelay2); - }, loadingDelay1); - }); + $("#" + id_loadingProgressbar2).css("width", "100%"); + window.setTimeout(function () { + $("." + class_loading).hide().detach(); + if (engageCore.model.browserSupported) { + $("#" + id_browserWarning).hide().detach(); + $("#" + id_engage_view).show(); + translateCoreHTML(); + if (engageCore.model.desktop) { + window.setTimeout(function () { + if ($("#" + id_volumeSlider).html() === undefined) { + $("#" + id_btn_reloadPage).click(function (e) { + e.preventDefault(); + location.reload(); + }); + $("#" + id_engage_view).hide().detach(); + $("body").css("min-width", ""); + $("#" + id_customError).show(); + } else { + $("#" + id_customError + ", #" + id_btn_login).hide().detach(); + throwEvents(); + } + }, errorCheckDelay); + } + // TODO: Error/loading checks for embed and mobile + } else { + $("#" + id_engage_view + ", #" + id_customError).hide().detach(); + $("body").css("min-width", ""); + $("#" + id_browserWarning).show(); + $("#" + id_btn_tryAnyway).click(function (e) { + e.preventDefault(); + window.location.href = window.location.href + "&browser=all"; + }); + } + }, loadingDelay2); + }, loadingDelay1); + }); - this.dispatcher.on(events.movePiP.getName(), function (pos) { - pipPos = pos; - }); - this.dispatcher.on(events.togglePiP.getName(), function (status) { - pip = status; - }); - } - }); + this.dispatcher.on(events.movePiP.getName(), function (pos) { + pipPos = pos; + }); + this.dispatcher.on(events.togglePiP.getName(), function (status) { + pip = status; + }); + } + }); - var engageCore = new EngageCore(); - engageCore.trigger(events.coreInit.getName()); - return engageCore; + var engageCore = new EngageCore(); + engageCore.trigger(events.coreInit.getName()); + return engageCore; }); diff --git a/player/js/engage_init.js b/player/js/engage_init.js index 368a18473f987b7ff93553762c0d5f682f0cc273..41490fe3dcdd1dad839c936f4243ac074de7df10 100644 --- a/player/js/engage_init.js +++ b/player/js/engage_init.js @@ -1,7 +1,7 @@ /* global require.js config */ requirejs.config({ baseUrl: "js/lib", - waitSeconds: 50, + waitSeconds: 30, paths: { engage: "../engage", plugins: "../plugin" @@ -38,6 +38,18 @@ requirejs.config({ }); var PLUGIN_PATH = "../../plugin/"; -var opencastlink = "http://localhost:8080"; + +// Get opencast url +var query = window.location.search.substring(1); +var vars = query.split("&"); +var opencastlink = ""; +for (var i = 0; i < vars.length; i++) { + var pair = vars[i].split("="); + if (pair[0] == "ocurl") { + opencastlink = decodeURIComponent(pair[1]); + break; + } +} + // start core logic require(["engage/core"]); diff --git a/player/plugin/controls/main.js b/player/plugin/controls/main.js index 911ea8842f1b72086daee3a9c48fa13bec820080..e3cbd2816bddd944f7a492ecaa905cfd8482b762 100644 --- a/player/plugin/controls/main.js +++ b/player/plugin/controls/main.js @@ -28,8 +28,6 @@ define(['require', 'jquery', 'underscore', 'backbone', 'basil', 'bootbox', 'enga var PLUGIN_TYPE = 'engage_controls'; var PLUGIN_VERSION = '1.0'; var PLUGIN_TEMPLATE_DESKTOP = Engage.controls_top ? 'templates/desktop_top.html' : 'templates/desktop_bottom.html'; - // provide this additional template if the controls are below the video to have content above the video - // var PLUGIN_TEMPLATE_DESKTOP_TOP_IFBOTTOM = Engage.controls_top ? 'none' : 'templates/desktop_top_ifbottom.html'; // Delete content above the video var PLUGIN_TEMPLATE_DESKTOP_TOP_IFBOTTOM = 'none'; var PLUGIN_TEMPLATE_EMBED = 'templates/embed.html'; diff --git a/player/plugin/custom-mhConnection/main.js b/player/plugin/custom-mhConnection/main.js index 265121113b7b8ccb593829b3c42f71e68f230869..eaa06206feea81133cc03a4ce14b02fa77623b55 100644 --- a/player/plugin/custom-mhConnection/main.js +++ b/player/plugin/custom-mhConnection/main.js @@ -95,7 +95,7 @@ define(["require", "jquery", "backbone", "engage/core"], function(require, $, Ba } /* change these variables */ - var SEARCH_ENDPOINT = opencastlink+"/search/episode.json"; + var SEARCH_ENDPOINT = window.opencastlink+"/search/episode.json"; /* don't change these variables */ var initCount = 3; // decreased init count due to disabling footprint, viewsmodel diff --git a/player/plugin/custom-usertracking/main.js b/player/plugin/custom-usertracking/main.js deleted file mode 100644 index 9be23154ecdbfd46aafa01e2d25894d45fc91b0d..0000000000000000000000000000000000000000 --- a/player/plugin/custom-usertracking/main.js +++ /dev/null @@ -1,164 +0,0 @@ -/** - * Licensed to The Apereo Foundation under one or more contributor license - * agreements. See the NOTICE file distributed with this work for additional - * information regarding copyright ownership. - * - * - * The Apereo Foundation licenses this file to you under the Educational - * Community License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of the License - * at: - * - * http://opensource.org/licenses/ecl2.txt - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - * - */ -/*jslint browser: true, nomen: true*/ -/*global define*/ -define(["jquery", "backbone", "engage/core"], function($, Backbone, Engage) { - "use strict"; - - var insertIntoDOM = false; - var PLUGIN_NAME = "Engage Plugin Custom Usertracking"; - var PLUGIN_TYPE = "engage_custom"; - var PLUGIN_VERSION = "1.0"; - var PLUGIN_TEMPLATE_DESKTOP = "none"; - var PLUGIN_TEMPLATE_MOBILE = "none"; - var PLUGIN_TEMPLATE_EMBED = "none"; - var PLUGIN_STYLES_DESKTOP = [ - "" - ]; - var PLUGIN_STYLES_EMBED = [ - "" - ]; - var PLUGIN_STYLES_MOBILE = [ - "" - ]; - - var plugin; - var events = { - plugin_load_done: new Engage.Event("Core:plugin_load_done", "", "handler"), - timeupdate: new Engage.Event("Video:timeupdate", "notices a timeupdate", "handler"), - mediaPackageModelError: new Engage.Event("MhConnection:mediaPackageModelError", "", "handler") - }; - - var isDesktopMode = false; - var isEmbedMode = false; - var isMobileMode = false; - - // desktop, embed and mobile logic - switch (Engage.model.get("mode")) { - case "embed": - plugin = { - insertIntoDOM: insertIntoDOM, - name: PLUGIN_NAME, - type: PLUGIN_TYPE, - version: PLUGIN_VERSION, - styles: PLUGIN_STYLES_EMBED, - template: PLUGIN_TEMPLATE_EMBED, - events: events - }; - isEmbedMode = true; - break; - case "mobile": - plugin = { - insertIntoDOM: insertIntoDOM, - name: PLUGIN_NAME, - type: PLUGIN_TYPE, - version: PLUGIN_VERSION, - styles: PLUGIN_STYLES_MOBILE, - template: PLUGIN_TEMPLATE_MOBILE, - events: events - }; - isMobileMode = true; - break; - case "desktop": - default: - plugin = { - insertIntoDOM: insertIntoDOM, - name: PLUGIN_NAME, - type: PLUGIN_TYPE, - version: PLUGIN_VERSION, - styles: PLUGIN_STYLES_DESKTOP, - template: PLUGIN_TEMPLATE_DESKTOP, - events: events - }; - isDesktopMode = true; - break; - } - - /* don't change these variables */ - var mediapackageChange = "change:mediaPackage"; - var footprintsChange = "change:footprints"; - var initCount = 3; - var lastFootprint = undefined; - var mediapackageID; - var mediapackageError = false; - - /* TODO: Wait for the new usertracking service... - - function initPlugin() { - mediapackageID = Engage.model.get("urlParameters").id; - if (!mediapackageID) { - mediapackageID = ""; - return; - } - - Engage.on(plugin.events.mediaPackageModelError.getName(), function(msg) { - mediapackageError = true; - }); - - Engage.on(plugin.events.timeupdate.getName(), function(currentTime) { - if (!mediapackageError) { - // add footprint each timeupdate - var cTime = Math.round(currentTime); - if (lastFootprint != undefined) { - if (lastFootprint != cTime) { - lastFootprint = cTime; - Engage.model.get("footprints").put(cTime, cTime + 1); - } - } else { - lastFootprint = cTime; - } - } - }); - } - - // init event - Engage.log("Usertracking: Init"); - var relative_plugin_path = Engage.getPluginPath("EngagePluginCustomUsertracking"); - - // mediapackage model created - Engage.model.on(mediapackageChange, function() { - initCount -= 1; - if (initCount <= 0) { - initPlugin(); - } - }); - - // footprints model created - Engage.model.on(footprintsChange, function() { - initCount -= 1; - if (initCount <= 0) { - initPlugin(); - } - }); - - // all plugins loaded - Engage.on(plugin.events.plugin_load_done.getName(), function() { - Engage.log("Usertracking: Plugin load done"); - initCount -= 1; - if (initCount <= 0) { - initPlugin(); - } - }); - - */ - - return plugin; -}); diff --git a/player/plugin/video-videojs/main.js b/player/plugin/video-videojs/main.js index 6a08e7a4147e8a04e4b0e1d5093f61912f13db71..5487a0877a6823ee47b069cac9b74eac5aa33da2 100644 --- a/player/plugin/video-videojs/main.js +++ b/player/plugin/video-videojs/main.js @@ -181,7 +181,7 @@ define(['require', 'jquery', 'underscore', 'backbone', 'basil', 'bowser', 'engag var isUsingFlash = false; var mastervideotype = ''; var aspectRatio = null; - var singleVideoPaddingTop = '56.25%'; + var singleVideoPaddingTop = '0'; var initCount = 7; var infoMeChange = 'change:infoMe'; var mediapackageError = false; @@ -957,8 +957,8 @@ define(['require', 'jquery', 'underscore', 'backbone', 'basil', 'bowser', 'engag } }); for (var j = 0; j < videoDisplays.length; ++j) { - $('#' + videoDisplays[j]).css('padding-top', (aspectRatio[2] / aspectRatio[1] * 100) + '%').addClass('auto-height'); - singleVideoPaddingTop = (aspectRatio[2] / aspectRatio[1] * 100) + '%'; + // $('#' + videoDisplays[j]).css('padding-top', (aspectRatio[2] / aspectRatio[1] * 100) + '%').addClass('auto-height'); + // singleVideoPaddingTop = (aspectRatio[2] / aspectRatio[1] * 100) + '%'; } } @@ -1111,8 +1111,8 @@ define(['require', 'jquery', 'underscore', 'backbone', 'basil', 'bowser', 'engag Engage.trigger(plugin.events.aspectRatioSet.getName(), [aspectRatio[1], aspectRatio[2], (aspectRatio[1] / aspectRatio[2]) * 100]); $('.' + id_videoDisplayClass).css('width', '100%'); for (var i = 0; i < videoDisplays.length; ++i) { - $('#' + videoDisplays[i]).css('padding-top', (aspectRatio[2] / aspectRatio[1] * 100) + '%').addClass('auto-height'); - singleVideoPaddingTop = (aspectRatio[2] / aspectRatio[1] * 100) + '%'; + // $('#' + videoDisplays[i]).css('padding-top', (aspectRatio[2] / aspectRatio[1] * 100) + '%').addClass('auto-height'); + // singleVideoPaddingTop = (aspectRatio[2] / aspectRatio[1] * 100) + '%'; } } else { Engage.trigger(plugin.events.aspectRatioSet.getName(), -1, -1, -1); @@ -1153,7 +1153,7 @@ define(['require', 'jquery', 'underscore', 'backbone', 'basil', 'bowser', 'engag Engage.trigger(plugin.events.aspectRatioSet.getName(), aspectRatio[1], aspectRatio[2], (aspectRatio[2] / aspectRatio[1]) * 100); $('.' + id_videoDisplayClass).css('width', '100%'); for (var j = 0; j < videoDisplays.length; ++j) { - $('#' + videoDisplays[j]).css('padding-top', (aspectRatio[2] / aspectRatio[1] * 100) + '%').addClass('auto-height'); + // $('#' + videoDisplays[j]).css('padding-top', (aspectRatio[2] / aspectRatio[1] * 100) + '%').addClass('auto-height'); } } else { Engage.trigger(plugin.events.aspectRatioSet.getName(), -1, -1, -1); @@ -1978,7 +1978,7 @@ define(['require', 'jquery', 'underscore', 'backbone', 'basil', 'bowser', 'engag $('.' + videoUnfocusedClass).css('margin-left', marginLeft + '%'); } else { var height = $('.' + videoFocusedClass).height(); - $('#engage_video').height(height + 10); + //$('#engage_video').height(height + 10); } delayedCalculateVideoAreaAspectRatio(); diff --git a/player/plugin/video-videojs/styles/desktop.css b/player/plugin/video-videojs/styles/desktop.css index 3d386158b4fb61a0d08f3422cbb4d8dc9ec2daa3..805d9f84ee13cf2b06159cd6ae1f866eac8d30ef 100644 --- a/player/plugin/video-videojs/styles/desktop.css +++ b/player/plugin/video-videojs/styles/desktop.css @@ -1,10 +1,10 @@ #canvas { - position: absolute; + position: absolute; } .videojs_wrapper { width: 100%; - /*height: 100%;*/ + height: 100%; position: relative; margin: 0 auto; cursor: pointer; @@ -30,7 +30,7 @@ .videoFrame { width: 100%; - /*height: 100%;*/ + height: 100%; } .videoFocusedPiP { @@ -44,7 +44,6 @@ position: absolute; margin-left: 12%; margin-top: 10%; - box-shadow: 3px 3px 3px black; opacity: 0.7; z-index: 20; } @@ -60,10 +59,12 @@ width: 19.5%; float: right; margin-left: 70%; - } +} .video-js { background-color: rgba(0, 0, 0, 0.0) !important; + width: 100% !important; + height: 100%; } .clearfix:before, .clearfix:after { @@ -89,7 +90,7 @@ } #fullscreen_video_wrapper { - background-color: #000; + background-color: #000; } #indicator { @@ -102,3 +103,11 @@ top: 88%; border: 1px solid white; } + +.video-js .vjs-tech { + position: relative !important; +} + +.vjs-poster { + background-color: transparent !important; +} \ No newline at end of file diff --git a/player_changes.pdf b/player_changes.pdf new file mode 100644 index 0000000000000000000000000000000000000000..6fb8e884635f6a9422bb39acc052a7b0ddc2db30 Binary files /dev/null and b/player_changes.pdf differ diff --git a/settings.php b/settings.php index 3ad01b5a34d5f8d986a73eee6a274bff71af8620..a3128ec3d446bd9d6d93932a3b4561e80a55abde 100644 --- a/settings.php +++ b/settings.php @@ -15,24 +15,17 @@ // along with Moodle. If not, see <http://www.gnu.org/licenses/>. /** - * Settings. + * Settings for opencast filter. * - * @package block_opencast + * @package filter_opencast * @copyright 2017 Tamara Gunkel * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ defined('MOODLE_INTERNAL') || die; if ($ADMIN->fulltree) { - - $issuers = \core\oauth2\api::get_all_issuers(); - $choices = array(); - foreach($issuers as $issuer){ - $choices[$issuer->get('id')] = $issuer->get('name'); - } - - $settings->add(new admin_setting_configselect('filter_opencast/issuerid', get_string('setting_issuer', 'filter_opencast'), - get_string('setting_issuer_desc', 'filter_opencast'), 0, $choices)); - $settings->add(new admin_setting_configtext('filter_opencast/baseurlapi', get_string('setting_baseurlapi', 'filter_opencast'), - get_string('setting_baseurlapi_desc', 'filter_opencast'), '')); + $settings->add(new admin_setting_configtext('filter_opencast/consumerkey', get_string('setting_consumerkey', 'filter_opencast'), + get_string('setting_consumerkey_desc', 'filter_opencast'), '')); + $settings->add(new admin_setting_configtext('filter_opencast/consumersecret', get_string('setting_consumersecret', 'filter_opencast'), + get_string('setting_consumersecret_desc', 'filter_opencast'), '')); } diff --git a/version.php b/version.php index c5bd2c7ffee5e0405a009f4fdd1da8c7b3a3fd71..1e76d9a7aa14ecf9c3b273a21e672592ee23c5f4 100644 --- a/version.php +++ b/version.php @@ -25,6 +25,7 @@ defined('MOODLE_INTERNAL') || die(); -$plugin->version = 2018010906; // The current plugin version (Date: YYYYMMDDXX) +$plugin->version = 2018021500; // The current plugin version (Date: YYYYMMDDXX) $plugin->requires = 2017050500; // Requires this Moodle version $plugin->component = 'filter_opencast'; // Full name of the plugin (used for diagnostics) +$plugin->dependencies = array('tool_opencast' => ANY_VERSION);