“;
forYoudata += “”;
forYoudata += “”;
forYoudata += “”;
count++;
if (i === 7) {
return false;
}
});
forYouApiResponse=forYoudata;
$(forutxt).html(‘Recommended for you’);
$(foruContent).html(forYoudata);
}
}
});
}
else if(forYouApiResponse!=”){
$(forutxt).html(‘Recommended for you’);
$(foruContent).html(forYouApiResponse);
}
}
function getUserData(){
$.ajax({
url:”https://www.hindustantimes.com/newsletter/get-active-subscription?usertoken=”+user_token,
type:”GET”,
dataType:”json”,
success: function(res){
if(res.length>0)
{
$(“[id^=loggedin]”).each(function(){
$(this).hide();
});
}
}
});
}
function postUserData(payLoad, elm){
var msgelm=$(elm).parents(“.subscribe-update”).nextAll(“#thankumsg”);
$.ajax({
url:”https://www.hindustantimes.com/newsletter/subscribe”,
type:”POST”,
data:payLoad,
contentType: “application/json”,
dataType: “json”,
success: function(res){
if(res.success===true){
$(msgelm).show();
$(“[id^=loggedin]”).each(function(){
$(this).css(“display”,”none”);
});
$(“[id^=loggedout]”).each(function(){
$(this).css(“display”,”none”);
});
}
else if(res.exceptionResponse.alreadySubscribed===true){
$(msgelm).show();
$(“[id^=loggedin]”).each(function(){
$(this).css(“display”,”none”);
});
$(“[id^=loggedout]”).each(function(){
$(this).css(“display”,”none”);
});
$(msgelm).find(“.subscribed-successfully:first span.msg”).text(res.exceptionResponse.message);
}
}
});
}
function captchverification(captchaResponse) {
$(‘#captchaResponse’).value = captchaResponse;
$(“#captcha-div”).removeClass(“block”);
$(“body”).removeAttr(“style”);
var payLoad=JSON.stringify({
“domain”: “HT”,
“emailId”: email,
“googleCaptcha”: captchaResponse,
“subscriptionTypes”: [
“daily”
]
});
postUserData(payLoad,activeElm);
}
function subscribeNewsletter(inputText)
{
activeElm=inputText;
var mailformat = /^w+([.-]?w+)*@w+([.-]?w+)*(.w{2,3})+$/;
if(inputText.val().match(mailformat))
{
inputText.focus();
email=inputText.val();
$(“#captcha-div”).addClass(“block”);
$(“body”).css(“overflow”,”hidden”);
return true;
}
else
{
alert(“You have entered an invalid email address!”);
inputText.focus();
return false;
}
}
//DFP Ads
var $dfpRightAd1 = $(‘.dfp-rightAd1-‘ + storyUuid);
var $dfpRightAd2 = $(‘.dfp-rightAd2-‘ + storyUuid);
var $dfpRightAd3 = $(‘.dfp-rightAd3-‘ + storyUuid);
var $dfpRightAd4 = $(‘.dfp-rightAd4-‘ + storyUuid);
var $dfpRightAd5 = $(‘.dfp-rightAd5-‘ + storyUuid);
var $dfpStoryAd1 = $(‘.dfp-storyAd1-‘ + storyUuid);
var $dfpStoryAd2 = $(‘.dfp-storyAd2-‘ + storyUuid);
var $dfpStoryAd3 = $(‘.dfp-storyAd3-‘ + storyUuid);
var $dfpStoryAd4 = $(‘.dfp-storyAd4-‘ + storyUuid);
var $dfpStoryAd5 = $(‘.dfp-storyAd5-‘ + storyUuid);
var $centerAd = $(‘.centerAd-‘ + storyUuid);
getPersonlizeData(”);
displayAd($dfpRightAd1,’/1055314/HT_StoryPages_300x250_Top’,[[300, 250], [300, 600]]);
displayAd($dfpRightAd2,’/3106570/HT_Desk_Story_BS_Multisize’,[‘fluid’, [300, 100]]);
var rightMiddleScrollHandler = function () {
if ($dfpRightAd3.isInViewport()) {
displayAd($dfpRightAd3, ‘/1055314/HT_StoryPages_300x250_Middle’, [[300, 250], [300, 600]]);
$(window).off(“scroll”, rightMiddleScrollHandler);
}
}
$(window).on(“scroll”, rightMiddleScrollHandler);
var rightTabRepTopScrollHandler = function () {
if ($dfpRightAd4.isInViewport()) {
displayAd($dfpRightAd4, ‘/1055314/HT_Desk_Story_TabRep_Top_Multisize’, [[300, 250], [300, 600]]);
$(window).off(“scroll”, rightTabRepTopScrollHandler);
}
}
$(window).on(“scroll”, rightTabRepTopScrollHandler);
var rightTabRepBottomScrollHandler = function () {
if ($dfpRightAd5.isInViewport()) {
displayAd($dfpRightAd5, ‘/1055314/HT_Desk_Story_TabRep_Bottom_Multisize’, [300, 250]);
$(window).off(“scroll”, rightTabRepBottomScrollHandler);
}
}
$(window).on(“scroll”, rightTabRepBottomScrollHandler);
var storyCenterScrollHandler = function () {
if ($centerAd.isInViewport()) {
displayAd($centerAd, ‘/1055314/HT_Desk_Story_ES_Top_728x90’, [728, 90]);
$(window).off(“scroll”, storyCenterScrollHandler);
}
}
$(window).on(“scroll”, storyCenterScrollHandler);
//Inline story ads
var storyAd1ScrollHandler = function () {
if ($dfpStoryAd1.isInViewport()) {
displayAd($dfpStoryAd1, storyAdList[0].ad, [728, 90]);
$(window).off(“scroll”, storyAd1ScrollHandler);
}
}
$(window).on(“scroll”, storyAd1ScrollHandler);
var storyAd2ScrollHandler = function () {
if ($dfpStoryAd2.isInViewport()) {
displayAd($dfpStoryAd2, storyAdList[1].ad, [728, 90]);
$(window).off(“scroll”, storyAd2ScrollHandler);
}
}
$(window).on(“scroll”, storyAd2ScrollHandler);
var storyAd3ScrollHandler = function () {
if ($dfpStoryAd3.isInViewport()) {
displayAd($dfpStoryAd3, storyAdList[2].ad, [728, 90]);
$(window).off(“scroll”, storyAd3ScrollHandler);
}
}
$(window).on(“scroll”, storyAd3ScrollHandler);
var storyAd4ScrollHandler = function () {
if ($dfpStoryAd4.isInViewport()) {
displayAd($dfpStoryAd4, storyAdList[3].ad, [728, 90]);
$(window).off(“scroll”, storyAd4ScrollHandler);
}
}
$(window).on(“scroll”, storyAd4ScrollHandler);
var storyAd5ScrollHandler = function () {
if ($dfpStoryAd5.isInViewport()) {
displayAd($dfpStoryAd5, storyAdList[4].ad, [728, 90]);
$(window).off(“scroll”, storyAd5ScrollHandler);
}
}
$(window).on(“scroll”, storyAd5ScrollHandler);
validateUser($(“#loggedin”),$(“#loggedout”));
if(user_token){
$(“#loggedin .subscribe-text”).html(“Subscribe to get our daily newsletter in your inbox”);
$(“#loginSub”).click(function(){
var udata=JSON.stringify({
“domain”: “HT”,
“userToken”: user_token,
“googleCaptcha”: “string”,
“subscriptionTypes”: [
“daily”
]
});
postUserData(udata,this);
});
}else{
$(“#loggedout .subscribe-text”).html(“Enter your email to get our daily newsletter in your inbox”);
$(“#subscribeBtn”).click(function(){
subscribeNewsletter($(this).prev());
});
}
function ScrollMe(uuid) {
var id = uuid.replace(‘story_’,”).trim();
id = id +”_story”;
var newid = uuid.trim();
$(‘#ulInfinite’).each(function() {
var phrase = ”;
$(this).find(‘li’).each(function(j, lix) {
var myid = $(lix).attr(‘id’);
if (myid.trim() == newid.trim())
$(lix).addClass(“active”);
else
$(lix).removeClass(“active”);
});
});
var element = document.getElementById(id);
element.scrollIntoView();
element.scrollIntoView({
behavior : “auto”,
block : “start”,
inline : “nearest”
});
$(‘html, body’).animate({
scrollTop : $(“#” + newid).offset().top – 800
}, 800, ‘swing’);
}
function InfiniteScroll() {
var nextURL = listUrl[urlCount];
var $container = $(‘.articles’).infiniteScroll({
path : function() {
return nextURL;
},
append : ‘.article’,
status : ‘.scroller-status’,
hideNav : ‘.pagination’,
loadOnScroll : false,
scrollThreshold : false
});
$container.infiniteScroll(‘loadNextPage’);
$container.on(‘history.infiniteScroll’, function(event, title, path) {
var currentID = “article_” + getStoryIdByUrl(‘https://www.hindustantimes.com/it-s-viral/slow-motion-video-of-ripples-in-ice-cube-tray-is-oddly-satisfying-watch/story-n6jwEWrbykyk2Zw3htJ0aK.html’);
var articleID = “article_” + getStoryIdByUrl(path);
document.title = title;
var temp = path.replace(‘.html’, ”).split(‘-‘);
temp = temp.reverse();
var forNid = temp[0].trim();
$(‘#ulInfinite li’).removeClass(“active”);
$(‘#story_’ + forNid).addClass(“active”);
var n = gatag.includes(articleID, 0);
if(n==false)
{
gatag.push(articleID);
showSkippablePopup();
ga(‘send’, {
hitType : ‘pageview’,
location : window.location.hostname.trim(),
title : title.trim(),
page : window.location.pathname.trim(),
dimension15 : title
});
}
window.snowplow(“trackPageView”, title);
window.snowplow(‘resetPagePing’);
if (typeof COMSCORE != ‘undefined’
&& typeof COMSCORE.beacon !== ‘undefined’) {
COMSCORE.beacon({
c1 : “2”,
c2 : “6035286”
});
}
});
$container.on(‘load.infiniteScroll’, function(event, response, path) {
urlCount++;
});
var counter = 1;
var uuid;
$container.on(‘append.infiniteScroll’, function(event, response, path, items) {
uuid= $(items).find(‘.get-uuid’).val();
var elmLogin=$(items).find(‘#loggedin’);
var elmLogout=$(items).find(‘#loggedout’);
getPersonlizeData(items);
validateUser(elmLogin,elmLogout);
if(user_token){
getUserData();
$(elmLogin).find(“.subscribe-text”).html(“Subscribe to get our daily newsletter in your inbox”);
$(items).find(“#loginSub”).click(function(){
var udata=JSON.stringify({
“domain”: “HT”,
“userToken”: user_token,
“googleCaptcha”: “string”,
“subscriptionTypes”: [
“daily”
]
});
postUserData(udata, this);
});
}else{
$(elmLogout).find(“.subscribe-text”).html(“Enter your email to get our daily newsletter in your inbox”);
$(items).find(“#subscribeBtn”).click(function(){
subscribeNewsletter($(this).prev());
});
}
var $dfpRightAd1ES = $(items).find(‘.dfp-rightAd1-‘+uuid);
var $dfpRightAd3ES = $(items).find(‘.dfp-rightAd3-‘+uuid);
var $dfpRightAd4ES = $(items).find(‘.dfp-rightAd4-‘+uuid);
var $dfpRightAd5ES = $(items).find(‘.dfp-rightAd5-‘+uuid);
var $centerAdES = $(items).find(‘.centerAd-‘ + uuid);
var $dfpStoryAd1ES = $(‘.dfp-storyAd1-‘ + uuid);
var $dfpStoryAd2ES = $(‘.dfp-storyAd2-‘ + uuid);
var $dfpStoryAd3ES = $(‘.dfp-storyAd3-‘ + uuid);
var $dfpStoryAd4ES = $(‘.dfp-storyAd4-‘ + uuid);
var $dfpStoryAd5ES = $(‘.dfp-storyAd5-‘ + uuid);
var isVideoExists = $(items).find(‘.video-js’);
var isVideo=false;
if (isVideoExists.length > 0) {
isVideo=true;
}
var rightESTopScrollHandler = function () {
if ($dfpRightAd1ES.isInViewport()) {
displayAd($dfpRightAd1ES, rightAdList[0].ad, rightAdList[0].adsizes);
$(window).off(“scroll”, rightESTopScrollHandler);
}
}
$(window).on(“scroll”, rightESTopScrollHandler);
var rightESMiddleScrollHandler = function () {
if ($dfpRightAd3ES.isInViewport()) {
displayAd($dfpRightAd3ES, rightAdList[1].ad, rightAdList[1].adsizes);
$(window).off(“scroll”, rightESMiddleScrollHandler);
}
}
$(window).on(“scroll”, rightESMiddleScrollHandler);
var rightESTabRepTopScrollHandler = function () {
if ($dfpRightAd4ES.isInViewport()) {
displayAd($dfpRightAd4ES, rightAdList[2].ad, rightAdList[2].adsizes);
$(window).off(“scroll”, rightESTabRepTopScrollHandler);
}
}
$(window).on(“scroll”, rightESTabRepTopScrollHandler);
var rightESTabRepBottomScrollHandler = function () {
if ($dfpRightAd5ES.isInViewport()) {
displayAd($dfpRightAd5ES, rightAdList[3].ad, rightAdList[3].adsizes);
$(window).off(“scroll”, rightESTabRepBottomScrollHandler);
}
}
$(window).on(“scroll”, rightESTabRepBottomScrollHandler);
var storyCenterScrollHandler = function () {
if ($centerAdES.isInViewport()) {
displayAd($centerAdES, ‘/1055314/HT_Desk_Story_ES_Top_728x90′, [728, 90]);
$(window).off(“scroll”, storyCenterScrollHandler);
}
}
$(window).on(“scroll”, storyCenterScrollHandler);
//Story Inline ads
var storyESAd1ScrollHandler = function () {
if ($dfpStoryAd1ES.isInViewport()) {
displayAd($dfpStoryAd1ES, storyAdList[0].ad2, [728, 90]);
$(window).off(“scroll”, storyESAd1ScrollHandler);
}
}
$(window).on(“scroll”, storyESAd1ScrollHandler);
var storyESAd2ScrollHandler = function () {
if ($dfpStoryAd2ES.isInViewport()) {
displayAd($dfpStoryAd2ES, storyAdList[1].ad2, [728, 90]);
$(window).off(“scroll”, storyESAd2ScrollHandler);
}
}
$(window).on(“scroll”, storyESAd2ScrollHandler);
var storyESAd3ScrollHandler = function () {
if ($dfpStoryAd3ES.isInViewport()) {
displayAd($dfpStoryAd3ES, storyAdList[2].ad2, [728, 90]);
$(window).off(“scroll”, storyESAd3ScrollHandler);
}
}
$(window).on(“scroll”, storyESAd3ScrollHandler);
var storyESAd4ScrollHandler = function () {
if ($dfpStoryAd4ES.isInViewport()) {
displayAd($dfpStoryAd4ES, storyAdList[3].ad, [728, 90]);
$(window).off(“scroll”, storyESAd4ScrollHandler);
}
}
$(window).on(“scroll”, storyESAd4ScrollHandler);
var storyESAd5ScrollHandler = function () {
if ($dfpStoryAd5ES.isInViewport()) {
displayAd($dfpStoryAd5ES, storyAdList[4].ad, [728, 90]);
$(window).off(“scroll”, storyESAd5ScrollHandler);
}
}
$(window).on(“scroll”, storyESAd5ScrollHandler);
counter++;
if (urlCount = n && o = n ? t.play() : t.pause()) : console.log(“iOS”)
})
});
}
}
else if(isVideo)
{
$(items).find(“video[id^=’myPlayerID_’]”).each(function(t, e) {
var n = “myPlayerID_” + $(e).attr(“data-video-id”);
bc(n), videojs(n).ready(function() {
this.scrollIntoView()
})
});
}
$(items).find(“div[id^=’right-swiper-‘]”).each(function(i, e) {
var swipID = $(e).attr(“id”);
var storySwiper = new Swiper(‘#’ + swipID, {
pagination : {
el : ‘.swiper-pagination’,
clickable : true
},
preloadImages : false,
lazyLoading : true,
simulateTouch : false,
autoplay : {
delay : 3000,
}
});
});
var ind = 0;
$(items).find(‘.read-more’).each(function(ind, obj) {
ind = ind + 1;
var html = $(items).find(“#inlineStory” + ind).html();
$(this).html(html);
});
$(items).find(‘img.lazy’).each(function(i, e) {
$(e).lazyload({
effect : “fadeIn”,
effectTime : 20,
threshold : 200,
failurelimit : 0
});
});
//getSeoContent(items);
});
}
var reqOpen = true;
$(document).bind(“scroll”,function() {
var viewport = {
top : $(document).scrollTop(),
left : $(document).scrollLeft()
};
viewport.bottom = viewport.top + $(document).height();
lastScrollTop = viewport.top;
var bot = viewport.bottom – $(document).height();
if (viewport.top > 200 && (showInfinite)) {
if(isCorona && !loaded){
var s= document.createElement(‘script’);
s.setAttribute(‘async’,”);
s.src=”https://chat.amplify.ai/plugin/5e77327dd8722a5cf17170be/chat_plugin.js?pluginId=5e77327dd8722a5cf17170be”;
document.getElementsByTagName(‘head’)[0].appendChild(s);
loaded=true;
}
$(‘.footer-scroll-main’).show();
if (reqOpen == true) {
$(‘#ulInfinite li:first’).addClass(“active”);
$(‘#ulInfinite li .stroy-link’).each(function(i, t) {
if(i>0){
listUrl.push($(t).html());
}
});
InfiniteScroll();
reqOpen = false;
}
} else if (bot