-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathapplication.js
72 lines (55 loc) · 1.17 KB
/
application.js
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
/*
* Get instagram user ID
*/
(function(){
var _init
, _getUserData
, _displayUserData
, _login
;
var access_token
;
$.extend({
instagramr: function(){
_init();
}
});
_init = function(){
// Remove no-js class
$('html').removeClass('no-js');
// Check if user is logged in
_login();
// Event handlers
$('#get-user-data').click(_getUserData);
};
_getUserData = function(event){
event.preventDefault();
var request = $.ajax({
dataType: "jsonp",
url: "https://api.instagram.com/v1/users/self",
data: {
access_token: access_token
}
});
request.success(_displayUserData);
};
_login = function(){
access_token = location.hash.split('=')[1];
if (access_token === undefined) {
$('body').addClass('not-logged-in');
} else {
$('body').addClass('logged-in');
}
};
_displayUserData = function(json){
$("#result").html("")
.fadeIn(300)
.append("Your user ID is: " + json.data.id);
};
})(jQuery);
/*
* Initialize on DOM Ready
*/
$(function(){
$.instagramr();
});