[j] x
Viewer
- (function(window){window.MDIGITAL=window.MDIGITAL||{};window.MDIGITAL.version='2.32.0';})(window);window.KAMPYLE_CONSTANT={SVGS:{NO_DATA_MODAL_IMG:'<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="450" height="278.118" viewBox="0 0 450 278.118"> <defs> <radialGradient id="radial-gradient" cx="0.5" cy="0.5" r="0.5" gradientUnits="objectBoundingBox"> <stop offset="0" stop-color="#c7c7c8" stop-opacity="0.71"/> <stop offset="1" stop-color="#ddddde" stop-opacity="0"/> </radialGradient> <linearGradient id="linear-gradient" x1="0.747" y1="0.203" x2="0" y2="0.393" gradientUnits="objectBoundingBox"> <stop offset="0" stop-color="#dbe4f1" stop-opacity="0"/> <stop offset="1" stop-color="#c7c7c8" stop-opacity="0.518"/> </linearGradient> <linearGradient id="linear-gradient-2" x1="0.521" y1="0.272" x2="1" y2="0.393" gradientUnits="objectBoundingBox"> <stop offset="0" stop-color="#dbe4f1" stop-opacity="0"/> <stop offset="1" stop-color="#c7c7c8" stop-opacity="0.482"/> </linearGradient> <radialGradient id="radial-gradient-2" cx="0.5" cy="0.5" r="0.5" gradientUnits="objectBoundingBox"> <stop offset="0" stop-color="#727272"/> <stop offset="1" stop-color="#cbd9ee" stop-opacity="0"/> </radialGradient> </defs> <g id="illustration" transform="translate(0 0.118)"> <ellipse id="Ellipse_57" data-name="Ellipse 57" cx="63" cy="8" rx="63" ry="8" transform="translate(158 262)" opacity="0.576" fill="url(#radial-gradient)"/> <g id="Group_6" data-name="Group 6" transform="translate(4 1)"> <g id="Group_4" data-name="Group 4" transform="translate(4 33)"> <path id="Path_383" data-name="Path 383" d="M2639.414-199.864l0,231.392L2865,75.031l-20.3-274.777Z" transform="translate(-2423 165.746)" opacity="0.9" fill="url(#linear-gradient)"/> <path id="Path_384" data-name="Path 384" d="M2863.758-199.746V31.526l-176.474,25.2L2639.34-199.746Z" transform="translate(-2647.34 165.746)" opacity="0.855" fill="url(#linear-gradient-2)"/> </g> <g id="Group_1" data-name="Group 1" transform="translate(-1463 535.503)"> <path id="Path_379" data-name="Path 379" d="M5.835,10.273,79.907,0a3.054,3.054,0,0,1,3.054,3.054L81.715,111.191c.063,2.486-2.975,6.563-5.475,6.741L3.054,124.1A3.054,3.054,0,0,1,0,121.046L2.781,13.328A3.054,3.054,0,0,1,5.835,10.273Z" transform="translate(1706.488 -454.452) rotate(48)"/> <path id="Path_375" data-name="Path 375" d="M5.835,10.273,79.907,0a3.054,3.054,0,0,1,3.054,3.054L81.455,111.911a6.165,6.165,0,0,1-6.024,5.684L3.054,124.1A3.054,3.054,0,0,1,0,121.046L2.781,13.328A3.054,3.054,0,0,1,5.835,10.273Z" transform="translate(1706.488 -456.743) rotate(48)" fill="#0a203b"/> <path id="Path_377" data-name="Path 377" d="M2076.8-429.738l-75.839,64.658,49,44.591,78.639-64.87Z" transform="translate(-376.238 -8.675)" fill="#c7c7c8"/> <path id="Path_378" data-name="Path 378" d="M2076.7-430.081l-75.638,64.93s15.716,16.233,28.546,23.725,29.693,9.832,46.565-.884,51.869-42.744,51.869-42.744Z" transform="translate(-376.262 -10.884)" fill="#fff"/> <path id="Path_376" data-name="Path 376" d="M3.054,4.947,37.394,0a3.054,3.054,0,0,1,3.054,3.054L40.187,14.4a3.054,3.054,0,0,1-3.054,3.054L3.3,21.832A3.054,3.054,0,0,1,.249,18.778L0,8A3.054,3.054,0,0,1,3.054,4.947Z" transform="translate(1721.953 -441.186) rotate(48)" fill="#0a203b"/> <path id="Path_380" data-name="Path 380" d="M3.054,4.947,37.394,0a3.054,3.054,0,0,1,3.054,3.054L40.187,14.4a3.054,3.054,0,0,1-3.054,3.054L3.3,21.832A3.054,3.054,0,0,1,.249,18.778L0,8A3.054,3.054,0,0,1,3.054,4.947Z" transform="translate(1721.953 -441.949) rotate(48)" fill="#0a203b"/> </g> <g id="Group_5" data-name="Group 5" transform="translate(-10 -14)"> <path id="Path_381" data-name="Path 381" d="M2592.494,263.491s9.979-1.826,24.476-6.086,20.113-11.228,20.113-11.228a133.644,133.644,0,0,0,20.467,18.252c11.729,8.324,26.451,15.046,26.451,15.046s-.792,6.831-30.43,9.428S2592.494,263.491,2592.494,263.491Z" transform="translate(-2483 -186.904)" fill="#fff"/> <path id="Path_382" data-name="Path 382" d="M2616.774,289.346s10.217,2.575,18.2,1.853a31.263,31.263,0,0,0,13.747-4.739s6.545,6.793,14.2,10.529a51.819,51.819,0,0,0,16.428,4.415,107.79,107.79,0,0,1-30.106,1.766C2633.395,301.7,2616.774,289.346,2616.774,289.346Z" transform="translate(-2491.962 -201.772)" fill="#ddddde"/> </g> <g id="Group_3" data-name="Group 3" transform="translate(312.821 125.927) rotate(-8)"> <path id="Path_385" data-name="Path 385" d="M2662.33,259.391a94.073,94.073,0,0,1-18.68-4.645,69.8,69.8,0,0,1-15.35-8.569,101.988,101.988,0,0,1-15.62,13.929,143.873,143.873,0,0,1-20.187,11.483s.6,5.213,23.224,7.2S2662.33,259.391,2662.33,259.391Z" transform="translate(-2592.493 -246.177)" fill="#fff"/> <path id="Path_386" data-name="Path 386" d="M2664.76,288.863a19.6,19.6,0,0,1-13.662,1.214c-8.043-2.008-10.491-3.617-10.491-3.617s-4.869,6.187-10.839,8.036-12.511,3.081-12.511,3.081,9.582,3.4,22.95,1.636S2664.76,288.863,2664.76,288.863Z" transform="translate(-2606.846 -267.064)" fill="#dcdcdd" opacity="0.675"/> </g> </g> <path id="Path_389" data-name="Path 389" d="M40.337,0C62.614,0,80.673,2.462,80.673,5.5S62.614,11,40.337,11,0,8.538,0,5.5,18.059,0,40.337,0Z" transform="translate(261 253)" opacity="0.15" fill="url(#radial-gradient-2)"/> <g id="Symbol_7_3" data-name="Symbol 7 – 3" transform="matrix(0.839, 0.545, -0.545, 0.839, 296.825, 161.227)"> <rect id="Rectangle_786" data-name="Rectangle 786" width="9.48" height="49.43" transform="translate(43.68 17.037) rotate(45)" fill="#b7b7b7"/> <rect id="Rectangle_787" data-name="Rectangle 787" width="6.771" height="49.43" transform="translate(44.159 17.516) rotate(45)" fill="#c7c7c8"/> <rect id="Rectangle_788" data-name="Rectangle 788" width="2.708" height="49.43" transform="translate(43.68 17.037) rotate(45)" fill="#dcdcdd"/> <path id="Path_373" data-name="Path 373" d="M3.909,0H5.555L9.48,6.094H0Z" transform="translate(47.989 12.728) rotate(45)" fill="#e7e7e8"/> <path id="Path_374" data-name="Path 374" d="M.849,0l.858,1.535H0Z" transform="translate(51.833 14.401) rotate(45)" fill="#4d4d4d"/> </g> <g id="Group_7" data-name="Group 7" transform="translate(310.701 92.66) rotate(87)"> <rect id="Rectangle_790" data-name="Rectangle 790" width="21.145" height="2.917" rx="1.458" transform="translate(37 75.614)" fill="#ff6f6f"/> <rect id="Rectangle_791" data-name="Rectangle 791" width="21.145" height="2.917" rx="1.458" transform="translate(49.031 66.5) rotate(90)" fill="#ff6f6f"/> </g> </g> </svg>',CLOSE_NO_DATA_MODAL_BTN:'<svg id="close-no-json-modal" data-aut="no-json-modal-close-button" style="cursor:pointer; position:absolute; top:14px; right:14px;" xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 14 13.998"><defs><style>.a{fill:rgba(0,0,0,0.36);}</style></defs><path class="a" d="M1421.292,5992.4l-4.9,4.9-2.1-2.1,4.9-4.9-4.9-4.9,2.1-2.1,4.9,4.9,4.9-4.9,2.1,2.1-4.9,4.9,4.9,4.9-2.1,2.1Z" transform="translate(-1414.292 -5983.293)"/></svg>',CLOSE_NO_DATA_MODAL_BTN_INNER_HTML:'<defs></defs><path class="a" d="M1421.292,5992.4l-4.9,4.9-2.1-2.1,4.9-4.9-4.9-4.9,2.1-2.1,4.9,4.9,4.9-4.9,2.1,2.1-4.9,4.9,4.9,4.9-2.1,2.1Z" transform="translate(-1414.292 -5983.293)"/>',NO_DATA_MODAL_IMG_INNER_HTML:'<defs> <radialGradient id="radial-gradient" cx="0.5" cy="0.5" r="0.5" gradientUnits="objectBoundingBox"> <stop offset="0" stop-color="#c7c7c8" stop-opacity="0.71"/> <stop offset="1" stop-color="#ddddde" stop-opacity="0"/> </radialGradient> <linearGradient id="linear-gradient" x1="0.747" y1="0.203" x2="0" y2="0.393" gradientUnits="objectBoundingBox"> <stop offset="0" stop-color="#dbe4f1" stop-opacity="0"/> <stop offset="1" stop-color="#c7c7c8" stop-opacity="0.518"/> </linearGradient> <linearGradient id="linear-gradient-2" x1="0.521" y1="0.272" x2="1" y2="0.393" gradientUnits="objectBoundingBox"> <stop offset="0" stop-color="#dbe4f1" stop-opacity="0"/> <stop offset="1" stop-color="#c7c7c8" stop-opacity="0.482"/> </linearGradient> <radialGradient id="radial-gradient-2" cx="0.5" cy="0.5" r="0.5" gradientUnits="objectBoundingBox"> <stop offset="0" stop-color="#727272"/> <stop offset="1" stop-color="#cbd9ee" stop-opacity="0"/> </radialGradient> </defs> <g id="illustration" transform="translate(0 0.118)"> <ellipse id="Ellipse_57" data-name="Ellipse 57" cx="63" cy="8" rx="63" ry="8" transform="translate(158 262)" opacity="0.576" fill="url(#radial-gradient)"/> <g id="Group_6" data-name="Group 6" transform="translate(4 1)"> <g id="Group_4" data-name="Group 4" transform="translate(4 33)"> <path id="Path_383" data-name="Path 383" d="M2639.414-199.864l0,231.392L2865,75.031l-20.3-274.777Z" transform="translate(-2423 165.746)" opacity="0.9" fill="url(#linear-gradient)"/> <path id="Path_384" data-name="Path 384" d="M2863.758-199.746V31.526l-176.474,25.2L2639.34-199.746Z" transform="translate(-2647.34 165.746)" opacity="0.855" fill="url(#linear-gradient-2)"/> </g> <g id="Group_1" data-name="Group 1" transform="translate(-1463 535.503)"> <path id="Path_379" data-name="Path 379" d="M5.835,10.273,79.907,0a3.054,3.054,0,0,1,3.054,3.054L81.715,111.191c.063,2.486-2.975,6.563-5.475,6.741L3.054,124.1A3.054,3.054,0,0,1,0,121.046L2.781,13.328A3.054,3.054,0,0,1,5.835,10.273Z" transform="translate(1706.488 -454.452) rotate(48)"/> <path id="Path_375" data-name="Path 375" d="M5.835,10.273,79.907,0a3.054,3.054,0,0,1,3.054,3.054L81.455,111.911a6.165,6.165,0,0,1-6.024,5.684L3.054,124.1A3.054,3.054,0,0,1,0,121.046L2.781,13.328A3.054,3.054,0,0,1,5.835,10.273Z" transform="translate(1706.488 -456.743) rotate(48)" fill="#0a203b"/> <path id="Path_377" data-name="Path 377" d="M2076.8-429.738l-75.839,64.658,49,44.591,78.639-64.87Z" transform="translate(-376.238 -8.675)" fill="#c7c7c8"/> <path id="Path_378" data-name="Path 378" d="M2076.7-430.081l-75.638,64.93s15.716,16.233,28.546,23.725,29.693,9.832,46.565-.884,51.869-42.744,51.869-42.744Z" transform="translate(-376.262 -10.884)" fill="#fff"/> <path id="Path_376" data-name="Path 376" d="M3.054,4.947,37.394,0a3.054,3.054,0,0,1,3.054,3.054L40.187,14.4a3.054,3.054,0,0,1-3.054,3.054L3.3,21.832A3.054,3.054,0,0,1,.249,18.778L0,8A3.054,3.054,0,0,1,3.054,4.947Z" transform="translate(1721.953 -441.186) rotate(48)" fill="#0a203b"/> <path id="Path_380" data-name="Path 380" d="M3.054,4.947,37.394,0a3.054,3.054,0,0,1,3.054,3.054L40.187,14.4a3.054,3.054,0,0,1-3.054,3.054L3.3,21.832A3.054,3.054,0,0,1,.249,18.778L0,8A3.054,3.054,0,0,1,3.054,4.947Z" transform="translate(1721.953 -441.949) rotate(48)" fill="#0a203b"/> </g> <g id="Group_5" data-name="Group 5" transform="translate(-10 -14)"> <path id="Path_381" data-name="Path 381" d="M2592.494,263.491s9.979-1.826,24.476-6.086,20.113-11.228,20.113-11.228a133.644,133.644,0,0,0,20.467,18.252c11.729,8.324,26.451,15.046,26.451,15.046s-.792,6.831-30.43,9.428S2592.494,263.491,2592.494,263.491Z" transform="translate(-2483 -186.904)" fill="#fff"/> <path id="Path_382" data-name="Path 382" d="M2616.774,289.346s10.217,2.575,18.2,1.853a31.263,31.263,0,0,0,13.747-4.739s6.545,6.793,14.2,10.529a51.819,51.819,0,0,0,16.428,4.415,107.79,107.79,0,0,1-30.106,1.766C2633.395,301.7,2616.774,289.346,2616.774,289.346Z" transform="translate(-2491.962 -201.772)" fill="#ddddde"/> </g> <g id="Group_3" data-name="Group 3" transform="translate(312.821 125.927) rotate(-8)"> <path id="Path_385" data-name="Path 385" d="M2662.33,259.391a94.073,94.073,0,0,1-18.68-4.645,69.8,69.8,0,0,1-15.35-8.569,101.988,101.988,0,0,1-15.62,13.929,143.873,143.873,0,0,1-20.187,11.483s.6,5.213,23.224,7.2S2662.33,259.391,2662.33,259.391Z" transform="translate(-2592.493 -246.177)" fill="#fff"/> <path id="Path_386" data-name="Path 386" d="M2664.76,288.863a19.6,19.6,0,0,1-13.662,1.214c-8.043-2.008-10.491-3.617-10.491-3.617s-4.869,6.187-10.839,8.036-12.511,3.081-12.511,3.081,9.582,3.4,22.95,1.636S2664.76,288.863,2664.76,288.863Z" transform="translate(-2606.846 -267.064)" fill="#dcdcdd" opacity="0.675"/> </g> </g> <path id="Path_389" data-name="Path 389" d="M40.337,0C62.614,0,80.673,2.462,80.673,5.5S62.614,11,40.337,11,0,8.538,0,5.5,18.059,0,40.337,0Z" transform="translate(261 253)" opacity="0.15" fill="url(#radial-gradient-2)"/> <g id="Symbol_7_3" data-name="Symbol 7 – 3" transform="matrix(0.839, 0.545, -0.545, 0.839, 296.825, 161.227)"> <rect id="Rectangle_786" data-name="Rectangle 786" width="9.48" height="49.43" transform="translate(43.68 17.037) rotate(45)" fill="#b7b7b7"/> <rect id="Rectangle_787" data-name="Rectangle 787" width="6.771" height="49.43" transform="translate(44.159 17.516) rotate(45)" fill="#c7c7c8"/> <rect id="Rectangle_788" data-name="Rectangle 788" width="2.708" height="49.43" transform="translate(43.68 17.037) rotate(45)" fill="#dcdcdd"/> <path id="Path_373" data-name="Path 373" d="M3.909,0H5.555L9.48,6.094H0Z" transform="translate(47.989 12.728) rotate(45)" fill="#e7e7e8"/> <path id="Path_374" data-name="Path 374" d="M.849,0l.858,1.535H0Z" transform="translate(51.833 14.401) rotate(45)" fill="#4d4d4d"/> </g> <g id="Group_7" data-name="Group 7" transform="translate(310.701 92.66) rotate(87)"> <rect id="Rectangle_790" data-name="Rectangle 790" width="21.145" height="2.917" rx="1.458" transform="translate(37 75.614)" fill="#ff6f6f"/> <rect id="Rectangle_791" data-name="Rectangle 791" width="21.145" height="2.917" rx="1.458" transform="translate(49.031 66.5) rotate(90)" fill="#ff6f6f"/> </g> </g> '},PLACEHOLDERS:{URL_PREFIX:'https://resources.digital-cloud-gov.medallia.com/',USERSNAP_CDN_URL:'//screencaptue-cdn.kampyle.com/',USERSNAP_HOST_PREFIX:'//screencapture.kampyle.com/',USERSNAP_CDN_V2_URL:'//screencapturev2-cdn.kampyle.com/',COOLADATA_SRC_PREFIX:'//nebula-cdn.kampyle.com/',COOLDATA_API_HOST:'udc-neb.kampyle.com/',USERSNAP_V4_HOST_PREFIX:'//scp.kampyle.com'},SRC:{OPEN_SANS:'resources/form/FormBuilder/vendor/fonts-googleapis/css/open-sans-v14.css',KLOADER:'resources/onsite/images/kloader.gif',COOLADATA:'resources/onsite/js/cool-2.1.15.min.js'},FORM_HEIGHT:'450',FORM_WIDTH:'450',COOKIE_EXPIRATION:365,DEVICES:{DESKTOP:'desktop',MOBILE:'mobile',TABLET:'tablet',},FEATURE_VERSIONS:{MOBILE_DYNAMIC_SIZING:2,},TIME_FORMATS:{SECONDS:'seconds',MINUTES:'minutes',HOURS:'hours',DAYS:'days',WEEKS:'weeks',MONTHS:'months',YEARS:'years',},DISPLAY_TYPES:{LIGHTBOX:'lightbox',ANIMATION:'animation',POPUP:'popup',EMBEDDED:'embedded',},FORM_TYPES:{EMBEDDED:'embedded',INVITATION:'invitation',BUTTON:'button',CODE:'code',},EVENT_DATA:{PAGE_NUMBER:'pageNumber',UUID:'feedbackUUID',},EVENT_NAME:{NEB_LOAD_FORM:'neb_loadForm'},FEATURE_FLAGS:{WCAG:'WCAG'},PROVISIONS:{cooladataNewEvents:'cooladataNewEvents',NEW_SCREEN_CAPTURE_CONFIG:'newScreenCaptureConfiguration',ON_PREM_HYBRID:'onPremHybrid',API_GATEWAY:'apiGateway',LOCALIZED_FORMS:'localizedForms',FORM_TEMPLATE_DATA_SEPERATION:'separateFormTemplateFromData',EVENT_INCLUDE_FEEDBACK_CONTENT:'eventIncludeFeedbackContent',CP_EXT_REFACTOR:'cpExtractRefactor',ADOBE_INCLUDE_LINK_TRACK_VARS:'adobeIncludeLinkTrackVars',ADOBE_ANALYTICS_OBJECT_NAME:'adobeAnalyticsObjectName',ADOBE_CONCAT_LINK_TRACK_VARS:'adobeConcatLinkTrackVars',ENABLE_OVERFLOW:'enableOverflow',SERVER_BASED_TARGETING:'serverBasedTargeting',NATIVE_SCREEN_CAPTURE:'nativeScreenCapture',COOLADATA_EVNETS_LIMIT:'cooladataEventsLimit',UBT_EXTRA_EVENTS:'UBTExtraEvents',ALTERNATIVE_UUID:'alternativeUUID',DISABLE_COOKIE_STORAGE:'cookieStorageDisable',SHARE_PROPERTY_DOMAIN:'sharePropertyBetweenSubdomains',SKIP_INVITATION_OPTIMIZATION:'skipInvitationOptimization',COOLADATA_SUBMITTED_BY_XHR:'cooladataSubmittedByXhr',DO_NOT_SURVEY_ON_UBT_NETWORK_FAIL:'doNotSurveyOnUBTNetworkFail',USER_SNAP_V4:'userSnapV4',CSP_RULES:'CSPRemoveInlineStyling',CREATE_SESSION:'cooladataCreateSessionEvent',},MEDALLIA_DIGITAL_EMBED_FILE:'medallia-digital-embed.js',DEFAULT_ADOBE_SDK_NAME:'s',ONPREM_URL_PREFIX:'/****ONPREM_URL_PREFIX****/',ONPREM_UDC_PREFIX:'/****JS_UDC****/',ANALYTICS_EVENT_FORBIDDEN_PROPERTIES:{sourceWindow:true,content:true},FORM_TRIGGER_TYPES_MAP:{embedded:'Embedded',invitation:'Intercept',button:'AlwaysOn',code:'TriggeredByCode',},LANG_MEMORY_DATA_KEY_PREFIX:'formLanguage:',FORM_JSON_DATA_KEY_PREFIX:'formJsonData:',INVITE_JSON_DATA_KEY_PREFIX:'inviteJsonData:',FORM_BUTTON:'button',FORM_INVITATION:'invitation',CUSTOM_EVENT_OTHER:'Other',EXPOSED_FORM_ID_LABEL:'Form_ID',EXPOSED_FORM_TYPE_LABEL:'Form_Type',EXPOSED_FEEDBACK_UUID_LABEL:'Feedback_UUID',EXPOSED_FEEDBACK_CONTENT_LABEL:'Content',LOCALIZED_FORM_DEFAULT_REPLACE_VALUE:'default',EMBEDDED:{IFRAME_ID_PREFIX:"embeddedIframe",},PROPERTY_SETTINGS:{MANUALLY_INVITE_TARGETING:'MANUALLY_INVITE_TARGETING',CUSTOM_CSS_UPLOAD:'CUSTOM_CSS_UPLOAD'},EVENTS:{MDIGITAL_MANUALLY_INVITE_TARGETING:'MDigital_manuallyInviteTargeting',MDIGITAL_PAGE_TARGETING_PHASE_ENDED:'MDigital_pageTargetingPhaseEnded',MDIGITAL_BEHAVIORAL_TARGETING_PHASE_ENDED:'MDigital_behavioralTargetingPhaseEnded',MDIGITAL_QUARANTINED_SURVEY_PHASE_ENDED:'MDigital_quarantinedSurveyPhaseEnded',MDIGITAL_TARGETING_RULE_EVALUATED:'MDigital_targetingRuleEvaluated',MDIGITAL_SCREEN_CAPTURE_LOADED:'neb_screenCaptureLoaded',MDIGITAL_SDK_PAGE_VIEW:'neb_sdkPageView',MDIGITAL_WARNING:'MDigital_warning',MDIGITAL_COULD_NOT_FETCH_DATA:'Mdigital_couldNotFetchData',NEB_EVENT_DISPATCHER_ERROR:'neb_eventDispatcherError',NEB_LOAD_FORM:'neb_loadForm',NEB_FORM_LOADING_HAS_FAILED:'neb_formLoadingHasFailed',CREATE_SESSION:'createSession',},LOG_MESSAGES:{TRIGGER_MESSAGE_TEMPLATE:'Event {{EVENT_NAME}} has been {{STATUS}}. \n the data is: {{DATA}}. \n the context is :{{CONTEXT}}. \n the options are : {{OPTIONS}}.\n',ERROR_LOG_TEMPLATE:'Error Message is {{ERROR_MESSAGE}}'},LOG_STATUSES:{FAILED:'failed',TRIGGERED:'triggered'},OPERATORS:{REGEX:'regex',EQUALS:'equals',DOES_NOT_EQUAL:'doesnotequal',CONTAINS:'contains',DOES_NOT_CONTAIN:'doesnotcontain',STARTS_WITH:'startswith',ENDS_WITH:'endswith',HAS_VALUE:'hasvalue',LATER_THAN:'laterthan',EARLIER_THAN:'earlierthan',GREATER_THAN:'greaterthan',SMALLER_THAN:'smallerthan'},TARGETING_STATUS:{CANDIDACY:'candidacy',TRIGGERED:'triggered',QUARANTINED:'quarantined'},TARGETING_PHASES:{PAGE_TARGETING:"pageTargeting",BEHAVIORAL_TARGETING:"behavioralTargeting",QUARANTINE_TARGETING:"quarantineTargeting"},REGIONS:{DEV:'dev',QA:'qa',COLO_QA:'digital-cloud-qa',COLO_US:'digital-cloud-us',},MEMORY_DATA_FIELDS:{MDIGITAL_ALTERNATIVE_UUID:'mdigital_alternative_uuid',FETCHING_DATA_IN_PROGRESS:'FETCHING_DATA_IN_PROGRESS_'},CSS_FONT_RULE:'CSSFontFaceRule',NETWORK:{RETRY_TIMEOUT:1000,REQUEST_TIMEOUT:2000,TIME_FOR_FORM_TO_LOAD_MS:60000,NUM_OF_RETRIES:3},ERROR_CODE:{SECURITY_ERROR:18},BROWSERS:{IE:'IE',CHROME:'Chrome'},URLS:{KMA_UDC:'https://nginx-log-post.kampyle.com/?data='},TEXTS:{SCREEN_CAPTURE:{DEFAULT_DESCRIPTION:'Click "Capture Image" button or drag the cursor to highlight a specific area'}}};window.KAMPYLE_FUNC=(function(){function init(){var formattedFormData;formattedFormData=kampyleGetData()||{};var customParams;if(formattedFormData.formNodes&&formattedFormData.formNodes.length){for(var i=0;i<formattedFormData.formNodes.length;i++){if(formattedFormData.formNodes[i].customParams){customParams=JSON.parse(formattedFormData.formNodes[i].customParams);formattedFormData.formNodes[i].customParams=customParams;}}}
- KAMPYLE_EVENT_DISPATCHER.init();KAMPYLE_DATA.init();subscribeFirstToPageEvents();KAMPYLE_VIEW.init();window.MDIGITAL&&window.MDIGITAL.EMBEDDED&&window.MDIGITAL.EMBEDDED.init();KAMPYLE_TARGETING.init();KAMPYLE_MESSAGE.init();KAMPYLE_ANIMATION.init();var region=formattedFormData?formattedFormData.region:'dev';formattedFormData=validateFormContract(formattedFormData);if(MDIGITAL_OnPrem.isOnPrem()){formattedFormData.formNodes.forEach(MDIGITAL_OnPrem.replaceFormNodeUrls);}
- KAMPYLE_DATA.setMemoryData('dataJson',formattedFormData);var context=KAMPYLE_UTILS.getUrlParam('nebContext')||'live';KAMPYLE_DATA.setMemoryData('context',context);KAMPYLE_DATA.setMemoryData('region',region);KAMPYLE_DATA.setMemoryData('kampyleDevice',checkDevice());KAMPYLE_DATA.setMemoryData('hostedViewportContent',[]);KAMPYLE_DATA.setMemoryData('isGuest',true);var browser=KAMPYLE_UTILS.getBrowser();if(KAMPYLE_DATA.getMemoryData('context')!=='preview'&&(browser.name!=='MSIE'||parseInt(browser.version,10)>9)){}
- KAMPYLE_SESSIONCAM.init();MDIGITAL.CUSTOM_EVENTS.init();createSession();subscribeToPageEvents();subscribeToCustomEvents();KAMPYLE_UTILS.setEventHandler(window,'hashchange',handleHashChanged);KAMPYLE_UTILS.triggerCustomEvent('neb_OnsiteLoaded');}
- function validateFormContract(formsObj){formsObj.formNodes=formsObj.formNodes||[];var currForm;for(var i=formsObj.formNodes.length-1;i>=0;i--){currForm=formsObj.formNodes[i];if(!currForm.formHeight||currForm.formHeight==='null'){currForm.formHeight=KAMPYLE_CONSTANT.FORM_HEIGHT;}
- if(!currForm.formWidth||currForm.formWidth==='null'){currForm.formWidth=KAMPYLE_CONSTANT.FORM_WIDTH;}}
- return formsObj;}
- function subscribeFirstToPageEvents(){var eventMapping={neb_inviteReady:[sendInviteInitialData],neb_buttonClicked:[loadFormFirst],neb_inviteAccepted:[loadFormFirst],neb_showInvitation:[prepareInviteTriggeringData],neb_sdkPageView:[setInviteState,KAMPYLE_DATA.initFormState],};KAMPYLE_EVENT_DISPATCHER.subscribeMany(eventMapping);}
- function loadFormFirst(eventName,data){var formState=KAMPYLE_DATA.getFormState(data.formId);if(!formState.loaded&&!formState.loading){KAMPYLE_EVENT_DISPATCHER.trigger('neb_loadForm',{formId:data.formId});}}
- function loadMultipileForms(eventName,data){var formIds=(data||{}).formIds||[];formIds.forEach(function(fid){KAMPYLE_COMMON.loadForm(fid);});}
- function routeToForm(eventName,data){data=data||{};KAMPYLE_COMMON.closeForm(data.sourceFormId);if(!KAMPYLE_COMMON.showForm(data.formId)){throw new Error('Form cannot be loaded');}}
- function focusOnInviteIframe(){var iframe=document.querySelector('#kampyleInvite');if(iframe&&typeof iframe.focus==='function'){iframe.focus();}}
- function handleInviteApplicationUpdated(eventName,data){data=data||{};var shouldShowInvite=(KAMPYLE_DATA.getFormState(data.formId)||{}).inviteShown;if(shouldShowInvite&&MDIGITAL.FORM_STATE.isInviteLoaded(data.formId)&&isJsonDataLoaded(data.formId,true)&&!isAnyOtherFormAlreadyShown()){KAMPYLE_VIEW.showInvite("",{formId:data.formId});KAMPYLE_EVENT_DISPATCHER.trigger('neb_inviteReady',data);KAMPYLE_DATA.setMemoryData('inviteLoadedAndShown',true);}
- else if(hasApplicationLoadingFailed(data.formId,true)||isAnyOtherFormAlreadyShown()){KAMPYLE_DATA.setFormState(data.formId,{inviteShown:false});}}
- function subscribeToCustomEvents(){var eventMapping={neb_inviteDeclined:['neb_displayClosed'],neb_formClosed:['neb_displayClosed'],};KAMPYLE_EVENT_DISPATCHER.subscribeMany(eventMapping);}
- function isFormAlreadyShown(formId){var shouldSkipShowingForm=KAMPYLE_DATA.isSkipInvitation(formId)&&isAnyOtherFormAlreadyShown(formId);if(shouldSkipShowingForm){KAMPYLE_EVENT_DISPATCHER.trigger('neb_formReady',{formId:formId});KAMPYLE_DATA.setFormState(formId,{shouldBeShown:false});KAMPYLE_EVENT_DISPATCHER.trigger('neb_skipShowingForm',{formId:formId});}
- return shouldSkipShowingForm;}
- function hasApplicationLoadingFailed(formId,isInvite){var jsonDataKey=(isInvite?KAMPYLE_CONSTANT.INVITE_JSON_DATA_KEY_PREFIX:KAMPYLE_CONSTANT.FORM_JSON_DATA_KEY_PREFIX)+formId;var currentMemoryData=KAMPYLE_DATA.getMemoryData(jsonDataKey);var formState=KAMPYLE_DATA.getFormState(formId);return currentMemoryData===false||(!isInvite&&formState&&formState.loaded===false)||(isInvite&&formState&&formState.inviteLoaded===false);}
- function isJsonDataLoaded(formId,isInvite){var jsonDataKey=(isInvite?KAMPYLE_CONSTANT.INVITE_JSON_DATA_KEY_PREFIX:KAMPYLE_CONSTANT.FORM_JSON_DATA_KEY_PREFIX)+formId;return!KAMPYLE_FUNC.checkProvision(KAMPYLE_CONSTANT.PROVISIONS.FORM_TEMPLATE_DATA_SEPERATION)||KAMPYLE_DATA.getMemoryData(jsonDataKey);}
- function shouldSkipFetchingFormData(formId,isInvite){var isFetchingDataInProgress=KAMPYLE_DATA.getMemoryData(KAMPYLE_CONSTANT.MEMORY_DATA_FIELDS.FETCHING_DATA_IN_PROGRESS+formId);return!KAMPYLE_FUNC.checkProvision(KAMPYLE_CONSTANT.PROVISIONS.FORM_TEMPLATE_DATA_SEPERATION)||hasApplicationLoadingFailed(formId,isInvite)||isJsonDataLoaded(formId,false)||isFetchingDataInProgress;}
- function handleFormLoadingFailed(eventName,data){setTimeout(function(){KAMPYLE_DATA.setFormState(data.formId,{shouldBeShown:false,loaded:false});},0);}
- function isFormLoaded(formId){var formData=KAMPYLE_DATA.getFormData(formId);var displayType=KAMPYLE_DATA.getDisplayType(formData);return MDIGITAL.FORM_STATE.isFormLoaded(formId)||displayType===KAMPYLE_CONSTANT.DISPLAY_TYPES.POPUP;}
- function prepareJsonData(eventName,data){var isInvite=eventName==='neb_loadInvitation';if(KAMPYLE_FUNC.shouldSkipFetchingFormData(data.formId,isInvite)){return;}
- else{KAMPYLE_DATA.setMemoryData(KAMPYLE_CONSTANT.MEMORY_DATA_FIELDS.FETCHING_DATA_IN_PROGRESS+data.formId+(isInvite?"_invite":''),true);}
- KAMPYLE_DATA.fetchFormJsonData({formId:data.formId,isInvite:isInvite,callback:function(){if(isInvite){KAMPYLE_FUNC.handleInviteApplicationUpdated("",data);}
- else{KAMPYLE_FUNC.handleFormStateUpdated(data);}},onError:onJsonFetchingFailed.bind(null,data,isInvite)});}
- function shouldRenderForm(data){var isFormLoadedSuccessfully=isFormLoaded(data.formId)&&isJsonDataLoaded(data.formId,false);var shouldShowForm=MDIGITAL.FORM_STATE.shouldFormBeShown(data.formId)&&!isFormAlreadyShown(data.formId);return isFormLoadedSuccessfully&&shouldShowForm;}
- function onJsonFetchingFailed(data,isInvite){if(isInvite){KAMPYLE_DATA.setMemoryData(KAMPYLE_CONSTANT.INVITE_JSON_DATA_KEY_PREFIX+data.formId,false);}
- else{KAMPYLE_DATA.setMemoryData(KAMPYLE_CONSTANT.FORM_JSON_DATA_KEY_PREFIX+data.formId,false);KAMPYLE_EVENT_DISPATCHER.trigger(KAMPYLE_CONSTANT.EVENTS.NEB_FORM_LOADING_HAS_FAILED,{formId:data.formId});}
- KAMPYLE_COOLADATA.triggerCooladataEvent(KAMPYLE_CONSTANT.EVENTS.MDIGITAL_COULD_NOT_FETCH_DATA,{formId:data.formId,isInvite:isInvite,err:'Could not fetch json data'});}
- function handleFormStateUpdated(data){if(shouldRenderForm(data)){KAMPYLE_EVENT_DISPATCHER.trigger('neb_showForm',{formId:data.formId});KAMPYLE_EVENT_DISPATCHER.trigger('neb_formReady',{formId:data.formId});KAMPYLE_DATA.setFormState(data.formId,{shown:true})}
- else if(hasApplicationLoadingFailed(data.formId,false)){KAMPYLE_EVENT_DISPATCHER.trigger(KAMPYLE_CONSTANT.EVENTS.NEB_FORM_LOADING_HAS_FAILED,{formId:data.formId});}}
- function subscribeToPageEvents(){var eventMapping={neb_pageView:[increasePageViewCounter],neb_showInvitation:[setInviteState,KAMPYLE_UTILS.setCurrentScrollPosition,setFocusedElement,focusOnInviteIframe,handleInviteApplicationUpdated],neb_buttonClicked:[KAMPYLE_UTILS.setCurrentScrollPosition,setFocusedElement,handleShowForm],neb_sdkShowForm:[KAMPYLE_UTILS.setCurrentScrollPosition,setFocusedElement,handleShowForm],neb_skipInvitation:[KAMPYLE_UTILS.setCurrentScrollPosition,handleShowForm],neb_inviteLoaded:[setInviteState,handleInviteLoaded],neb_inviteAccepted:[setInviteState,KAMPYLE_UTILS.setCurrentScrollPosition,handleShowForm],neb_inviteDeclined:[setInviteState,handleInviteDeclined,KAMPYLE_UTILS.scrollToLastPosition],neb_formClosed:[handleFormClosed,KAMPYLE_UTILS.scrollToLastPosition],neb_popupBlocked:[handleFormClosed,KAMPYLE_UTILS.scrollToLastPosition],neb_loadForm:[prepareJsonData,handleFormLoading],neb_loadInvitation:[prepareJsonData],neb_formLoaded:[handleFormLoaded],neb_loadMultipileForms:[loadMultipileForms],neb_routeToForm:[routeToForm],neb_formReady:[sendFormExtraData,handleVersion,loadScreenCaptureApi],neb_feedbackSubmitted:[handleFeedbackSubmitted],neb_captureImageClicked:[handleTakenScreenCapture],neb_sdkPageView:[startCheckingTargeting],neb_screenCaptureLoaded:[handleScreenCaptureApiLoaded],neb_formLoadingHasFailed:[handleFormLoadingFailed]};KAMPYLE_EVENT_DISPATCHER.subscribeMany(eventMapping);}
- function getTriggerTypeByEvent(eventName){var eventTriggerMapping={neb_buttonClicked:'Button',neb_sdkShowForm:'ByCode',neb_routeToForm:'ByCode',neb_skipInvitation:'Invitation',neb_inviteAccepted:'Invitation',};return eventTriggerMapping[eventName]||null;}
- function handleShowForm(eventName,data){data=data||{};data.triggerType=data.triggerType||getTriggerTypeByEvent(eventName);KAMPYLE_DATA.saveFormExtraData(data.formId,{triggerType:data.triggerType,});KAMPYLE_DATA.setMemoryData('currentFormId',data.formId);KAMPYLE_DATA.setMemoryData('formIsShown',true);KAMPYLE_DATA.setFormState(data.formId,{shouldBeShown:true});handleFormStateUpdated(data);}
- function createSession(){var referrerDifferentThanHost=isReferrerDifferentThanHost();var kampyleUserSession=KAMPYLE_DATA.getData('kampyleUserSession');var isDirectNavigation=false;try{isDirectNavigation=document.referrer===''||window.parent.document.referrer==='';}catch(e){var data={errorMessage:e.message,errorStack:e.stack,additionalInfo:"createSession- failed to access document.referrer, probably CORS problem when the customer's iframe is hosted in a website with different domain."};referrerDifferentThanHost=false;}finally{if(!kampyleUserSession||isDirectNavigation||referrerDifferentThanHost){var currentTime=new Date();KAMPYLE_DATA.setMemoryData('isSyncedIdentifierData',false);KAMPYLE_DATA.setData('kampyleUserSession',currentTime.getTime());KAMPYLE_DATA.setData('kampyleSessionPageCounter',0);addToSessionCount();KAMPYLE_DATA.deleteData('kampyleUserPercentile');KAMPYLE_DATA.deleteData('kampyleInvitePresented');}}}
- function isReferrerDifferentThanHost(){var referrerDomain=document.referrer.match(/:\/\/(.[^/]+)/);if(!referrerDomain){return true;}
- referrerDomain=referrerDomain[1];if(referrerDomain===window.location.host){return false;}
- var propertySharedSubdomain=KAMPYLE_DATA.getPropertySharedSubdomain();if(propertySharedSubdomain){return!KAMPYLE_UTILS.isHostMatchesSubdomain(referrerDomain,propertySharedSubdomain)||!KAMPYLE_UTILS.isHostMatchesSubdomain(window.location.host,propertySharedSubdomain);}
- return true;}
- function kampyleGetData(){var dataJson=KAMPYLE_DATA.getMemoryData('dataJson''inviteVersion');KAMPYLE_DATA.setMemoryData('inviteVersion',inviteVersion);var formState=KAMPYLE_DATA.getFormState(data.formId)||{};if(formState.inviteShown){handleInviteApplicationUpdated("",data);}}
- function handleFormLoading(eventName,data){data=data||{};KAMPYLE_DATA.setFormState(data.formId,{loading:true,});KAMPYLE_EVENT_DISPATCHER.trigger('neb_form_loaded',{formId:data.formId});}
- function sendInviteInitialData(eventName,data){data=data||{};if(!KAMPYLE_DATA.getFormState(data.formId).inviteLoaded){return false;}
- KAMPYLE_UTILS.sendMessageToIframe('kampyleInvite',{action:'inviteShown',});var messageData={accountId:data.accountId,websiteId:data.websiteId,environment:data.enviroment,url:document.location.href,kampyle_version:window.KAMPYLE_REVISION||'0.0.0.0',formId:data.formId,cookie_size:KAMPYLE_UTILS.getByteSize(document.cookie),isWCAG:KAMPYLE_DATA.isFeatureEnabled('WCAG'),deviceType:checkDevice(),provisions:getAllProvisions(),position:KAMPYLE_VIEW.getInvitePosition(data.formId),customCssUpload:KAMPYLE_DATA.isFeatureEnabled(KAMPYLE_CONSTANT.PROPERTY_SETTINGS.CUSTOM_CSS_UPLOAD)};if(KAMPYLE_FUNC.checkProvision(KAMPYLE_CONSTANT.PROVISIONS.FORM_TEMPLATE_DATA_SEPERATION)){var callbackFunction=function(jsonData){messageData=Object.assign({},messageData,{inviteData:jsonData});if(KAMPYLE_FUNC.checkProvision(KAMPYLE_CONSTANT.PROVISIONS.LOCALIZED_FORMS)){messageData.formLanguage=MDIGITAL.LOCALIZATION.getFormLanguage(data.formId)||null;}
- KAMPYLE_UTILS.sendMessageToIframe('kampyleInvite',{action:'setExtraData',data:messageData,});};var onError=function(error){console.error(error);};KAMPYLE_DATA.fetchFormJsonData({formId:data.formId,callback:callbackFunction,onError:onError,isInvite:true},true)}else{KAMPYLE_UTILS.sendMessageToIframe('kampyleInvite',{action:'setExtraData',data:messageData,});}}
- function setInviteState(eventName,data){data=data||{};data.formId=data.formId||KAMPYLE_DATA.getMemoryData('currentFormId');switch(eventName){case'neb_showInvitation':KAMPYLE_DATA.setFormState(data.formId,{inviteShown:true,});break;case'neb_inviteDeclined':case'neb_inviteAccepted':KAMPYLE_DATA.setFormState(data.formId,{inviteShown:false,});break;case'neb_inviteLoaded':KAMPYLE_DATA.setFormState(data.formId,{inviteLoaded:true,});break;case'neb_sdkPageView':KAMPYLE_DATA.setFormState(data.formId,{inviteLoaded:null,inviteShown:false,});break;default:KAMPYLE_UTILS.showWarning('Unhandled event name '+eventName);}}
- function updatePreviewIframeStyle(formData){var currentFormId=formData.formId;var formWidth;var formHeight;if(formData){formWidth=parseInt(formData.formWidth,10);formHeight=parseInt(formData.formHeight,10);}
- var hostWidth=document.documentElement.clientWidth;var hostHeight=document.documentElement.clientHeight;var innerContainerStyle={overflowY:'auto',height:'100%',};KAMPYLE_UTILS.setElementStyle(document.getElementById('innerContainer'),innerContainerStyle);var iframeStyleObject={border:0,position:'relative',margin:'50px auto 50px',height:formHeight+'px',width:formWidth+'px',};if(hostWidth>formWidth&&hostHeight>formHeight){if(KAMPYLE_DATA.isCustomHtmlAndFixedSizeForm(currentFormId)){iframeStyleObject={position:'absolute',top:'50%','margin-top':-formHeight/2+'px',left:'50%','margin-left':-formWidth/2+'px',height:formHeight+'px',width:formWidth+'px',};}
- else{iframeStyleObject={position:'fixed',height:'100%',width:'100%',};}}
- var modal=document.getElementById('kampyleFormModal');if(modal&&modal.style&&modal.removeAttribute){modal.removeAttribute('style');KAMPYLE_UTILS.setElementStyle(modal,iframeStyleObject);}}
- function showPreviewForm(){var formHeight=450;var formWidth=450;var formUrl=KAMPYLE_UTILS.getUrlParam('url');var url;if(KAMPYLE_DATA.getMemoryData('kampyleDevice')===KAMPYLE_CONSTANT.DEVICES.MOBILE){formWidth='100%';formHeight='100%';}
- else{var height=KAMPYLE_UTILS.getUrlParam('height');var width=KAMPYLE_UTILS.getUrlParam('width');if(!!height&&!isNaN(height)){formHeight=height;}
- if(!!width&&!isNaN(width)){formWidth=width;}}
- if(!!formUrl&&KAMPYLE_UTILS.validateKampyleDomain(decodeURIComponent(formUrl))){formUrl=decodeURIComponent(formUrl);formUrl+='?region='+KAMPYLE_DATA.getMemoryData('region');var formId=KAMPYLE_UTILS.getUrlParam('formId');if(!!formId){formUrl+='&formId='+formId;KAMPYLE_DATA.setMemoryData('currentFormId',formId);}
- else{url=location.protocol+'//'+location.host;window.location=url+'/#/error/404';}
- var provisions=decodeURIComponent(window.getUrlParam('provisions'));if(!!provisions){formUrl+='&provisions='+encodeURIComponent(provisions);}
- var currentWebsiteId=decodeURIComponent(window.getUrlParam('websiteId'));if(!!currentWebsiteId){formUrl+='&websiteId='+encodeURIComponent(currentWebsiteId);}
- var type=KAMPYLE_UTILS.getUrlParam('type')||'direct';var validTypes=['live','direct','preview'];if(validTypes.indexOf(type.toLowerCase())===-1){type='direct';}
- formUrl+='&type='+type;var iframeHeight='100%';var iframeWidth='100%';if(KAMPYLE_DATA.isCustomHtmlAndFixedSizeForm(formId)){iframeHeight=formHeight;iframeWidth=formWidth;}
- var iframe=KAMPYLE_UTILS.createIframe(formUrl,iframeWidth,iframeHeight,'kampyleForm'+formId);if(KAMPYLE_DATA.isCustomHtmlForm(formId)){updatePreviewIframeStyle({formId:formId,formHeight:formHeight,formWidth:formWidth,});}
- var modal=document.getElementById('kampyleFormModal');if(!!modal){modal.appendChild(iframe);if(iframe.offsetTop<30&&!KAMPYLE_DATA.getMemoryData('kampyleDevice')===KAMPYLE_CONSTANT.DEVICES.MOBILE){modal.style.paddingTop=30-iframe.offsetTop+'px';}}}
- else{url=location.protocol+'//'+location.host;window.location=url+'/#/error/404';}}
- function getUserIdentifierVal(){var identifierCustomParam=KAMPYLE_DATA.getUserIdentifier();if(!identifierCustomParam){return null;}
- var userIdentifierVal=MDIGITAL.CUSTOM_PARAMETERS.getCustomParamValue({name:identifierCustomParam.source_name,type:identifierCustomParam.type,source:identifierCustomParam.source,});if(!userIdentifierVal){return null;}
- return userIdentifierVal;}
- function setIdentifierData(identifierData){KAMPYLE_DATA.setMemoryData('isSyncedIdentifierData',true);updateIdentifierDataIfNecessary(identifierData.data);}
- function updateIdentifierDataIfNecessary(identifierData){updateIdentifierDataIntegerIfNecessary(identifierData.DECLINED_DATE,'DECLINED_DATE');updateIdentifierDataIntegerIfNecessary(identifierData.SUBMITTED_DATE,'SUBMITTED_DATE');}
- function updateIdentifierDataIntegerIfNecessary(identifierDataValue,userStateString){var localStorageDate=parseInt(KAMPYLE_DATA.getData(userStateString));localStorageDate=localStorageDate?localStorageDate:null;var identifierDataToSync={identifierDataState:userStateString,identifierValOnLocalStorage:localStorageDate};var identifierDataValues={identifierDataState:userStateString,identifierValOnSbt:identifierDataValue,identifierValOnLocalStorage:localStorageDate};identifierDataValue=identifierDataValue?identifierDataValue:null;if(identifierDataValue===localStorageDate){return null;}
- if((identifierDataValue!==null&&localStorageDate===null)||identifierDataValue>localStorageDate){KAMPYLE_DATA.setData(userStateString,identifierDataValue);}
- else if((localStorageDate!==null&&identifierDataValue===null)||identifierDataValue<localStorageDate){KAMPYLE_FUNC.updateTargeting(userStateString,localStorageDate);}
- else{KAMPYLE_UTILS.showWarning('special case');}}
- function syncIdentifierData(userIdentifierVal,callback){var propertyId=kampyleGetData().websiteId||null;var urlPrefix=KAMPYLE_DATA.getServerBasedTargetingPrefix();var envPrefix=KAMPYLE_DATA.getServerBasedTargetingEnv();var url=urlPrefix+'/api/targeting/property/'+envPrefix+propertyId+'/identity/'+userIdentifierVal;var onSuccess=KAMPYLE_FUNC.onSyncIdentifierDataSuccess.bind(null,callback);var onFailure=onSyncIdentifierDataFailure.bind(null,callback);KAMPYLE_UTILS.httpGetRequest(url,onSuccess,onFailure);}
- function onSyncIdentifierDataSuccess(callback,data){if(!data||data.error){}else{setIdentifierData(data);}
- typeof callback==='function'&&callback();}
- function onSyncIdentifierDataFailure(callback,error){typeof callback==='function'&&callback();}
- function shouldSyncIdentifier(newUserIdentifierVal){var prevUserIdentifierVal=KAMPYLE_DATA.getMemoryData('identifierValue');var isSyncedIdentifierData=KAMPYLE_DATA.getMemoryData('isSyncedIdentifierData')===true;var isSBTOn=!!KAMPYLE_FUNC.checkProvision('serverBasedTargeting');var isIdentifiedUser=!!newUserIdentifierVal;return isIdentifiedUser&&isSBTOn&&(!isSyncedIdentifierData||prevUserIdentifierVal!==newUserIdentifierVal);}
- function startCheckingTargeting(){if(isAnyOtherFormAlreadyShown()){return false;}
- KAMPYLE_DATA.setMemoryData('isInvitationShouldBeIgnored',false);KAMPYLE_EVENT_DISPATCHER.trigger('neb_pageView');if(KAMPYLE_DATA.getMemoryData('context')==='preview'){showPreviewForm();}
- else if(window.KAMPYLE_ONSITE_STATE!=='manual'){var shouldSkipInviteTargeting=KAMPYLE_DATA.isFeatureEnabled(KAMPYLE_CONSTANT.PROPERTY_SETTINGS.MANUALLY_INVITE_TARGETING);KAMPYLE_EVENT_DISPATCHER.trigger('neb_targetingInit',{skipInviteTargeting:shouldSkipInviteTargeting});}}
- function increasePageViewCounter(){var sessionPageCounter=KAMPYLE_DATA.getData('kampyleSessionPageCounter')||0;sessionPageCounter=parseInt(sessionPageCounter);KAMPYLE_DATA.setData('kampyleSessionPageCounter',++sessionPageCounter);}
- function handleFormClosed(eventName,data){data=data||{};if(!data.isFormSubmitted){var date=Date.now();KAMPYLE_DATA.setData('DECLINED_DATE',date);if(!!KAMPYLE_FUNC.checkProvision('serverBasedTargeting')){KAMPYLE_EVENT_DISPATCHER.trigger('MDigital_updateTargetingWithDeclinedDateFormClosed',{declinedDate:date});}
- KAMPYLE_FUNC.updateTargeting('DECLINED_DATE',date);}
- KAMPYLE_DATA.setMemoryData('formIsShown',false);var formData=KAMPYLE_DATA.getFormData(data.formId);KAMPYLE_DATA.setFormState(data.formId,{shouldBeShown:false,shown:false,loaded:null});refocusActiveElement();KAMPYLE_UTILS.triggerCustomEvent('neb_formClosed',{formId:data.formId});if(KAMPYLE_DATA.getMemoryData('context')==='preview'){window.close();}
- var formData=KAMPYLE_DATA.getFormData(KAMPYLE_DATA.getMemoryData('buttonFormId'));var delay=0;if(KAMPYLE_DATA.getDisplayType(formData)==='animation'){delay=1000;}
- if(KAMPYLE_DATA.getMemoryData('buttonFormId')){setTimeout(function(){KAMPYLE_EVENT_DISPATCHER.trigger('neb_showButton',{formId:KAMPYLE_DATA.getMemoryData('buttonFormId')});},delay);}}
- function updateTargeting(stateType,data){if(!!checkProvision('serverBasedTargeting')&&!!KAMPYLE_DATA.getMemoryData('identifierValue')){var dataJson={};dataJson[stateType]=data;var urlPrefix=KAMPYLE_DATA.getServerBasedTargetingPrefix();var envPrefix=KAMPYLE_DATA.getServerBasedTargetingEnv();var url=urlPrefix+'/api/targeting/property/'+envPrefix+kampyleGetData().websiteId+'/identity/'+KAMPYLE_DATA.getMemoryData('identifierValue');var dataStateType=dataJson[stateType];var dataObjForSbt={dataState:dataStateType,dataValue:data};KAMPYLE_EVENT_DISPATCHER.trigger('MDigital_updatingSbtServer',dataObjForSbt);KAMPYLE_UTILS.httpPostRequest(url,dataJson);}}
- function handleFeedbackSubmitted(eventMapping,data){var date=Date.now();KAMPYLE_DATA.setData('SUBMITTED_DATE',date);if(!!KAMPYLE_FUNC.checkProvision('serverBasedTargeting')){KAMPYLE_EVENT_DISPATCHER.trigger('MDigital_updateTargetingWithSubmittedDate',{submittedDate:date});}
- if(checkProvision(KAMPYLE_CONSTANT.PROVISIONS.NATIVE_SCREEN_CAPTURE)){KAMPYLE_EVENT_DISPATCHER.trigger('neb_sendScreenCapture');}
- KAMPYLE_FUNC.updateTargeting('SUBMITTED_DATE',date);}
- function handleInviteDeclined(eventName,data){var date=Date.now();KAMPYLE_DATA.setData('DECLINED_DATE',date);if(!!KAMPYLE_FUNC.checkProvision('serverBasedTargeting')){KAMPYLE_EVENT_DISPATCHER.trigger('MDigital_updateTargetingWithDeclinedDateInviteDeclined',{declinedDate:date});}
- KAMPYLE_FUNC.updateTargeting('DECLINED_DATE',date);refocusActiveElement();}
- function handleFormLoaded(eventName,data){KAMPYLE_DATA.setFormState(data.formId,{loading:false,loaded:true,});handleFormStateUpdated(data);}
- function loadScreenCaptureApi(eventName,data){data=data||{};}
- function handleScreenCaptureApiLoaded(eventName,data){data=data||{};var formData=KAMPYLE_DATA.getFormData(data.formId);var iframePrefix;switch(KAMPYLE_DATA.getDisplayType(formData)){case KAMPYLE_CONSTANT.DISPLAY_TYPES.LIGHTBOX:iframePrefix='kampyleForm';break;case KAMPYLE_CONSTANT.DISPLAY_TYPES.ANIMATION:iframePrefix='kampyleFormAnimation';break;default:iframePrefix='kampyleForm';}
- var iframeId=iframePrefix+data.formId;KAMPYLE_UTILS.sendMessageToIframe(iframeId,{action:'screenCaptureLoaded'});}
- function setFocusedElement(){KAMPYLE_DATA.setMemoryData('kampyleFocusedElement',document.activeElement);}
- function refocusActiveElement(){var focused=KAMPYLE_DATA.getMemoryData('kampyleFocusedElement');if(focused&&focused.focus){focused.focus();}}
- function checkProvision(name){var dataObj=kampyleGetData();return!!name&&!!dataObj&&!!dataObj.provisions&&(!!dataObj.provisions[name]||dataObj.provisions[name]==='true');}
- function getAllProvisions(){var allProvisions=KAMPYLE_FUNC.kampyleGetData().provisions;var provisions={};for(var provision in allProvisions){if(allProvisions.hasOwnProperty(provision)){provisions[provision]=checkProvision(provision);}}
- return provisions;}
- function checkDevice(){if(!KAMPYLE_DATA.getMemoryData('kampyleDevice')){KAMPYLE_DATA.setMemoryData('kampyleDevice',KAMPYLE_UTILS.getDeviceTypeByUserAgent(navigator.userAgent));}
- return KAMPYLE_DATA.getMemoryData('kampyleDevice')||'desktop';}
- function addScreenCaptureData(messageData){var version=KAMPYLE_DATA.getMemoryData('version');if(version===1){messageData.screenCapture={isTaken:false};}
- else{messageData.integrations.screenCapture={isTaken:false};}
- return messageData;}
- function sendFormExtraData(eventName,data){data=data||{};var formData=KAMPYLE_DATA.getFormData(data.formId);if(!formData||!data.formId){return false;}
- var targetWindow;var currIframe;var formDisplayType=KAMPYLE_DATA.getDisplayType(formData);switch(formDisplayType){case'animation':currIframe=document.getElementById('kampyleFormAnimation'+data.formId);break;case'lightbox':currIframe=document.getElementById('kampyleForm'+data.formId);break;case'popup':targetWindow=KAMPYLE_DATA.getMemoryData('popupHandler');break;case KAMPYLE_CONSTANT.DISPLAY_TYPES.EMBEDDED:currIframe=document.getElementById(KAMPYLE_CONSTANT.EMBEDDED.IFRAME_ID_PREFIX+data.formId);break;default:KAMPYLE_UTILS.showWarning('Invalid display type - '+formDisplayType);return false;}
- var origin='*';if(currIframe&&currIframe.getAttribute){origin=currIframe.getAttribute('origin')||'*';targetWindow=currIframe.contentWindow;}
- if(targetWindow&&targetWindow.postMessage){if(MDIGITAL.CUSTOM_PARAMETERS.hasCustomParams(data.formId))
- {var customParams=MDIGITAL.CUSTOM_PARAMETERS.formatCustomParams(data.formId);targetWindow.postMessage('{"action": "customParamsLoaded","customParams" : '+JSON.stringify(customParams)+'}',origin);}
- var messageData='{"action": "setFormId","formId" : '+data.formId+'}';targetWindow.postMessage(messageData,origin);messageData={action:'setExtraData',};messageData.provisions=getAllProvisions();messageData.integrations=KAMPYLE_INTEGRATION.getIntegrationData();messageData.websiteId=kampyleGetData().websiteId||null;messageData.device=KAMPYLE_DATA.getMemoryData('kampyleDevice');messageData.context=KAMPYLE_DATA.getMemoryData('context');messageData.url=encodeURIComponent(document.location.href);messageData.customCssUpload=KAMPYLE_DATA.isFeatureEnabled(KAMPYLE_CONSTANT.PROPERTY_SETTINGS.CUSTOM_CSS_UPLOAD),messageData.displayType=KAMPYLE_DATA.getDisplayType(formData);if(KAMPYLE_FUNC.checkProvision('serverBasedTargeting')){messageData.endUserIdentifier=getUserIdentifierVal();KAMPYLE_EVENT_DISPATCHER.trigger('neb_initUserIdentifierOnExtraData',{hasIdentifierValue:messageData.endUserIdentifier!==null});}
- if(KAMPYLE_FUNC.checkProvision(KAMPYLE_CONSTANT.PROVISIONS.ON_PREM_HYBRID)){messageData.onPremPackageVersion=MDIGITAL_OnPrem.getPackageVersion();}
- var pendingExtraData=KAMPYLE_DATA.flushFormExtraData(data.formId);if(pendingExtraData){for(var extra in pendingExtraData){if(pendingExtraData.hasOwnProperty(extra)){messageData[extra]=pendingExtraData[extra];}}}
- if(KAMPYLE_FUNC.checkProvision(KAMPYLE_CONSTANT.PROVISIONS.FORM_TEMPLATE_DATA_SEPERATION)){var callbackFunction=function(jsonData){messageData=Object.assign({},messageData,{formData:jsonData});if(KAMPYLE_FUNC.checkProvision(KAMPYLE_CONSTANT.PROVISIONS.LOCALIZED_FORMS)){messageData.formLanguage=MDIGITAL.LOCALIZATION.getFormLanguage(data.formId)||null;}
- targetWindow.postMessage(JSON.stringify(messageData),origin);};var onError=function(error){console.error(error);};KAMPYLE_DATA.fetchFormJsonData({formId:formData.formId,callback:callbackFunction,onError:onError},true);}else{targetWindow.postMessage(JSON.stringify(messageData),origin);}}
- KAMPYLE_EVENT_DISPATCHER.trigger('neb_formShown',{formId:data.formId,feedbackUUID:data.uuid,});}
- function handleVersion(eventName,data){data=data||{};KAMPYLE_DATA.setMemoryData('NEB_FORM_VERSION',data.formVersion||0);}
- function handleTakenScreenCapture(eventName,data){data=data||{};var iframeId='kampyleForm'+data.formId;var formData=KAMPYLE_DATA.getFormData(data.formId);if(KAMPYLE_DATA.getDisplayType(formData)==='animation'){iframeId='kampyleFormAnimation'+data.formId;}
- KAMPYLE_UTILS.sendMessageToIframe(iframeId,{action:'takenScreenCapture',data:data});}
- function isAnyInviteShown(){var allFormStates=KAMPYLE_DATA.getMemoryData('formsState')||{};for(var formId in allFormStates){if(allFormStates.hasOwnProperty(formId)){if(allFormStates[formId].inviteShown){return true;}}}
- return false;}
- function isAnyOtherFormAlreadyShown(currentFormId,shouldIgnoreSkipInvitation){var allFormStates=KAMPYLE_DATA.getMemoryData('formsState')||{};for(var formId in allFormStates){if(allFormStates.hasOwnProperty(formId)){var shouldIgnoreForm=!MDIGITAL.FORM_STATE.isFormAlreadyShown(formId)&&((currentFormId&¤tFormId==formId)||shouldIgnoreSkipInvitation&&KAMPYLE_DATA.isSkipInvitation(formId))
- if((allFormStates[formId].shown||allFormStates[formId].shouldBeShown)&&!KAMPYLE_DATA.isEmbeddedDisplayType(formId)&&!shouldIgnoreForm){return true;}}}
- return false;}
- function getSafeCustomParamVal(currParam){currParam=currParam||{};var currParamVal=currParam.value;var currParamSource=currParam.source||'var';var currParamType=currParam.type||'';var currParamName=currParam.name||currParam.source_name||'';if(currParamVal===undefined){switch(KAMPYLE_UTILS.safeToLower(currParamSource)){case'var':currParamVal=KAMPYLE_UTILS.getNestedPropertyValue(window,currParamName);break;case'url':currParamVal=KAMPYLE_UTILS.getUrlParam(currParamName);break;case'cookie':currParamVal=KAMPYLE_UTILS.getCookie(currParamName);break;default:currParamVal=null;break;}
- if(currParamVal===''){currParamVal=null;}}
- if(currParamVal!==null){switch(currParamType.toLowerCase()){case'datetime':if(typeof currParamVal==='string')
- {currParamVal=parseInt(currParamVal)||null;}
- else if(!(currParamVal instanceof Date)&&(!currParamVal.getTime||isNaN(currParamVal.getTime())))
- {currParamVal=null;}
- else{currParamVal=currParamVal.getTime();}
- break;case'number':currParamVal=KAMPYLE_UTILS.getNumericValue(currParamVal);break;case'text':if(typeof(currParamVal)!=='string')
- {currParamVal=null;}
- break;case'boolean':if(currParamVal==='true')
- {currParamVal=true;}
- else if(currParamVal==='false')
- {currParamVal=false;}
- if(typeof(currParamVal)!=='boolean')
- {currParamVal=null;}
- break;default:currParamVal=null;console.error('Invalid custom parameter type '+currParamType);break;}}
- return currParamVal;}
- function isPreloadConfigured(){var data=KAMPYLE_FUNC.kampyleGetData();return(!!data&&data.isFormsPreloaded!=='false'&&data.isFormsPreloaded!==false);}
- function addToSessionCount(){var kampyleUserSessionsCount=KAMPYLE_DATA.getData('kampyleUserSessionsCount');kampyleUserSessionsCount=Number(kampyleUserSessionsCount)||0;KAMPYLE_DATA.setData('kampyleUserSessionsCount',++kampyleUserSessionsCount);}
- function handleHashChanged(){if(KAMPYLE_DATA.isFeatureEnabled('SPA')){startCheckingTargeting();}}
- function kampyleButtonClicked(formData){formData=formData||{};KAMPYLE_EVENT_DISPATCHER.trigger('neb_buttonClicked',{formId:formData.formId,});}
- function getTimeInSession(){var sessionStartTimestamp=Number(KAMPYLE_DATA.getData('kampyleUserSession'))||Date.now();return Math.floor(KAMPYLE_UTILS.getTimeDiff(sessionStartTimestamp,KAMPYLE_CONSTANT.TIME_FORMATS.SECONDS));}
- function getTimeOnPage(){var timeOnPage=Number(KAMPYLE_DATA.getData('kampylePageLoadedTimestamp'))||Date.now();return Math.floor(KAMPYLE_UTILS.getTimeDiff(timeOnPage,KAMPYLE_CONSTANT.TIME_FORMATS.SECONDS));}
- function getLastDeclineSubmit(key){var date=Number(KAMPYLE_DATA.getData(key));return!!date?KAMPYLE_UTILS.getTimeDiff(date,KAMPYLE_CONSTANT.TIME_FORMATS.DAYS):null;}
- function prepareInviteTriggeringData(eventName,data){var deviceName=(KAMPYLE_DATA.getMemoryData('kampyleDevice')||KAMPYLE_CONSTANT.DEVICES.DESKTOP).toLowerCase();var formData=KAMPYLE_DATA.getFormData(data.formId);var inviteTriggeringData={desktop:deviceName===KAMPYLE_CONSTANT.DEVICES.DESKTOP,mobile:deviceName===KAMPYLE_CONSTANT.DEVICES.MOBILE,tablet:deviceName===KAMPYLE_CONSTANT.DEVICES.TABLET,abandon:!!KAMPYLE_DATA.getMemoryData('targetingState.abandon'),time_in_session:getTimeInSession(),time_on_page:getTimeOnPage(),excluded_urls:KAMPYLE_UTILS.getNestedPropertyValue(formData,'urlRules.exclusionUrl.rule'),included_urls:KAMPYLE_UTILS.getNestedPropertyValue(formData,'urlRules.inclusionUrl.rule'),number_of_visits:Number(KAMPYLE_DATA.getData('kampyleUserSessionsCount'))||1,last_declined:getLastDeclineSubmit('DECLINED_DATE'),last_feedback:getLastDeclineSubmit('SUBMITTED_DATE'),percentage:KAMPYLE_TARGETING.getUserPercentile(data.formId),};KAMPYLE_DATA.setMemoryData('invitationTriggeringData',inviteTriggeringData);}
- return{increasePageViewCounter:increasePageViewCounter,subscribeToCustomEvents:subscribeToCustomEvents,subscribeToPageEvents:subscribeToPageEvents,createSession:createSession,updateTargeting:updateTargeting,checkProvision:checkProvision,getAllProvisions:getAllProvisions,onSyncIdentifierDataSuccess:onSyncIdentifierDataSuccess,shouldRenderForm:shouldRenderForm,addScreenCaptureData:addScreenCaptureData,sendFormExtraData:sendFormExtraData,handleVersion:handleVersion,showPreviewForm:showPreviewForm,updatePreviewIframeStyle:updatePreviewIframeStyle,validateFormContract:validateFormContract,getTriggerTypeByEvent:getTriggerTypeByEvent,prepareInviteTriggeringData:prepareInviteTriggeringData,loadScreenCaptureApi:loadScreenCaptureApi,handleInviteLoaded:handleInviteLoaded,sendInviteInitialData:sendInviteInitialData,checkDevice:checkDevice,shouldSyncIdentifier:shouldSyncIdentifier,prepareJsonData:prepareJsonData,shouldSkipFetchingFormData:shouldSkipFetchingFormData,init:init,startCheckingTargeting:startCheckingTargeting,isAnyOtherFormAlreadyShown:isAnyOtherFormAlreadyShown,isAnyInviteShown:isAnyInviteShown,getSafeCustomParamVal:getSafeCustomParamVal,isPreloadConfigured:isPreloadConfigured,kampyleGetData:kampyleGetData,kampyleButtonClicked:kampyleButtonClicked,loadMultipileForms:loadMultipileForms,routeToForm:routeToForm,updateIdentifierDataIntegerIfNecessary:updateIdentifierDataIntegerIfNecessary,syncIdentifierData:syncIdentifierData,getUserIdentifierVal:getUserIdentifierVal,handleFormStateUpdated:handleFormStateUpdated,hasApplicationLoadingFailed:hasApplicationLoadingFailed,isJsonDataLoaded:isJsonDataLoaded,handleInviteApplicationUpdated:handleInviteApplicationUpdated,isFormLoaded:isFormLoaded,};})();window.KAMPYLE_DATA=(function(){var dataJson;var _memory;var TargetingMapping={abandon:'abandon',percentage:'kampyleInvitePercentageUsers',timeInSession:'kampyleTimeInSession',timeOnPage:'kampyleTimeOnPage',deviceTypes:'devicetypes',pageEvents:'pageElementEvent',};var init=function(){dataJson=KAMPYLE_FUNC.kampyleGetData()||{};_memory={};initFormState();};function getShownFormId(){var allFormStates=KAMPYLE_DATA.getMemoryData('formsState')||{};for(var formId in allFormStates){if(allFormStates.hasOwnProperty(formId)){if(allFormStates[formId].shouldBeShown){return formId;}}}
- return false;}
- function initFormState(){var formsState={};var allData=KAMPYLE_FUNC.kampyleGetData()||{};var allForms=allData.formNodes||[];var len=allForms.length;var curr;for(var i=0;i<len;i++){curr=allForms[i];if(curr){formsState[curr.formId]={loading:false,loaded:null,shouldBeShown:false,shown:false,inviteLoaded:null,inviteShown:false,targeting:{pageTargeting:null,behavioralTargeting:[],quarantineTargeting:[]}};}}
- setMemoryData('formsState',formsState);setMemoryData('hostingElementsHeights',{});}
- function isFeatureEnabled(featureName){var featureToPathMapping={'GTM':'isGoogleAnalyticsClientGTM','WCAG':'isWCAG','SPA':'isSpa','MANUALLY_INVITE_TARGETING':'isManuallyInviteTargeting','CUSTOM_CSS_UPLOAD':'customCssUpload'};var path=featureToPathMapping[featureName];return!!path&&!!KAMPYLE_UTILS.getNestedPropertyValue(dataJson,path);}
- function getData(dataName){try{if(KAMPYLE_DATA.getPropertySharedSubdomain()){return KAMPYLE_UTILS.kampyleGetCookie(KAMPYLE_UTILS.TOP_LEVEL_DOMAIN_COOKIE_PREFIX+dataName);}
- return localStorage[dataName]||KAMPYLE_UTILS.kampyleGetCookie(dataName);}
- catch(e){return KAMPYLE_UTILS.kampyleGetCookie(dataName);}}
- function getMemoryData(dataName){dataName=dataName||'';return KAMPYLE_UTILS.getNestedPropertyValue(_memory,dataName);}
- function setMemoryData(dataName,dataValue){KAMPYLE_UTILS.setNestedPropertyValue(_memory,dataName,dataValue);}
- function deleteMemoryData(dataName){delete(_memory||{})[dataName];}
- function setData(dataName,dataValue,expriration){if(!KAMPYLE_DATA.getPropertySharedSubdomain()){try{localStorage[dataName]=dataValue;}
- catch(e){}}
- KAMPYLE_UTILS.kampyleSetCookie(dataName,dataValue,expriration||getCookieExpiration(),KAMPYLE_DATA.getPropertySharedSubdomain());return true;}
- var deleteData=function(dataName){var propertySharedSubdomain=KAMPYLE_DATA.getPropertySharedSubdomain();if(propertySharedSubdomain){KAMPYLE_UTILS.kampyleDeleteCookie(KAMPYLE_UTILS.TOP_LEVEL_DOMAIN_COOKIE_PREFIX+dataName,propertySharedSubdomain);return;}
- try{if(localStorage[dataName]!==undefined){delete localStorage[dataName];}}
- catch(e){}
- KAMPYLE_UTILS.kampyleDeleteCookie(dataName);};function getFormData(formId){var allForms=getAllForms();var len=allForms.length,curr;for(var i=0;i<len;i++){curr=allForms[i];if(parseInt(formId)===parseInt(curr.formId)){return curr;}}
- return null;};function getMemory(){return _memory;}
- function getFormState(formId){formId=formId||'';return getMemoryData('formsState.'+formId)||null;}
- function setFormState(formId,data){data=data||{};var allFormState=getMemoryData('formsState')||{};allFormState[formId]=allFormState[formId]||{};for(var prop in data){if(typeof allFormState[formId][prop]==="object"&&allFormState[formId][prop]!==null){Object.assign(allFormState[formId][prop],data[prop]);}
- else{allFormState[formId][prop]=data[prop];}}
- setMemoryData('formsState',allFormState);}
- function getAllForms(){var allData=KAMPYLE_FUNC.kampyleGetData()||{};var allForms=allData.formNodes||[];return allForms;}
- function getInegrations(){var allData=KAMPYLE_FUNC.kampyleGetData()||{};return allData.integrations||{};}
- function getInviteData(formId){var formData=getFormData(formId);return!!formData?formData.inviteData:null;}
- function isNewMobileInvitation(){var hasProvision=KAMPYLE_FUNC.checkProvision('mobileInvitationLayout');var kampyleDevice=KAMPYLE_DATA.getMemoryData('kampyleDevice');return!!hasProvision&&kampyleDevice!=='desktop';}
- function isSkipInvitation(formId){var formData=getFormData(formId)||{};var isSkipInvitation=KAMPYLE_UTILS.getNestedPropertyValue(formData,'inviteData.skipInvitation')
- return isSkipInvitation&&isSkipInvitation!=="false";}
- function isFixedSize(formId){var formData=getFormData(formId)||{};return formData.isFixedSize===true||formData.isFixedSize==='true';}
- function isCustomHtmlAndFixedSizeForm(formId){var customHtmlForm=KAMPYLE_DATA.isCustomHtmlForm(formId);var hasProvision=KAMPYLE_FUNC.checkProvision('dynamicModalSizeInCustomHtml');return customHtmlForm&&(!hasProvision||hasProvision&&(isFixedSize(formId)));}
- function getDisplayType(formData){var kampyleDevice=KAMPYLE_DATA.getMemoryData('kampyleDevice');var displayType=KAMPYLE_UTILS.getNestedPropertyValue(formData,'formDisplay.displayType');if(kampyleDevice!==KAMPYLE_CONSTANT.DEVICES.DESKTOP){return displayType===KAMPYLE_CONSTANT.DISPLAY_TYPES.EMBEDDED?KAMPYLE_CONSTANT.DISPLAY_TYPES.EMBEDDED:KAMPYLE_CONSTANT.DISPLAY_TYPES.LIGHTBOX;}
- else{return displayType||KAMPYLE_CONSTANT.DISPLAY_TYPES.LIGHTBOX;}}
- function saveFormExtraData(formId,extraData){extraData=extraData||{};var oldExtraData=(getFormState(formId)||{}).pendingExtraData||{};extraData=Object.assign(oldExtraData,extraData);setFormState(formId,{pendingExtraData:extraData});}
- function flushFormExtraData(formId){var formState=getFormState(formId)||{};var extraData={};if(formState&&formState.pendingExtraData){extraData=formState.pendingExtraData;delete formState.pendingExtraData;}
- return extraData;}
- function isCustomHtmlForm(formId){var formData=getFormData(formId)||{};var isCustomHtml=KAMPYLE_UTILS.getUrlParam('isCustomHtml');return formData.isCustomHtmlEnabled===true||formData.isCustomHtmlEnabled==='true'||isCustomHtml===true||isCustomHtml==='true';}
- function getCookieExpiration(){return KAMPYLE_UTILS.getNestedPropertyValue(dataJson,'cookieExpirationTime')||KAMPYLE_CONSTANT.COOKIE_EXPIRATION;}
- function getTargetingData(formId,targetingName){if(!formId||!targetingName||!TargetingMapping[targetingName]){return null;}
- var selectedForm=getFormData(formId)||{};var targetingRealName=TargetingMapping[targetingName];return KAMPYLE_UTILS.getNestedPropertyValue(selectedForm,'onSiteData.'+targetingRealName);}
- function getFormVersion(formId){var formData=KAMPYLE_DATA.getFormData(formId);return Number((formData||{}).formVersion)||0;}
- function getPropertyId(){return KAMPYLE_FUNC.kampyleGetData().websiteId||null;}
- function isMobileDynamicSizing(formId){var device=KAMPYLE_DATA.getMemoryData('kampyleDevice');var requiredVersion=KAMPYLE_CONSTANT.FEATURE_VERSIONS.MOBILE_DYNAMIC_SIZING;formId=formId||KAMPYLE_DATA.getMemoryData('currentFormId');var isCustomHtml=KAMPYLE_DATA.isCustomHtmlForm(formId);var isProvisioned=((isCustomHtml&&KAMPYLE_FUNC.checkProvision('mobileWebDynamicFormSize'))||(!isCustomHtml&&KAMPYLE_FUNC.checkProvision('mobileWebDynamicFormSizeInFormBuilder')));return isProvisioned&&(device&&device!=='desktop')&&KAMPYLE_DATA.getFormVersion(formId)>=requiredVersion;}
- function isMobile(){var device=KAMPYLE_DATA.getMemoryData('kampyleDevice');return(device&&device!=='desktop');}
- function getServerBasedTargetingPrefix(){return getMemoryData('dataJson.sbtServerDomain');}
- function getServerBasedTargetingEnv(){return getMemoryData('dataJson.sbtEnvPrefix');}
- function getCustomParams(){var formNodes=getMemoryData('dataJson.formNodes')||[];if(formNodes&&formNodes[0]&&formNodes[0].customParams){return formNodes[0].customParams;}
- return null;}
- function getPropertySharedSubdomain(){var sharedSubdomain=getMemoryData('dataJson.sharedSubdomain');return sharedSubdomain&&KAMPYLE_UTILS.isHostMatchesSubdomain(window.location.host,sharedSubdomain)?sharedSubdomain:null;}
- function getUserIdentifier(){var formNodes=KAMPYLE_DATA.getMemoryData('dataJson.formNodes')||[];for(var i=0;i<formNodes.length;i++){var identifierCp=(formNodes[i].customParams||[]).find(function(cp){return cp.is_identifier.toLowerCase()==='true'})||null;if(identifierCp!==null){return identifierCp;}}
- return null;}
- function isPopupDisplayType(formId){var formData=getFormData(formId);return getDisplayType(formData)===KAMPYLE_CONSTANT.DISPLAY_TYPES.POPUP;}
- function isEmbeddedDisplayType(formId){var formData=getFormData(formId);return getDisplayType(formData)===KAMPYLE_CONSTANT.DISPLAY_TYPES.EMBEDDED;}
- function isLightBoxDisplayType(formId){var formData=getFormData(formId);return getDisplayType(formData)===KAMPYLE_CONSTANT.DISPLAY_TYPES.LIGHTBOX;}
- function localizeUrl(formId,url){var langCode=(KAMPYLE_FUNC.checkProvision(KAMPYLE_CONSTANT.PROVISIONS.LOCALIZED_FORMS)&&MDIGITAL.LOCALIZATION.getFormLanguage(formId))||KAMPYLE_CONSTANT.LOCALIZED_FORM_DEFAULT_REPLACE_VALUE;return url.replace('###LANGUAGE_CODE###',langCode);}
- function getDataJsonUrl(formId,isInviteJson){var formData=KAMPYLE_DATA.getFormData(formId);var jsonDataUrl=KAMPYLE_UTILS.getNestedPropertyValue(formData,isInviteJson?'inviteData.inviteDataUrl':'formDataUrl')
- if(!jsonDataUrl){return null;}
- return KAMPYLE_DATA.localizeUrl(formId,jsonDataUrl);}
- function fetchFormJsonData(obj,isSecondCall){var jsonDataMemoryKey=(obj.isInvite?KAMPYLE_CONSTANT.INVITE_JSON_DATA_KEY_PREFIX:KAMPYLE_CONSTANT.FORM_JSON_DATA_KEY_PREFIX)+obj.formId;var jsonData=KAMPYLE_DATA.getMemoryData(jsonDataMemoryKey);var url=KAMPYLE_DATA.getDataJsonUrl(obj.formId,obj.isInvite);if(jsonData){return typeof obj.callback==="function"&&obj.callback(jsonData);}
- if(!url){var error=new Error("Failed to get JSON data URL");return typeof obj.onError==="function"&&obj.onError(error);}
- KAMPYLE_UTILS.httpGetRequest(url,function(data){if(isSecondCall){var warnMessage='second http request have been made to the url: '+url;KAMPYLE_EVENT_DISPATCHER.trigger('MDigital_warning',{message:warnMessage});}
- if(!data){var error=new Error('Invalid form json data. Data: '+JSON.stringify(data));typeof obj.onError==="function"&&obj.onError(error);}else{KAMPYLE_DATA.setMemoryData(jsonDataMemoryKey,data);typeof obj.callback==="function"&&obj.callback(data);}},function(error){typeof obj.onError==="function"&&obj.onError(error);});}
- function getFormTriggerType(formId){var formType=KAMPYLE_UTILS.getNestedPropertyValue(KAMPYLE_DATA.getFormData(formId),'formType');return KAMPYLE_CONSTANT.FORM_TRIGGER_TYPES_MAP[formType]?formType:null;}
- return{init:init,isFeatureEnabled:isFeatureEnabled,getData:getData,setData:setData,deleteData:deleteData,getAllForms:getAllForms,getInegrations:getInegrations,getFormData:getFormData,getMemoryData:getMemoryData,getTargetingData:getTargetingData,setMemoryData:setMemoryData,getShownFormId:getShownFormId,getFormState:getFormState,setFormState:setFormState,getInviteData:getInviteData,getDisplayType:getDisplayType,saveFormExtraData:saveFormExtraData,flushFormExtraData:flushFormExtraData,isCustomHtmlForm:isCustomHtmlForm,getCookieExpiration:getCookieExpiration,isNewMobileInvitation:isNewMobileInvitation,isCustomHtmlAndFixedSizeForm:isCustomHtmlAndFixedSizeForm,deleteMemoryData:deleteMemoryData,getFormVersion:getFormVersion,isMobileDynamicSizing:isMobileDynamicSizing,getCustomParams:getCustomParams,getPropertySharedSubdomain:getPropertySharedSubdomain,getUserIdentifier:getUserIdentifier,getServerBasedTargetingPrefix:getServerBasedTargetingPrefix,getServerBasedTargetingEnv:getServerBasedTargetingEnv,isPopupDisplayType:isPopupDisplayType,isEmbeddedDisplayType:isEmbeddedDisplayType,isLightBoxDisplayType:isLightBoxDisplayType,fetchFormJsonData:fetchFormJsonData,getFormTriggerType:getFormTriggerType,getPropertyId:getPropertyId,isMobile:isMobile,isSkipInvitation:isSkipInvitation,localizeUrl:localizeUrl,getMemory:getMemory,initFormState:initFormState,getDataJsonUrl:getDataJsonUrl};})();window.KAMPYLE_TARGETING=(function(window,document){var QUARANTINE_DEFAULT_TEXTS={DECLINED_DATE:'The user did not decline',SUBMITTED_DATE:'The user did not submit'};function init(){var eventMapping={neb_targetingInit:[initTargeting],MDigital_manuallyInviteTargeting:[handleFormsTargeting],neb_initButton:[handleButton],};KAMPYLE_EVENT_DISPATCHER.subscribeMany(eventMapping);KAMPYLE_DATA.setMemoryData('targetingState',{});}
- function isDataValid(days,cookieName){var checkingDate=Number(KAMPYLE_DATA.getData(cookieName));days=Number(days);if(!checkingDate||!days){return false;}
- var msInOneDay=1000*60*60*24;return(checkingDate+(msInOneDay*days))>Date.now();}
- function handleButton(eventName,data){data=data||{};var formData=KAMPYLE_DATA.getFormData(data.formId);if(!formData){return false;}
- var kampyleDevice=KAMPYLE_DATA.getMemoryData('kampyleDevice');if(kampyleDevice===KAMPYLE_CONSTANT.DEVICES.MOBILE||kampyleDevice===KAMPYLE_CONSTANT.DEVICES.TABLET){if(KAMPYLE_FUNC.isPreloadConfigured()){KAMPYLE_EVENT_DISPATCHER.trigger(KAMPYLE_CONSTANT.EVENTS.NEB_LOAD_FORM,{formId:data.formId});}}
- KAMPYLE_DATA.setFormState(data.formId,{loaded:null});KAMPYLE_DATA.setMemoryData('buttonFormId',data.formId);KAMPYLE_EVENT_DISPATCHER.trigger('neb_showButton',{formId:data.formId});KAMPYLE_DATA.setMemoryData('isButtonShown',true);return true;}
- function getTextByQuarentine(quarentineKey){if(KAMPYLE_DATA.getData(quarentineKey)){return new Date(parseInt(KAMPYLE_DATA.getData(quarentineKey)));}
- else{return QUARANTINE_DEFAULT_TEXTS[quarentineKey];}}
- function isShowInvite(formData){var currentFormId=KAMPYLE_DATA.getMemoryData('currentInviteFormId');formData=formData||KAMPYLE_DATA.getFormData(currentFormId);if(!formData||KAMPYLE_DATA.getMemoryData('isInvitationShouldBeIgnored')){return false;}
- var targetingState=KAMPYLE_DATA.getMemoryData('targetingState');for(var index in targetingState){if(targetingState[index]!==true){return false;}}
- var shouldDisableIntercept=false;KAMPYLE_EVENT_DISPATCHER.trigger(KAMPYLE_CONSTANT.EVENTS.MDIGITAL_BEHAVIORAL_TARGETING_PHASE_ENDED,formData);if(shouldDisableIntercept){return false;}
- var isQuarantinePassed=isQuarantinePhasePassed(formData);KAMPYLE_EVENT_DISPATCHER.trigger(KAMPYLE_CONSTANT.EVENTS.MDIGITAL_QUARANTINED_SURVEY_PHASE_ENDED,formData);if(!isQuarantinePassed){return false;}
- KAMPYLE_DATA.setData('kampyleInvitePresented',true);var isSkipInvitation=KAMPYLE_UTILS.getNestedPropertyValue(formData,'inviteData.skipInvitation');KAMPYLE_UTILS.isTruthy(isSkipInvitation)?handleSkippedInvitaion(formData):KAMPYLE_TARGETING.handleNotSkippedInvitaion(formData);return true;}
- function isQuarantinePhasePassed(formData){var isDeclined=false;var isSubmitted=false;var isFormIsShown=KAMPYLE_DATA.getMemoryData('formIsShown')===true;var isInviteAlreadyShown=KAMPYLE_TARGETING.isInviteAlreadyShownInSession(formData);isDeclined=isAlreadyDeclined(formData);isSubmitted=isAlreadySubmitted(formData);return(!isDeclined&&!isSubmitted&&!isFormIsShown&&!isInviteAlreadyShown)}
- function isUbtFailed(formData){var isUbtCheckFailed=KAMPYLE_FUNC.checkProvision(KAMPYLE_CONSTANT.PROVISIONS.SERVER_BASED_TARGETING)&&KAMPYLE_FUNC.checkProvision(KAMPYLE_CONSTANT.PROVISIONS.DO_NOT_SURVEY_ON_UBT_NETWORK_FAIL)&&!KAMPYLE_DATA.getMemoryData('isGuest')&&!KAMPYLE_DATA.getMemoryData('isSyncedIdentifierData');if(isUbtCheckFailed){KAMPYLE_EVENT_DISPATCHER.trigger('MDigital_targetingRuleEvaluated',{formId:formData.formId,targetingRule:'ubtFailed',formTriggerType:KAMPYLE_DATA.getFormTriggerType(formData.formId),targetingPhase:KAMPYLE_CONSTANT.TARGETING_PHASES.PAGE_TARGETING,isPassed:!isUbtCheckFailed,expected:'should ignore quarantine rules evaluation',actual:isUbtCheckFailed,});}
- return isUbtCheckFailed;}
- function isInviteAlreadyShownInSession(formData){var isInviteAlreadyShownInSession=KAMPYLE_TARGETING.isInviteShownInSession(formData.onSiteData.kampyleInvitePerSession)===true;var configuredMoreThanOncePerSession=KAMPYLE_UTILS.getNestedPropertyValue(formData,'onSiteData.kampyleInvitePerSession.inviteOncePerSession');configuredMoreThanOncePerSession=configuredMoreThanOncePerSession===true||configuredMoreThanOncePerSession==='true';KAMPYLE_EVENT_DISPATCHER.trigger('MDigital_targetingRuleEvaluated',{formId:formData.formId,targetingRule:'InvitePerSession',formTriggerType:KAMPYLE_DATA.getFormTriggerType(formData.formId),targetingPhase:KAMPYLE_CONSTANT.TARGETING_PHASES.QUARANTINE_TARGETING,isPassed:!isInviteAlreadyShownInSession,expected:"Display Invite more than once per session",actual:configuredMoreThanOncePerSession||!isInviteAlreadyShownInSession,});return isInviteAlreadyShownInSession;}
- function handleSkippedInvitaion(formData){if(!KAMPYLE_FUNC.isPreloadConfigured()){KAMPYLE_EVENT_DISPATCHER.trigger(KAMPYLE_CONSTANT.EVENTS.NEB_LOAD_FORM,{formId:formData.formId});}
- KAMPYLE_EVENT_DISPATCHER.trigger('neb_skipInvitation',{formId:formData.formId});}
- function isAlreadySubmitted(formData){var isAlreadySubmitted=isSubmitted(formData.onSiteData)===true;var submittedDays=KAMPYLE_UTILS.getNestedPropertyValue(formData,'onSiteData.submitted.days');var submittedDateText=KAMPYLE_TARGETING.getTextByQuarentine("SUBMITTED_DATE");submittedDays&&KAMPYLE_EVENT_DISPATCHER.trigger('MDigital_targetingRuleEvaluated',{formId:formData.formId,targetingRule:'DontInviteOnSubmitted',formTriggerType:KAMPYLE_DATA.getFormTriggerType(formData.formId),targetingPhase:KAMPYLE_CONSTANT.TARGETING_PHASES.QUARANTINE_TARGETING,isPassed:!isAlreadySubmitted,expected:submittedDays+" days",actual:"Current: "+Date()+" Submitted: "+submittedDateText,});return isAlreadySubmitted;}
- function isAlreadyDeclined(formData){var isAlreadyDeclined=isDeclined(formData.onSiteData)===true;var declinedDateText=KAMPYLE_TARGETING.getTextByQuarentine("DECLINED_DATE");var declinedDays=KAMPYLE_UTILS.getNestedPropertyValue(formData,'onSiteData.declined.days');declinedDays&&KAMPYLE_EVENT_DISPATCHER.trigger('MDigital_targetingRuleEvaluated',{formId:formData.formId,targetingRule:'DontInviteOnDeclined',formTriggerType:KAMPYLE_DATA.getFormTriggerType(formData.formId),targetingPhase:KAMPYLE_CONSTANT.TARGETING_PHASES.QUARANTINE_TARGETING,isPassed:!isAlreadyDeclined,expected:declinedDays+" days",actual:"Current: "+Date()+" Declined: "+declinedDateText,});return isAlreadyDeclined;}
- function handleNotSkippedInvitaion(formData){if(KAMPYLE_DATA.getDisplayType(formData)===KAMPYLE_CONSTANT.DISPLAY_TYPES.POPUP){KAMPYLE_DATA.setFormState(formData.formId,{inviteShown:true});KAMPYLE_EVENT_DISPATCHER.trigger('neb_showInvitation',{formId:formData.formId});}else{KAMPYLE_DATA.setMemoryData(KAMPYLE_TARGETING.generateShouldShowInviteParamName(formData.formId),true);KAMPYLE_EVENT_DISPATCHER.trigger(KAMPYLE_CONSTANT.EVENTS.NEB_LOAD_FORM,{formId:formData.formId});}}
- function initTargetingObject(){var targetingState=KAMPYLE_DATA.getMemoryData('targetingState');targetingState.kampyleTimeInSession=false;if(KAMPYLE_DATA.getMemoryData('kampyleDevice')==='desktop'){targetingState.abandon=false;}
- targetingState.kampyleTimeOnPage=false;KAMPYLE_DATA.setMemoryData('targetingState',targetingState);}
- function validateCommonTargetingOnForm(form){var canShow=true;var isUrlExcludedResult;if(canShow===true){isUrlExcludedResult=isUrlExcluded(form);KAMPYLE_UTILS.getNestedPropertyValue(form,'urlRules.exclusionUrl.rule')&&KAMPYLE_EVENT_DISPATCHER.trigger('MDigital_targetingRuleEvaluated',{formId:form.formId,targetingRule:'UrlExclude',formTriggerType:KAMPYLE_DATA.getFormTriggerType(form.formId),targetingPhase:KAMPYLE_CONSTANT.TARGETING_PHASES.PAGE_TARGETING,isPassed:!isUrlExcludedResult,expected:KAMPYLE_UTILS.getNestedPropertyValue(form,'urlRules.exclusionUrl.rule'),actual:location.href,});if(isUrlExcludedResult===true){canShow=false;}}
- if(canShow===true){var isIncluded=isUrlIncluded(form);(KAMPYLE_UTILS.getNestedPropertyValue(form,'urlRules.inclusionUrl.rule')&&KAMPYLE_EVENT_DISPATCHER.trigger('MDigital_targetingRuleEvaluated',{formId:form.formId,formTriggerType:KAMPYLE_DATA.getFormTriggerType(form.formId),targetingRule:'UrlInclude',targetingPhase:KAMPYLE_CONSTANT.TARGETING_PHASES.PAGE_TARGETING,isPassed:isIncluded,expected:KAMPYLE_UTILS.getNestedPropertyValue(form,'urlRules.inclusionUrl.rule'),actual:location.href,}));if(isIncluded===false){canShow=false;}}
- if(canShow===true){var isGenericRuleValidResult=isGenericRuleValid(form);(KAMPYLE_UTILS.getNestedPropertyValue(form,'onSiteData.genericRule')&&KAMPYLE_EVENT_DISPATCHER.trigger('MDigital_targetingRuleEvaluated',{formId:form.formId,targetingRule:'GenericRule',formTriggerType:KAMPYLE_DATA.getFormTriggerType(form.formId),targetingPhase:KAMPYLE_CONSTANT.TARGETING_PHASES.PAGE_TARGETING,isPassed:isGenericRuleValidResult,expected:"Generic rule evaluation result should be true",actual:isGenericRuleValidResult,}));canShow=isGenericRuleValidResult;}
- function isGenericRuleValid(data){if(data&&data.onSiteData&&data.onSiteData.genericRule){if(typeof data.onSiteData.genericRule==='string'){data.onSiteData.genericRule=JSON.parse(data.onSiteData.genericRule);}
- return KAMPYLE_TARGETING.evaluateRule(data.onSiteData.genericRule,data);}
- return true;}
- if(canShow===true){canShow=targetingDevice(form);(KAMPYLE_UTILS.getNestedPropertyValue(form,'onSiteData.devicetypes')&&KAMPYLE_EVENT_DISPATCHER.trigger('MDigital_targetingRuleEvaluated',{formId:form.formId,targetingRule:'DeviceTypes',formTriggerType:KAMPYLE_DATA.getFormTriggerType(form.formId),targetingPhase:KAMPYLE_CONSTANT.TARGETING_PHASES.PAGE_TARGETING,isPassed:canShow,expected:KAMPYLE_UTILS.getNestedPropertyValue(form,'onSiteData.devicetypes').toString(),actual:KAMPYLE_DATA.getMemoryData('kampyleDevice'),}));}
- return canShow;}
- function isUrlMatch(urlToMatch){if(!(typeof urlToMatch==='string')){return false;}
- urlToMatch=urlToMatch.toLowerCase();var currentUrl=document.location.href.toLowerCase();var matchUrl=currentUrl.substring(0,urlToMatch.length);if(matchUrl===urlToMatch){return true;}
- else{currentUrl=currentUrl.replace(/^(?:https?:\/\/)?(?:www\.)?([^\/]+)/i,'');matchUrl=currentUrl.substring(0,urlToMatch.length);if(matchUrl===urlToMatch){return true;}}
- return false;}
- function isUrlLimits(urlsData){urlsData=urlsData.split(';');var length=urlsData.length;for(var i=0;i<length;i++){var res=isUrlMatch(urlsData[i]);if(res===true){return true;}}
- return false;}
- function isUrlExcluded(data){if(!!data.urlRules&&!!data.urlRules.exclusionUrl){if(!!data.urlRules.exclusionUrl.rule){var isExcluded=isUrlLimits(data.urlRules.exclusionUrl.rule);return isExcluded;}}
- return false;}
- function isUrlIncluded(data){if(!!data.urlRules&&!!data.urlRules.inclusionUrl){if(!!data.urlRules.inclusionUrl.rule){var isIncluded=isUrlLimits(data.urlRules.inclusionUrl.rule);return isIncluded;}}
- return true;}
- function checkAllowedOperator(paramType,operator){var paramTypeToOperator={'text':[KAMPYLE_CONSTANT.OPERATORS.EQUALS,KAMPYLE_CONSTANT.OPERATORS.DOES_NOT_EQUAL,KAMPYLE_CONSTANT.OPERATORS.CONTAINS,KAMPYLE_CONSTANT.OPERATORS.DOES_NOT_CONTAIN,KAMPYLE_CONSTANT.OPERATORS.STARTS_WITH,KAMPYLE_CONSTANT.OPERATORS.ENDS_WITH,KAMPYLE_CONSTANT.OPERATORS.HAS_VALUE,KAMPYLE_CONSTANT.OPERATORS.REGEX],'boolean':[KAMPYLE_CONSTANT.OPERATORS.EQUALS,KAMPYLE_CONSTANT.OPERATORS.HAS_VALUE],'datetime':[KAMPYLE_CONSTANT.OPERATORS.EQUALS,KAMPYLE_CONSTANT.OPERATORS.DOES_NOT_EQUAL,KAMPYLE_CONSTANT.OPERATORS.LATER_THAN,KAMPYLE_CONSTANT.OPERATORS.EARLIER_THAN,KAMPYLE_CONSTANT.OPERATORS.HAS_VALUE],'number':[KAMPYLE_CONSTANT.OPERATORS.EQUALS,KAMPYLE_CONSTANT.OPERATORS.DOES_NOT_EQUAL,KAMPYLE_CONSTANT.OPERATORS.GREATER_THAN,KAMPYLE_CONSTANT.OPERATORS.SMALLER_THAN,KAMPYLE_CONSTANT.OPERATORS.HAS_VALUE]};paramType=KAMPYLE_UTILS.safeToLower(paramType);operator=KAMPYLE_UTILS.safeToLower(operator);if(!paramType||!operator||!paramTypeToOperator[paramType]||paramTypeToOperator[paramType].indexOf(operator)===-1){return false;}
- else{return true;}
- return true;}
- function evaluateCriteria(criteria,formData){var evaluation=false;var paramValue;var secondParamValue;var isAllowedOperator;if(!criteria){return false;}
- var allowedTypes=['customParam'];var condition=KAMPYLE_UTILS.safeToLower(criteria.condition);if(!criteria||criteria.value===undefined||criteria.value===null||allowedTypes.indexOf(criteria.fieldOrigin)===-1){evaluation=false;}
- else{switch(criteria.fieldOrigin){case'customParam':var customParamObj=MDIGITAL.CUSTOM_PARAMETERS.getCustomParamById(criteria.fieldId,formData);if(customParamObj&&customParamObj.source_name){paramValue=MDIGITAL.CUSTOM_PARAMETERS.getCustomParamValue({type:customParamObj.type,name:customParamObj.source_name,source:customParamObj.source});secondParamValue=MDIGITAL.CUSTOM_PARAMETERS.getCustomParamValue({type:customParamObj.type,name:customParamObj.source_name,source:customParamObj.source,value:criteria.value});isAllowedOperator=checkAllowedOperator(customParamObj.type,criteria.condition);}
- if(paramValue!==undefined&&isAllowedOperator){evaluation=KAMPYLE_UTILS.kampyleCompareByOperator(paramValue,secondParamValue,condition,customParamObj.type);}
- break;default:break;}}
- return evaluation;}
- function evaluateRule(toEvaluate,formData){var tmpEval;var finalEval=false;var stopFlag=false;if(toEvaluate&&toEvaluate.type==='criteriaGroup'&&toEvaluate.childrenCriterias&&toEvaluate.childrenCriterias.length&&toEvaluate.conjunction){for(var i=0;i<toEvaluate.childrenCriterias.length&&!stopFlag;i++){tmpEval=KAMPYLE_TARGETING.evaluateRule(toEvaluate.childrenCriterias[i],formData);if(tmpEval&&toEvaluate.conjunction==='OR')
- {finalEval=true;stopFlag=true;}
- else if(!tmpEval&&toEvaluate.conjunction==='AND')
- {finalEval=false;stopFlag=true;}
- else{finalEval=tmpEval;}}}
- else if(toEvaluate&&toEvaluate.type==='criteria'){finalEval=evaluateCriteria(toEvaluate,formData);}
- return finalEval;}
- function targetingDevice(data){if(data&&data.onSiteData&&data.onSiteData.devicetypes){var devicetypesLength=data.onSiteData.devicetypes.length;for(var i=0;i<devicetypesLength;i++){if(data.onSiteData.devicetypes[i]===KAMPYLE_DATA.getMemoryData('kampyleDevice')){return true;}}
- return false;}
- return true;}
- function checkPagesInSession(sessionPageObj){sessionPageObj=sessionPageObj||{};var pageCount=Number(KAMPYLE_DATA.getData('kampyleSessionPageCounter')||0);return KAMPYLE_UTILS.kampyleCompareByOperator(pageCount,parseInt(sessionPageObj.numberOfRepeats),sessionPageObj.compareString);}
- function timeInSession(time,formData){validateGap(time,formData);}
- function getTimeInSession(){var kampyleUserSession=KAMPYLE_DATA.getData('kampyleUserSession');var kampyleUserSessionTimestamp=parseInt(kampyleUserSession);var diff=KAMPYLE_UTILS.getTimeDiff(kampyleUserSessionTimestamp);return diff;}
- function validateGap(time,formData){var requiredTimeInSession=parseInt(time)*1000;var timeInSession=getTimeInSession();var targetingState=KAMPYLE_DATA.getMemoryData('targetingState');if(targetingState&&timeInSession>=requiredTimeInSession){targetingState.kampyleTimeInSession=true;KAMPYLE_DATA.setMemoryData('targetingState',targetingState);KAMPYLE_EVENT_DISPATCHER.trigger('MDigital_targetingRuleEvaluated',{formId:formData.formId,targetingRule:'TimeInSession',formTriggerType:KAMPYLE_DATA.getFormTriggerType(formData.formId),targetingPhase:KAMPYLE_CONSTANT.TARGETING_PHASES.BEHAVIORAL_TARGETING,isPassed:true,expected:requiredTimeInSession,actual:"Over on the expected "+requiredTimeInSession,});isShowInvite();}
- else{var randomTime=0;var diff=requiredTimeInSession-timeInSession;var thisObj=this;setTimeout(function(){validateGap(time,formData);},diff+randomTime);}}
- function isDeclined(data){data=data||{};if(data.declined!==null&&data.declined!==undefined){var isStillDeclined=isDataValid(data.declined.days,'DECLINED_DATE');return isStillDeclined;}
- return false;}
- function isInviteShownInSession(oncePerSessionObj){var inviteShownFlag=KAMPYLE_DATA.getData('kampyleInvitePresented');var inviteShownFlag=(inviteShownFlag===true||inviteShownFlag==='true');oncePerSessionObj=oncePerSessionObj||{};var configuredOncePerSession=(oncePerSessionObj.inviteOncePerSession===true||oncePerSessionObj.inviteOncePerSession==='true');if(configuredOncePerSession===true){return false;}
- return!!inviteShownFlag;}
- function isSubmitted(data){if(KAMPYLE_UTILS.getNestedPropertyValue(data,'submitted')){var isStillSubmitted=isDataValid(data.submitted.days,'SUBMITTED_DATE');return isStillSubmitted;}
- return false;}
- function checkAbandon(formData){KAMPYLE_DATA.setMemoryData('targetingState.abandon',true);KAMPYLE_EVENT_DISPATCHER.trigger('MDigital_targetingRuleEvaluated',{formId:formData.formId,targetingRule:'UserAbandonment',formTriggerType:KAMPYLE_DATA.getFormTriggerType(formData.formId),isPassed:true,targetingPhase:KAMPYLE_CONSTANT.TARGETING_PHASES.BEHAVIORAL_TARGETING,expected:"Mouse over user abandonment",actual:"Mouse was over user abandonment",});if(isShowInvite()===false){KAMPYLE_DATA.setMemoryData('targetingState.abandon',false);}}
- function abandon(abandonObj,formData){var zIndexDef="0",heightDef="5";if(!abandonObj){abandonObj={height:heightDef,zIndex:zIndexDef};}
- var zIndex=(!!abandonObj.zIndex)?abandonObj.zIndex:zIndexDef;var height=(!!abandonObj.height&&abandonObj.height!=="0")?abandonObj.height+'px':heightDef+'px';var abandon=document.getElementById('kampyle_abandon_zone');if(abandon===null){var abandon=document.createElement('div');abandon.id='kampyle_abandon_zone';abandon.style.width='100%';abandon.style.height=height;abandon.style.zIndex=zIndex;abandon.style.position='fixed';abandon.style.top='0px';abandon.onmouseover=function(){checkAbandon(formData);};document.body.appendChild(abandon);}
- else{abandon.style.height=height;abandon.style.zIndex=zIndex;}}
- function sendTimeOnPageEventData(formData){var timeOnPage=KAMPYLE_UTILS.getNestedPropertyValue(formData,'onSiteData.kampyleTimeOnPage.time');timeOnPage&&KAMPYLE_EVENT_DISPATCHER.trigger('MDigital_targetingRuleEvaluated',{formId:formData.formId,targetingRule:'TimeOnPage',formTriggerType:KAMPYLE_DATA.getFormTriggerType(formData.formId),isPassed:true,targetingPhase:KAMPYLE_CONSTANT.TARGETING_PHASES.BEHAVIORAL_TARGETING,expected:timeOnPage,actual:"Over on the expecetd "+timeOnPage,});}
- function timeOnPage(time,formData){if(time===null){KAMPYLE_DATA.setMemoryData('targetingState.kampyleTimeOnPage',true);return;}
- var thisObj=this;var timeOnPageTimeOut=setTimeout(function(){KAMPYLE_DATA.setMemoryData('targetingState.kampyleTimeOnPage',true);sendTimeOnPageEventData(formData);isShowInvite();},time*1000);KAMPYLE_DATA.setData('kampylePageLoadedTimestamp',Date.now());}
- function getUserPercentile(formId){var percentile=KAMPYLE_DATA.getData('kampyleUserPercentile');if(!percentile&&percentile!=='0')
- {percentile=Math.random()*100;KAMPYLE_DATA.setData('kampyleUserPercentile',percentile);}
- if(Number(percentile)&&Number(percentile).toFixed){return Number(percentile).toFixed(1);}
- else{return Number(percentile);}}
- function invitePercentageUsers(precUsersObj){var userPercentile=getUserPercentile();if(!!precUsersObj&&!!userPercentile){var prec=Number(precUsersObj.prec);if(userPercentile>prec){return false;}}
- return true;}
- function initDynamicTargeting(formData){KAMPYLE_DATA.setMemoryData('isInviteActivated',true);var targetingState=KAMPYLE_DATA.getMemoryData('targetingState');if(formData.onSiteData.kampyleTimeInSession!==undefined){timeInSession(formData.onSiteData.kampyleTimeInSession.time,formData);}
- else{targetingState.kampyleTimeInSession=true;}
- if(!!formData.onSiteData.abandon){if(KAMPYLE_DATA.getMemoryData('kampyleDevice')==='desktop'){abandon(formData.onSiteData.abandon,formData);}}
- else{targetingState.abandon=true;}
- if(formData.onSiteData.kampyleTimeOnPage!==undefined){timeOnPage(formData.onSiteData.kampyleTimeOnPage.time,formData);}
- else{targetingState.kampyleTimeOnPage=true;}
- KAMPYLE_DATA.setMemoryData('targetingState',targetingState);for(var key in targetingState){if(targetingState.hasOwnProperty(key)&&!targetingState[key]){return false;}}
- isShowInvite(formData);}
- function initTargeting(eventName,data){initTargetingMemoryData();initTargetingObject();initEmbeddedTargeting();handleFormsTargeting(eventName,data);}
- function initTargetingMemoryData(){KAMPYLE_DATA.setMemoryData('invitationTimeStamp',null);KAMPYLE_DATA.setMemoryData('formIsShown',false);KAMPYLE_DATA.setMemoryData('isButtonShown',false);KAMPYLE_DATA.setMemoryData('isInviteActivated',false);KAMPYLE_DATA.setMemoryData('targetingState',{});}
- function initEmbeddedTargeting(){var allForms=KAMPYLE_DATA.getAllForms();if(!allForms||!allForms.length){return;}
- var canShow;for(var i=allForms.length-1;i>=0;i--){if(allForms[i].formType===KAMPYLE_CONSTANT.FORM_TYPES.EMBEDDED){canShow=KAMPYLE_TARGETING.validateCommonTargetingOnForm(allForms[i]);if(canShow){KAMPYLE_EVENT_DISPATCHER.trigger(KAMPYLE_CONSTANT.EVENTS.NEB_LOAD_FORM,{formId:allForms[i].formId});}}}}
- function initUserIdentifier(){var userIdentifierVal=null;if(!!KAMPYLE_FUNC.checkProvision(KAMPYLE_CONSTANT.PROVISIONS.SERVER_BASED_TARGETING)){userIdentifierVal=KAMPYLE_FUNC.getUserIdentifierVal();var hasIdentifierValue=userIdentifierVal!==null;KAMPYLE_DATA.setMemoryData('isGuest',!hasIdentifierValue);KAMPYLE_EVENT_DISPATCHER.trigger('neb_initUserIdentifier',{hasIdentifierValue:hasIdentifierValue});}
- return userIdentifierVal;}
- function handleFormsTargeting(eventName,data){var userIdentifierVal=initUserIdentifier();if(KAMPYLE_FUNC.shouldSyncIdentifier(userIdentifierVal)){KAMPYLE_EVENT_DISPATCHER.trigger('MDigital_settingIdentifierValueOnMemory',{hasIdentifierValue:userIdentifierVal!==null});KAMPYLE_DATA.setMemoryData('identifierValue',userIdentifierVal);KAMPYLE_FUNC.syncIdentifierData(userIdentifierVal,initFormsTargeting.bind(this,arguments[0],arguments[1]));}else{KAMPYLE_EVENT_DISPATCHER.trigger('MDigital_shouldNotSyncIdentifier');initFormsTargeting(eventName,data);}}
- function initFormsTargeting(eventName,data){data=data||{};var allForms=KAMPYLE_DATA.getAllForms();if(!allForms||!allForms.length){return;}
- var canShow;for(var i=allForms.length-1;i>=0;i--){if(allForms[i].formType===KAMPYLE_CONSTANT.FORM_TYPES.BUTTON&&!data.skipButtonTargeting&&KAMPYLE_DATA.getMemoryData('isButtonShown')===false){canShow=KAMPYLE_TARGETING.validateCommonTargetingOnForm(allForms[i]);if(canShow===true){KAMPYLE_EVENT_DISPATCHER.trigger('neb_initButton',{formId:allForms[i].formId});}}
- else if(KAMPYLE_TARGETING.shouldCheckInvite(allForms[i],data)){canShow=KAMPYLE_TARGETING.validateCommonTargetingOnForm(allForms[i])&&KAMPYLE_TARGETING.validateInviteTargeting(allForms[i].formId);if(canShow===true){KAMPYLE_TARGETING.initDynamicTargeting(allForms[i]);}}
- if(KAMPYLE_DATA.getMemoryData('isInviteActivated')===true&&KAMPYLE_DATA.getMemoryData('isButtonShown')===true){break;}}
- KAMPYLE_EVENT_DISPATCHER.trigger(KAMPYLE_CONSTANT.EVENTS.MDIGITAL_PAGE_TARGETING_PHASE_ENDED);}
- function shouldCheckInvite(form,targetingSettings){return(form.formType===KAMPYLE_CONSTANT.FORM_TYPES.INVITATION&&KAMPYLE_UTILS.kampyleIsCookieEnabled()&&!targetingSettings.skipInviteTargeting&&KAMPYLE_DATA.getMemoryData('isInviteActivated')===false&&!KAMPYLE_TARGETING.isUbtFailed(form))}
- function validateInviteTargeting(formId){formId=formId||'';KAMPYLE_DATA.setMemoryData('currentInviteFormId',formId);var data=KAMPYLE_DATA.getFormData(formId);if(KAMPYLE_UTILS.getNestedPropertyValue(data,'onSiteData.kampyleInvitePercentageUsers.prec')){var invitePercentageUsersResult=invitePercentageUsers(data.onSiteData.kampyleInvitePercentageUsers);KAMPYLE_EVENT_DISPATCHER.trigger('MDigital_targetingRuleEvaluated',{formId:data.formId,targetingRule:'UsersPercentage',formTriggerType:KAMPYLE_DATA.getFormTriggerType(data.formId),targetingPhase:KAMPYLE_CONSTANT.TARGETING_PHASES.PAGE_TARGETING,isPassed:invitePercentageUsersResult,expected:KAMPYLE_UTILS.getNestedPropertyValue(data,'onSiteData.kampyleInvitePercentageUsers.prec'),actual:getUserPercentile(),});if(invitePercentageUsersResult===false){return false;}}
- var numberOfPagesResult=!!data.onSiteData.numberOfPagesViewed&&checkPagesInSession(data.onSiteData.numberOfPagesViewed)===false;(KAMPYLE_UTILS.getNestedPropertyValue(data,'onSiteData.numberOfPagesViewed.numberOfRepeats')&&KAMPYLE_EVENT_DISPATCHER.trigger('MDigital_targetingRuleEvaluated',{formId:data.formId,targetingRule:'NumberOfPagesViewed',targetingPhase:KAMPYLE_CONSTANT.TARGETING_PHASES.PAGE_TARGETING,isPassed:!numberOfPagesResult,expected:KAMPYLE_UTILS.getNestedPropertyValue(data,'onSiteData.numberOfPagesViewed.numberOfRepeats'),actual:KAMPYLE_DATA.getData('kampyleSessionPageCounter'),}));if(numberOfPagesResult){return false;}
- if(data.inviteData.skipInvitation===true||data.inviteData.skipInvitation==='true'){if(KAMPYLE_FUNC.isPreloadConfigured()){KAMPYLE_EVENT_DISPATCHER.trigger(KAMPYLE_CONSTANT.EVENTS.NEB_LOAD_FORM,{formId:formId});}}
- else{KAMPYLE_EVENT_DISPATCHER.trigger('neb_loadInvitation',{formId:formId});}
- return true;}
- function setTargetingState(targetingName,isPassed){KAMPYLE_DATA.setMemoryData('targetingState.'+targetingName,isPassed);}
- function generateShouldShowInviteParamName(formId){if(!formId){return null;}
- return'shouldShowInvite'+'_'+formId;}
- return{init:init,isInviteAlreadyShownInSession:isInviteAlreadyShownInSession,initTargeting:initTargeting,initFormsTargeting:initFormsTargeting,validateCommonTargetingOnForm:validateCommonTargetingOnForm,isShowInvite:isShowInvite,handleButton:handleButton,isDataValid:isDataValid,generateShouldShowInviteParamName:generateShouldShowInviteParamName,handleNotSkippedInvitaion:handleNotSkippedInvitaion,initDynamicTargeting:initDynamicTargeting,validateInviteTargeting:validateInviteTargeting,isUbtFailed:isUbtFailed,evaluateRule:evaluateRule,checkPagesInSession:checkPagesInSession,targetingDevice:targetingDevice,getUserPercentile:getUserPercentile,invitePercentageUsers:invitePercentageUsers,validateGap:validateGap,setTargetingState:setTargetingState,isInviteShownInSession:isInviteShownInSession,getTextByQuarentine:getTextByQuarentine,shouldCheckInvite:shouldCheckInvite};})(window,document);window.KAMPYLE_ANIMATION=(function(){var DEFAULTS={ANIMATION_DIRECTION:'centerRight',};var CONSTANTS={CONTAINER_ID:'KampyleAnimationContainer',IFRAME_ID:'kampyleFormAnimation',};function init(){var eventMapping={neb_buttonClicked:[animateWithInit],neb_sdkShowForm:[animateWithInit],neb_loadForm:[createFormIframe,initAnimationPosition],neb_inviteAccepted:[animateWithInit],neb_skipInvitation:[animateWithInit],neb_formClosed:[animateOut,refreshFormIframe],neb_popupBlocked:[animateOut,refreshFormIframe],neb_captureInit:[animateOut],neb_captureImageClicked:[animateIn],neb_cancelCaptureClicked:[animateIn],neb_formHide:[animateOut],neb_formLoadingHasFailed:[hideAnimationContainer],neb_skipShowingForm:[hideFormAnimationContainer]};KAMPYLE_EVENT_DISPATCHER.subscribeMany(eventMapping);var formSpanPlacer=document.createElement('span');var divAnimationContainer=document.createElement('div');KAMPYLE_UTILS.addAttributesOnElement(divAnimationContainer,{id:CONSTANTS.CONTAINER_ID});divAnimationContainer.style.zIndex='2147483000';formSpanPlacer.appendChild(divAnimationContainer);document.body.appendChild(formSpanPlacer);var animationContainer=document.getElementById(CONSTANTS.CONTAINER_ID);if(animationContainer){KAMPYLE_UTILS.setElementStyle(animationContainer,{border:0,position:'fixed',display:'block',zIndex:'2147483000',});}
- hideAnimationContainer();}
- function animateWithInit(eventName,data){initAnimationPosition(eventName,data);setTimeout(function(){animateIn(eventName,data);},10);}
- function shouldIgnoreRenderAnimationForm(formData,animationContainer,formId){return!formData||!animationContainer||!isAnimationForm(formData)||KAMPYLE_FUNC.hasApplicationLoadingFailed(formId,false)}
- function animateIn(eventName,data){data=data||{};var formData=KAMPYLE_DATA.getFormData(data.formId);var animationContainer=document.getElementById(CONSTANTS.CONTAINER_ID);if(shouldIgnoreRenderAnimationForm(formData,animationContainer,data.formId)){return false;}
- KAMPYLE_DATA.setMemoryData('isInvitationShouldBeIgnored',true);var formIframe=document.getElementById(CONSTANTS.IFRAME_ID+data.formId);if(formIframe){formIframe.style.display='block';}
- var displayDirection=getDisplayDirection(formData);switch(displayDirection){case'centerRight':KAMPYLE_UTILS.setElementStyle(animationContainer,{right:0,});break;case'centerLeft':KAMPYLE_UTILS.setElementStyle(animationContainer,{left:0,});break;case'bottomRight':case'bottomLeft':KAMPYLE_UTILS.setElementStyle(animationContainer,{bottom:0,});break;default:KAMPYLE_UTILS.showWarning('Invalid animation type - '+displayDirection);return false;}}
- function hideAnimationContainer(){var animationContainer=document.getElementById(CONSTANTS.CONTAINER_ID);if(animationContainer){KAMPYLE_UTILS.setElementStyle(animationContainer,{width:0,height:0,});}}
- function refreshFormIframe(eventName,data){setTimeout(function(){var formData=KAMPYLE_DATA.getFormData(data.formId);var currIframe=document.getElementById(CONSTANTS.IFRAME_ID+data.formId);if(!!currIframe){if(KAMPYLE_FUNC.checkProvision("disableFormReloadOnClose")){currIframe.remove();KAMPYLE_DATA.initFormState();}else{currIframe.src=currIframe.src;currIframe.style.display='none';if(currIframe.removeAttribute){currIframe.removeAttribute('origin');}}}
- hideAnimationContainer();},1000);}
- function animateOut(eventName,data){var formData=KAMPYLE_DATA.getFormData(data.formId);if(KAMPYLE_DATA.getDisplayType(formData)!=='animation'){return false;}
- data=data||{};var animationContainer=document.getElementById(CONSTANTS.CONTAINER_ID);if(!formData||!animationContainer||!isAnimationForm(formData)){return false;}
- setAnimationContainerInitialPosition(formData,animationContainer);}
- function getMiddleHeight(formHeight){return String((window.innerHeight-parseInt(formHeight,10))/2)+'px';}
- function getDisplayDirection(formData){formData=formData||{};return KAMPYLE_UTILS.getNestedPropertyValue(formData,'formDisplay.displayDirection')||DEFAULTS.ANIMATION_DIRECTION;}
- function setAnimationContainerInitialPosition(formData,animationContainer){var cornerMargin;switch(getDisplayDirection(formData)){case'centerRight':KAMPYLE_UTILS.setElementStyle(animationContainer,{top:getMiddleHeight(animationContainer.style.height),right:'-'+formData.formWidth+'px',bottom:null,left:null,transition:'right 1s ease-in-out',});break;case'centerLeft':KAMPYLE_UTILS.setElementStyle(animationContainer,{top:getMiddleHeight(animationContainer.style.height),right:null,bottom:null,left:'-'+formData.formWidth+'px',transition:'left 1s ease-in-out',});break;case'bottomRight':cornerMargin=KAMPYLE_VIEW.getCornerMargin(formData)+'px';KAMPYLE_UTILS.setElementStyle(animationContainer,{top:null,right:cornerMargin,bottom:'-'+formData.formHeight+'px',left:null,transition:'bottom 1s ease-in-out',});break;case'bottomLeft':cornerMargin=KAMPYLE_VIEW.getCornerMargin(formData)+'px';KAMPYLE_UTILS.setElementStyle(animationContainer,{top:null,right:null,bottom:'-'+formData.formHeight+'px',left:cornerMargin,transition:'bottom 1s ease-in-out',});break;default:KAMPYLE_UTILS.showWarning('Invalid animation type - '+formData.formDisplayDirection);return false;}}
- function isAnimationForm(formData){return KAMPYLE_DATA.getDisplayType(formData)==='animation';}
- function hideFormAnimationContainer(eventName,data){var formData=KAMPYLE_DATA.getFormData(data.formId);if(isAnimationForm(formData)){var formIframe=document.getElementById(CONSTANTS.IFRAME_ID+data.formId);if(formIframe){KAMPYLE_UTILS.setElementStyle(formIframe,{display:'none',});}}}
- function createFormIframe(eventName,data){data=data||{};var formData=KAMPYLE_DATA.getFormData(data.formId);var animationContainer=document.getElementById(CONSTANTS.CONTAINER_ID);if(!animationContainer||!formData||!isAnimationForm(formData)){return false;}
- var formIframe=document.getElementById(CONSTANTS.IFRAME_ID+data.formId);if(!formIframe){formIframe=document.createElement('iframe');KAMPYLE_UTILS.setElementStyle(formIframe,{border:0,height:formData.formHeight+'px',width:formData.formWidth+'px',display:'none',});formIframe.id=CONSTANTS.IFRAME_ID+data.formId;animationContainer.appendChild(formIframe);}
- var formHtml=formData.formHtmlUrl;formHtml=KAMPYLE_COMMON.createFormUrl(formHtml,data.formId);formIframe.src=formHtml;}
- function initAnimationPosition(eventName,data){data=data||{};var formData=KAMPYLE_DATA.getFormData(data.formId);var isSkipInvitation=KAMPYLE_DATA.isSkipInvitation(data.formId);var animationContainer=document.getElementById(CONSTANTS.CONTAINER_ID);if(!animationContainer||!formData||!isAnimationForm(formData)||(isSkipInvitation&&KAMPYLE_FUNC.isAnyOtherFormAlreadyShown(data.formId))){return false;}
- if(!document.getElementById(CONSTANTS.IFRAME_ID+data.formId)){createFormIframe(eventName,data);}
- KAMPYLE_UTILS.setElementStyle(animationContainer,{height:formData.formHeight+'px',width:formData.formWidth+'px',});setAnimationContainerInitialPosition(formData,animationContainer);}
- return{initAnimationPosition:initAnimationPosition,getDisplayDirection:getDisplayDirection,init:init,hideAnimationContainer:hideAnimationContainer,hideFormAnimationContainer:hideFormAnimationContainer,};})();window.KAMPYLE_VIEW=(function(window,document){var DEFAULTS={CORNER_MARGIN:0,TRIANGULAR_MARGIN:0,VERTICAL_MARGIN:30,};var BUTTON_FUNCTION_ENUM={vertical:'getVerticalButton',triangular:'getTriangularButton',custom:'getCustomButton',}
- function handleInviteReady(eventName,data){data=data||{};if(KAMPYLE_FUNC.hasApplicationLoadingFailed(data.formId,true)){return;}
- var inviteContainer=document.getElementById('kampyleInviteContainer');if(newMobileInvite()){restoreHostingDOM();if(inviteContainer){KAMPYLE_UTILS.setElementStyle(inviteContainer,{top:'',bottom:'',left:'',right:'',background:'none',visibility:'',display:'none',},true);}}
- else{KAMPYLE_UTILS.setElementStyle(inviteContainer,{visibility:'visible',},true);var iframe=document.getElementById('kampyleInvite');if(iframe){KAMPYLE_UTILS.setElementStyle(iframe,{visibility:'visible',},true);}}}
- function onKeyboardClose(e){KAMPYLE_UTILS.showInvite();KAMPYLE_UTILS.removeEventHandler(e.srcElement,'blur',onKeyboardClose);}
- function onKeyboardOpen(e){KAMPYLE_UTILS.hideInvite();KAMPYLE_UTILS.setEventHandler(e.srcElement,'blur',onKeyboardClose);}
- function getAllFocusableElements(){var inputs=document.querySelectorAll('input');var textarea=document.querySelectorAll('textarea');var allFocusableElements=[];var i;for(i=0;i<inputs.length;i++){allFocusableElements.push(inputs[i]);}
- for(i=0;i<textarea.length;i++){allFocusableElements.push(textarea[i]);}
- return allFocusableElements;}
- function setupListenersForHideInviteWhenVirtualKeyboardIsOpen(eventName,data){data=data||{};data.formId=data.formId||KAMPYLE_DATA.getMemoryData('currentFormId');var pos=KAMPYLE_VIEW.getInvitePosition(data.formId);if(newMobileInvite()&&pos==='bottom'){var allFocusableElements=getAllFocusableElements();for(var i=0;i<allFocusableElements.length;i++){KAMPYLE_UTILS.setEventHandler(allFocusableElements[i],'focus',onKeyboardOpen);}}}
- function removeListenersForHideInviteWhenVirtualKeyboardIsOpen(eventName,data){data=data||{};data.formId=data.formId||KAMPYLE_DATA.getMemoryData('currentFormId');var pos=KAMPYLE_VIEW.getInvitePosition(data.formId);if(newMobileInvite()&&pos==='bottom'){var allFocusableElements=getAllFocusableElements();for(var i=0;i<allFocusableElements.length;i++){KAMPYLE_UTILS.removeEventHandler(allFocusableElements[i],'focus',onKeyboardOpen);}}}
- function showInviteIfNeeded(eventName,params){var shouldShowParamName=KAMPYLE_TARGETING.generateShouldShowInviteParamName(params.formId);var shouldShowInvite=KAMPYLE_DATA.getMemoryData(shouldShowParamName);if(shouldShowInvite){KAMPYLE_EVENT_DISPATCHER.trigger('neb_invitation_loaded',{formId:params.formId});KAMPYLE_EVENT_DISPATCHER.trigger('neb_showInvitation',{formId:params.formId});KAMPYLE_DATA.deleteMemoryData(shouldShowParamName);}}
- function scrollToEmbeddedForm(formId){document.getElementById(KAMPYLE_CONSTANT.EMBEDDED.IFRAME_ID_PREFIX+formId).scrollIntoView();}
- function doScrollY(numOfPixels){window.scrollTo(0,numOfPixels);}
- function scrollToTop(eventName,data){data=data||{};if(!KAMPYLE_DATA.isEmbeddedDisplayType(data.formId)){doScrollY(0);}}
- function scrollFromTop(eventName,data){var pixelsToScroll=(data||{}).numberOfPixels||0;if(KAMPYLE_DATA.isEmbeddedDisplayType(data.formId)){scrollToEmbeddedForm(data.formId);var scrollY=(KAMPYLE_UTILS.getScrollPosition()||{}).y||0;KAMPYLE_VIEW.doScrollY(pixelsToScroll+scrollY);}
- else{KAMPYLE_VIEW.doScrollY(pixelsToScroll);}}
- function handleInvitationSkippedForms(eventName,data){if(KAMPYLE_DATA.getData('isSkipInvitationOptimized')!=='true'){return;}
- KAMPYLE_UTILS.setElementStyle(document.getElementById('kampyleFormContainer'),{visibility:'visible',},true);KAMPYLE_VIEW.prepareHostingDOM();KAMPYLE_DATA.setData('isSkipInvitationOptimized',false);}
- function init(){var eventMapping={neb_targetingInit:[removeAllShownElements],neb_loadInvitation:[createInviteIframe],neb_loadForm:[createIframe,showSpinner,applyMobileDynamicStyles],neb_formReady:[hideButton],neb_formLoaded:[setIframeOrigin,hideSpinner,showInviteIfNeeded],neb_formShown:[handleInvitationSkippedForms],neb_inviteHeightChanged:[changeInviteHeight],neb_iFrameHeightChanged:[reactToIframeHeightChange],neb_scrollToTop:[scrollToTop],neb_scrollFromTop:[scrollFromTop],neb_inviteReady:[handleInviteReady,setupListenersForHideInviteWhenVirtualKeyboardIsOpen],neb_scrollToForm:[scrollToForm],neb_showButton:[showButton,alignButtonWithForm],neb_buttonClicked:[handleButtonClicked],neb_sdkShowForm:[hideButton],neb_captureInit:[hideVisibility,hideButton],neb_inviteAccepted:[hideInvite,hideButton,removeListenersForHideInviteWhenVirtualKeyboardIsOpen],neb_showForm:[showForm],neb_sdkPageView:[hideInvite,removeListenersForHideInviteWhenVirtualKeyboardIsOpen],neb_inviteDeclined:[hideInvite,removeListenersForHideInviteWhenVirtualKeyboardIsOpen],neb_formClosed:[hideForm],neb_popupBlocked:[hideForm],neb_formHide:[hideVisibility],neb_captureImageClicked:[showVisibility],neb_cancelCaptureClicked:[showVisibility],neb_formLoadingHasFailed:[showFormCouldNotFechtedErrorMsg],};eventMapping.neb_showButton.push(setVerticalOffset);KAMPYLE_EVENT_DISPATCHER.subscribeMany(eventMapping);if(!KAMPYLE_FUNC.checkProvision(KAMPYLE_CONSTANT.PROVISIONS.CSP_RULES)){KAMPYLE_UTILS.addStyle('.noOutline{outline: none !important;}');KAMPYLE_UTILS.addStyle('.wcagOutline:focus{outline: 1px dashed #595959 !important;outline-offset: 2px !important;transition: none !important;}');}
- KAMPYLE_UTILS.setEventHandler(window,'resize',function(e){updateIframeStyle();});}
- function toggleSpinner(isShow){var display=isShow?'block':'none';var spinners=document.getElementsByClassName('neb-loading-spinner');if(spinners&&spinners.length){for(var i=spinners.length-1;i>=0;i--){KAMPYLE_UTILS.setElementStyle(spinners[i],{display:display});}}}
- function hideSpinner(eventName,data){toggleSpinner(false);}
- function showSpinner(eventName,data){toggleSpinner(true);}
- function scrollToForm(eventName,data){document.getElementById('kampyleFormContainer').scrollIntoView();}
- function getCornerMargin(formData){formData=formData||{};var isInvite=KAMPYLE_UTILS.getNestedPropertyValue(formData,'formType')==='invitation';var margin;if(!isInvite){var buttonType=KAMPYLE_UTILS.getNestedPropertyValue(formData,'buttonData.type');switch(buttonType){case'vertical':case'triangular':margin=DEFAULTS.TRIANGULAR_MARGIN;break;case'custom':margin=KAMPYLE_UTILS.getNestedPropertyValue(formData,'buttonData.cornerMargin')||DEFAULTS.CORNER_MARGIN;break;default:margin=DEFAULTS.CORNER_MARGIN;break;}}
- else{margin=DEFAULTS.CORNER_MARGIN;}
- return parseInt(margin,10);}
- function getButtonDirection(formData){formData=formData||{};return KAMPYLE_UTILS.getNestedPropertyValue(formData,'buttonData.position')||'right';}
- function alignButtonWithForm(eventName,data){data=data||{};var formData=KAMPYLE_DATA.getFormData(data.formId);var buttonContainer=document.getElementById('nebula_div_btn');if(!buttonContainer||!formData){return false;}
- var cornerMargin=getCornerMargin(formData)+'px';switch(getButtonDirection(formData)){case'bottomRight':buttonContainer.style.right=cornerMargin;break;case'bottomLeft':buttonContainer.style.left=cornerMargin;break;default:break;}}
- function setVerticalOffset(eventName,data){var formData=KAMPYLE_DATA.getFormData(data.formId);var buttonData=KAMPYLE_UTILS.getNestedPropertyValue(formData,'buttonData');var offset=KAMPYLE_UTILS.getNestedPropertyValue(buttonData,'verticalOffset')||0;if(!isNaN(offset)){var nebButton=document.getElementById('nebula_div_btn');if(nebButton&&nebButton.style){if(buttonData.position.indexOf('bottom')>-1){nebButton.style.marginBottom=offset+'px';}else{offset=Number(offset)*-1;nebButton.style.marginTop=offset+'px';}}}}
- function showVisibility(eventName,data){var currentFormId=KAMPYLE_DATA.getMemoryData('currentFormId');var formData=KAMPYLE_DATA.getFormData(currentFormId);if(KAMPYLE_DATA.getDisplayType(formData)==='animation'){return false;}
- var formContainer=document.getElementById('kampyleFormContainer');var formIframe=document.getElementById('kampyleForm'+currentFormId);if(!!formContainer&&!!formIframe)
- {KAMPYLE_UTILS.setElementStyle(formContainer,{display:'block',visibility:'visible',},true);}}
- function getWCAGClass(){return KAMPYLE_DATA.isFeatureEnabled('WCAG')?' wcagOutline ':' noOutline ';}
- function hideVisibility(){var currentFormId=KAMPYLE_DATA.getMemoryData('currentFormId');if(!currentFormId){return;}
- var formContainer=document.getElementById('kampyleFormContainer');var formIframe=document.getElementById('kampyleForm'+currentFormId);var noDataContainer=document.getElementById("mdigital-no-json-modal_"+currentFormId);if(!!formContainer&&(!!formIframe||!!noDataContainer))
- {KAMPYLE_UTILS.setElementStyle(formContainer,{display:'none',visibility:'hidden',},true);}}
- function hideForm(eventName,data){data=data||{};var currentFormId=KAMPYLE_DATA.getMemoryData('currentFormId');setMetaViewport('remove');if(document.getElementById('kampyleFormContainer')!==null){var currIframe=document.getElementById('kampyleForm'+currentFormId);if(!!currIframe){if(!KAMPYLE_FUNC.checkProvision("disableFormReloadOnClose")){currIframe.src=currIframe.src;KAMPYLE_EVENT_DISPATCHER.trigger('neb_load_form_form_reload',{formId:data.formId});}else{KAMPYLE_DATA.initFormState();var kampyleFormContainer=document.getElementById('kampyleFormContainer');if(kampyleFormContainer){kampyleFormContainer.remove();}}
- KAMPYLE_UTILS.setElementStyle(currIframe,{display:'none',},true);if(currIframe.removeAttribute){currIframe.removeAttribute('origin');}}
- hideVisibility();restoreHostingDOM();}
- if(!KAMPYLE_FUNC.checkProvision("disableFormReloadOnClose")||KAMPYLE_DATA.isPopupDisplayType(currentFormId)){if(data.sourceWindow&&data.sourceWindow.close){data.sourceWindow.close();}}}
- function formatTriangularStyle(data){data=data||{};var triangularStyle=['button#nebula_div_btn { height: auto !important }','.kampyle_feedback-button{','background-color:transparent !important;font-family:"Open Sans",sans-serif;cursor:pointer;position:fixed;z-index:99999990','}','.kampyle_feedback-button .kampyle_triangle{position:absolute;width:0;height:0;z-index:-1}','.kampyle_feedback-button .kampyle_button-text{ ','height:81px;width:81px;text-align:center;z-index:1000;color:{{BUTTON_TEXT_COLOR}};font-size:14px;font-weight:normal !important;','}','.kampyle_feedback-button .kampyle_bottom{','line-height:108px !important;','}','.kampyle_feedback-button .kampyle_top {','line-height:53px !important;','}','.kampyle_feedback-button.kampyle_top-right{ ','top:0;right:0','}','.kampyle_feedback-button.kampyle_top-right .kampyle_triangle {','top:0;right:0;border-top:81px solid {{BUTTON_BACKGROUND_COLOR}};border-left:81px solid transparent ','}','.kampyle_feedback-button.kampyle_top-right .kampyle_button-text { ','-ms-transform:rotate(45deg); -webkit-transform:rotate(45deg); transform:rotate(45deg)','}','.kampyle_feedback-button.kampyle_top-left {','top:0;left:0;','}','.kampyle_feedback-button.kampyle_top-left .kampyle_triangle {','top:0;left:0;border-top:81px solid {{BUTTON_BACKGROUND_COLOR}};border-right:81px solid transparent;','}','.kampyle_feedback-button.kampyle_top-left .kampyle_button-text {','-ms-transform:rotate(-45deg);-webkit-transform:rotate(-45deg);transform:rotate(-45deg)','}','.kampyle_feedback-button.kampyle_bottom-right {','bottom:0;right:0;','}','.kampyle_feedback-button.kampyle_bottom-right .kampyle_triangle {','bottom:0;right:0;border-bottom:81px solid {{BUTTON_BACKGROUND_COLOR}};border-left:81px solid transparent','}','.kampyle_feedback-button.kampyle_bottom-right .kampyle_button-text {','-ms-transform:rotate(-45deg);-webkit-transform:rotate(-45deg);transform:rotate(-45deg);','}','.kampyle_feedback-button.kampyle_bottom-left {','bottom:0;left:0;','}','.kampyle_feedback-button.kampyle_bottom-left .kampyle_triangle {','bottom:0;left:0;border-bottom:81px solid {{BUTTON_BACKGROUND_COLOR}};border-right:81px solid transparent','}','.kampyle_feedback-button.kampyle_bottom-left .kampyle_button-text {','-ms-transform:rotate(45deg);-webkit-transform:rotate(45deg);transform:rotate(45deg);','}','.kampyle_feedback-button.kampyle_bottom-left, .kampyle_feedback-button.kampyle_bottom-right, .kampyle_feedback-button.kampyle_top-left, .kampyle_feedback-button.kampyle_top-right {','padding: 0 !important;','}',].join(' ');triangularStyle=triangularStyle.replace(/{{BUTTON_TEXT_COLOR}}/g,data.textColor);triangularStyle=triangularStyle.replace(/{{BUTTON_BACKGROUND_COLOR}}/g,data.backgroundColor);return triangularStyle;}
- function formatVerticalStyle(data){data=data||{};var verticalStyle=['button#nebula_div_btn { height: auto !important }','.kampyle_vertical_button {','background-color:transparent !important;font-family:"Open Sans",sans-serif;cursor:pointer;position:fixed;top:45%;z-index:99999990;height:35px !important;min-height: 35px !important;max-height: 35px !important;width:125px !important;max-width: 125px !important;min-width: 125px !important;-ms-transform:rotate(90deg);-webkit-transform:rotate(90deg);transform:rotate(90deg)','}','.kampyle_vertical_button .kampyle_button {','height:35px;min-height: 35px !important;max-height: 35px !important;width:125px !important;min-width: 125px !important;max-width: 125px !important; background:{{BUTTON_BACKGROUND_COLOR}};color:{{BUTTON_TEXT_COLOR}};position:absolute;top:0;left:0;z-index:-1;','}','.kampyle_vertical_button .kampyle_button-text {','color:{{BUTTON_TEXT_COLOR}};font-size:14px;line-height:35px;text-align:center;font-weight:normal !important;','}','.kampyle_vertical_button.kampyle_left .kampyle_button {','-webkit-border-radius:3px 3px 0 0;-moz-border-radius:3px 3px 0 0;-ms-border-radius:3px 3px 0 0;border-radius:3px 3px 0 0;','}','.kampyle_vertical_button.kampyle_right {','right:-45px;','}','.kampyle_vertical_button.kampyle_left {','left:-45px','}','.kampyle_vertical_button.kampyle_right .kampyle_button {','-webkit-border-radius:0 0 3px 3px;-moz-border-radius:0 0 3px 3px;-ms-border-radius:0 0 3px 3px;border-radius:0 0 3px 3px','}','.kampyle_vertical_button.kampyle_right, .kampyle_vertical_button.kampyle_left {','padding: 0 !important;','}',].join(' ');verticalStyle=verticalStyle.replace(/{{BUTTON_TEXT_COLOR}}/g,data.textColor);verticalStyle=verticalStyle.replace(/{{BUTTON_BACKGROUND_COLOR}}/g,data.backgroundColor);return verticalStyle;}
- function getTriangleButtonStyle(formData){var buttonText=KAMPYLE_VIEW.getButtonText(formData);var classDirection=getClassDirectonByPosition(formData.buttonData.position);return'<button id="nebula_div_btn" style="border: none; background: none" alt="'+buttonText+'" tabindex="0" class="kampyle_feedback-button '+classDirection.leftright+' '+getWCAGClass()+'"><div class="kampyle_triangle"></div><div data-aut="feedback" class="kampyle_button-text '+classDirection.topbottom+'">'+buttonText+'</div></button>';}
- function getVerticalButtonStyle(formData){var direction='kampyle_left';var buttonText=KAMPYLE_VIEW.getButtonText(formData);switch(formData.buttonData.position){case'left':direction='kampyle_left';break;case'right':direction='kampyle_right';break;}
- return'<button id="nebula_div_btn" style="position: fixed !important; border: none" alt="'+buttonText+'" tabindex="0" class="kampyle_vertical_button '+direction+' '+getWCAGClass()+'"><div class="kampyle_button"></div><div data-aut="feedback" class="kampyle_button-text">'+buttonText+'</div></button>';}
- function displayGenericFormBtn(formData){var btnBuilders=({vertical:{html:getVerticalButtonStyle,style:formatVerticalStyle},triangular:{html:getTriangleButtonStyle,style:formatTriangularStyle}})[formData.buttonData.type];if(!btnBuilders){KAMPYLE_UTILS.showWarning('Invalid button type '+formData.buttonData.type);return'';}
- KAMPYLE_UTILS.addStyle(btnBuilders.style({textColor:formData.buttonData.textColor,backgroundColor:formData.buttonData.backgroundColor,}));return btnBuilders.html(formData);}
- function displayImageFormBtn(formData){var divStyle='z-index: 99999990 !important;position: fixed !important;cursor: pointer !important;line-height:1px !important; padding:0;';var buttonText=KAMPYLE_VIEW.getButtonText(formData);var imageBtnStyles=['.nebula_image_button {','width: auto !important;','background: transparent !important;','}',].join(' ');KAMPYLE_UTILS.addStyle(imageBtnStyles);switch(formData.buttonData.position){case'bottomLeft':divStyle+='bottom:0;left:0;';break;case'bottomRight':divStyle+='bottom:0;right:0;';break;case'topLeft':divStyle+='top:0;left:0;';break;case'topRight':divStyle+='top:0;right:0;';break;case'left':divStyle+='left:0;top:50%;';break;case'right':divStyle+='right:0;top:50%;';break;default:break;}
- return'<button id="nebula_div_btn" class="nebula_image_button '+getWCAGClass()+'" style="'+divStyle+';border: none" tabindex="0"><img alt="'+buttonText+'" src="'+formData.buttonData.buttonUrl+'" /></button>';}
- function showIframeContainers(formId){setMetaViewport('add');var kampyleFormContainer=document.getElementById('kampyleFormContainer');if(kampyleFormContainer){var currIframe=document.getElementById('kampyleForm'+formId);if(!!currIframe){KAMPYLE_UTILS.setElementStyle(currIframe,{display:'block',},true);}
- KAMPYLE_UTILS.setElementStyle(kampyleFormContainer,{display:'block',visibility:'visible',},true);}}
- function onErrModalClose(formId){var NO_JSON_MODAL_ID="mdigital-no-json-modal_"+formId;hideForm({formId:formId});document.getElementById(NO_JSON_MODAL_ID).style.display="none";KAMPYLE_DATA.setFormState(formId,{shown:false});showButton("",{formId:KAMPYLE_DATA.getMemoryData('buttonFormId')});KAMPYLE_UTILS.triggerCustomEvent('MD_errorModalClosed',{});}
- function getErrorFetchedModal(formId){var errorModalWidth=KAMPYLE_DATA.isMobile()?'98%':"450px";var NO_JSON_MODAL_ID="mdigital-no-json-modal_"+formId;if(!KAMPYLE_FUNC.checkProvision(KAMPYLE_CONSTANT.PROVISIONS.CSP_RULES)){var errModal=document.createElement('div');errModal.innerHTML='<div id="'+NO_JSON_MODAL_ID+'" style="position:relative; text-align:center; background:rgba(255,255,255, 1); margin:auto; border: 1px solid #cccccc; box-shadow:8px 10px 58px 2px rgba(64, 64, 74, 0.56); color:rgb(64, 64, 74); margin-bottom:2%; height:500px; margin-top:5%; width:'+errorModalWidth+' ; ">'+
- KAMPYLE_CONSTANT.SVGS.NO_DATA_MODAL_IMG+
- KAMPYLE_CONSTANT.SVGS.CLOSE_NO_DATA_MODAL_BTN+'<span style="font-size:24px; font-weight:bold; margin:auto; display:block; font-family:helvetica, Bold; margin-top:38px">Oops...</span>'+'<span style="padding: 0 44px 0 44px; font-size:17px; margin:auto; display:block; font-family:helvetica; margin-top:10px">We can’t collect your feedback at the moment. </span>'+'<span style="padding: 0 44px 0 44px; font-size:17px; margin:auto; display:block; font-family:helvetica; margin-top:5px">Refresh your page and try again</span>'+'<div>';return errModal;}}
- function handleButtonClicked(eventName,data){var formData=KAMPYLE_DATA.getFormData(data.formId);var displayType=KAMPYLE_DATA.getDisplayType(formData);displayType=displayType.toLowerCase();if(displayType==='lightbox'){var kampyleFormContainer=document.getElementById('kampyleFormContainer');if(!kampyleFormContainer||KAMPYLE_FUNC.hasApplicationLoadingFailed(data.formId,false)||KAMPYLE_FUNC.isAnyOtherFormAlreadyShown(data.formId,true)){return false;}
- KAMPYLE_UTILS.setElementStyle(kampyleFormContainer,{display:'block',visibility:'visible',},true);}}
- function getClassDirectonByPosition(position){var classDirection={topbottom:'kampyle_bottom',leftright:'kampyle_bottom-left'};switch(position){case'bottomLeft':classDirection.leftright='kampyle_bottom-left';classDirection.topbottom='kampyle_bottom';break;case'bottomRight':classDirection.leftright='kampyle_bottom-right';classDirection.topbottom='kampyle_bottom';break;case'topLeft':classDirection.leftright='kampyle_top-left';classDirection.topbottom='kampyle_top';break;case'topRight':classDirection.leftright='kampyle_top-right';classDirection.topbottom='kampyle_top';break;default:break;}
- return classDirection;}
- function shouldShowErrMsgOnForm(formId){var formTriggerType=KAMPYLE_DATA.getFormTriggerType(formId);return MDIGITAL.FORM_STATE.shouldFormBeShown(formId)&&(formTriggerType===KAMPYLE_CONSTANT.FORM_TYPES.BUTTON||formTriggerType===KAMPYLE_CONSTANT.FORM_TYPES.CODE);}
- function showFormCouldNotFechtedErrorMsg(eventName,data){if(KAMPYLE_FUNC.isAnyOtherFormAlreadyShown(data.formId)||!KAMPYLE_VIEW.shouldShowErrMsgOnForm(data.formId)){return;}
- var NO_JSON_MODAL_ID="mdigital-no-json-modal_"+data.formId;var kampyleFormModal=document.getElementById('kampyleFormModal');hideSpinner();showIframeContainers(data.formId);if(document.getElementById(NO_JSON_MODAL_ID)){document.getElementById(NO_JSON_MODAL_ID).style.display="block";}
- else{var fetchedDataErrrModal=getErrorFetchedModal(data.formId);if(!kampyleFormModal){createFormContainer();kampyleFormModal=document.getElementById('kampyleFormModal');showIframeContainers(data.formId);}
- kampyleFormModal.innerHTML="";kampyleFormModal.appendChild(fetchedDataErrrModal);var closeBtnElem=document.querySelector("#"+NO_JSON_MODAL_ID+" #close-no-json-modal");closeBtnElem.onclick=onErrModalClose.bind(null,data.formId);}
- KAMPYLE_DATA.setFormState(data.formId,{shown:true});hideButton("",{formId:KAMPYLE_DATA.getMemoryData('buttonFormId')});}
- function showButton(eventName,data){var btnHtml='';data=data||{};var formData=KAMPYLE_DATA.getFormData(data.formId)||{};var buttonType=KAMPYLE_UTILS.getNestedPropertyValue(formData,'buttonData.type')||'';if(!KAMPYLE_FUNC.checkProvision(KAMPYLE_CONSTANT.PROVISIONS.CSP_RULES)){switch(buttonType.toLowerCase()){case'vertical':case'triangular':btnHtml=displayGenericFormBtn(formData);break;case'custom':btnHtml=displayImageFormBtn(formData);break;default:KAMPYLE_UTILS.showWarning('Invalid button type - '+buttonType);return false;}
- var spanContainer=document.getElementById('kampyleButtonContainer');if(spanContainer===null){spanContainer=document.createElement('span');spanContainer.innerHTML=btnHtml;spanContainer.id='kampyleButtonContainer';document.body.appendChild(spanContainer);}
- else{spanContainer.innerHTML=btnHtml;}}
- KAMPYLE_EVENT_DISPATCHER.trigger('neb_button_displayed',{formId:data.formId,position:KAMPYLE_UTILS.getNestedPropertyValue(formData,'buttonData.position')||'',});spanContainer.onclick=function(event){if(!KAMPYLE_FUNC.isAnyOtherFormAlreadyShown(data.formId,true)){KAMPYLE_EVENT_DISPATCHER.trigger('neb_buttonClicked',{formId:data.formId});event.preventDefault();event.stopPropagation();}};var isDesktop=KAMPYLE_DATA.getMemoryData('kampyleDevice')===KAMPYLE_CONSTANT.DEVICES.DESKTOP;if(isDesktop){KAMPYLE_UTILS.setEventHandler(spanContainer,'mouseover',function(event){if(!KAMPYLE_DATA.getFormState(data.formId).loaded){KAMPYLE_EVENT_DISPATCHER.trigger('neb_loadForm',{formId:data.formId});}});var buttonProximityFunc=function(event){var formState=KAMPYLE_DATA.getFormState(data.formId);if(!formState||formState.loading||formState.loaded){return false;}
- var isNear=KAMPYLE_UTILS.isNear('nebula_div_btn',100,event);if(isNear){KAMPYLE_EVENT_DISPATCHER.trigger('neb_load_form_preload_proximity',{formId:data.formId});KAMPYLE_EVENT_DISPATCHER.trigger('neb_loadForm',{formId:data.formId});}};KAMPYLE_UTILS.setEventHandler(window,'mousemove',buttonProximityFunc);}
- else{KAMPYLE_EVENT_DISPATCHER.trigger('neb_loadForm',{formId:data.formId});}
- spanContainer.onkeyup=function(event){switch(event.keyCode){case 9:KAMPYLE_EVENT_DISPATCHER.trigger('neb_loadForm',{formId:data.formId});break;default:break;}};spanContainer.onkeypress=function(event){switch(event.keyCode){case 13:if(!KAMPYLE_FUNC.isAnyOtherFormAlreadyShown(data.formId,true)){KAMPYLE_EVENT_DISPATCHER.trigger('neb_buttonClicked',{formId:data.formId});}
- break;default:break;}};}
- function setIframeOrigin(eventName,data){var formIframe=document.getElementById('kampyleForm'+data.formId);if(formIframe&&formIframe.setAttribute){formIframe.setAttribute('origin',data.origin);}}
- function updateIframeStyle(formData){var currentFormId=KAMPYLE_DATA.getMemoryData('currentFormId')||KAMPYLE_DATA.getShownFormId();if(document.getElementById('kampyleFormContainer')===null||!currentFormId){return;}
- formData=formData||KAMPYLE_DATA.getFormData(currentFormId)||{};if(KAMPYLE_DATA.isMobileDynamicSizing(formData.formId)){return updateDynamicIframeStyle(formData);}else{updateStaticIframeStyle(formData);}}
- function updateStaticIframeStyle(formData){var currentFormId=(formData||{}).formId||KAMPYLE_DATA.getMemoryData('currentFormId')||KAMPYLE_DATA.getShownFormId();var formWidth;var formHeight;if(formData){formWidth=parseInt(formData.formWidth,10)||450;formHeight=parseInt(formData.formHeight,10)||450;}
- var hostHeight=document.documentElement.clientHeight;var innerContainerStyle={overflowY:'auto',height:'100%',};KAMPYLE_UTILS.setElementStyle(document.getElementById('innerContainer'),innerContainerStyle);var iframeStyleObject={border:0,position:'relative',margin:'50px auto 50px',height:formHeight+'px',width:formWidth+'px',};var kampyleDevice=KAMPYLE_DATA.getMemoryData('kampyleDevice');if(kampyleDevice===KAMPYLE_CONSTANT.DEVICES.MOBILE||kampyleDevice===KAMPYLE_CONSTANT.DEVICES.TABLET){formHeight='100%';formWidth='100%';iframeStyleObject={position:'relative',margin:'0',height:formHeight,width:formWidth,};}
- else if(KAMPYLE_DATA.isCustomHtmlAndFixedSizeForm(currentFormId)){iframeStyleObject={position:'absolute',top:'50%','margin-top':-formHeight/2+'px',left:'50%','margin-left':-formWidth/2+'px',height:formHeight+'px',width:formWidth+'px',};if(hostHeight<formHeight){iframeStyleObject.position='relative';iframeStyleObject.top='0';iframeStyleObject['margin-top']='50px';iframeStyleObject['margin-bottom']='50px';}}
- else{iframeStyleObject={position:'fixed',height:'100%',width:'100%',};}
- var modal=document.getElementById('kampyleFormModal');if(modal&&modal.style&&modal.removeAttribute){modal.removeAttribute('style');KAMPYLE_UTILS.setElementStyle(modal,iframeStyleObject,true);}}
- function updateDynamicIframeStyle(formData){var spanContainer=document.getElementById('formLightboxContainer');if(spanContainer){spanContainer.setAttribute('aria-hidden',false);}
- var modal=document.getElementById('kampyleFormModal');if(modal){KAMPYLE_UTILS.setElementStyle(modal,{top:0,margin:0,width:'100%',},true);}}
- function openPopup(formUrl,formId,formWidth,formHeight,eventName){formUrl=KAMPYLE_COMMON.createFormUrl(formUrl,formId);var popupPageName='NebulaCX'+formId;var popupSettings='width='+formWidth+', height='+formHeight+',scrollbars=yes';var popupHandler=window.open(formUrl,popupPageName,popupSettings);var isPopupBlocked=!popupHandler||popupHandler.closed||typeof popupHandler.closed=='undefined'
- KAMPYLE_DATA.setMemoryData('popupHandler',popupHandler);setTimeout(function(){if(isPopupBlocked){if(eventName!=='neb_skipInvitation'){alert("The survey was blocked, please disable popup blocker and refresh the page.");}
- KAMPYLE_EVENT_DISPATCHER.trigger('neb_popupBlocked',{formId:formId});}},25);}
- function handlePopupShow(formUrl,formId,formWidth,formHeight,eventName){if(KAMPYLE_FUNC.shouldRenderForm({formId:formId})){openPopup(formUrl,formId,formWidth,formHeight,eventName);}}
- function showForm(eventName,data){var isSkipInvitationEvent=eventName==='neb_skipInvitation';data=data||{};var formData=KAMPYLE_DATA.getFormData(data.formId);if(KAMPYLE_VIEW.ignoreShowForm(formData)||KAMPYLE_FUNC.hasApplicationLoadingFailed(data.formId,false)||KAMPYLE_FUNC.isAnyOtherFormAlreadyShown(data.formId,true)){return false;}
- var formUrl=formData.formHtmlUrl;var formWidth=formData.formWidth;var formHeight=formData.formHeight;var displayType=KAMPYLE_DATA.getDisplayType(formData);displayType=displayType.toLowerCase();setMetaViewport('add');KAMPYLE_DATA.setMemoryData('currentFormId',data.formId);if(!KAMPYLE_DATA.isEmbeddedDisplayType(data.formId)){KAMPYLE_DATA.setMemoryData('formIsShown',true);KAMPYLE_DATA.setMemoryData('isInvitationShouldBeIgnored',true);}
- var kampyleDevice=KAMPYLE_DATA.getMemoryData('kampyleDevice');var shouldOptimizeSkipInvitation=isSkipInvitationEvent&&KAMPYLE_FUNC.checkProvision(KAMPYLE_CONSTANT.PROVISIONS.SKIP_INVITATION_OPTIMIZATION);if(displayType==='lightbox'){if(!shouldOptimizeSkipInvitation){KAMPYLE_VIEW.prepareHostingDOM();}else{KAMPYLE_DATA.setData('isSkipInvitationOptimized',true);}
- var kampyleFormContainer=document.getElementById('kampyleFormContainer');if(kampyleFormContainer){updateIframeStyle(formData);var currIframe=document.getElementById('kampyleForm'+data.formId);if(!!currIframe){KAMPYLE_UTILS.setElementStyle(currIframe,{display:'block',},true);}
- KAMPYLE_UTILS.setElementStyle(kampyleFormContainer,{display:'block',visibility:shouldOptimizeSkipInvitation?'hidden':'visible',},true);}
- else{KAMPYLE_UTILS.showWarning("formContainer wasn't loaded properly");}}
- else if(displayType==='popup'){handlePopupShow(formUrl,data.formId,formWidth,formHeight,eventName);}
- return true;}
- function ignoreShowForm(formData){return(!formData||KAMPYLE_DATA.getDisplayType(formData)==='animation')}
- function hideInvite(){KAMPYLE_DATA.setMemoryData('inviteLoadedAndShown',false);setMetaViewport('remove');var inviteContainer=document.getElementById('kampyleInviteContainer');var kampyleInvite=document.getElementById('kampyleInvite');if(inviteContainer&&kampyleInvite){KAMPYLE_UTILS.setElementStyle(inviteContainer,{display:'none',},true);restoreHostingDOM();}}
- function changeInviteHeight(eventName,data){data=data||{};var positions=['top','bottom'];var isInviteShown=(KAMPYLE_DATA.getFormState(data.formId)||{}).inviteShown;if(!newMobileInvite()||!isInviteShown){return false;}
- var pos=KAMPYLE_VIEW.getInvitePosition(data.formId);var inviteContainer=document.getElementById('kampyleInviteContainer');var inviteIframe=document.getElementById('kampyleInvite');if(document.activeElement.tagName==='INPUT'||document.activeElement.tagName==='TEXTAREA'){KAMPYLE_UTILS.hideInvite();KAMPYLE_UTILS.setEventHandler(document.activeElement,'blur',(function(elm){return function onBlurCallback(){KAMPYLE_UTILS.removeEventHandler(elm,'blur',onBlurCallback);KAMPYLE_UTILS.showInvite();};})(document.activeElement));}else{KAMPYLE_UTILS.showInvite();}
- var style={display:'block',height:data.newHeight+'px',left:'0',right:'0',};style[pos]=0;style[positions[(positions.indexOf(pos)+1)%2]]='';KAMPYLE_UTILS.setElementStyle(inviteContainer,style,true);}
- function setMetaViewport(optional){optional=optional||'';if(KAMPYLE_DATA.getMemoryData('kampyleDevice')==='desktop'){return;}
- var kampyleMeta=document.getElementById('kampyleMetaViewport');var hostedViewportContent=document.getElementsByName('viewport');var savedViewportContent=KAMPYLE_DATA.getMemoryData('hostedViewportContent')||[];if(hostedViewportContent&&hostedViewportContent.length&&!savedViewportContent.length){for(var i=hostedViewportContent.length-1;i>=0;i--){if(hostedViewportContent[i].hasAttribute('content')){savedViewportContent.push(hostedViewportContent[i]);}}}
- switch(optional.toLowerCase()){case'add':if(savedViewportContent&&savedViewportContent.length){for(var i=savedViewportContent.length-1;i>=0;i--){if(savedViewportContent[i].hasAttribute('id')&&savedViewportContent[i].id==='kampyleMetaViewport'){continue;}
- else{if(savedViewportContent[i].remove){savedViewportContent[i].remove();}}}}
- if(!kampyleMeta){var meta=document.createElement('meta');meta.content='width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no';meta.name='viewport';meta.id='kampyleMetaViewport';document.getElementsByTagName('head')[0].appendChild(meta);}else{kampyleMeta.content='width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no';kampyleMeta.name='viewport';}
- break;case'remove':if(kampyleMeta){kampyleMeta.content='';kampyleMeta.name='';if(kampyleMeta.remove){kampyleMeta.remove();}}
- if(savedViewportContent&&savedViewportContent.length){for(var i=savedViewportContent.length-1;i>=0;i--){if(savedViewportContent[i].hasAttribute('id')&&savedViewportContent[i].id==='kampyleMetaViewport'){continue;}
- else{document.getElementsByTagName('head')[0].appendChild(savedViewportContent[i]);}}}
- break;}
- KAMPYLE_DATA.setMemoryData('hostedViewportContent',savedViewportContent);}
- function newMobileInvite(){return(Number(KAMPYLE_DATA.getMemoryData('inviteVersion'))>0)&&KAMPYLE_DATA.isNewMobileInvitation();}
- function getInvitePosition(formId){var formData=(KAMPYLE_DATA.getFormData(formId)||{});return(formData.inviteData||{}).invitationPosition||'top';}
- function showInvite(eventName,data){setMetaViewport('add');var inviteTop='25%';var inviteData=KAMPYLE_DATA.getInviteData(data.formId);if(!inviteData||!MDIGITAL.FORM_STATE.isInviteLoaded(data.formId)||!KAMPYLE_FUNC.isJsonDataLoaded(data.formId,true)){return false;}
- var kampyleDevice=KAMPYLE_DATA.getMemoryData('kampyleDevice');if(kampyleDevice===KAMPYLE_CONSTANT.DEVICES.MOBILE||kampyleDevice===KAMPYLE_CONSTANT.DEVICES.TABLET){inviteData.inviteHeight='100%';inviteData.inviteWidth='100%';inviteTop=0;}
- var invitationTimeStamp=new Date().getTime();KAMPYLE_DATA.setMemoryData('invitationTimeStamp',invitationTimeStamp);KAMPYLE_DATA.setData('LAST_INVITATION_VIEW',invitationTimeStamp);var inviteContainer=document.getElementById('kampyleInviteContainer');if(inviteContainer&&KAMPYLE_DATA.getMemoryData('formIsShown')===false){KAMPYLE_UTILS.setElementStyle(inviteContainer,{display:'block',visibility:KAMPYLE_DATA.isNewMobileInvitation()?'hidden':'visible',},true);prepareHostingDOM();KAMPYLE_EVENT_DISPATCHER.trigger('neb_invitation_ready',{formId:data.formId});var inviteModal=document.getElementById('kampyleInviteModal');if(inviteModal){KAMPYLE_UTILS.setElementStyle(inviteModal,{top:inviteTop,width:inviteData.inviteWidth+'px','max-width':inviteData.inviteWidth+'px',height:inviteData.inviteHeight+'px','max-height':inviteData.inviteHeight+'px',display:'block',},true);}
- var inviteIframe=document.getElementById('kampyleInvite');if(inviteIframe){KAMPYLE_UTILS.setElementStyle(inviteIframe,{width:inviteData.inviteWidth+'px','max-width':inviteData.inviteWidth+'px',height:inviteData.inviteHeight+'px','max-height':inviteData.inviteHeight+'px',display:'block',visibility:KAMPYLE_DATA.isNewMobileInvitation()?'hidden':'visible',},true);}}
- return true;}
- function prepareHostingDOM(){if(KAMPYLE_DATA.isMobileDynamicSizing()){KAMPYLE_VIEW.manipulateAriaHiddens();KAMPYLE_DATA.setMemoryData('hostedBodyOverflowXAttr',document.body.style.overflowX);document.body.style.overflowX='hidden';}else{KAMPYLE_DATA.setMemoryData('hostedBodyPositionAttr',document.body.style.position);if(KAMPYLE_FUNC.checkProvision(KAMPYLE_CONSTANT.PROVISIONS.ENABLE_OVERFLOW)){return false;}else{KAMPYLE_DATA.setMemoryData('hostedBodyOverflowAttr',document.body.style.overflow);document.body.style.overflow='hidden';var kampyleDevice=KAMPYLE_DATA.getMemoryData('kampyleDevice');if(kampyleDevice===KAMPYLE_CONSTANT.DEVICES.MOBILE||kampyleDevice===KAMPYLE_CONSTANT.DEVICES.TABLET){document.body.style.position='fixed';}}}}
- function restoreHostingDOM(){if(KAMPYLE_DATA.isMobileDynamicSizing()){var modal=document.getElementById('kampyleFormModal');KAMPYLE_UTILS.setElementStyle(modal,{height:'100%'},true);KAMPYLE_VIEW.restoreAriaHidden();document.body.style.overflowX=KAMPYLE_DATA.getMemoryData('hostedBodyOverflowXAttr')||'';}else{if(!KAMPYLE_FUNC.checkProvision(KAMPYLE_CONSTANT.PROVISIONS.ENABLE_OVERFLOW)){document.body.style.overflow=KAMPYLE_DATA.getMemoryData('hostedBodyOverflowAttr')||'';}
- document.body.style.position=KAMPYLE_DATA.getMemoryData('hostedBodyPositionAttr')||'';}}
- function createFormContainer(){var onPremRoot=MDIGITAL_OnPrem.getPackageRoot();var kloaderSrc=(onPremRoot?onPremRoot+'/':KAMPYLE_CONSTANT.PLACEHOLDERS.URL_PREFIX)+'resources/onsite/images/kloader.gif';if(!KAMPYLE_FUNC.checkProvision(KAMPYLE_CONSTANT.PROVISIONS.CSP_RULES)){var formSpanPlacer=document.createElement('span');formSpanPlacer.id='formLightboxContainer';var html='';html+='<div id="kampyleFormContainer" style="top:0 !important;left:0 !important;width: 100% !important;height: 100% !important;position: fixed !important;visibility:hidden !important;display:table !important;background-color: rgba(102,102,102,0.4) !important;z-index:99999999 !important;-webkit-overflow-scrolling: touch !important; ">';html+=' <div id="innerContainer">';html+=' <img class="neb-loading-spinner" alt="Loading" style="position:absolute !important;top:50% !important;left:50% !important; margin-top: -30px !important;margin-left: -30px !important; max-width:60px !important;" src="'+kloaderSrc+'"/>';html+=' <div id="kampyleFormModal" style="z-index:99999999 !important; -webkit-overflow-scrolling: touch !important;"></div>';html+=' </div>';html+='</div>';formSpanPlacer.innerHTML=html;document.body.appendChild(formSpanPlacer);}}
- function createIframe(eventName,data){data=data||{};var formState=KAMPYLE_DATA.getFormState(data.formId);if(formState&&formState.loaded||KAMPYLE_FUNC.hasApplicationLoadingFailed(data.formId,false)){return;}
- var formData=KAMPYLE_DATA.getFormData(data.formId);var displayType=KAMPYLE_DATA.getDisplayType(formData);if(!formData||!data.formId||displayType!=='lightbox'){return;}
- setTimeout(function(){if(!KAMPYLE_FUNC.isFormLoaded(data.formId)){KAMPYLE_EVENT_DISPATCHER.trigger(KAMPYLE_CONSTANT.EVENTS.NEB_FORM_LOADING_HAS_FAILED,{formId:data.formId})}},KAMPYLE_CONSTANT.NETWORK.TIME_FOR_FORM_TO_LOAD_MS);if(!document.getElementById('kampyleFormContainer')){createFormContainer();}
- var formHtml=data.formHtmlUrl||formData.formHtmlUrl;formHtml=KAMPYLE_COMMON.createFormUrl(formHtml,data.formId);if(displayType==='popup'){}
- else{var formIframe=document.getElementById('kampyleForm'+data.formId);if(!formIframe){var iframeStyleObject={border:0,height:'100%','max-height':'100%','min-height':'100%',width:'100%','max-width':'100%','min-width':'100%',display:'none',};formIframe=document.createElement('iframe');formIframe.id='kampyleForm'+data.formId;formIframe.setAttribute('title','Feedback Survey');if(!KAMPYLE_DATA.isCustomHtmlForm(data.formId)&&!KAMPYLE_DATA.isMobileDynamicSizing(formData.formId)){iframeStyleObject.position='fixed';}
- KAMPYLE_UTILS.setElementStyle(formIframe,iframeStyleObject,true);}
- formIframe.src=formHtml;document.getElementById('kampyleFormModal').appendChild(formIframe);}}
- function applyMobileDynamicStyles(eventName,data){var formId=data.formId;var kFormContainer=document.getElementById('kampyleFormContainer');if(!(formId&&kFormContainer&&KAMPYLE_DATA.isMobileDynamicSizing(formId))){return false;}
- KAMPYLE_UTILS.setElementStyle(kFormContainer,{height:KAMPYLE_UTILS.getDocumentSize().height+'px',position:'absolute',},true);}
- function getDefaultIframeHeight(){return KAMPYLE_UTILS.isIos()?'30px':'100%';}
- function iFrameHeightChangedHandler(eventData){if(KAMPYLE_DATA.isLightBoxDisplayType(eventData.formId)){var modal=document.getElementById('kampyleFormModal');var newHeight=Number((eventData||{}).newHeight);newHeight=isNaN(newHeight)?getDefaultIframeHeight():(newHeight)+'px';KAMPYLE_UTILS.setElementStyle(modal,{height:newHeight},true);}}
- function reactToIframeHeightChange(eventName,eventData){if(KAMPYLE_DATA.isMobileDynamicSizing((eventData||{}).formId)){iFrameHeightChangedHandler(eventData);var formHeight=KAMPYLE_UTILS.getNestedPropertyValue(eventData,'newHeight');if(KAMPYLE_VIEW.shouldAddScroll(formHeight)){var kFormContainer=document.getElementById('kampyleFormContainer');KAMPYLE_UTILS.setElementStyle(kFormContainer,{overflowY:'auto'},true);}}}
- function manipulateAriaHiddens(){var bodyChilds=document.body.children;var ariaHiddenValues=[];for(var i=0;i<bodyChilds.length;i++){ariaHiddenValues.push({element:bodyChilds[i],prevAriaHiddenValue:bodyChilds[i].getAttribute('aria-hidden'),});bodyChilds[i].setAttribute('aria-hidden',true);}
- KAMPYLE_DATA.setMemoryData('initialAriaHiddenValues',ariaHiddenValues);}
- function restoreAriaHidden(){var storeValues=KAMPYLE_DATA.getMemoryData('initialAriaHiddenValues')||[];for(var i=0;i<storeValues.length;i++){if(!(storeValues[i].element&&storeValues[i].element instanceof Element)){continue;}
- if(storeValues[i].prevAriaHiddenValue===null){storeValues[i].element.removeAttribute('aria-hidden');}else{storeValues[i].element.setAttribute('aria-hidden',storeValues[i].prevAriaHiddenValue);}}
- KAMPYLE_DATA.deleteMemoryData('initialAriaHiddenValues');}
- function createInviteIframe(eventName,eventData){var data=KAMPYLE_DATA.getFormData(eventData.formId);var inviteSpanPlacer=document.createElement('span');var onPremRoot=MDIGITAL_OnPrem.getPackageRoot();var kloaderSrc=(onPremRoot?onPremRoot+'/':KAMPYLE_CONSTANT.PLACEHOLDERS.URL_PREFIX)+'resources/onsite/images/kloader.gif';if(!KAMPYLE_FUNC.checkProvision(KAMPYLE_CONSTANT.PROVISIONS.CSP_RULES)){var inviteContainerStyles='top:0 !important;left:0 !important;width: 100% !important;';inviteContainerStyles+='height: 100% !important;position: fixed !important;visibility:hidden !important;';inviteContainerStyles+='display:none !important;background-color: rgba(22,22,22,0.5) !important;';inviteContainerStyles+='z-index:99999999 !important;overflow:auto !important';var spinnerStyles='position:absolute !important;top:50% !important;left:50% !important;';spinnerStyles+='margin-top: -30px !important;margin-left: -30px !important; max-width:60px !important;';inviteSpanPlacer.innerHTML='<div id="kampyleInviteContainer" style="'+inviteContainerStyles+'"><img class="neb-loading-spinner" alt="Loading" style="'+spinnerStyles+'" src="'+kloaderSrc+'"/><div id="kampyleInviteModal" style="overflow: hidden;margin: 0 auto;height:'+data.inviteData.inviteHeight+';width:'+data.inviteData.inviteWidth+';position:relative;z-index:99999999;top: 25%;-webkit-box-shadow:0 0 10px rgba(0,0,0,0.4);-moz-box-shadow:0 0 10px rgba(0,0,0,0.4); box-shadow:0 0 10px rgba(0,0,0,0.4);"></div></div>';var s=document.body.appendChild(inviteSpanPlacer);}
- var inviteIframe=document.createElement('iframe');inviteIframe.id='kampyleInvite';inviteIframe.title='Invitation to provide feedback';var inviteHeight=data.inviteData.inviteHeight;var inviteWidth=data.inviteData.inviteWidth;var kampyleDevice=KAMPYLE_DATA.getMemoryData('kampyleDevice');if(kampyleDevice===KAMPYLE_CONSTANT.DEVICES.MOBILE||kampyleDevice===KAMPYLE_CONSTANT.DEVICES.TABLET){inviteHeight='100%';inviteWidth='100%';var inviteModal=document.getElementById('kampyleInviteModal');if(!!inviteModal)
- {KAMPYLE_UTILS.setElementStyle(inviteModal,{height:'100%',width:'100%',},true);}}
- KAMPYLE_UTILS.setElementStyle(inviteIframe,{height:inviteHeight,width:inviteWidth,display:'none',border:'0',},true);if(KAMPYLE_DATA.isFeatureEnabled('WCAG')){data.inviteData.inviteUrl+='?isWCAG=true';}
- inviteIframe.src=data.inviteData.inviteUrl;document.getElementById('kampyleInviteModal').appendChild(inviteIframe);if(KAMPYLE_DATA.isNewMobileInvitation()){var spinner=document.getElementsByClassName('neb-loading-spinner')[0];KAMPYLE_UTILS.setElementStyle(spinner,{display:'none',},true);KAMPYLE_UTILS.setElementStyle(inviteSpanPlacer,{'z-index':99999998,},true);var inviteContainer=document.getElementById('kampyleInviteContainer');if(inviteContainer){KAMPYLE_UTILS.setElementStyle(inviteContainer,{'z-index':99999998,},true);}}
- setTimeout(function(){if(KAMPYLE_DATA.getFormState(data.formId).inviteLoaded!==true){KAMPYLE_DATA.setFormState(data.formId,{inviteLoaded:false,inviteShown:false});}},KAMPYLE_CONSTANT.NETWORK.TIME_FOR_FORM_TO_LOAD_MS);}
- function hideButton(eventName,data){var buttonElementById=document.getElementById('kampyleButtonContainer');if(!data||KAMPYLE_DATA.isEmbeddedDisplayType(data.formId)||!buttonElementById){return false;}
- buttonElementById.innerHTML='';return true;}
- function removeAllShownElements(eventName,data){var kampyleFormContainer=document.getElementById('kampyleFormContainer');var kampyleInviteContainer=document.getElementById('kampyleInviteContainer');KAMPYLE_VIEW.hideButton(eventName,data);if(kampyleFormContainer){KAMPYLE_UTILS.removeAllContent(kampyleFormContainer);}
- if(kampyleInviteContainer){KAMPYLE_UTILS.removeAllContent(kampyleInviteContainer);}}
- function getButtonText(formData){if(typeof MDIGITAL.LOCALIZATION!=='undefined'&&KAMPYLE_FUNC.checkProvision(KAMPYLE_CONSTANT.PROVISIONS.LOCALIZED_FORMS)){return MDIGITAL.LOCALIZATION.getLocalizedButtonText(formData);}
- else{return formData.buttonData.text;}}
- function shouldAddScroll(formHeight){var bodyPosition=KAMPYLE_UTILS.getElementStyle(document.body,'position');return(bodyPosition==='fixed'||bodyPosition==='absolute')&&(KAMPYLE_UTILS.getDocumentSize().height<=formHeight);}
- return{ignoreShowForm:ignoreShowForm,scrollToEmbeddedForm:scrollToEmbeddedForm,scrollFromTop:scrollFromTop,doScrollY:doScrollY,removeAllShownElements:removeAllShownElements,createIframe:createIframe,showForm:showForm,hideForm:hideForm,showButton:showButton,hideInvite:hideInvite,hideButton:hideButton,handleInvitationSkippedForms:handleInvitationSkippedForms,updateIframeStyle:updateIframeStyle,formatTriangularStyle:formatTriangularStyle,formatVerticalStyle:formatVerticalStyle,prepareHostingDOM:prepareHostingDOM,restoreHostingDOM:restoreHostingDOM,getInvitePosition:getInvitePosition,newMobileInvite:newMobileInvite,changeInviteHeight:changeInviteHeight,iFrameHeightChangedHandler:iFrameHeightChangedHandler,manipulateAriaHiddens:manipulateAriaHiddens,restoreAriaHidden:restoreAriaHidden,getDefaultIframeHeight:getDefaultIframeHeight,shouldAddScroll:shouldAddScroll,shouldShowErrMsgOnForm:shouldShowErrMsgOnForm,init:init,setMetaViewport:setMetaViewport,showVisibility:showVisibility,getCornerMargin:getCornerMargin,showFormCouldNotFechtedErrorMsg:showFormCouldNotFechtedErrorMsg,handleInviteReady:handleInviteReady,getButtonText:getButtonText,showInvite:showInvite,getWCAGClass:getWCAGClass,getClassDirectonByPosition:getClassDirectonByPosition};})(window,document);window.KAMPYLE_MESSAGE=(function(){function init(){KAMPYLE_UTILS.setEventHandler(window,'message',handleMessage);}
- function validateMessageEvent(e){if(!e||!e.origin||!e.data){return false;}
- var baseUrl=KAMPYLE_CONSTANT.PLACEHOLDERS.URL_PREFIX;if(baseUrl.charAt(baseUrl.length-1)==='/'){baseUrl=baseUrl.slice(0,baseUrl.length-1);}
- return KAMPYLE_FUNC.checkProvision(KAMPYLE_CONSTANT.PROVISIONS.ON_PREM_HYBRID)||e.origin===baseUrl;}
- function handleMessage(e){if(!validateMessageEvent(e)){return false;}
- var currDate=new Date();var data;try{data=JSON.parse(e.data);}
- catch(e){return false;}
- switch(data.action){case'inviteAccepted':KAMPYLE_EVENT_DISPATCHER.trigger('neb_inviteAccepted',{'formId':data.formId});break;case'inviteDeclined':case'inviteDefered':KAMPYLE_EVENT_DISPATCHER.trigger('neb_inviteDeclined',{'formId':data.formId});break;case'inviteHeightChanged':KAMPYLE_EVENT_DISPATCHER.trigger('neb_inviteHeightChanged',{formId:data.formId,newHeight:data.newHeight,});break;case'formLoaded':KAMPYLE_EVENT_DISPATCHER.trigger('neb_formLoaded',{'formId':data.formId,origin:e.origin,isScreenCaptureEnabled:data.isScreenCaptureEnabled,});break;case'formSubmitPending':case'formHide':KAMPYLE_EVENT_DISPATCHER.trigger('neb_formHide',{'formId':data.formId});break;case'formSubmitted':var payload={formId:data.formId,feedbackUUID:data.uuid,};if(KAMPYLE_FUNC.checkProvision(KAMPYLE_CONSTANT.PROVISIONS.EVENT_INCLUDE_FEEDBACK_CONTENT)&&data.content){payload.content=data.content;}
- KAMPYLE_EVENT_DISPATCHER.trigger('neb_feedbackSubmitted',payload);break;case'formClose':var payload={formId:data.formId,feedbackUUID:data.uuid,sourceWindow:e.source,isFormSubmitted:data.isFormSubmitted,};KAMPYLE_EVENT_DISPATCHER.trigger('neb_formClosed',payload);break;case'formPageShown':KAMPYLE_EVENT_DISPATCHER.trigger('neb_formPageShown',{'formId':data.formId,'feedbackUUID':data.uuid,'pageNumber':data.pageNumber,});break;case'triggerScreenCapture':break;case'scrollToForm':KAMPYLE_EVENT_DISPATCHER.trigger('neb_scrollToForm',{formId:data.formId});break;case'iFrameHeightChanged':KAMPYLE_EVENT_DISPATCHER.trigger('neb_iFrameHeightChanged',{formId:data.formId,newHeight:data.newHeight,});break;case'scrollToTop':KAMPYLE_EVENT_DISPATCHER.trigger('neb_scrollToTop',{formId:data.formId,});break;case'scrollFromTop':KAMPYLE_EVENT_DISPATCHER.trigger('neb_scrollFromTop',{formId:data.formId,numberOfPixels:data.numberOfPixels});break;case'inviteLoaded':KAMPYLE_EVENT_DISPATCHER.trigger('neb_inviteLoaded',{formId:data.formId,inviteVersion:data.inviteVersion,});break;case'loadMultipleForms':KAMPYLE_EVENT_DISPATCHER.trigger('neb_loadMultipileForms',{formId:data.formId,formIds:data.formIds,});break;case'routeToForm':KAMPYLE_EVENT_DISPATCHER.trigger('neb_routeToForm',{formId:data.destinationForm,sourceFormId:data.formId,},null,{isStrictMode:true});break;case'submitFeedbackFailed':KAMPYLE_EVENT_DISPATCHER.trigger('neb_submitFeedbackFailed',data);break;case'feedbackUUIDisNull':KAMPYLE_EVENT_DISPATCHER.trigger('neb_feedbackUUIDisNull',data);break;case'MDigital_Form_Next_Page':case'MDigital_Form_Back_Page':case'MDigital_ThankYou_Displayed':case'MDigital_ThankYou_Close':case'MDigital_Form_Close_No_Submit':case'MDigital_Form_Close_Submitted':KAMPYLE_EVENT_DISPATCHER.trigger(data.action,data);break;default:if(!KAMPYLE_FUNC.checkProvision(KAMPYLE_CONSTANT.PROVISIONS.ON_PREM_HYBRID)){KAMPYLE_UTILS.showWarning('invalid action - '+data.action);}
- return false;}}
- return{init:init,handleMessage:handleMessage,validateMessageEvent:validateMessageEvent};})();window.KAMPYLE_UTILS={TOP_LEVEL_DOMAIN_COOKIE_PREFIX:'Tld-',startsWith:function(originalString,searchString,position){return originalString.substr(position||0,searchString.length)===searchString;},isIos:function(){return/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream;},isSafari:function(){return navigator.userAgent.indexOf("Safari")>-1&&navigator.userAgent.indexOf("Chrome")<0;},isIE:function(){return/rv:11.0/i.test(navigator.userAgent)||/MSIE 10/i.test(navigator.userAgent)||/MSIE 9/i.test(navigator.userAgent);},createIEEvent:function(eventName,data){var e=document.createEvent('HTMLEvents');e.initEvent(eventName,true,true);e.detail=data||{};return e;},triggerCustomEvent:function(eventName,data){var e;var isIE=KAMPYLE_UTILS.isIE();if(isIE){e=KAMPYLE_UTILS.createIEEvent(eventName,data);}else{data=data?{detail:data}:{};e=new CustomEvent(eventName,data);}
- try{window.dispatchEvent(e);}catch(e){KAMPYLE_UTILS.showWarning('Could not trigger custom event '+eventName);}},isDebugMode:function(){var region=KAMPYLE_DATA.getMemoryData('region');return(region==='dev'||region==='qa');},showErrorStack:function(e){if(KAMPYLE_UTILS.isDebugMode()){console.warn(e.stack);}},showWarning:function(message){if(KAMPYLE_UTILS.isDebugMode()){console.warn(message);}},addStyle:function(cssStyle,referencedDocument){if(!KAMPYLE_FUNC.checkProvision(KAMPYLE_CONSTANT.PROVISIONS.CSP_RULES)){referencedDocument=referencedDocument||window.document;var style=referencedDocument.getElementById('kampyleStyle');if(style===null){style=referencedDocument.createElement('style');style.type='text/css';style.id='kampyleStyle';var head=referencedDocument.head||referencedDocument.getElementsByTagName('head')[0];head.appendChild(style);}
- if(style.styleSheet){style.styleSheet.cssText+=cssStyle;}else{style.appendChild(document.createTextNode(cssStyle));}}
- else{console.error("Should not use this method if the provision csp rules is on");}},addAttributesOnElement:function(element,attributesObj){if(element&&attributesObj){for(var key in attributesObj){if(attributesObj.hasOwnProperty(key)){element.setAttribute(key,attributesObj[key]);}}}},getViewportSize:function(){return{width:Math.max(document.documentElement.clientWidth,window.innerWidth||0),height:Math.max(document.documentElement.clientHeight,window.innerHeight||0),};},getDocumentSize:function(){var body=document.body;var html=document.documentElement;var height=Math.max(body.scrollHeight||0,body.offsetHeight||0,html.clientHeight||0,html.scrollHeight||0,html.offsetHeight||0);var width=Math.max(body.scrollWidth||0,html.scrollWidth||0,body.offsetWidth||0,html.offsetWidth||0,html.clientWidth||0);return{width:width+(body.getBoundingClientRect?body.getBoundingClientRect().left||0:0),height:height+(body.getBoundingClientRect?body.getBoundingClientRect().top||0:0),};},getElementSize:function(element){var height=Math.max(element.scrollHeight||0,element.offsetHeight||0,element.clientHeight||0);var width=Math.max(element.scrollWidth||0,element.offsetWidth||0,element.clientWidth||0);return{width:width,height:height,};},getTimeDiff:function(time,format){var datetime=typeof time!=='undefined'?time:'2014-01-01 01:02:03.123456';datetime=new Date(datetime).getTime();var now=Date.now();if(isNaN(datetime)){return'';}
- var miliSecDiff=0;if(datetime<now){miliSecDiff=now-datetime;}else{miliSecDiff=datetime-now;}
- switch(format){case KAMPYLE_CONSTANT.TIME_FORMATS.SECONDS:return miliSecDiff.toFixed(1)/1000;case KAMPYLE_CONSTANT.TIME_FORMATS.DAYS:return Math.floor(miliSecDiff/1000/60/60/24);default:return miliSecDiff;}},setEventHandler:function(elem,eventType,handler){if(elem.addEventListener){elem.addEventListener(eventType,handler,false);}
- else if(elem.attachEvent){elem.attachEvent('on'+eventType,handler);}},subscribeToCustomEvent:function(eventType,handler){if(window&&window.addEventListener&&typeof handler==="function"){window.addEventListener(eventType,function(event){var payload=event&&event.detail;handler.apply(null,[eventType,payload]);},false);}},removeEventHandler:function(elem,eventType,handler){if(elem.removeEventListener){elem.removeEventListener(eventType,handler);}else if(elem.detachEvent){elem.detachEvent('on'+eventType,handler);}},setElementStyle:function(element,styleObj,isImportant){var k;var dashed;isImportant=!!isImportant?'important':'';if(element){for(k in styleObj){if(styleObj.hasOwnProperty(k)){if(isImportant&&element&&element.style.setProperty){dashed=KAMPYLE_UTILS.camelToDash(k);try{element.style.setProperty(dashed,''+styleObj[k],isImportant);}
- catch(e){element.style.setProperty(dashed,''+styleObj[k],'!'+isImportant);}}
- else{element.style[k]=styleObj[k];}}}}},isNear:function(elementId,distance,event){var element=document.getElementById(elementId);if(!element){return false;}
- var left=KAMPYLE_UTILS.offset(element).left-distance;var top=KAMPYLE_UTILS.offset(element).top-distance;var right=left+element.clientWidth+(2*distance);var bottom=top+element.clientHeight+(2*distance);var x=event.pageX;var y=event.pageY;return(x>left&&x<right&&y>top&&y<bottom);},offset:function(element){if(!element){return false;}
- var rect=element.getBoundingClientRect();var bodyElm=document.body;return{top:+rect.top+bodyElm.scrollTop,left:rect.left+bodyElm.scrollLeft,};},createIframe:function(src,width,height,iframeId){var iframe=document.createElement('iframe');iframe.width=width;iframe.height=height;iframe.src=src;iframe.id=iframeId;iframe.style.border=0;iframe.frameBorder=0;iframe.style.display='inline-block';return iframe;},getUrlParam:function(name){var params=location.search.substr(location.search.indexOf('?')+1);if(params===''){params=location.hash.substr(location.hash.indexOf('?')+1);}
- var sval=null;params=params.split('&');var paramLenght=params.length;for(var i=0;i<paramLenght;i++)
- {var temp=params[i].split('=');if(temp&&[temp[0]]==name){sval=decodeURIComponent(temp[1]);}}
- return sval;},htmlDecode:function(inputHtml){inputHtml=inputHtml||'';var re;re=new RegExp('<','g');inputHtml=inputHtml.replace(re,'<');re=new RegExp('>','g');inputHtml=inputHtml.replace(re,'>');return inputHtml;},escapeRegExp:function(str){return str.replace(/([.*+?^=!:${}()|\[\]\/\\])/g,'\\$1');},replaceAll:function(str,find,replace){return str.replace(new RegExp(KAMPYLE_UTILS.escapeRegExp(find),'g'),replace);},sendMessageToIframe:function(iframeId,message){var origin;var targetWindow;var iframe;if(!iframeId){return;}
- iframe=document.getElementById(iframeId);if(!iframe||!iframe.getAttribute){return;}
- var origin=iframe.getAttribute('origin')||'*';var targetWindow=iframe.contentWindow;if(targetWindow&&targetWindow.postMessage)
- {targetWindow.postMessage(JSON.stringify(message),origin);}},getBrowser:function(){var ua=navigator.userAgent,tem,M=ua.match(/(opera|chrome|safari|firefox|msie|trident(?=\/))\/?\s*(\d+)/i)||[];if(/trident/i.test(M[1])){tem=/\brv[ :]+(\d+)/g.exec(ua)||[];return{name:'IE',version:tem[1]||'',};}
- if(M[1]==='Chrome'){tem=ua.match(/\b(OPR|Edge)\/(\d+)/);if(tem!=null){var temArr=tem.slice(1);return{name:temArr[0].replace('OPR','Opera'),version:temArr[1]||'',};}}
- M=M[2]?[M[1],M[2]]:[navigator.appName,navigator.appVersion,'-?'];if((tem=ua.match(/version\/(\d+)/i))!=null)M.splice(1,1,tem[1]);return{name:M[0],version:M[1],};},initEventSubscriptions:function(eventObj,callback){for(var prop in eventObj)
- {if(eventObj.hasOwnProperty(prop))
- {KAMPYLE_EVENT_DISPATCHER.subscribe(prop,callback);}}},getRandomTimeMS:function(minValue,maxValue){return minValue+(Math.round(Math.random()*(maxValue-minValue)));},kampyleGetUserId:function(){var userid=KAMPYLE_DATA.getData('kampyle_userid');if(!userid){userid=KAMPYLE_UTILS.kampyleCreateUUID();KAMPYLE_DATA.setData('kampyle_userid',userid);if(KAMPYLE_FUNC.checkProvision(KAMPYLE_CONSTANT.PROVISIONS.ALTERNATIVE_UUID)){KAMPYLE_DATA.setData(KAMPYLE_CONSTANT.MEMORY_DATA_FIELDS.MDIGITAL_ALTERNATIVE_UUID,KAMPYLE_UTILS.generateUUID());}}
- return userid;},kampyleCreateUUID:function(){var numAttempts=8;var uuidAlgorithm=function(){return Math.floor((1+Math.random())*0x10000).toString(16).substring(1);};var uuid=uuidAlgorithm();for(var i=0;i<numAttempts-1;i++){uuid+='-'+uuidAlgorithm();}
- return uuid;},removeAllContent:function(elem){if(!elem){return;}
- while(elem.firstChild){elem.removeChild(elem.firstChild);}
- elem.parentNode.removeChild(elem);},safeToLower:function(toLower){if(typeof toLower!=='string')
- {return toLower;}
- else{return toLower.toLowerCase();}},buildQueryParams:function(params){return Object.keys(params||{}).map(function(key,index){return(index===0?'?':'')+key+'='+params[key];}).join('&')||'';},kampyleSetCookie:function(cookieName,cookieValue,exDays,propertySharedSubdomain){var currDate=new Date();currDate.setTime(currDate.getTime()+(exDays*24*60*60*1000));var isSecureProtocol=KAMPYLE_UTILS.isSecureProtocol();var expires='expires='+currDate.toUTCString();var domain=propertySharedSubdomain?';domain='+propertySharedSubdomain+';':'';var sameSiteValue=isSecureProtocol?'None':'Lax';var secure=isSecureProtocol?'Secure; ':'';cookieName=propertySharedSubdomain?KAMPYLE_UTILS.TOP_LEVEL_DOMAIN_COOKIE_PREFIX+cookieName:cookieName;document.cookie=cookieName+'='+cookieValue+'; SameSite='+sameSiteValue+'; '+secure+expires+';path=/'+domain;},isSecureProtocol:function(){return location.protocol==='https:';},getCookie:function(cookieName){this.name=cookieName+'=';this.ca=document.cookie.split(';');for(var i=0;i<this.ca.length;i++){this.c=this.ca[i];while(this.c.charAt(0)===' ')this.c=this.c.substring(1);if(this.c.indexOf(this.name)===0){var valueToReturn=this.c.substring(this.name.length,this.c.length);return valueToReturn;}}
- return null;},getDomainFromHost:function(host){if(host===null){return null;}
- var portStartIndex=host.indexOf(':');var lastDomainCharacter=portStartIndex===-1?host.length:portStartIndex;return host.substring(0,lastDomainCharacter);},isHostMatchesSubdomain:function(host,subdomain){var domain=KAMPYLE_UTILS.getDomainFromHost(host);return domain===subdomain||domain.endsWith('.'+subdomain);},kampyleGetCookie:function(cookieName){this.name=cookieName+'=';this.ca=document.cookie.split(';');for(var i=0;i<this.ca.length;i++){this.c=this.ca[i];while(this.c.charAt(0)===' ')this.c=this.c.substring(1);if(this.c.indexOf(this.name)===0)return this.c.substring(this.name.length,this.c.length);}
- return'';},getByteSize:function(s){return encodeURIComponent('<q></q>'+s).length;},getAllKampyleData:function(){var kampyleDataNames=['SUBMITTED_DATE','kampyleUserPercentile','kampyleUserSession','kampyle_userid','kampyleInvitePresented','DECLINED_DATE','LAST_INVITATION_VIEW',];if(KAMPYLE_FUNC.checkProvision(KAMPYLE_CONSTANT.PROVISIONS.ALTERNATIVE_UUID)){kampyleDataNames.push(KAMPYLE_CONSTANT.MEMORY_DATA_FIELDS.MDIGITAL_ALTERNATIVE_UUID);}
- var result={};for(var i=kampyleDataNames.length-1;i>=0;i--){result[kampyleDataNames[i]]=KAMPYLE_DATA.getData(kampyleDataNames[i]);}
- return result;},kampyleDeleteCookie:function(cookieName,propertySharedSubdomain){var domain='';if(propertySharedSubdomain){domain=';domain='+propertySharedSubdomain+';';}
- var expires='expires=Thu, 01 Jan 1970 00:00:00 UTC';document.cookie=cookieName+'= ; '+expires+'; path=/'+domain;},kampyleIsCookieEnabled:function(){return navigator.cookieEnabled;},kampyleCompareTimestamps:function(source,toCompare,operator)
- {if(typeof source!=='number'||typeof toCompare!=='number')
- {return false;}
- source=new Date(source);toCompare=new Date(toCompare);source.setHours(0,0,0,0);switch(operator){case'equals':toCompare.setHours(0,0,0,0);return(source.getTime()===toCompare.getTime());break;case'laterthan':toCompare.setHours(23,59,59,999);return(source>toCompare);break;case'earlierthan':toCompare.setHours(0,0,0,0);return(source<toCompare);break;case'doesnotequal':toCompare.setHours(0,0,0,0);return(source.getTime()!==toCompare.getTime());break;default:return false;break;}},kampyleCompareByOperator:function(source,toCompare,operator,varType){varType=KAMPYLE_UTILS.safeToLower(varType);var ans=false;if(source===undefined)
- {return ans;}
- operator=KAMPYLE_UTILS.safeToLower(operator);switch(operator){case KAMPYLE_CONSTANT.OPERATORS.EQUALS:if(varType==='datetime')
- {ans=KAMPYLE_UTILS.kampyleCompareTimestamps(source,toCompare,operator);}
- else{ans=(source===toCompare);}
- break;case KAMPYLE_CONSTANT.OPERATORS.DOES_NOT_EQUAL:if(varType==='datetime')
- {ans=KAMPYLE_UTILS.kampyleCompareTimestamps(source,toCompare,operator);}
- else{ans=(source!==toCompare);}
- break;break;case KAMPYLE_CONSTANT.OPERATORS.GREATER_THAN:ans=(source>toCompare);break;case KAMPYLE_CONSTANT.OPERATORS.LATER_THAN:if(varType==='datetime')
- {ans=KAMPYLE_UTILS.kampyleCompareTimestamps(source,toCompare,operator);}
- else{ans=(source>toCompare);}
- break;case KAMPYLE_CONSTANT.OPERATORS.SMALLER_THAN:ans=(source<toCompare);break;case KAMPYLE_CONSTANT.OPERATORS.EARLIER_THAN:if(varType==='datetime')
- {ans=KAMPYLE_UTILS.kampyleCompareTimestamps(source,toCompare,operator);}
- else{ans=(source>toCompare);}
- break;case KAMPYLE_CONSTANT.OPERATORS.CONTAINS:ans=(!!source&&source.indexOf&&source.indexOf(toCompare)!==-1);break;case KAMPYLE_CONSTANT.OPERATORS.DOES_NOT_CONTAIN:ans=(!!source&&source.indexOf&&source.indexOf(toCompare)===-1);break;case KAMPYLE_CONSTANT.OPERATORS.STARTS_WITH:ans=(!!source&&source.indexOf&&source.indexOf(toCompare)===0);break;case KAMPYLE_CONSTANT.OPERATORS.ENDS_WITH:ans=(!!source&&source.indexOf&&source.length&&source.indexOf(toCompare,source.length-source.length)!==-1);break;case KAMPYLE_CONSTANT.OPERATORS.HAS_VALUE:ans=(!!source||source===''||source===false||source===0);break;case KAMPYLE_CONSTANT.OPERATORS.REGEX:try{var regex=new RegExp(toCompare);ans=(!!source&®ex.exec(source)!==null);}catch(e){ans=false;}
- break;default:break;}
- return ans;},setNestedPropertyValue:function(obj,propString,value){var schema=obj;var pList=propString.split('.');var len=pList.length;for(var i=0;i<len-1;i++){var elem=pList[i];if(!schema[elem]){schema[elem]={};}
- schema=schema[elem];}
- schema[pList[len-1]]=value;},getNestedPropertyValue:function(obj,propString,fallback){if(!obj||!propString||typeof propString!=='string'){return null;}
- var propNameDotPlaceholder='#DOT#';var props=propString.split('.');var tmpObj=obj;var len=props.length;for(var i=0;i<len;i++){var currProp=props[i].split(propNameDotPlaceholder).join('.');if(!!tmpObj&&(tmpObj.hasOwnProperty(currProp)||tmpObj[currProp])){tmpObj=tmpObj[currProp];}else{return typeof fallback==="undefined"?null:fallback;}}
- return tmpObj;},validateKampyleDomain:function(url){var urlRegex=/(^https?:\/\/[A-Za-z0-9\-]+\.kampyle\.com(\/[A-Za-z0-9\-\._~:\/\?#\[\]@!$&'\(\)\*\+,;\=]*)?)/;var result=urlRegex.test(url);if(!result){console.warn('Invalid url in validateKampyleDomain: '+url);}
- return result;},camelToDash:function(str){if(typeof str!=='string'){return str;}
- else{return str.replace(/\W+/g,'-').replace(/([a-z\d])([A-Z])/g,'$1-$2').toLowerCase();}},objectPropertyObserver:function(obj,pathToProperty,callback){var MAX_TIMEOUT_RUNS=100;var timeoutMs=100;var runsCounter=0;function timoutCallback(){var propertyValue=KAMPYLE_UTILS.getNestedPropertyValue(obj,pathToProperty);if(!!propertyValue&&callback instanceof Function){return callback(propertyValue);}
- if(runsCounter++<MAX_TIMEOUT_RUNS){window.setTimeout(timoutCallback,timeoutMs);}}
- window.setTimeout(timoutCallback,timeoutMs);},showInvite:function(){var inviteIframe=document.getElementById('kampyleInvite');KAMPYLE_UTILS.setElementStyle(inviteIframe,{visibility:'visible'},true);},hideInvite:function(){var inviteIframe=document.getElementById('kampyleInvite');KAMPYLE_UTILS.setElementStyle(inviteIframe,{visibility:'hidden'},true);},getNumericValue:function(val){if(val===''||val===null){return null;}
- if(typeof(val)!=='number'&&isNaN(Number(val))){return null;}
- return Number(val);},httpGetRequest:function(url,onSuccess,onError,config){var counter=0;var numOfTimes=(config||{}).numOfTimes||KAMPYLE_CONSTANT.NETWORK.NUM_OF_RETRIES;var timeout=(config||{}).timeout||KAMPYLE_CONSTANT.NETWORK.REQUEST_TIMEOUT;function handleError(error,eventName,eventData){if(counter<numOfTimes){counter++;var timeoutBetweenRetries=KAMPYLE_UTILS.getRetryTimeout();setTimeout(makeRequest,timeoutBetweenRetries);}else{KAMPYLE_EVENT_DISPATCHER.trigger(eventName,eventData);if(typeof onError==='function'){onError(error);}}}
- function makeRequest(){var beforeRequestData={attemptNumber:counter,url:url,maxTimes:numOfTimes};KAMPYLE_EVENT_DISPATCHER.trigger('neb_beforeHttpGetRequest',{httpRequestData:beforeRequestData});var xhr=new XMLHttpRequest();xhr.open('GET',url,true);xhr.timeout=timeout||0;xhr.onerror=function(error){handleError(error,'neb_afterHttpGetRequestOnError',{httpRequestData:{error:JSON.stringify(error)}});};xhr.ontimeout=function(error){handleError(error,'neb_afterHttpGetRequestOnTimeout',{httpRequestData:{attemptNumber:counter,error:JSON.stringify(error)}});};xhr.onload=function(){if(xhr.status===200){var data=KAMPYLE_UTILS.safeJsonParse(xhr.responseText);KAMPYLE_EVENT_DISPATCHER.trigger('neb_afterHttpGetRequest',{httpRequestData:data});if(typeof onSuccess==='function'){onSuccess(data);}}
- else{var afterRequestData={responseStatus:xhr.status,responseText:KAMPYLE_UTILS.safeJsonParse(xhr.responseText),attemptNumber:counter};handleError(xhr.status,'neb_afterHttpGetRequest',{httpRequestData:afterRequestData,error:xhr.status});}};xhr.send();}
- makeRequest();},httpPostRequest:function(url,jsonData,callback){var postRequestData={postData:Object.assign({},jsonData),};KAMPYLE_EVENT_DISPATCHER.trigger('neb_beforeHttpPostRequest',postRequestData);var xhr=new XMLHttpRequest();xhr.open('POST',url);xhr.setRequestHeader('Content-Type','application/json');xhr.onerror=function(){KAMPYLE_EVENT_DISPATCHER.trigger('neb_afterHttpPostRequestOnError',{postData:xhr.status});if(typeof callback==='function'){callback();}else{return;}}
- xhr.onload=function(){if(xhr.status===200){var data=KAMPYLE_UTILS.safeJsonParse(xhr.responseText);if(typeof callback==='function'){callback(null,data);}else{return;}}else{KAMPYLE_EVENT_DISPATCHER.trigger('neb_afterHttpPostRequest',{postData:xhr.status});if(typeof callback==='function'){callback(xhr.status);}else{return;}}};xhr.send(JSON.stringify(postRequestData.postData));},lowerize:function(str){return str.toLowerCase();},trim:function(str){return str.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,'');},getDeviceTypeByUserAgent:function(agent){var FUNC_TYPE='function',MODEL='model',OBJ_TYPE='object',TYPE='type',VENDOR='vendor',CONSOLE='console',MOBILE='mobile',TABLET='tablet',SMARTTV='smarttv',WEARABLE='wearable',DESKTOP='desktop';var device={};var arrays=[[/\((ipad|playbook);[\w\s\);-]+(rim|apple)/i],[MODEL,VENDOR,[TYPE,TABLET]],[/applecoremedia\/[\w\.]+ \((ipad)/],[MODEL,[VENDOR,'Apple'],[TYPE,TABLET]],[/(archos)\s(gamepad2?)/i,/(hp).+(touchpad)/i,/(hp).+(tablet)/i,/(kindle)\/([\w\.]+)/i,/\s(nook)[\w\s]+build\/(\w+)/i,/(dell)\s(strea[kpr\s\d]*[\dko])/i,/SHIELD Tablet/,/A500/,/LG-V410\/V41020c/,/Puffin/,/^(?!.*Mobile).*Android.*$/],[VENDOR,MODEL,[TYPE,TABLET]],[/(kf[A-z]+)\sbuild\/[\w\.]+.*silk\//i],[MODEL,[VENDOR,'Amazon'],[TYPE,TABLET]],[/\((ip[honed|\s\w*]+);.+(apple)/i],[MODEL,VENDOR,[TYPE,MOBILE]],[/\((ip[honed|\s\w*]+);/i],[MODEL,[VENDOR,'Apple'],[TYPE,MOBILE]],[/(blackberry)[\s-]?(\w+)/i,/(blackberry|benq|palm(?=\-)|sonyericsson|acer|asus|dell|huawei|meizu|motorola|polytron)[\s_-]?([\w-]+)*/i,/(hp)\s([\w\s]+\w)/i,/(asus)-?(\w+)/i],[VENDOR,MODEL,[TYPE,MOBILE]],[/\(bb10;\s(\w+)/i],[MODEL,[VENDOR,'BlackBerry'],[TYPE,MOBILE]],[/android.+(transfo[prime\s]{4,10}\s\w+|eeepc|slider\s\w+|nexus 7|padfone)/i],[MODEL,[VENDOR,'Asus'],[TYPE,TABLET]],[/(sony)\s(tablet\s[ps])\sbuild\//i,/(sony)?(?:sgp.+)\sbuild\//i],[[VENDOR,'Sony'],[MODEL,'Xperia Tablet'],[TYPE,TABLET]],[/(?:sony)?(?:(?:(?:c|d)\d{4})|(?:so[-l].+))\sbuild\//i],[[VENDOR,'Sony'],[MODEL,'Xperia Phone'],[TYPE,MOBILE]],[/(lenovo)\s?(S(?:5000|6000)+(?:[-][\w+]))/i],[VENDOR,MODEL,[TYPE,TABLET]],[/(htc)[;_\s-]+([\w\s]+(?=\))|\w+)*/i,/(zte)-(\w+)*/i,/(alcatel|geeksphone|huawei|lenovo|nexian|panasonic|(?=;\s)sony)[_\s-]?([\w-]+)*/i],[VENDOR,[MODEL,/_/g,' '],[TYPE,MOBILE]],[/(nexus\s9)/i],[MODEL,[VENDOR,'HTC'],[TYPE,TABLET]],[/(nexus\s6p)/i],[MODEL,[VENDOR,'Huawei'],[TYPE,MOBILE]],[/(microsoft);\s(lumia[\s\w]+)/i],[VENDOR,MODEL,[TYPE,MOBILE]],[/(kin\.[onetw]{3})/i],[[MODEL,/\./g,' '],[VENDOR,'Microsoft'],[TYPE,MOBILE]],[/\s(milestone|droid(?:[2-4x]|\s(?:bionic|x2|pro|razr))?(:?\s4g)?)[\w\s]+build\//i,/mot[\s-]?(\w+)*/i,/(XT\d{3,4}) build\//i,/(nexus\s6)/i],[MODEL,[VENDOR,'Motorola'],[TYPE,MOBILE]],[/android.+\s(mz60\d|xoom[\s2]{0,2})\sbuild\//i],[MODEL,[VENDOR,'Motorola'],[TYPE,TABLET]],[/android.+((sch-i[89]0\d|shw-m380s|gt-p\d{4}|gt-n\d+|sgh-t8[56]9|nexus 10))/i,/((SM-T\w+))/i],[[VENDOR,'Samsung'],MODEL,[TYPE,TABLET]],[/smart-tv.+(samsung)/i],[VENDOR,[TYPE,SMARTTV],MODEL],[/((s[cgp]h-\w+|gt-\w+|galaxy\snexus|sm-\w[\w\d]+))/i,/(sam[sung]*)[\s-]*(\w+-?[\w-]*)*/i,/sec-((sgh\w+))/i],[[VENDOR,'Samsung'],MODEL,[TYPE,MOBILE]],[/sie-(\w+)*/i],[MODEL,[VENDOR,'Siemens'],[TYPE,MOBILE]],[/(maemo|nokia).*(n900|lumia\s\d+)/i,/(nokia)[\s_-]?([\w-]+)*/i],[[VENDOR,'Nokia'],MODEL,[TYPE,MOBILE]],[/android\s3\.[\s\w;-]{10}(a\d{3})/i],[MODEL,[VENDOR,'Acer'],[TYPE,TABLET]],[/android\s3\.[\s\w;-]{10}(lg?)-([06cv9]{3,4})/i],[[VENDOR,'LG'],MODEL,[TYPE,TABLET]],[/(nexus\s[45])/i,/lg[e;\s\/-]+(\w+)*/i],[MODEL,[VENDOR,'LG'],[TYPE,MOBILE]],[/android.+(ideatab[a-z0-9\-\s]+)/i],[MODEL,[VENDOR,'Lenovo'],[TYPE,TABLET]],[/linux;.+((jolla));/i],[VENDOR,MODEL,[TYPE,MOBILE]],[/android.+;\s(oppo)\s?([\w\s]+)\sbuild/i],[VENDOR,MODEL,[TYPE,MOBILE]],[/android.+;\s(pixel c)\s/i],[MODEL,[VENDOR,'Google'],[TYPE,TABLET]],[/android.+;\s(pixel xl|pixel)\s/i],[MODEL,[VENDOR,'Google'],[TYPE,MOBILE]],[/android.+(\w+)\s+build\/hm\1/i,/android.+(hm[\s\-_]*note?[\s_]*(?:\d\w)?)\s+build/i,/android.+(mi[\s\-_]*(?:one|one[\s_]plus|note lte)?[\s_]*(?:\d\w)?)\s+build/i],[[MODEL,/_/g,' '],[VENDOR,'Xiaomi'],[TYPE,MOBILE]],[/android.+a000(1)\s+build/i],[MODEL,[VENDOR,'OnePlus'],[TYPE,MOBILE]],[/\s(tablet)[;\/]/i,/\s(mobile)(?:[;\/]|\ssafari)/i],[[TYPE,KAMPYLE_UTILS.lowerize],VENDOR,MODEL],[/Mobile|iP(hone|od|ad)|(Android).*(Mobile|sdk)|BlackBerry|portalmmm|BOLT|Vodafone|WindowsCE|IEMobile|Kindle|NetFront|Silk-Accelerated|(hpw|web)OS|Fennec|Minimo|Opera M(obi|ini)|Blazer|Dolfin|Dolphin|Skyfire|Zune/],[VENDOR,MODEL,[TYPE,MOBILE]],];var ua=agent||navigator.userAgent;var i=0,j,k,p,q,matches,match;while(i<arrays.length&&!matches){var regex=arrays[i],props=arrays[i+1];j=k=0;while(j<regex.length&&!matches){matches=regex[j++].exec(ua);if(!!matches){for(p=0;p<props.length;p++){match=matches[++k];q=props[p];if(typeof q===OBJ_TYPE&&q.length>0){if(q.length==2){if(typeof q[1]==FUNC_TYPE){device[q[0]]=q[1].call(device,match);}else{device[q[0]]=q[1];}}else if(q.length==3){if(typeof q[1]===FUNC_TYPE&&!(q[1].exec&&q[1].test)){device[q[0]]=match?q[1].call(device,match,q[2]):undefined;}else{device[q[0]]=match?match.replace(q[1],q[2]):undefined;}}else if(q.length==4){device[q[0]]=match?q[3].call(device,match.replace(q[1],q[2])):undefined;}}else{device[q]=match?match:undefined;}}}}
- i+=2;}
- if(!device[TYPE]||(device[TYPE]!==MOBILE&&device[TYPE]!==TABLET)){return DESKTOP;}
- return device[TYPE];},getElementStyle:function(domElement,styleProperty){if(domElement instanceof HTMLElement){try{return window.getComputedStyle(domElement).getPropertyValue(styleProperty);}catch(err){}}
- return null;},isTruthy:function(expression){if(typeof expression!=='string'){return expression;}
- try{expression=JSON.parse(expression);}catch(err){}
- return expression;},safeJsonParse:function(str,msgOnFail){try{return JSON.parse(str);}catch(e){KAMPYLE_UTILS.showWarning(msgOnFail?msgOnFail:'Failed to parse JSON, error message: '+(e||{}).message);KAMPYLE_UTILS.showErrorStack(e||{});return null;}},scrollToLastPosition:function(){var position=KAMPYLE_DATA.getMemoryData('scrollPosition');if(position){window.scroll(position.x,position.y);KAMPYLE_DATA.deleteMemoryData('scrollPosition');}},setCurrentScrollPosition:function(){if(document.body!==document.activeElement){return false;}
- var axis=KAMPYLE_UTILS.getScrollPosition()||{};KAMPYLE_DATA.setMemoryData('scrollPosition',{x:axis.x,y:axis.y});},getScrollPosition:function(){var isPageOffsetSupported=window.pageXOffset!==undefined;var isCSS1Compat=((document.compatMode||"")==="CSS1Compat");var x=isPageOffsetSupported?window.pageXOffset:isCSS1Compat?document.documentElement.scrollLeft:document.body.scrollLeft;var y=isPageOffsetSupported?window.pageYOffset:isCSS1Compat?document.documentElement.scrollTop:document.body.scrollTop;return{x:x,y:y}},getStrigifiedData:function(data){var strigifyData;if(typeof data==='object'&&data!==null){try{strigifyData=JSON.stringify(data);}
- catch(err){strigifyData=data;}}
- else{strigifyData=data;}
- return strigifyData;},appendScript:function(scriptSrc){var s=document.createElement('script');s.src=scriptSrc;document.body.appendChild(s);},toBase64:function(str){str=str||'';return btoa(unescape(encodeURIComponent(str)));},styleObjToInline:function(styleObj){var inlineStyle='';for(var prop in styleObj){inlineStyle+=prop+':'+styleObj[prop]+';';}
- return inlineStyle;},getBaseUrl:function(){return location.origin+location.pathname;},generateUUID:function(){var seed=Date.now();if(window.performance&&typeof window.performance.now==='function'){seed+=performance.now();}
- var UUID='xxxx-xxxx-xxxx-xxxx-xxxx-xxxx-xxxx-xxxx'.replace(/[x]/g,function(){var random=(seed+Math.random()*16)%16|0;seed=Math.floor(seed/16);return random.toString(16);});return UUID;},getRetryTimeout:function(){var dataJson=KAMPYLE_DATA.getMemoryData('dataJson');return KAMPYLE_UTILS.getNestedPropertyValue(dataJson,'retryTimout')||KAMPYLE_CONSTANT.NETWORK.RETRY_TIMEOUT;},};window.KAMPYLE_EVENT_DISPATCHER=(function(window,document){var eventSubscriptions;function init(){eventSubscriptions={};}
- function getEventSubscriptions(eventName){if(eventName&&eventSubscriptions&&eventSubscriptions[eventName]){return eventSubscriptions[eventName];}
- else{return eventSubscriptions;}};var unsubscribe=function(eventName,callback){if(!eventName||typeof eventName!=='string'||!callback||typeof callback!=='function'){return false;}
- var subscribers=eventSubscriptions[eventName];if(typeof subscribers!=='undefined'){var callbackIndex=subscribers.indexOf(callback);if(callbackIndex!==-1)
- {subscribers.splice(callbackIndex,1);}}
- return true;};var subscribe=function(eventName,callback){if(!eventName||typeof eventName!=='string'||!callback||(typeof callback!=='function'&&typeof callback!=='string')){return false;}
- var subscribers=eventSubscriptions[eventName];if(typeof subscribers==='undefined'){subscribers=eventSubscriptions[eventName]=[];}
- var callbackIndex=subscribers.indexOf(callback);if(callbackIndex===-1)
- {subscribers.push(callback);}
- return true;};function appendDefaultEventParams(data){data=data||{};var allData=KAMPYLE_FUNC.kampyleGetData();var defaultValues={};if(allData){defaultValues={'accountId':allData.accountId,'websiteId':allData.websiteId,'enviroment':allData.region};}
- return Object.assign(data,defaultValues);}
- var trigger=function(eventName,data,context,options){var subscribers=eventSubscriptions[eventName];var i,iMax;if(typeof subscribers==='undefined'){return false;}
- data=appendDefaultEventParams(data);var dataAsArray=(data instanceof Array)?data:[data];context=context||null;iMax=subscribers.length;for(i=0;i<iMax;i+=1){if(typeof subscribers[i]==='string'){KAMPYLE_UTILS.triggerCustomEvent(subscribers[i]);}
- else{try{subscribers[i].apply(context,[eventName].concat(dataAsArray));}catch(e){KAMPYLE_UTILS.showErrorStack(e);if(window.KAMPYLE_COOLADATA){if(data){data.errorMessage=e.message;data.errorStack=e.stack;KAMPYLE_COOLADATA.triggerCooladataEventDispatcherError(data);}}
- if(options&&options.isStrictMode){break;}
- continue;}}}
- return true;};var subscribeMany=function(eventMapping){for(var eventName in eventMapping){if(eventMapping.hasOwnProperty(eventName)){for(var i=0;i<eventMapping[eventName].length;i++){subscribe(eventName,eventMapping[eventName][i]);}}}};function subscribeOnce(eventName,callback){var subscribers=getEventSubscriptions(eventName);if(!subscribers[eventName]||subscribers.indexOf(callback)===-1){subscribe(eventName,callback);}}
- return{subscribe:subscribe,subscribeOnce:subscribeOnce,subscribeMany:subscribeMany,trigger:trigger,unsubscribe:unsubscribe,init:init,getEventSubscriptions:getEventSubscriptions,appendDefaultEventParams:appendDefaultEventParams}})(window,document);window.MDIGITAL_OnPrem=(function(){var onPremRelatedPaths=['formHtmlUrl','buttonData.buttonUrl','formDataUrl','inviteData.inviteUrl','inviteData.inviteDataUrl'];function isOnPrem(){var isOnPrem=KAMPYLE_UTILS.getNestedPropertyValue(window,'KAMPYLE_EMBED.isOnPrem');return!!(KAMPYLE_FUNC.checkProvision(KAMPYLE_CONSTANT.PROVISIONS.ON_PREM_HYBRID)&&(typeof isOnPrem==='function'&&isOnPrem()));}
- function resolveAbsolutePath(relativePath){if(!window.KAMPYLE_EMBED||!window.KAMPYLE_EMBED.getResourcesPrefix()){return relativePath;}else{return window.KAMPYLE_EMBED.getResourcesPrefix()+relativePath;}}
- function getPackageRoot(){return isOnPrem()?window.KAMPYLE_EMBED.getResourcesPrefix():null;}
- function getPackageVersion(){if(KAMPYLE_DATA&&KAMPYLE_DATA.getMemoryData('dataJson')){return KAMPYLE_DATA.getMemoryData('dataJson').packageVersion;}
- else{return null;}}
- function replaceOnPremPrefixes(rawText){rawText=rawText||'';var formattedText;if(rawText.indexOf(KAMPYLE_CONSTANT.ONPREM_URL_PREFIX)===-1){return rawText;}
- else{var formattedText=rawText.replace(KAMPYLE_CONSTANT.ONPREM_URL_PREFIX,KAMPYLE_EMBED.getResourcesPrefix());return formattedText;}}
- function replaceFormNodeUrls(node){if(!node){return false;}
- onPremRelatedPaths.forEach(function(path){var pathValue=KAMPYLE_UTILS.getNestedPropertyValue(node,path);if(pathValue){KAMPYLE_UTILS.setNestedPropertyValue(node,path,replaceOnPremPrefixes(pathValue))}});return node;}
- return{resolveAbsolutePath:resolveAbsolutePath,getPackageVersion:getPackageVersion,getPackageRoot:getPackageRoot,replaceFormNodeUrls:replaceFormNodeUrls,isOnPrem:isOnPrem,};})();window.MDIGITAL=window.MDIGITAL||{};window.MDIGITAL.EMBEDDED=(function(window,document){function init(){var eventMapping={neb_loadForm:[createEmbeddedIframe],neb_formLoaded:[showForm],neb_iFrameHeightChanged:[calculateFormSize],neb_formClosed:[deleteEmbeddedIframe],MDigital_ThankYou_Displayed:[handleThankyouPage]};KAMPYLE_EVENT_DISPATCHER.subscribeMany(eventMapping);}
- function isEmbeddedFullWidth(formId){var formData=KAMPYLE_DATA.getFormData(formId);return KAMPYLE_UTILS.getNestedPropertyValue(formData,'isFullWidthEmbedded');}
- function createEmbeddedIframe(eventName,data){data=data||{};if(!KAMPYLE_DATA.isEmbeddedDisplayType(data.formId)){return false;}
- var hostingElement=getHostingElement(data.formId);if(!isHostingElementValid(hostingElement)){return false;}
- if(hostingElement){var hostingElementHeight=parseInt(getComputedStyle(hostingElement).height);addHostingElementHeight(hostingElement.id,hostingElementHeight);}
- setTimeout(function(){if(!KAMPYLE_FUNC.isFormLoaded(data.formId)){KAMPYLE_EVENT_DISPATCHER.trigger(KAMPYLE_CONSTANT.EVENTS.NEB_FORM_LOADING_HAS_FAILED,{formId:data.formId})}},KAMPYLE_CONSTANT.NETWORK.TIME_FOR_FORM_TO_LOAD_MS);var formIframe=getOrCreateIframe(KAMPYLE_CONSTANT.EMBEDDED.IFRAME_ID_PREFIX+data.formId);var formData=KAMPYLE_DATA.getFormData(data.formId);formIframe.src=KAMPYLE_COMMON.createFormUrl(formData.formHtmlUrl,data.formId);hostingElement.appendChild(formIframe);KAMPYLE_DATA.setFormState(data.formId,{shouldBeShown:true});return true;}
- function showForm(eventName,data){if(!KAMPYLE_DATA.isEmbeddedDisplayType(data.formId)||KAMPYLE_FUNC.hasApplicationLoadingFailed(data.formId)){return false;}
- var currIframe=document.getElementById(KAMPYLE_CONSTANT.EMBEDDED.IFRAME_ID_PREFIX+data.formId);if(!!currIframe){setIframeStyle(currIframe,{display:'block'});}
- return true;}
- function isHostingElementValid(element){return element!==null&&(!element.innerHTML||(typeof element.innerHTML==='string'&&element.innerHTML.trim()===""));}
- function getHostingElement(formId){var formData=KAMPYLE_DATA.getFormData(formId);return document.getElementById(KAMPYLE_UTILS.getNestedPropertyValue(formData,'embeddedData.pageElementId'));}
- function getOrCreateIframe(iframeId){var formIframe=document.getElementById(iframeId);if(!formIframe){formIframe=document.createElement('iframe');formIframe.id=iframeId;formIframe.setAttribute('title','Feedback Survey');setIframeStyle(formIframe,{display:'none'})}
- return formIframe;}
- function setIframeStyle(formIframe,style){var defaultStyle={border:0,width:'100%',height:'100%'};var formattedStyle=Object.assign({},defaultStyle,style);KAMPYLE_UTILS.setElementStyle(formIframe,formattedStyle,false);}
- function calculateFormSize(event,data){data=data||{};var formData=KAMPYLE_DATA.getFormData(data.formId)||{};var hostingElement=getHostingElement(data.formId);var formIframe=document.getElementById(KAMPYLE_CONSTANT.EMBEDDED.IFRAME_ID_PREFIX+data.formId);if(!KAMPYLE_DATA.isEmbeddedDisplayType(data.formId)||hostingElement===null||formIframe===null){return false;}
- var newHeightSettings=calculateHeights(hostingElement,formData,data);var newWidth=calculateWidth(hostingElement,formData);var iframeStyle={height:newHeightSettings.iframeHeight+'px',width:isEmbeddedFullWidth(data.formId)?'100%':newWidth+'px'}
- setIframeStyle(formIframe,iframeStyle);var messageData={height:newHeightSettings.formHeight,width:newWidth,shouldBeStatic:newHeightSettings.shouldBeStatic};KAMPYLE_UTILS.sendMessageToIframe(KAMPYLE_CONSTANT.EMBEDDED.IFRAME_ID_PREFIX+data.formId,{action:'setFormStyle',data:messageData,});return messageData;}
- function calculateHeights(hostingElement,formData,data){var isStatic=formData.isFixedSize==='true'||formData.isFixedSize===true;var shouldBeStatic=isStatic;var formHeight=isStatic?parseInt(formData.formHeight):data.newHeight;var hostingElementComputedStyle=getComputedStyle(hostingElement);var hostHeight=getHostingElementHeight(hostingElement.id);hostHeight=isNaN(hostHeight)?parseInt(hostingElement.style.height||0):hostHeight;var hostMaxHeight=isNaN(parseInt(hostingElementComputedStyle.maxHeight))?(hostHeight||0):parseInt(hostingElementComputedStyle.maxHeight);var hostMinHeight=isNaN(parseInt(hostingElementComputedStyle.minHeight))?0:parseInt(hostingElementComputedStyle.minHeight);var isDynamicHost=hostMaxHeight===0&&hostMinHeight===0;if(hostMaxHeight!==0&&hostMinHeight>hostMaxHeight){hostMaxHeight=hostMinHeight;}
- return getNewHeightSettings(formHeight,shouldBeStatic,isDynamicHost,hostMaxHeight,hostMinHeight,hostHeight);}
- function getNewHeightSettings(formHeight,shouldBeStatic,isDynamicHost,hostMaxHeight,hostMinHeight,hostHeight){var newIframeHeight;var newFormHeight=formHeight;if(isDynamicHost){newFormHeight=formHeight;newIframeHeight=newFormHeight;}
- else{if(hostMaxHeight!==0&&formHeight>=hostMaxHeight){newFormHeight=hostMaxHeight;shouldBeStatic=true;}
- newIframeHeight=newFormHeight;if(formHeight<hostMinHeight||formHeight<hostHeight){newIframeHeight=hostMinHeight!==0?hostMinHeight:hostHeight;}}
- return{formHeight:newFormHeight,iframeHeight:newIframeHeight,shouldBeStatic:shouldBeStatic}}
- function calculateWidth(hostingElement,formData){var formWidth=parseInt(formData.formWidth);return Math.min(formWidth,KAMPYLE_UTILS.getElementSize(hostingElement).width);}
- function deleteEmbeddedIframe(eventName,data){if(!KAMPYLE_DATA.isEmbeddedDisplayType(data.formId)){return false;}
- var currIframe=document.getElementById(KAMPYLE_CONSTANT.EMBEDDED.IFRAME_ID_PREFIX+data.formId);if(currIframe===null){return false;}
- KAMPYLE_UTILS.removeAllContent(currIframe);return true;}
- function addHostingElementHeight(elementId,height){var elementsHeightsObj=KAMPYLE_DATA.getMemoryData('hostingElementsHeights');elementsHeightsObj[elementId]=height;KAMPYLE_DATA.setMemoryData('hostingElementsHeights',elementsHeightsObj);}
- function getHostingElementHeight(elementId){return KAMPYLE_DATA.getMemoryData('hostingElementsHeights')[elementId]||0;}
- function handleThankyouPage(eventName,data){data=data||{};if(KAMPYLE_DATA.isEmbeddedDisplayType(data.formId)&&KAMPYLE_DATA.isMobile()){KAMPYLE_VIEW.scrollToEmbeddedForm(data.formId);}}
- return{init:init,createEmbeddedIframe:createEmbeddedIframe,showForm:showForm,calculateFormSize:calculateFormSize,deleteEmbeddedIframe:deleteEmbeddedIframe,addHostingElementHeight:addHostingElementHeight,getHostingElementHeight:getHostingElementHeight,handleThankyouPage:handleThankyouPage,};})(window,document);window.MDIGITAL=window.MDIGITAL||{};window.MDIGITAL.FORM_STATE=(function(window,document){function init(){var eventMapping={MDigital_targetingRuleEvaluated:[updateTargetingState],};KAMPYLE_EVENT_DISPATCHER.subscribeMany(eventMapping);}
- function updateTargetingState(eventName,data){if(!canUpdateState(data)){return false;}
- var formState=KAMPYLE_DATA.getFormState(data.formId);var phaseRules=[].concat(formState.targeting[data.targetingPhase]||[]);phaseRules.push(getRuleData(data));var targetingPhaseState={};targetingPhaseState[data.targetingPhase]=phaseRules;KAMPYLE_DATA.setFormState(data.formId,{targeting:targetingPhaseState});}
- function isInviteLoaded(formId){var formState=KAMPYLE_DATA.getFormState(formId);return!!formState&&!!formState.inviteLoaded;}
- function isFormLoaded(formId){var formState=KAMPYLE_DATA.getFormState(formId);return!!formState&&!!formState.loaded}
- function shouldFormBeShown(formId){var formState=KAMPYLE_DATA.getFormState(formId);return formState&&formState.shouldBeShown;}
- function isFormAlreadyShown(formId){var formState=KAMPYLE_DATA.getFormState(formId);return formState&&formState.shown;}
- function getRuleData(data){var ruleData={targetingRule:"",isPassed:false,expected:"",actual:"",};Object.keys(ruleData).forEach(function(property){ruleData[property]=data[property];});return ruleData;}
- function canUpdateState(data){data=data||{};var formState=KAMPYLE_DATA.getFormState(data.formId);return!(!formState||!formState.targeting||!data.targetingPhase);}
- return{init:init,updateTargetingState:updateTargetingState,getRuleData:getRuleData,canUpdateState:canUpdateState,shouldFormBeShown:shouldFormBeShown,isFormLoaded:isFormLoaded,isInviteLoaded:isInviteLoaded,isFormAlreadyShown:isFormAlreadyShown,};})(window,document);window.KAMPYLE_COMMON=(function(window,document){var screenCaptureTooltipStyles='[data-tips]{position:relative;text-decoration:none}[data-tips]:after,[data-tips]:before{position:absolute;z-index:100;opacity:0}[data-tips]:after{content:attr(data-tips);line-height:20px;padding:0 10px;font-size:12px;text-align:center;color:#fff;background:#222;border-radius:5px;text-shadow:0 0 5px #000;-moz-box-shadow:0 0 5px rgba(0, 0, 0, .3);-webkit-box-shadow:0 0 5px rgba(0, 0, 0, .3);box-shadow:0 0 5px rgba(0, 0, 0, .3);white-space:normal;-moz-box-sizing:border-box;-webkit-box-sizing:border-box;box-sizing:border-box;width:135px;word-wrap:break-word}[data-tips]:before{content:"";width:0;height:0;border-width:6px;border-style:solid}[data-tips]:hover:after,[data-tips]:hover:before{opacity:1}[data-tips].top-tip:after,[data-tips].top-tip:before{-webkit-transition:bottom .25s ease-in-out, opacity .25s ease-in-out;-moz-transition:bottom .25s ease-in-out, opacity .25s ease-in-out;transition:bottom .25s ease-in-out, opacity .25s ease-in-out;bottom:90%;left:-9999px;margin-bottom:12px}[data-tips].top-tip:before{border-color:#222 transparent transparent;margin-bottom:0}[data-tips].top-tip:hover:after,[data-tips].top-tip:hover:before{bottom:100%;left:0}[data-tips].top-tip:hover:before{left:15px}[data-tips].bottom-tip:after,[data-tips].bottom-tip:before{-webkit-transition:top .25s ease-in-out, opacity .25s ease-in-out;-moz-transition:top .25s ease-in-out, opacity .25s ease-in-out;transition:top .25s ease-in-out, opacity .25s ease-in-out;top:90%;left:-9999px;margin-top:12px}[data-tips].bottom-tip:before{border-color:transparent transparent #222;margin-top:0}[data-tips].bottom-tip:hover:after,[data-tips].bottom-tip:hover:before{top:100%;left:0}[data-tips].bottom-tip:hover:before{left:15px}[data-tips].left-tip:after,[data-tips].left-tip:before{-webkit-transition:left .25s ease-in-out, opacity .25s ease-in-out;-moz-transition:left .25s ease-in-out, opacity .25s ease-in-out;transition:left .25s ease-in-out, opacity .25s ease-in-out;top:-9999px;left:96%;margin-left:12px}[data-tips].left-tip:before{border-color:transparent #222 transparent transparent;margin-left:0}[data-tips].left-tip:hover:after,[data-tips].left-tip:hover:before{left:100%;top:0}[data-tips].left-tip:hover:before{top:7px}[data-tips].right-tip:after,[data-tips].right-tip:before{-webkit-transition:right .25s ease-in-out, opacity .25s ease-in-out;-moz-transition:right .25s ease-in-out, opacity .25s ease-in-out;transition:right .25s ease-in-out, opacity .25s ease-in-out;top:-9999px;right:96%;margin-right:12px}[data-tips].right-tip:before{border-color:transparent transparent transparent #222;margin-right:0}[data-tips].right-tip:hover:after,[data-tips].right-tip:hover:before{right:100%;top:0}[data-tips].right-tip:hover:before{top:7px}';var screenCaptureButtonsOutlineStyle='.scTitle:focus, .scParagraph:focus, .sc-widget-footer-cancel:focus, .sc-widget-footer-capture:focus, p:focus { border: 2px solid #8e8e93 !important; box-shadow: 0 0 7px #8e8e93 !important;}';var SCREEN_CAPTURE_DEFAULT_TEXTS={submitScreenCaptureLabel:'Capture Image',cancelScreenCaptureLabel:'Cancel',instructionsScreenCapture:'<h2 class="scTitle" style="font-size: 1.5em;">Screen Capture</h2><p class="scParagraph" style="font-size: 1em; margin-top: 10px;">Drag the cursor around the area you want to highlight.<br>Press Capture Image to take the snapshot and return to your feedback</p>',submitScreenCaptureTooltip:'Take snapshot',cancelScreenCaptureTooltip:'Back to Feedback',};var screenCaptureWidgetTemplate=['<html>','<head>','<link rel="stylesheet" type="text/css" href="'+KAMPYLE_CONSTANT.PLACEHOLDERS.URL_PREFIX+KAMPYLE_CONSTANT.SRC.OPEN_SANS+'" />','<script type="text/javascript">','function resizeIframe() {','parent.document.getElementById("nebScIframe").height = document.getElementById("sc-widget").scrollHeight + 15;','var SCWidget = parent.document.getElementById("nebScIframe");','if (SCWidget) {','SCWidget.focus();','}','}','</script>','<style>{tooltipStyles} {buttonsOutlineStyle}</style>','</head>','<body onload="resizeIframe();" style="margin:0px;overflow:hidden;">','<div id="sc-widget" class="sc-widget" style="{widget}">','<div class="sc-widget-content" style="{widgetContent}">','{{instructionsScreenCapture}}','</div>','<div class="sc-widget-footer" style="{widgetFooter}">','<button onclick="parent.KAMPYLE_COMMON.cancelScreenCapture();" class="sc-widget-footer-cancel top-tip" '+'data-tips="{{cancelScreenCaptureTooltip}}" style="{widgetFooterBtn} {widgetFooterCancel}">','{{cancelScreenCaptureLabel}}','</button>','<button onclick="parent.KAMPYLE_COMMON.screenCaptureClicked();" class="sc-widget-footer-capture top-tip" '+'data-tips="{{submitScreenCaptureTooltip}}" style="{widgetFooterBtn} {widgetFooterCapture}">','<img alt="Loading" src="'+KAMPYLE_CONSTANT.PLACEHOLDERS.URL_PREFIX+KAMPYLE_CONSTANT.SRC.KLOADER+'" id="widgetFooterCaptureImg" style="width:20px;height:20px;display: none;" />','<span id="widgetFooterCaptureText">{{submitScreenCaptureLabel}}</span>','</button>','</div>','</div>','</body></html>',].join(' ');var defaultStyles={overlay:{'position':'fixed','top':'0','left':'0','z-index':'2147483646 !important','right':'0','bottom':'0','display':'block','pointer-events':'none'},widget:{'font-family':'\'Open Sans\'','border':'1px solid #999','width':'285px','border-radius':'5px','position':'absolute','z-index':'2147483647 !important','pointer-events':'auto','background':'#FFFFFF','text-align':'center','line-height':'20px'},widgetContent:{'padding':'10px 14px','outline':'none'},widgetFooter:{'font-family':'\'Open Sans\' !important','padding':'10px','font-size':'14px','padding-top':'0','font-stretch':'normal','font-style':'normal','font-variant':'normal','font-weight':'normal','letter-spacing':'normal','line-height':'20px'},widgetFooterBtn:{'height':'34px','margin':'0 0 2px 5px','min-width':'100px','padding':'6px 12px','display':'inline-block','border-radius':'4px','cursor':'pointer','transition-delay':'0s','transition-duration':'0.3s','transition-property':'all','transition-timing-function':'ease','vertical-align':'middle','white-space':'nowrap','word-spacing':'0px','border':'none','color':'#FFF',},widgetFooterCancel:{'background':'#A2A2A2','color':'#FFF'},widgetFooterCapture:{'margin-left':'5px','background':'#020202','color':'#FFF'}};function overrideDefaultScreenCaptureStyles(customSettings){var res=defaultStyles;if(!!customSettings){res.widget.background=!!customSettings.backgroundColor?customSettings.backgroundColor:res.widget.background;res.widgetFooterCapture.background=!!customSettings.submitButtoncolor?customSettings.submitButtoncolor:res.widgetFooterCapture.background;res.widgetFooterCancel.background=!!customSettings.closeButtoncolor?customSettings.closeButtoncolor:res.widgetFooterCancel.background;res.widgetFooterCancel.color=!!customSettings.closeButtonTextColor?customSettings.closeButtonTextColor:res.widgetFooterBtn.color;res.widgetFooterCapture.color=!!customSettings.submitButtonTextColor?customSettings.submitButtonTextColor:res.widgetFooterBtn.color;}
- return res;}
- function overrideDefaultScreenCaptureTexts(customSettings){var res=SCREEN_CAPTURE_DEFAULT_TEXTS;if(!!customSettings){for(var prop in res){if(customSettings.hasOwnProperty(prop)&&res.hasOwnProperty(prop)){res[prop]=customSettings[prop];}}
- return res;}};function loadForm(formId){return KAMPYLE_ONSITE_SDK.loadForm(formId);}
- function showForm(formId,options){return KAMPYLE_ONSITE_SDK.showForm(formId,options);}
- function closeForm(formId){KAMPYLE_EVENT_DISPATCHER.trigger('neb_formClosed',{formId:formId});}
- function createFormUrl(url,formId){url+='?formId='+formId;url+='&type=live';var fullUrl=window.location.href;var splitted=fullUrl.split('?');if(splitted&&splitted.length){fullUrl=splitted[0];}
- url+='&referrer='+encodeURIComponent(fullUrl);var region=KAMPYLE_DATA.getMemoryData('region');if(region){url+='®ion='+region;}
- if(KAMPYLE_DATA.isFeatureEnabled('WCAG')){url+='&isWCAG=true';}
- url+='&displayType='+KAMPYLE_DATA.getDisplayType(KAMPYLE_DATA.getFormData(formId));return url;}
- function showScreenCaptureSpinner(){var iframeDocument=document.getElementById('nebScIframe').contentDocument;var spinner=iframeDocument.getElementById('widgetFooterCaptureImg');if(!!spinner){spinner.style.display='inline';var text=iframeDocument.getElementById('widgetFooterCaptureText');if(!!text){text.style.display='none';}}};function isScreenCaptureEnabled(formId){var browser=KAMPYLE_UTILS.getBrowser();var formJson=KAMPYLE_DATA.getFormData(formId);if(!formJson){return false;}
- var displayType=KAMPYLE_DATA.getDisplayType(formJson);return!!browser&&(browser.name!=='MSIE'||Number(browser.version)>8)&&!!displayType&&displayType!=='popup';};function formatScreenCaptureWidget(formData){formData=formData||{};var widgetHtml=screenCaptureWidgetTemplate;var formattedText=overrideDefaultScreenCaptureTexts(formData.screenCaptureSettings);if(!formattedText||!formattedText.submitScreenCaptureTooltip){widgetHtml=widgetHtml.replace('data-tips="{{submitScreenCaptureTooltip}}"','');}
- if(!formattedText||!formattedText.cancelScreenCaptureTooltip){widgetHtml=widgetHtml.replace('data-tips="{{cancelScreenCaptureTooltip}}"','');}
- for(var prop in formattedText){if(SCREEN_CAPTURE_DEFAULT_TEXTS.hasOwnProperty(prop)){widgetHtml=widgetHtml.replace('{{'+prop+'}}',SCREEN_CAPTURE_DEFAULT_TEXTS[prop]);}}
- var formattedStyles=overrideDefaultScreenCaptureStyles(formData.screenCaptureSettings);for(var element in formattedStyles){widgetHtml=KAMPYLE_UTILS.replaceAll(widgetHtml,'{'+element+'}',KAMPYLE_UTILS.styleObjToInline(defaultStyles[element]));}
- widgetHtml=widgetHtml.replace('{tooltipStyles}',screenCaptureTooltipStyles).replace('{buttonsOutlineStyle}',screenCaptureButtonsOutlineStyle);return KAMPYLE_UTILS.htmlDecode(widgetHtml);}
- function createScreenCaptureWidget(formData,scContainer){if(!KAMPYLE_FUNC.checkProvision(KAMPYLE_CONSTANT.PROVISIONS.CSP_RULES)){var widgetHtml=formatScreenCaptureWidget(formData);var scIframe=document.createElement('iframe');scIframe.id='nebScIframe';KAMPYLE_UTILS.setElementStyle(scIframe,{width:'310px',bottom:'20px',left:'20px',zIndex:2147483647,position:'fixed',});KAMPYLE_UTILS.setElementStyle(scIframe,{display:'block'},true);scIframe.frameBorder='0';scIframe.sandbox='allow-top-navigation allow-same-origin allow-scripts';if(scContainer){scContainer.parentNode.insertBefore(scIframe,scContainer);}
- else{document.body.appendChild(scIframe);}
- if(scIframe.contentWindow){scIframe.contentWindow.contents=widgetHtml;}
- scIframe.src='javascript:window["contents"]';setTimeout(function(){document.activeElement.blur();},100);return true;}}
- function cancelScreenCapture(){KAMPYLE_EVENT_DISPATCHER.trigger('neb_cancelCaptureClicked',{formId:KAMPYLE_DATA.getMemoryData('currentFormId'),feedbackUUID:KAMPYLE_DATA.getMemoryData('currentFeedbackUuid'),});}
- function screenCaptureClicked(){showScreenCaptureSpinner();}
- return{loadForm:loadForm,showForm:showForm,closeForm:closeForm,createFormUrl:createFormUrl,createScreenCaptureWidget:createScreenCaptureWidget,isScreenCaptureEnabled:isScreenCaptureEnabled,cancelScreenCapture:cancelScreenCapture,screenCaptureClicked:screenCaptureClicked,overrideDefaultScreenCaptureStyles:overrideDefaultScreenCaptureStyles,formatScreenCaptureWidget:formatScreenCaptureWidget,overrideDefaultScreenCaptureTexts:overrideDefaultScreenCaptureTexts,};})(window,document);window.KAMPYLE_THERMO_TEALEAF_FUNC=(function(){var TEALEAF_COOKIE_SESSION_ID='TLTSID';function isTealeafEnabled(){return!!KAMPYLE_UTILS.kampyleGetCookie(TEALEAF_COOKIE_SESSION_ID);}
- function getTealeafData(){if(KAMPYLE_THERMO_TEALEAF_FUNC.isTealeafEnabled()){return{sid:KAMPYLE_UTILS.kampyleGetCookie(TEALEAF_COOKIE_SESSION_ID),};}
- return null;}
- return{isTealeafEnabled:isTealeafEnabled,getTealeafData:getTealeafData,};})();window.KAMPYLE_CLICKTALE_FUNC=(function(){function isClicktaleEnabled(){return(!!window.ClickTale&&!!window.ClickTale.KampyleLink);};function getClicktaleData(){if(KAMPYLE_CLICKTALE_FUNC.isClicktaleEnabled()){if(window.ClickTale.KampyleLink!=='NOT_RECORDING'){var clicktaleData={recordingUrl:window.ClickTale.KampyleLink};return clicktaleData;}}
- return null;}
- return{isClicktaleEnabled:isClicktaleEnabled,getClicktaleData:getClicktaleData};})();window.KAMPYLE_SESSIONCAM={isSessionCamEnabled:function(){return(!!window.sessionCamRecorder);},getSessionCamData:function(){if(KAMPYLE_SESSIONCAM.isSessionCamEnabled()){var sessionId=window.sessionCamRecorder.sessionId();if(!!sessionId){var sessionCamData={recordingUrl:"https://console.sessioncam.com/Console/Recordings/PlaybackSession?sessionId="+sessionId};return sessionCamData;}}
- return null;},sendCustomParam:function(key,value){window.sessioncamConfiguration=window.sessioncamConfiguration||{};window.sessioncamConfiguration.customDataObjects=window.sessioncamConfiguration.customDataObjects||[];var item={key:key,value:value};window.sessioncamConfiguration.customDataObjects.push(item);},init:function(){KAMPYLE_EVENT_DISPATCHER.subscribe("neb_feedbackSubmitted",this.sessionCamFormSubmittedCallback);},sessionCamFormSubmittedCallback:function(eventName,oData){if(eventName!=='neb_feedbackSubmitted'){return;}
- KAMPYLE_SESSIONCAM.sendCustomParam("nebula_feedback_uuid",oData.feedbackUUID);}};window.KAMPYLE_ONSITE_SDK=(function(window,document){function loadForm(formId){var formState=KAMPYLE_DATA.getFormState(formId);if(!formState){KAMPYLE_UTILS.showWarning('Error fetching data for form id '+formId);return false;}
- if(!formState.loaded){KAMPYLE_EVENT_DISPATCHER.trigger('neb_sdkLoadForm',{formId:formId});KAMPYLE_EVENT_DISPATCHER.trigger('neb_loadForm',{formId:formId});}
- return true;}
- function showForm(formId,options){options=options||{};var formState=KAMPYLE_DATA.getFormState(formId);if(!formState){KAMPYLE_UTILS.showWarning('Error fetching data for form id '+formId);return false;}
- if(KAMPYLE_DATA.getMemoryData('inviteLoadedAndShown')){KAMPYLE_UTILS.showWarning('There is already an invite displayed');return false;}
- if(KAMPYLE_FUNC.isAnyOtherFormAlreadyShown(formId,true)){KAMPYLE_UTILS.showWarning('There is already a form displayed');return false;}
- if(!formState.loaded){loadForm(formId);}
- options.triggerType=options.triggerType||'ByCode';KAMPYLE_DATA.saveFormExtraData(formId,options);var extraData={formId:formId,};for(var prop in options){if(options.hasOwnProperty(prop)){extraData[prop]=options[prop];}}
- KAMPYLE_EVENT_DISPATCHER.trigger('neb_sdkShowForm',{formId:formId,triggerType:options.triggerType});return true;}
- function updatePageView(){KAMPYLE_EVENT_DISPATCHER.trigger('neb_sdkPageView');}
- function isSurveyDisplayed(){if(KAMPYLE_FUNC.isAnyInviteShown()||KAMPYLE_FUNC.isAnyOtherFormAlreadyShown()){return true;}
- KAMPYLE_EVENT_DISPATCHER.trigger('neb_sdkSurveyDisplayed');return false;}
- function startInviteTargeting(){if(!KAMPYLE_DATA.isFeatureEnabled(KAMPYLE_CONSTANT.PROPERTY_SETTINGS.MANUALLY_INVITE_TARGETING)){KAMPYLE_UTILS.showWarning('Manually invite targeting feature is disabled');return false;}
- KAMPYLE_EVENT_DISPATCHER.trigger(KAMPYLE_CONSTANT.EVENTS.MDIGITAL_MANUALLY_INVITE_TARGETING,{skipButtonTargeting:true,skipInviteTargeting:false});}
- return{loadForm:loadForm,showForm:showForm,updatePageView:updatePageView,isSurveyDisplayed:isSurveyDisplayed,startInviteTargeting:startInviteTargeting,};})(window,document);window.KAMPYLE_POLYFILLS=(function(window,document){if(!Array.prototype.includes){Object.defineProperty(Array.prototype,'includes',{value:function(searchElement,fromIndex){if(this==null){throw new TypeError('"this" is null or not defined');}
- var o=Object(this);var len=o.length>>>0;if(len===0){return false;}
- var n=fromIndex|0;var k=Math.max(n>=0?n:len-Math.abs(n),0);function sameValueZero(x,y){return x===y||(typeof x==='number'&&typeof y==='number'&&isNaN(x)&&isNaN(y));}
- while(k<len){if(sameValueZero(o[k],searchElement)){return true;}
- k++;}
- return false;},});}
- if(!String.prototype.includes){String.prototype.includes=function(search,start){'use strict';if(typeof start!=='number'){start=0;}
- if(start+search.length>this.length){return false;}else{return this.indexOf(search,start)!==-1;}};}
- if(!String.prototype.startsWith){Object.defineProperty(String.prototype,'startsWith',{value:function(search,pos){pos=!pos||pos<0?0:+pos;return this.substring(pos,pos+search.length)===search;}});}
- if(!Array.prototype.find){Object.defineProperty(Array.prototype,'find',{value:function(predicate){if(this==null){throw new TypeError('"this" is null or not defined');}
- var o=Object(this);var len=o.length>>>0;if(typeof predicate!=='function'){throw new TypeError('predicate must be a function');}
- var thisArg=arguments[1];var k=0;while(k<len){var kValue=o[k];if(predicate.call(thisArg,kValue,k,o)){return kValue;}
- k++;}
- return undefined;},});}
- if(typeof Object.assign!='function'){Object.assign=function(target,varArgs){if(target==null){throw new TypeError('Cannot convert undefined or null to object');}
- var to=Object(target);for(var index=1;index<arguments.length;index++){var nextSource=arguments[index];if(nextSource!=null){for(var nextKey in nextSource){if(Object.prototype.hasOwnProperty.call(nextSource,nextKey)){to[nextKey]=nextSource[nextKey];}}}}
- return to;};}
- if(!Array.prototype.indexOf){Array.prototype.indexOf=function(searchElement,fromIndex){var k;if(this==null){throw new TypeError('"this" is null or not defined');}
- var o=Object(this);var len=o.length>>>0;if(len===0){return-1;}
- var n=+fromIndex||0;if(Math.abs(n)===Infinity){n=0;}
- if(n>=len){return-1;}
- k=Math.max(n>=0?n:len-Math.abs(n),0);while(k<len){if(k in o&&o[k]===searchElement){return k;}
- k++;}
- return-1;};}
- if(!Array.prototype.filter){Array.prototype.filter=function(fun){'use strict';if(this===void 0||this===null){throw new TypeError();}
- var t=Object(this);var len=t.length>>>0;if(typeof fun!=='function'){throw new TypeError();}
- var res=[];var thisArg=arguments.length>=2?arguments[1]:void 0;for(var i=0;i<len;i++){if(i in t){var val=t[i];if(fun.call(thisArg,val,i,t)){res.push(val);}}}
- return res;};}
- if(!Array.prototype.forEach){Array.prototype.forEach=function(callback){var T,k;if(this==null){throw new TypeError('this is null or not defined');}
- var O=Object(this);var len=O.length>>>0;if(typeof callback!=='function'){throw new TypeError(callback+' is not a function');}
- if(arguments.length>1){T=arguments[1];}
- k=0;while(k<len){var kValue;if(k in O){kValue=O[k];callback.call(T,kValue,k,O);}
- k++;}};}
- if(!window.JSON){window.JSON={parse:function(sJSON){return eval('('+sJSON+')');},stringify:(function(){var toString=Object.prototype.toString;var isArray=Array.isArray||function(a){return toString.call(a)==='[object Array]';};var escMap={'"':'\\"','\\':'\\\\','\b':'\\b','\f':'\\f','\n':'\\n','\r':'\\r','\t':'\\t'};var escFunc=function(m){return escMap[m]||'\\u'+(m.charCodeAt(0)+0x10000).toString(16).substr(1);};var escRE=/[\\"\u0000-\u001F\u2028\u2029]/g;return function stringify(value){if(value==null){return'null';}else if(typeof value==='number'){return isFinite(value)?value.toString():'null';}else if(typeof value==='boolean'){return value.toString();}else if(typeof value==='object'){if(typeof value.toJSON==='function'){return stringify(value.toJSON());}else if(isArray(value)){var res='[';for(var i=0;i<value.length;i++)
- res+=(i?', ':'')+stringify(value[i]);return res+']';}else if(toString.call(value)==='[object Object]'){var tmp=[];for(var k in value){if(value.hasOwnProperty(k))
- tmp.push(stringify(k)+': '+stringify(value[k]));}
- return'{'+tmp.join(', ')+'}';}}
- return'"'+value.toString().replace(escRE,escFunc)+'"';};})(),};}
- if(!Date.now){Date.now=function now(){return new Date().getTime();};}
- if(typeof Object.assign!='function'){(function(){Object.assign=function(target){'use strict';if(target===undefined||target===null){throw new TypeError('Cannot convert undefined or null to object');}
- var output=Object(target);for(var index=1;index<arguments.length;index++){var source=arguments[index];if(source!==undefined&&source!==null){for(var nextKey in source){if(source.hasOwnProperty(nextKey)){output[nextKey]=source[nextKey];}}}}
- return output;};})();}
- if(!Array.prototype.some){Array.prototype.some=function(fun){'use strict';if(this==null){throw new TypeError('Array.prototype.some called on null or undefined');}
- if(typeof fun!=='function'){throw new TypeError();}
- var t=Object(this);var len=t.length>>>0;var thisArg=arguments.length>=2?arguments[1]:void 0;for(var i=0;i<len;i++){if(i in t&&fun.call(thisArg,t[i],i,t)){return true;}}
- return false;};}
- if(!Array.prototype.reduce){Object.defineProperty(Array.prototype,'reduce',{value:function(callback){if(this===null){throw new TypeError('Array.prototype.reduce '+'called on null or undefined');}
- if(typeof callback!=='function'){throw new TypeError(callback+' is not a function');}
- var o=Object(this);var len=o.length>>>0;var k=0;var value;if(arguments.length>=2){value=arguments[1];}else{while(k<len&&!(k in o)){k++;}
- if(k>=len){throw new TypeError('Reduce of empty array '+'with no initial value');}
- value=o[k++];}
- while(k<len){if(k in o){value=callback(value,o[k],k,o);}
- k++;}
- return value;}});}
- (function(){if(typeof window.CustomEvent==='function')return false;function CustomEvent(event,params){params=params||{bubbles:false,cancelable:false,detail:undefined};var evt=document.createEvent('CustomEvent');evt.initCustomEvent(event,params.bubbles,params.cancelable,params.detail);return evt;}
- CustomEvent.prototype=window.Event.prototype;window.CustomEvent=CustomEvent;})();})(window,document);if(!Array.prototype.findIndex){Object.defineProperty(Array.prototype,'findIndex',{value:function(predicate){if(this==null){throw new TypeError('"this" is null or not defined');}
- var o=Object(this);var len=o.length>>>0;if(typeof predicate!=='function'){throw new TypeError('predicate must be a function');}
- var thisArg=arguments[1];var k=0;while(k<len){var kValue=o[k];if(predicate.call(thisArg,kValue,k,o)){return k;}
- k++;}
- return-1;},});}
- if(!Element.prototype.remove){Element.prototype.remove=function remove(){if(this.parentNode){this.parentNode.removeChild(this);}};}
- if(!String.prototype.endsWith){String.prototype.endsWith=function(search,this_len){if(this_len===undefined||this_len>this.length){this_len=this.length;}
- return this.substring(this_len-search.length,this_len)===search;};}
- if(!Array.from){Array.from=(function(){var toStr=Object.prototype.toString;var isCallable=function(fn){return typeof fn==='function'||toStr.call(fn)==='[object Function]';};var toInteger=function(value){var number=Number(value);if(isNaN(number)){return 0;}
- if(number===0||!isFinite(number)){return number;}
- return(number>0?1:-1)*Math.floor(Math.abs(number));};var maxSafeInteger=Math.pow(2,53)-1;var toLength=function(value){var len=toInteger(value);return Math.min(Math.max(len,0),maxSafeInteger);};return function from(arrayLike){var C=this;var items=Object(arrayLike);if(arrayLike==null){throw new TypeError('Array.from requires an array-like object - not null or undefined');}
- var mapFn=arguments.length>1?arguments[1]:void undefined;var T;if(typeof mapFn!=='undefined'){if(!isCallable(mapFn)){throw new TypeError('Array.from: when provided, the second argument must be a function');}
- if(arguments.length>2){T=arguments[2];}}
- var len=toLength(items.length);var A=isCallable(C)?Object(new C(len)):new Array(len);var k=0;var kValue;while(k<len){kValue=items[k];if(mapFn){A[k]=typeof T==='undefined'?mapFn(kValue,k):mapFn.call(T,kValue,k);}else{A[k]=kValue;}
- k+=1;}
- A.length=len;return A;};}());}
- window.KAMPYLE_INTEGRATION=(function(){var INTEGRATION_CONTEXT={sessionCam:'sessionCamRecorder',quantumMetrics:'QuantumMetricAPI',};function getParameterBySource(getParamsBySourceParameters){switch(getParamsBySourceParameters.source){case'var':return KAMPYLE_UTILS.getNestedPropertyValue(window,getParamsBySourceParameters.param);case'cookie':return KAMPYLE_UTILS.kampyleGetCookie(getParamsBySourceParameters.param);case'function':var func=KAMPYLE_UTILS.getNestedPropertyValue(window,getParamsBySourceParameters.param);if(typeof func==='function'){try{var predefinedArgs=getParamsBySourceParameters.predefinedArgs;if(predefinedArgs){predefinedArgs=predefinedArgs.split(',');return(predefinedArgs instanceof Array)?func.apply(getParamsBySourceParameters.context,predefinedArgs):null;}
- else{return func.apply(getParamsBySourceParameters.context);}}
- catch(e){return null;}}
- else{return null;}
- case'url':return KAMPYLE_UTILS.getUrlParam(KAMPYLE_UTILS.getNestedPropertyValue(window,getParamsBySourceParameters.param));case'storage':return localStorage.getItem(KAMPYLE_UTILS.getNestedPropertyValue(window,getParamsBySourceParameters.param));default:}}
- function isEnabled(integrationData){var isEnabledBol=true;var valueBySource;var paramValue;var isEnabledArray=integrationData.isEnabled;var contextParam=INTEGRATION_CONTEXT[integrationData.integrationName];var integrationContext=KAMPYLE_UTILS.getNestedPropertyValue(window,contextParam);for(var i=0;i<isEnabledArray.length;i++){var isEnabledCurr=false;var isEnabledCurrName=isEnabledArray[i].param;paramValue=isEnabledArray[i].paramValue;if(!isEnabledCurrName){KAMPYLE_UTILS.showWarning('no current name found');}
- valueBySource=getParameterBySource({source:isEnabledArray[i].source,param:isEnabledCurrName,context:integrationContext,predefinedArgs:isEnabledArray[i].predefinedArguments});if(paramValue===null){isEnabledCurr=(valueBySource!==undefined&&valueBySource!==null);}
- else{isEnabledCurr=paramValue===valueBySource;}
- isEnabledBol=isEnabledBol&&isEnabledCurr;}
- return isEnabledBol;}
- function prepareIntegrationData(integrationData){var parametersJson={};var integrationDataJson={};var parametersArray=integrationData.parameters||[];var contextParam=INTEGRATION_CONTEXT[integrationData.integrationName]||null;var integrationContext=KAMPYLE_UTILS.getNestedPropertyValue(window,contextParam);for(var i=0;i<parametersArray.length;i++){var paramValue=getParameterBySource({source:parametersArray[i].source,param:parametersArray[i].param,context:integrationContext,predefinedArgs:parametersArray[i].predefinedArguments});var putIn=integrationData.parameters[i].putIn;KAMPYLE_UTILS.setNestedPropertyValue(parametersJson,putIn,paramValue);}
- integrationDataJson={integrationName:integrationData.integrationName,parameters:parametersJson,};return integrationDataJson;}
- function getIntegrationData(){var integrations=KAMPYLE_DATA.getInegrations()||{};var integrationData={};var currIntegration;for(var integrationType in integrations){if(integrations.hasOwnProperty(integrationType)){var currIntegrationType=integrations[integrationType];for(var i=0;i<currIntegrationType.length;i++){currIntegration=currIntegrationType[i];if(isEnabled(currIntegration)){integrationData[integrationType]=integrationData[integrationType]||[];integrationData[integrationType].push(prepareIntegrationData(currIntegration));}}}}
- return integrationData;}
- return{isEnabled:isEnabled,prepareIntegrationData:prepareIntegrationData,getParameterBySource:getParameterBySource,getIntegrationData:getIntegrationData,};})();window.MDIGITAL=window.MDIGITAL||{};window.MDIGITAL.CUSTOM_EVENTS=(function(){var FORM_ID='formId';var FORM_TRIGGER_TYPE='formTriggerType';var FEEDBACK_UUID='feedbackUUID';var FEEDBACK_CONTENT='content';var IS_PASSED='isPassed';var TARGETING_RULE='targetingRule';var EXPECTED='expected';var ACTUAL='actual';var customEvents={MDigital_Form_Close_Submitted:{customEventId:'MDigital_Form_Close_Submitted',payload:[FORM_ID,FORM_TRIGGER_TYPE]},neb_formReady:{customEventId:'MDigital_Form_Displayed',payload:[FORM_ID,FORM_TRIGGER_TYPE]},neb_pageView:{customEventId:'MDigital_Page_View',payload:[],},MDigital_Form_Next_Page:{customEventId:'MDigital_Form_Next_Page',payload:[FORM_ID,FORM_TRIGGER_TYPE]},MDigital_Form_Back_Page:{customEventId:'MDigital_Form_Back_Page',payload:[FORM_ID,FORM_TRIGGER_TYPE]},MDigital_Form_Close_No_Submit:{customEventId:'MDigital_Form_Close_No_Submit',payload:[FORM_ID,FORM_TRIGGER_TYPE]},MDigital_ThankYou_Displayed:{customEventId:'MDigital_ThankYou_Displayed',payload:[FORM_ID,FORM_TRIGGER_TYPE]},MDigital_ThankYou_Close:{customEventId:'MDigital_ThankYou_Close',payload:[FORM_ID,FORM_TRIGGER_TYPE,FEEDBACK_UUID]},neb_feedbackSubmitted:{customEventId:'MDigital_Submit_Feedback',payload:[FORM_ID,FORM_TRIGGER_TYPE,FEEDBACK_UUID].concat(KAMPYLE_FUNC.checkProvision(KAMPYLE_CONSTANT.PROVISIONS.EVENT_INCLUDE_FEEDBACK_CONTENT)?FEEDBACK_CONTENT:[])},neb_inviteAccepted:{customEventId:'MDigital_Invite_Accepted',payload:[FORM_ID]},neb_showInvitation:{customEventId:'MDigital_Invite_Displayed',payload:[FORM_ID]},neb_inviteDeclined:{customEventId:'MDigital_Invite_Declined',payload:[FORM_ID]},neb_skipInvitation:{customEventId:'MDigital_invite_Skipped',payload:[FORM_ID]},neb_buttonClicked:{customEventId:'MDigital_Feedback_Button_Clicked',payload:[FORM_ID,FORM_TRIGGER_TYPE]},neb_captureInit:{customEventId:'MDigital_CaptureButton_Clicked',payload:[FORM_ID,FORM_TRIGGER_TYPE,FEEDBACK_UUID]},neb_captureImageClicked:{customEventId:'MDigital_CaptureButton_Taken',payload:[FORM_ID,FORM_TRIGGER_TYPE,FEEDBACK_UUID]},neb_cancelCaptureClicked:{customEventId:'MDigital_CaptureButton_Cancel',payload:[FORM_ID,FORM_TRIGGER_TYPE,FEEDBACK_UUID]},neb_sdkShowForm:{customEventId:'MDigital_ShowForm_Called',payload:[FORM_ID,FORM_TRIGGER_TYPE]},MDigital_targetingRuleEvaluated:{customEventId:'MDigital_targetingRuleEvaluated',payload:[FORM_ID,IS_PASSED,TARGETING_RULE,EXPECTED,ACTUAL,FORM_TRIGGER_TYPE],},};var dataToSendMapping={formId:{exposedProperty:KAMPYLE_CONSTANT.EXPOSED_FORM_ID_LABEL,manipulateValueMethod:null},formTriggerType:{exposedProperty:KAMPYLE_CONSTANT.EXPOSED_FORM_TYPE_LABEL,manipulateValueMethod:manipulateTriggerTypeValue},feedbackUUID:{exposedProperty:KAMPYLE_CONSTANT.EXPOSED_FEEDBACK_UUID_LABEL,manipulateValueMethod:null},content:{exposedProperty:KAMPYLE_CONSTANT.EXPOSED_FEEDBACK_CONTENT_LABEL,manipulateValueMethod:null,}}
- function init(){try{KAMPYLE_UTILS.initEventSubscriptions(customEvents,triggerCustomEvent);return true;}catch(e){console.warn(e);}}
- function formatData(eventName,eventDispatcherData){if(!eventName||!eventDispatcherData){return null;}
- for(var eventProp in customEvents[eventName]){if(customEvents[eventName].hasOwnProperty(eventProp)){eventDispatcherData[eventProp]=customEvents[eventName][eventProp];}}
- eventDispatcherData.eventName=eventName;eventDispatcherData.formTriggerType=KAMPYLE_DATA.getFormTriggerType(eventDispatcherData.formId);return eventDispatcherData;}
- function triggerCustomEvent(eventName,eventDispatcherData){var eventDispatcherDataFormatted=formatData(eventName,eventDispatcherData);var customEventData=getCustomEventDataToSend(eventDispatcherDataFormatted);if(customEventData){KAMPYLE_UTILS.triggerCustomEvent(eventDispatcherDataFormatted.customEventId,customEventData);}};function getCustomEventDataToSend(eventDispatcherDataFormatted){var dataToSend={};if(!eventDispatcherDataFormatted||!eventDispatcherDataFormatted.payload){return null;}
- for(var i=0;i<eventDispatcherDataFormatted.payload.length;i++){var payloadProperty=eventDispatcherDataFormatted.payload[i];var payloadValue=KAMPYLE_UTILS.getNestedPropertyValue(eventDispatcherDataFormatted,payloadProperty);var mappingObject;if(payloadValue!==undefined&&payloadValue!==null){mappingObject=dataToSendMapping[payloadProperty];if(mappingObject&&mappingObject.exposedProperty){dataToSend[mappingObject.exposedProperty]=mappingObject.manipulateValueMethod?mappingObject.manipulateValueMethod.apply(this,[payloadValue]):payloadValue;}else{dataToSend[payloadProperty]=payloadValue;}}else{dataToSend=null;break;}}
- return dataToSend;}
- function manipulateTriggerTypeValue(formTriggerType){return KAMPYLE_CONSTANT.FORM_TRIGGER_TYPES_MAP[formTriggerType]||KAMPYLE_CONSTANT.CUSTOM_EVENT_OTHER;}
- return{init:init,triggerCustomEvent:triggerCustomEvent,getCustomEventDataToSend:getCustomEventDataToSend,};})();window.MDIGITAL=window.MDIGITAL||{};window.MDIGITAL.CUSTOM_PARAMETERS=(function(window,document){function getCustomParamValue(customParam){if(!KAMPYLE_FUNC.checkProvision(KAMPYLE_CONSTANT.PROVISIONS.CP_EXT_REFACTOR)){return KAMPYLE_FUNC.getSafeCustomParamVal(customParam)}
- var cp=customParam||{};var extractedValue=MDIGITAL.CUSTOM_PARAMETERS.extractCPValue(cp);return MDIGITAL.CUSTOM_PARAMETERS.castCPValue(extractedValue,cp.type||'');}
- function formatCustomParams(formId){var customParams=MDIGITAL.CUSTOM_PARAMETERS.getFormCustomParams(formId)||[];return customParams.map(MDIGITAL.CUSTOM_PARAMETERS.appendValueToCPObject);}
- function getFormCustomParams(formId){var formData=KAMPYLE_DATA.getFormData(formId)||{};return formData.customParams||null;}
- function hasCustomParams(formId){var formData=KAMPYLE_DATA.getFormData(formId);return!!formData&&!!formData.customParams&&!!formData.customParams.length;}
- function getCustomParamValueById(id,formData){var customParam=MDIGITAL.CUSTOM_PARAMETERS.getCustomParamById(id,formData)||{};return MDIGITAL.CUSTOM_PARAMETERS.getCustomParamValue(customParam);}
- function getCustomParamValueByUniqueName(uniqueName){var customParam=MDIGITAL.CUSTOM_PARAMETERS.getCustomParamByUniqueName(uniqueName)||{};return MDIGITAL.CUSTOM_PARAMETERS.getCustomParamValue(customParam);}
- function getCustomParamById(fieldId,formData){if(fieldId!==undefined&&formData&&formData.customParams&&formData.customParams.length){return formData.customParams.find(function(cp){return cp.id==fieldId;})||null;}
- else{return null;}}
- function getCustomParamByUniqueName(uniqueName){var customParams=KAMPYLE_DATA.getCustomParams()||[];return customParams.find(function(cp){return cp.unique_name===uniqueName;});}
- function extractCPValue(cp){var value=cp.value;var source=(cp.source||'var').toLowerCase();var name=cp.name||cp.source_name||'';if(value===undefined){switch(source){case'var':value=KAMPYLE_UTILS.getNestedPropertyValue(window,name);break;case'url':value=KAMPYLE_UTILS.getUrlParam(name);break;case'cookie':value=KAMPYLE_UTILS.getCookie(name);break;default:value=null;break;}}
- return value!==''?value:null;}
- function castCPValue(value,type){if(value===null){return value;}
- switch(type.toLowerCase()){case'datetime':return MDIGITAL.CUSTOM_PARAMETERS.handleDatetimeCasting(value);case'number':return KAMPYLE_UTILS.getNumericValue(value)
- case'text':return MDIGITAL.CUSTOM_PARAMETERS.handleTextCasting(value);case'boolean':return MDIGITAL.CUSTOM_PARAMETERS.handleBooleanCasting(value);default:console.error('Invalid custom parameter type '+type);return null;}}
- function handleDatetimeCasting(value){if(typeof value==='string'){return Number(value)||null;}else if(!(value instanceof Date)&&(!(value||{}).getTime||isNaN(value.getTime()))){return null;}else{return value.getTime();}}
- function handleTextCasting(value){return(typeof value==='string')?value:null;}
- function handleBooleanCasting(value){if(value==='true'){return true;}else if(value==='false'){return false}
- return(typeof value==='boolean')?value:null;}
- function appendValueToCPObject(cp){cp=cp||{};var cpValue=MDIGITAL.CUSTOM_PARAMETERS.getCustomParamValue({name:cp.source_name,type:cp.type,source:cp.source,});return Object.assign(cp,{value:cpValue});}
- return{getCustomParamValue:getCustomParamValue,getCustomParamValueById:getCustomParamValueById,getCustomParamValueByUniqueName:getCustomParamValueByUniqueName,formatCustomParams:formatCustomParams,getFormCustomParams:getFormCustomParams,hasCustomParams:hasCustomParams,getCustomParamById:getCustomParamById,getCustomParamByUniqueName:getCustomParamByUniqueName,extractCPValue:extractCPValue,castCPValue:castCPValue,handleDatetimeCasting:handleDatetimeCasting,handleTextCasting:handleTextCasting,handleBooleanCasting:handleBooleanCasting,appendValueToCPObject:appendValueToCPObject,};})(window,document);KAMPYLE_FUNC.init();KAMPYLE_FUNC.startCheckingTargeting();
Editor
You can edit this paste and save as new: