-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
91 lines (86 loc) · 2.88 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
<!DOCTYPE html>
<html lang="en">
<head>
<title>Bucket</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script type="text/javascript" src="qrcode/qrcode.js"></script>
<!-- <link href="https://fonts.googleapis.com/css?family=Sansita" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Lobster|Sansita" rel="stylesheet"> -->
<!-- pusher -->
<script src="//js.pusher.com/3.1/pusher.min.js" type="text/javascript"></script>
<script src="//code.jquery.com/jquery-2.1.3.min.js" type="text/javascript"></script>
<link rel="stylesheet" href="index.css">
</head>
<body>
<div class="container">
<h1 style="text-align: center; margin-top:35px; ">Welcome to Bucket!</h1>
<div class="box" style="padding:80px 30px 80px 30px; ">
<div class="row">
<div style="text-align: center;" class="col-md-4" id="qrcode"></div>
<div class="col-md-8" style="padding: 0px 40px 0px 40px">
<h4>Use the Android App to scan the QR code on your phone!</h4>
<img class="android-thumbnail" src="img/android.png">
</div>
</div>
</div>
</div>
</body>
<script>
$( document ).ready(function() {
var host_name = "http://9c1a3ec5.ngrok.io/";
var user_key = '';
$.ajax({
url: host_name + 'user/new',
type: 'GET',
dataType: 'json',
// cache: false,
// contentType: false,
// processData: false,
success: function( data ){
console.log(data.success);
if(data.success == true){
console.log(data);
user_key = data.user_key;
document.cookie = "user_key=" + user_key;
console.log(user_key);
generateQR(user_key);
}
}
});
function generateQR(user_key){
var qrcode = new QRCode('qrcode', {
text: user_key,
width: 230,
height: 230,
colorDark : "#000000",
colorLight : "#ffffff",
correctLevel : QRCode.CorrectLevel.H
});
qrcode.makeCode(user_key);
}
// Initialize pusher
var pusher = new Pusher('31932a4df70b512824e3', {
cluster: 'eu',
encrypted: true
});
var channel = pusher.subscribe('ICStrangers');
channel.bind("on_connection" , function(data){
console.log(data);
if (data.destination_key == user_key) {
document.cookie = "bucket_key=" + data.bucket_key;
window.location.replace("bucket.html");
}
});
// channel.bind("bucket_updated" , function(data){
// console.log("Update Bucket Notified");
// });
// channel.bind("bucket_destroyed" , function(data){
// console.log("Destroy Bucket Notified");
// });
});
</script>
</html>