-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
215 lines (185 loc) · 9.34 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
<!DOCTYPE html>
<html lang="en">
<head>
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-QNCCWNK84K"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-QNCCWNK84K');
</script>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no, viewport-fit=cover">
<meta name="theme-color" content="#009900">
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
<link rel='manifest' href='/manifest.webmanifest'>
<link rel="icon" sizes="512x512" href="assets/img/icon.png">
<link rel="apple-touch-icon" sizes="57x57" href="assets/img/apple-icon-57x57.png">
<link rel="apple-touch-icon" sizes="60x60" href="assets/img/apple-icon-60x60.png">
<link rel="apple-touch-icon" sizes="72x72" href="assets/img/apple-icon-72x72.png">
<link rel="apple-touch-icon" sizes="76x76" href="assets/img/apple-icon-76x76.png">
<link rel="apple-touch-icon" sizes="114x114" href="assets/img/apple-icon-114x114.png">
<link rel="apple-touch-icon" sizes="120x120" href="assets/img/apple-icon-120x120.png">
<link rel="apple-touch-icon" sizes="144x144" href="assets/img/apple-icon-144x144.png">
<link rel="apple-touch-icon" sizes="152x152" href="assets/img/apple-icon-152x152.png">
<link rel="apple-touch-icon" sizes="180x180" href="assets/img/apple-icon-180x180.png">
<link rel="icon" type="image/png" sizes="192x192" href="assets/img/android-icon-192x192.png">
<link rel="icon" type="image/png" sizes="32x32" href="assets/img/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="96x96" href="assets/img/favicon-96x96.png">
<link rel="icon" type="image/png" sizes="16x16" href="assets/img/favicon-16x16.png">
<meta name="msapplication-TileImage" content="assets/img/ms-icon-144x144.png">
<title>What's BOGO?</title>
<link rel="stylesheet" href="assets/css/style.css">
<script src="https://code.jquery.com/jquery-3.4.1.min.js" integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo=" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/js-cookie@beta/dist/js.cookie.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-modal/0.9.1/jquery.modal.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/jquery-modal/0.9.1/jquery.modal.min.css" />
</head>
<body class="has-navbar-fixed-top">
<nav class="navbar has-background-link is-fixed-top" role="navigation" aria-label="main navigation" style="top:-15px;height:85px;">
<div class="navbar-brand has-background-primary" style="padding-top:25px;">
<a class="navbar-item" href="#">
<img src="assets/img/brand-mark-rev.png" alt="BogoAlert" class="logo" width="auto" height="auto">
</a>
</div>
<div class="navbar-menu" style="margin-top:20px;">
<div class="navbar-item">
<h1>Current Publix BOGO Offers</h1>
</div>
</div>
</nav>
<section class="main">
<div class="container">
<div class="columns is-centered">
<div class="column is-one-quarter">
<button id="view_list" class="button is-link has-text-centered is-size-6 is-fixed-bottom" style="position:fixed;top:90;right:0;z-index:1000; border-radius: 0;">View My Shopping List</button><br>
</div>
</div>
<div class="modal" id="list_modal">
</div>
<br>
<h1 class="is-hidden-desktop is-size-4 has-text-centered">Current Publix BOGO Offers</h1>
<br>
<div class="columns is-multiline" id="items">
</div>
</div>
</section>
<footer class="footer">
<div class="content has-text-centered">
<p>BOGOAlert has no affiliation with Publix Super Markets, Inc.</p>
<p><a href="/legal.html">Privacy Policy</a> | <a href="/legal.html">Terms of Service</a></p>
<p>©2019 BOGOAlert, All Rights Reserved.</p>
</div>
</footer>
<script>
// This is the "Offline page" service worker
// Add this below content to your HTML page, or add the js file to your page at the very top to register service worker
// Check compatibility for the browser we're running this in
if ("serviceWorker" in navigator) {
if (navigator.serviceWorker.controller) {
console.log("[PWA Builder] active service worker found, no need to register");
} else {
// Register the service worker
navigator.serviceWorker
.register("pwabuilder-sw.js", {
scope: "./"
})
.then(function (reg) {
console.log("[PWA Builder] Service worker has been registered for scope: " + reg.scope);
});
}
}
</script>
<script>
$.ajax({
url: "https://api.bogoalert.com/publix_bogos.json",
method: "POST",
data: {}
}).done(function(data) {
console.log(data);
const offers = JSON.parse(JSON.stringify(data));
if (offers.data == null) {
var template =
`<div class="column is-one-fifth">
<div class="card">
<div class="card-content has-text-centered">
<p class="name">No BOGOs?!</p>
<div class="terms">
<p>We're having an issue fetching BOGO Offers</p>
</div>
<p class="dates">This is most likely due to there being an issue with the Publix Database.<br>Please check back soon.</p>
</div>
</div>
</div>`;
$('#items').append(template);
} else {
console.log(offers.data.offer)
offers.data.offer.forEach(function(element) {
var product = element.product;
var deal_type = element.deal_type;
var terms = element.terms;
var date_start = element.date_start;
var date_end = element.date_end;
var img = element.img;
if (img == null) { img = "assets/img/placeholder.png"; } else {
img = "https://" + element.img;
}
var template =
`<div class="column is-one-fifth">
<div class="card">
<div class="card-content has-text-centered">
<p class="name">${product}</p>
<img src="${img}"/>
<div class="terms">
<p>${deal_type}</p>
<p class="is-size-7">${terms}</p>
</div>
<p class="dates">Valid: ${date_start} - ${date_end}</p>
<footer class="card-footer">
<p class="card-footer-item">
<span>
<button class="button is-link list-added" data_name="${product}" data_expire="${date_end}">Add to My List</a>
</span>
</p>
</footer>
</div>
</div>
</div>`;
$('#items').append(template);
});
}
});
$(document).ready(function() {
var shopping_list = "<h1>Shopping List</h1><br><ul>";
$("#items").on("click", ".list-added", function(e){
e.preventDefault();
var target = e.target;
if ($(target).text() !== "Remove from My List") {
$(target).addClass("has-background-grey");
shopping_list = shopping_list + "<li><strong>" + $(target).attr("data_name") + "</strong> BOGO until " + $(target).attr("data_expire") + "</li>";
console.log("added");
$(target).text("Remove from My List");
} else {
$(target).removeClass("has-background-grey");
shopping_list = shopping_list.replace("<li><strong>" + $(target).attr("data_name") + "</strong> BOGO until " + $(target).attr("data_expire") + "</li>", "");
console.log("removed");
$(target).text("Add to My List");
}
});
$('#view_list').click(function() {
$('#list_modal').html(shopping_list + "<ul>" + '<p><a href="#" id="remove-all">Remove All Items</a></p>');
$('#list_modal').modal();
});
$("#list_modal").on("click", "#remove-all", function(e){
e.preventDefault;
shopping_list = "<h1>Shopping List</h1><br><ul>";
$(".list-added").text("Add to My List");
$(".list-added").removeClass("has-background-grey");
$.modal.close();
});
});
</script>
</body>
</html>