-
Notifications
You must be signed in to change notification settings - Fork 1
/
global.js
57 lines (52 loc) · 2.42 KB
/
global.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
(async () => {
console.log(`
██╗ ██╗███████╗██████╗ ██████╗ ██████╗ ███████╗██╗ ██╗███████╗
██║ ██║██╔════╝██╔══██╗██╔═══██╗██╔══██╗██╔════╝██║ ██║██╔════╝
███████║█████╗ ██████╔╝██║ ██║██║ ██║█████╗ ██║ ██║███████╗
██╔══██║██╔══╝ ██╔══██╗██║ ██║██║ ██║██╔══╝ ╚██╗ ██╔╝╚════██║
██║ ██║███████╗██║ ██║╚██████╔╝██████╔╝███████╗ ╚████╔╝ ███████║
╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝ ╚═════╝ ╚═════╝ ╚══════╝ ╚═══╝ ╚══════╝
`);
window.HD = {
IS_PROD:
window.location.href.toLowerCase().indexOf('www.herodevs.com') > -1,
};
const HD_CONF = {
LIB_SCRIPTS: ['hubspot.js'],
SCRIPT: {
ENV: window.HD.IS_PROD ? 'main' : 'staging',
PATH: `https://raw.githubusercontent.com/herodevs/webflow/${window.HD.IS_PROD ? 'main' : 'staging'}/scripts`,
},
FEATURES: [],
};
console.log(`BOOTING [${window.HD.IS_PROD ? 'PRODUCTION' : 'STAGING'}]`);
// LOAD HELPERS
for (let script of HD_CONF.LIB_SCRIPTS) {
loadScript(script, `${HD_CONF.SCRIPT.PATH}/helpers/${script}`);
}
// LOAD FEATURES
for (let { page, script } of HD_CONF.FEATURES) {
if (page) {
// CONDITIONALLY RENDER BASED ON PAGE
} else {
// LOAD FOR ALL PAGES
loadScript(script, `${HD_CONF.SCRIPT.PATH}/features/${script}`);
}
}
function loadScript(name, script) {
console.log(`[${name}]: Loading`);
$.ajax({
type: 'GET',
url: script,
cache: false,
error: () => console.error(`[${name}]: Loading failed`),
success: data => {
const scriptElem = document.createElement('script');
scriptElem.innerHTML = data;
scriptElem.setAttribute('type', 'text/javascript');
document.body.appendChild(scriptElem);
console.log(`[${name}]: Loaded`);
},
});
}
})();