-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.js
97 lines (74 loc) · 3.24 KB
/
main.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
/*
for material components
- install material component - no need in our case cause we installed for all material-web-components
- import - such as - import { MDCRipple } from '@material/ripple/index';
- assosiate w/ DOM element - such as - const ripple = new MDCRipple(document.querySelector('.foo-button'));
*/
import {MDCRipple} from '@material/ripple/index';
[].slice.call(document.querySelectorAll('.mdc-button'))
.forEach(function(ele) {
MDCRipple.attachTo(ele);
});
/*
Adjust dynamic routing: when you click Get Started button, you need to redirect to core-app link considering dev,
release, demo and prod!
*/
function parseDomainName(url) {
let a = document.createElement('a');
a.href = url;
return a.hostname;
}
const domainName = parseDomainName(window.document.URL);
const hostName = domainName.substr(domainName.indexOf('.'));
const route = {'development': 'https://core-app-abcde.firebaseapp.com',
'release': 'https://core-app-12345.firebaseapp.com',
'demon': 'define a url', //demo :)
'www': 'https://core-app.cardbase.io', // production
'localhost': 'https://core-app-xyzkm.firebaseapp.com', // route 2 development, why not
'learnMore': '/learn-more-about-......html' //define naming b/w your idea and SEO
}
document.querySelector('.getStarted')
.addEventListener('click', ()=> {
console.log('clicked to getStarted');
console.log(window.document.URL);
if (domainName.startsWith('development')) {
console.log('environment = development');
console.log(route.development);
window.open(route.development);
}
else if(domainName.startsWith('release')) {
console.log('environment = release');
window.open(route.release);
}
else if(domainName.startsWith('demo') ||
domainName.startsWith('demon')) {
console.log('environment = demo');
window.open(route.demo);
}
else if(domainName.startsWith('www')) {
console.log('environment = production');
window.open(route.www);
}
else if(domainName.startsWith('localhost')) {
console.log('environment = localhost, core-app will be routed to development env');
window.open(route.localhost);
}
});
/*
Normally, when you clicked requestDemo, we should get user information for lead management, then redirect to
demo environment.
there are many ways to do it.
1- mailchimp - add its form, then store as marketing-list, then redirect ??
2- crm system - add its form, then store as a deal, then redirect ??
this part will always redirect to demo environment!
*/
document.querySelector('.requestDemo')
.addEventListener('click', ()=> {
console.log('clicked to requestDemo');
window.open(route.demo);
});
document.querySelector('.learnMore')
.addEventListener('click', () => {
console.log('clicked to learnMore');
window.open(route.learnMore);
});