1// DETECTS IF NAMESPACE OF THE APP EXISTS, CREATES THE NAMESPACE OF THE APP. 2if (!JSC) var JSC = {}; 3else if (JSC && typeof (JSC) != "object") 4 throw new Error("JSC is not an Object type"); 5 6JSC.OCOLORBOX = { 7 "login" : { width:"608", height:"480", fixed:true, iframe:true }, 8 "question" : { width:"608", height:"480", fixed:true, iframe:true }, 9 "infojogo": { width:"608", height:"480", fixed:true, iframe:true }, 10 "lotclasPop": { width:"608", height:"400", fixed:true, iframe:true }, 11 "personalData": { width:"380", height:"325", fixed:true, iframe:true }, 12 "firstLogin" : { width:"668", height:"650", fixed:true, iframe:true, href:"/html/messages/welcome/welcomePopup.jsp"}, 13 "underage" : {width:"400", height:"120", href:"/html/account/cc/underage.jsp", onClosed: function() {window.location.href = '/';}} 14}; 15 16/* JSC.MAIN 17 * All application initialization in this class name 18 */ 19JSC.MAIN = (function ($) { 20 21 // PRIVATE ATTRIBUTES. ONLY PRIVELEGED METHODS MAY VIEW/EDIT/INVOKE 22 var _that = {}; 23 24 // PRIVATE MEMBERS. ONLY PRIVELEGED METHODS MAY VIEW/EDIT/INVOKE. 25 26 //RETURN OBJECT LITERAL. 27 return { 28 //PUBLIC ATTRIBUTES ANYONE MAY READ/WRITE. 29 NAME: "Application initialize module", 30 VERSION: 1.3, 31 32 // PUBLIC MEMBERS ANYONE MAY READ/WRITE. (MAY BE OVERRIDEN). 33 // PUBLIC METHOD THAT INITIALIZES MAIN APP. 34 init: function () { 35 36 _that = this; 37 38 this.loadInits(); 39 40 this.colorBox('.question', JSC.OCOLORBOX.question); // INIT QUESTION COLORBOX. 41 this.colorBox('.infojogo', JSC.OCOLORBOX.infojogo); // INIT QUESTION COLORBOX. 42 this.colorBox('.lotclasPop', JSC.OCOLORBOX.lotclasPop); 43 this.colorBox('.personalData', JSC.OCOLORBOX.personalData); 44 }, 45 46 /** 47 * Run all the init methods 48 */ 49 loadInits: function() { 50 for (var func in this) { 51 if (typeof this[func] == 'function' && func.substr(0,4) == 'init' && func != 'init') { 52 this[func](); 53 } 54 } 55 }, 56 57 // INIT MENU, CALCULATE THE WIDTH OF LIS, SUM OF UL, CALCULATE THE WIDTH FOR THE BACKGROUND. 58 initMenu : function (){ 59 if ( !$('.menu').length ) return false; 60 61 var split = Breadcrumb.location.split('/'); 62 $.each(split, function (i, el) { 63 split[i] = el.toLowerCase(); 64 }); 65 66 $('li.firstLevel > a').each(function(i, el) { 67 var this_ = $(this); 68 if (this_.html().toLowerCase() == split[0]){ 69 this_ = this_.parent().addClass('defaultLevel'); 70 return false; 71 } 72 }); 73 74 JSC.UI.initOverMenu(); 75 76 /* not in f6 code JSC.UI.initCalculateWidth('ul.menu', 'firstLevel'); */ 77 78 if ( /iphone|ipad|ipod|android|blackberry|mini|windows\sce|palm/i.test(navigator.userAgent.toLowerCase()) ){ 79 JSC.MOBILE.menuInteraction(); 80 } 81 }, 82 83 redirectLogin : function() { 84 $('.redirect-to-self').each(function() { 85 var this_ = $(this); 86 if (this_.attr('href').indexOf('r=') > -1) return; 87 88 var href = window.parent.location.href; 89 var i = href.indexOf('#'); 90 var str = 'r='; 91 if (i >= 0) { 92 str += href.substring(0, i); 93 } else { 94 str += href; 95 } 96 97 if (this_.attr('href').indexOf('?') < 0) { 98 this_.attr('href', this_.attr('href') + "?" + str); 99 } 100 else { 101 this_.attr('href', this_.attr('href') + "&" + str); 102 } 103 }); 104 }, 105 106 // INIT CSS FIX FOR BANNERS. 107 initCssBanners : function (){ 108 if ( !$('.banners').length ) return false; 109 110 JSC.UI.cssBanners(); 111 }, 112 113 initJokerAlert : function (){ 114 if ( !$('a[href="#"][title="joker"]').length ) return false; 115 116 JSC.UI.initJokerAlert(); 117 }, 118 119 // INIT CAROUSEL WITH ARROWS AND PAGINATION. 120 initSingleCarouselPagination : function (){ 121 if ( !$('.blockSingleCarousel').length ) return false; 122 123 JSC.UI.singleCarouselPagination(); 124 }, 125
126 // INIT FOOTER - MINOR CSS FIX, AND UL LI CALCULATE WIDTH. 127 initFooter : function (){ 128 if ( !$('.footer').length ) return false; 129 130 JSC.UI.initFooter(); 131 }, 132 133 initStripped : function () { 134 if ( !$('.stripped').length ) return false; 135 136 JSC.UI.initStripped(); 137 }, 138 139 // INIT CSS FIX FOR LINK IN MY ACCOUNT. 140 initMyAccountLink : function (){ 141 if ( !$('.contentMyAccout').length ) return false; 142 143 JSC.UI.myAccountLink(); 144 }, 145 146 loginPopup: function (logged) { 147 if (JSC.MOBILE && !JSC.MOBILE.isMobile) { 148 var str = 'frame=true'; 149 150 if (logged) { 151 $('.menu .cboxElement').removeClass('cboxElement'); 152 $('.loginPopup').each(function () { 153 var this_ = $(this); 154 if(this_.attr('href').indexOf('frame') > -1) { 155 this_.attr('href', this_.attr('href').replace(str, '')); 156 }; 157 }); 158 } else { 159 this.colorBox('.loginPopup', JSC.OCOLORBOX.login); // INIT LOGIN COLORBOX. 160 $('.loginPopup').each(function () { 161 var this_ = $(this); 162 if (this_.attr('href').indexOf('frame') < 0) { 163 if (this_.attr('href').indexOf('?') < 0) { 164 this_.attr('href', this_.attr('href') + "?" + str); 165 } 166 else { 167 this_.attr('href', this_.attr('href') + "&" + str); 168 } 169 } 170 }); 171 } 172 } 173 174 this.redirectLogin(); 175 }, 176 177 initLoginPopup: function (logged){ 178 this.loginPopup(false); 179 }, 180 181 // INIT LOGIN VIRTUAL KEYBOARD. 182 initLogin : function (){ 183 if ( !$('.wrapper-login').length ) return false; 184 185 JSC.UI.initLogin(); 186 }, 187 188 initBackspaceIntercept : function () { 189 if ( !$('input[type="password"]').length ) return false; 190 191 JSC.UI.initInterceptBackspace(); 192 }, 193 194 initValidCharText: function() { 195 if ( !$('input[type="text"]').length ) return false; 196 197 JSC.UI.validateChars(); 198 }, 199 200 /* JSC.MAIN.colorBox 201 * method that inits jquery plugin colorbox 202 * Params: [DOM Element] el - string of the el to be applied the plugin 203 * Params: [Object] opts - object with the necessary options for the initialization of the plugin 204 */ 205 colorBox : function (el, opts){ 206 if ( !$(el).length ) return false; 207 208 $(el).colorbox(opts); 209 }, 210 211 // INIT VALID FORM RECOVER PASSWORD. 212 initValidRecoverPass : function (){ 213 if ( $('.wrapper-login').length || !$('.contentRecoverPass').length ) return false; 214 215 JSC.UI.validRecoverPass('recoverPassword'); 216 }, 217 218 // INIT VALID FORM REGISTRATION STEP ONE. 219 initValidRegStepOne : function (){ 220 if ( !$('.contentRegistration').length ) return false; 221 222 JSC.UI.validRegStepOne(); 223 }, 224 225 // INIT VALID FORM REGISTRATION STEP TWO. 226 initValidRegStepTwo : function (){ 227 if ( !$('.contentRegistrationStepTwo').length ) return false; 228 229 JSC.UI.validRegStepTwo(); 230 }, 231 232 // INIT VALID FORM REGISTRATION STEP THREE. 233 initValidRegStepThree : function (){ 234 if ( !$('.contentRegistrationStepThree').length ) return false; 235 236 JSC.UI.validRegStepThree(); 237 }, 238 239 // INIT VALID FORM REGISTRATION PAGE TAB. 240 initValidRegPage : function (){ 241 if ( !$('.contentTabB').length ) return false; 242 243 JSC.UI.validRegPage(); 244 }, 245 246 // INIT VALID PRIZE HISTORY PAGE. 247 initValidHistPremios : function (){ 248 if ( !$('.histPrizes').length ) return false; 249 250 JSC.UI.validHistPremios(); 251 }, 252 253 // INIT RANDOM LETTERS NUMBERS IN VIRTUAL KEYBOARD. 254 initKeyboardRandom : function (){ 255 if ( !$('.keyboardBox').length ) return false; 256 257 JSC.UI.keyboardRandom(); 258 }, 259 260 // INIT RANDOM NUMBERS IN VIRTUAL KEYBOARD. 261 initKeyboard2Random : function (){ 262 if ( !$('.keyboardBox2').length ) return false; 263 264 JSC.UI.keyboardRandom(); 265 }, 266 267 // INIT REGISTRATION TABS. 268 initRegTabs : function (){ 269 if ( !$('.tabsRegistration').length ) return false; 270 271 JSC.UI.registrationTabs(); 272 }, 273 274 // INIT CARD TABS. 275 initCardTabs : function (){ 276 if ( !$('.tabsCards').length ) return false; 277 278 JSC.UI.cardTabs(); 279 }, 280 281 // INIT GAMES TABS. 282 initGameTabs : function (){ 283 if ( !$('.tabsGames').length ) return false; 284 285 JSC.UI.gameTabs(); 286 }, 287 288 // INIT FOCUS BLUR EVENTS ON INPUT TYPE TEXT. 289 /*initFieldInputText : function(){ 290 if ( !$('.field input[type="text"]').length ) return false;
291 292 JSC.UI.initFieldInputText(); 293 }, 294 295 // INIT FOCUS BLUR EVENTS ON INPUT TYPE TEXT. 296 initFieldInputPassword : function(){ 297 if ( !$('.field input[type="password"]').length ) return false; 298 299 JSC.UI.initFieldInputPassword(); 300 },*/ 301 302 initFieldInput : function(){ 303 if ( !$('.field input[type=password], .field input[type=text]').length ) return false; 304 305 JSC.UI.initFieldInput(); 306 }, 307 308 //INIT GENERAL FORM STYLES 309 initFormStyles : function(){ 310 if ($.jStyling) { 311 JSC.UI.styleFormElemets(); 312 } 313 }, 314 315 // INIT EMAIL PAGINATION 316 initEmailPagination : function(){ 317 if ( !$('.paging_emailCtn').length ) return false; 318 319 JSC.UI.emailPagination(); 320 }, 321 322 initCardMovementsPagination : function(){ 323 if ( !$('.paging_CardCtn').length ) return false; 324 325 JSC.UI.cardMovementsPagination(); 326 }, 327 328 initSearchMediatorPagination : function(){ 329 if ( !($('#containerSearch').length && $('.salePointSearch3').length) ) return false; 330 331 JSC.UI.searchMediatorPagination(); 332 }, 333 334 // INIT EMAIL SELECT ALL MESSAGES 335 initEmailSelectAll : function(){ 336 if ( !$('.emailSelectAll').length ) return false; 337 338 JSC.UI.emailSelectAll(); 339 }, 340 341 342 // INIT MYKEYS SELECT ALL KEYS 343 initMyKeysSelectAll : function(){ 344 if ( !$('.mykeysSelectAll').length ) return false; 345 346 JSC.UI.myKeysSelectAll(); 347 }, 348 349 // INIT SEARCH LABEL DEFAULT VALUE. 350 initSearchLabelValue : function (){ 351 if ( !$('.inputSearchBlock').length ) return false; 352 353 JSC.UI.initLabelDefaultValue('.inputSearchBlock input[type="text"]'); 354 }, 355 356 // INIT COLS EQUAL HEIGTH. - Retirado para o SoM e SM 24/09/2016 357 // initColsEqualHeigth : function (){ 358 // if ( !$('.colum').length ) return false; 359 360 // JSC.UI.colsEqualHeigth( $(".colum") ); 361 // }, 362 363 // INIT SCROLLPANE IN POPIN. 364 initPopinScroll : function (){ 365 if ( !$('.scrolInfo').length ) return false; 366 367 JSC.UI.initPopinScroll(); 368 }, 369 370 /* 371 // INIT SCROLLPANE. 372 initScrollPane : function (){ 373 if ( !$('.scroll-pane').length ) return false; 374 375 JSC.UI.initScrollPane(); 376 }, 377 */ 378 379 // INIT BET CUSTOM FORM. 380 initBetCustomForm : function (){ 381 if ( !$('.sendBtn').length ) return false; 382 383 JSC.UI.betCustomForm(); 384 }, 385 386 // INIT ADVANCE TO PAYMENT PAGE IF CONFIRMED 387 initConfirmPayment : function(){ 388 if ( !$('.confirmPayment').length ) return false; 389 390 JSC.UI.initConfirmPayment(); 391 }, 392 393 initTooltipSearch : function(){ 394 if ( !$('.searchContent').length ) return false; 395 396 JSC.UI.tooltipSearch(); 397 }, 398 399 initFocusBlurInput : function(){ 400 if ( !$('.focusBlurInput').length ) return false; 401 402 JSC.UI.initFocusBlurInput(); 403 }, 404 405 initDatePicker : function(){ 406 if ( !$('.datepicker').length ) return false; 407 408 if( $('.year1700').length){ 409 year = 1700; 410 411 JSC.UI.initDatePicker(year); 412 }else{ 413 year = 1900; 414 JSC.UI.initDatePicker(year); 415 } 416 }, 417 418 initHistorySearchVal : function(){ 419 if ( !$('.histSearchVal').length ) return false; 420 421 JSC.UI.initHistorySearchVal(); 422 }, 423 424 initTooltipTotoBola : function(){ 425 if ( !$('.tbolaColWrp').length ) return false; 426 427 JSC.UI.tooltipTotoBola(); 428 }, 429 430 initMyKeysSms : function(){ 431 if ( !$('.mykeySms').length ) return false; 432 433 JSC.UI.myKeysSms (); 434 }, 435 436 437 initValidateLotary : function(){ 438 if ( !$('.ticketForm').length ) return false; 439 440 JSC.UI.validateLotary(); 441 }, 442 443 // INIT Show/Hide BUTTONS IN REGIS AUTO 444 initRegisAutoButtons : function(){ 445 if ( !$('.sortButtons').length ) return false; 446 447 JSC.UI.regisAutoButtons(); 448 }, 449 450 // INIT LOTARY SEARCH RESULTS - SELECT ALL INPUTS 451 initLotarySelectAllResults : function(){ 452 if ( !$('.lotarySelectAllResults').length ) return false; 453 454 JSC.UI.lotarySelectAllResults(); 455 }, 456 457 initHijaxing : function() { 458 JSC.UI.hijaxing(); 459 }, 460 461 //Init formContent TEXTAREA blur quickPlay 462 initFormContentBlur: function() { 463 if ( !$('.formContent').length) return false; 464 JSC.UI.formContentBlur(); 465 }, 466 467 //INIT MINHA CONTA GESTÃO - NOTIFICAÇÕES 468 initGame: function() { 469 if ( !$('.game input[type=checkbox]').length ) return false; 470 JSC.UI.gameOption(); 471 }, 472 473 //Init sortManager 474 initSortManager: function() { 475 if ( !$('.sortTable').length ) return false;
476 JSC.UI.sortManager(); 477 }, 478 479 initPesqNibBtn: function() { 480 if ( !$('.pesqNibBtn').length ) return false; 481 JSC.UI.pesqNibBtn(); 482 483 }, 484 485 //Init sortManager 486 initMoneyWon: function() { 487 if ( !$('.howMuchWin').length ) return false; 488 JSC.UI.moneyWon(); 489 }, 490 491 initMyAwards: function() { 492 if ( !$('.myAwards').length ) return false; 493 JSC.UI.myAwards(); 494 }, 495 496 //Init Form Contact Manager 497 /*initFormContact: function() { 498 if ( !$('.formContact').length) return false; 499 JSC.UI.formContact(); 500 },*/ 501 502 //Init expand/collapse in site map 503 initExpandMap: function() { 504 if ( !$('.map').length) return false; 505 JSC.UI.expandMap(); 506 }, 507 508 initPrintBehavior:function(){ 509 if ( !$('.btnPrint').length) return false; 510 JSC.UI.printBehavior(); 511 }, 512 513 initMouseLeaveDropDown:function(){ 514 //if ( !$('.print').length ) return false; 515 516 JSC.UI.mouseLeaveDropForm(); 517 518 }, 519 520 initPageCssBackground: function(){ 521 522 if( $('.contentErrorPage').length){ 523 JSC.UI.pageCssBackground(); 524 525 $(window).resize(function(){ 526 JSC.UI.pageCssBackground(); 527 }) 528 529 } 530 }, 531 532 initDetectIpadIphoneIpod: function(){ 533 if (JSC.MOBILE) { 534 JSC.MOBILE.detectIpadIphoneIpod(); 535 } 536 }, 537 538 initSelectIdentifValue: function() { 539 if ( $(".selectIdentif").length ) { 540 $(".selectIdentif").data('pre', $(".selectIdentif").val()); 541 } 542 }, 543 544 initSelectDisableIfOutro: function() { 545 $('.selectIdentif').change(function() { 546 var $t = $(this), 547 v = $t.val(); 548 549 if ( $("#issuedBy").length ) { 550 if (v == '1') { 551 updateIssuedBy(true, 'República Portuguesa', true); 552 } else if (v == '2') { 553 updateIssuedBy(true, 'Serviço de Estrangeiros e Fronteiras', true); 554 } else { 555 updateIssuedBy($t.data('pre') != v, '' , false); 556 } 557 } 558 559 // desactivar opção de documento vitalício 560 if ( $("#identificationLifetime").length ) { 561 var ilt = $("#identificationLifetime"); 562 if (v == '3') { 563 ilt.attr('disabled',false); 564 ilt.removeClass('disabled'); 565 ilt.parent().removeClass('disabled'); 566 } else { 567 ilt.attr('checked', false); 568 ilt.attr('disabled',true); 569 ilt.addClass('disabled'); 570 ilt.parent().addClass('disabled'); 571 ilt.parent().removeClass('active'); 572 } 573 // remove disabled from expire date 574 updateExpirationDate($("#identificationLifetime").attr('checked'), $t.data('pre') != v); 575 } 576 577 $t.data('pre', v); 578 }).trigger('change'); 579 }, 580 581 initIdentificationLifetime: function() { 582 $('#identificationLifetime').change(function() { 583 updateExpirationDate($(this).attr('checked'), true); 584 }); 585 586 if($("#identificationLifetime").attr('checked')) { 587 $("#identificationLifetime").trigger('change') 588 } 589 }, 590 591 initFocus: function () { 592 $('.focus').focus(); 593 }, 594 595 initCorners: function () { 596 var tag = '<div class="{0}"></div>'; 597 var html = $('<div class="corners-wrapper"></div>'); 598 var corners = ['top-left', 'top-right', 'bottom-right', 'bottom-left']; 599 for (var i in [0, 1, 2, 3]) { 600 html.append(tag.replace('{0}', corners[i])); 601 } 602 $('.corners:not(:has(.corners-wrapper))').append(html); 603 }, 604 605 loadHeader: function () { 606 $.ajax({ 607 type : 'GET', 608 cache: false, 609 url : '/web/SCHome/header', 610 success : function(data) { 611 if (data.length) { 612 $('#info').replaceWith(data); 613 } 614 } 615 }); 616 }, 617 618 loadToken: function (sTitle, sRedirectFromPopIn) { 619 history.pushState({id: '1'}, sTitle, sRedirectFromPopIn); 620 } 621 } 622}(jQuery)); // THE PARENS HERE CAUSE THE ANONYMOUS FUNCTION TO EXECUTE AND RETURN. 623 624// ON DOM READY INIT APPLICATION. 625jQuery(document).ready(function(){ 626 627 JSC.UI.RunCodeBeforeAnyEventBindingViaJquery(); 628 629 //THE APP MAIN MODULE CODE HAS ALREADY EXECUTED, SO WE CAN ACCESS THE INIT METHOD IMMEDIATELY. 630 JSC.MAIN.init(); 631 JSC.MAIN.codeFormat(); //Format Codes on ready 632 633}); 634 635/** 636 * Outputs a log of the passed in object. This is centralized in one method so 637 * that we can keep info logs around the site and easily disable/enable them 638 * when jumping between live/dev. 639 * @param {string} o Message to log to console. 640 */ 641JSC.log = function (o) { 642 if (window.console && o) { 643 window.console.log(o); 644 } 645}; 646 647 648/** 649 * Formats Codes from M1 and CMIL 650 * with desired format 651 */ 652JSC.MAIN.codeFormat = function(){ 653 try{ 654 $('[name=code_m1]').each(function(){ 655 var output = $(this).text().replace(/([BCDFGHJKLMNPQRSTVWXZ]{3})(\d{5})/g, "$1 $2"); 656 $(this).text(output); 657 }); 658 } catch(e){ 659 //do nothing 660 } 661 try{ 662 $('[name=code_cmil]').each(function(){ 663 var output = $(this).text().replace(/([BHJMTVXZFIPERLAOWNSCDGKQUY])([BCDFGHJKLMNPQRSTVWXZ]{3})(\d{5})/g, "$1 $2 $3"); 664 $(this).text(output); 665 }); 666 }catch(e){ 667 //do nothing 668 } 669} 670 671setDisabled = function(disabled, element, parent) { 672 if (disabled) { 673 element.attr('disabled',true); 674 parent.addClass('disabled'); 675 } else { 676 element.attr('disabled', false); 677 parent.removeClass('disabled'); 678 } 679} 680 681updateExpirationDate = function(disabled, resetValue) { 682 var edD = $('#expirationDateDay'), edM = $('#expirationDateMonth'), edY = $('#expirationDateYear'); 683 684 setDisabled(disabled, edD, edD.parent()); 685 setDisabled(disabled, edM, edM.parent()); 686 setDisabled(disabled, edY, edY.parent()); 687 688 if (resetValue) { 689 edD.val('0'); 690 edD.attr('value', '0'); 691 edM.val('0'); 692 edM.attr('value', '0'); 693 edY.val('0'); 694 edY.attr('value', '0'); 695 696 $('.jstyling-select-t_expirationDateDay').text($("#expirationDateDay option[value='0']").text()); 697 $('.jstyling-select-t_expirationDateMonth').text($("#expirationDateMonth option[value='0']").text()); 698 $('.jstyling-select-t_expirationDateYear').text($("#expirationDateYear option[value='0']").text()); 699 } 700} 701
702updateIssuedBy = function(changeValue, textValue, readOnly) { 703 var issuedBy = $("#issuedBy"), issuedByP = issuedBy.parent().parent(); 704 705 if (changeValue) { 706 issuedBy.val(textValue); 707 issuedBy.attr('value', textValue); 708 } 709 710 if (readOnly) { 711 issuedBy.attr('readOnly',true); 712 issuedByP.addClass('disabled'); 713 } else { 714 issuedBy.attr('readOnly',false); 715 issuedByP.removeClass('disabled'); 716 } 717}
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.