/
site.js
59 lines (51 loc) · 2.14 KB
/
site.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
//50506
var tw;
var insertUser = function (user){
var template = $('.template').clone();
template.find('.name a').html(user.screen_name);
template.find('.name a').attr('href' ,'http://twitter.com/'+user.screen_name);
template.find('img').attr('src' ,user.profile_image_url);
template.find('.following .count').html(user.friends_count);
template.find('.followers .count').html(user.followers_count);
template.find('.minus').attr('onClick','tw.unfollowByScreenName("'+ user.screen_name +'",function() {alert("Unfollowed '+ user.screen_name +'");});');
$(template).appendTo('#userlist').hide().removeClass('template').addClass('added').addClass('userclass' + user.screen_name).show();
}
var setProfile = function(user){
var profile = $('.profile');
profile.find('.name').html(user.screen_name);
profile.find('img').attr('src' ,user.profile_image_url);
profile.find('.following .count').html(user.friends_count);
profile.find('.followers .count').html(user.followers_count);
profile.find('.followbacks .count').html(tw.reciprications.length);
profile.find('.fans .count').html(tw.fans.length);
profile.find('.nofollowback .count').html(tw.toogoodforme.length);
};
var clearList = function() {
$('.added').remove();
$('.box').removeClass('selected');
}
var populateList = function(list){
$('#userlist').hide();
_.map(list,function(item){
insertUser(item);
});
setTimeout("$('#userlist').slideDown('slow');",1);
}
var replaceList = function(list){
$('.profile').find('img').attr('src' ,'/images/spinner.gif');
clearList();
populateList(list);
$('.profile').find('img').attr('src' ,tw.personalprofile.profile_image_url);
}
var setStatusBar = function(percent, message){
$('#progressbar').css('width', (percent+'%'));
$('#progressstatus span').html( (message || '') );
}
var showError = function(error){
var profile = $('.profile');
profile.find('.name').html(theuser);
profile.find('img').attr('src' ,'/images/fail-avatar.png');
$('#errorbox span').html(error);
$('#progressbox').slideUp('slow');
$('#errorbox').slideDown('slow');
}