This shows you the differences between two versions of the page.
Both sides previous revision Previous revision | |||
public:apps:preorder:manual_installation [17.05.21 в 11:47] Дария Тяжлова |
public:apps:preorder:manual_installation [17.03.22 в 04:29] (current) Дария Тяжлова |
||
---|---|---|---|
Line 52: | Line 52: | ||
</script> | </script> | ||
- | <script src="{{ 'simple-preorder-data.js' | asset_url }}" defer="defer"></script> | + | <script id="kad-preorder-config-loader"> |
- | <script src="https://preorder.kad.systems/scripts/NAME-OF-YOUR-SHOP.myshopify.com.js" defer="defer"></script> | + | (() => { |
- | <script src="{{ 'simple-preorder.js' | asset_url }}" defer="defer"></script> | + | try { |
+ | function loadPersonalConfig() { | ||
+ | let personalConfig = localStorage.getItem('SimplePreorderBootstrap') | ||
+ | if (typeof personalConfig === 'string') { | ||
+ | return JSON.parse(personalConfig) | ||
+ | } | ||
+ | } | ||
+ | |||
+ | function savePersonalConfig(config) { | ||
+ | localStorage.setItem('SimplePreorderBootstrap', JSON.stringify(config, null, 2)) | ||
+ | } | ||
+ | |||
+ | function isDevParamSpecified() { | ||
+ | return new URLSearchParams(window.location.search).get('kad-dev') !== null | ||
+ | } | ||
+ | |||
+ | let personalConfig = loadPersonalConfig() | ||
+ | |||
+ | if (isDevParamSpecified()) { | ||
+ | personalConfig = personalConfig || {} | ||
+ | personalConfig.dev = true | ||
+ | } | ||
+ | |||
+ | if (personalConfig) { | ||
+ | Object.assign(SimplePreorderBootstrap, personalConfig) | ||
+ | savePersonalConfig(personalConfig) | ||
+ | } | ||
+ | } catch (err) {} | ||
+ | })() | ||
+ | </script> | ||
+ | |||
+ | <script id="kad-preorder-injector"> | ||
+ | (() => { | ||
+ | let lastScript = document.getElementById('kad-preorder-injector') | ||
+ | |||
+ | function injectScript(url, type) { | ||
+ | const script = document.createElement('script') | ||
+ | script.src = url | ||
+ | script.type = type || '' | ||
+ | script.async = false | ||
+ | script.defer = true | ||
+ | lastScript = lastScript.parentNode.insertBefore(script, lastScript.nextSibling) | ||
+ | } | ||
+ | |||
+ | if (SimplePreorderBootstrap.dev && SimplePreorderBootstrap.devScriptUrl) { | ||
+ | injectScript(SimplePreorderBootstrap.devScriptUrl, SimplePreorderBootstrap.devScriptType) | ||
+ | } | ||
+ | |||
+ | if (SimplePreorderBootstrap.dataScriptUrl) { | ||
+ | injectScript(SimplePreorderBootstrap.dataScriptUrl, SimplePreorderBootstrap.dataScriptType) | ||
+ | } | ||
+ | |||
+ | if (SimplePreorderBootstrap.settingsScriptUrl) { | ||
+ | injectScript(SimplePreorderBootstrap.settingsScriptUrl, SimplePreorderBootstrap.settingsScriptType) | ||
+ | } | ||
+ | |||
+ | if (SimplePreorderBootstrap.appScriptUrl) { | ||
+ | injectScript(SimplePreorderBootstrap.appScriptUrl, SimplePreorderBootstrap.appScriptType) | ||
+ | } | ||
+ | })() | ||
+ | </script> | ||
</code> | </code> | ||