Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /** > /scripts-v1705/profil/utils.js **/
- /*
- * $Id: utils.js,v 1.7 2016/10/20 09:27:47 mbenrebia Exp $
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
- var StrutsUtils = {};
- // gets an object with validation errors from string returned by
- // the ajaxValidation interceptor
- StrutsUtils.getValidationErrors = function(data) {
- if (data.indexOf("{}&& {") == 0) {
- return eval("( " + data.substring(4, data.length) + " )");
- } else {
- return null;
- }
- };
- StrutsUtils.clearValidationErrors = function(form) {
- clearErrors(form);
- };
- StrutsUtils.clearActionErrors = function(errorMsgDiv) {
- clearActionErrors(errorMsgDiv);
- };
- // shows validation errors using functions from xhtml/validation.js
- // or css_xhtml/validation.js
- StrutsUtils.showValidationErrors = function(form, errors) {
- StrutsUtils.clearValidationErrors(form, errors);
- StrutsUtils.clearActionErrors();
- if (errors.fieldErrors) {
- for (var fieldName in errors.fieldErrors) {
- for (var i = 0; i < errors.fieldErrors[fieldName].length; i++) {
- //var el = form.elements[fieldName];
- //alert( form.elements[fieldName] );
- //if (form.elements[fieldName][0] && form.elements[fieldName][0].type == 'radio')
- //if (el instanceof NodeList)
- // addError(el[0], errors.fieldErrors[fieldName][i]);
- //else
- addError(fieldName, errors.fieldErrors[fieldName][i]);
- }
- }
- }
- if (errors.actionErrors) {
- for (var i = 0; i < errors.actionErrors.length; i++) {
- addActionError(errors.actionErrors[i]);
- }
- }
- };
- StrutsUtils.firstElement = function(parentNode, tagName) {
- var node = parentNode.firstChild;
- while (node && node.nodeType != 1) {
- node = node.nextSibling;
- }
- if (tagName && node && node.tagName && node.tagName.toLowerCase() != tagName.toLowerCase()) {
- node = StrutsUtils.nextElement(node, tagName);
- }
- return node;
- };
- StrutsUtils.nextElement = function(node, tagName) {
- if (!node) {
- return null;
- }
- do {
- node = node.nextSibling;
- } while (node && node.nodeType != 1);
- if (node && tagName && tagName.toLowerCase() != node.tagName.toLowerCase()) {
- return StrutsUtils.nextElement(node, tagName);
- }
- return node;
- };
- StrutsUtils.previousElement = function(node, tagName) {
- if (!node) {
- return null;
- }
- if (tagName) {
- tagName = tagName.toLowerCase();
- }
- do {
- node = node.previousSibling;
- } while (node && node.nodeType != 1);
- if (node && tagName && tagName.toLowerCase() != node.tagName.toLowerCase()) {
- return StrutsUtils.previousElement(node, tagName);
- }
- return node;
- };
- StrutsUtils.addOnLoad = function(func) {
- var oldonload = window.onload;
- if (typeof window.onload != 'function') {
- window.onload = func;
- } else {
- window.onload = function() {
- oldonload();
- func();
- }
- }
- };
- StrutsUtils.addEventListener = function(element, name, observer, capture) {
- if (element.addEventListener) {
- element.addEventListener(name, observer, false);
- } else if (element.attachEvent) {
- element.attachEvent('on' + name, observer);
- }
- };
- /* -------------------------------
- /* Ajout Spikly le 28/01/2012
- /* nouvel espace perso
- /* ------------------------------- */
- utilsProfil = {
- init: function() {
- this.setBackgroundImage();
- this._rewriteUrlDmname();
- },
- _rewriteUrlDmname: function() {
- if (jQuery(".http").length) {
- var preDomName = document.domain.match(/www\.|secure\.|s\-/, "");
- if (preDomName == "secure.") {
- jQuery(".http").attr("href", jQuery(".http").attr("href").replace(/www\.|secure\.|s\-/, "www."));
- } else if (preDomName == "s-") {
- jQuery(".http").attr("href", jQuery(".http").attr("href").replace(/www\.|secure\.|s\-/, ""));
- }
- }
- },
- setBackgroundImage :function(){
- var country = this.getCookie('displayZone'),
- userLang = this.getCookie('userLang'),
- selectedCountry = ['malaysia' , 'indonesia' ,'india' , 'bahrain' ,'jordan' , 'kuwait' ,'lebanon' ,'oman' ,'qatar' , 'saudi-arabia' ,'united-arab-emirates','other-regions-of-middle-east'] ;
- if(selectedCountry.indexOf(country) > -1 || ['ar' ,'tr'].indexOf(userLang) > -1){
- if(!jQuery('.mainContainer').parent().hasClass('registration'))
- jQuery(".mainContainer").css('background-image' , 'url("/imagerie/profil/bg-visuel_ar.jpg")')
- }else{
- if(!jQuery('.mainContainer').parent().hasClass('registration'))
- jQuery(".mainContainer").css('background-image' , 'url("/imagerie/profil/bg-visuel.jpg")')
- }
- },
- getCookie:function(cname) {
- var name = cname + "=";
- var ca = document.cookie.split(';');
- for(var i = 0; i <ca.length; i++) {
- var c = ca[i];
- while (c.charAt(0)==' ') {
- c = c.substring(1);
- }
- if (c.indexOf(name) == 0) {
- return c.substring(name.length,c.length);
- }
- }
- return "";
- }
- }
- jQuery(document).ready(function() {
- utilsProfil.init();
- });
- /** < /scripts-v1705/profil/utils.js **/
- /** > /scripts-v1705/profil/booking-engine.js **/
- var bookingEngine = {
- _init: function(){
- bookingEngineRegistration = new BookingEngine("bookingEngine", "bookingEngineRegistration", true);
- //Ajax request
- ajaxRequest._executeByUrl(
- "/bean/getViewBeans.action?beans=SearchCriteriaViewBean|OriginViewBean|CurrenciesViewBean|UserViewBean|WebSiteFunctionnalitiesViewBean|LoyaltyAccountViewBean",
- "validatorInvalidState",
- "bookingEngine._profilbookingsucess(errors, response)"
- );
- },
- _profilbookingsucess : function(errors, response){
- bookingEngineRegistration.success(errors, response);
- var viewBeans = {
- UserViewBean : response.viewBeans.UserViewBean,
- SearchCriteriaViewBean : response.viewBeans.SearchCriteriaViewBean
- }
- this._generateproinput(viewBeans);
- },
- _generateproinput : function (viewBeans){
- this._setInputProValue(viewBeans);
- if(jQuery("#identification-reserverContract-boo").val() == '' || jQuery("#identification-reserverContract-boo").val() == jQuery("#identification-reserverContract-boo").attr("title") &&(jQuery("#identification-reserverId-boo").val() == '' || jQuery("#identification-reserverId-boo").val() == jQuery("#identification-reserverId-boo").attr("title"))){
- jQuery('#pro-input').hide();
- }else{
- jQuery('#pro-input').show();
- jQuery("#identification-businessTravel-boo").attr('checked',false);
- this._setProInputObservers();
- }
- },
- _setProInputObservers : function(){
- jQuery("#identification-reserverContract-boo , #identification-reserverId-boo").focusout(function () {
- if((jQuery("#identification-reserverContract-boo").val() == '' || jQuery("#identification-reserverContract-boo").val() == jQuery("#identification-reserverContract-boo").attr("title")) && (jQuery("#identification-reserverId-boo").val() == '' || jQuery("#identification-reserverId-boo").val() == jQuery("#identification-reserverId-boo").attr("title"))){
- jQuery("#identification-businessTravel-boo").attr('checked',false);
- }else{
- jQuery("#identification-businessTravel-boo").attr('checked',true);
- }
- });
- },
- _setInputProValue :function(viewBeans){
- var AccountContract = "" ;
- var AccountId = "";
- // if search Criteria load Searched Criter
- if(viewBeans.SearchCriteriaViewBean && viewBeans.SearchCriteriaViewBean.accountContract && viewBeans.SearchCriteriaViewBean.accountContract.length>0 && viewBeans.SearchCriteriaViewBean.accountId && viewBeans.SearchCriteriaViewBean.accountId.length>0 ){
- AccountContract = viewBeans.SearchCriteriaViewBean.accountContract ;
- AccountId = viewBeans.SearchCriteriaViewBean.accountId
- } // if not search Criteria load professional Data
- else if(viewBeans.UserViewBean && viewBeans.UserViewBean.professionalData && viewBeans.UserViewBean.professionalData.contracts && viewBeans.UserViewBean.professionalData.companyId){
- if(viewBeans.UserViewBean.professionalData.contracts && viewBeans.UserViewBean.professionalData.contracts.length >0 && viewBeans.UserViewBean.professionalData.companyId.length >0){
- AccountContract = viewBeans.UserViewBean.professionalData.contracts ;
- AccountId = viewBeans.UserViewBean.professionalData.companyId;
- }
- }
- jQuery("#identification-reserverContract-boo").val(AccountContract);
- jQuery("#identification-reserverId-boo").val(AccountId);
- if((jQuery("#identification-reserverContract-boo").val() == '' || jQuery("#identification-reserverContract-boo").val() == jQuery("#identification-reserverContract-boo").attr("title")) && (jQuery("#identification-reserverId-boo").val() == '' || jQuery("#identification-reserverId-boo").val() == jQuery("#identification-reserverId-boo").attr("title"))){
- jQuery("#identification-businessTravel-boo").attr('checked',false);
- }else{
- jQuery("#identification-businessTravel-boo").attr('checked',true);
- }
- }
- };
- jQuery(document).ready(function() {
- bookingEngine._init();
- })
- /** < /scripts-v1705/profil/booking-engine.js **/
- /** > /scripts-v1705/profil/template_utils.js **/
- var template_utils = {
- /* CONVERT A VARIABLE NAME NESTED IN A STRING (Vous êtes à seulement $nightsToNextTiering) TO A VALUE
- * @param [Object] :
- * str [String] : a string that holds variable name
- * vars [Object] : an objet that holds the variables to implement
- */
- stringToVarValue : function(obj){
- var s = obj.str;
- for(var key in obj.vars){
- s = s.replace(key, obj.vars[key]);
- }
- return s;
- },
- /* CONVERT A DATE STRING (2014-08-26T00:00:00) TO A READABLE DATE FORMAT (02/07/2014)
- * @param [Object] :
- * date [String] : a date
- * separator [String] : a separator to concatenate
- * lang [String] : test the different date format to return
- */
- dateFormat : function(obj){
- var d = (new Date(obj.date).toString() === 'NaN')? new Date(obj.date.replace(/-/g, "/")) : new Date(obj.date);
- var day = (d.getDate().toString().length === 1) ? '0' + d.getDate() : d.getDate();
- var month = d.getMonth() + 1;
- month = (month.toString().length === 1) ? '0' + month : month;
- var year = d.getFullYear();
- var s = "";
- switch(obj.lang){
- case "fr" :
- case "tr" :
- s = day + obj.separator + month + obj.separator + year;
- break;
- case "en" :
- s = month + obj.separator + day + obj.separator + year;
- break;
- default :
- s = month + obj.separator + day + obj.separator + year;
- break;
- }
- return s;
- }
- }
- /** < /scripts-v1705/profil/template_utils.js **/
- /** > /scripts-v1705/profil/welcome.js **/
- var welcome = {
- init : function(obj){
- var facebookURL = {
- "aclubMember" : "https://www.facebook.com/leclubaccorhotels",
- "ALL" : "https://www.facebook.com/accorhotels",
- "SOF" : "https://www.facebook.com/Sofitel",
- "PUL" : "https://www.facebook.com/accorhotels",
- "MGA" : "https://www.facebook.com/accorhotels",
- "NOV" : "https://www.facebook.com/Novotelhotels",
- "SUI" : "https://www.facebook.com/suitenovotel",
- "MER" : "https://www.facebook.com/accorhotels",
- "ADG" : "https://www.facebook.com/accorhotels",
- "IBS" : "https://www.facebook.com/ibis",
- "IBH" : "https://www.facebook.com/ibis",
- "IBB" : "https://www.facebook.com/ibis",
- "IBP" : "https://www.facebook.com/ibis",
- "HOF" : "https://www.facebook.com/HotelF1",
- "FOR" : "https://www.facebook.com/accorhotels"
- }
- //PRINT WELCOME MESSAGE
- jQuery('.welcome h1>strong').html(obj.firstName.toLowerCase() + ' ' + obj.lastName.toLowerCase());
- //FACEBOOK BUTTON
- var url = (obj.aclubMember)? facebookURL.aclubMember : facebookURL[obj.siteCode];
- jQuery('.welcome p')
- .css('cursor', 'pointer')
- .click(function(e){
- //
- TagManager._pushVirtualPageView('account::transverse::facebookclick');
- //
- var o = jQuery(this).find('a').attr('href',url)[0];
- return xt_click(o, 'F', WebAnalyticsTools._getLv2Code(), 'account::transverse::facebookclick');
- });
- }
- }
- /** < /scripts-v1705/profil/welcome.js **/
- /** > /scripts-v1705/profil/leftCol.js **/
- var profilWebAnalytics = {
- _callTagClickFavoriteHotel: function() {
- TagManager._pushVirtualPageView('account::transverse::favoritehotel');
- xt_click(this, 'F', WebAnalyticsTools._getLv2Code(), 'account::transverse::favoritehotel');
- },
- _callTagClickSearch: function() {
- TagManager._pushVirtualPageView('account::transverse::searchclick');
- xt_click(this, 'F', WebAnalyticsTools._getLv2Code(), 'account::transverse::searchclick');
- },
- _callTagClickContactUs: function() {
- TagManager._pushVirtualPageView('account::transverse::contactus');
- xt_click(this, 'F', WebAnalyticsTools._getLv2Code(), 'account::transverse::contactus');
- },
- _callTagClickTabFavoriteHotels: function() {
- TagManager._pushVirtualPageView('account::favoritehotel::favoritehotel');
- xt_click(this, 'F', WebAnalyticsTools._getLv2Code(), 'account::favoritehotel::favoritehotel');
- },
- _callTagClickCarteAbo: function() {
- TagManager._pushVirtualPageView('account::favoritehotel::favoritehotel');
- xt_click(this, 'F', WebAnalyticsTools._getLv2Code(), 'account::favoritehotel::favoritehotel');
- }
- }
- var leftColUtils = {
- viewBeans: null,
- page: '',
- init: function(param) {
- this.viewBeans = param.viewBeans;
- this.page = param.page;
- this.slidePage();
- this.buildFavoriteHotels();
- this.bookingEvnt();
- this.configureMenu();
- this.buildCallTemplate();
- this.buildClick2Call();
- this.setFaqResaUrl();
- this.setFaqFidelityUrl();
- this.leftMenuEvnt();
- var activeBookingCount = false;
- if (this.viewBeans.HistoricViewBean)
- activeBookingCount = this.viewBeans.HistoricViewBean.currentFolders.length;
- else if(this.viewBeans.AccountViewBean)
- activeBookingCount = this.viewBeans.AccountViewBean.activeBookingCount;
- if (activeBookingCount)
- jQuery('#current_booking_nb').html(' ('+activeBookingCount+') ');
- },
- slidePage: function() {
- var $anchor;
- if (jQuery("html, body").hasClass("booking")) {
- if (leftColUtils.getParamLocation("anchor") == "booking") {
- $anchor = jQuery('#reservations');
- jQuery('html, body').animate({scrollTop: $anchor.offset().top - 90}, 500);
- } else if (leftColUtils.getParamLocation("anchor") == "history") {
- $anchor = jQuery('#history');
- jQuery('html, body').animate({scrollTop: $anchor.offset().top - 90}, 500);
- }
- }
- },
- buildFavoriteHotels: function(optionalArr) {
- var $select = jQuery('.user_favorite_destination');
- var $saveOption0 = jQuery(".user_favorite_destination option:eq(0)");
- $select.empty();
- $select.append($saveOption0);
- var arr = (optionalArr)? optionalArr : this.viewBeans.UserViewBean.favoriteHotels;
- var $option;
- if (arr) {
- if (arr.length > 0) {
- for (var i = 0; i < arr.length; i++) {
- if (arr[i].bookableOnTheSameSite) {
- $option = this.buildOption(arr[i]);
- $select.append($option);
- }else if(arr[i].originalBean){
- $option = this.buildOption(arr[i].originalBean);
- $select.append($option);
- }
- }
- } else {
- jQuery(".destination_switch a").hide();
- }
- }
- if ($select.children().length === 1) {
- jQuery(".destination_switch a").hide();
- }
- },
- buildOption : function(obj){
- var $option = jQuery('<option></option>');
- $option.html(obj.name);
- $option.attr('value', obj.code);
- return $option;
- },
- bookingEvnt: function() {
- jQuery("#engine-submit .tSubmit").click(function() {
- profilWebAnalytics._callTagClickSearch();
- });
- jQuery(".leftCol .toogle").click(function() {
- var userLocalization = leftColUtils._readCookie('userLocalization'),
- userLanguage = (leftColUtils._readCookie('userPrefLocalization'))? leftColUtils._readCookie('userPrefLocalization') : leftColUtils.viewBeans.OriginViewBean.codeLang,
- userLanguage = (userLanguage === "en") ? "gb" : userLanguage;
- if(userLanguage === 'gb' || userLanguage === 'fr'){
- window.location = '/' + userLanguage + '/support/index.shtml';
- }else{
- if (!jQuery(this).hasClass("on")) {
- profilWebAnalytics._callTagClickContactUs();
- }
- jQuery(this).toggleClass("on");
- jQuery(this).next("ul").slideToggle("normal");
- }
- return false;
- });
- jQuery(".destination_switch a").click(function() {
- if (!jQuery("fieldset.destination").hasClass("fav")) {
- profilWebAnalytics._callTagClickFavoriteHotel();
- }
- jQuery("fieldset.destination").toggleClass("fav");
- jQuery(".tSearchDestination").val(jQuery(".tSearchDestination").attr("title"));
- jQuery(".user_favorite_destination option").removeAttr("selected");
- jQuery(".user_favorite_destination option:eq(0)").attr("selected", "selected");
- return false;
- });
- jQuery(".user_favorite_destination").change(function() {
- if (jQuery(this).val() != "") {
- jQuery(".tSearchDestination").val(jQuery(this).val());
- } else {
- jQuery(".tSearchDestination").val("");
- }
- })
- jQuery(".tSearchDestination").addClass("disabled").focus(function() {
- if (jQuery(this).val() == jQuery(this).attr("title"))
- jQuery(this).val("").removeClass("disabled");
- });
- jQuery(".tSearchDestination").blur(function() {
- if (jQuery(this).val() == "")
- jQuery(this).val(jQuery(this).attr("title")).addClass("disabled");
- });
- },
- configureMenu: function(obj) {
- var siteCode = this.viewBeans.OriginViewBean.siteCode;
- if (this.viewBeans.LoyaltyAccountViewBean && this.viewBeans.LoyaltyAccountViewBean.account) {
- var defaultCard = this.viewBeans.LoyaltyAccountViewBean.account.loyaltyCards[0];
- var subscriptionCard = this.viewBeans.LoyaltyAccountViewBean.account.subscriptionCards[0];
- if (defaultCard) {
- if (defaultCard.links.CardFinalization) {
- this.cancelMenuList('myCarte',0);
- jQuery('#myCarte').show();
- jQuery('#myCarte ul').children().hide();
- jQuery('#myCarte ul :first-child').show();
- } else {
- jQuery('#myCarte').show();
- }
- }
- }
- if(subscriptionCard){
- jQuery('#myCarteAbo').show();
- }else if(defaultCard){
- if(defaultCard.type === 'D4' || defaultCard.type === 'D5' || defaultCard.type === 'D6' || defaultCard.type === 'D7' || defaultCard.type === 'D9' || defaultCard.cardGroup === 'WW'){
- jQuery('#myCarteAbo').hide();
- }else{
- if (siteCode === "ALL" || siteCode === "IBB" || siteCode === "IBS" || siteCode === "IBH" || siteCode === "IBP" || siteCode === "BUS") {
- jQuery('#myCarteAbo').show();
- }
- }
- }else if(!subscriptionCard && !defaultCard){
- if (siteCode === "ALL" || siteCode === "IBB" || siteCode === "IBS" || siteCode === "IBH" || siteCode === "IBP" || siteCode === "BUS") {
- jQuery('#myCarteAbo').show();
- }else{
- jQuery('#myCarteAbo').hide();
- }
- }
- //My WALLET
- if(this.viewBeans.UserViewBean){
- if(this.viewBeans.UserViewBean.eligibleWallet == true){
- jQuery('#myProfil').find('ul li:eq(2)').show();
- }else{
- jQuery('#myProfil').find('ul li:eq(2)').hide();
- }
- }
- },
- buildCallTemplate: function() {
- var isWhiteLabel = leftColUtils.viewBeans.OriginViewBean.subSiteCode && leftColUtils.viewBeans.OriginViewBean.subSiteCode.toUpperCase() === 'WLB';
- var $call_us = jQuery(".contact_us ul>li:eq(0)>ul>li:eq(1)")
- if (! isWhiteLabel) {
- //var $call_us = jQuery(".contact_us ul>li:eq(0)>ul>li:eq(1)")
- var userLocalization = this._readCookie('userLocalization');
- var userLanguage = (this._readCookie('userPrefLocalization'))? this._readCookie('userPrefLocalization') : this.viewBeans.OriginViewBean.codeLang;
- userLanguage = (userLanguage === "en") ? "gb" : userLanguage;
- //var url = "/hotel-cms/" + userLanguage + "/profil/call-center_" + userLocalization + ".js";
- var url = "/geoloc/geoloc.cgi?file=/" + userLanguage + "/profil/call-center.js";
- jQuery.ajax({
- type: "GET",
- url: url,
- dataType: "json",
- success: function(data) {
- var arr = data['call-center-fh'];
- var phoneNumber, phoneCallRate;
- if (arr.length > 0) {
- for (var i = 0; i < arr.length; i++) {
- if (arr[i].brand === leftColUtils.viewBeans.OriginViewBean.siteCode) {
- phoneNumber = arr[i].phoneNumber;
- phoneCallRate = arr[i].phoneCallRate;
- $call_us.setTemplateURL("/templates-v1705/profil/call_us.tpl", null, {filter_data: false});
- $call_us.setParam('call_us', template_utils.stringToVarValue({
- "str": registration_i18n.leftCol.call_us,
- "vars": {
- "$phoneNumber": phoneNumber,
- "$phoneCallRate": phoneCallRate
- }
- }));
- $call_us.processTemplate();
- if (phoneCallRate === null || phoneCallRate === "") {
- jQuery(".call_us_tel_number span").hide();
- }
- $call_us.show();
- break;
- } else {
- $call_us.hide();
- }
- }
- } else {
- $call_us.hide();
- }
- },
- error: function(data) {
- $call_us.hide();
- }
- });
- }else{
- var $lang = (jQuery("html").attr("lang") == "en") ? "gb" : jQuery("html").attr("lang");
- $call_us.css("padding", "11px 0 15px 46px").html('<a href="/'+ $lang +'/aide/callcenters.htm" class="popin p-m-a-s-w:800-h:400-type:infos-ref:callcenterhelp">'+registration_i18n.leftCol.call_us_WL+'</a>');
- if (popins) {
- // open call us in popin mode
- popins.init();
- }
- }
- },
- _readCookie: function(name) {
- var nameEQ = name + "=";
- var ca = document.cookie.split(';');
- for (var i = 0; i < ca.length; i++) {
- var c = ca[i];
- while (c.charAt(0) == ' ')
- c = c.substring(1, c.length);
- if (c.indexOf(nameEQ) == 0) {
- if (name == "authentification") {
- return decodeURIComponent(c.substring(nameEQ.length, c.length));
- } else {
- return c.substring(nameEQ.length, c.length);
- }
- }
- }
- return null;
- },
- buildClick2Call: function() {
- click2Call.init(this.viewBeans.OriginViewBean.accorhotels, this.page, jQuery('.orange_call_service'));
- },
- setFaqResaUrl: function() {
- var codeLang = (this.viewBeans.OriginViewBean.codeLang === 'en')? 'gb' : this.viewBeans.OriginViewBean.codeLang;
- var siteCode = this.viewBeans.OriginViewBean.siteCode;
- siteCode = (siteCode === 'IBP' && this.viewBeans.OriginViewBean.subSiteCode !== null)? this.viewBeans.OriginViewBean.subSiteCode : this.viewBeans.OriginViewBean.siteCode;
- var faqURL = {
- "ACP" : "http://int1-accorplus.hotelandbook.com/LANG/aide/aide.shtml",
- "ALL": "https://int1-www.accorhotels.com/LANG/contact/contact.shtml",
- "SOF": "http://int1-www.sofitel.com/LANG/contact/ask-question-form.shtml",
- "PUL": "http://int1-www.pullmanhotels.com/LANG/contact/ask-question-form.shtml",
- "MGA": "http://int1-www.mgallery.com/LANG/help/booking.shtml",
- "NOV": "http://int1-www.novotel.com/LANG/help/index.shtml",
- "SUI": "http://www.suitenovotel.com/LANG/help/index.shtml#reservation",
- "MER": "http://int1-www.mercure.com/LANG/help/booking.shtml",
- "ADG": "http://int1-www.adagio-city.com/LANG/contact/ask-question-form.shtml",
- "IBP": "http://int1-www.ibis.com/LANG/frequently-asked-question/reservation.shtml",
- "IBS": "http://ibisstyleshotel.ibis.com/LANG/frequently-asked-question/reservation.shtml",
- "IBH": "http://ibishotel.ibis.com/LANG/frequently-asked-question/reservation.shtml",
- "IBB": "http://ibisbudgethotel.ibis.com/LANG/frequently-asked-question/reservation.shtml",
- "HOF": "http://int1-www.hotelf1.com/LANG/frequently-asked-questions/reservation.html",
- "FOR": "https://int1-www.accorhotels.com/LANG/aide/aide.shtml",
- "HOF": "",
- "FOR": "",
- "GME": "",
- "MSH": "",
- "WTH": "",
- "WTC": "",
- "WAF": ""
- }
- if (siteCode === "HOF" || siteCode === "FOR") {
- jQuery('.contact_us>ul>li:last').hide();
- } else {
- var url = (typeof faqURL[siteCode] !== 'undefined')?faqURL[siteCode].replace(/LANG/g, codeLang) :'';
- jQuery('.faq_resa').attr('href', url);
- }
- },
- setFaqFidelityUrl: function() {
- var codeLang = (this.viewBeans.OriginViewBean.codeLang === 'en')? 'gb' : this.viewBeans.OriginViewBean.codeLang;
- var siteCode = this.viewBeans.OriginViewBean.siteCode;
- siteCode = (siteCode === 'IBP' && this.viewBeans.OriginViewBean.subSiteCode !== null)? this.viewBeans.OriginViewBean.subSiteCode : this.viewBeans.OriginViewBean.siteCode;
- var faqURL = {
- "ACP" : "https://int1-www.accorhotels.com/LANG/leclub/help.shtml",
- "ALL": "https://int1-www.accorhotels.com/LANG/leclub/help.shtml",
- "SOF": "https://int1-www.accorhotels.com/LANG/leclub/help.shtml",
- "PUL": "https://int1-www.accorhotels.com/LANG/leclub/help.shtml",
- "MGA": "https://int1-www.accorhotels.com/LANG/leclub/help.shtml",
- "NOV": "https://int1-www.accorhotels.com/LANG/leclub/help.shtml",
- "SUI": "https://int1-www.accorhotels.com/LANG/leclub/help.shtml",
- "MER": "https://int1-www.accorhotels.com/LANG/leclub/help.shtml",
- "ADG": "https://int1-www.accorhotels.com/LANG/leclub/help.shtml",
- "IBP": "https://int1-www.accorhotels.com/LANG/leclub/help.shtml",
- "IBS": "https://int1-www.accorhotels.com/LANG/leclub/help.shtml",
- "IBH": "https://int1-www.accorhotels.com/LANG/leclub/help.shtml",
- "IBB": "https://int1-www.accorhotels.com/LANG/leclub/help.shtml",
- "HOF": "",
- "FOR": "",
- "GME": "",
- "MSH": "",
- "WTH": "",
- "WTC": "",
- "WAF": ""
- }
- if (siteCode === "HOF" || siteCode === "FOR") {
- jQuery('.contact_us>ul>li:last').hide();
- } else {
- var url = (typeof faqURL[siteCode] !== 'undefined')?faqURL[siteCode].replace(/LANG/g, codeLang) :'';
- jQuery('.faq_loyalty').attr('href', url);
- }
- },
- cancelMenuList: function(id,escape) {
- var i= 0;
- jQuery('#' + id + ' ul>li>a').each(function(){
- if(escape>i)
- jQuery(this).attr('href', '')
- .css({'color': '#DFDFDF', 'cursor': 'default'})
- .bind('click', function(event) {
- return false;
- });
- })
- },
- getParamLocation: function(sname) {
- var params = location.search.substr(location.search.indexOf("?") + 1);
- var sval = "";
- params = params.split("&");
- for (var i = 0; i < params.length; i++)
- {
- temp = params[i].split("=");
- if ([temp[0]] == sname) {
- sval = temp[1];
- }
- }
- return sval;
- },
- setActiveMenu: function(numP, numF) {
- var menu = jQuery(".leftCol_elements .menu > ul > li:eq(" + numP + ")"),
- subMenu = menu.find("ul li:eq(" + numF + ")");
- menu.addClass("current");
- if (subMenu.length > 0) {
- menu.find(" > a").next("ul").show();
- subMenu.addClass("sCurrent");
- }
- },
- leftMenuEvnt: function() {
- if (jQuery(".leftCol_elements .menu").size() == 0)
- return false;
- jQuery(".menu > ul > li > ul").each(function() {
- jQuery(this).find("li:eq(0)")
- .addClass("first");
- });
- jQuery(".menu ul").find("ul").hide();
- var menu_rub = jQuery('.menu > ul > li > a'),
- menu_sub = jQuery('.menu > ul > li > ul');
- menu_rub.click(function(event) {
- event.preventDefault();
- if (! jQuery(this).hasClass("direct_link")) {
- // les liens avec direct_link n'ont pas besoin d'afficher de se déplier pour afficher le sous-menu
- if (jQuery(this).parents("li").attr('class') != 'current') {
- menu_sub.slideUp('normal');
- jQuery(this).stop().next().slideToggle('normal');
- menu_rub.parents("li").removeClass('current');
- jQuery(this).parents("li").addClass('current');
- } else {
- jQuery(this).parents("li").removeClass('current');
- jQuery(this).stop().next().slideUp('normal');
- }
- }
- });
- var jBody = jQuery("body");
- if (jBody.hasClass("booking")) {
- if (leftColUtils.getParamLocation("anchor") == "booking") {
- leftColUtils.setActiveMenu(0, 0);
- } else if (leftColUtils.getParamLocation("anchor") == "history") {
- leftColUtils.setActiveMenu(0, 1);
- }
- } else if (jBody.hasClass("favoritehotels")) {
- leftColUtils.setActiveMenu(1, 0);
- } else if (jBody.hasClass("personaldetails")) {
- leftColUtils.setActiveMenu(2, 0);
- }else if (jBody.hasClass("contact-informations")) {
- leftColUtils.setActiveMenu(2, 1);
- } else if (jBody.hasClass("preferences")) {
- leftColUtils.setActiveMenu(2, 3);
- } else if (jBody.hasClass("newsletters")) {
- leftColUtils.setActiveMenu(2, 4);
- } else if (jBody.hasClass("pointHistory")) {
- leftColUtils.setActiveMenu(3, 0);
- } else if (jBody.hasClass("mycurrentoffers")) {
- leftColUtils.setActiveMenu(3, 1);
- } else if (jBody.hasClass("rewards")) {
- leftColUtils.setActiveMenu(3, 2);
- } else if (jBody.hasClass("subscription")) {
- leftColUtils.setActiveMenu(4, 0);
- } else if (jBody.hasClass("payment-cards")) {
- leftColUtils.setActiveMenu(2, 2);
- }
- jQuery("#myFavoriteHotels").click(function() {
- profilWebAnalytics._callTagClickTabFavoriteHotels();
- document.location.href = "/" + getDirLangFromHtmlAttrib() + "/profil/favoritehotels.shtml";
- });
- jQuery("#myCarteAbo").click(function() {
- document.location.href = "/" + getDirLangFromHtmlAttrib() + "/profil/subscription.shtml";
- });
- }
- }
- /** < /scripts-v1705/profil/leftCol.js **/
- /** > /scripts-v1705/profil/profil_popin.js **/
- var profil_popin = {
- init : function(param){
- var datas = {
- modal: param.cls.indexOf('-m-') > -1,
- drag: param.cls.indexOf('-d-') > -1,
- redim: param.cls.indexOf('-r-') > -1,
- iframe: param.cls.indexOf('-i-') > -1,
- scrollable: param.cls.indexOf('-s-') > -1 ? "auto" : "no",
- ajax: param.cls.indexOf('-a-') > -1,
- width: /w:\d+/.test(param.cls) ? parseInt(param.cls.match(/w:(\d+)/)[1], 10) : null,
- height: /h:\d+/.test(param.cls) ? parseInt(param.cls.match(/h:(\d+)/)[1], 10) : null,
- type: param.cls.match(/type:([^\s-]+)/)[1],
- ref: param.cls.match(/ref:([^\s-]+)/)[1],
- url : "../../common/profil/message_popin.html",
- complete: /complete:([^\s-]+)/.test(param.cls) ? param.cls.match(/complete:([^\s-]+)/)[1] : null,
- objcomplete: /objcomplete:([^\s-]+)/.test(param.cls) ? param.cls.match(/objcomplete:([^\s-]+)/)[1] : null
- };
- if(param.popinType === 'redirect'){
- datas.url = param.url;
- }
- if (param.onClose) {
- datas.onClose = param.onClose;
- }
- if(datas.ajax) {
- //RESIZE THE BODY ELEMENT WHEN POPIN IS CLOSED
- var docHeight = jQuery('body').outerHeight(true) + 'px';
- jQuery(document).bind('closePopin', function(evt){
- jQuery('body').css('height', 'auto');
- });
- jQuery.get(datas.url, function (response) {
- popins.openPopin(jQuery("<div class='popinBaseContent'>" + response + "</div>").appendTo('.mainContainer'), datas);
- if(param.popinType === 'redirect'){
- datas.url = param.url;
- jQuery(".ui-dialog-titlebar").css("display", "none");
- jQuery(".popinBaseContent .msgBox").html(param.msg);
- jQuery(".popinBaseContent .btn .stop span").html(param.cancel);
- jQuery(".popinBaseContent .btn .next span").html(param["continue"]).click(function(event){
- if(typeof param.loadProcess != 'undefined'){
- jQuery.globalEval(param.loadProcess+ "()");
- } else {
- jQuery(".ui-dialog-titlebar-close").click();
- window.location = param.redirectURL;
- return false;
- }
- });
- jQuery(".popinBaseContent").css({width : 'auto', height : 'auto'})
- jQuery(".close a, a.close, .stop").click(function(){
- jQuery(".ui-dialog-titlebar-close").click();
- return false;
- });
- }else{
- jQuery(".popinProfil h2").html(param.title);
- jQuery(".popinProfil p.msgBox").html(param.msg);
- if(param.userEmail != param.newUserEmail){
- jQuery(".popinProfil p.newEmailTerms").html(param.newEmailTerms);
- if(jQuery(".popinProfil p.newEmailTerms span.newUserEmail").size() > 0){
- jQuery(".popinProfil p.newEmailTerms span.newUserEmail").html(param.newUserEmail);
- }else if(jQuery(".popinProfil p.msgBox span.newUserEmail").size() > 0){
- jQuery(".popinProfil p.msgBox span.newUserEmail").html(param.newUserEmail);
- }
- }
- jQuery(".close a span").html(param.closePopin);
- jQuery(".close a, a.close").click(function(){
- jQuery(".ui-dialog-titlebar-close").click();
- if(param.redirectToClose){
- window.location = param.redirectToClose;
- }
- return false;
- });
- /*RESIZE FOR THE PROFIL PAGES*/
- jQuery(".popinBaseContent").css('height', jQuery('.popin-personalValidation').css('height'));
- jQuery('.ui-widget-overlay').css('height', docHeight);
- jQuery('body').css('height', docHeight);
- }
- });
- }else if(datas.iframe) {
- currentPopinIframe = jQuery('<div class="popin' + datas.ref + '"><iframe allowtransparency="true" class="popinBaseContent" src="about:blank" frameborder="0" scrolling="' + datas.scrollable + '"></iframe></div>').appendTo(document.body).data('popin', datas);
- popins.openPopin(currentPopinIframe, datas);
- }else{
- popins.openPopin(jQuery('div.' + datas.ref).data('popin', datas), datas);
- }
- }
- }
- /** < /scripts-v1705/profil/profil_popin.js **/
- jQuery.noConflict();
- /** > /scripts-v1705/profil/duplicate-card.js **/
- var duplicateCard = {
- viewBeans : null,
- returnCodeDuplicateisOne : false,
- initPopin : function(viewBeans){
- duplicateCard.print();
- duplicateCard.viewBeans = viewBeans;
- var $duplicateCard = jQuery('.js-link-letter');
- $duplicateCard.bind('click', function(event) {
- event.preventDefault;
- if(!duplicateCard.returnCodeDuplicateisOne){
- ajaxRequest._executeByUrl(
- "/ajax/loyalty/duplicateCard.action?cardNumber="+jQuery(event.currentTarget).data('card'),
- "none",
- "duplicateCard.duplicate(errors, response)"
- );
- } else {
- var data = {
- cls: 'p-m-a-w:560-h:170-s:1-type:infos-ref:duplicateCard',
- title : registration_i18n["dashboard"]["lc_infos"]["ask_card_by_post"],
- closePopin : registration_i18n["popinMessage"]["close"],
- msg : registration_i18n["dashboard"]["lc_infos"]["card_duplicate_success_address"]
- };
- profil_popin.init(data);
- }
- });
- },
- duplicate : function(errors, response){
- var data = {
- cls: 'p-m-a-w:560-h:170-s:1-type:infos-ref:duplicateCard',
- title : registration_i18n["dashboard"]["lc_infos"]["ask_card_by_post"],
- closePopin : registration_i18n["popinMessage"]["close"]
- };
- if(errors && errors.length > 0){
- data.msg = registration_i18n["dashboard"]["lc_infos"]["card_duplicate_error"];
- } else {
- if(response.viewBeans && response.viewBeans.DuplicateCardResultViewBean) {
- var codeRetour = response.viewBeans.DuplicateCardResultViewBean.codeRetour;
- var $duplicateCardElt = jQuery('.js-link-letter');
- if(codeRetour === 0){ // demande prise en compte
- $contenu = $duplicateCardElt.html();
- $duplicateCardElt
- .find('p')
- .unwrap()
- .empty()
- .html('<i class="sprite sprite-letter"></i>' + registration_i18n["dashboard"]["lc_infos"]["card_fabrication_progress"]);
- data.msg = registration_i18n["dashboard"]["lc_infos"]["card_duplicate_success"];
- } else if (codeRetour === 1){ // ok mais inviter a saisir adresse
- data.msg = registration_i18n["dashboard"]["lc_infos"]["card_duplicate_success_address"];
- duplicateCard.returnCodeDuplicateisOne = true;
- }
- }
- }
- profil_popin.init(data);
- },
- print : function(){
- jQuery(".js-link-print").click(function(){
- var cardNumber = jQuery(this).data('card');
- var url = "/pdf/open.action?type=1&cardNumber="+cardNumber;
- if(jQuery.browser.msie){
- url = "/pdf/download.action?type=1&cardNumber="+cardNumber;
- }
- jQuery(this).attr('href', url);
- });
- },
- printed : function(errors, response){
- if(errors && errors.length > 0){
- } else {
- }
- }
- };
- /** < /scripts-v1705/profil/duplicate-card.js **/
- /** > /scripts-v1705/profil/subscription.js **/
- (function(window, undefined) {
- var viewBeans = {};
- var $user_cards;
- function init(errors, response) {
- viewBeans.LoyaltyAccountViewBean = response.viewBeans.LoyaltyAccountViewBean;
- viewBeans.AClubViewBean = response.viewBeans.AClubViewBean;
- viewBeans.OriginViewBean = response.viewBeans.OriginViewBean;
- //WELCOME MESSAGE AND FACEBOOK BUTTON
- welcome.init({
- firstName: viewBeans.UserViewBean.firstName,
- lastName: viewBeans.UserViewBean.lastName,
- aclubMember: viewBeans.AClubViewBean.aclubMember,
- siteCode: viewBeans.OriginViewBean.siteCode
- });
- if (viewBeans.LoyaltyAccountViewBean.account && !viewBeans.LoyaltyAccountViewBean.account.subscriptionCards) {
- viewBeans.LoyaltyAccountViewBean.account.subscriptionCards = [];
- }
- printCard();
- manageLeftCol();
- //
- trackersXiti();
- }
- function printCard() {
- var dates = [], subscriptionCards = [];
- var cardType;
- var hasAFGBCard = false;
- var hasIbisCard = false;
- var isAccountLocked;
- if (viewBeans.LoyaltyAccountViewBean.account) {
- isAccountLocked = viewBeans.LoyaltyAccountViewBean.account.locked;
- for (var i = 0; i < viewBeans.LoyaltyAccountViewBean.account.subscriptionCards.length; i++) {
- var myRegexDate = new RegExp("([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})");
- var resultDate = myRegexDate.exec(viewBeans.LoyaltyAccountViewBean.account.subscriptionCards[i].cardExpirationDate);
- var cardExpirationDate = new Date(resultDate[1], resultDate[2] - 1, resultDate[3]);
- cardExpirationDate = utils.printDate(cardExpirationDate, i18n.calendar.displayDateFormat);
- dates.push(cardExpirationDate);
- cardType = viewBeans.LoyaltyAccountViewBean.account.subscriptionCards[i].type;
- if(cardType === "B3" || cardType === "B4" || cardType === "B5" || cardType === "B6" || cardType === "FavoriteGuestBusiness"){
- hasAFGBCard = true;
- }else if(cardType === "FI"){
- hasIbisCard = true;
- }
- }
- subscriptionCards = viewBeans.LoyaltyAccountViewBean.account.subscriptionCards;
- }
- var isBusinnesTravelSite = (viewBeans.OriginViewBean.siteCode === 'ALL' && viewBeans.OriginViewBean.subSiteCode === 'BIZ' && hasAFGBCard === false) ? true : false;
- var isIbisSite = (viewBeans.OriginViewBean.siteCode === 'IBP')? true : false;
- var randomCard = Math.round(Math.random());
- $user_cards.setTemplateURL("../../templates-v1705/profil/subscription.tpl", null, {filter_data: false});
- $user_cards.setParam("i18n", registration_i18n);
- $user_cards.setParam("dates", dates);
- $user_cards.setParam("isAccountLocked", isAccountLocked);
- $user_cards.setParam("isBusinnesTravelSite", isBusinnesTravelSite);
- $user_cards.setParam("isIbisSite", isIbisSite);
- $user_cards.setParam("hasIbisCard", hasIbisCard);
- $user_cards.setParam("hasAFGBCard", hasAFGBCard);
- $user_cards.setParam("randomCard", randomCard);
- $user_cards.processTemplate(subscriptionCards);
- $user_cards.processTemplateStop(duplicateCard.initPopin(viewBeans));
- //CHECK FOR LOCKEDACCOUNT CLASS AND DEACTIVATE THE TEMPLATES LINKS
- jQuery('.user_cards .lockedAccount').each(function(element, index){
- jQuery(this)
- .css('cursor', 'default')
- .find('span').css('cursor', 'default');
- jQuery(this).click(function(event){
- return false;
- });
- });
- }
- function manageLeftCol() {
- leftColUtils.init({viewBeans: viewBeans, page: 'subscription'});
- }
- function trackersXiti() {
- jQuery(".card.ibis.expired a.btnMore").click(function(e) {
- TagManager._pushVirtualPageView('account::subscription::renewibissubscription');
- xt_click(this, 'C', WebAnalyticsTools._getLv2Code(), 'account::subscription::renewibissubscription', 'N');
- });
- jQuery(".card.accor.expired a.btnMore").click(function(e) {
- TagManager._pushVirtualPageView('account::subscription::renewaccorsubscription');
- xt_click(this, 'C', WebAnalyticsTools._getLv2Code(), 'account::subscription::renewaccorsubscription', 'N');
- });
- jQuery(".card.ibis.subscription a.btnMore").click(function(e) {
- TagManager._pushVirtualPageView('account::subscription::subscriptionoffer');
- xt_click(this, 'C', WebAnalyticsTools._getLv2Code(), 'account::subscription::subscriptionoffer', 'N');
- });
- jQuery(".subscription .card a.btnMore").click(function(e) {
- TagManager._pushVirtualPageView('account::subscription::validatetermsofsales');
- });
- }
- var tagGTMbusinessPlus = {
- init: function() {
- jQuery(".card.accor.expired a.btnMore").click(function(e){
- e.preventDefault();
- tagGTMbusinessPlus._cardDiscover(this.href);
- })
- jQuery(".user_cards .card a.btnMore").click(function(e){
- e.preventDefault();
- tagGTMbusinessPlus._reNewSubscription(this.href);
- });
- },
- _cardDiscover:function(link){
- this._addTagGTM({
- 'event': 'GAevent',
- 'eventCategory': 'Profile page',
- 'eventAction': 'My subscription cards - Click on CTA',
- 'eventLabel': 'Business Plus - Discover'
- });
- this._callLink(link);
- },
- _reNewSubscription:function(link){
- this._addTagGTM({
- 'event': 'GAevent',
- 'eventCategory': 'Profile page',
- 'eventAction': 'My subscription cards - Click on CTA',
- 'eventLabel': 'Business Plus - Renew subscription'
- });
- this._callLink(link);
- },
- _callLink:function(link){
- setTimeout(function(){window.location.href=link} , 1500);
- },
- _addTagGTM : function(data){
- if(typeof TagManager !== undefined || TagManager != null){
- TagManager.pushDataCustom({
- 'event': data.event,
- 'eventCategory': data.eventCategory,
- 'eventAction': data.eventAction,
- 'eventLabel': data.eventLabel
- });
- }
- }
- };
- window.Subscription = {};
- Subscription.accessControl = accessControl;
- Subscription.init = init;
- jQuery(document).ready(function() {
- jQuery.noConflict();
- $user_cards = jQuery('.user_cards');
- ajaxRequest._executeByUrl("/bean/getViewBeans.action?beans=UserViewBean",
- "tAjaxError",
- "Subscription.accessControl(errors, response)");
- });
- jQuery(window).load(function() {
- tagGTMbusinessPlus.init();
- });
- function accessControl(errors, response) {
- if (response.viewBeans.UserViewBean && response.viewBeans.UserViewBean.identified === true) {
- viewBeans.UserViewBean = response.viewBeans.UserViewBean;
- ajaxRequest._executeByUrl("/bean/getViewBeans.action?beans=OriginViewBean|LoyaltyAccountViewBean|AClubViewBean",
- "tAjaxError",
- "Subscription.init(errors, response)");
- } else {
- document.location.href = "/" + getDirLangFromHtmlAttrib() + "/profil/login.shtml";
- }
- }
- })(window);
- /** < /scripts-v1705/profil/subscription.js **/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement