Created
November 21, 2019 11:28
-
-
Save ericdevries/fd99cad8ffae07e7e5f679afae9ec771 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| * | |
| * DTC Media implement OTM | |
| * | |
| * Author: DTC Media | |
| * Description: Generic script for implement the Online Taxation Module (3.0) | |
| * | |
| */ | |
| (function(d) { | |
| if (typeof dtcOtmBaseUrl !== 'undefined' && dtcOtmBaseUrl === '') { | |
| console.log('Variabele "dtcOtmBaseUrl" is leeg! Deze moet ingevuld zijn om de OTM in te kunnen laden.'); | |
| return; | |
| } | |
| if (typeof dtcOtmCampaignKey !== 'undefined' && dtcOtmCampaignKey === '') { | |
| console.log('Variabele "dtcOtmCampaignKey" is leeg! Deze moet ingevuld zijn om de OTM in te kunnen laden.'); | |
| return; | |
| } | |
| function getURLParameter(name) { return decodeURIComponent((new RegExp('[?|&]' + name + '=' + '([^&;]+?)(&|#|;|$)').exec(location.search)||[,''])[1].replace(/\+/g, '%20'))||'' } | |
| function buildQueryString(urlParams) { return Object.keys(urlParams).map(function(param){return encodeURIComponent(param) + '=' + encodeURIComponent(urlParams[param]);}).join('&'); } | |
| const possibleParams = ['kenteken', 'kenmerk', 'appraisalID', 'hash', 'merk', 'model','uitvoering', 'did', 'dgid']; | |
| const urlParams = (function() { const params = {}; for( var index = 0, paramsLength = possibleParams.length; index < paramsLength; index++ ) { const key = possibleParams[index]; if( ( val = getURLParameter(key)) != '') { params[key] = val.split('_').join(' '); }} return params; })(); | |
| if (typeof dtcOtmIdentifier !== 'undefined' && dtcOtmIdentifier !== '') { | |
| urlParams['kenmerk'] = dtcOtmIdentifier; | |
| } | |
| if (typeof dtcOtmBrandPreselect !== 'undefined' && dtcOtmBrandPreselect !== '') { | |
| urlParams['merk'] = dtcOtmBrandPreselect; | |
| } | |
| if (typeof dtcOtmModelPreselect !== 'undefined' && dtcOtmModelPreselect !== '') { | |
| urlParams['model'] = dtcOtmModelPreselect; | |
| } | |
| if (typeof dtcOtmTrimPreselect !== 'undefined' && dtcOtmTrimPreselect !== '') { | |
| urlParams['uitvoering'] = dtcOtmTrimPreselect; | |
| } | |
| if (typeof dtcOtmDidPreselect !== 'undefined' && dtcOtmDidPreselect !== '') { | |
| urlParams['did'] = dtcOtmDidPreselect; | |
| } | |
| if (typeof dtcOtmDgidPreselect !== 'undefined' && dtcOtmDgidPreselect !== '') { | |
| urlParams['dgid'] = dtcOtmDgidPreselect; | |
| } | |
| const otmParams = (Object.keys(urlParams).length !== 0) ? '?' + buildQueryString(urlParams) : ''; | |
| const otmUrl = dtcOtmBaseUrl + '/campagne/' + dtcOtmCampaignKey + '/' + otmParams; | |
| d.getElementById('taxatie_iframe_container').style.width='100%'; | |
| // d.getElementById('taxatie_iframe_container').style.minHeight='100%'; | |
| otmIframe = d.createElement('iframe'); | |
| otmIframe.style.width = '100%'; | |
| otmIframe.style.height = '100%'; | |
| otmIframe.style.border = '0'; | |
| otmIframe.style.overflow = 'hidden'; | |
| otmIframe.src = otmUrl; | |
| d.getElementById('taxatie_iframe_container').appendChild(otmIframe); | |
| })(document); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment