// Recreate the script tags with the syntax for the new plugin // by appending the ?DestinationID= to the source URL var scriptInstances = document.getElementsByTagName('script'); for (i = 0; i < scriptInstances.length; i++) { if (scriptInstances[i].src.match(/plugin(\.aspx|\.js)/i)) { var sourceUrl = scriptInstances[i].src; // Prevent infinite redirects in case the destinationID or contentID is already appended if (!sourceUrl.match(/(destinationID|contentID|videoID)=.*/i)) { var parentNode = scriptInstances[i].parentNode; var script = document.createElement('script'); script.type = 'text/javascript'; // If this is not a call to embed the content if (!sourceUrl.match(/embed=/i)) { // Set the source of the script and append the destinationID script.src = scriptInstances[i].src + ((scriptInstances[i].src.indexOf('?') > 0) ? '&' : '?') + 'destinationID=' + scriptInstances[i].id; parentNode.id = 'ensembleContentContainer_' + scriptInstances[i].id; parentNode.setAttribute('class', 'ensembleContentContainer'); } else { // Set the source of the script and append the contentID script.src = scriptInstances[i].src + '&contentID=' + scriptInstances[i].id; parentNode.id = 'ensembleEmbeddedContent_' + scriptInstances[i].id; parentNode.setAttribute('class', 'ensembleEmbeddedContent'); } parentNode.innerHTML = ''; parentNode.appendChild(script); } else if (!sourceUrl.match(/q=.*/i)) { var parentNode = scriptInstances[i].parentNode; var script = document.createElement('script'); script.type = 'text/javascript'; script.src = sourceUrl + '&q=' + escape(location.host); parentNode.innerHTML = ''; parentNode.appendChild(script); } } } var exec_scripts = function (body_el) { var scripts = [], script, children_nodes = body_el.childNodes, child, i, rcleanScript = /^\s*\s*$/g, evalUrl = function (url) { var xmlHttp = new XMLHttpRequest(); xmlHttp.open("GET", url, false); xmlHttp.send(); if (xmlHttp.readyState == 4 && xmlHttp.status == 200) { var script = document.createElement("script"); script.type = "text/javascript"; script.text = xmlHttp.responseText; document.head.appendChild(script).parentNode.removeChild(script); } }, globalEval = function (code) { var script = document.createElement("script"); script.type = "text/javascript"; script.text = code; document.head.appendChild(script).parentNode.removeChild(script); }, nodeName = function (elem, name) { return elem.nodeName && elem.nodeName.toUpperCase() === name.toUpperCase(); }, evalScript = function (elem) { if (elem.src) { evalUrl(elem.src); } else { globalEval((elem.text || elem.textContent || elem.innerHTML || "").replace(rcleanScript, "")); } }; for (i = 0; children_nodes[i]; i++) { child = children_nodes[i]; if (nodeName(child, "script") && (!child.type || child.type.toLowerCase() === "text/javascript")) { scripts.push(child); } } for (i = 0; scripts[i]; i++) { script = scripts[i]; if (script.parentNode) { script.parentNode.removeChild(script); } evalScript(scripts[i]); } }, addClass = function (el, classNameToAdd) { el.className += ' ' + classNameToAdd; }, appendHtml = function (el, str) { var div = document.createElement('div'); div.innerHTML = str; while (div.children.length > 0) { el.appendChild(div.children[0]); } }; try { var xmlHttp = new XMLHttpRequest(); xmlHttp.onreadystatechange = function() { if (xmlHttp.readyState == 4 && xmlHttp.status == 200) { var embedDiv = document.getElementById('ensembleEmbeddedContent_PV5wRV0fOUWS3LEj6DaI6g'); addClass(embedDiv, 'ev-full-height'); var wrapperDiv = document.createElement("div"); addClass(wrapperDiv, 'ev-full-height'); wrapperDiv.innerHTML = xmlHttp.responseText; embedDiv.appendChild(wrapperDiv); exec_scripts(wrapperDiv); } }; xmlHttp.open("GET", 'https://stream.queensu.ca/hapi/v1/contents/45705e3d-1f5d-4539-92dc-b123e83688ea/plugin?embedId=ensembleEmbeddedContent_PV5wRV0fOUWS3LEj6DaI6g&embedAsThumbnail=false&displayTitle=False&displaySharing=False&autoplay=False&showCaptions=False&hideControls=False&audioPreviewImage=False&displayEmbedCode=True&displayDownloadIcon=False&displayAttachments=True&displayLinks=True&displayCredits=True&displayMetaData=True&displayVideoDuration=False&displayAnnotations=False&displayCaptionSearch=False&isJavascriptEmbed=True&isResponsive=False&displayViewersReport=False&playlistId=00000000-0000-0000-0000-000000000000', true); xmlHttp.withCredentials = true; xmlHttp.send(null); } catch (err) { console.log(err.message); }