`, "current_news_slug":"highly-processed-food-affects-memory-study20211014224602", "meta_html":`
`, "curr_news_url":"/news/lifestyle/food/highly-processed-food-affects-memory-study20211014224602", "title":"Highly processed food affects memory: Study" }]; //console.log('IntersectionObserver' in window) var initIntersectionObserver = function(el,callback){ //intit intersection observer for scrolling element var func = function(entries) { //console.log(entries) //log all enteries entries.forEach(entry => { if(entry.isIntersecting){ //check every entry while they are intersecting //console.log(entry) callback(entry);//callbacks } }); } var observer = new IntersectionObserver(func); $(el).each(function(i,e){ observer.observe(e); }); } //initIntersectionObserver('[data-footer]',load_more_news) function addLink(e) { e.preventDefault(); var pagelink = 'nRead more At: n' + document.location.href, copytext = $('h1.title').text() + pagelink; clipdata = e.clipboardData || window.clipboardData; //console.log(e.clipboardData,window.clipboardData) if (clipdata) { clipdata.setData('Text', copytext); } } document.addEventListener('copy', addLink); function load_more_news(ent) { var url = "/api/load-next-news/"; setTimeout(function(){ if(window.xhr==undefined){ //console.log(exclude_news,next_news_slug,loadedNews) if(count is intersecting entry while it is visiable var id = $(ent.target).data('news-id') //console.log(id,ent) if( $('[data-news-section]').last().offset().top - $(ent.target).offset().top > 200){ var arr = loadedNews.filter(function(k){ return k.current_news == id; }); replaceState(arr[0]) changeMetaTagsOnForword(arr[0]) }else{ //console.log($('[data-news-section]').last().offset().top - $(ent.target).offset().top) } } function replaceState(data){ if('state' in window.history){ var h = window.history; h.replaceState(data,data.title,data.curr_news_url) }else{ console.warn('You browser is not updated') } } }),100);