formatted

 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
(function() {
var $body = $(document.body);
// добавление в друзья
$body.on('click', '.js-add-friend', function (e) {
e.preventDefault();
e.stopPropagation();
var el = $(this),
user = el.data('user');
Spaces.api("friends.offer", {user: user, CK: null}, function (res) {
if (res.code == 0) {
$('.js-add-friend').hide();
$('.friends_link_requested').show();
} else {
Spaces.showApiError(res);
}
}, {prefix: "neoapi"});
});
// добавление в ленту
$body.on('click', '.js-add-lenta', function (e) {
e.preventDefault();
e.stopPropagation();
var el = $(this),
oname = el.data('oname'),
ot = el.data('ot');
Spaces.api("lenta.authorAdd", {oname: oname, Ot: ot, CK: null}, function (res) {
if (res.code == 0) {
$('.js-add-lenta').hide();
$('.delete_from_lenta_link').show();
} else {
Spaces.showApiError(res);
}
}, {prefix: "neoapi"});
});
// удаление из друзей
$body.on('click', '.js-remove-friend', function (e) {
e.preventDefault();
e.stopPropagation();
var el = $(this),
user = el.data('user');
Spaces.api("friends.delete", {user: user, CK: null}, function (res) {
if (res.code == Codes.COMMON.SUCCESS){
$('.not_friends_link, .delete_from_lenta_link').hide();
$('.friends_link_item, .add_to_lenta_link').show();
$body.trigger('click');
} else {
Spaces.showApiError(res);
}
}, {prefix: "neoapi"});
});
// удаление из ленты
$body.on('click', '.js-remove-lenta', function (e) {
e.preventDefault();
e.stopPropagation();
var el = $(this),
oname = el.data('oname'),
ot = el.data('ot');
Spaces.api("lenta.authorDelete", {oname: oname, Ot: ot, CK: null}, function (res) {
if (res.code == 0) {
$('.delete_from_lenta_link').hide();
$('.add_to_lenta_link').show();
$body.trigger('click');
} else {
Spaces.showApiError(res);
}
}, {prefix: "neoapi"});
});
// отмена заявки в друзья
$body.on('click', '.js-cancel-friend-request', function (e) {
e.preventDefault();
e.stopPropagation();
var el = $(this),
user = el.data('user');
Spaces.api("friends.revokeOffer", {user: user, CK: null}, function (res) {
if (res.code == Codes.COMMON.SUCCESS) {
$('.friends_link_requested').hide();
$('.friends_link_item').show();
$body.trigger('click');
} else {
Spaces.showApiError(res);
}
}, {prefix: "neoapi"});
});
})();