-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathmain.js
More file actions
59 lines (44 loc) · 1.2 KB
/
Copy pathmain.js
File metadata and controls
59 lines (44 loc) · 1.2 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
$(function() {
var getInfo = function(callback) {
Twitch.api({method: 'channel'}, function(error, channel) {
callback(channel);
});
}
Twitch.init({clientId: 'pugdziizvbmk12pd1qkp8svt3ptb7zp'}, function(error, status) {
console.log(status);
if (status.authenticated) {
$('.twitch-connect').hide();
getInfo(function(data) {
$('strong').text(data.display_name);
$('#picture').attr('src','http://static-cdn.jtvnw.net/jtv_user_pictures/soldiercorp_-profile_image-3446f50591a2e810-300x300.png');
$('#visit').text('Visita mi canal').attr('href','http://www.twitch.tv/soldiercorp_');
});
} else {
$('#login-info').hide();
}
});
var login = function()
{
Twitch.login({
scope: ['user_read', 'channel_read']
});
}
var logout = function()
{
Twitch.logout(function(error) {
$('.twitch-connect').show();
$('strong').text('');
$('#picture').attr('src','');
$('#visit').text('').attr('href','#');
$('#login-info').hide();
});
}
$('.twitch-connect').click(function(e) {
e.preventDefault();
login();
})
$('.twitch-disconnect').click(function(e) {
e.preventDefault();
logout();
})
})