-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdasuiFriends.js.disabled
150 lines (115 loc) · 6.95 KB
/
dasuiFriends.js.disabled
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
var firstFriendLength = -1;
loadFriends = function(_list){
if(firstFriendLength == -1){
firstFriendLength = _list.length;
friendList = _list;
}
for (var i=0; i < friendList.length; i++){
friendList[i].FilterTags += ','+(friendList[i].UserIsOnline?'frndonline':'frndoffline');
}
renderFriends(_list);
OrderFriendlist();
// filterFriendList("frndonline")
}
renderFriends = function(_list){
// var contentList = document.querySelector('#friends .list-content');
/*
var html = '<div class="flex-list">';
for(var i=0; _list[i]; i++){
html += '<div data-id="'+_list[i].UserId+'" class="content-cell friend" onclick="getUserDetailsNew(\''+_list[i].UserId+'\',event);" onmousedown="mousedowntest(event);"><div class="content-cell-formatter"></div>'+
'<div class="content-cell-content"><div class="online-state-test '+(_list[i].UserIsOnline?'online':'offline')+' '+_list[i].FilterTags+'">'+
'<img class="content-image online-state-image '+(_list[i].UserIsOnline?'online':'offline')+'" src="'+
_list[i].UserImageUrl+'"></div><div class="content-name">'+
_list[i].UserName.makeSafe()+'</div></div>'+
'</div>';
}
html += '</div>';
contentList.innerHTML = html;
*/
// document.querySelector('#friends .list-content .flex-list').innerHTML = "";
for(var i=0; _list[i]; i++){
if (cvr('#friends .list-content .flex-list #frnd_'+_list[i].UserId+'').length == 0){
AddFriendLoading(_list[i]);
} else {
UpdateFriendNew(_list[i]);
}
}
}
function OrderFriendlist(){
// friendList.sort(function(a,b){
// return b.UserIsOnline - a.UserIsOnline;
// });
friendList.sort(function(a,b){
return a.UserName.toLowerCase().localeCompare(b.UserName.toLowerCase());
});
friendList.sort(function(a,b){
return b.UserIsOnline - a.UserIsOnline;
});
var parent = document.querySelector('#friends .list-content .flex-list');
for(var i = friendList.length-1; friendList[i];i--){
var node = document.querySelector('#friends .list-content .flex-list #frnd_'+friendList[i].UserId);
parent.insertBefore(node,parent.childNodes[0]);
}
}
UpdateFriend = function(_friend){
return;
}
function UpdateFriendNew(_friend){
cvr('#friends .list-content .flex-list #frnd_'+_friend.UserId).className('content-cell friend '+(_friend.UserIsOnline?'frndonline':'frndoffline'));
cvr('#friends .list-content .flex-list #frnd_'+_friend.UserId+' .online-state-test').className('online-state-test '+(_friend.UserIsOnline?'online':'offline')+' '+_friend.FilterTags);
if (cvr('#friends .list-content .flex-list #frnd_'+_friend.UserId+' .content-image').first().getAttribute('src') != _friend.UserImageUrl) {
cvr('#friends .list-content .flex-list #frnd_' + _friend.UserId + ' .content-image').attr('src', _friend.UserImageUrl);
}
cvr('#friends .list-content .flex-list #frnd_'+_friend.UserId+' .content-name').innerHTML(_friend.UserName.makeSafe());
var foundIndex = friendList.findIndex(x => x.UserId == _friend.UserId);
friendList[foundIndex].UserIsOnline = _friend.UserIsOnline;
console.log("updatefrends");
OrderFriendlist();
}
AddFriend = function(_friend){
var html =
'<div id="frnd_'+_friend.UserId+'" status="'+_friend.UserIsOnline+'" class="content-cell friend '+(_friend.UserIsOnline?'frndonline':'frndoffline')+'" onclick="getUserDetailsNew(\''+_friend.UserId+'\',event);" onmousedown="mousedowntest(event);">'+
'<div class="content-cell-formatter"></div>'+
'<div class="content-cell-content"><div class="online-state-test '+(_friend.UserIsOnline?'online':'offline')+' '+_friend.FilterTags+'"></div>'+
'<img class="content-image online-state-image '+(_friend.UserIsOnline?'online':'offline')+'" src="'+
_friend.UserImageUrl+'"><div class="content-name">'+
_friend.UserName.makeSafe()+'</div>'+
'</div></div>';
cvr('#friends .list-content .flex-list').addHTML(html);
OrderFriendlist();
}
function AddFriendLoading(_friend){
var html =
'<div id="frnd_'+_friend.UserId+'" status="'+_friend.UserIsOnline+'" class="content-cell friend '+(_friend.UserIsOnline?'frndonline':'frndoffline')+'" onclick="getUserDetailsNew(\''+_friend.UserId+'\',event);" onmousedown="mousedowntest(event);">'+
'<div class="content-cell-formatter"></div>'+
'<div class="content-cell-content"><div class="online-state-test '+(_friend.UserIsOnline?'online':'offline')+' '+_friend.FilterTags+'"></div>'+
'<img class="content-image online-state-image '+(_friend.UserIsOnline?'online':'offline')+'" src="'+
_friend.UserImageUrl+'"><div class="content-name">'+
_friend.UserName.makeSafe()+'</div>'+
'</div></div>';
cvr('#friends .list-content .flex-list').addHTML(html);
}
document.styleSheets[0].insertRule(".friend .content-cell-formatter{ margin-top: 2em !important; }");
document.styleSheets[0].insertRule(".content-cell.friend{ width: 18.5% !important; margin-right: 1.5% !important; margin-bottom: 1.5% !important; /* NEW */ background-color: rgba(150,150,150,0.6) !important; border: none !important; border-radius: 5px !important; /* box-shadow: 5px 5px 10px 5px rgba(181,175,174,0.5); */ }");
document.styleSheets[0].insertRule(".content-cell.friend:hover { background-color: rgba(150,150,150,0.8) !important; }");
document.styleSheets[0].insertRule(".friend .content-cell-content{ left: 6% !important; }");
document.styleSheets[0].insertRule(".friend .online-state-test { position: absolute !important; width: 100% !important; height: auto !important; bottom: 2em !important; top: 0 !important; border-radius: 10px !important; }");
document.styleSheets[0].insertRule(".friend .online-state-test.online { box-shadow: 0px 0px 20px 10px #00cc00 !important; }");
document.styleSheets[0].insertRule(".friend .online-state-test.offline { box-shadow: 0px 0px 20px 10px #cc0000 !important; }");
document.styleSheets[0].insertRule(".friend .online-state-image.offline { filter: grayscale(100%) !important; }");
document.styleSheets[0].insertRule(".friend .content-name{ left: -6% !important; bottom: -6% !important; width: 112% !important; height: 2em !important; /* background-color: rgba(150,150,150,0.8); */ line-height:2em !important; }");
document.styleSheets[0].insertRule(".friend .content-image{ position: unset !important; width: 100% !important; height: 83% !important; bottom: unset !important; top: unset !important; border-radius: unset !important; }");
function getUserDetailsNew(_uid,e){
var dif = {x:0,y:0};
dif.x = e.clientX - mousedownlocation.x;
dif.y = e.clientY - mousedownlocation.y;
if(mousedownlocation.x === 0 && mousedownlocation.y === 0){
dif = {x:0,y:0};
}
if(Math.abs(dif.x) > 50 || Math.abs(dif.y) > 50){
return;
}
mousedownlocation = {x:0,y:0};
engine.call('CVRAppCallGetUserDetails', _uid);
}
console.log("Loaded friends");