var userLang = window.navigator.language;
var rf_cm_mmc;
var rf_cm_mmca1;
var rf_cm_mmca2;
var rf_cm_mmca3;
/*function getRFElement(position, type){
var $elem = $('#myDynamicForm :nth-child('+ position+')')
switch(type){
case 'read-only':
return $elem.find('.readOnly-value').html()
case 'select':
return $elem.find('select')
case 'input':
return $elem.find('input')
default:
return ''
}
}
function getRFElementId(id, type){
var $elem = $(document.getElementById(id))
switch(type){
case 'read-only':
return $elem.find('.readOnly-value').html()
case 'select':
return $elem.find('select')
case 'input':
return $elem.find('input')
default:
return ''
}
} */
//
function createElement(name,id,value,type){
var input = document.createElement("input")
input.setAttribute("type", type)
input.setAttribute("name", name)
input.setAttribute("value", value)
input.setAttribute("id", id)
return input
}
var INTERVAL_DELAY = 100;
var MAX_INTERVAL_ITERATIONS = 100; // 10s at 100ms intervals
var FORM_ID = 'myDynamicForm';
var dlTimerIterations = 0;
var dlTimer = window.setInterval(function () {
if (window.dl && window.dl.fn) {
rf_cm_mmc = dl.fn.getCampInfo().cm_mmc;
rf_cm_mmca1 = dl.fn.getCampInfo().cm_mmca1;
rf_cm_mmca2 = dl.fn.getCampInfo().cm_mmca2;
rf_cm_mmca3 = dl.fn.getCampInfo().cm_mmca3;
window.clearInterval(dlTimer);
}
if (dlTimerIterations >= MAX_INTERVAL_ITERATIONS) {
// Safety net to ensure this interval won't run forever.
window.clearInterval(dlTimer);
}
dlTimerIterations++;
}, INTERVAL_DELAY);
function setNativeValue(element, value) {
const valueSetter = Object.getOwnPropertyDescriptor(element, 'value').set;
const prototype = Object.getPrototypeOf(element);
const prototypeValueSetter = Object.getOwnPropertyDescriptor(
prototype,
'value'
).set;
if (valueSetter && valueSetter !== prototypeValueSetter) {
prototypeValueSetter.call(element, value);
} else {
valueSetter.call(element, value);
}
}
function calculateDefaultCountry() {
// IBM expects the defaultcountry to be in the reverse order of the browser api
// i.e. {country}-{lang} rather than {lang-country}
// They also need country to be lower-case.
var languageSetting = navigator.language;
var separated = languageSetting.split('-');
var lang = separated[0];
var country = separated[1];
return country ? country.toLowerCase() + '-' + lang : lang;
}
function runNoticeChoice() {
var noticeChoiceDiv = document.createElement('div');
noticeChoiceDiv.setAttribute('id', 'noticeChoiceId');
$('.form-footer-actions').before(noticeChoiceDiv);
var $rfSubmitButton = $('.mdBtnR-primary'); //.attr('id','submitButton')
var buttonText = document.createElement('span');
$(buttonText).append(document.createTextNode('Continue'));
buttonText.className = 'mdBtnR-text';
var button = document.createElement('button');
button.className = 'mdBtnR mdBtnR-primary';
$(button).append(buttonText);
$rfSubmitButton.after(button);
$rfSubmitButton.css('display', 'none');
// addHiddenElementToForm('rfEmail','rfEmail',getRFElement(5,'read-only'))
/* var $country = getRFElementId('wf-formAttendee-countryId', 'select');
$country.attr('id', 'rfCountry')
var $email = getRFElementId('wf-formAttendee-email', 'input');
$email.attr('id', 'rfEmail')
$email.attr('readonly', 'readonly')
$email.blur();
var $country = getRFElement(16, 'select');
$country.attr('id', 'rfCountry')
var $email = getRFElement(8, 'input');
$email.attr('id', 'rfEmail')
$email.attr('readonly', 'readonly')
$email.blur();
*/
var ncButton = createElement('rfSubmit', 'rfSubmit', 'Submit', 'submit');
$('#' + FORM_ID).append(ncButton);
$(ncButton).css('display', 'none');
var $NC_HIDDEN_EMAIL_FIELD = $('#15724979646720018TC7');
$NC_HIDDEN_EMAIL_FIELD.parent().css('display', 'none');
var $NC_HIDDEN_PHONE_FIELD = $('#1572498016288001blca');
$NC_HIDDEN_PHONE_FIELD.parent().css('display', 'none');
//VCPI
var $CM_MMC_HIDDEN0 = $('#1572449484696001b9Y8');
$CM_MMC_HIDDEN0.parent().css('display', 'none');
var $CM_MMC_HIDDEN1 = $('#1572449642433001bMIM');
$CM_MMC_HIDDEN1.parent().css('display', 'none');
var $CM_MMC_HIDDEN2 = $('#15724497526980018kZ3');
$CM_MMC_HIDDEN2.parent().css('display', 'none');
var $CM_MMC_HIDDEN3 = $('#1572449788449001jL4l');
$CM_MMC_HIDDEN3.parent().css('display', 'none');
//END VCPI
$(button).on('click', function () {
$(ncButton).click();
setTimeout(function () {
var input = $NC_HIDDEN_EMAIL_FIELD[0];
// input.value = $('#NC_HIDDEN_EMAIL').val();
// var event = new Event('change', { bubbles: true });
// input.dispatchEvent(event);
setNativeValue(input, $('#NC_HIDDEN_EMAIL').val());
input.dispatchEvent(new Event('input', { bubbles: true }));
input = $NC_HIDDEN_PHONE_FIELD[0];
// input.value = $('#NC_HIDDEN_PHONE').val();
// // event = new Event('change', { bubbles: true });
// event = new Event('input', { bubbles: true });
// input.dispatchEvent(event);
setNativeValue(input, $('#NC_HIDDEN_PHONE').val());
input.dispatchEvent(new Event('input', { bubbles: true }));
// VCPI
ibmStats.event({
ibmEv: 'Event Registration',
ibmEvAction: bUnit + eventName + 'seminar=' + ep_id,
ibmConversion: 'true',
convtype: '2',
});
input = $CM_MMC_HIDDEN0[0];
setNativeValue(input, rf_cm_mmc);
input.dispatchEvent(new Event('input', { bubbles: true }));
input = $CM_MMC_HIDDEN1[0];
setNativeValue(input, rf_cm_mmca1);
input.dispatchEvent(new Event('input', { bubbles: true }));
input = $CM_MMC_HIDDEN2[0];
setNativeValue(input, rf_cm_mmca2);
input.dispatchEvent(new Event('input', { bubbles: true }));
input = $CM_MMC_HIDDEN3[0];
setNativeValue(input, rf_cm_mmca3);
input.dispatchEvent(new Event('input', { bubbles: true }));
// END VCPI
$rfSubmitButton.click();
}, 500);
});
var options = {
id: {
form: FORM_ID,
email: 'formAttendee-email',
privacyDiv: 'noticeChoiceId',
country: 'formAttendee-countryId',
customButton: 'rfSubmit',
},
defaultcountry: calculateDefaultCountry(),
questionType: '4',
questionChoice: '1,2',
pageDesc: '',
offerCode: '',
dcSubject: '',
granular: 'off',
footer: 'off',
preferenceareas: '',
trial: '',
Submit: 'false',
SaveToGECS: 'true',
};
window.noticeJQuery.noticeandchoice(options);
}
if (data.page === 'contactInfo' || data.page === 'createaccount') {
var noticeChoiceTimerIterations = 0;
var noticeChoiceTimer = window.setInterval(function () {
if (document.getElementById(FORM_ID)) {
runNoticeChoice();
window.clearInterval(noticeChoiceTimer);
}
if (noticeChoiceTimerIterations >= MAX_INTERVAL_ITERATIONS) {
// Safety net to ensure this interval won't run forever.
window.clearInterval(noticeChoiceTimer);
}
noticeChoiceTimerIterations++;
}, INTERVAL_DELAY);
}