Skip to content

Commit

Permalink
First commit - not working yet
Browse files Browse the repository at this point in the history
  • Loading branch information
bernatfortet committed May 20, 2013
0 parents commit 46107fd
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 0 deletions.
46 changes: 46 additions & 0 deletions likemashup.behance.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,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);
15 changes: 15 additions & 0 deletions test.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<!DOCTYPE html>
<head>
<meta charset="utf-8">
<title></title>
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script src="./likemashup.behance.js"></script>
<script>

$.lm_behance.getUserAppreciations("bernatfortet", function( data ){
console.log(data);
})
</script>
</head>
<body>
</body>

0 comments on commit 46107fd

Please sign in to comment.