-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.html
440 lines (365 loc) · 23.2 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
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
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Front-End</title>
<link rel="shortcut icon" type="image/jpg"
href="https://braze-front-end.s3.amazonaws.com/Braze-Logo-Monogram-White-3x.png">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="./css/bootstrap.min.css">
<link rel="stylesheet" href="./css/font-awesome.css">
<link rel="stylesheet" href="./css/style.css">
<script src="https://code.jquery.com/jquery-1.6.2.min.js"></script>
<link href="./css/main.css" rel="stylesheet" />
<script type="text/javascript">
+function(a,p,P,b,y){a.braze={};a.brazeQueue=[];for(var s="BrazeSdkMetadata DeviceProperties Card Card.prototype.dismissCard Card.prototype.removeAllSubscriptions Card.prototype.removeSubscription Card.prototype.subscribeToClickedEvent Card.prototype.subscribeToDismissedEvent Card.fromContentCardsJson ImageOnly CaptionedImage ClassicCard ControlCard ContentCards ContentCards.prototype.getUnviewedCardCount Feed Feed.prototype.getUnreadCardCount ControlMessage InAppMessage InAppMessage.SlideFrom InAppMessage.ClickAction InAppMessage.DismissType InAppMessage.OpenTarget InAppMessage.ImageStyle InAppMessage.Orientation InAppMessage.TextAlignment InAppMessage.CropType InAppMessage.prototype.closeMessage InAppMessage.prototype.removeAllSubscriptions InAppMessage.prototype.removeSubscription InAppMessage.prototype.subscribeToClickedEvent InAppMessage.prototype.subscribeToDismissedEvent InAppMessage.fromJson FullScreenMessage ModalMessage HtmlMessage SlideUpMessage User User.Genders User.NotificationSubscriptionTypes User.prototype.addAlias User.prototype.addToCustomAttributeArray User.prototype.addToSubscriptionGroup User.prototype.getUserId User.prototype.getUserId User.prototype.incrementCustomUserAttribute User.prototype.removeFromCustomAttributeArray User.prototype.removeFromSubscriptionGroup User.prototype.setCountry User.prototype.setCustomLocationAttribute User.prototype.setCustomUserAttribute User.prototype.setDateOfBirth User.prototype.setEmail User.prototype.setEmailNotificationSubscriptionType User.prototype.setFirstName User.prototype.setGender User.prototype.setHomeCity User.prototype.setLanguage User.prototype.setLastKnownLocation User.prototype.setLastName User.prototype.setPhoneNumber User.prototype.setPushNotificationSubscriptionType InAppMessageButton InAppMessageButton.prototype.removeAllSubscriptions InAppMessageButton.prototype.removeSubscription InAppMessageButton.prototype.subscribeToClickedEvent FeatureFlag FeatureFlag.prototype.getStringProperty FeatureFlag.prototype.getNumberProperty FeatureFlag.prototype.getBooleanProperty FeatureFlag.prototype.getImageProperty FeatureFlag.prototype.getJsonProperty FeatureFlag.prototype.getTimestampProperty automaticallyShowInAppMessages destroyFeed hideContentCards showContentCards showFeed showInAppMessage deferInAppMessage toggleContentCards toggleFeed changeUser destroy getDeviceId getDeviceId initialize isPushBlocked isPushPermissionGranted isPushSupported logCardClick logCardDismissal logCardImpressions logContentCardImpressions logContentCardClick logCustomEvent logFeedDisplayed logInAppMessageButtonClick logInAppMessageClick logInAppMessageHtmlClick logInAppMessageImpression logPurchase openSession requestPushPermission removeAllSubscriptions removeSubscription requestContentCardsRefresh requestFeedRefresh refreshFeatureFlags requestImmediateDataFlush enableSDK isDisabled setLogger setSdkAuthenticationSignature addSdkMetadata disableSDK subscribeToContentCardsUpdates subscribeToFeedUpdates subscribeToInAppMessage subscribeToSdkAuthenticationFailures toggleLogging unregisterPush wipeData handleBrazeAction subscribeToFeatureFlagsUpdates getAllFeatureFlags logFeatureFlagImpression".split(" "),i=0;i<s.length;i++){for(var m=s[i],k=a.braze,l=m.split("."),j=0;j<l.length-1;j++)k=k[l[j]];k[l[j]]=(new Function("return function "+m.replace(/\./g,"_")+"(){window.brazeQueue.push(arguments); return true}"))()}window.braze.getDeferredInAppMessage=function(){return new window.braze.InAppMessage};window.braze.getCachedContentCards=function(){return new window.braze.ContentCards};window.braze.getCachedFeed=function(){return new window.braze.Feed};window.braze.getUser=function(){return new window.braze.User};window.braze.getFeatureFlag=function(){return new window.braze.FeatureFlag};(y=p.createElement(P)).type='text/javascript';
y.src='https://js.appboycdn.com/web-sdk/5.3/braze.min.js';
y.async=1;(b=p.getElementsByTagName(P)[0]).parentNode.insertBefore(y,b)
}(window,document,'script');
let BCards;
// initialize the SDK
braze.initialize(localStorage.api_key, {
baseUrl: localStorage.baseUrl,
enableLogging: true,
allowUserSuppliedJavascript: true,
minimumIntervalBetweenTriggerActionsInSeconds: 5
});
// optionally show all in-app messages without custom handling
braze.automaticallyShowInAppMessages();
// braze.subscribeToInAppMessage(function(inAppMessage) {
// // check if message is not a control variant
// if (!(inAppMessage.isControl)) {
// // access the key-value pairs, defined as `extras`
// const keyValuePairs = inAppMessage.extras || {};
// // check the value of our key `msg-id` defined in the Braze dashboard
// if (keyValuePairs["msg_id"] === "card") {
// // We don't want to display the push prompt to users on browsers
// // do not call `showInAppMessage`
// $("#tile1").empty();
// $("#tile1").append("<h2>" + inAppMessage.message + "</h2>");
// return;
// }
// }
// show the in-app message now
// braze.showInAppMessage(inAppMessage);
//});
// if you use Content Cards
braze.subscribeToContentCardsUpdates(function (updates) {
// cards have been updated
console.log("Braze - subscribeToContentCardsUpdates: ", updates.cards);
render_the_cards(updates.cards);
});
// Be sure to call `openSession` after `automaticallyShowInAppMessages`
braze.openSession();
</script>
</head>
<body>
<div id="Tab" class="container">
<!-- Jumbotron -->
<div class="jumbotron">
<b>Brand</b>
<div style="float:right;min-width: 20%;">
<button id="btn_refresh" title="requestContentCardsRefresh"> </button><button id="btn_show" title="showContentCards"> </button> <div style="float:right;color: grey;" id="usertag"></div></div>
</div>
<!-- End -- Jumbotron -->
<!-- Tabs -->
<div class="col-lg-12">
<ul class="nav nav-pills">
<li class="active"><a data-toggle="pill"
href="index.html">Home</a></li>
<li class=""><a data-toggle="pill" href="navigation.html">Navigation</a></li>
<li class=""><a data-toggle="pill" href="news.html">News</a></li>
<li class=""><a data-toggle="pill" href="settings.html"><div id="indicator">Settings</div></a></li>
</ul>
</div>
<!-- End -- Tabs -->
<div class="tab-content">
<div class="tab-pane fade active in" id="email">
<p> </p>
</div>
<!-- Spacer -->
<div class="col-xs-12" style="height:10px;"></div>
<!-- End -- Spacer -->
<!-- 1-column -->
<div class="row">
<!--<div class="col-lg-10">-->
<!-- hero image carousel here-->
<div id="board" class="slideshow-container">
<!-- hero banner section here -->
</div>
<br>
<!-- The circles/dots -->
<!--<div style="text-align:center">
<span class="dots" onclick="currentSlide(1)"></span>
<span class="dots" onclick="currentSlide(2)"></span>
<span class="dots" onclick="currentSlide(3)"></span>
</div>-->
</div>
<!-- End -- 1-column -->
<div class="row">
<div id="collapsible_banner" style="position: relative; text-align: center;">
</div>
</div>
<div class="row">
<div id="trainer_message">
</div>
</div>
<div class="col-xs-12" style="height:10px;"></div>
<!-- End -- 1-column -->
<div class="row" >
<div id="onboarding_header" ></div>
<div id="onboarding_set" >
<div id="ob_tile1" class="col-sm-4" >
</div>
<div id="ob_tile2" class="col-sm-4" >
</div>
<div id="ob_tile3" class="col-sm-4" >
</div>
</div>
</div>
<!-- Spacer -->
<div class="col-xs-12" style="height:10px;"></div>
<div class="col-xs-12" style="height:10px;"></div>
<div class="col-xs-12" style="height:10px;"></div>
<!-- 3-column -->
<div class="row">
<div id="recommendation_header" ></div>
<div id="tile1" class="col-sm-4" style="min-height:300px; background-color: #eeeeee;">
<p> </p>
<label>
<input type="radio" name="template-pick" value="3e4634f6-f9f5-4c14-36b8-de973596e7f5" checked="">
<img class="img-fluid" src="./rs/tile1_494_563.png">
</label>
</div>
<div id="tile2" class="col-sm-4" style="min-height:300px; background-color: #eeeeee;">
<p> </p>
<label>
<input type="radio" name="template-pick" value="3e4634f6-f9f5-4c14-36b8-de973596e7f5" checked="">
<img class="img-fluid" src="./rs/tile2_494_563.png">
</label>
</div>
<div id="tile3" class="col-sm-4" style="min-height:300px; background-color: #eeeeee;">
<p> </p>
<label>
<input class="img-fluid col-sm-4" type="radio" name="template-pick"
value="9b74cac7-8946-46c4-95af-607444920bdd" alt="(location:tile_3, image ratio: 494x563)">
<img class="img-fluid" src="./rs/tile3_494_563.png" alt="(location:tile_3, image ratio: 494x563)">
</label>
</div>
</div>
<!-- Spacer -->
<div class="col-xs-12" style="height:10px;"></div>
<!-- End -- Spacer -->
<!-- Spacer -->
<div class="col-xs-12" style="height:50px;"></div>
<!-- End -- Spacer -->
</div>
</div>
<script>
function render_the_cards(contentcard_objs) {
BCards = contentcard_objs;
let render = false;
//do something with the latest instance of 'cards'
//This will be invoked every time the feed is successfully refreshed following a requestContentCardsRefresh() request
//Here you can render the cards to the UI as well as logging impressions and clicks. You can check if the card is a Control here.
$("#board").empty();
$("#board").append("<div class='Containers'> <div class='MessageInfo'> 1/1 (image ratio: 3000 x 1200) </div><img src='./rs/wireframe_SX3000_.jpg' style='width:100%'><div class='Info'>location=hero</div> </div>");
$("#collapsible_banner").empty();
$("#onboarding_set").empty();
let latest_tile1 = contentcard_objs.filter(obj=> obj.extras.location ==='tile_1')
.reduce((a,b)=> (a.updated > b.updated ? a : b), {});
if (Object.keys(latest_tile1).length > 0) {
//render tile1
if (latest_tile1.extras.type=="asset") {
$("#tile1").empty();
$("#tile1").append("<br>");
$("#tile1").append("<label><input class='img-fluid col-sm-4' type='radio' name='template-pick' value='9b74cac7-8946-46c4-95af-607444920bdd'>");
$("#tile1").append("<a href='" + latest_tile1.url + "'><img class='img-fluid' src='" + latest_tile1.imageUrl + "'></a></label>");
$("#tile1").append("<div style='text-align: center;'><p>" + latest_tile1.title + "</p></div>");
}
else {
$("#recommendation_header").empty();
$("#recommendation_header").append("<p><h3> " + latest_tile1.extras.groupheader + "</h3></p>");
$("#tile1").empty();
$("#tile1").append("<p> </p>");
$("#tile1").append("<div style='width: 280px;'>");
$("#tile1").append("<label>");
$("#tile1").append("<input type='radio' name='template-pick' value='de586dc2-e71a-4aac-948b-6553a7285c4d'>");
$("#tile1").append("<a href='" + latest_tile1.url + "'><img class='img-fluid' src='" + latest_tile1.imageUrl + "'></a></label>");
$("#tile1").append("<h4>" + latest_tile1.title + "</h4>");
$("#tile1").append("<a href='" + latest_tile1.url + "'><p>" + latest_tile1.description + "</p></a>");
$("#tile1").append("<div style='color:grey; padding-block: 4px; text-align: right;'>" + latest_tile1.extras.readmeter + " </div>");
$("#tile1").append("</div></div>");
var viewedcards = [latest_tile1];
braze.logContentCardImpressions(viewedcards);
}
} else {
$("#recommendation_header").empty();
$("#tile1").empty();
$("#tile1").append("<p> </p>");
$("#tile1").append("<label>");
$("#tile1").append("<input type='radio' name='template-pick' value='de586dc2-e71a-4aac-948b-6553a7285c4d'>");
$("#tile1").append("<img class='img-fluid' src='./rs/tile1_494_563.png'></label>");
}
let latest_tile2 = contentcard_objs.filter(obj=> obj.extras.location==='tile_2' && obj.extras.type === 'recommendation')
.reduce((a,b)=> (a.updated > b.updated ? a : b), {});
if (Object.keys(latest_tile2).length > 0) {
//render tile2
$("#tile2").empty();
$("#tile2").append("<p> </p>");
$("#tile2").append("<div style='width: 280px;'>");
$("#tile2").append("<label>");
$("#tile2").append("<input type='radio' name='template-pick' value='de586dc2-e71a-4aac-948b-6553a7285c4d'>");
$("#tile2").append("<a href='" + latest_tile2.url + "'><img class='img-fluid' src='" + latest_tile2.imageUrl + "'></a></label>");
$("#tile2").append("<h4>" + latest_tile2.title + "</h4>");
$("#tile2").append("<a href='" + latest_tile2.url + "'><p>" + latest_tile2.description + "</p></a>");
$("#tile2").append("<div style='color:grey; padding-block: 4px; text-align: right;'>" + latest_tile2.extras.readmeter + " </div>");
$("#tile2").append("</div></div>");
var viewedcards = [latest_tile2];
braze.logContentCardImpressions(viewedcards);
} else {
$("#tile2").empty();
$("#tile2").append("<p> </p>");
$("#tile2").append("<label>");
$("#tile2").append("<input type='radio' name='template-pick' value='de586dc2-e71a-4aac-948b-6553a7285c4d'>");
$("#tile2").append("<img class='img-fluid' src='./rs/tile2_494_563.png'></label>");
}
let latest_tile3 = contentcard_objs.filter(obj=> obj.extras.location==='tile_3' && obj.extras.type === 'recommendation')
.reduce((a,b)=> (a.updated > b.updated ? a : b), {});
if (Object.keys(latest_tile3).length > 0) {
//render tile2
$("#tile3").empty();
$("#tile3").append("<p> </p>");
$("#tile3").append("<div style='width: 280px;'>");
$("#tile3").append("<label>");
$("#tile3").append("<input type='radio' name='template-pick' value='de586dc2-e71a-4aac-948b-6553a7285c4d'>");
$("#tile3").append("<a href='" + latest_tile3.url + "'><img class='img-fluid' src='" + latest_tile3.imageUrl + "'></a></label>");
$("#tile3").append("<h4>" + latest_tile3.title + "</h4>");
$("#tile3").append("<a href='" + latest_tile3.url + "'><p>" + latest_tile3.description + "</p></a>");
$("#tile3").append("<div style='color:grey; padding-block: 4px; text-align: right;'>" + latest_tile3.extras.readmeter + " </div>");
$("#tile3").append("</div></div>");
var viewedcards = [latest_tile3];
braze.logContentCardImpressions(viewedcards);
} else {
$("#tile3").empty();
$("#tile3").append("<p> </p>");
$("#tile3").append("<label>");
$("#tile3").append("<input type='radio' name='template-pick' value='de586dc2-e71a-4aac-948b-6553a7285c4d'>");
$("#tile3").append("<img class='img-fluid' src='./rs/tile3_494_563.png' alt='(location:tile_3, image ratio: 494x563)'></label>");
}
for (let i = 0; i < BCards.length; i++) {
if (BCards[i].extras.location == "hero") {
$("#board").append("<div class='Containers'> <div class='MessageInfo'>Location: " + BCards[i].extras.location + "</div><img src='" + BCards[i].imageUrl + "' style='width:100%'><div class='Info_white'>" + BCards[i].title + "</div> </div>");
render = true;
let viewedcards = new Array(BCards[i]);
braze.logContentCardImpressions(viewedcards);
}
if (BCards[i].extras.location == "collapsible_banner") {
var someheadertextcolor = "#222222";
if (BCards[i].extras.headertextcolor != null)
{
someheadertextcolor = BCards[i].extras.headertextcolor;
}
$("#collapsible_banner").append("<img src='" + BCards[i].imageUrl +"' style='width:100%;height:auto'><div style='color:" + someheadertextcolor + "; font-size: 25px;position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);'><p><b>" + BCards[i].title + "</b></p><span style='font-size:20px'>" + BCards[i].description + "</span></div>");
if (BCards[i].linkText != "") {
$("#collapsible_banner").append("<div style='position:absolute;bottom:100px;right:100px'><a id='collapsible_banner_link' href='" + BCards[i].url + "' style='font-size:17px;;border:none; border-radius:5px;display:inline-block;padding:10px 28px;vertical-align:middle;overflow:hidden;text-align:center;cursor:pointer;white-space:nowrap;user-select:none;background-color:#04AA6D;color:#ffffff;'>" + BCards[i].linkText + "</a></div>");
}
$("#collapsible_banner").append("<div style='position:absolute;top:8px;right:16px;font-size:18px'><a id='collapsible_banner_close' style='color:#bbbbbb' href='#'>X</a></div>");
$("#collapsible_banner_link").click(function(){ braze.logContentCardClick(BCards[i]); return true; });
$("#collapsible_banner_close").click(function(){ braze.logCardDismissal(BCards[i]); $("#collapsible_banner").fadeOut(); });
let viewedcards = new Array(BCards[i]);
braze.logContentCardImpressions(viewedcards);
}
if (BCards[i].extras.location =='ob_tile_1') {
$("#onboarding_header").empty();
$("#onboarding_header").append("<p><h3> Getting started:!</h3></p>");
$("#onboarding_set").append("<div id='" + BCards[i].id + "' class='col-sm-4'><a href='" + BCards[i].url + "'><img class='img-fluid' src='" + BCards[i].imageUrl + "'></a></div>");
}
if (BCards[i].extras.location =='ob_tile_2') {
$("#onboarding_header").empty();
$("#onboarding_header").append("<p><h3> Get the most of Sweat!</h3></p>");
//$("#onboarding_set1").empty();
//$("#onboarding_set1").append("<p><h3> Get the most of Sweat!</h3></p>");
//$("#ob_tile2").empty();
//$("#ob_tile2").append("<a href='" + BCards[i].url + "'><img class='img-fluid' src='" + BCards[i].imageUrl + "'></a>");
$("#onboarding_set").append("<div id='" + BCards[i].id + "' class='col-sm-4'><a href='" + BCards[i].url + "'><img class='img-fluid' src='" + BCards[i].imageUrl + "'></a></div>");
}
if (BCards[i].extras.location =='ob_tile_3') {
$("#onboarding_header").empty();
$("#onboarding_header").append("<p><h3> Get the most of Sweat!</h3></p>");
//$("#onboarding_set1").empty();
//$("#onboarding_set1").append("<p><h3> Get the most of Sweat!</h3></p>");
//$("#ob_tile3").empty();
//$("#ob_tile3").append("<a href='" + BCards[i].url + "'><img class='img-fluid' src='" + BCards[i].imageUrl + "''></a>");
$("#onboarding_set").append("<div id='" + BCards[i].id + "' class='col-sm-4'><a href='" + BCards[i].url + "'><img class='img-fluid' src='" + BCards[i].imageUrl + "'></a></div>");
}
}
if (render == false) {
//console.log("No personalised content card ", render);
$("#board").append("<div id='navigation' style='display:none;'><a class='Back' onclick='minusSlides(1)'>❮</a><a class='forward' onclick='plusSlides(1)'>❯</a></div>")
} else {
$("#board").append("<div id='navigation' style='display:block;'><a class='Back' onclick='minusSlides(1)'>❮</a><a class='forward' onclick='plusSlides(1)'>❯</a></div>")
}
SlideShow(1);
}
// forward/Back controls
function plusSlides(n) {
SlideShow(slidePosition);
}
function minusSlides(n) {
SlideShow(slidePosition - 1);
}
// images controls
function currentSlide(n) {
SlideShow(slidePosition = n);
}
function SlideShow(n) {
var i;
var slides = document.getElementsByClassName("Containers");
//var circles = document.getElementsByClassName("dots");
if (n > slides.length) { slidePosition = 1 }
if (n < 1) { slidePosition = slides.length }
for (i = 0; i < slides.length; i++) {
slides[i].style.display = "none";
}
//for (i = 0; i < circles.length; i++) {
// circles[i].className = circles[i].className.replace(" enable", "");
//}
slides[slidePosition - 1].style.display = "block";
//circles[slidePosition-1].className += " enable";
}
function SlideShow() {
var i;
var slides = document.getElementsByClassName("Containers");
for (i = 0; i < slides.length; i++) {
slides[i].style.display = "none";
}
slidePosition++;
if (slidePosition > slides.length) { slidePosition = 1 }
slides[slidePosition - 1].style.display = "block";
//setTimeout(SlideShow, 20000); // Change image every 2 seconds
}
var slidePosition = 1;
window.onload = function () {
console.log('The user is ' + braze.getUser().getUserId());
$("#usertag").html("userId: " + braze.getUser().getUserId());
render_the_cards(braze.getCachedContentCards().cards);
console.log("Braze - getCachedContentCards: ", braze.getCachedContentCards().cards);
}
</script>
<script>
$(document).ready(function () {
$("#btn_refresh").click(function () {
braze.requestContentCardsRefresh();
console.log('The user is ' + braze.getUser().getUserId());
$("#usertag").html("userId: " + braze.getUser().getUserId());
});
$("#btn_show").click(function () {
braze.toggleContentCards();
});
if (localStorage.getItem("baseUrl") === null) {
$("#indicator").append("<img src='https://i.pinimg.com/originals/b1/e1/0b/b1e10b0e4e26bf904a565172e79992ae.png' style='height:15px;width:15px;'>");
}
});
</script>
</body>
</html>