/
FriendList.js
76 lines (76 loc) · 2 KB
/
FriendList.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
73
74
75
76
var curpos;
var listLength=4;
var friends_with_sidebar;
function DisplayFriendLoadWait()
{
boardArea.removeAllContentItems();
boardArea.contentFlags=gddContentFlagHaveDetails;
AddButtonAuto(strCancel,OnCancelNotify);
AddLabelAuto(strFindingFriends)
};
function DrawFriends()
{
DisplayFriendLoadWait();
var friends=googleTalk.friends.toArray();
friends_with_sidebar=new Array();
for(var i=0;i<friends.length;i++)
{
if(friends[i].has_sidebar)
friends_with_sidebar.push(friends[i])
}
if(!friends_with_sidebar.length)
{
boardArea.removeAllContentItems();
boardArea.contentFlags=gddContentFlagHaveDetails;
AddButtonTextImgAuto(strGoToMainMenu,imgBlueList[10],OnCancelNotify);
AddLabelAuto(strNoFriendsOnline);
AddImageAuto(imgMain);
return
}
boardArea.removeAllContentItems();
boardArea.contentFlags=gddContentFlagHaveDetails;
MakeFirstList()
};
function MakeFirstList()
{
curpos=0;
MakeFriendList()
};
function OnNext(item)
{
MakeFriendList()
};
function OnPrev(item)
{
curpos-=listLength*2;
MakeFriendList()
};
function MakeFriendList()
{
boardArea.removeAllContentItems();
boardArea.contentFlags=gddContentFlagHaveDetails;
if(curpos+listLength<friends_with_sidebar.length)
AddButtonAuto("next",OnNext);
for(var i=curpos;i<Math.min(friends_with_sidebar.length,curpos+listLength);i++)
{
var icon;
if(friends_with_sidebar[i].status==gddFriendStatusOnline)
{
icon=imgBlueList[0]
}
else if(friends_with_sidebar[i].status==gddFriendStatusBusy)
{
icon=imgGreen
}
else
{
icon=imgBlueList[12]
}
AddButtonTextImgAuto(friends_with_sidebar[i].name,icon,OnStartMultiPlayer,friends_with_sidebar[i].user_id)
}
if(curpos>0)
AddButtonAuto("prev",OnPrev);
curpos+=listLength;
AddButtonTextImgAuto(strGoToMainMenu,imgBlueList[10],OnCancelNotify);
AddImageAuto(imgMainSmall)
}