( function(){ var interval = setInterval( function(){ if (document.getElementById('video-container') != null && document.getElementsByTagName('app-oney-site-pages') != null) { var attributes = document.getElementsByTagName('app-oney-site-pages')[0].attributes; for (let i = 0; i < attributes.length; i++) { if(attributes[i].name.includes('nghost-serverapp')) { var config = { targetElId: 'video-container',vidataIdSource: { querystring: 'id' },autoplay: true,playerWidth: 560,playerHeight: 315,uid: '1234567890' }; var Booter = function () { this.isReady = false; this.options = []; }; Booter.prototype.Init = function () { var that = this; function completed() { document.removeEventListener("DOMContentLoaded", completed); window.removeEventListener("load", completed); that.OnReady(); } if (document.readyState === "complete" || (document.readyState !== "loading" && !document.documentElement.doScroll)) { window.setTimeout(function () { that.OnReady() }); } else { document.addEventListener("DOMContentLoaded", completed); window.addEventListener("load", completed); } }; Booter.prototype.OnReady = function () { try { if (this.options.length > 0) { for (var x = 0; x < this.options.length; x++) { this.ExecuteSetup(this.options[x]); } } this.isReady = true; } catch (e) { console.error("Vidata: failed to setup player due to unexpected error", e); } }; Booter.prototype.Setup = function (o) { try { if (this.isReady) { this.ExecuteSetup(o); } else { this.options.push(o); } } catch (e) { console.error("Vidata: failed to setup player due to unexpected error", e); } } Booter.prototype.ExecuteSetup = function (o) { if (!o) { console.warn("Vidata: failed to setup player, you must pass a valid configuration to the Setup function"); return; } var vid = "none"; if (o.vidataIdSource && o.vidataIdSource.querystring) { vid = this.GetParameterByName(o.vidataIdSource.querystring); } if (o.vidataIdSource && o.vidataIdSource.useLastPathPart) { var parts = window.location.pathname.split("/"); for (var x = parts.length - 1; x > 0; x--) { var part = parts[x]; if (part.length > 0) { vid = part; break; } } } var userIdHash = this.GetParameterByName("userIdHash"); if (userIdHash) { localStorage.setItem("userIdHash", userIdHash); } var autoplay = o.autoplay ? o.autoplay : false; var width = o.playerWidth ? o.playerWidth : null; var height = o.playerHeight ? o.playerHeight : null; var playerSrc = "https://player.vidata.io/embed/index/" + vid + "?autoplay=" + autoplay.toString(); if (o.uid) { playerSrc += "&uid=" + encodeURIComponent(o.uid); } if (o.hideContextMenu) { playerSrc += "&showContextMenu=false"; } var iframe = document.createElement("iframe"); iframe.src = playerSrc; if (width && height) { iframe.setAttribute("width", width); iframe.setAttribute("height", height); iframe.setAttribute("style", "width:" + width + "px !important; " + "height: " + height + "px !important;"); } iframe.setAttribute("allowfullscreen", true); iframe.setAttribute("frameborder", 0); if (!o.targetElId) { console.warn("Vidata: failed to setup player, you must pass a targetElId property in the configuration object"); return; } var targetEl = document.getElementById(o.targetElId); if (targetEl) { targetEl.appendChild(iframe); } else { console.warn("Vidata: Failed to setup player due to invalid target element id"); return; } }; Booter.prototype.GetParameterByName = function (name, url) { if (!url) url = window.location.href; name = name.replace(/[\[\]]/g, "\\$&"); var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"), results = regex.exec(url); if (!results) return null; if (!results[2]) return ""; return decodeURIComponent(results[2].replace(/\+/g, " ")); }; window.VidataPlayer = new Booter(); window.VidataPlayer.Init(); window.VidataPlayer.Setup(config) clearInterval(interval); } } } }, 200); } )();