-
Notifications
You must be signed in to change notification settings - Fork 0
/
pos.html
233 lines (217 loc) · 9.95 KB
/
pos.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
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
<!DOCTYPE html>
<html lang="en">
<head>
<title>Tealium - Event Simulator Page</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/css/bootstrap.min.css">
<script src="https://code.jquery.com/jquery-3.2.1.min.js"
integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4="
crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.3/umd/popper.min.js"
integrity="sha384-vFJXuSJphROIrBnz7yo7oB41mKfc8JzQZiCq4NCceLEaO4IHwicKwpJf9c9IpFgh"
crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/js/bootstrap.min.js"
integrity="sha384-alpBpkh1PFOepccYVYDB4do5UnbKysX5WZXm3XxPqe5iKTfUKjNkCk9SaVuEZflJ"
crossorigin="anonymous"></script>
<style type="text/css">
.control-label, .nav-item .nav-text .nav-text-header {
font-weight: bold;
}
.nav-item .nav-text {
padding: .5rem;
}
</style>
</head>
<body>
<div class="container">
<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNav"
aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarNav">
<ul class="navbar-nav mr-auto">
<li class="nav-item">
<span class="navbar-text nav-text"><span class="nav-text-header">Account: </span><span
id="tealium-account">sales-salim</span></span>
</li>
<li class="nav-item">
<span class="navbar-text nav-text"><span class="nav-text-header">Profile: </span><span
id="tealium-profile">retailer</span></span>
</li>
<li class="nav-item">
<span class="navbar-text nav-text"><span class="nav-text-header">Data Source: </span><span
id="tealium-data-source">k6o0by</span></span>
</li>
<li class="nav-item">
<span class="navbar-text nav-text"><span class="nav-text-header">Event Name: </span><span
id="tealium-event-name">event_POS</span></span>
</li>
<li class="nav-item">
<span class="navbar-text nav-text"><span class="nav-text-header">Trace ID: </span><span
id="tealium-trace-id">09853</span></span>
</li>
</ul>
<button class="btn btn-outline-secondary my-2 my-sm-0" type="button" data-toggle="modal"
data-target="#updateSetup" onclick="populateSetup()">Update
</button>
</div>
</nav>
<!--Event details-->
<div class="jumbotron">
<legend class="text-center">
<h1 class="mb-5"><img src="https://images.martechadvisor.com/images/uploads/product_logos/Tealium.png"
height="70px"/></h1>
</legend>
<div class="container">
<label class="control-label">Tealium - Event Simulator (POS DATA)</label>
<div class="data-layer-controls">
<div class="entry row mb-3">
<div class="col-md-3">
<input type="text" class="form-control event-key" placeholder="Key"
onchange="updateKeyEntryInDataLayer(this);this.oldValue = this.value;">
</div>
<div class="col-md-3">
<input type="text" class="form-control event-value" placeholder="Value"
onchange="updateValueEntryInDataLayer(this)">
</div>
<div class="col-auto">
<button class="btn btn-success btn-add" type="button">Add</button>
</div>
</div>
<button id="btn-event-submit" class="btn btn-primary">Submit Event</button>
</div>
</div>
</div>
</div>
<!--Modal setup-->
<div id="updateSetup" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel"
aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">Update Setup</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<form>
<div class="form-group row">
<label for="modal-account" class="col-sm-4 col-form-label">Account</label>
<div class="col-sm-8">
<input type="text" class="form-control" id="modal-account">
</div>
</div>
<div class="form-group row">
<label for="modal-profile" class="col-sm-4 col-form-label">Profile</label>
<div class="col-sm-8">
<input type="text" class="form-control" id="modal-profile">
</div>
</div>
<div class="form-group row">
<label for="modal-data-source" class="col-sm-4 col-form-label">Data Source</label>
<div class="col-sm-8">
<input type="text" class="form-control" id="modal-data-source">
</div>
</div>
<div class="form-group row">
<label for="modal-event-name" class="col-sm-4 col-form-label">Event Name</label>
<div class="col-sm-8">
<input type="text" class="form-control" id="modal-event-name">
</div>
</div>
<div class="form-group row">
<label for="modal-trace-id" class="col-sm-4 col-form-label">Trace ID</label>
<div class="col-sm-8">
<input type="text" class="form-control" id="modal-trace-id">
</div>
</div>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-primary" onclick="updateSetup()">Save</button>
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
<!--ENd of Modal Setup-->
<script type="text/javascript">
var dataLayer = {};
setupTealiumDataLayer();
function addEntryToDataLayer(key, value) {
dataLayer[key] = value;
}
function deleteEntryFromDataLayer(key) {
delete dataLayer[key];
}
function updateKeyEntryInDataLayer(element) {
var oldKey = element.oldValue;
var newKey = element.value;
if (dataLayer[oldKey] != null) {
dataLayer[newKey] = dataLayer[oldKey];
deleteEntryFromDataLayer(oldKey);
} else {
dataLayer[newKey] = "";
}
}
function updateValueEntryInDataLayer(element) {
var key = getKey(element);
var value = element.value;
addEntryToDataLayer(key, value);
}
function getKey(element) {
return $(element).parents('.entry').find('.event-key')[0].value;
}
function getValue(element) {
return $(element).parents('.entry').find('.event-value')[0].value;
}
function setupTealiumDataLayer() {
dataLayer["tealium_account"] = $('#tealium-account').html();
dataLayer["tealium_profile"] = $('#tealium-profile').html();
dataLayer["tealium_datasource"] = $('#tealium-data-source').html();
dataLayer["tealium_event"] = $('#tealium-event-name').html();
dataLayer["tealium_trace_id"] = $('#tealium-trace-id').html();
}
function populateSetup() {
$('#modal-account').val($('#tealium-account').html());
$('#modal-profile').val($('#tealium-profile').html());
$('#modal-data-source').val($('#tealium-data-source').html());
$('#modal-event-name').val($('#tealium-event-name').html());
$('#modal-trace-id').val($('#tealium-trace-id').html());
}
function updateSetup() {
$('#tealium-account').html($('#modal-account').val());
$('#tealium-profile').html($('#modal-profile').val());
$('#tealium-data-source').html($('#modal-data-source').val());
$('#tealium-event-name').html($('#modal-event-name').val());
$('#tealium-trace-id').html($('#modal-trace-id').val());
setupTealiumDataLayer();
$('#updateSetup').modal('hide');
}
$(document).on('click', '.btn-add', function () {
var currentEntry = $(this).parents('.entry'),
newEntry = $(currentEntry.clone()).insertAfter(currentEntry).find("input[type='text']").val("");
$(this).html("Remove");
$(this).attr("class", "btn btn-danger btn-remove");
}).on('click', '.btn-remove', function () {
$(this).parents('.entry').remove();
deleteEntryFromDataLayer(getKey(this));
});
$('#btn-event-submit').click(function() {
var serializedDataLayer = $.param(dataLayer);
$.ajax({
url: 'https://collect.tealiumiq.com/event',
type: 'GET',
data: serializedDataLayer,
success: function (result) {
alert("Your bookmark has been saved");
}
});
alert('Event Submitted');
});8
</script>
</body>
</html>