-
Notifications
You must be signed in to change notification settings - Fork 1
/
scan.html
281 lines (254 loc) · 11 KB
/
scan.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="Tracking system | QR code | Delivery Confirmation">
<meta name="author" content="Mark Kirzon | Sanket Chauhan | Pallav Rustogi">
<link rel="shortcut icon" href="assets/img/favicon.png">
<title>ScanItOn | Thank you!</title>
<link href="css/bootstrap.css" rel="stylesheet">
<link href="css/home-css.css" rel="stylesheet">
<link href='http://fonts.googleapis.com/css?family=Lato:300,400,900' rel='stylesheet' type='text/css'>
<script src="http://www.parsecdn.com/js/parse-1.2.12.min.js"></script>
</head>
<body>
<!-- Navbar -->
<nav class="navbar navbar-default navbar-fixed-top" role="navigation">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="index.html"><b>ScanItOn</b></a>
</div>
<div class="collapse navbar-collapse ">
<ul class="nav navbar-nav navbar-right">
<li>
<a href="" id="login" style="display:inline-block">Log In</a>
<input id="logout" class="btn btn-success" type="submit" value="Logout" style="display:none; margin-top: 0px" />
</li>
</ul>
<ul class="nav navbar-nav navbar-left">
<li><a href="">About</a></li>
<li><a href="">Contact</a></li>
<li><a href="">Dashboard</a></li>
</ul>
</div>
</div>
</nav>
<!-- /End of Navbar -->
<div class="container" id="register">
<div id="tyscan" style="display:none;">
<p>The sender has been notified. Thank you for using Scaniton.</p>
</div>
<div id="signinup" class="col-md-6">
<div id="emailform" style="display:none;">
<form id="emailform">
<label for="name" class="nameLabel">Name*</label>
<input id="emailname" type="text" name="name" placeholder="Enter your name..." required>
<label for="email" class="emailLabel">Email*</label>
<input id="emailemail" type="text" name="email" placeholder="Enter your email..." required>
<label for="subject">Subject*</label>
<input id="emailsubject" type="text" name="subject" placeholder="Your subject..." required>
<label for="message" class="messageLabel">Message*</label>
<textarea id="emailmessage" name="message" placeholder="Your message..." required></textarea>
</form>
</div>
<div id="signupform" style="display: none">
<h3 align="center">Login/Signup </h3>
<form>
<input type="email" id="semail" name="email" class="form-control input-hg" placeholder="Email" />
<input type="password" id="spass" class="form-control" id="spass" placeholder="Password">
<input type="text" id="sname" name="name" style="display:none;" class="form-control input-hg" placeholder="Full Name" />
<input type="button" id="signup" class="btn btn-success btn-lg btn-signinup" value="New User?"></input>
<input type="button" id="signin" class="btn btn-inverse btn-block" value="Sign in" style="background-color: transparent"></input>
<input type="button" id="existingUser" class="btn btn-inverse btn-block" value="Already have an account?" style="background-color: transparent; display:none"></input>
</form>
</div>
<div id="dash" style="display:none;">
<h3 id="tyuser">Thank You!</h3>
<input type="button" class="btn btn-info btn-block" onClick="location.href='create.html'" value="Dashboard"></input>
<input type="button" id="logout2" class="btn btn-info btn-block" value="Logout"></input>
</div>
<div id="tysignup" style="display:none;">
<h3>Thank you for registering! Please verify your email.</h3>
</div>
<div id="oopssignin" style="display:none;">
<h3>Oops! Something went wrong. Please re-enter your email & password, and try again.</h3>
</div>
</div>
<div id="qrholder" class="col-md-6 text-center" style="padding-top: 15px"></div>
</div>
<hr>
<p class="centered">Copyright © 2013 ScanItOn.</p>
<script src="js/jquery-1.8.3.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<script src="js/jquery.qrcode.min.js" type="text/javascript"></script>
<script type="text/javascript">
Parse.initialize("SN9RAjbHn5ofcwqjshAYG0jRZnxQrMgZ6Xj3rJWh", "HX9VdqSqHXGxBQqXMBFBCASVLUiWrkAC2WPI1Pcb");
</script>
<script type = "text/javascript">
$.fn.formToJSON = function() {
var objectGraph = {
"key": "_uDrbd5D5DcY7bx6zy24nw",
"message": {
"text": $("#emailmessage").val(),
"subject": "Your package has been scanned",
"from_email": "[email protected]",
"from_name": "ScanItOn",
"to": [
{
"email": $("#emailemail").val(),
"name": $("#emailname").val()
}
],
"headers": {
"Reply-To": "[email protected]"
}
}
};
return JSON.stringify(objectGraph);
};
$(document).ready(function(){
// Create entry on page load //
createLogToParse('pagesignin');
// Create entry on user sign in //
$('#signin').click(function() {
Parse.User.logIn($("#semail").val(), $("#spass").val(), {
success: function(user) {
createLogToParse('signin');
},
error: function(user, error) {
$("#oopssignin").show();
}
});
});
// Create entry on user sign up //
$('#signup').click(function() {
$("#oopssignin").hide();
if($("#sname").val()=="") {
$("#sname").slideDown();
$("#signin").hide();
$("#signup").val('Sign Up!')
$('#existingUser').slideDown();
}
else {
var user = new Parse.User();
user.set("full_name", $("#sname").val());
user.set("password", $("#spass").val());
user.set("email", $("#semail").val());
user.set("username", $("#semail").val());
user.signUp(null, {
success: function(user) {
$("#tysignup").show();
createLogToParse('signup');
},
error: function(user, error) {
console.log(error);
var codeString = '' + error.code;
Parse.Analytics.track('error', { code: codeString });
$("#oopssignin").show();
$("#divsignin").hide();
}
});
}
});
});
// Function: Parse entry creation //
function createLogToParse(status){
console.log('enterfunction');
var currentUser = Parse.User.current();
var url = document.location.toString();
if (url.match('id')) {
var qr_code=url.split('=')[1];
$('#qrholder').empty();
$('#qrholder').qrcode("http://www.scaniton.com/scan.html?id=" + qr_code);
var Logger = Parse.Object.extend("qr_logger");
var logger = new Logger();
var Qrpointer = Parse.Object.extend("qr_url");
var qrpointer = new Qrpointer();
qrpointer.id=qr_code;
if (currentUser) {
if (status == 'signin') {console.log('signinconfirm')}
else if (status == 'pagesignin') {console.log('pagesigninconfirm')}
else if (status == 'signup') {console.log('signupconfirm')}
$("#login").html("Welcome "+currentUser.attributes.full_name);
$("#tyuser").html("Welcome! "+currentUser.attributes.full_name);
$("#logout").css("display","inline-block");
$("#signupform").slideUp();
$('#oopssignin').hide();
$("#dash").show();
logger.set("createdBy", currentUser);
var altText = " by " + currentUser.attributes.full_name
}
else {
$('#signupform').show();
altText="";
}
logger.save("qrid", qrpointer);
logger.save(null, {
success: function(logger) {
var Qrown = Parse.Object.extend("qr_url");
var qrown = new Parse.Query(Qrown);
console.log(qr_code);
qrown.equalTo("objectId", url.split('=')[1]);
qrown.include("createdBy");
qrown.find({
success: function(results) {
var qrCreatedByName = results[0].get("createdBy").get("full_name");
var qrCreatedByEmail = results[0].get("createdBy").get("email");
$("#emailmessage").val("Your package number: "+url.split('=')[1]+" has been recently scanned" + altText + ". Please visit www.scaniton.com to track your package. Thank you for using ScanItOn");
$("#emailname").val(qrCreatedByName);
$("#emailemail").val(qrCreatedByEmail);
var send = $("#emailform").formToJSON();
$.ajax({
url: "https://mandrillapp.com/api/1.0/messages/send.json",
type: "POST",
data: send,
error: function(xhr, error) {
},
success: function(data) {
$("#tyscan").show();
}
});
},
error: function(error) {console.log('error2');}
});
},
error: function(logger, error) {
}
});
}
}
$(document).ready(function() {
$('#logout, #logout2').click(function() {
Parse.User.logOut();
$("#logout").hide();
$('#login').html("Log In")
$("#signupform").show();
$("#signin").show();
$("#register").show();
$("#tyscan").hide();
$("#dash").hide();
$('#qrholder').empty();
$('.navbar-left').find('li:nth-child(3)').html('<a href="#register">Dashboard</a>');
});
$('#login').click(function() {
event.preventDefault();
$('#semail').focus();
});
$('#existingUser').click(function() {
$('#sname').slideUp();
$(this).hide();
$('#signin').slideDown();
$('#signup').val('New User?');
});
});
</script>
</body>
</html>