1var returnPath = window.location.pathname || '/' 2if (window.location.search) { 3 returnPath += window.location.search 4} 5 6var currentModal = null 7var facebookData = null 8var facebookUser = null 9var email = '' 10var loginCallback = null 11var requalifyCallback = null 12var params = [] 13var otherParams = [] 14var registrationForm = 'normal' 15var registrationFormRules 16 17var postalCodeRules = site.domain === 'oteuamc.tv' ? {cpPortugal: []} : { 18 required: true, 19 minlength: 5, 20 maxlength: 5, 21 digits: true 22} 23 24 25getParameterByName('signin'); 26getParameterByName('unete'); 27getParameterByName('lite'); 28 29function getParameterByName(name) { 30 const url = window.location.href 31 32 name = name.replace(/[\[\]]/g, '\\$&'); 33 var regex = new RegExp('[?&]' + name + '(=([^&#]*)|&|#|$)'), 34 results = regex.exec(url); 35 if(results && name==='signin'){ 36 $('#form-registration-email').hide() 37 $('#register-image').show() 38 $('#register-param-image').hide() 39 showLoginModal(); 40 } else if(results && name==='unete'){ 41 $('#form-registration-email').css('display', 'flex') 42 $('#register-image').hide() 43 $('#register-param-image').show() 44 registrationForm = 'unete' 45 showRegisterModal(); 46} else if(results && name==='lite'){ 47 $('#form-registration-email').css('display', 'flex') 48 //$('#register-image').hide() 49 //$('#register-param-image').show() 50 registrationForm = 'lite' 51 showRegisterLiteModal(); 52 } 53} 54 55 56function loginPromise() { 57 return new Promise((resolve) => { 58 showLoginModal((user) => { 59 resolve(user) 60 }) 61 }) 62} 63 64function changeSigninUrl(action){ 65 if(action === 'add-param'){ 66 var params = new URLSearchParams(window.location.search); 67 var newurl = window.location.protocol + "//" + window.location.host + window.location.pathname + '?signin'; 68 if (params.has('card')) { 69 newurl += '&card=' + encodeURIComponent(params.get('card')); 70 } 71 window.history.replaceState({ path: newurl }, '', newurl); 72 } 73 if(action === 'add-param-unete'){ 74 var newurl = window.location.protocol + "//" + window.location.host + window.location.pathname + '?unete'; 75 window.history.replaceState({ path: newurl }, '', newurl); 76 } 77 if(action === 'add-param-lite'){ 78 var newurl = window.location.protocol + "//" + window.location.host + window.location.pathname + '?lite'; 79 window.history.replaceState({ path: newurl }, '', newurl); 80 } 81 if(action === 'remove-param'){ 82 var newurl = window.location.protocol + "//" + window.location.host + window.location.pathname; 83 window.history.replaceState({ path: newurl }, '', newurl); 84 } 85} 86 87function showLoginModal(callback) { 88 let currentUserManager = JSON.parse(localStorage.getItem(`Parse/${site.parse.appId}/currentUser`) || null) 89 if(currentUserManager && currentUserManager.isManager === true){ 90 closeLoginModal() 91 window.location.reload() 92 return 93 } 94 if (loginCallback) { 95 closeLoginModal() 96 return 97 } 98 loginCallback = callback 99 updateToModal('#page-login-modal') 100 changeSigninUrl('add-param') 101} 102 103function showRegisterModal(callback) { 104 updateToModal('#page-register-modal') 105} 106 107function showRegisterLiteModal(callback) { 108 updateToModal('#page-register-modal-lite') 109} 110 111function showRequalifyUserPopup(callback) { 112 updateToModal('#page-requalify-user-popup') 113} 114 115function showWelcomeModal(callback) { 116 updateToModal('#page-welcome-modal') 117} 118 119function closeLoginModal(user = null) { 120 if (currentModal) { 121 hideModal(currentModal, () => { 122 currentModal = null 123 if (loginCallback) { 124 loginCallback(user) 125 loginCallback = null 126 } 127 }) 128 changeSigninUrl('remove-param') 129 } else { 130 if (loginCallback) { 131 loginCallback(user) 132 loginCallback = null 133 } 134 } 135} 136 137function resetForm(form) { 138 form.trigger("reset"); 139 form.removeClass('error') 140 form.removeClass('loading') 141} 142 143function requalifyPromise(userParams, additionalDataText) { 144 console.log('userParams: ', userParams) 145 return new Promise((resolve) => { 146 showRequalifyModal(userParams, (user) => { 147 resolve(user) 148 }, additionalDataText) 149 }) 150} 151 152 // Use external library pselect.js 153function initializeProvinceAndCitiesDropdowns() { 154 const province = document.getElementById('province'); 155 const city = document.getElementById('city'); 156 $('#province').empty() 157 $('#city').empty() 158 new Pselect().create(province, city); 159} 160 161function initializeStreamingSelect() { 162 $('#streamingPlatforms').select2(); 163} 164 165function initializeRegistrationFavouriteChannelsSelect() { 166 $('form[name=registration] select[name=favouriteChannels]').select2(); 167} 168function initializeRequalifyFavouriteChannelsSelect() { 169 $('form[name=requalify] select[name=favouriteChannels]').select2(); 170} 171function initializeRegistrationLiteFavouriteChannelsSelect() { 172 $('form[name=registration-lite] select[name=favouriteChannels]').select2(); 173} 174 175function changeAdditionalUserClubinTextLabel() { 176 const additionalUserClubinText = selectedCard.additionalUserClubinText; 177 if (!additionalUserClubinText) return; 178 $("#additionalUserClubinTextLabel").text(additionalUserClubinText) 179} 180 181function showRequalifyModal(userParams, callback, additionalDataText) { 182 183 initializeStreamingSelect(); 184 initializeRequalifyFavouriteChannelsSelect() 185 initializeProvinceAndCitiesDropdowns() 186 hideUnNeededFields() 187 changeAdditionalUserClubinTextLabel(); 188 189 resetForm($("form[name=requalify]")) 190 if (requalifyCallback || !currentUser) { 191 closeRequalifyModal() 192 return 193 } 194 195 params = userParams 196
197 const allParams = ['name', 'surname', 'platform', 'address', 'postalcode', 'birthdate', 'mobile', 'fullAddress', 'favouriteChannels', 'streamingPlatforms'] 198 const fullAddressParams = ['country', 'province', 'city', 'pc', 'street', 'number', 'block', 'stair', 'floor', 'letter'] 199 const paramsWithMultiSelect= ['favouriteChannels', 'streamingPlatforms'] 200 201 var rules = {} 202 allParams.forEach(param => { 203 204 if (param == 'fullAddress' && !userParams.includes(param)) { 205 return fullAddressParams.forEach(addressParam => $('#requalify_'+ addressParam).addClass('hidden')) 206 } 207 208 if (!userParams.includes(param)) return $('#requalify_'+param).addClass('hidden'); 209 210 rules[param] = { required: true } 211 let value = currentUser.get(param) 212 213 if (!isEmpty(value)) { 214 if(param === 'birthdate') { 215 const [year, month, day] = value.split('-'); 216 $('form #birthage').val(year) 217 $('form #birthmonth').val(month) 218 $('form #birthday').val(day) 219 } else if (param === 'platform') { 220 selectedPlatform = currentUser.get('platform') 221 if (selectedPlatform && selectedPlatform.id) { 222 $('form #platform-'+selectedPlatform.id).addClass('checked') 223 } 224 } else if (param == 'fullAddress') { 225 fullAddressParams.forEach(addressParam => { 226 const addressFormNode = $('form #'+addressParam) 227 const value = currentUser.get(param)[addressParam] 228 if (!addressFormNode.is("select")) 229 return addressFormNode.val(value) 230 if (!value) return 231 // If the element is a dropdown then we are using external library pselect.js 232 // So we collect the province and city and we trigger onChange event to update the cities according to the province selected 233 $(`form #${addressParam} option`).filter(function(index) { return $(this).text() === value }).attr('selected', 'selected'); 234 return document.getElementById(addressParam).dispatchEvent(new Event("change")) 235 }) 236 } else { 237 $('form #'+param).val(value) 238 } 239 if (paramsWithMultiSelect.includes(param)) { 240 $('form #'+param).trigger('change'); 241 } 242 } 243 244 if (param == 'fullAddress') { 245 if(currentUser.get('postalcode') && !currentUser.get('fullAddress')) { 246 $('form #pc').val(currentUser.get('postalcode')) 247 } 248 return fullAddressParams.forEach(addressParam => $('#requalify_'+ addressParam).removeClass('hidden')) 249 } 250 251 $('#requalify_'+param).removeClass('hidden') 252 253 }); 254 255 if (additionalDataText) { 256 $('#descriptionText').text(additionalDataText) 257 } 258 259 requalifyCallback = callback 260 updateToModal('#page-requalify-modal') 261} 262 263function closeRequalifyModal(user = null) { 264 if (currentModal) { 265 hideModal(currentModal, () => { 266 currentModal = null 267 if (requalifyCallback) { 268 requalifyCallback(user) 269 requalifyCallback = null 270 } 271 }) 272 } else { 273 if (requalifyCallback) { 274 requalifyCallback(user) 275 requalifyCallback = null 276 } 277 } 278} 279 280function updateToModal(newPage) { 281 if (currentModal) { 282 hideModal(currentModal, () => { 283 showModal(newPage) 284 currentModal = newPage 285 }) 286 } else { 287 showModal(newPage) 288 currentModal = newPage 289 } 290} 291 292function isPlatformSelected(value, _ , params) { 293 const formName = value || params && params[0] || 'registration'; 294 if (! $(`form[name="${formName}"] .platformItem:visible`).length) return true; 295 return $(`form[name="${formName}"] .platformItem.checked`).length; 296} 297function isAbove18Years(value) { 298 if (!value) return true; 299 const [year, month, day] = value.split('-'); 300 return new Date(+year+18, +month-1, +day) <= new Date(); 301} 302 303function checkPostcalCodePortugal(value) { 304 if (!value) return true; 305 const regex = /^\d{4}-\d{3}[ -~]{0,17}$/ 306 return regex.test(value) 307} 308 309function addRemovePlatformSelectedErrorBorders(formName) { 310 if (!isPlatformSelected(formName)) { 311 $(`form[name="${formName}"] .platforms`).addClass("border-2 border-red-300") 312 } else { 313 $(`form[name="${formName}"] .platforms`).removeClass("border-2 border-red-300") 314 } 315} 316 317$(function() { 318 // Add customized validation to check that any of the platforms have been selected 319 $.validator.addMethod("platformSelected", isPlatformSelected, tr.error.operadorObligatorio); 320 $.validator.addMethod("above18years", isAbove18Years, tr.error.menorEdad); 321 $.validator.addMethod("cpPortugal", checkPostcalCodePortugal); 322 323 // $(".loginLink").each(function() { 324 // var $this = $(this) 325 // var _href = $this.attr("href") 326 // $this.attr("href", _href + "?rp="+encodeURIComponent(returnPath)) 327 // }); 328 329 // Login 330 $("form[name='login']").submit(function(event) { 331 event.preventDefault(); 332 }
332).validate({ 333 // Specify validation rules 334 rules: { 335 // The key name on the left side is the name attribute 336 // of an input field. Validation rules are defined 337 // on the right side 338 email: { 339 required: true, 340 // Specify that email should be validated 341 // by the built-in "email" rule 342 email: true 343 } 344 }, 345 // Specify validation error messages 346 messages: { 347 email: tr.error.emailInvalido 348 }, 349 // Make sure the form is submitted to the destination defined 350 // in the "action" attribute of the form when valid 351 submitHandler: function(form) { 352 $(form).removeClass('error') 353 $(form).addClass('loading') 354 email = $('form[name=login] input[name=email]').val().toLowerCase() 355 console.log('returnPath: ', returnPath) 356 sessionStorage.setItem('email', email); 357 magicLogin(email, returnPath).then(async (user) => { 358 $(form).removeClass('loading') 359 // Analytics must not block login (adblock / offline / ws.tuamc.tv failures) 360 try { 361 await log_access({event: 'login'}) 362 } catch (e) { 363 console.log('log_access error: ', e) 364 } 365 $('form[name=login] input[name=email]').val('') 366 updateToModal('#page-code-modal') 367 }).catch((error) => { 368 console.log('login error: ', error.message) 369 if (error.message === 'error_no_user') { 370 // If not registered send to register 371 console.log('change modal to register') 372 initializeRegistrationFavouriteChannelsSelect() 373 updateToModal('#page-register-modal') 374 } else if (error.message === 'error_no_clubbin_user') { 375 // If not in clubbin send to clubbin register 376 console.log('change modal to clubbin register') 377 updateToModal('#page-clubbin-register-modal') 378 } else {
379 var errorStr = error === 'isBanned' ? tr.error.usuarioBaneado : tr.error.algoMal; 380 if (error.message && error.message === 'user_unavailable' ) { 381 errorStr = tr.error.usuarioNoDisponible; 382 } 383 if (errorStr.includes('101')) { 384 errorStr = tr.error.emailPasswordInvalidos 385 } 386 $('form[name=login] #error-span').text(errorStr) 387 $(form).addClass('error') 388 } 389 $(form).removeClass('loading') 390 }) 391 } 392 }); 393 394 // Code 395 $("form[name='verification']").submit(function(event) { 396 event.preventDefault(); 397 }).validate({ 398 // Specify validation rules 399 rules: { 400 // The key name on the left side is the name attribute 401 // of an input field. Validation rules are defined 402 // on the right side 403 code: { 404 required: true, 405 minlength: 4, 406 maxlength: 4 407 } 408 }, 409 // Specify validation error messages 410 messages: { 411 code: { 412 required: tr.error.codigoObligatorio, 413 minlength: tr.error.codigo4caracteres, 414 maxlength: tr.error.codigo4caracteres, 415 }, 416 }, 417 // Make sure the form is submitted to the destination defined 418 // in the "action" attribute of the form when valid 419 submitHandler: function(form) { 420 $(form).removeClass('error') 421 $(form).addClass('loading') 422 const code = $('form[name=verification] input[name=code]').val() 423 validateCode(code).then(async (response) => { 424 if (response && response.username && response.password) { 425 login(response.username, response.password) 426 .then((user) => { 427 $(form).removeClass('loading') 428 // Update facebook info if get 429 updateFacebookData(user).catch((error) => { 430 console.log('error updating facebook info: ', error) 431 }).finally(()=> { 432 closeLoginModal(user) 433 var lastMinute = new Date(new Date().getTime() - 60000) 434 if (lastMinute < user.get('first_login') && user.get('createdAt') > new Date('05-01-2024') && site && site.domain !== 'oteuamc.tv') { 435 showWelcomeModal() 436 } 437 typeof(dataLayer)!== 'undefined' && dataLayer.push({'event':'sign_up_completed','site':site.domain,'user_id':user.id}); 438 // Reload after login if player or video screen 439 const locationPathname = window.location.pathname 440 const isVideoPlayerScreen = locationPathname.includes('/player') || locationPathname.includes('/video/') 441 if (isVideoPlayerScreen ) { 442 window.location.reload() 443 } 444 // <!-- Adform Tracking Code BEGIN --> 445 window._adftrack = Array.isArray(window._adftrack) ? window._adftrack : (window._adftrack ? [window._adftrack] : []); 446 window._adftrack.push({ 447 HttpHost: 'track.adform.net', 448 pm: 3503491, 449 divider: encodeURIComponent('|'), 450 pagename: encodeURIComponent('AMC_SELEKT/5-Login') 451 }); 452 (function() { 453 var s = document.createElement('script'); 454 s.type = 'text/javascript'; 455 s.async = true; 456 s.src = 'https://s2.adform.net/banners/scripts/st/trackpoint-async.js'; 457 var x = document.getElementsByTagName('script')[0]; 458 x.parentNode.insertBefore(s, x); 459 })(); 460 }) 461 }) 462 .catch((error) => { 463 var errorStr = error === 'isBanned' ? tr.error.usuarioBaneado : tr.error.algoMal 464 $(form).removeClass('loading') 465 $('form[name=verification] #error-span').text(errorStr) 466 $(form).addClass('error') 467 }) 468 } else { 469 var errorStr = tr.error.algoMal 470 $(form).removeClass('loading') 471 $('form[name=verification] #error-span').text(errorStr) 472 $(form).addClass('error') 473 } 474 }).catch((error) => { 475 console.log('verification error: ', error.message) 476 // If not registered send to register 477 var errorStr = (error.message === 'code_error') ? tr.error.codigoInvalido : tr.error.algoMal 478 $(form).removeClass('loading') 479 $('form[name=verification] #error-span').text(errorStr) 480 $(form).addClass('error') 481 }) 482 } 483 }); 484 485 // Register 486 loadYearsOptions() 487 loadDaysOptions($("form[name=registration]")) 488 loadDaysOptions($("form[name=requalify]")) 489 490 $('form #birthday').change(updateBirthdate) 491 $('form #birthage').change(updateBirthdate) 492 $('form #birthmonth').change(updateBirthdate) 493 494 initializeRegistrationFavouriteChannelsSelect() 495 initializeRegistrationLiteFavouriteChannelsSelect() 496 497 registrationFormRules = registrationFormRules = { //OJO 498 // The key name on the left side is the name attribute 499 // of an input field. Validation rules are defined 500 // on the right side 501 name: "required", 502 email: { 503 required: true, 504 // Specify that email should be validated 505 // by the built-in "email" rule 506 email: true // Even if this field is not required if this is set to true it will complain for not valid or blank emails 507 }, 508 birthday: { 509 required: true, 510 }, 511 birthmonth: { 512 required: true, 513 }, 514 birthage: { 515 required: true, 516 }, 517 birthdate: { 518 above18years: ['registration'] 519 }, 520 surname: { 521 required: true, 522 }, 523 postalcode: postalCodeRules, 524 platforms: { 525 platformSelected: ['registration'] 526 }, 527 favouriteChannels : { 528 required: true 529 } 530 } 531 532 // window.onload = function() { 533 generateRegistrationFormRules() 534 535 $("form[name=registration]").submit(function(event) { 536 event.preventDefault(); 537 addRemovePlatformSelectedErrorBorders('registration'); 538 }).validate({ 539 // Specify validation rules 540 rules: registrationFormRules, 541 // Specify validation error messages 542 messages: { 543 name: tr.error.nombreObligatorio, 544 surname: tr.error.apellidosObligatorio, 545 email: tr.error.emailInvalido, 546 postalcode: tr.error.cpObligatorio, 547 favouriteChannels: tr.error.canalObligatorio, 548 birthday: tr.error.diaObligatorio, 549 birthmonth: tr.error.mesObligatorio, 550 birthage: tr.error.anyoObligatorio, 551 }, 552 // Make sure the form is submitted to the destination defined 553 // in the "action" attribute of the form when valid 554 submitHandler: async function(form) { 555 if (!terms || !privacy) { return } 556 $(form).removeClass('error') 557 $(form).addClass('loading') 558 const name = $('form[name=registration] input[name=name]').val() 559 const surname = $('form[name=registration] input[name=surname]').val() 560 const mobile = $('form[name=registration] input[name=mobile]').val() 561 const birthdate = $('form[name=registration] input[name=birthdate]').val() 562 const postalcode = $('form[name=registration] input[name=postalcode]').val() 563 const favouriteChannels = $("form[name=registration] select[name=favouriteChannels]").val() 564 const canal = getCanal($("form[name=registration] select[name=favouriteChannels]").val()[0]) 565 const allowPublicity = publicity 566 const platform = selectedPlatform.id === 'null' ? null : { objectId: selectedPlatform.id } 567 if (!email) { 568 email = $('form[name=registration] input[name=email]').val().toLowerCase() 569 } 570 let params = {username: email, email, name, surname, mobile, birthdate, postalcode, allowPublicity, platform, favouriteChannels, registrationForm, canal} 571 572 573 // If there are favourite channels, we select the first one and set 'channel' field with that one. 574 if (favouriteChannels && favouriteChannels.length) { 575 const Channel = Parse.Object.extend('Channel') 576 const channelQuery = new Parse.Query(Channel) 577 const channelString = favouriteChannels[0]; 578 channelQuery.matches('nameInUserDotCom', channelString) 579 const channel = await channelQuery.first() 580 if (channel) { 581 params = {...params, channel: channel.toJSON() } 582 } 583 } 584 585 magicSignup(params, returnPath).then(async (response) => { 586 $(form).removeClass('loading') 587 updateToModal('#page-code-modal') 588 589 // TODO // 590 // To Cloud 591 // const User = Parse.Object.extend('_User') 592 // const userQuery = new Parse.Query(User) 593 // userQuery.equalTo('email', response[0].email) 594 // newUser = await userQuery.first() 595 // const LogUserDotCom = Parse.Object.extend('LogUserDotCom') 596 // var logUserDotCom = new LogUserDotCom() 597 // logUserDotCom.set('user',newUser) 598 // logUserDotCom.set('data',params) 599 // logUserDotCom.save() 600 601 // Adform Scripts 602 // runAdformScriptsBySiteAndRouteAndUser(site, newUser) 603 604 typeof(gtag)!== 'undefined' && gtag('event', 'conversion', {'send_to': 'AW-743809320/bW19CPjx_ZMDEKjC1uIC'}); 605 606 const it = $('form input[name=it]').val() 607 const idcrm = response.userId //$('form input[name=idcrm]').val() 608 const xid = $('form input[name=xid]').val() 609 const xtoken = $('form input[name=xtoken]').val() 610 console.log("PARAMS:", params) 611 const xeerpaParams = {it, idcrm, xid, xtoken} 612 console.log(`Xeerpa Params: it= ${it}, idcrm= ${idcrm}, xid= ${xid}, xtoken= ${xtoken}`) 613 if (it && idcrm && xid && xtoken) { 614 console.log('send xeerpa params: ', xeerpaParams) 615 try { 616 const response = await sendToXeerpa(params, xeerpaParams) 617 if (response && response.data && response.data.data && response.data.data) { 618 const updateXeerpaDataParams = { 619 xeerpaData: response.data.data, 620 userId: idcrm 621 } 622 console.log("updateXeerpaDataParams", updateXeerpaDataParams) 623 Parse.Cloud.run("updateXeerpaData", updateXeerpaDataParams) 624 } 625 } catch (error) { 626 console.log('error sending to xeerpa: ', error) 627 } 628 } else { 629 console.log('do not send to xeerpa') 630 } 631 632 }).catch((error) => { 633 console.log('register error: ', error) 634 var errorStr = tr.error.algoMal; 635 if (error.message && error.message === 'email_exists') { 636 errorStr = tr.error.emailExistente; 637 } 638 $(form).removeClass('loading') 639 $('form[name=registration] #error-span').text(errorStr) 640 $(form).addClass('error') 641 }) 642 } 643 }); 644 // } 645 646 $("form[name=registration-lite]").submit(function(event) { 647 event.preventDefault(); 648 addRemovePlatformSelectedErrorBorders('registration-lite'); 649 }
649).validate({ 650 // Specify validation rules 651 rules: registrationFormRules, 652 // Specify validation error messages 653 messages: { 654 email: tr.error.emailInvalido, 655 favouriteChannels: tr.error.canalObligatorio, 656 }, 657 // Make sure the form is submitted to the destination defined 658 // in the "action" attribute of the form when valid 659 submitHandler: async function(form) { 660 if (!terms || !privacy) { return } 661 $(form).removeClass('error') 662 $(form).addClass('loading') 663 const allowPublicity = publicity 664 if (!email) { 665 email = $('form[name=registration-lite] input[name=email]').val().toLowerCase() 666 } 667 let params = {username: email, email, allowPublicity, registrationForm} 668 sessionStorage.setItem('email', email); 669 magicSignup(params, returnPath).then(async (response) => { 670 $(form).removeClass('loading') 671 updateToModal('#page-code-modal') 672 673 // TODO // 674 // To Cloud 675 // const User = Parse.Object.extend('_User') 676 // const userQuery = new Parse.Query(User) 677 // userQuery.equalTo('email', response[0].email) 678 // newUser = await userQuery.first() 679 // const LogUserDotCom = Parse.Object.extend('LogUserDotCom') 680 // var logUserDotCom = new LogUserDotCom() 681 // logUserDotCom.set('user',newUser) 682 // logUserDotCom.set('data',params) 683 // logUserDotCom.save() 684 685 // Adform Scripts 686 // runAdformScriptsBySiteAndRouteAndUser(site, newUser) 687 688 typeof(gtag)!== 'undefined' && gtag('event', 'conversion', {'send_to': 'AW-743809320/bW19CPjx_ZMDEKjC1uIC'}); 689 690 const it = $('form input[name=it]').val() 691 const idcrm = response.userId //$('form input[name=idcrm]').val() 692 const xid = $('form input[name=xid]').val() 693 const xtoken = $('form input[name=xtoken]').val() 694 console.log("PARAMS:", params) 695 const xeerpaParams = {it, idcrm, xid, xtoken} 696 console.log(`Xeerpa Params: it= ${it}, idcrm= ${idcrm}, xid= ${xid}, xtoken= ${xtoken}`) 697 if (it && idcrm && xid && xtoken) { 698 console.log('send xeerpa params: ', xeerpaParams) 699 try { 700 const response = await sendToXeerpa(params, xeerpaParams) 701 if (response && response.data && response.data.data && response.data.data) { 702 const updateXeerpaDataParams = { 703 xeerpaData: response.data.data, 704 userId: idcrm 705 } 706 console.log("updateXeerpaDataParams", updateXeerpaDataParams) 707 Parse.Cloud.run("updateXeerpaData", updateXeerpaDataParams) 708 } 709 } catch (error) { 710 console.log('error sending to xeerpa: ', error) 711 } 712 } else { 713 console.log('do not send to xeerpa') 714 } 715 716 }).catch((error) => { 717 console.log('register error: ', error) 718 var errorStr = tr.error.algoMal; 719 if (error.message && error.message === 'email_exists') { 720 errorStr = tr.error.emailExistente; 721 } 722 $(form).removeClass('loading') 723 $('form[name=registration-lite] #error-span').text(errorStr) 724 $(form).addClass('error') 725 }) 726 } 727 }); 728 729 $("form[name=requalify]").submit(function(event) { 730 event.preventDefault(); 731 addRemovePlatformSelectedErrorBorders('requalify'); 732 }).validate({ 733 // Specify validation rules 734 rules: { 735 // The key name on the left side is the name attribute 736 // of an input field. Validation rules are defined 737 // on the right side 738 name: "required", 739 surname: { 740 required: true 741 }, 742 address: { 743 required: true 744 }, 745 postalcode: postalCodeRules, 746 mobile: { 747 required: true 748 }, 749 birthday: { 750 required: true, 751 }, 752 birthmonth: { 753 required: true, 754 }, 755 birthage: { 756 required: true, 757 }, 758 birthdate: { 759 above18years: ['registration'] 760 }, 761 province: { 762 required: true 763 }, 764 city: { 765 required: true 766 }, 767 pc: { 768 required: true 769 }, 770 street: { 771 required: true 772 }, 773 requalify_platforms: { 774 platformSelected: ['requalify'] 775 }, 776 streamingPlatforms: { 777 required: true, 778 }, 779 favouriteChannels : { 780 required: true 781 } 782 }, 783 // Specify validation error messages 784 messages: { 785 name: tr.error.nombreObligatorio, 786 surname: tr.error.apellidosObligatorio, 787 address: tr.error.direccionObligatoria, 788 email: tr.error.emailInvalido, 789 postalcode: tr.error.cpObligatorio, 790 mobile: tr.error.telefonoObligatorio, 791 province: tr.error.provinciaObligatoria, 792 city: tr.error.localidadObligatoria, 793 pc: tr.error.cpObligatorio, 794 street: tr.error.calleObligatoria, 795 streamingPlatforms: tr.error.plataformaObligatoria, 796 favouriteChannels: tr.error.canalObligatorio, 797 birthday: tr.error.diaObligatorio, 798 birthmonth: tr.error.mesObligatorio, 799 birthage: tr.error.anyoObligatorio, 800 }, 801 // Make sure the form is submitted to the destination defined 802 // in the "action" attribute of the form when valid 803 submitHandler: function(form) { 804 $(form).removeClass('error') 805 $(form).addClass('loading') 806 const favouriteChannels = $("form[name=requalify] select[name=favouriteChannels]").val() 807 values = { 808 name: $('form[name=requalify] input[name=name]').val(), 809 surname: $('form[name=requalify] input[name=surname]').val(), 810 mobile: $('form[name=requalify] input[name=mobile]').val(), 811 birthdate: $('form[name=requalify] input[name=birthdate]').val(), 812 address: $('form[name=requalify] input[name=address]').val(), 813 postalcode: $('form[name=requalify] input[name=postalcode]').val(), 814 streamingPlatforms: $('form[name=requalify] #streamingPlatforms').val(), 815 platform: selectedPlatform.id === 'null' ? null : { objectId: selectedPlatform.id }, 816 favouriteChannels, 817 canal: !!favouriteChannels ? getCanal(favouriteChannels[0]) : '', 818 819 fullAddress: { 820 country: 'España', 821 province: $('form[name=requalify] #province option:selected').text(), 822 city: $('form[name=requalify] #city option:selected').text(), 823 pc: $('form[name=requalify] input[name=pc]').val(), 824 street: $('form[name=requalify] input[name=street]').val(), 825 number: $('form[name=requalify] input[name=number]').val(), 826 block: $('form[name=requalify] input[name=block]').val(), 827 stair: $('form[name=requalify] input[name=stair]').val(), 828 floor: $('form[name=requalify] input[name=floor]').val(), 829 letter: $('form[name=requalify] input[name=letter]').val(), 830 }, 831 } 832 833 console.log("Form: ", form); 834 saveAdditionalParams() 835
836 params.forEach(param => { 837 if (param === 'platform') { 838 if(values[param]) { 839 currentUser.set(param, { 840 '__type': 'Pointer', 841 'className': 'Platform', 842 'objectId': values[param].objectId 843 }); 844 } else { 845 currentUser.unset(param) 846 } 847 } else { 848 currentUser.set(param, values[param]) 849 if (param === 'favouriteChannels') { 850 currentUser.set('canal', values.canal) 851 } 852 } 853 }); 854 855 // If postal code in fullAdress does not exist but in the field 'postalcode' 856 const changePostalCode = params.includes('fullAddress') && !params.includes('postalcode') && values['fullAddress'].pc; 857 if (changePostalCode) { 858 currentUser.set('postalcode', values['fullAddress'].pc) 859 } 860 861 currentUser.save().then(async () => { 862 const session = await Parse.Session.current() 863 864 $.post('/api/user/updateUserDotComAddress', { 865 userId: currentUser.id, 866 sessionToken: session.get('sessionToken'), 867 }) 868 869 closeRequalifyModal(currentUser) 870 }).catch((error) => { 871 console.log('requalify error: ', error) 872 var errorStr = 'Algo ha salido mal, prueba más tarde' 873 $(form).removeClass('loading') 874 $('form[name=requalify] #error-span').text(errorStr) 875 $(form).addClass('error') 876 }) 877 878 // Save extra params 879 } 880 }); 881 882 // Register Clubbin 883 884 $("form[name=requalify]").submit(function(event) { 885 console.log('requalify submit') 886 }).validate({ 887 submitHandler: function(form) { 888 console.log('requalify validate') 889 } 890 }); 891 892 $("form[name=clubbinRegistration]").submit(function(event) { 893 event.preventDefault(); 894 }).validate({ 895 // Specify validation rules 896 rules: { 897 }, 898 // Specify validation error messages 899 messages: { 900 }, 901 // Make sure the form is submitted to the destination defined 902 // in the "action" attribute of the form when valid 903 submitHandler: function(form) { 904 if (!terms || !privacy) { return } 905 $(form).removeClass('error') 906 $(form).addClass('loading') 907 const allowPublicity = publicity 908 magicSignup({username: email, email, allowPublicity}, returnPath).then(async (user) => { 909 $(form).removeClass('loading') 910 updateToModal('#page-code-modal') 911 }).catch((error) => { 912 console.log('register error: ', error) 913 var errorStr = 'Algo ha salido mal, prueba más tarde' 914 $(form).removeClass('loading') 915 $('form[name=clubbinRegistration] #error-span').text(errorStr) 916 $(form).addClass('error') 917 }) 918 } 919 }); 920 921 document.addEventListener('platformsReady', () => { 922 console.log('platformsReady') 923 updatePlatforms() 924 }) 925}); 926 927// Code 928function validateCode(code) { 929 console.log('checkCode') 930 const params = { code, site, email: sessionStorage.getItem('email') || ''} 931 console.log('params: ', params) 932 return Parse.Cloud.run("validateMagicCode", params) 933} 934 935 936// Registration 937var selectedPlatform = {id: "null"} 938var terms = false 939var privacy = false 940var publicity = false 941 942 943 944async function updatePlatforms() { 945 const localPlatforms = await getPlatformsForRegistration() 946 947 var html = '<ul class="flex flex-wrap items-center justify-center mx-auto">' 948 949 localPlatforms.forEach(platform => { 950 html += ` 951 <li id="platform-${platform.id}" 952 class="platformItem justify-center flex card transition-in-out-6 p-2 cursor-pointer" 953 onclick="selectPlatform('${platform.id}')">` 954 if (platform.get('logo')) { 955 html += ` 956 <div class="flex items-center mx-auto"> 957 <img loading="lazy" class="self-center" alt="${platform.get('name')}" src="${platform.get('logo').url()}" /> 958 </div>` 959 } else { 960 html += ` 961 <div class="m-auto flex align-center items-center"> 962 <span class="text-center text-xs sm:text-sm lg:text-xs font-bold"> 963 ${platform.get('name')} 964 </span> 965 </div>` 966 } 967 html += '</li>' 968 }); 969// html += ` 970// <li id="platform-null" 971// class="platformItem justify-center flex card transition-in-out-6 p-2 other cursor-pointer" 972// onclick="selectPlatform()"> 973// <div class="m-auto flex align-center items-center"> 974// <span class="text-center text-xs sm:text-sm lg:text-xs font-bold">
974${tr.register.noOperador}</span> 975// </div> 976// </li> 977// </ul> 978// ` 979 $('form .platforms').html(html) 980 981 if (selectedPlatform) { 982 selectPlatform(selectedPlatform.id) 983 } 984 985} 986 987function selectPlatform(platId) { 988 989 if (selectedPlatform.id === platId) { return } 990 $('form #platform-'+selectedPlatform.id).removeClass('checked') 991 selectedPlatform = platId ? platformsForRegistration.find(platform => platform.id === platId) : {id: 'null'} 992 $('form #platform-'+selectedPlatform.id).addClass('checked') 993} 994 995function selectCheckBox(checkbox) { 996 switch (checkbox) { 997 case 'terms': 998 if (terms) { 999 terms = false 1000 $('.terms-checkbox').removeClass('checked') 1001 } else { 1002 terms = true 1003 $('.terms-checkbox').addClass('checked') 1004 } 1005 break; 1006 case 'privacy': 1007 if (privacy) { 1008 privacy = false 1009 $('.privacy-checkbox').removeClass('checked') 1010 } else { 1011 privacy = true 1012 $('.privacy-checkbox').addClass('checked') 1013 } 1014 break; 1015 case 'publicity': 1016 if (publicity) { 1017 publicity = false 1018 $('.publicity-checkbox').removeClass('checked') 1019 } else { 1020 publicity = true 1021 $('.publicity-checkbox').addClass('checked') 1022 } 1023 break; 1024 } 1025 if (terms && privacy) { 1026 $('form .submitBtn').removeClass('disabled').prop('disabled', false) 1027 } else { 1028 $('form .submitBtn').addClass('disabled').prop('disabled', true) 1029 } 1030} 1031 1032function updateBirthdate(event) { 1033 const form = $(event.target).closest("form") 1034 loadDaysOptions(form) 1035 const day = form.find('#birthday').val() || ''
1036 const month = form.find('#birthmonth').val() || '' 1037 const year = form.find('#birthage').val() || '' 1038 if (!day || day.length == 0 || !month || month.length == 0 || !year || year.length == 0) { 1039 $('form #birthdate').val(null) 1040 } else { 1041 const dim = daysInMonth(parseInt(month), parseInt(year)) 1042 1043 if (parseInt(day) > dim) { 1044 form.find('#birthday').val(null) 1045 form.find('#birthmonth').val(null) 1046 } else { 1047 const date = year+'-'+month+'-'+day 1048 form.find('#birthdate').val(date) 1049 } 1050 } 1051} 1052 1053function daysInMonth (month, year) { // Use 1 for January, 2 for February, etc. 1054 return new Date(year, month, 0).getDate(); 1055} 1056 1057function loadDaysOptions(form) { 1058 var totalDays = 31 1059 const selected = form.find('#birthday').val() 1060 const month = form.find('#birthmonth').val() 1061 const year = form.find('#birthage').val() 1062 if (month && year) { 1063 totalDays = daysInMonth(parseInt(month), parseInt(year)) 1064 } 1065 var html = '<option disabled selected value>DÃa</option>' 1066 var i = 0 1067 for (let i = 1; i <= totalDays; i++) { 1068 var day = (i < 10) ? ('0'+i) : (''+i) 1069 html += (day === selected) ? `<option selected>${day}</option>` : `<option>${day}</option>` 1070 } 1071 form.find('#birthday').html(html) 1072} 1073 1074function loadYearsOptions() { 1075 const totalYears = 120 1076 var html = '<option disabled selected value>Año</option>' 1077 var i = 0 1078 const year = new Date().getFullYear() 1079 for (let i = 0; i < totalYears; i++) { 1080 html += `<option>${year - i}</option>` 1081 } 1082 $('form #birthage').html(html) 1083} 1084 1085// XEERPA 1086var popup 1087 1088function loginFacebook(sn, width, height) { 1089 console.log('loginFacebook') 1090 1091 clearCookie(); 1092 1093 if (navigator.appName == 'Microsoft Internet Explorer' || !!(navigator.userAgent.match(/Trident/) || navigator.userAgent.match(/rv 11/))) { 1094 if (checkCookie) clearInterval(checkCookie); 1095 var checkCookie = setInterval(function () { 1096 var cookie = readCookie() 1097 if (cookie) { 1098 clearInterval(checkCookie); 1099 receiveData(cookie); 1100 if (popup) 1101 popup.close(); 1102 } 1103 }, 100) 1104 } 1105 1106 // This function initiates the social login calling socialLoginCallback.php in the server and sending the chosen socialNetwork. 'random' tries to avoid cache issues. 1107 var url = "/xsocial/login?socialNetwork=" + sn + "&random=" + Math.random(); 1108 console.log('url: ' + url); 1109 // In this example we use the email as CRM ID. This will be useful to later link other social networks to the same user even if her/his email is different in them. The first time it will be empty. 1110 if (document.getElementById("idcrm").value != "") 1111 url += "&id=" + document.getElementById("email").value; 1112 1113 popup = window.open(url, "Login", "width=" + (width || 650) + ", height=" + (height || 740) + ", scrollbars=yes"); 1114} 1115 1116function clearCookie() { 1117 localStorage.removeItem('x_user_data'); 1118 sessionStorage.removeItem('x_user_data'); 1119 document.cookie = "x_user_data=;path=/;expires=" + new Date(Date.now() - 1000).toGMTString(); // Clear cookie if it exists -- Borra cookie si existe. 1120} 1121 1122function readCookie() { 1123 if (!document.cookie) return 1124 var cookies = document.cookie.split("; ") 1125 for (var i = 0; cookies.length; i++) { 1126 var cookie = cookies[i].split("=") 1127 if (cookie[0] === "x_user_data") { 1128 var value = cookie[1]; 1129 clearCookie(); 1130 return value; 1131 } 1132 } 1133} 1134 1135function listen(obj, evt, func) { 1136 'addEventListener' in window ? obj.addEventListener(evt, func, false) : obj.attachEvent('on' + evt, func); 1137} 1138 1139listen(window, 'message', function (event) { 1140 console.log('Windows message: ' + event.data); 1141 if ('event data') 1142 if ((event.data.sn === 'FB' || event.data.sn === 'GO') && event.data.user) { 1143 console.log('received message from iframe: ', event.data); 1144 receiveData(event.data) 1145 } 1146}); 1147 1148function receiveData(data) { 1149 //Here we process the JSON returned by Completed, you can modify as required. 1150 facebookUser = data.user 1151 1152 if (popup) { 1153 popup.close() 1154 } 1155 1156 if (!data.xtoken || !data.user.email) { 1157 return 1158 } 1159 1160 if (registrationForm === 'lite' || registrationForm === 'ruleta') { 1161 terms = true 1162 privacy = true 1163 $('form[name=registration-lite] input[name=email]').val(data.user.email.toLowerCase()) 1164 $( "form[name=registration-lite]" ).submit() 1165 1166 $('form[name=registration-lite] input[name=xid]').val(data.xid) 1167 $('form[name=registration-lite] input[name=xtoken]').val(data.xtoken) 1168 $('form[name=registration-lite] input[name=idcrm]').val(data.idcrm) 1169 $('form[name=registration-lite] input[name=it]').val(data.it) 1170 1171 } else { 1172 facebookData = data 1173 $('#email').val(data.user.email) 1174 $( "form[name=login]" ).submit() 1175 1176 $('form #xid').val(data.xid) 1177 $('form #xtoken').val(data.xtoken) 1178 $('form #idcrm').val(data.idcrm) 1179 $('form #it').val(data.it) 1180 1181 // Update register data 1182 const info = data.user.info 1183 if (info) { 1184 if (info.name) { 1185 if (info.name.first) 1186 $('form #name').val(info.name.first); 1187 if (info.name.last) 1188 $('form #surname').val(info.name.last); 1189 } 1190 if (info.birthday) { 1191 if (info.birthday.day) { 1192 const d = info.birthday.day 1193 var day = (d < 10) ? ('0'+d) : (''+d) 1194 $('form #birthday').val(day); 1195 } 1196 if (info.birthday.month) { 1197 const m = info.birthday.month
1198 var month = (m < 10) ? ('0'+m) : (''+m) 1199 $('form #birthmonth').val(month) 1200 } 1201 if (info.birthday.year) { 1202 $('form #birthage').val(info.birthday.year) 1203 } 1204 updateBirthdate() 1205 } 1206 } 1207 } 1208 1209 // Fill form in -- Rellena el formulario. 1210} 1211 1212function updateFacebookData(user) { 1213 return new Promise(async (resolve, reject) => { 1214 console.log('updateFacebookData: ', user) 1215 if (!facebookUser) { 1216 resolve() 1217 return 1218 } 1219 try { 1220 user.set('facebookUser', facebookData) 1221 const info = facebookUser.info 1222 if (info) { 1223 // Name 1224 if (info.name) { 1225 if (info.name.first) { 1226 user.set('name', info.name.first) 1227 } 1228 if (info.name.last) { 1229 user.set('surname', info.name.last) 1230 } 1231 } 1232 // Address 1233 if (info.address) { 1234 if (info.address.country) { 1235 user.set('country', info.address.country) 1236 } 1237 if (info.address.city) { 1238 user.set('city', info.address.city) 1239 } 1240 } 1241 // Gender 1242 if (info.gender && info.gender.value) { 1243 user.set('gender', info.gender.value) 1244 } 1245 // Birthday 1246 if (info.birthday && info.birthday.time) { 1247 user.set('birthdate', info.birthday.time.substring(0,10)) 1248 } 1249 } 1250 await user.save() 1251 resolve(user) 1252 } catch (error) { 1253 reject(error) 1254 } 1255 }) 1256} 1257 1258 1259function sendToXeerpa(userParams, xeerpaParams) { 1260 return new Promise(async (resolve, reject) => { 1261 try { 1262 1263 // const params = {username: email, email, name, surname, mobile, birthdate, postalcode, allowPublicity, platform} 1264 // const xeerpaParams = {it, idcrm, xid, xtoken} 1265 var url = new URL('xsocial/saveData', window.location.origin); 1266 if (userParams.name) { url.searchParams.append('fname', userParams.name) } 1267 if (userParams.surname) { url.searchParams.append('lname', userParams.surname) } 1268 if (userParams.email) { url.searchParams.append('email', userParams.email) } 1269 if (userParams.birthday) { url.searchParams.append('birthday', userParams.birthday) } 1270 if (userParams.mobile) { url.searchParams.append('phone', userParams.mobile) } 1271 if (userParams.city) { url.searchParams.append('city', userParams.city) } 1272 if (userParams.postalcode) { url.searchParams.append('cp', userParams.postalcode) } 1273 1274 url.searchParams.append('robinson', !userParams.allowPublicity) 1275 url.searchParams.append('it', xeerpaParams.it) 1276 url.searchParams.append('idcrm', xeerpaParams.idcrm) 1277 url.searchParams.append('xid', xeerpaParams.xid) 1278 url.searchParams.append('xtoken', xeerpaParams.xtoken) 1279 const extId = xeerpaParams.extId || window.anonymousUserId 1280 if (extId) { url.searchParams.append('extId', extId) } 1281 1282 // var url = encodeURI("saveData?" + params); 1283 load(encodeURI(url.href), function (response) { 1284 // Process completed, show Thank You or error message 1285 response = JSON.parse(response); 1286 console.log('xeerpa response: ', response) 1287 if (response.error && response.error == true) { 1288 console.log('xeerpa error: ', response) 1289 reject(response) 1290 } else { 1291 resolve(response) 1292 } 1293 }); 1294 } catch (error) { 1295 console.log('sendToXeerpa error: ', error) 1296 reject(error) 1297 } 1298 }) 1299} 1300 1301function load(url, callback) { 1302 var xhr = new XMLHttpRequest(); 1303 xhr.onreadystatechange = function () { 1304 if (xhr.readyState === 4) { 1305 callback(xhr.response); 1306 } 1307 } 1308 1309 xhr.open('GET', url, true); 1310 xhr.send(''); 1311} 1312 1313function validateEmail(email) { 1314 const re = /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/; 1315 return re.test(String(email).toLowerCase()); 1316} 1317 1318// Validates that the input string is a valid date formatted as "yyyy/mm/dd" 1319function isValidDate(dateString) { 1320 // First check for the pattern 1321 if (!/^\d{4}\/\d{1,2}\/\d{1,2}$/.test(dateString)) 1322 return false;
1323 1324 // Parse the date parts to integers 1325 var parts = dateString.split("/"); 1326 var day = parseInt(parts[2], 10); 1327 var month = parseInt(parts[1], 10); 1328 var year = parseInt(parts[0], 10); 1329 1330 // Check the ranges of month and year 1331 if (year < 1000 || year > 3000 || month == 0 || month > 12) 1332 return false; 1333 1334 var monthLength = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]; 1335 1336 // Adjust for leap years 1337 if (year % 400 == 0 || (year % 100 != 0 && year % 4 == 0)) 1338 monthLength[1] = 29; 1339 1340 // Check the range of the day 1341 return day > 0 && day <= monthLength[month - 1]; 1342} 1343 1344const isEmpty = (obj) => { 1345 if (obj === undefined || obj === null) { return true } 1346 switch (typeof obj) { 1347 case 'string': 1348 return obj.length == 0 1349 case 'boolean': 1350 return false 1351 case 'number': { 1352 return isNaN(obj) 1353 } 1354 case 'object': { 1355 if (Array.isArray(obj)) { 1356 return obj.length == 0 1357 } 1358 return false 1359 } 1360 } 1361 return false 1362} 1363 1364function hideUnNeededFields() { 1365 if (!selectedCard.showStreamingPlatforms) { 1366 $('#requalify_streamingPlatforms').addClass('hidden') 1367 } 1368 if (!selectedCard.additionalUserClubinText) { 1369 $('#requalify_additionalUserClubinText').addClass('hidden') 1370 } else { 1371 $('#requalify_additionalUserClubinText').removeClass('hidden') 1372 } 1373} 1374 1375function saveAdditionalParams() { 1376 var selectedPlatforms = [] 1377 $.each($('#streamingPlatforms').find(':selected'), function (index, item) { 1378 selectedPlatforms.push(item.value) 1379 } 1380 ) 1381 const additionalUserClubinTextField = selectedCard.additionalUserClubinText; 1382 const additionalUserClubinText = $('form[name=requalify] textarea[name=additionalUserClubinText]').val().trim(); 1383 if (selectedPlatforms.length || additionalUserClubinTextField) { 1384 console.log("Selected card", selectedCard); 1385 Parse.Cloud.run('saveClubbinCardResponse', { 1386 clubbinCardId: selectedCard.objectId, 1387 data: { 1388 platforms: selectedPlatforms, 1389 additionalUserClubinTextField, 1390 additionalUserClubinText 1391 } 1392 }) 1393 } 1394} 1395 1396function runAdformScriptsBySiteAndRouteAndUser(site, user) { 1397 1398 switch (site.domain) { 1399 case 'tuamc.tv': 1400 1401 if (user.get('registrationForm') == 'unete') { 1402 userRegisterUneteScript(user.id, user.get('platform'), user.get('favouriteChannels').join()) 1403 } 1404 break; 1405 1406 case 'amcselekt.es': 1407 1408 if (user.get('registrationForm') == 'unete') { 1409 userRegisterUneteScript(user.id, user.get('platform'), user.get('favouriteChannels').join()) 1410 } 1411 break; 1412 1413 case 'amcchannels.es': 1414 1415 if (user.get('registrationForm') == 'unete') { 1416 userRegisterUneteScript(user.id, user.get('platform'), user.get('favouriteChannels').join()) 1417 } 1418 break; 1419 1420 case 'oteuamc.tv': 1421 1422 userOteuRegisterScript() 1423 break; 1424 } 1425 1426} 1427 1428function userRegisterUneteScript(userId, platform, channels) { 1429 window._adftrack = Array.isArray(window._adftrack) ? window._adftrack : (window._adftrack ? [window._adftrack] : []); 1430 window._adftrack.push({ 1431 HttpHost: 'track.adform.net', 1432 pm: 1661778, 1433 divider: encodeURIComponent('|'), 1434 pagename: encodeURIComponent('Registro - Clubbin - Unete'), 1435 order : { 1436 sv1: `${userId}`, 1437 sv2: `${platform}`, 1438 sv3: `${channels}`, 1439 sv4: `orgánico`, 1440 }, 1441 eids: [{ 1442 source: site ? site.domain : 'amcchannels.es', 1443 uids: [{ 1444 atype: 1, 1445 id: userId 1446 }] 1447 }] 1448 }); 1449 (function () { var s = document.createElement('script'); s.type = 'text/javascript'; s.async = true; s.src = 'https://s2.adform.net/banners/scripts/st/trackpoint-async.js'; var x = document.getElementsByTagName('script')[0]; x.parentNode.insertBefore(s, x); })(); 1450} 1451 1452function userOteuRegisterScript() { 1453 window._adftrack = Array.isArray(window._adftrack) ? window._adftrack : (window._adftrack ? [window._adftrack] : []); 1454 window._adftrack.push({ 1455 HttpHost: 'track.adform.net', 1456 pm: 1661778, 1457 divider: encodeURIComponent('|'), 1458 pagename: encodeURIComponent('oteuamc_registro'), 1459 eids: [{ 1460 source: site ? site.domain : 'amcchannels.es', 1461 uids: [{ 1462 atype: 1, 1463 id: currentUser ? currentUser.id : undefined 1464 }] 1465 }] 1466 }); 1467 (function 1468 () { var s = document.createElement('script'); s.type = 1469 'text/javascript'; s.async = true; s.src = 1470 'https://s2.adform.net/banners/scripts/st/trackpoint-async.js'; 1471 var x = document.getElementsByTagName('script')[0]; 1472 x.parentNode.insertBefore(s, x); })(); 1473} 1474 1475function generateRegistrationFormRules() { 1476 if (registrationForm === 'lite' || registrationForm === 'ruleta') { 1477 registrationFormRules = { 1478 // The key name on the left side is the name attribute 1479 // of an input field. Validation rules are defined 1480 // on the right side 1481 email: { 1482 required: true, 1483 // Specify that email should be validated 1484 // by the built-in "email" rule 1485 email: true // Even if this field is not required if this is set to true it will complain for not valid or blank emails 1486 } 1487 } 1488 } else if (site && site.registrationFormFields) { 1489 registrationFormRules = { 1490 // The key name on the left side is the name attribute 1491 // of an input field. Validation rules are defined 1492 // on the right side 1493 name: "required", 1494 email: { 1495 required: true, 1496 // Specify that email should be validated 1497 // by the built-in "email" rule 1498 email: true // Even if this field is not required if this is set to true it will complain for not valid or blank emails 1499 }, 1500 birthday: { 1501 required: true, 1502 }, 1503 birthmonth: { 1504 required: true, 1505 }, 1506 birthage: { 1507 required: true, 1508 }, 1509 birthdate: { 1510 above18years: ['registration'] 1511 }, 1512 surname: { 1513 required: site.registrationFormFields.mandatory.surname ? true : false, 1514 }, 1515 postalcode: postalCodeRules, 1516 platforms: { 1517 platformSelected: ['registration'] 1518 }, 1519 favouriteChannels : { 1520 required: true 1521 } 1522 } 1523 } 1524 // console.log(registrationFormRules); 1525} 1526 1527function registrationLitePopUp() { 1528 $('#form-registration-email').css('display', 'flex') 1529 //$('#register-image').hide() 1530 //$('#register-param-image').show() 1531 registrationForm = 'lite' 1532 generateRegistrationFormRules() 1533 showRegisterLiteModal() 1534} 1535 1536function registrationRoulettePopUp() { 1537 $('#form-registration-email').css('display', 'flex') 1538 //$('#register-image').hide() 1539 //$('#register-param-image').show() 1540 registrationForm = 'ruleta' 1541 generateRegistrationFormRules() 1542 showRegisterLiteModal() 1543}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.