-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathapplication.js
More file actions
35 lines (30 loc) · 1.01 KB
/
application.js
File metadata and controls
35 lines (30 loc) · 1.01 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
;(function($) {
$(function() {
var $repositories = $('#repositories');
var $search_text = $('#search_text');
// give the search box focus
$search_text.focus();
$('#github_search').submit(function(e) {
e.preventDefault();
// trick or treat
if ($search_text.val()=='') $search_text.val('codeofficer');
$repositories.empty();
$repositories.append("<li><img src ='assets/ajax-loader.gif' alt='loading' /></li>");
// repository search
$.get('https://github.com/api/v2/json/repos/search/' + escape($search_text.val()), function(json){
$.get('templates/repository.ejs', function(template){
$repositories.empty();
if (json.repositories.length > 0) {
$.each(json.repositories, function(index, repository) {
var html = $.srender(template, repository);
$repositories.append(html);
$("abbr.relatize").timeago();
});
} else {
$repositories.append("<li>No results found.</li>");
};
});
});
});
});
})(jQuery);