@postnord/pn-marketweb-components 2.0.6-beta5 → 2.0.6-beta8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -5,42 +5,19 @@
|
|
|
5
5
|
}
|
|
6
6
|
document.body.dataset["marketwebComponentsSalesforceInit"] = true;
|
|
7
7
|
|
|
8
|
-
const checkParameters = function(originSrc) {
|
|
9
|
-
if (!originSrc.indexOf('?')) {
|
|
10
|
-
return;
|
|
11
|
-
}
|
|
12
|
-
const originalQueryString = originSrc.substring(originSrc.indexOf('?') + 1);
|
|
13
|
-
const originalParams = new URLSearchParams(originalQueryString);
|
|
14
|
-
const injectElements = originalParams.get('inject').split(',').map(function(item) { return item.trim(); });
|
|
15
|
-
injectElements.forEach(function(element) {
|
|
16
|
-
const s = document.createElement('script');
|
|
17
|
-
let injectSrc = originSrc.replace('pn-marketweb-init.js', 'pn-marketweb-inject.js');
|
|
18
|
-
injectSrc = injectSrc.substring(0, injectSrc.indexOf('?'));
|
|
19
|
-
const params = new URLSearchParams(originalQueryString);
|
|
20
|
-
params.delete('inject');
|
|
21
|
-
params.set('inject', element);
|
|
22
|
-
|
|
23
|
-
if (element.indexOf('header') !== -1) {
|
|
24
|
-
params.set('domlocation', 'top');
|
|
25
|
-
}
|
|
26
|
-
if (element.indexOf('footer') !== -1) {
|
|
27
|
-
params.set('domlocation', 'bottom');
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
s.setAttribute("src", `${injectSrc}?${params.toString()}`);
|
|
31
|
-
document.querySelector("head").appendChild(s);
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
|
|
35
8
|
const s = document.createElement('script');
|
|
36
|
-
// const currentScriptTag = document.querySelector('script[src*="pn-marketweb-init.js"]');
|
|
37
|
-
// const currentScriptSrc = currentScriptTag.getAttribute('src');
|
|
38
|
-
|
|
39
|
-
const currentScriptSrc = 'https://unpkg.com/@postnord/pn-marketweb-components@latest/umd/pn-marketweb-salesforce.js?market=se&language=en&inject=pn-marketweb-siteheader,pn-marketweb-sitefooter,cssoverride';
|
|
40
|
-
checkParameters(currentScriptSrc);
|
|
41
|
-
const loaderScriptSrc = currentScriptSrc.replace('pn-marketweb-salesforce.js', 'standalone-loader.js');
|
|
42
9
|
s.setAttribute("type", "module");
|
|
43
|
-
s.setAttribute("src",
|
|
10
|
+
s.setAttribute("src", "https://unpkg.com/@postnord/pn-marketweb-components@2.0.6-beta8/umd/standalone-loader-salesforce.js");
|
|
44
11
|
document.querySelector("head").appendChild(s);
|
|
45
|
-
|
|
12
|
+
|
|
13
|
+
const unlockScripts = function() {
|
|
14
|
+
const blockedScripts = [...document.querySelectorAll('[data-locker-src]:not([src])')];
|
|
15
|
+
if (blockedScripts && blockedScripts.length > 0) {
|
|
16
|
+
blockedScripts.forEach((item) => {
|
|
17
|
+
item.setAttribute('src', item.getAttribute('data-locker-src'))
|
|
18
|
+
});
|
|
19
|
+
window.clearInterval(window["marketwebComponentsSalesforce-timer"]);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
window["marketwebComponentsSalesforce-timer"] = window.setInterval(unlockScripts, 100);
|
|
46
23
|
})();
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/*
|
|
2
|
+
# No webpack loader
|
|
3
|
+
See the documentation in readme.md on how to properly setup this script.
|
|
4
|
+
You need to change the relative directories as well as the resourceUrl property to make files load from the correct directories.
|
|
5
|
+
|
|
6
|
+
<script type="module" src="/scripts/no-webpack-loader.js"></script>
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import './modules/@webcomponents/custom-elements/src/native-shim.js';
|
|
10
|
+
import { defineCustomElements as defineCustomElementsMarketWeb } from '../esm-es5/loader.js';
|
|
11
|
+
import { defineCustomElements } from './modules/@postnord/web-components/esm-es5/loader.js';
|
|
12
|
+
|
|
13
|
+
window['marketweb-components'] = {};
|
|
14
|
+
window['marketweb-components']['defineCustomElementsMarketWeb'] = defineCustomElementsMarketWeb;
|
|
15
|
+
window['marketweb-components']['defineCustomElements'] = defineCustomElements;
|
|
16
|
+
console.log("window['marketweb-components']", window['marketweb-components'])
|
|
17
|
+
(function(){
|
|
18
|
+
if (typeof defineCustomElements === "undefined") {
|
|
19
|
+
return
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const header = document.createElement('pn-marketweb-header');
|
|
23
|
+
const footer = document.createElement('pn-marketweb-footer');
|
|
24
|
+
|
|
25
|
+
[header, footer].forEach((comp) => {
|
|
26
|
+
comp.setAttribute('market', 'dk');
|
|
27
|
+
comp.setAttribute('language', 'da');
|
|
28
|
+
})
|
|
29
|
+
document.body.insertBefore(header, document.body.firstElementChild);
|
|
30
|
+
document.body.appendChild(footer);
|
|
31
|
+
|
|
32
|
+
window['marketweb-components']['defineCustomElements'](window, { resourcesUrl: '/scripts/' });
|
|
33
|
+
window['marketweb-components']['defineCustomElementsMarketWeb'](window, { resourcesUrl: '/scripts/' });
|
|
34
|
+
})();
|