-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlikemashup.behance.js
46 lines (36 loc) · 1.24 KB
/
likemashup.behance.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
;(function($, window, document, undefined) {
'use strict';
$.lm_behance = {};
var jsonpGET = function (path, args) {
$.ajax({
type: 'GET',
url: ' http://www.behance.net/v2' + path + "?api_key=gPVGVtNKZxWBqYZbM4jF37ionx4ugsmN",
data: args[1] || {},
success: function (data) {
if (typeof (data) === 'undefined') {
args[0]({error: true});
}
else {
args[0](data);
}
}
});
};
var methods = {
'getUserAppreciations': '/users/$/appreciations',
'getProject': '/projects/$/',
};
var createAPIMethod = function (urlPattern) {
return function () {
var // Convert arguments to a real Array
args = [].slice.call(arguments),
// We run shift() on args here because we don't need to send
// the first argument to jsonpGET.
url = urlPattern.replace('$', args.shift());
jsonpGET(url, args);
};
};
for (var method in methods) {
$.lm_behance[method] = createAPIMethod(methods[method]);
}
})(jQuery, window , document);