-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
83 lines (78 loc) · 3.23 KB
/
index.html
File metadata and controls
83 lines (78 loc) · 3.23 KB
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
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<meta name="google-signin-client_id" content="403092275269-8ubnhiaih6ngk6t3vf3bidlak6f92ten.apps.googleusercontent.com">
<script src="https://apis.google.com/js/client:platform.js?onload=renderButton" async defer></script>
<script src="https://rawgit.com/schmich/instascan-builds/master/instascan.min.js"></script>
<title>Google Sign In</title>
</head>
<body>
<center>
<div id="gSignIn"></div>
<div class="userContent" style="display: none;"></div>
<video id="preview" style="display: none;"></video>
<embed src="beep.wav" autostart="false" width="0" height="0" id="sound" enablejavascript="true">
</center>
<script>
function renderButton() {
gapi.signin2.render('gSignIn', {
'scope': 'profile email',
'width': 240,
'height': 50,
'longtitle': true,
'theme': 'dark',
'onsuccess': onSuccess
});
}
function scannerQR() {
let scanner = new Instascan.Scanner(
{
video: document.getElementById('preview')
});
scanner.addListener('scan', function(content){
console.log(content);
PlaySound();
});
Instascan.Camera.getCameras().then(function(cameras){
if (cameras.length > 0) {
scanner.start(cameras[0])
} else {
console.log('No camera Found!');
}
}).catch(function(e){
console.error(e);
});
}
function onSuccess(googleUser) {
gapi.client.load('oauth2', 'v2', function () {
var request = gapi.client.oauth2.userinfo.get({
'userId': 'me'
});
request.execute(function (resp) {
var profileHTML = '<h3>Welcome '+resp.given_name+'! <a href="javascript:void(0);" onclick="signOut();">Sign out</a></h3>';
profileHTML += '<img src="'+resp.picture+'"/><p><b>Google ID: </b>'+resp.id+'</p><p><b>Name: </b>'+resp.name+'</p><p><b>Email: </b>'+resp.email+'</p><p><b>Gender: </b>'+resp.gender+'</p><p><b>Locale: </b>'+resp.locale+'</p><p><b>Google Profile:</b> <a target="_blank" href="'+resp.link+'">click to view profile</a></p>';
document.getElementsByClassName("userContent")[0].innerHTML = profileHTML;
document.getElementById("gSignIn").style.display = "none";
document.getElementsByClassName("userContent")[0].style.display = "block";
document.getElementById("preview").style.display = "block";
scannerQR();
});
});
}
function signOut() {
var auth2 = gapi.auth2.getAuthInstance();
auth2.signOut().then(function () {
document.getElementsByClassName("userContent")[0].innerHTML = '';
document.getElementsByClassName("userContent")[0].style.display = "none";
document.getElementById("gSignIn").style.display = "block";
});
auth2.disconnect();
}
function PlaySound() {
var sound = new Audio('beep.wav');
sound.play()
}
</script>
</body>
</html>