Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // gid - id группы, если указан, то все друзья состоящие в группе обнуляются
- function getFriends(cb, opts) {
- opts = opts || {};
- ajax.post('al_friends.php', {
- act: 'load_friends_silent',
- al: 1,
- gid: opts['gid'] || 0,
- id: vk.id
- }, {
- onDone: function(a, b, c) {
- // a - друзья, b - учебные заведения, c - города
- var friends;
- eval('friends = (' + a + ').all');
- if ( opts['gid'] ) {
- friends = friends.filter(function(el) {
- return el;
- });
- }
- if ( opts['online'] ) {
- friends = friends.filter(function(el) {
- return parseInt( el[4] );
- });
- }
- if ( opts['filters'] ) {
- if (opts['filters']['city']) {
- for (var i = 0, l = c.cities.length; i < l; ++i) {
- if (c.cities[i][1] == opts['filters']['city']) {
- opts['filters']['city'] = c.cities[i][0];
- break;
- }
- }
- }
- ajax.post('friends', {
- act: 'filter_friends',
- ads_section: 'friends',
- age_from: opts['filters']['age_from'] || 0,
- age_to: opts['filters']['age_to'] || 0,
- al: 1,
- al_ad: 1,
- // код города
- city: opts['filters']['city'] || 0,
- // 1 - женский, 2 - мужской
- sex: opts['filters']['sex'] ? ( opts['filters']['sex'] == 'м' ? 2 : ( opts['filters']['sex'] == 'ж' ? 1 : 0 ) ) : 0,
- uid: vk.id
- }, {
- onDone: function(filtered) {
- friends = friends.filter(function(el) {
- return filtered.indexOf( el[0] ) > -1;
- });
- cb(friends);
- }
- });
- return;
- }
- cb(friends);
- }
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment