-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.html
111 lines (101 loc) · 4.08 KB
/
index.html
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
<meta name="apple-mobile-web-app-capable" content="yes">
<script type="text/javascript">
var globalEmail = '[email protected]';
var name = 'Bob';
var config = {
partner_id: 'aZXOEYwKSn',
locale: 'en',
env: 'test', // for test env. Change to prod for production deployment
onAddToCart: function(products) {
// To be filled in by skincaredemo
if (Array.isArray(products)) {
// Array means we got multiple products (add all to cart)
console.log("User clicked add all cart. Adding all products to shopping cart.");
console.log(products);
} else {
// Single object means we got one product (add to cart)
console.log("User clicked add to cart. Adding the product to shopping cart.");
console.log(products);
}
},
onClose: function() {
// User closed modal. Here you could forward them to checkout if they had
// added products (onAddToCart was called before).
console.log('User clicked close');
},
onSendEmail: function(emailData) {
//console.log(JSON.stringify(emailData));
var email = JSON.stringify(emailData.email);
globalEmail = email.substr(1, email.length-2);
var emailName = email.substr(1, email.indexOf('@')-1);
name=emailName;
console.log(email);
},
onCheckout: function(data) {
// User clicked the checkout button that is visible on results page
// after adding one or more products to cart. Redirect to checkout page?
//console.log('User clicked checkout, CV data is :'+ JSON.stringify(data.data.cvData) + ' active selections are : ' +JSON.stringify(data.data.activeSelections) + ' and here is the CV data : ' + JSON.stringify(data.data.cvData));
//console.log(data.cvData);
var c= data.data.cvData;
c.push(data.data.activeSelections);
//console.log(JSON.stringify(c));
console.log(JSON.stringify(data));
delete data.data['products'];
delete data.data.activeSelections['locationData'];
data.email = globalEmail;
globalEmail= '[email protected]';
//console.log(JSON.stringify(data));
var myHeaders = new Headers();
myHeaders.append("X-RapidAPI-Key", "89004c1120mshf4a79aa7c2995aep1d9f77jsn049236ba3331");
myHeaders.append("Host", "json2xls-json-xls-v1.p.rapidapi.com");
myHeaders.append("Content-Type", "application/json");
myHeaders.append("responseType", "arraybuffer");
var raw = JSON.stringify(data);
var requestOptions = {
method: 'POST',
headers: myHeaders,
body: raw,
redirect: 'follow'
};
var filename = name;
fetch("https://json2xls-json-xls-v1.p.rapidapi.com/ConvertJsonRaw?format=xlsx&layout=Landscape&view=Hierarchy&InternalIDs=None", requestOptions)
.then(response => response.blob())
.then(blob => URL.createObjectURL(blob))
.then(uril => {
var link = document.createElement("a");
link.href = uril;
link.download = filename + ".xlsx";
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
name='bob';
});
},
onClickProduct: function(product) {
// To be filled in by skincaredemo.
console.log("User clicked info action.");
console.log(product);
var win = window.open(product.url, '_blank');
win.focus();
},
};
(function() {
var rv = document.createElement('script');
rv.src = 'https://d38knilzwtuys1.cloudfront.net/revieve-plugin-v4/revieve-plugin-loader.js';
rv.charset = 'utf-8';
rv.type = 'text/javascript';
rv.async = 'true';
rv.onload = rv.onreadystatechange = function() {
var rs = this.readyState;
if (rs && rs != 'complete' && rs != 'loaded') return;
Revieve.Init(config, function() {
// Comment out the below line if you want to open the modal
// manually when user clicks a certain button or navigates
// to certain page.
Revieve.API.show();
});
};
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(rv, s);
})();
</script>