var FlickFusionExecuter = function () { "use strict"; var _mediaHostURL = "//media.flickfusion.net/", _verifyHostURL = "//verify.flickfusion.net/", _getRefDomain = window.location.hostname, _displayButtonThumb, _displayButtonDefault, _custom_script_run, _button_image_path, _showSpanishBtn = false, _profilesBag = {}, _filterUnique = {}, _buttonsCount = 0, _buttons_count = document.querySelectorAll('#ff_link').length, _domainName = window.location.hostname, _path = window.location.href, _allowDuplicates = false, siteConfig; window.clientKey = "9DBFA137-6209-204A-EE26-019DE7BEC303"; // json include // js inlcude if (document.referrer) { _getRefDomain = document.referrer; _getRefDomain = _getRefDomain.match(/:\/\/(.[^/]+)/)[1]; if(_getRefDomain == "resources.flickfusion.net") _getRefDomain = '' } if(document.querySelector('.hproduct .media .video')){ var existingButtons = document.querySelectorAll('.hproduct .media .video'); [].forEach.call(existingButtons, function(button) { button.style.display = "none"; }); } (function(history){ var pushState = history.pushState; history.pushState = function(state) { if (typeof history.onpushstate == "function") { history.onpushstate({state: state}); } _filterUnique = {} return pushState.apply(history, arguments); } })(window.history); window.addEventListener('popstate', function(e) { _filterUnique = {} }); var isJsonConfigAdded = siteConfig != null; // var isFFLinkAdded = document.querySelector('#ff_link') != null; var loadJSCSSFile = function (filename, filetype) { var fileref; if (filetype == "js") { fileref = document.createElement("script"); fileref.setAttribute("type", "text/javascript"); fileref.setAttribute("src", filename); } else if (filetype == "css") { fileref = document.createElement("link"); fileref.setAttribute("rel", "stylesheet"); fileref.setAttribute("type", "text/css"); fileref.setAttribute("href", filename); } if (typeof fileref != "undefined") document.getElementsByTagName("head")[0].appendChild(fileref); }; if(isJsonConfigAdded){ window.siteConfig = siteConfig; loadJSCSSFile("//media.flickfusion.net/videos/global/prod/button_div_finder.js", "js"); } var loadButtons = function () { var profielsArray = []; if(document.getElementById("ff_link")){ document.querySelectorAll("#ff_link") .forEach(function (buttonData, index, array) { _buttonsCount ++; if (profielsArray.indexOf(buttonData.getAttribute('ff_client')) === -1) profielsArray.push(buttonData.getAttribute('ff_client')); if(_buttonsCount === array.length){ generateProfilesThenButtons(profielsArray); } }); } }; var generateProfilesThenButtons = function (profielsArray) { profielsArray.forEach(function (profileKey, index, profilesArray) { var verifyClientMultiProfile = _verifyHostURL + "ff_verify_client.php?client_id=" + profileKey + "&d="+_domainName+"&p="+ encodeURIComponent(_path)+"&b="+ _buttons_count; fetchJsonp(verifyClientMultiProfile, { timeout: 25000, }).then(function (response) { return response.json(); }).then(function (multiClientDetails) { if(multiClientDetails.code === 200){ multiClientDetails.client_data.data.forEach(function (clientData) { _profilesBag[clientData.client_fk] = clientData; }); } if(index+1 === profilesArray.length){ document.querySelectorAll("#ff_link") .forEach(function (buttonData, index, array) { checkVehicleData(buttonData); }); } }).catch(function (reason) { console.log('parsing failed', reason); }) }) } // include var checkVehicleData = function (buttonData) { var isDuplicateButton = _filterUnique[buttonData.getAttribute('ff_client')+'__'+buttonData.getAttribute('ff_vin')]; if(buttonData.getAttribute("ff_inline")) isDuplicateButton = false; if(!_allowDuplicates){ if(isDuplicateButton || buttonData.hasAttribute('verified')){ return false; } } buttonData.innerHTML = ""; var verifyDetails, ff_vin = buttonData.getAttribute("ff_vin") || '', ff_year = buttonData.getAttribute("ff_year") || '', ff_make = buttonData.getAttribute("ff_make") || '', ff_model = buttonData.getAttribute("ff_model") || '', ff_trim = buttonData.getAttribute("ff_trim") || '', ff_lp = buttonData.getAttribute("ff_lp") || '', ff_body_type = buttonData.getAttribute("ff_body_type") || '', clientKey = buttonData.getAttribute("ff_client") || ''; var ff_new_car = "&ff_year=" + ff_year + "&ff_make=" + ff_make + "&ff_model=" + ff_model + "&ff_trim=" + ff_trim + "&ff_body_type=" + ff_body_type + "&ff_lp=" + ff_lp; for (var key in _profilesBag) { if (_profilesBag.hasOwnProperty(key)) { if(_profilesBag[key].disp_spanish_btn === 1){ _showSpanishBtn = true; break; } } } verifyDetails = _verifyHostURL + "ff_verify_vin.php?vin=" + ff_vin + "&client_id=" + clientKey + ff_new_car + (_showSpanishBtn ? '&ff_spanish=1' : ''); fetchJsonp(verifyDetails, { timeout: 25000, }) .then(function (response) { return response.json() }).then(function (videoData) { if (videoData.code === 200) { generateDistplyItems(videoData.data, buttonData); } else return false; }).catch(function (reason) { console.log('parsing failed', reason); }) _filterUnique[buttonData.getAttribute('ff_client')+'__'+buttonData.getAttribute('ff_vin')] = true; }; function isElementHidden(el) { return (el.offsetParent === null) } // check vehicle data(based on vin) -- ends // create and print buttons on the page -- starts var generateDistplyItems = function (videoData, buttonData) { // siteConfig if(siteConfig && document.querySelector(siteConfig.VDP.VDPIndicator) && _profilesBag[videoData.client_fk].inline == 1) buttonData.setAttribute("ff_inline", 1); if(_profilesBag[videoData.client_fk].vid_call === 1){ if(_buttons_count === 1){ var videoCallFromName = videoData.veh_year +" "+ videoData.veh_make +" "+videoData.veh_model+" "+ videoData.veh_trim; videoCallFromName = encodeURIComponent(videoCallFromName); if(_profilesBag[videoData.client_fk].vid_call_html){ var createVideoWrapper = document.createElement('div'); createVideoWrapper.innerHTML = _profilesBag[videoData.client_fk].vid_call_html; document.body.appendChild(createVideoWrapper); }else{ var cardTitle = "Have Questions?" || "Have Questions?"; var cardDesc = "Video Chat With Us Now And Get Real Answers, No Sales Pitch. No Pressure" ||"Video Chat With Us Now And Get Real Answers, No Sales Pitch. No Pressure" loadJSCSSFile("generate_video_call_card.js?externalCallEmbed=0&user_html_added=0&cardDesc="+cardDesc+"&cardTitle="+cardTitle+"&fromName="+videoCallFromName+"&roof_key="+_profilesBag[videoData.client_fk].client_fk, "js"); } } if(_buttons_count > 1 && _profilesBag[videoData.client_fk].vid_call_img){ var vidCallBtn = document.createElement('img'); vidCallBtn.style.cursor = "pointer"; vidCallBtn.src = _profilesBag[videoData.client_fk].vid_call_img; buttonData.appendChild(vidCallBtn); var videoCallFromName = videoData.veh_year +" "+ videoData.veh_make +" "+videoData.veh_model+" "+ videoData.veh_trim; videoCallFromName = encodeURIComponent(videoCallFromName); var videoCallURL = "https://media.flickfusion.net/videocall/external_vidcall.php?from_user_name="+videoCallFromName+"&roof_key="+ _profilesBag[videoData.client_fk].client_fk vidCallBtn.addEventListener('click', function () { window.open(videoCallURL); }) } } var disableAutoPlay = buttonData.getAttribute("disable_auto_play") || ''; var iframeElement, isLandingPage = Number(buttonData.getAttribute("ff_lp")) === 1 ? true : _profilesBag[videoData.client_fk].lp === 1 ? true : false, checkInline = buttonData.getAttribute("ff_inline") || 0; if (Number(checkInline) === 1) { if (videoData.popup && videoData.popup.type === 2 || videoData.nv && videoData.nv.type === 2) window.addEventListener("message", receiveMessage, false); addJsonLdToHead(videoData.jsonLD); iframeElement = document.createElement("iframe"); iframeElement.frameBorder = 0; iframeElement.scrolling = "no"; iframeElement.setAttribute('allowFullScreen',''); iframeElement.src = videoData.popup.url + (Number(disableAutoPlay) === 1 ? '&disable_auto_play=1': '') + "&referer=" + _getRefDomain; buttonData.appendChild(iframeElement); iframeElement.id = "ff_link_iframe"; iframeElement.style.cssText = "width:1px; min-width:100%;"; // fullscreen icon var create_full_screen_image = document.createElement("img"); create_full_screen_image.style.cssText = "position:absolute;right:5px;top:3px;margin-top:0;padding:7px 0;cursor:pointer;width: 25px;"; buttonData.setAttribute("style", "position:relative;"); create_full_screen_image.src = _profilesBag[videoData.client_fk].full_scrn_img; create_full_screen_image.addEventListener("click", function () { openLargePopup(videoData.popup.type) }); buttonData.appendChild(create_full_screen_image); if (videoData.popup.type === 0) { buttonData.style.cssText = "position:relative; padding-bottom:60.2%; padding-top:25px; height:0;"; iframeElement.style.cssText = "position:absolute;top:0; left:0; width:100%; height:100%;"; } // new sticky player code starts if (videoData.popup.type === 0 && _profilesBag[videoData.client_fk].code_float_player === 1) { var flagScrollIn = true, flagScrollOut = true, minimizeClicked = false; var quickActionBlock = document.createElement('div'); quickActionBlock.style.cssText = "background-color: #ccc; position: fixed; height: 20px; right: 0px; bottom: 260px; display: block; width: 400px;"; quickActionBlock.className = "quick_action_buttons"; var minimizeButton = document.createElement("span"); quickActionBlock.appendChild(minimizeButton); minimizeButton.innerHTML = "–"; minimizeButton.style.cssText = "margin: 0px 3px; cursor: pointer; font-size: 18px; float: right; font-weight: bold; text-align: center; width: 15px; line-height: 16px;"; var playMinimize = document.createElement("div"); playMinimize.className = "play_button_icon"; var playIcon = document.createElement('img'); playIcon.src = _mediaHostURL + "videos/assets/images/play_square_button.jpg"; playIcon.style.width = "150px"; playMinimize.appendChild(playIcon); playMinimize.style.cssText = "cursor:pointer;background-color: #eee; position: fixed; height: 20px; right: 0px; bottom: 90px;"; buttonData.appendChild(playMinimize); playMinimize.style.display = "none"; minimizeButton.addEventListener("click", function () { if (minimizeClicked) { iframeElement.style.display = "block"; playMinimize.style.display = "none"; quickActionBlock.style.cssText = "background-color: #ccc; position: fixed; height: 20px; right: 0px; bottom: 260px; display: block; width: 400px;"; minimizeButton.style.cssText = "margin: 0px 3px; cursor: pointer; font-size: 18px; float: right; font-weight: bold; text-align: center; width: 14px; line-height: 16px;text-shadow: 1px 2px 5px #4a4141;"; minimizeButton.innerHTML = "–"; minimizeClicked = false; } else { iframeElement.src = videoData.popup.url + "&referer=" + _getRefDomain; iframeElement.style.display = "none"; playMinimize.style.display = "block"; quickActionBlock.style.cssText = "background-color: #ccc; position: fixed; height: 20px; right: 0px; bottom: 110px; display: block; width: 150px;"; minimizeButton.innerHTML = "❏"; minimizeButton.style.cssText = "margin: 0px 3px; cursor: pointer; font-size: 12px; float: right; text-align: center; width: 14px; line-height: 20px;"; minimizeClicked = true; } }) playMinimize.addEventListener("click", function () { iframeElement.style.display = "block"; playMinimize.style.display = "none"; quickActionBlock.style.cssText = "background-color: #ccc; position: fixed; height: 20px; right: 0px; bottom: 260px; display: block; width: 400px;"; minimizeButton.style.cssText = "margin: 0px 3px; cursor: pointer; font-size: 18px; float: right; font-weight: bold; text-align: center; width: 14px; line-height: 16px;"; minimizeButton.innerHTML = "–"; minimizeClicked = false; }) var scrollHeightFromTop; function setMiniStickyPlayer() { scrollHeightFromTop = window.scrollY || document.documentElement.scrollTop; if (document.querySelector('#ff_link').offsetTop + document.querySelector('#ff_link').clientHeight < scrollHeightFromTop && flagScrollIn) { iframeElement.style.cssText = "background-color:#eee;position: fixed; height: 260px; width: 400px; right: 0; bottom: 0;width: 400px; right: 0; bottom: 0;"; buttonData.appendChild(quickActionBlock); quickActionBlock.style.display = "block"; flagScrollIn = false; flagScrollOut = true; } else if (document.querySelector('#ff_link').offsetTop + document.querySelector('#ff_link').clientHeight > scrollHeightFromTop && flagScrollOut) { iframeElement.style.cssText = "position: absolute; top: 0px; left: 0px; width: 100%; height: 100%;"; playMinimize.style.display = "none"; minimizeButton.innerHTML = "–"; minimizeButton.style.cssText = "margin: 0px 3px; cursor: pointer; font-size: 18px; float: right; font-weight: bold; text-align: center; width: 15px; line-height: 16px;"; quickActionBlock.style.cssText = "background-color: #ccc; position: fixed; height: 20px; right: 0px; bottom: 260px; display: block; width: 400px;"; quickActionBlock.style.display = "none"; minimizeClicked = false; flagScrollOut = false; flagScrollIn = true; } } setMiniStickyPlayer(); window.addEventListener('scroll', function () { setMiniStickyPlayer(); }, false) } // new sticky player code ends return false; } // open fullscreen popup function openLargePopup(modalType) { new ConModal({ width: 960, videoPage: modalType, modalTitle: "Video", iframeUrl: videoData.popup.url + "&referer=" + _domainName, }); var ff_iframe = document.getElementById("ff_link_iframe"); ff_iframe.src = ff_iframe.src+"&disable_auto_play=1"; } // code for button generate _button_image_path = buttonData.getAttribute("ff_img") || _profilesBag[videoData.client_fk].vid_button; // srp video button display if(_buttons_count > 1 && _profilesBag[videoData.client_fk].srp_btn_img){ _button_image_path = buttonData.getAttribute("ff_img") || _profilesBag[videoData.client_fk].srp_btn_img; } // vdp video button display if(_buttons_count === 1 && _profilesBag[videoData.client_fk].vdp_btn_img){ _button_image_path = buttonData.getAttribute("ff_img") || _profilesBag[videoData.client_fk].vdp_btn_img; } if( _button_image_path != '' ) { if( !_button_image_path.match(/\.(jpg|jpeg|png|gif)$/) ) { _button_image_path = _profilesBag[videoData.client_fk].vid_button; console.log("Not Image"); } } if (videoData.popup && videoData.popup.is360 === 1) { _button_image_path = _profilesBag[videoData.client_fk].img_360; // srp 360 button display if(_buttons_count > 1 && _profilesBag[videoData.client_fk].img_srp_360){ _button_image_path = buttonData.getAttribute("ff_img") || _profilesBag[videoData.client_fk].img_srp_360; } // vdp 360 button display if(_buttons_count === 1 && _profilesBag[videoData.client_fk].img_vdp_360){ _button_image_path = buttonData.getAttribute("ff_img") || _profilesBag[videoData.client_fk].img_vdp_360; } } _displayButtonDefault = generateButton(videoData, buttonData, null, _button_image_path); if (_custom_script_run !== undefined) { _button_image_path = _custom_script_run.buttonImage; _displayButtonThumb = generateButton(videoData, buttonData, _custom_script_run, _button_image_path); if (_custom_script_run.appendElement) { if(_custom_script_run.replaceAsInlinePlayer){ var makeInlinePlayer = buttonData.cloneNode(true); makeInlinePlayer.setAttribute("ff_inline", 1); _custom_script_run.appendElement(buttonData).innerHTML = makeInlinePlayer.outerHTML; } if(videoData.thumb && !_custom_script_run.replaceAsInlinePlayer) _custom_script_run.appendElement(buttonData).appendChild(_displayButtonThumb); if(_custom_script_run.parentElementCSS) _custom_script_run.appendElement(buttonData).style.cssText = _custom_script_run.parentElementCSS; if(_custom_script_run.targetElementSectionForCSS) _custom_script_run.targetElementSectionForCSS(buttonData).style.cssText = _custom_script_run.targetElementSectionCSS; if(_custom_script_run.siteCustomCssInclude){ var styleTag = document.createElement('style'); styleTag.innerText = _custom_script_run.siteCustomCssInclude; document.head.appendChild(styleTag); } if (_buttons_count === 1 && _profilesBag[videoData.client_fk].enable_tracking) GenerateTrafficScoreURL(videoData, _getRefDomain, buttonData.getAttribute('ff_vin'), buttonData); } else { buttonData.appendChild(buttonData); if (_buttons_count === 1 && _profilesBag[videoData.client_fk].enable_tracking) GenerateTrafficScoreURL(videoData, _getRefDomain, buttonData.getAttribute('ff_vin'), buttonData); } // thumb play button _displayButtonThumb.addEventListener("click", function (e) { e.preventDefault(); e.stopPropagation(); new ConModal({ width: videoData.nv ? videoData.nv.button === "AF" ? "90%" : 960 : 960, videoPage: videoData.thumb.type, modalTitle: "Video", iframeUrl: videoData.thumb.url + "&referer=" + _getRefDomain }); }); } // show default button if (videoData.popup) { if (_custom_script_run !== undefined && _custom_script_run.showButton === false) return false; else buttonData.appendChild(_displayButtonDefault); if(videoData.popup.spanish_url){ var _display_spanish_btn = document.createElement("img"); _display_spanish_btn.src = _profilesBag[videoData.client_fk].spanish_btn_url; _display_spanish_btn.style.cursor = "pointer"; var popupWidthSpanish = isLandingPage ? "90%" : 960; var iframeURLSpanish = videoData.popup.spanish_url; _display_spanish_btn.addEventListener("click", function (e) { e.preventDefault(); e.stopPropagation(); new ConModal({ width: popupWidthSpanish, videoPage: videoData.popup.type, modalTitle: "Video", iframeUrl: iframeURLSpanish + "&referer=" + _getRefDomain + (!isLandingPage ? "":"&full_screen=1"), fullscreen: (videoData.popup.tab === 1 && !isLandingPage) ? true : false, }); }); buttonData.appendChild(_display_spanish_btn); } if (_buttons_count === 1 && _profilesBag[videoData.client_fk].enable_tracking) GenerateTrafficScoreURL(videoData, _getRefDomain, buttonData.getAttribute('ff_vin'), buttonData); var iframeURL = videoData.popup.url; var popupWidth = isLandingPage ? "90%" : 960; _displayButtonDefault.addEventListener("click", function (e) { e.preventDefault(); e.stopPropagation(); new ConModal({ width: popupWidth, videoPage: videoData.popup.type, modalTitle: "Video", iframeUrl: iframeURL + "&referer=" + _getRefDomain + (!isLandingPage ? "":"&full_screen=1"), fullscreen: (videoData.popup.tab === 1 && !isLandingPage) ? true : false, }); }); } // show nv button if (videoData.nv) { var _dislpay_nv_button = document.createElement("img"); _dislpay_nv_button.src = videoData.nv.button === "VT" ? _profilesBag[videoData.client_fk].veh_test_img : _profilesBag[videoData.client_fk].af_img; _dislpay_nv_button.style.cursor = "pointer"; _dislpay_nv_button.addEventListener("click", function (e) { e.preventDefault(); e.stopPropagation(); new ConModal({ width: videoData.nv ? videoData.nv.button === "AF" ? "90%" : 960 : 960, videoPage: videoData.nv.type, modalTitle: "Video", iframeUrl: videoData.nv.url + "&referer=" + _getRefDomain }); }); buttonData.appendChild(_dislpay_nv_button); } buttonData.setAttribute("verified", ""); }; var generateButton = function (videoData, buttonData, options, _button_image_path) { addJsonLdToHead(videoData.jsonLD); var createButton; createButton = document.createElement("img"); if(videoData.popup && videoData.popup.alt) { createButton.setAttribute("alt", videoData.popup.alt); createButton.setAttribute("title", videoData.popup.alt); } createButton.src = _button_image_path; createButton.style.cursor = "pointer"; if(_profilesBag[videoData.client_fk].exclusive_btn){ createButton.src = _profilesBag[videoData.client_fk].exclusive_btn; } if (options) { if (options.buttonText) { createButton = document.createElement("span"); createButton.innerText = options.buttonText; } if (options.buttonCSS) { createButton.style.cssText = options.buttonCSS; createButton.style.cursor = "pointer"; } } if(siteConfig && document.querySelector(siteConfig.VLP.VLPIndicator) && siteConfig.VLP.buttonText){ createButton = document.createElement('a'); var flickFusionLink = document.createElement("div"); flickFusionLink.style.cssText = siteConfig.VLP.buttonStyle; flickFusionLink.innerHTML = siteConfig.VLP.buttonText; createButton.appendChild(flickFusionLink); } if(siteConfig && document.querySelector(siteConfig.VDP.VDPIndicator) && siteConfig.VDP.buttonText){ createButton = document.createElement('a'); var flickFusionLink = document.createElement("div"); flickFusionLink.style.cssText = siteConfig.VDP.buttonStyle; flickFusionLink.innerHTML = siteConfig.VDP.buttonText; createButton.appendChild(flickFusionLink); } return createButton; }; // Generate and Add Json Ld to header function addJsonLdToHead(data) { var uploadDate = data.uploadDate ? data.uploadDate : new Date().toISOString().split('T')[0]; var jsonLdData = { "@context": "https://schema.org/", "@type": "VideoObject", "name": data.name, "description": data.description, "duration": CalcJsonLdDuration(data.duration), "contentUrl": data.contentUrl, "thumbnailUrl": data.thumbnailUrl, "uploadDate": uploadDate }; var head = document.getElementsByTagName("head")[0]; var scriptTag = document.createElement("script"); scriptTag.setAttribute("type", "application/ld+json"); scriptTag.innerHTML = JSON.stringify(jsonLdData); head.appendChild(scriptTag); } // Video JSON LD for seo meta -- ends /* All Utility Methods used in the app */ var defaultOptions = { timeout: 25000, jsonpCallback: 'jsoncallback', jsonpCallbackFunction: null }; function generateCallbackFunction() { return 'jsonp_' + Date.now() + '_' + Math.ceil(Math.random() * 100000); } function clearFunction(functionName) { try { delete window[functionName]; } catch (e) { window[functionName] = undefined; } } function removeScript(scriptId) { var script = document.getElementById(scriptId); if (script) { document.getElementsByTagName('head')[0].removeChild(script); } } function fetchJsonp(_url) { var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; // to avoid param reassign var url = _url; var timeout = options.timeout || defaultOptions.timeout; var jsonpCallback = options.jsonpCallback || defaultOptions.jsonpCallback; var timeoutId = undefined; return new Promise(function (resolve, reject) { var callbackFunction = options.jsonpCallbackFunction || generateCallbackFunction(); var scriptId = jsonpCallback + '_' + callbackFunction; window[callbackFunction] = function (response) { resolve({ ok: true, // keep consistent with fetch API json: function json() { return Promise.resolve(response); } }); if (timeoutId) clearTimeout(timeoutId); removeScript(scriptId); clearFunction(callbackFunction); }; // Check if the user set their own params, and if not add a ? to start a list of params url += url.indexOf('?') === -1 ? '?' : '&'; var jsonpScript = document.createElement('script'); jsonpScript.setAttribute('src', '' + url + jsonpCallback + '=' + callbackFunction); if (options.charset) { jsonpScript.setAttribute('charset', options.charset); } jsonpScript.id = scriptId; document.getElementsByTagName('head')[0].appendChild(jsonpScript); timeoutId = setTimeout(function () { reject(new Error('JSONP request to ' + _url + ' timed out')); clearFunction(callbackFunction); removeScript(scriptId); window[callbackFunction] = function () { clearFunction(callbackFunction); }; }, timeout); // Caught if got 404/500 jsonpScript.onerror = function () { reject(new Error('JSONP request to ' + _url + ' failed')); clearFunction(callbackFunction); removeScript(scriptId); if (timeoutId) clearTimeout(timeoutId); }; }); } // end function CalcJsonLdDuration(durationInSeconds) { durationInSeconds = Math.round(durationInSeconds / 60); var days = Math.floor(durationInSeconds / 1440); durationInSeconds = durationInSeconds - days * 1440; var hours = Math.floor(durationInSeconds / 60); durationInSeconds = durationInSeconds - hours * 60; var dur = "PT"; if (days > 0) { dur += days + "D"; } if (hours > 0) { dur += hours + "H"; } dur += durationInSeconds + "M"; return dur; } // Video JsonLd duration convertor ends. // Add height received from child iframe on inline embeds starts // window.addEventListener("message", receiveMessage, false); function receiveMessage(event) { if (event !== null && typeof event === "object") { if ( event.origin.indexOf("media.flickfusion.net") > -1 && JSON.parse(event.data).action == "no_modal" && document.getElementById("ff_link_iframe") ) { document.getElementById("ff_link_iframe").style.height = JSON.parse(event.data).body_height + "px"; } } } // Add height received from child iframe on inline embeds ends // Filter polyfill if (!Array.prototype.filter) { Array.prototype.filter = function (func, thisArg) { 'use strict'; if (!((typeof func === 'Function' || typeof func === 'function') && this)) throw new TypeError(); var len = this.length >>> 0, res = new Array(len), // preallocate array t = this, c = 0, i = -1; if (thisArg === undefined) { while (++i !== len) { // checks to see if the key was set if (i in this) { if (func(t[i], i, t)) { res[c++] = t[i]; } } } } else { while (++i !== len) { // checks to see if the key was set if (i in this) { if (func.call(thisArg, t[i], i, t)) { res[c++] = t[i]; } } } } res.length = c; // shrink down array to proper size return res; }; } // Get Json data -- ends // Get Closest Element Polyfill if (!Element.prototype.matches) { Element.prototype.matches = Element.prototype.msMatchesSelector || Element.prototype.webkitMatchesSelector; } if (!Element.prototype.closest) { Element.prototype.closest = function (s) { var el = this; do { if (el.matches(s)) return el; el = el.parentElement || el.parentNode; } while (el !== null && el.nodeType === 1); return null; }; } // Foreach polyfill if ("NodeList" in window && !NodeList.prototype.forEach) { NodeList.prototype.forEach = function (callback, thisArg) { thisArg = thisArg || window; for (var i = 0; i < this.length; i++) { callback.call(thisArg, this[i], i, this); } }; } loadJSCSSFile(_mediaHostURL + "/videos/global/open_ff_window_new.js", "js"); loadButtons(); runDynamicButtonsAddedFun(); var dynamicButtonsAdded = function (dynamicSnippet) { if(_profilesBag[dynamicSnippet.getAttribute('ff_client')] === undefined){ var verifyClientMultiProfileDynamic = _verifyHostURL + "ff_verify_client.php?client_id=" + dynamicSnippet.getAttribute('ff_client'); fetchJsonp(verifyClientMultiProfileDynamic, { timeout: 25000, }).then(function (response) { return response.json(); }).then(function (multiClientDetails) { if(multiClientDetails.code === 200){ multiClientDetails.client_data.data.forEach(function (clientData, index, arrayData) { _profilesBag[clientData.client_fk] = clientData; if(index+1 === arrayData.length){ checkVehicleData(dynamicSnippet); } }); } }).catch(function (reason) { console.log('parsing failed', reason); }) }else{ checkVehicleData(dynamicSnippet); } } function runDynamicButtonsAddedFun() { var observer = new MutationObserver(function (mutations) { runButtonGenerate(mutations); }); observer.observe(document, { attributes: true, childList: true, characterData: true, subtree: true }); function runButtonGenerate(data) { data.filter(function (element) { if (element.addedNodes.length === 1 && element.addedNodes[0].id === 'ff_link' && !isElementHidden(element) && !(element.addedNodes[0].hasAttribute('verified'))) { dynamicButtonsAdded(element.addedNodes[0]); } if (element.addedNodes.length > 1) { element.addedNodes.forEach(function (item) { if ((item instanceof Element || item instanceof HTMLDocument) && !isElementHidden(item)) { if (item.id === 'ff_link' && !(item.hasAttribute('verified'))) { dynamicButtonsAdded(item); } else { generateNewlyAddedButtonsSet(item); } } }) } }); function generateNewlyAddedButtonsSet(ButtonsList) { if (ButtonsList.querySelectorAll('#ff_link').length > 0) { ButtonsList.querySelectorAll('#ff_link').forEach(function (runSnipp) { if (!(runSnipp.hasAttribute('verified'))) { dynamicButtonsAdded(runSnipp); } }) } } } } } if (window._flickFusionScritpLoaded_Tag === undefined) { if (!(typeof Promise !== "undefined" && Promise.toString().indexOf("[native code]") !== -1)) { loadFFScript("//media.flickfusion.net/videos/global/es6-promise.polyfill.js", function () { setTimeout(function () { FlickFusionExecuter(); }, 1000); }); }else{ setTimeout(function () { FlickFusionExecuter(); }, 1000); } function loadFFScript(url, callback) { var head = document.getElementsByTagName("head")[0]; var script = document.createElement("script"); script.type = "text/javascript"; script.src = url; var done = false; script.onload = script.onreadystatechange = function () { if (!done && (!this.readyState || this.readyState == "loaded" || this.readyState == "complete")) { done = true; callback(); script.onload = script.onreadystatechange = null; head.removeChild(script); } }; head.appendChild(script); } window._flickFusionScritpLoaded_Tag = true; }