setTimeout((function(win, require, $){ var TimesGDPREU = (function() { var _const = { mandatoryCookieList : ['isWeatherListWidgetHide','geolocation','globalprimarylang','visitCounter','videoCompletedFromNudge','tp_video_ticker_hide','gcm_enabled','gcm_disable','lastPopupShown','rs','liveTvhide', 'MSCSAuth'] } var utils = { validateGDPRCookieForEU: function(){ var gdpr = this.getCookie('gdpr'); var newGdprVal; if (window._euuser && gdpr && gdpr == '1#1#1'){ newGdprVal = "0"; } if (!window._euuser && gdpr && gdpr == '1#1#0'){ newGdprVal = "1"; } if (newGdprVal){ if (typeof jssoCrosswalkObj =='undefined'){ window.jssoCrosswalkObj = new JssoCrosswalk('happytrips', 'WEB'); } jssoCrosswalkObj.updateUserPermissions("1", "1", "0", function(r) { if (r && r.code=='200'){ jssoCrosswalkObj.getValidLoggedInUser(); } }); } }, checkAndUpdateGDPRConsent: function (result) { //debugger; console.log('eu-59,result',result); var userId = result.uid; var _mytGdprConsent, _mytGdprPersonalizedConsent; if (result.travel_S_P){ _mytGdprConsent = 1 ; } if (result.travel_P_C){ _mytGdprPersonalizedConsent = "0"; } var _gdprConsentCookie = this.getCookie('ckns_policyV2'); var _gdprPersonalizedConsentCookie = this.getCookie('optoutV2'); /*consent is present in myt - sync it to cookie*/ if(typeof _mytGdprConsent !== 'undefined'){ //Set it to cookie, if cookie are not present TimesGDPR.common.consentModule.setConsentToCookies(_mytGdprConsent, _mytGdprPersonalizedConsent); } /*consent is present in cookie - sync it to myt*/ /*Set myt consent to cookie- as it might be updated through other site*/ else if(typeof _gdprConsentCookie !== 'undefined' && typeof _gdprPersonalizedConsentCookie !== 'undefined' && typeof _mytGdprConsent == 'undefined' ){ var toi_gdprcookieconsentVal = !!(_gdprPersonalizedConsentCookie); var toi_gdprpersonalizedconsentVal = !(parseInt(_gdprPersonalizedConsentCookie, 10)); var consentObj = { toi_gdprcookieconsent : toi_gdprcookieconsentVal, toi_gdprpersonalizedconsent : toi_gdprpersonalizedconsentVal }; //this.updateGDPRConsent(userId, consentObj, function(data) { console.log('Consent updated for EU: ' + data)} ); } }, updateGDPRConsent: function (userId, consentObj, callback) { if(typeof userId !== 'undefined' && typeof consentObj !== 'undefined'){ var _gdprcookieconsent = consentObj.toi_gdprcookieconsent; var _gdprpersonalizedconsent = consentObj.toi_gdprpersonalizedconsent; if(typeof _gdprcookieconsent !== 'undefined' && typeof _gdprpersonalizedconsent !== 'undefined'){ // var url = window.__mytime_domain + "mytimes/profile/update"; var url = _MYTDOMAIN+"/mytimes/profile/update"; $.getJSON(url, { // propertyKeyValuePairs: JSON.stringify({ 'toi_gdprcookieconsent' : _gdprcookieconsent, 'toi_gdprpersonalizedconsent' : _gdprpersonalizedconsent}), propertyKeyValuePairs: JSON.stringify({ 'travel_S_P' : _gdprcookieconsent, 'travel_P_C' : _gdprpersonalizedconsent}), uuId: userId, }, function( data ) { callback(data); }); } } }, getCookie: function(name){ var re = new RegExp(name + "=([^;]+)"); var value = re.exec(document.cookie); return (value != null) ? unescape(value[1]) : null; }, setCookie: function(name, set, value, domainName, days, path){ /*function to set cookies on the document based the consent cookies*/ if(!!domainName){ var domain = ";domain="+domainName; } if(!path){ var path = '/'; } if(!!days){ //Below variable is one day time in mili seconds. var _oneDayinMS = 24*60*60*1000; var d = new Date(); d.setTime(d.getTime() + (days*_oneDayinMS)); var expires = ";expires="+d.toUTCString(); } document.cookie = name+"=" +value + ( ( expires ) ? expires : '' ) + ( ( domain ) ? domain : '' ) + ";path="+path; }, getLocalStorage: function(name){ try{ return localStorage.getItem(name)? localStorage.getItem(name): null; }catch(e){ } }, setLocalStorage: function(name,value){ try{ localStorage.setItem(name, value); }catch(e){ } }, checkForGDPRCookies: function(name) { if (utils.getCookie('geo_continent') == 'AS' && _const.mandatoryCookieList.indexOf(name) > -1) { if (TimesGDPR.common.consentModule.gdprCookieInfo && TimesGDPR.common.consentModule.gdprCookieInfo.TOI_sendPromotions) { return true; } else { return false; } } else { return true; } } }; var euPopup = (function() { var _const = { consentblockerPopup: "#consentblockerPopup", consentAgreeButton: "#consentAgreeButton", consentblockerPopupForm: "#consentblockerPopupForm", jssoTermCondition: "#jssoTermCondition", jssoSharedDataAllowed: "#jssoSharedDataAllowed", closeConsentPopupButton:"#closeConsentPopupButton" }, init = function() { require(['tiljs/event', 'tiljs/cookie'],function(event, cookie) { event.subscribe("user.status",function(user) { if (user){ var gdpr = cookie.get('gdpr'); if (gdpr!='1#1#0' && gdpr != '1#1#1' && !($(_const.consentblockerPopup).length > 0)){ //showEuPopup(); //$('body').addClass('bodyoverflow imp'); } // let stop multiple calls. if (!window._updatepermission){ window._updatepermission = true; utils.validateGDPRCookieForEU(); } } }) }) // showEuPopup(); }; function bindEvent() { $(_const.consentblockerPopup) .off('click', _const.consentAgreeButton).on('click', _const.consentAgreeButton, postConsentCookies) .off('click', _const.closeConsentPopupButton).on('click', _const.closeConsentPopupButton, closeConsentPopup) .off('click', _const.jssoTermCondition).on('click', _const.jssoTermCondition, validateCheckBoxes) .off('click', _const.jssoSharedDataAllowed).on('click', _const.jssoSharedDataAllowed, validateCheckBoxes); // $(_const.consentblockerPopup).on('click', _const.consentAgreeButton, postConsentCookies) } function showEuPopup(){ var checked = window._euuser ? '' : 'checked' ; var pp = window._euuser ? 'http://jssocdn.jeetwin-gaming.com/policy/euprivacypolicy.html' : 'http://jssocdn.jeetwin-gaming.com/policy/privacypolicy.html'; var tncp = 'http://jssocdn.jeetwin-gaming.com/policy/termsandcondition.html'; // var tncp = "http://jeetwin-gaming.com/cookie-policy"; // var pp = "http://jeetwin-gaming.com/privacy-policy"; var html = '
' + '
' + ' ' + ' ' + '
' + '
'; $('body').append(html); bindEvent(); } function validateCheckBoxes(e, isReturn){ var isAgree = $('#jssoTermCondition').is(':checked') ? "1" : "0"; var isSharedData = $('#jssoSharedDataAllowed').is(':checked') ? "1" : "0"; var isValid = (isAgree == "1" && isSharedData == "1"); var $btn = $(_const.consentAgreeButton) if (isValid){ $btn.attr('disabled', false); $btn.removeClass('disabled'); }else{ $btn.removeAttr('disabled'); $btn.addClass('disabled'); } if (isReturn){ return isValid; } } function postConsentCookies(e) { e.preventDefault(); //debugger; if (validateCheckBoxes(e, true)){ // if (typeof LoginModule != 'undefined'){ // LoginModule.updateUserPermission("1", "1", "0", function(r) { // if (r && r.code=='200'){ // closeConsentPopup(e, true); // } // }); // } var termsAccepted = $('#jssoTermCondition').is(':checked') ? "1" : "0"; var timespointsPolicy = window._euuser ? "0" : "1"; var shareDataAllowed=$('#jssoSharedDataAllowed').is(':checked') ? "1" : "0"; if (validateCheckBoxes(e, true)){ if (typeof jssoCrosswalkObj =='undefined'){ window.jssoCrosswalkObj = new JssoCrosswalk('happytrips', 'WEB'); } jssoCrosswalkObj.getValidLoggedInUser(); jssoCrosswalkObj.updateUserPermissions(termsAccepted, shareDataAllowed, timespointsPolicy, function(r) { if (r && r.code=='200'){ closeConsentPopup(e, true); } }); } } } function closeConsentPopup(e, isClose){ //debugger; if(!isClose){ require(['tiljs/login'], function(login) { var user = login.getUser(); if (user){ login.logout(); } }); } $(_const.consentblockerPopup).remove(); // trigger event to work with other modules. require(['tiljs/event'],function(event) { event.publish('gdpr.jsso.popupclose'); }); $('body').removeClass('bodyoverflow imp'); } return { init: init } })() init = function(){ // if (window._euuser){ euPopup.init(); // } } return { init: init, utils: utils }; })(); win.TimesGDPREU = TimesGDPREU; win.TimesGDPREU.init(); })(window, require, jQuery), 1000);