(function () { var scripts = document.getElementsByTagName('script'); var current = scripts[scripts.length-1].src; var f_eventurl = current.match(/^(.*)growing.js/)[1]; var client = current.match(/client=([^&]+)/); if (client) client = client[1] + ".html"; else client = "index.html"; f_eventurl = f_eventurl + client; var stream = ""; var streammatch = current.match(/stream=([^&]+)/); if (streammatch) stream = "&stream=" + streammatch[1]; var f_body = document.body, f_html = document.documentElement, f_allowed = false; var f_frameid = "flypsiteFrame" + Math.round(Math.random()*10e15); var f_orientat = 0; document.write(''); window.addEventListener('message', function(e) { var message = e.data; var marr = message.split(':'); //console.log(marr); var el = document.getElementById(f_frameid); el.style.height = (marr[1]) + "px"; f_allowed = true; }); window.addEventListener("orientationchange", function() { // reload iframe var el = document.getElementById(f_frameid); f_orientat = (f_orientat + 1) % 2; el.setAttribute('src', f_eventurl +'?'+ f_frameid +'&allowmessaging'+stream+'&' + f_orientat); window.location.hash = '#top'; window.scroll(0,0); }, false); window.addEventListener('scroll', function(e){ var f_height = Math.max( f_body.scrollHeight, f_body.offsetHeight, f_html.clientHeight, f_html.scrollHeight, f_html.offsetHeight ); document.getElementById(f_frameid).contentWindow.postMessage('frame-top:' + document.getElementById(f_frameid).getBoundingClientRect().top, '*'); if (window.pageYOffset > f_height - window.innerHeight - 130 && f_allowed) { document.getElementById(f_frameid).contentWindow.postMessage('load-more', '*'); f_allowed = false; } }); document.f_loaded = function (){ document.getElementById(f_frameid).style.height = '800px'; document.getElementById(f_frameid).contentWindow.postMessage('load-more', '*'); } }());