forked from buildit/totem
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwelcome.html
81 lines (64 loc) · 2.3 KB
/
welcome.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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, user-scalable=no
initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0" />
<title>Microbit Sensors</title>
<style>
@import 'ui/css/evothings-app.css';
</style>
<script>
function getQueryVariable(variable)
{
var query = window.location.search.substring(1);
var vars = query.split("&");
for (var i=0;i<vars.length;i++) {
var pair = vars[i].split("=");
if(pair[0] == variable){return pair[1];}
}
return(false);
}
var token_code = getQueryVariable("code");
var temp_token ='xoxp-3360794059-3518803224-233131626928-8cdbab0f8c3359eff31d69cc2e72b186'
console.log(token_code);
function changeStatus()
{
console.log(localStorage.getItem("token_code"));
var url = 'https://slack.com/api/users.profile.set'
xhr.open("POST", url, true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
xhr.send('token='+temp_token+'&profile=%7B%22status_text%22%3A%22Hello%20There%22%2C%22status_emoji%22%3A%22%3Asunglasses%3A%22%7D');
}
var xhr = new XMLHttpRequest();
xhr.open('GET', 'https://slack.com/api/oauth.access?client_id=3360794059.221548354467&client_secret=2942f6d254a6321cbf469ee9e69a8bf3&code='+token_code);
xhr.onload = function() {
if (xhr.status === 200) {
var obj = JSON.parse(xhr.responseText);
console.log(obj.user.name);
console.log(obj.user.id);
console.log(obj.team.id);
console.log(xhr.responseText);
localStorage.setItem("username", obj.user.name );
localStorage.setItem("token_code", token_code );
localStorage.setItem("teamID", obj.team.id);
localStorage.setItem("userID", obj.user.id );
var username = localStorage.getItem("username");
var teamID = localStorage.getItem("teamID");
var userID = localStorage.getItem("userID");
document.getElementById('name').innerHTML = '<h2><b>Hello ' + username+'</b></h2>';
}
else {
alert('Request failed. Returned status of ' + xhr.status);
}
};
xhr.send();
</script>
</head>
<body ontouchstart=""><!-- ontouchstart="" enables low-delay CSS transitions. -->
<div id="name"></div>
<button id="disconnect-button" class="charcoal" ref="index.html">
continue
</button>
</body>
</html>