var programari_include_container = null; var addEvent = function (elem, type, eventHandle) { if (elem == null || typeof (elem) == 'undefined') return; if (elem.addEventListener) { elem.addEventListener(type, eventHandle, false); } else if (elem.attachEvent) { elem.attachEvent("on" + type, eventHandle); } else { elem["on" + type] = eventHandle; } }; function OnResize() { var container = GetContainer(); if (container == null) return; var iframe = document.getElementById(programari_include_container + '_iframe'); //var w = Math.max(document.documentElement.clientWidth, window.innerWidth || 0); //var h = Math.max(document.documentElement.clientHeight, window.innerHeight || 0); //h -= 40; //container.style.height = h + 'px'; //if(container.offsetHeight < 380) // container.style.height = '380px'; var i_width = container.offsetWidth - 2; var i_height = container.offsetHeight - 2; iframe.width = i_width + 'px'; iframe.height = i_height + 'px'; //console.log('resize to: ' + i_width + ',' + i_height); } function GetContainer() { var container = document.getElementById(programari_include_container); if (container == null) { // search by class name var divs = document.getElementsByClassName(programari_include_container); if (divs.length == 1) { container = divs[0]; } else { return null; } } return container; } function setupReceiveMessageFromChild(){ var eventMethod = window.addEventListener ? "addEventListener" : "attachEvent"; var eventer = window[eventMethod]; var messageEvent = eventMethod == "attachEvent" ? "onmessage" : "message"; // Listen to message from child window eventer(messageEvent,function(e) { var key = e.message ? "message" : "data"; var data = e[key]; //console.log(data); if(data === 'expand'){ var container = GetContainer(); if(container == null) return; if(container.className.indexOf('full-screen-iframe') < 0) container.className = container.className + ' full-screen-iframe'; OnResize(); } if(data === 'collapse'){ var container = GetContainer(); if(container == null) return; container.className = container.className.replace(/\bfull-screen-iframe\b/,''); OnResize(); } },false); var style = document.createElement('style'); style.type = 'text/css'; style.innerHTML = '.full-screen-iframe {z-index: 9999; width: 100% !important; height: 100% !important; position: fixed; top: 0; left: 0; background-color: #fff; }'; document.getElementsByTagName('head')[0].appendChild(style); //document.getElementById('someElementId').className = 'cssClass'; } function InitializareProgramariInternal2(config, id_container, clear, local) { programari_include_container = id_container; var container = GetContainer(); if (container == null) return; if (clear) { while (container.firstChild) { container.removeChild(container.firstChild); } } var height = getParameterByName('h'); if (height != null) { container.style.height = height + 'px'; } //var base_url = 'http://gdio.ro'; var base_url = 'https://gdio.ro/programari'; if (local) base_url = 'http://localhost:2994/programari'; //container.style.overflowY = 'scroll'; //container.style.WebkitOverflowScrolling = 'touch'; var iframe = document.createElement('iframe'); iframe.id = id_container + '_iframe'; var clinica = null; var doctor = null; if (config.clinica != null) clinica = config.clinica; else if (config.doctor != null) doctor = config.doctor; else clinica = config; // fallback for www.bote-san.ro iframe.frameBorder = 0; container.appendChild(iframe); addEvent(window, "resize", OnResize); OnResize(); scrollIt(container); setupReceiveMessageFromChild(); /* window.addEventListener("message", function (e) { if (e.origin !== base_url) { return; } window.scrollTo(0, 0); console.log('window.addEventListener - message' + e.data); }, false); */ var version = 'v035'; var test_version = getParameterByName('version'); if(test_version != null) version = test_version; var src = base_url + '/' + version + '/Start.aspx?'; if (clinica != null) src += 'c=' + clinica; if (doctor != null) src += 'o=' + doctor; var current_url = window.location.href; if (current_url.indexOf('?') > 0) src += '&' + current_url.substr(current_url.indexOf('?') + 1); src += '&domain=' + window.location.hostname; CONSOLE(src); iframe.src = src; } /// https://pawelgrzybek.com/page-scroll-in-vanilla-javascript/ function scrollIt(destination, duration = 200, easing = 'linear', callback) { const easings = { linear(t) { return t; }, easeInQuad(t) { return t * t; }, easeOutQuad(t) { return t * (2 - t); }, easeInOutQuad(t) { return t < 0.5 ? 2 * t * t : -1 + (4 - 2 * t) * t; }, easeInCubic(t) { return t * t * t; }, easeOutCubic(t) { return (--t) * t * t + 1; }, easeInOutCubic(t) { return t < 0.5 ? 4 * t * t * t : (t - 1) * (2 * t - 2) * (2 * t - 2) + 1; }, easeInQuart(t) { return t * t * t * t; }, easeOutQuart(t) { return 1 - (--t) * t * t * t; }, easeInOutQuart(t) { return t < 0.5 ? 8 * t * t * t * t : 1 - 8 * (--t) * t * t * t; }, easeInQuint(t) { return t * t * t * t * t; }, easeOutQuint(t) { return 1 + (--t) * t * t * t * t; }, easeInOutQuint(t) { return t < 0.5 ? 16 * t * t * t * t * t : 1 + 16 * (--t) * t * t * t * t; } }; const start = window.pageYOffset; const startTime = 'now' in window.performance ? performance.now() : new Date().getTime(); const documentHeight = Math.max(document.body.scrollHeight, document.body.offsetHeight, document.documentElement.clientHeight, document.documentElement.scrollHeight, document.documentElement.offsetHeight); const windowHeight = window.innerHeight || document.documentElement.clientHeight || document.getElementsByTagName('body')[0].clientHeight; const destinationOffset = typeof destination === 'number' ? destination : destination.offsetTop; const destinationOffsetToScroll = Math.round(documentHeight - destinationOffset < windowHeight ? documentHeight - windowHeight : destinationOffset); if ('requestAnimationFrame' in window === false) { window.scroll(0, destinationOffsetToScroll); if (callback) { callback(); } return; } function scroll() { const now = 'now' in window.performance ? performance.now() : new Date().getTime(); const time = Math.min(1, ((now - startTime) / duration)); const timeFunction = easings[easing](time); window.scroll(0, Math.ceil((timeFunction * (destinationOffsetToScroll - start)) + start)); if (window.pageYOffset === destinationOffsetToScroll) { if (callback) { callback(); } return; } requestAnimationFrame(scroll); } scroll(); } function getParameterByName(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, " ")); } function CONSOLE(text) { var field = 'debug'; var url = window.location.href; var debug = false; if (url.indexOf('?' + field + '=') != -1) debug = true; else if (url.indexOf('&' + field + '=') != -1) debug = true; if (debug) console.log(text); } function InitializareProgramari2Local(account, id_container, clear) { InitializareProgramariInternal2(account, id_container, clear, true); } function InitializareProgramari2(account, id_container, clear) { InitializareProgramariInternal2(account, id_container, clear, false); } function InitializareProgramari(account, id_container, clear) { } document.addEventListener("DOMContentLoaded", function(){ InitializareProgramari2( { "clinica": "finas.medical" }, 'programari', false); }); window.addEventListener("load", function(){ // .... });