// 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]); } }, parseQueryString = function (query) { var vars = query.split("&"); var query_string = {}; for (var i = 0; i < vars.length; i++) { var pair = vars[i].split(/=(.+)/); var key = decodeURIComponent(pair[0]); var value = decodeURIComponent(pair[1]); // If first entry with this name if (typeof query_string[key] === "undefined") { query_string[key] = decodeURIComponent(value); // If second entry with this name } else if (typeof query_string[key] === "string") { var arr = [query_string[key], decodeURIComponent(value)]; query_string[key] = arr; // If third or later entry with this name } else { query_string[key].push(decodeURIComponent(value)); } } return query_string; }, overrideParameter = function (originalUrl, parameter, value) { if (originalUrl === undefined || originalUrl === null || parameter === null || parameter === undefined || parameter === '') return originalUrl; if (originalUrl.toLowerCase().indexOf(parameter.toLowerCase()) > -1) { originalUrl = originalUrl.replace(new RegExp('(' + parameter + '=).*?(&|$)', 'ig'), '$1' + value + '$2'); } else { originalUrl = originalUrl.indexOf('?') > -1 || originalUrl.toLowerCase().indexOf('http') === -1 ? (originalUrl + '&' + parameter + '=' + value) : (originalUrl + '?' + parameter + '=' + value); } return originalUrl; }, overrideIdentityParams = function (originalUrl, identityQuery) { var idnParams = parseQueryString(identityQuery); for (var property in idnParams) { var value = idnParams[property]; if (value !== undefined && value !== null && value !== "") originalUrl = overrideParameter(originalUrl, property, value); } return originalUrl; }; try { var xmlHttp = new XMLHttpRequest(); xmlHttp.onreadystatechange = function() { if (xmlHttp.readyState == 4 && xmlHttp.status == 200) { var showReturnUrl = true; var embedDiv = document.getElementById('ensembleEmbeddedContent_QDamX4hcmk-tSLNgGLHMsw'); if (embedDiv == null) embedDiv = document.getElementById('ensembleEmbeddedContent_5fa63640-5c88-4f9a-ad48-b36018b1ccb3'); if (embedDiv == null){ showReturnUrl = false; embedDiv = document.getElementById(''); } if (embedDiv == null){ showReturnUrl = false; embedDiv = document.getElementById(''); } 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); } }; var storageIdentityKey = 'Identity_5fa63640-5c88-4f9a-ad48-b36018b1ccb3'; var identity = localStorage.getItem(storageIdentityKey); if ('true' === 'true') localStorage.removeItem(storageIdentityKey); var pluginUrl = 'https://cloud02.ensemblevideo.com/hapi/v1/contents/5fa63640-5c88-4f9a-ad48-b36018b1ccb3/plugin?embedId=ensembleEmbeddedContent_QDamX4hcmk-tSLNgGLHMsw&embedAsThumbnail=false&displayTitle=false&displaySharing=false&autoplay=true&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&displayAxdxs=false&playlistId=00000000-0000-0000-0000-000000000000&isJavascriptInIframe=False&idn_content=5fa63640-5c88-4f9a-ad48-b36018b1ccb3&idn_init=True&idn_sig=EaVUiOzLflZW0WIPaEL6N%2BWsasE%3D'; if (identity !== undefined && identity !== null) pluginUrl = overrideIdentityParams(pluginUrl, identity); xmlHttp.open("GET", pluginUrl, true); xmlHttp.withCredentials = true; xmlHttp.send(null); } catch (err) { console.log(err.message); }