Contenu en cours de chargement...

 
 
---
---
// Add jQuery if not present if(typeof jQuery == 'undefined'){ var oScriptElem = document.createElement("script"); oScriptElem.type = "text/javascript"; oScriptElem.src = "https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"; document.getElementById("letemps_chat").appendChild(oScriptElem); //document.head.insertBefore(oScriptElem, document.getElementsByTagName("script")[0]) } if(typeof pym == 'undefined'){ var oScriptElem = document.createElement("script"); oScriptElem.type = "text/javascript"; oScriptElem.src = "https://labs.letemps.ch/chat/js/pym.min.js"; document.getElementById("letemps_chat").appendChild(oScriptElem); //document.head.insertBefore(oScriptElem, document.getElementsByTagName("script")[0]) } window.addEventListener("load", function(){ // Smooth scroll function scrollPage( pixel, duration) { if (document.getElementById('main-navbar')) { document.getElementById('main-navbar').style.display = "none"; } $('html, body').animate({scrollTop: '+='+pixel+'px'}, duration, function(){ // Force main menu to hide if (document.getElementById('main-navbar')) { setTimeout(function() { document.getElementById('main-navbar').className = document.getElementById('main-navbar').className.replace('navbar-pinned',''); document.getElementById('main-navbar').className = document.getElementById('main-navbar').className.replace('navbar-unpinned',''); document.getElementById('main-navbar').className += ' navbar-unpinned'; document.getElementById('main-navbar').style.display = ''; }, duration); } }); } var pymParent = new pym.Parent("letemps_chat", "https://labs.letemps.ch/chat/live.html?chat=forward-2018", {}); // &partner=XXX pymParent.onMessage("reload", function(data) { location.reload(); }); pymParent.onMessage("removeloader", function(data) { if(document.getElementById('chat_loader')!== null){ document.getElementById('chat_loader').parentNode.removeChild(document.getElementById('chat_loader')); } }); pymParent.onMessage("scrollTo", function(data) { console.log('scrollTo '+data); var chatOffset = document.getElementById("letemps_chat").getBoundingClientRect().top; var pixels = parseInt(chatOffset,10) + parseInt(data,10); scrollPage( pixels, 500); }); pymParent.onMessage("scroll", function(data) { //var pgYoff = window.pageYOffset || document.body.scrollTop || document.documentElement.scrollTop; scrollPage( parseInt(data, 10), 500); }); // Scroll window for a given number of pixels if newly inserted/modified/removed item is above the visible part of the page pymParent.onMessage("scrollIfAbove", function(data) { data = data.split('__'); // [new article offset, pix, time to go] articleOffset = document.getElementById("letemps_chat").getBoundingClientRect().top + parseInt(data[0],10); if( articleOffset < 0 ){ var delay = parseInt(data[2],10) - Date.now(); setTimeout(function() { scrollPage( parseInt(data[1], 10), 500); }, delay); } }); pymParent.onMessage("warn", function(data) { data = data.split('__'); // [articles offset, new article offset, time, message] // Warn only if page is scrolled at least to articles var articlesOffset = document.getElementById("letemps_chat").getBoundingClientRect().top + parseInt(data[0],10); var chatOffset = document.getElementById("letemps_chat").getBoundingClientRect().top; if(articlesOffset <= 0){ // feed warn div document.getElementById("warnNewArticleTime").innerHTML = data[2]; document.getElementById("warnNewArticleMessage").innerHTML = data[3]; document.getElementById("warnNewArticle").onclick = function () { var pixels = parseInt(chatOffset,10) + parseInt(data[1],10); scrollPage( parseInt(pixels ,10) ,500); document.getElementById("warnNewArticle").style.display = "none"; }; document.getElementById("warnNewArticle").style.display = "block"; setTimeout(function() { document.getElementById("warnNewArticle").style.display = "none"; }, 3000); } }); // Provide main URL to child for email alert pymParent.sendMessage('parentURL', window.location.href); }, false );
également interessant