-
Notifications
You must be signed in to change notification settings - Fork 0
/
index-iframe.html
133 lines (124 loc) · 4.08 KB
/
index-iframe.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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
<!DOCTYPE html>
<html>
<head>
<meta charset = "UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Card Name</title>
<link rel="stylesheet" type="text/css" href="https://utils.pro.to/Assets/semantic.min.css">
<link rel="stylesheet" type="text/css" href="card.min.css">
<script type="text/javascript">
var siteId, origin, base_url;
// Setting variables from environment
origin = window.location.origin;
if (origin == 'https://s3.ap-south-1.amazonaws.com') {
let bucket_name = window.location.pathname.split('/')['1'];
base_url = origin + "/" + bucket_name;
switch(bucket_name){
case "cdn.protograph":
case "utils.protograph":
siteId = '1';
break;
case "staging.cdn.protograph":
siteId = '2';
break;
}
} else if (origin === 'https://dkqrqc7q64awx.cloudfront.net') {
siteId = '2';
base_url = origin;
} else {
siteId = '1';
base_url = origin;
}
if(siteId){
var _paq = _paq || [];
/* tracker methods like "setCustomDimension" should be called before "trackPageView" */
_paq.push(['trackPageView']);
_paq.push(['enableLinkTracking']);
(function() {
var u="//protograph.innocraft.cloud/";
_paq.push(['setTrackerUrl', u+'piwik.php']);
_paq.push(['setSiteId', siteId]);
var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
g.type='text/javascript'; g.async=true; g.defer=true; g.src=u+'piwik.js'; s.parentNode.insertBefore(g,s);
})();
}
</script>
</head>
<body>
<div id="card-name-div"></div>
<script src="https://d2m6lzru8erw1k.cloudfront.net/lib/oasis.min.js"></script>
<script src = "./dist/0.0.1/card.min.js"></script>
<script type="text/javascript">
var x = new ProtoGraph.Card.toCardName();
function findGetParameter(parameterName) {
var result = null,
tmp = [],
search_url = decodeURIComponent(location.search);
search_url
.substr(1)
.split("&")
.forEach(function (item) {
tmp = item.split("=");
if (tmp[0] === parameterName) result = decodeURIComponent(tmp[1]);
});
return result;
}
let view_cast_id = findGetParameter('view_cast_id'),
schema_id = findGetParameter('schema_id');
var ReceiverConsumer = Oasis.Consumer.extend({
requests: {
receive: function(mode) {
var that = this;
x.init({
selector: document.querySelector('#card-name-div'),
data_url: "./dist/0.0.1/sample.json",
schema_url: "./dist/0.0.1/schema.json",
configuration_url: "./dist/0.0.1/configuration_sample.json",
configuration_schema_url: './dist/0.0.1/configuration_schema.json',
})
renderWithMode(mode);
}
},
events: {
get_size: function(){
var that = this;
var intervalId = setInterval(function(){
try {
clientRect = x.getData();
} catch (err) {}
if(clientRect.height){
var height = clientRect.height,
width = clientRect.width;
that.send("resize_frame", {height: height, width: width});
clearInterval(intervalId);
}
}, 10)
},
change_mode: function(mode){
renderWithMode(mode);
var that = this;
setTimeout(function(){
height = x.getData().height;
that.send("resize_frame", {height: height});
})
}
}
});
oasis.connect({
consumers: {
receive: ReceiverConsumer
}
});
function renderWithMode(mode) {
switch(mode){
case "laptop":
x.renderLaptop();
break;
case "mobile":
x.renderMobile();
break;
}
}
</script>
</body>
</html>