-
Notifications
You must be signed in to change notification settings - Fork 3.9k
/
browser-events.html
170 lines (162 loc) · 5.28 KB
/
browser-events.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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
<!doctype html>
<html ⚡ lang="en">
<head>
<meta charset="utf-8">
<title>Custom Browser Events</title>
<link rel="canonical" href="amps.html" >
<meta name="viewport" content="width=device-width,minimum-scale=1,initial-scale=1">
<style amp-custom>
body {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
font-size: 14px;
}
[fallback] {
display: block;
/* @alternative */ display: flex;
flex-direction: column;
flex-wrap: nowrap;
justify-content: center;
align-items: center;
background: rgba(0, 0, 0, 0.5);
color: #fff;
}
.main {
display: flex;
flex-wrap: wrap;
}
.main, h1, .wrap {
max-width: 960px;
margin-left: auto;
margin-right: auto;
}
.input-container {
flex: 1;
}
.form-container {
flex: 1;
}
h1 {
font-weight: bold;
margin: 40px auto 20px;
font-size: 24px;
}
</style>
<style amp-boilerplate>body{-webkit-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-moz-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-ms-animation:-amp-start 8s steps(1,end) 0s 1 normal both;animation:-amp-start 8s steps(1,end) 0s 1 normal both}@-webkit-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-moz-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-ms-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-o-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}</style><noscript><style amp-boilerplate>body{-webkit-animation:none;-moz-animation:none;-ms-animation:none;animation:none}</style></noscript>
<script async custom-element="amp-form" src="https://cdn.ampproject.org/v0/amp-form-0.1.js"></script>
<script async custom-element="amp-analytics" src="https://cdn.ampproject.org/v0/amp-analytics-0.1.js"></script>
<script async src="https://cdn.ampproject.org/v0.js"></script>
<script>
(self.AMP = self.AMP || []).push(function (AMP) {
AMP.toggleExperiment('analytics-browser-events', true);
});
</script>
</head>
<body>
<div style="display: flex; flex-direction: column; height: 100vh">
<div>
<h1>Custom Browser Events</h1>
<h1>AMP Input</h1>
<div class="main">
<div class="input-container">
Enter any text: <input type="text" id="inputText">
</div>
<div class="input-container">
Enter any text: <input type="text" id="inputText2">
</div>
</div>
</div>
<div>
<h1>AMP Form</h1>
<div class="main">
<div class="form-container">
<form method="post"
class="p1"
action-xhr="wololo"
custom-validation-reporting="show-all-on-submit"
target="_top">
<label for="numChild">Child (0-17)</label>
<div class="custom-select sg__select-wrapper">
<select name="numChild" id="dropDown">
<option data-vars-num-child="0" value="0">0</option>
<option data-vars-num-child="1" value="1">1</option>
<option data-vars-num-child="2" value="2">2</option>
<option data-vars-num-child="3" value="3">3</option>
<option data-vars-num-child="4" value="4">4</option>
</select>
</div>
<div class="custom-select sg__select-wrapper">
<select name="numChild2" id="dropDown2">
<option data-vars-num-child="0" value="0">0</option>
<option data-vars-num-child="1" value="1">1</option>
<option data-vars-num-child="2" value="2">2</option>
<option data-vars-num-child="3" value="3">3</option>
<option data-vars-num-child="4" value="4">4</option>
</select>
</div>
</form>
</div>
</div>
</div>
</div>
<amp-analytics>
<script type="application/json">
{
"requests": {
"event": "https://foo.com/event?type=${eventType}"
},
"transport": {
"beacon": false,
"image": false,
"xhrpost": true
},
"triggers": {
"genericTrigger-1":{
"on": "change",
"request": "event",
"selector": "#inputText",
"vars": {
"eventType": "change"
},
"extraUrlParams":{
"eventId": "inputText"
}
},
"genericTrigger-2":{
"on": "change",
"request": "event",
"selector": "#dropDown",
"vars": {
"eventType": "change"
},
"extraUrlParams":{
"eventId": "dropDown"
}
},
"genericTrigger-3":{
"on": "blur",
"request": "event",
"selector": "#inputText2",
"vars": {
"eventType": "blur"
},
"extraUrlParams":{
"eventId": "inputText2"
}
},
"genericTrigger-4":{
"on": "blur",
"request": "event",
"selector": "#dropDown2",
"vars": {
"eventType": "blur"
},
"extraUrlParams":{
"eventId": "dropDown2"
}
}
}
}
</script>
</amp-analytics>
</body>
</html>