if(thirdPartyJS == '1'){self.COMSCORE && COMSCORE.beacon({c1: "2", c2: "6683813"});} var BASE_URL = ''; var domain = window.location.host; var story_json = ''; var newsscroll = true; $(window).scroll(function() { if ($(this).scrollTop()>100){ $('nav').addClass("nav-fxd"); $('nav li.for-logo').addClass("add-logo"); }else{ $('nav').removeClass("nav-fxd"); $('nav li.for-logo').removeClass("add-logo"); } }); $(document).ready(function(){ /*Header*/ $(".mbl-nav").click(function(){ $(".mobile-bg").toggle(); $(".mbl-nav").addClass("afterclick"); $(".mobile-navigation").animate({width: 'toggle'}, 'slow'); $("body").toggleClass("ovrflhdn"); $(".mbl-nav-clbx").css({"display":"block"}); }); $(".mbl-nav-clbx").click(function(){ $(".mbl-nav-clbx").css({"display":"none"}); $(".mbl-nav").removeClass("afterclick"); $(".mobile-bg").toggle(); $(".mobile-navigation").animate({width: 'toggle'}, 'slow'); }); $(".mobile-bg").click(function(){ $(".mbl-nav-clbx").css({"display":"none"}); $(".mbl-nav").removeClass("afterclick"); $(".mobile-bg").toggle(); $(".mobile-navigation").animate({width: 'toggle'}, 'slow'); }); $("#show-srch-forweb").click(function(){ $(".exp-search").slideToggle(); }); $(".srch-for-mbl").click(function(){ $(".exp-search-formobile").slideToggle(); }); $(".nav-rgt-links li:first-child").click(function(){ $(".nav-rgt-links li em").toggleClass("addcls"); $(".nav-rgt-inside-links").slideToggle('fast'); }); $('.nws-tab ul li').on('click', function(e){ e.preventDefault(); var $this = $(this); $this.addClass('active').siblings('.nws-tab ul li').removeClass('active'); var tab = $this.data('tag'); $('ul.tnl_listing').hide(); $('ul.'+tab).show(); }); /*Header End*/ var story_json_arr = $("#moreStoryjson").val(); var story_json = story_json_arr; var post_url = $(".article_page:first").attr('data-url'); $(".scroll-paginate").fadeIn(2000); }); var post_html = ''; var monthNames = ["Jan", "Feb", "Mar", "Apr", "May", "Jun","Jul", "Aug", "Sept", "Oct", "Nov", "Dec"]; var fullDatetime = ''; var date = ''; var tags_arr = ''; var slot_id = ''; var slot_html = ''; var post_title = ''; var div_id =''; var post_data = ''; var page_count; var vdo_div_id =''; page_count = 2; var page_nav_id = ''; var scrll_to_pg_fn =''; var categoryName = ''; function parseHtmlEnteties(str) { return str.replace(/&#([0-9]{1,3});/gi, function(match, numStr) { var num = parseInt(numStr, 10); // read num as normal number return String.fromCharCode(num); }); } function createAd1(slot_id,section,type){ var section = findCatWiseDFP(section); googletag.cmd.push(function() { if(type == 'web') var slot = googletag.defineSlot('/1039154/Hindi_News18/Hindi_News18_'+section+'/Hindi_News18_'+section+'_Internal/Hindi_News18_'+section+'_Internal_300x250', [300, 250], slot_id).addService(googletag.pubads()); else{ var slot = googletag.defineSlot('/1039154/Hindi_News18_Wap/Hindi_News18_Wap_'+section+'/Hindi_News18_Wap_'+section+'_Internal/Hindi_News18_Wap_'+section+'_Internal_300x250', [300, 250], slot_id).addService(googletag.pubads()); } // Display has to be called before // refresh and after the slot div is in the page. googletag.display(slot_id); googletag.pubads().refresh([slot]); }); } function createAd2(slot_id,section,type){ var section = findCatWiseDFP(section); googletag.cmd.push(function() { if(type == 'web') var slot = googletag.defineSlot('/1039154/Hindi_News18/Hindi_News18_'+section+'/Hindi_News18_'+section+'_Internal/Hindi_News18_'+section+'_Internal_300x600', [300, 600], slot_id).addService(googletag.pubads()); else{ var slot = googletag.defineSlot('/1039154/Hindi_News18_Wap/Hindi_News18_Wap_'+section+'/Hindi_News18_Wap_'+section+'_Internal/Hindi_News18_Wap_'+section+'_Internal_300x250_2', [300, 250], slot_id).addService(googletag.pubads()); } // Display has to be called before // refresh and after the slot div is in the page. googletag.display(slot_id); googletag.pubads().refresh([slot]); }); } function createAd3(slot_id,section,type){ var section = findCatWiseDFP(section); googletag.cmd.push(function() { if(type == 'web') var slot = googletag.defineSlot('/1039154/Hindi_News18/Hindi_News18_'+section+'/Hindi_News18_'+section+'_Internal/Hindi_News18_'+section+'_Internal_728x90_2', [728, 90], slot_id).addService(googletag.pubads()); else{ var slot = googletag.defineSlot('/1039154/Hindi_News18_Wap/Hindi_News18_Wap_Raajneeti/Hindi_News18_Wap_Raajneeti_Internal/Hindi_News18_Wap_Raajneeti_Internal_Sticky_320x50', [300, 250], slot_id).addService(googletag.pubads()); } // Display has to be called before // refresh and after the slot div is in the page. googletag.display(slot_id); googletag.pubads().refresh([slot]); }); } function createAdweb300x600(slot_id,section){ googletag.cmd.push(function() { var slot = googletag.defineSlot('/1039154/Hindi_News18/Hindi_News18_'+section+'/Hindi_News18_'+section+'_Internal/Hindi_News18_'+section+'_Internal_300x600', [300, 600], slot_id).addService(googletag.pubads()); googletag.display(slot_id); googletag.pubads().refresh([slot]); }); } function createAdweb728x90(slot_id,section){ googletag.cmd.push(function() { var slot = googletag.defineSlot('/1039154/Hindi_News18/Hindi_News18_'+section+'/Hindi_News18_'+section+'_Internal/Hindi_News18_'+section+'_Internal_728x90', [728, 90], slot_id).addService(googletag.pubads()); googletag.display(slot_id); googletag.pubads().refresh([slot]); }); } function createAdweb(slot_id,section){ googletag.cmd.push(function() { var slot = googletag.defineSlot('/1039154/Hindi_News18/Hindi_News18_'+section+'/Hindi_News18_'+section+'_Internal/Hindi_News18_'+section+'_Internal_300x250', [300, 250], slot_id).addService(googletag.pubads()); googletag.display(slot_id); googletag.pubads().refresh([slot]); }); } function createAdWebNative(slot_id){console.log("native-"+slot_id); googletag.cmd.push(function() { var slot = googletag.defineSlot('/1039154/Hindi_News18/Hindi_News18_Ros/Hindi_News18_ROS_Native_Inhebhipadhe', [285, 105], slot_id).addService(googletag.pubads()); googletag.display(slot_id); googletag.pubads().refresh([slot]); }); } function findCatWiseDFP(section){ var web_dfp_tags=''; switch(section){ case 'nation': web_dfp_tags='Desh'; break; case 'politics': web_dfp_tags='Raajneeti'; break; case 'entertainment': case 'interview': case 'controversy': case 'tv': case 'film-review': case 'bollywood': case 'hollywood': web_dfp_tags='Manoranjan'; break; case 'world': web_dfp_tags='Duniya'; break; case 'sports': web_dfp_tags='Khel'; break; case 'city-khabrain': web_dfp_tags='City'; break; case 'business': web_dfp_tags='Desh'; break; case 'lifestyle': case 'gadgets': case 'history': case 'auto': case 'rishte': case 'health': web_dfp_tags='Lifestyle'; break; case 'ajab-gajab': web_dfp_tags='AjabGajab'; break; case 'astro': web_dfp_tags='Astro'; break; case 'cricket': web_dfp_tags='Cricket'; break; default: web_dfp_tags='Desh'; break; } return web_dfp_tags; } $(function () { var currentHash = "#one";//$("#page1").data('url'); var article_url =''; var url_arr = ''; var id_arr = ''; var id_url_arr = ''; var count_scroll_page_id = ''; var scroll_page = ''; var isbackScoll=false; var previousScroll = 0; var is_hide_ads; $(document).scroll(function () { var currentScroll = $(this).scrollTop(); $('.article_page').each(function () { var top = window.pageYOffset; var distance = top - $(this).offset().top + 50; var hash = $(this).attr('data-url'); var dimension7 = $(this).data('dimension'); var title = $(this).attr('data-title'); var thisPostID = $(this).attr('data-id'); var thisPostSec = $(this).attr('data-section'); var isSkipCtn = $(this).attr('data-skipctn'); count_scroll_page_id = $(this).attr('id'); scroll_page = count_scroll_page_id.split("page"); if (distance < 10 && distance > -10 && currentHash != hash ) { is_hide_ads = ($(this).attr('data-objection')==0) ? true :false; var arrLen = $.map(related_Ids, function(n, i) { return i; }).length; if(scroll_page[1] == arrLen+1) $(".nxStory:last").hide(); if(!isbackScoll && currentHash!="#one"){ if(thirdPartyJS == '1'){ ga('set', {location: 'https://hindi.news18.com'+hash, page: hash}); if(dimension7){ ga("set","dimension7",dimension7); } ga("send", "pageview"); if(isOutbrainOff=="yes"){ ga('require', 'GTM-NLPB9LL'); } ga('send', 'pageview', hash); ga('send', 'event', 'Next_Story_Appear_'+scroll_page[1], 'scroll', 'scroll_next_story', 1, {'nonInteraction': 1}); ga('send', 'event', ' scroll_index_D ', ' scroll', 'article', 1, {'nonInteraction': 1}); self.COMSCORE && COMSCORE.beacon({c1: "2", c2: "6683813"}); pageview_candidate_comescore(); } } currentHash = hash; document.title = title; url_arr = currentHash.split("/"); article_url = url_arr[url_arr.length - 1]; id_url_arr = article_url.split('-'); id_arr = id_url_arr[id_url_arr.length - 1].split('.'); $(".scroll_li").removeClass('active'); $("#bottomBar_id_"+id_arr[0]).addClass('active'); $(".disqus_comment_bx").show(); history.replaceState({}, '', currentHash); slot_id = "rightads300x250_"+thisPostID; if(thirdPartyJS == '1'){ if (!navigator.userAgent.match(/Android/i) && !navigator.userAgent.match(/webOS/i) && !navigator.userAgent.match(/iPhone/i) && !navigator.userAgent.match(/iPod/i) && !navigator.userAgent.match(/iPad/i) && !navigator.userAgent.match(/Blackberry/i)) { if(is_hide_ads){ var slotName = 'sidebar_300x250_' + new Date().getTime(); $('#rightads300x250').html( $( '
' ).attr( 'id',slotName ) ); createAdweb(slotName,thisPostSec); createAdWebNative('native_ad_article_285x105_'+thisPostID); var slotName600 = 'sidebar_300x600_' + new Date().getTime(); $('#rightad300x600').html( $( '
' ).attr( 'id',slotName600 ) ); createAdweb300x600(slotName600,thisPostSec); var slotName728 = 'header_928x90_' + new Date().getTime(); $('#headerAds728x90').html( $( '
' ).attr( 'id',slotName728 ) ); createAdweb728x90(slotName728,thisPostSec); }else{ load_inhouse_ads(); } } if (!navigator.userAgent.match(/Android/i) && !navigator.userAgent.match(/webOS/i) && !navigator.userAgent.match(/iPhone/i) && !navigator.userAgent.match(/iPod/i) && !navigator.userAgent.match(/iPad/i) && !navigator.userAgent.match(/Blackberry/i)) { //createAd1(slot_id,thisPostSec,'web'); }else{ slot_id = "mobil300x250_"+thisPostID; if ($(slot_id).exists() == false) { createAd1(slot_id,thisPostSec,'mobile'); } } } slot_id = ''; slot_id = "rightad300x600_"+thisPostID; slot_id3 = "middleAds728x90_2_"+thisPostID; if(thirdPartyJS == '1'){ if (!navigator.userAgent.match(/Android/i) && !navigator.userAgent.match(/webOS/i) && !navigator.userAgent.match(/iPhone/i) && !navigator.userAgent.match(/iPod/i) && !navigator.userAgent.match(/iPad/i) && !navigator.userAgent.match(/Blackberry/i)) { if ($(slot_id).exists() == false && is_hide_ads) { createAd2(slot_id,thisPostSec,'web'); createAd3(slot_id3,thisPostSec,'web'); } }else{ slot_id = "mobil300x250_2_"+thisPostID; if ($(slot_id).exists() == false) { createAd2(slot_id,thisPostSec,'mobile'); } } } } if(distance > 500 && distance < 600 && currentHash != hash ) { // alert(currentHash +"=500=="+ hash); currentHash = hash; url_arr = currentHash.split("/"); article_url = url_arr[url_arr.length - 1];//alert(article_url); document.title = title; history.replaceState({}, '', currentHash); id_url_arr = article_url.split('-'); id_arr = id_url_arr[id_url_arr.length - 1].split('.'); $(".scroll_li").removeClass('active'); $("#bottomBar_id_"+id_arr[0]).addClass('active'); if(!isbackScoll && currentHash!="#one" && thirdPartyJS == '1'){ self.COMSCORE && COMSCORE.beacon({c1: "2", c2: "6683813"}); //callComScore(); ga('set', {location: 'https://hindi.news18.com'+hash, page: hash}); ga("send", "pageview"); pageview_candidate_comescore(); currentHash = hash; }else{ is_hide_ads = ($(this).attr('data-objection')==0) ? true :false; if(!is_hide_ads){ load_inhouse_ads(); } } } }); if (currentScroll < previousScroll) { console.log("back"); isbackScoll=true }else{ isbackScoll=false; } previousScroll = currentScroll; }); }); jQuery.fn.exists = function(){ return this.length > 0; } function pushGA(){ (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) })(window,document,'script','https://www.google-analytics.com/analytics.js','ga'); ga('create', 'UA-156703-3', 'auto'); ga('send', 'pageview'); } var _comscore function callComScore(){ _comscore = _comscore || []; _comscore.push({ c1: "2", c2: "6683813" }); (function() {var s = document.createElement("script"), el = document.getElementsByTagName("script")[0]; s.async = true; s.src = (document.location.protocol == "https:" ? "https://sb" : "http://b") + ".scorecardresearch.com/beacon.js"; el.parentNode.insertBefore(s, el); })(); } $(document).ready(function() { var count=1; var page_offset; var page_offset_top; var scroll_top; var win_height; var scroll_pagi_slider; var slide_move=0; scroll_pagi_slider = $('.scroll-paginate .bxslider').bxSlider({ pager:false, auto:false, slideWidth: 405, minSlides: 2, maxSlides: 5, slideMargin: 0, infiniteLoop:false, hideControlOnEnd:true }); var newsscroll= true; var total_li = $('.paginate-section-nav').length; $(document).scroll(function(){ count = (count > parseInt(total_li) )?$('.paginate-section-nav').length:count; if($(window).height() > 200 && newsscroll==true){ loadarticles(isOutbrainOff); newsscroll=false; } page_offset = $("#page"+count).offset().top - 100; var $page_section = $("#page"+count); page_offset_top = page_offset; scroll_top = $(window).scrollTop(); win_height = $(window).height(); var page_pos = scroll_top - page_offset_top; var page_height = $page_section.height(); var page_scrollpercent = 100-((page_height-page_pos)/page_height)*100; if(page_offset_top>scroll_top){ if(count>1)count--; slide_move = count; scroll_pagi_slider.goToPrevSlide(); } if(page_height3){ slide_move=count; scroll_pagi_slider.goToNextSlide(); } } count = (count > parseInt(total_li))?$('.paginate-section-nav').length:count; if($(window).scrollTop()>page_offset){ $('.paginate-section-nav').removeClass('active'); if(page_scrollpercent<=100){//alert('#paginav'+count+'.paginate-section-nav'); $('#paginav'+count+'.paginate-section-nav').addClass('active'); //START: io tagging scroll if(!$( "#page"+count ).hasClass( "iotrue" )){ var _url = $("#page"+count).attr("data-article-url"); var _title = $("#page"+count).attr("data-title"); var _section = $("#page"+count).attr("data-iosection"); var _author = $("#page"+count).attr('data-author'); var _articleDate = $("#page"+count).attr('data-iodate'); var _articleTotalwords = $("#page"+count).attr('data-iolength'); getIOScript(_url, _title, _author, _section, _articleTotalwords, _articleDate); $( "#page"+count ).addClass('iotrue'); } //END: io tagging scroll } } if(count == parseInt(total_li)) $('#paginav'+count+'.paginate-section-nav').addClass('active'); $('.paginate-section-nav .scroll_progress').css('width',''); $('.paginate-section-nav').css('background','none'); $('#paginav'+count+'.paginate-section-nav.active').css('background','#ddd'); $('#paginav'+count+'.paginate-section-nav.active .scroll_progress').css('width',''+page_scrollpercent+'%'); }); }); function scrollToPage(pageno){ $('html, body').animate({scrollTop: $('#page'+pageno+'').offset().top - 75}, 2000); ga('send', 'event', 'Next_Story_Bottom_Slider', 'click', 'click_next_story', 1, {'nonInteraction': 1}); } function scrollToaDiv(div){ $('html, body').animate({scrollTop: $(div).offset().top - 75}, 2000); } // How to force async functions to execute sequentially // by using deferred pipe chaining. // The master deferred. var dfd = $.Deferred(), // Master deferred dfdNext = dfd; // Next deferred in the chain x = 0, // Loop index values = []; // Simulates $.ajax, but with predictable behaviour. // You only need to understand that higher 'value' param // will finish earlier. simulateAjax = function (value,cnt,isOutbrainOff) { var _contextualVal = ''; if(cnt == 2){ _contextualVal = (_ajaxContextual)?_ajaxContextual:''; } if(isOutbrainOff=="no"){ var ajaxurlcall='/scroll/article/'+value+'/'+cnt+'.html?isoutbrain='+isOutbrainOff; }else{ var ajaxurlcall='/scroll/article/'+value+'/'+cnt+'.html'; } var dfdAjax = $.Deferred(); setTimeout( function () { $.ajax({ url: ajaxurlcall, type: 'GET', data:{contval: _contextualVal}, dataType : 'html', success:function(res){ $('#content_'+value).html(res); $('li[data-id="'+value+'"]').removeClass('dact'); $('li[data-id="'+value+'"]').find('a').append(''); // Call Outbrain infinite scroll function OBR.extern.researchWidget(); } }).complete(function(){ // resolve when complete always. Even on failure we // want to keep going with other requests dfdAjax.resolve(); }); }, 1000); return dfdAjax.promise(); }; // This would be a user function that makes an ajax request. // In normal code you'd be using $.ajax instead of simulateAjax. var requestAjax = function (value,cnt,isOutbrainOff) { return simulateAjax(value,cnt,isOutbrainOff); }; // Start the pipe chain. You should be able to do // this anywhere in the program, even // at the end,and it should still give the same results. dfd.resolve(); // Deferred pipe chaining. // What you want to note here is that an new // ajax call will not start until the previous // ajax call is completely finished. var loadarticles = function(isOutbrainOff){ $('#infinite-scroll').animate({'bottom':'0px'}, 1000); var cl = 2; $.each(related_Ids, function(index, id){ values.push(id); dfdNext = dfdNext.pipe(function () { var value = values.shift(); return requestAjax(value,cl,isOutbrainOff). done(function(response) { // Process the response here. cl++; }); }); }); }