var userLang = window.navigator.language;
var rf_cm_mmc;
var rf_cm_mmca1;
var rf_cm_mmca2;
var rf_cm_mmca3;
var rf_utm_campaign;
var rf_utm_content;
var rf_utm_id;
var rf_utm_medium;
var rf_utm_source;
var rf_utm_term;
var rf_p1;
var rf_p2;
var rf_p3;
var rf_p4;
var rf_p5;
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
}
// V10
var INTERVAL_DELAY = 100;
var MAX_INTERVAL_ITERATIONS = 100; // 10s at 100ms intervals
var FORM_ID = 'myDynamicForm';
var rfLocale = window.rfLocale || { lang: 'en', region: 'US' };
if (rfLocale.lang === 'en') {
rfLocale.region = 'SG';
}
var dlTimerIterations = 0;
var dlTimer = window.setInterval(function () {
// window.dl will be blocked by ad blockers and
// is not guaranteed to exist.
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;
rf_utm_campaign = dl.fn.getCampInfo().utm_campaign;
rf_utm_content = dl.fn.getCampInfo().utm_content;
rf_utm_id = dl.fn.getCampInfo().utm_id;
rf_utm_medium = dl.fn.getCampInfo().utm_medium;
rf_utm_source = dl.fn.getCampInfo().utm_source;
rf_utm_term = dl.fn.getCampInfo().utm_term;
rf_p1 = dl.fn.getCampInfo().p1;
rf_p2 = dl.fn.getCampInfo().p2;
rf_p3 = dl.fn.getCampInfo().p3;
rf_p4 = dl.fn.getCampInfo().p4;
rf_p5 = dl.fn.getCampInfo().p5;
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) {
var valueSetter = Object.getOwnPropertyDescriptor(element, 'value').set;
var prototype = Object.getPrototypeOf(element);
var prototypeValueSetter = Object.getOwnPropertyDescriptor(
prototype,
'value'
).set;
if (valueSetter && valueSetter !== prototypeValueSetter) {
prototypeValueSetter.call(element, value);
} else {
valueSetter.call(element, value);
}
}
// IE does not support the Event constructor. We need this fallback.
function createEvent(eventName, eventOptions) {
if (typeof Event === 'function') {
// This is a modern browser that supports the Event constructor.
return new Event(eventName, eventOptions)
} else {
// This is IE :(.
var event = document.createEvent('Event')
event.initEvent(eventName, eventOptions.bubbles, eventOptions.cancelable, eventOptions.detail)
return event
}
}
function runNoticeChoice() {
var noticeChoiceDiv = document.createElement('div');
noticeChoiceDiv.setAttribute('id', 'noticeChoiceId');
$('.form-footer-actions').before(noticeChoiceDiv);
var realContinueButton = $('#wf-btn-submit');
// This submit button is what will send form data to N&C.
var injectedSubmitButton = createElement('rfSubmit', 'rfSubmit', 'Submit', 'submit');
$('#' + FORM_ID).append(injectedSubmitButton);
$(injectedSubmitButton).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');
var $CM_UTM_CAMPAIGN_HIDDEN = $('#1605131082464001KlVx');
$CM_UTM_CAMPAIGN_HIDDEN.parent().css('display', 'none');
var $CM_UTM_CONTENT_HIDDEN = $('#1605131126603001UbPu');
$CM_UTM_CONTENT_HIDDEN.parent().css('display', 'none');
var $CM_UTM_ID_HIDDEN = $('#1605131235097001UXi4');
$CM_UTM_ID_HIDDEN.parent().css('display', 'none');
var $CM_UTM_MEDIUM_HIDDEN = $('#1605129411575001m0v4');
$CM_UTM_MEDIUM_HIDDEN.parent().css('display', 'none');
var $CM_UTM_SOURCE_HIDDEN = $('#1605131043877001m1i3');
$CM_UTM_SOURCE_HIDDEN.parent().css('display', 'none');
var $CM_UTM_TERM_HIDDEN = $('#1605131173552001mPiN');
$CM_UTM_TERM_HIDDEN.parent().css('display', 'none');
var $CM_P1_HIDDEN = $('#1605131267496001KQ7w');
$CM_P1_HIDDEN.parent().css('display', 'none');
var $CM_P2_HIDDEN = $('#1605131367051001UH3X');
$CM_P2_HIDDEN.parent().css('display', 'none');
var $CM_P3_HIDDEN = $('#1605131412009001KXrt');
$CM_P3_HIDDEN.parent().css('display', 'none');
var $CM_P4_HIDDEN = $('#1605131440679001i7J1');
$CM_P4_HIDDEN.parent().css('display', 'none');
var $CM_P5_HIDDEN = $('#1605131491155001irfB');
$CM_P5_HIDDEN.parent().css('display', 'none');
//END VCPI
realContinueButton.on('click', function (e) {
injectedSubmitButton.dispatchEvent(createEvent('click', { bubbles: true }));
// As we change these input values, we also need to dispatch an 'input'
// event so that nodes up the dom can react to the value change accordingly.
// It is also important that "bubbles" is set to true.
var input;
var hiddenEmailValue = $('#NC_HIDDEN_EMAIL').val()
if (hiddenEmailValue) {
input = $NC_HIDDEN_EMAIL_FIELD[0];
setNativeValue(input, hiddenEmailValue);
input.dispatchEvent(createEvent('input', { bubbles: true }));
}
var hiddenPhoneValue = $('#NC_HIDDEN_PHONE').val()
if (hiddenPhoneValue) {
input = $NC_HIDDEN_PHONE_FIELD[0];
setNativeValue(input, hiddenPhoneValue);
input.dispatchEvent(createEvent('input', { bubbles: true }));
}
// VCPI
if (rf_cm_mmc) {
input = $CM_MMC_HIDDEN0[0];
setNativeValue(input, rf_cm_mmc);
input.dispatchEvent(createEvent('input', { bubbles: true }));
}
if (rf_cm_mmca1) {
input = $CM_MMC_HIDDEN1[0];
setNativeValue(input, rf_cm_mmca1);
input.dispatchEvent(createEvent('input', { bubbles: true }));
}
if (rf_cm_mmca2) {
input = $CM_MMC_HIDDEN2[0];
setNativeValue(input, rf_cm_mmca2);
input.dispatchEvent(createEvent('input', { bubbles: true }));
}
if (rf_cm_mmca3) {
input = $CM_MMC_HIDDEN3[0];
setNativeValue(input, rf_cm_mmca3);
input.dispatchEvent(createEvent('input', { bubbles: true }));
}
if (rf_utm_campaign) {
input = $CM_UTM_CAMPAIGN_HIDDEN[0];
setNativeValue(input, rf_utm_campaign);
input.dispatchEvent(createEvent('input', { bubbles: true }));
}
if (rf_utm_content) {
input = $CM_UTM_CONTENT_HIDDEN[0];
setNativeValue(input, rf_utm_content);
input.dispatchEvent(createEvent('input', { bubbles: true }));
}
if (rf_utm_id) {
input = $CM_UTM_ID_HIDDEN[0];
setNativeValue(input, rf_utm_id);
input.dispatchEvent(createEvent('input', { bubbles: true }));
}
if (rf_utm_medium) {
input = $CM_UTM_MEDIUM_HIDDEN[0];
setNativeValue(input, rf_utm_medium);
input.dispatchEvent(createEvent('input', { bubbles: true }));
}
if (rf_utm_source) {
input = $CM_UTM_SOURCE_HIDDEN[0];
setNativeValue(input, rf_utm_source);
input.dispatchEvent(createEvent('input', { bubbles: true }));
}
if (rf_utm_term) {
input = $CM_UTM_TERM_HIDDEN[0];
setNativeValue(input, rf_utm_term);
input.dispatchEvent(createEvent('input', { bubbles: true }));
}
if (rf_p1) {
input = $CM_P1_HIDDEN[0];
setNativeValue(input, rf_p1);
input.dispatchEvent(createEvent('input', { bubbles: true }));
}
if (rf_p2) {
input = $CM_P2_HIDDEN[0];
setNativeValue(input, rf_p2);
input.dispatchEvent(createEvent('input', { bubbles: true }));
}
if (rf_p3) {
input = $CM_P3_HIDDEN[0];
setNativeValue(input, rf_p3);
input.dispatchEvent(createEvent('input', { bubbles: true }));
}
if (rf_p4) {
input = $CM_P4_HIDDEN[0];
setNativeValue(input, rf_p4);
input.dispatchEvent(createEvent('input', { bubbles: true }));
}
if (rf_p5) {
input = $CM_P5_HIDDEN[0];
setNativeValue(input, rf_p5);
input.dispatchEvent(createEvent('input', { bubbles: true }));
}
// END VCPI
})
var options = {
id: {
form: FORM_ID,
email: 'formAttendee-email',
privacyDiv: 'noticeChoiceId',
country: 'formAttendee-countryId',
customButton: 'rfSubmit',
},
// 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.
defaultcountry: (rfLocale.region + '-' + rfLocale.lang).toLowerCase(),
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);
}
function appendScript(url){
var s = document.createElement("script");
s.type = "text/javascript";
s.src = url;
s.async = "true";
document.head.appendChild(s);
}
var str = eventCode;
var ep_id = str.toUpperCase();
var eventName = eventName;
var bUnit = "";
// V2
bUnit = data.event['1578604769236001V632'];
// Track when the registration form is loaded.
if(data.page === 'contactInfo' || data.page === 'createaccount') {
eventInfo = {
primaryCategory: 'EVENT REGISTRATION',
eventName: bUnit + eventName + 'seminar=' + ep_id,
type: 'conversion',
eventAction: '1'
};
ibmStats.event(eventInfo);
}
// Track when registration has completed.
if (data.page === 'regConfirm') {
eventInfo = {
primaryCategory: 'EVENT REGISTRATION',
eventName: bUnit + eventName + 'seminar=' + ep_id,
type: 'conversion',
eventAction: '2'
};
ibmStats.event(eventInfo);
}
console.log(data.event);
//page submit convtype 2 on N&C script due to custom btn fn