-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
208 lines (180 loc) · 7.29 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
<html lang="en">
<head>
<meta charset="utf-8">
<meta content="width=device-width, initial-scale=1.0" name="viewport">
<meta property="og:url" content="http://www.quicktrack.pro" />
<meta property="og:type" content="article" />
<meta property="og:title" content="QuickTrack - Track your food by SMS/MMS" />
<meta property="og:description" content="Tracking your food? Use QuickTrack to easily track and share your food after every meal." />
<meta property="og:image" content="http://www.quicktrack.pro/images/header_photo.png" />
<title>Loading...</title>
<link rel="shortcut icon" href="images/favicon.png" type="image/x-icon">
<link rel="icon" href="images/favicon.png" type="image/x-icon">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">
<link rel="stylesheet" href="css/style.css">
<script src="https://code.jquery.com/jquery-1.12.4.min.js" integrity="sha256-ZosEbRLbNQzLpnKIkEdrPv7lOy9C27hHQ+Xp8a4MxAQ=" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js" integrity="sha384-0mSbJDEHialfmuBBQP6A4Qrprq5OVfW37PRR3j5ELqxss1yVqOtnepnHVP9aJ7xS" crossorigin="anonymous"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/handlebars.js/1.1.2/handlebars.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/moment.js/2.4.0/moment.min.js"></script>
</head>
<body>
<div class="container">
<div class="header clearfix">
<!--<nav>-->
<!--<ul class="nav nav-pills pull-right">-->
<!--<li role="presentation" class="active">Home</li>-->
<!--<li role="presentation"><a href="#about">About</a></li>-->
<!--</ul>-->
<!--</nav>-->
<h3 class="text-muted">
<!-- <a href="index.html"><img alt="quicktrack header" src="images/logo_transparent.png" width="200px" /></a>-->
<a href="index.html">QuickTrack</a>
</h3>
</div>
<div class="jumbotron text-center">
<h1>Easily track food</h1>
<h4>Just a click away.</h4>
<p class="lead">Easily send your breakfast/lunch/dinner to your coach.</p>
<div id="search-box" class="hero">
<form>
<div class="row">
<div class="col-md-12">
<div class="input-group form-group-lg">
<input id="numberSearch" type="text" autofocus="autofocus"
class="form-control" placeholder="603-555-1234" />
<div class="input-group-btn">
<button id="search-submit" class="btn btn-primary" type="submit" style="padding-bottom: 11px; padding-top: 11px;">
<span class="glyphicon glyphicon-search"></span>
</button>
</div>
</div>
<div class="">
<h4>
<a href="sms://+18573052778" type="button" id="sms-button"
class="btn btn-primary btn-sm btn-block">or start by sending your name via SMS 📱</a>
</h4>
</div>
</div>
</div>
</form>
</div>
</div>
<div class="row" style="margin-bottom: 10px;">
<div class="col-lg-12 text-center">
<h1 id="h1-title">Loading...</h1>
<div id="food-content" class="hide-while-loading">
</div>
</div>
</div>
<footer class="footer">
<p>This is a fun app I made to easily track my food.</p>
<p>This project is open source, so open up a <a href="https://github.com/ryanlitalien/ruby-on-lambda" target="_blank">pull request or issue</a>!</p>
<a id="about"></a>
</footer>
</div>
<script id="file-or-folder" type="text/x-handlebars-template">
<div class="col-lg-3 col-md-3 col-sm-3 text-center panel">
<h4>{{message}}</h4>
<div>
<img src="{{public_url}}" class="responsive-fit effect1" />
</div>
<h4>{{friendlyLastModified}}</h4>
</div>
</script>
<script>
function getUrlVars() {
let vars = {};
window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi, function(m, key, value) {
vars[key] = value;
});
return vars;
}
function setGetParameter(event, paramName, paramValue) {
event.preventDefault();
let url = window.location.href;
let hash = location.hash;
url = url.replace(hash, '');
if (url.indexOf(paramName + "=") >= 0)
{
let prefix = url.substring(0, url.indexOf(paramName));
let suffix = url.substring(url.indexOf(paramName));
suffix = suffix.substring(suffix.indexOf("=") + 1);
suffix = (suffix.indexOf("&") >= 0) ? suffix.substring(suffix.indexOf("&")) : "";
url = prefix + paramName + "=" + paramValue + suffix;
}
else {
if (url.indexOf("?") < 0)
url += "?" + paramName + "=" + paramValue;
else
url += "&" + paramName + "=" + paramValue;
}
window.location.href = url + hash;
}
document.getElementById('search-submit').onclick = function (event) {
event.preventDefault();
let number = $('#numberSearch').val().replace(/\D/g,'');
setGetParameter(event, 'num', number);
};
document.addEventListener("DOMContentLoaded", function () {
$("#numberSearch").focus();
"use strict";
let DATE_FORMAT = "dddd, MMM Do YYYY hh:mm a";
let number = getUrlVars()["num"];
console.log("fromNumber: " + number);
if(number === undefined) {
// let title = "Please select a phone number.";
let title = "No phone number selected.<br /> You can start by <a href=\"sms://+18573052778\">sending your name via SMS</a>\n";
document.title = title;
$("#h1-title").html(title);
$("#sms-button").show();
return;
} else {
number = number.replace(/\D/g,'');
$("#sms-button").hide();
}
let compiledTemplate;
function onAjaxError(xml) {
console.log("Error: " + xml);
}
function onAjaxSuccess(data, status) {
let $tbodyContent = $('#food-content');
// set a reasonable title instead of "Loading"
let title = 'Showing results for "' + number + '"';
document.title = title;
$('#h1-title').text( title );
$.each( data, function( obj, element ) {
element.friendlyLastModified = element.last_modified !== "" ? moment(element.last_modified).format( DATE_FORMAT ) : "";
if (!element.key.includes(number)) {
element.hidden = true;
}
$tbodyContent.append(compiledTemplate(element));
});
$('.hide-while-loading').show();
}
$.ajax( {
type: "GET",
crossDomain: true,
contentType: "application/json",
dataType: "json",
url: "https://md6r0oe3g2.execute-api.us-east-1.amazonaws.com/Prod/getphotos?from_number=" + encodeURIComponent(number),
success: function( xhr ) {
onAjaxSuccess(xhr);
},
error: function( xhr ) {
onAjaxError(xhr);
}
});
// compile while ajax is in progress
compiledTemplate = Handlebars.compile($('#file-or-folder').html());
});
</script>
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-1234-1"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-1234-1');
</script>
</body>
</html>