Hormold

VK Change (#1378727102)

Sep 9th, 2013
575
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 286.48 KB | None | 0 0
  1. Файл - audio.js (Старый размер - 92328 | Новый - 0):
  2. 0.  - var Audio = {
  3. 1.  -   address: '/audio',
  4. 2.  -   scrollnode: browser.msie6 ? pageNode : window,
  5. 3.  -   fixedScroll: !(browser.msie && browser.version < 8 || browser.mobile),
  6. 4.  -   init: function(obj, audioTpl) {
  7. 5.  -     extend(cur, {
  8. 6.  -       searchCont: ge('audio_search'),
  9. 7.  -       aSearch: ge('s_search'),
  10. 8.  -       clearSearch: ge('audio_query_reset'),
  11. 9.  -       aContent: ge('initial_list'),
  12. 10.  -       sContent: ge('search_list'),
  13. 11.  -       sPreload: ge('search_preload'),
  14. 12.  -       showMore: ge('more_link'),
  15. 13.  -       sShowMore: ge('s_more_link'),
  16. 14.  -       sWrap: ge('audio_search_wrap'),
  17. 15.  -       sSummary: ge('audio_search_summary'),
  18. 16.  -       albumFilters: ge('album_filters'),
  19. 17.  -       albumFiltered: ge('album_filtered'),
  20. 18.  -       searchFilters: ge('audio_search_filters'),
  21. 19.  -       popularFilters: ge('audio_popular_filters'),
  22. 20.  -       popularOwners: ge('audio_popular_owners'),
  23. 21.  -       audioFriends: ge('audio_friends'),
  24. 22.  -       audioAlbums: ge('audio_albums'),
  25. 23.  -       audioAlbumsWrap: ge('audio_albums_wrap'),
  26. 24.  -       audioWrap: ge('audio_wrap'),
  27. 25.  -       searchInfoCont: ge('audio_search_info'),
  28. 26.  -       searchStr: "",
  29. 27.  -       autoComplete: 1,
  30. 28.  -       audioTpl: audioTpl,
  31. 29.  -       audioEl: {
  32. 30.  -         head: ge('page_header'),
  33. 31.  -         bar: ge('ac'),
  34. 32.  -         cont: ge('audio'),
  35. 33.  -         filters: ge('side_filters')
  36. 34.  -       }
  37. 35.  -     });
  38. 36.  -
  39. 37.  -     if (ge('ac') && window.audioPlayer) {
  40. 38.  -       audioPlayer.initEvents();
  41. 39.  -       audioPlayer.registerPlayer('ac', {
  42. 40.  -         container: ge('ac'),
  43. 41.  -         performer: ge('ac_performer'),
  44. 42.  -         title: ge('ac_title'),
  45. 43.  -         titleWrap: ge('ac_name'),
  46. 44.  -         duration: ge('ac_duration'),
  47. 45.  -         load: ge('ac_load_line'),
  48. 46.  -         progress: ge('ac_pr_line'),
  49. 47.  -         progressArea: ge('ac_pr'),
  50. 48.  -         volume: ge('ac_vol_line'),
  51. 49.  -         volumeArea: ge('ac_vol'),
  52. 50.  -         play: ge('ac_play'),
  53. 51.  -         prev: ge('ac_prev'),
  54. 52.  -         next: ge('ac_next'),
  55. 53.  -         add: ge('ac_add'),
  56. 54.  -         repeat: ge('ac_repeat'),
  57. 55.  -         shuffle: ge('ac_shuffle'),
  58. 56.  -         rec: ge('ac_rec'),
  59. 57.  -         status: ge('ac_status'),
  60. 58.  -         fixed: !(browser.msie && browser.version < 8 || browser.mobile)
  61. 59.  -       });
  62. 60.  -     }
  63. 61.  -     if (browser.mobile) {
  64. 62.  -       hide('ac_vol');
  65. 63.  -       setStyle('ac_duration', {margin: 0});
  66. 64.  -     }
  67. 65.  -
  68. 66.  -     if (!cur.allAudiosIndex) cur.allAudiosIndex = 'all';
  69. 67.  -
  70. 68.  -     extend(cur, obj);
  71. 69.  -     cur.module = 'audio';
  72. 70.  -     //cur.disableAutoMore = true;
  73. 71.  -     if (cur.aSearch) {
  74. 72.  -       cur.aSearch.value = cur.q;
  75. 73.  -       toggleClass(cur.clearSearch, 'shown', !!cur.q);
  76. 74.  -       placeholderSetup(cur.aSearch, {back: true});
  77. 75.  -       setTimeout(function() {
  78. 76.  -         cur.aSearch.focus();
  79. 77.  -       }, 0);
  80. 78.  -     }
  81. 79.  -
  82. 80.  -     Audio.scrollnode = browser.msie6 ? pageNode : window;
  83. 81.  -     Audio.fixedScroll = !(browser.msie && browser.version < 8 || browser.mobile);
  84. 82.  -     window.scrollTop = bodyNode.scrollTop = pageNode.scrollTop = htmlNode.scrollTop = 0;
  85. 83.  -     Audio.startEvents();
  86. 84.  -     cur.destroy.push(function() {
  87. 85.  -       Audio.stopEvents();
  88. 86.  -     });
  89. 87.  -
  90. 88.  -     cur.nav.push(function(changed, old, n) {
  91. 89.  -       if (changed.act == 'popular') {
  92. 90.  -         Audio.loadPopular(true, intval(n.genre));
  93. 91.  -         return false;
  94. 92.  -       }
  95. 93.  -     });
  96. 94.  -
  97. 95.  -
  98. 96.  -     var _a = window.audioPlayer;
  99. 97.  -     if (_a && _a.showCurrentTrack) {
  100. 98.  -       _a.shuffle = false;
  101. 99.  -       _a.showCurrentTrack();
  102. 100.  -     }
  103. 101.  -
  104. 102.  -     cur.audios = {};
  105. 103.  -     hide(cur.sContent);
  106. 104.  -
  107. 105.  -     cur.silent = true;
  108. 106.  -     var query = {act: 'load_audios_silent', id: (cur.allAudiosIndex == 'all' ? cur.id : cur.audioFriend), gid: cur.gid, please_dont_ddos: 2};
  109. 107.  -     if (cur.allAudiosIndex != 'all') {
  110. 108.  -       Audio.cacheFriendsList();
  111. 109.  -     }
  112. 110.  -     if (cur.club) {
  113. 111.  -       cur.curSection = 'club' + cur.club;
  114. 112.  -       query.club = cur.club;
  115. 113.  -       cur.searchStr = cur.q;
  116. 114.  -     }
  117. 115.  -     ajax.post(Audio.address, query, {onDone: (function(data, opts) {
  118. 116.  -       opts = eval('('+opts+')');
  119. 117.  -       if (opts.exp) {
  120. 118.  -         _a.statusExport = opts.exp;
  121. 119.  -         checkbox('currinfo_audio', (_a.hasStatusExport()));
  122. 120.  -         if (_a && _a.showCurrentTrack) _a.showCurrentTrack();
  123. 121.  -         delete opts.exp;
  124. 122.  -       }
  125. 123.  -       extend(cur, opts);
  126. 124.  -       if (cur.hashes && cur.hashes.add_hash && !_a.addHash) {
  127. 125.  -         _a.addHash = cur.hashes.add_hash;
  128. 126.  -       }
  129. 127.  -       if (query.id > 0) {
  130. 128.  -         cur.allFriendsTitles = cur.allFriendsTitles || {};
  131. 129.  -         cur.allFriendsTitles[query.id] = opts.summaryLang.all_friend_title;
  132. 130.  -         cur.allFriendsHTitles = cur.allFriendsHTitles || {};
  133. 131.  -         cur.allFriendsHTitles[query.id] = opts.summaryLang.all_friend_htitle;
  134. 132.  -       }
  135. 133.  -       var obj = eval('('+data+')');
  136. 134.  -       if (!obj) {
  137. 135.  -         return;
  138. 136.  -       }
  139. 137.  -       cur.audiosList = cur.audiosList || {};
  140. 138.  -       if ((query.club || query.id < 0) && obj.club) {
  141. 139.  -         var club = query.club || -query.id;
  142. 140.  -         cur.allClubsHTitles = cur.allClubsHTitles || {};
  143. 141.  -         cur.allClubsHTitles[club] = opts.summaryLang.all_club_htitle || cur.htitle;
  144. 142.  -         cur.allFriendsHTitles = cur.allFriendsHTitles || {};
  145. 143.  -         cur.allFriendsHTitles[-club] = opts.summaryLang.all_club_htitle || cur.htitle;
  146. 144.  -         cur.curList = 'club' + club;
  147. 145.  -         cur.audiosList[cur.curList] = obj.club;
  148. 146.  -       } else {
  149. 147.  -         cur.curList = (cur.album_id) ? 'album'+cur.album_id : cur.allAudiosIndex;
  150. 148.  -       }
  151. 149.  -       cur.searchOffset = 0;
  152. 150.  -       cur.audiosList[cur.allAudiosIndex] = obj.all ? obj.all : [];
  153. 151.  -       if (cur.allAudiosIndex == 'all') Audio.generateAlbums();
  154. 152.  -       cur.sectionCount = (cur.audiosList[cur.curList] || []).length;
  155. 153.  -       if (cur.canEdit && nav.objLoc.act != 'popular' && nav.objLoc.act != 'recommendations' && nav.objLoc.act != 'feed' && !browser.mobile && cur.allAudiosIndex == 'all' && !cur.shuffled) {
  156. 154.  -         if (cur.sectionCount) {
  157. 155.  -           var opts = {onReorder: Audio.onAudioReorder, onMouseDown: Audio.onDragStart, onMouseUp: Audio.onDragEnd, noMoveCursor: 1};
  158. 156.  -           if (cur.audioAlbumsWrap) {
  159. 157.  -             extend(opts, {target: cur.audioAlbumsWrap, onDragOver: Audio.onDragOver, onDragOut: Audio.onDragOut});
  160. 158.  -           }
  161. 159.  -           sorter.init(cur.aContent, opts);
  162. 160.  -         }
  163. 161.  -       }
  164. 162.  -       if (cur.albums) {
  165. 163.  -         Audio.initAlbumsSort();
  166. 164.  -       }
  167. 165.  -       this.indexAll(function() {
  168. 166.  -         cur.silent = false;
  169. 167.  -         if (cur.onSilentLoad) {
  170. 168.  -           cur.onSilentLoad();
  171. 169.  -         }
  172. 170.  -         if (!cur.q || cur.club) {
  173. 171.  -           if (cur.curSection == 'recommendations' || cur.curSection == 'popular' || cur.curSection == 'feed') {
  174. 172.  -             if (cur[cur.curSection+'Audios']) {
  175. 173.  -               var k = 0;
  176. 174.  -               for (var i in cur[cur.curSection+'Audios']) {
  177. 175.  -                 cur[cur.curSection+'Audios'][i]._order = k++;
  178. 176.  -               }
  179. 177.  -               audioPlayer.genPlaylist(cur[cur.curSection+'Audios'], false);
  180. 178.  -             }
  181. 179.  -           } else {
  182. 180.  -             audioPlayer.genPlaylist(cur.audiosList[cur.curList], false, cur.curList == 'all' && cur.oid == vk.id);
  183. 181.  -           }
  184. 182.  -         } else if (!query.club) {
  185. 183.  -           Audio.selectPerformer(null, cur.q);
  186. 184.  -         }
  187. 185.  -         if (cur.audio_id) {
  188. 186.  -           var audio = cur.audios[cur.audio_id];
  189. 187.  -           if (audio) {
  190. 188.  -             var audio_id = audio[0] + '_' + audio[1];
  191. 189.  -             if (audio[11] && parseInt(audio[11])) {
  192. 190.  -               var claim = parseInt(audio[11]) || 0;
  193. 191.  -               if (claim == -2) claim = 0;
  194. 192.  -               Audio.showAudioClaimWarning(audio_id, claim, audio[5] + ' &ndash; ' + audio[6]);
  195. 193.  -             } else {
  196. 194.  -               try{
  197. 195.  -                 playAudioNew(audio_id);
  198. 196.  -               }catch(e){};
  199. 197.  -             }
  200. 198.  -           }
  201. 199.  -         }
  202. 200.  -       });
  203. 201.  -     }).bind(this), local: 1});
  204. 202.  -   },
  205. 203.  -
  206. 204.  -   startEvents: function() {
  207. 205.  -     addEvent(Audio.scrollnode, 'scroll', Audio.scrollCheck);
  208. 206.  -     addEvent(window, 'resize', Audio.scrollCheck);
  209. 207.  -     addEvent(cur.aSearch, 'blur', Audio.searchBlur);
  210. 208.  -     addEvent(cur.aSearch, 'focus', Audio.searchFocus);
  211. 209.  -     cur.gpHidden = true;
  212. 210.  -     toggleGlobalPlayer(false);
  213. 211.  -     if (Audio.fixedScroll) {
  214. 212.  -       var els = geByClass('top_info_wrap', ge('page_wrap'));
  215. 213.  -       each(els, function() { hide(this); });
  216. 214.  -       hide(_stlSide);
  217. 215.  -       setTimeout(function() {
  218. 216.  -         each(els, function() { hide(this); });
  219. 217.  -         hide(_stlSide);
  220. 218.  -       }, 110);
  221. 219.  -       var headH = cur.audioEl.head.clientHeight,
  222. 220.  -           headT = getXY(cur.audioEl.head)[1],
  223. 221.  -           audioNavH = cur.audioEl.bar.offsetHeight,
  224. 222.  -           headW = cur.audioEl.head.clientWidth,
  225. 223.  -           contentY = headH + audioNavH;
  226. 224.  -       setStyle(cur.audioEl.head, {width: headW, top: headT});
  227. 225.  -       setStyle('side_bar', {top: headH + headT});
  228. 226.  -       setStyle(cur.audioEl.bar, {top: headH + headT});
  229. 227.  -       setStyle(cur.audioEl.cont, {paddingTop: contentY});
  230. 228.  -       setStyle(cur.audioEl.filters, {top: contentY});
  231. 229.  -
  232. 230.  -       addClass(bodyNode, 'audio_fixed_nav');
  233. 231.  -       _fixedNav = true;
  234. 232.  -     }
  235. 233.  -     Audio.updateAlbumsTitles();
  236. 234.  -     Audio.handleFilterPos();
  237. 235.  -   },
  238. 236.  -
  239. 237.  -   stopEvents: function() {
  240. 238.  -     removeEvent(Audio.scrollnode, 'scroll', Audio.scrollCheck);
  241. 239.  -     removeEvent(window, 'resize', Audio.scrollCheck);
  242. 240.  -     removeEvent(cur.aSearch, 'blur', Audio.searchBlur);
  243. 241.  -     removeEvent(cur.aSearch, 'focus', Audio.searchFocus);
  244. 242.  -     if (Audio.fixedScroll) {
  245. 243.  -       var els = geByClass('top_info_wrap', ge('page_wrap'));
  246. 244.  -       each(els, function() { show(this); });
  247. 245.  -       setStyle(cur.audioEl.head, {width: '', top: ''});
  248. 246.  -       setStyle('side_bar', {top: ''});
  249. 247.  -
  250. 248.  -       removeClass(bodyNode, 'audio_fixed_nav');
  251. 249.  -       _fixedNav = false;
  252. 250.  -
  253. 251.  -       show(_stlSide, 'debuglogwrap');
  254. 252.  -     }
  255. 253.  -     audioPlayer.deregisterPlayer('ac');
  256. 254.  -     setTimeout(function() {
  257. 255.  -       toggleGlobalPlayer(true);
  258. 256.  -       updGlobalPlayer();
  259. 257.  -     }, 100);
  260. 258.  -   },
  261. 259.  -
  262. 260.  -   searchFocus: function() {
  263. 261.  -     var alist = ge('audios_list');
  264. 262.  -     if (!hasClass(alist, 'light')) addClass(alist, 'light');
  265. 263.  -   },
  266. 264.  -
  267. 265.  -   searchBlur: function() {
  268. 266.  -     var alist = ge('audios_list');
  269. 267.  -     if (hasClass(alist, 'light')) removeClass(alist, 'light');
  270. 268.  -   },
  271. 269.  -
  272. 270.  -   clearSearch: function(el, event) {
  273. 271.  -     setStyle(el, {opacity: .6});
  274. 272.  -     cur.aSearch.focus();
  275. 273.  -     if (cur.allAudiosIndex == 'all') {
  276. 274.  -       Audio.loadAlbum(0);
  277. 275.  -     } else {
  278. 276.  -       this.filterTimeout = setTimeout((function() {
  279. 277.  -         val(cur.aSearch, '');
  280. 278.  -         removeClass(cur.clearSearch, 'shown');
  281. 279.  -         this.updateList(null, cur.aSearch);
  282. 280.  -         this.hideSearchResults();
  283. 281.  -         scrollToTop();
  284. 282.  -       }).bind(this), 10);
  285. 283.  -     }
  286. 284.  -     if (isVisible(cur.searchInfoCont)) {
  287. 285.  -       hide(cur.searchInfoCont);
  288. 286.  -     }
  289. 287.  -   },
  290. 288.  -
  291. 289.  -   updateSorterRows: function(fromEl) {
  292. 290.  -     if (fromEl && fromEl.parentNode.sorter){
  293. 291.  -       sorter.update(fromEl);
  294. 292.  -     }
  295. 293.  -   },
  296. 294.  -
  297. 295.  -   showLyrics: function(id, lid, top) {
  298. 296.  -     var lyrics_div = ge('lyrics'+id);
  299. 297.  -     if (!isVisible(lyrics_div)) {
  300. 298.  -       show(lyrics_div);
  301. 299.  -       lyrics_div.innerHTML = "<div style='text-align: center; height: 50px; padding: 30px 10px 10px 10px'><img valign='middle' src='/images/progress7.gif'></div>";
  302. 300.  -       Audio.updateSorterRows(ge('audio'+id));
  303. 301.  -       ajax.post(Audio.address, {act: 'get_lyrics', lid: lid, aid: id, top: top ? 1 : 0}, {cache: 1, onDone: (function(responseText) {
  304. 302.  -           lyrics_div.innerHTML = responseText;
  305. 303.  -           Audio.updateSorterRows(ge('audio'+id));
  306. 304.  -         }).bind(this)});
  307. 305.  -     } else {
  308. 306.  -       lyrics_div.innerHTML = "";
  309. 307.  -       hide(lyrics_div);
  310. 308.  -       Audio.updateSorterRows(ge('audio'+id));
  311. 309.  -       Audio.handleFilterPos();
  312. 310.  -     }
  313. 311.  -   },
  314. 312.  -
  315. 313.  -   allAudios: function() {
  316. 314.  -     return cur.audiosList ? cur.audiosList[cur.allAudiosIndex] || [] : [];
  317. 315.  -   },
  318. 316.  -
  319. 317.  -   showRows: function(start, end, force) {
  320. 318.  -     if (cur.curSection == 'recommendations') {
  321. 319.  -       Audio.loadRecommendations();
  322. 320.  -       return;
  323. 321.  -     } else if (cur.curSection == 'popular') {
  324. 322.  -       Audio.loadPopular();
  325. 323.  -       return;
  326. 324.  -     } else if (cur.curSection == 'feed') {
  327. 325.  -       Audio.loadFeed();
  328. 326.  -       return;
  329. 327.  -     }
  330. 328.  -     if (cur.silent) {
  331. 329.  -       cur.onSilentLoad = function() {
  332. 330.  -         Audio.showRows(start, end, force);
  333. 331.  -       };
  334. 332.  -       return;
  335. 333.  -     }
  336. 334.  -     var list = cur.audiosList[cur.curList] || [];
  337. 335.  -     if (list[0] && list[0]._order !== undefined) {
  338. 336.  -       list = list.sort(function(a,b) {return a._order - b._order});
  339. 337.  -     }
  340. 338.  -     list = Audio.filterClaimed(list);
  341. 339.  -     cur.sectionCount = list.length;
  342. 340.  -     if (!cur.searchStr) {
  343. 341.  -       list = Audio.filterDeleted(list);
  344. 342.  -       if (cur.filterUnsorted) {
  345. 343.  -         list = Audio.filterByAlbum(list, 0);
  346. 344.  -       }
  347. 345.  -       cur.sectionCount = list.length;
  348. 346.  -     }
  349. 347.  -     if (start == undefined) {
  350. 348.  -       start = cur.shownAudios;
  351. 349.  -     }
  352. 350.  -     if (end == undefined) {
  353. 351.  -       end = cur.shownAudios + cur.audiosPerPage;
  354. 352.  -     }
  355. 353.  -     if (window.tooltips && cur.tooltips) {
  356. 354.  -       for (var i = 0; i < cur.tooltips.length; ++i) {
  357. 355.  -         if (cur.tooltips[i].el) {
  358. 356.  -           if (hasClass(cur.tooltips[i].el, 'audio_friend')) continue;
  359. 357.  -           if (cur.tooltips[i].el.ttimer) {
  360. 358.  -             clearTimeout(cur.tooltips[i].el.ttimer);
  361. 359.  -           }
  362. 360.  -         }
  363. 361.  -         cur.tooltips[i].hide({fasthide: true});
  364. 362.  -       }
  365. 363.  -     }
  366. 364.  -     var _a = window.audioPlayer;
  367. 365.  -     if (!list || !list.length) {
  368. 366.  -       if (cur.shownAudios == 0 && (cur.album_id || (!Audio.allAudios().length && !cur.searchStr))) {
  369. 367.  -         var msg;
  370. 368.  -         if (Audio.allAudios().length) {
  371. 369.  -           msg = (cur.album_id) ? getLang('audio_album_no_recs') : getLang('audio_no_audios_found').split('{query}').join('<b>'+cur.searchStr.replace(/([<>&#]*)/g, '')+'</b>');
  372. 370.  -         } else {
  373. 371.  -           if (cur.oid > 0 && !cur.audioFriend) {
  374. 372.  -             if (cur.id == vk.id && cur.allAudiosIndex == 'all') {
  375. 373.  -               msg = getLang('audio_no_rec_load_msg').split('{link}').join('<a href="#" onclick="Audio.addAudio(); return false">').split('{/link}').join('</a>');
  376. 374.  -             } else {
  377. 375.  -               msg = getLang('audio_user_no_recs');
  378. 376.  -             }
  379. 377.  -           } else {
  380. 378.  -             msg = cur.audioFriend > 0 ? getLang('audio_user_no_recs') : getLang('audio_group_no_recs');
  381. 379.  -           }
  382. 380.  -         }
  383. 381.  -         cur.aContent.innerHTML = '<div id="not_found" class="info_msg">'+msg+'</div>';
  384. 382.  -       }
  385. 383.  -       hide(cur.showMore);
  386. 384.  -     } else {
  387. 385.  -       if (!cur.shownAudios) cur.aContent.innerHTML = '';
  388. 386.  -       var audios = list.slice(start, end);
  389. 387.  -       if (!audios.length) {
  390. 388.  -         if (cur.shownAudios >= cur.sectionCount) {
  391. 389.  -           hide(cur.showMore);
  392. 390.  -           if (cur.searchStr) {
  393. 391.  -             this.loadRows();
  394. 392.  -           }
  395. 393.  -         }
  396. 394.  -         return;
  397. 395.  -       }
  398. 396.  -       var html = [];
  399. 397.  -       for (i in audios) {
  400. 398.  -         var audio = audios[i].slice();
  401. 399.  -         if (cur.selection) {
  402. 400.  -           audio[5] = audio[5].replace(cur.selection.re, cur.selection.val).replace(/&#(\d*)<span>(\d+)<\/span>(\d*);/g, "&#$1$2$3;");
  403. 401.  -           audio[6] = audio[6].replace(cur.selection.re, cur.selection.val).replace(/&#(\d*)<span>(\d+)<\/span>(\d*);/g, "&#$1$2$3;");
  404. 402.  -         }
  405. 403.  -         html.push(this.drawAudio(audio));
  406. 404.  -         cur.shownAudios += 1;
  407. 405.  -       }
  408. 406.  -       var au = ce('div', {innerHTML: html.join('')});
  409. 407.  -       while (au.firstChild) {
  410. 408.  -         var el = au.firstChild;
  411. 409.  -         cur.aContent.appendChild(el);
  412. 410.  -       }
  413. 411.  -       if (cur.canEdit && nav.objLoc.act != 'popular' && nav.objLoc.act != 'recommendations' && nav.objLoc.act != 'feed' && !browser.mobile && !cur.searchStr && cur.sectionCount && cur.allAudiosIndex == 'all' && !cur.shuffled) {
  414. 412.  -         if (start > 0) {
  415. 413.  -           setTimeout(sorter.added.pbind(cur.aContent), 0);
  416. 414.  -         } else {
  417. 415.  -           setTimeout(function(){
  418. 416.  -             var opts = {onReorder: Audio.onAudioReorder, onMouseDown: Audio.onDragStart, onMouseUp: Audio.onDragEnd, noMoveCursor: 1};
  419. 417.  -             if (cur.audioAlbumsWrap) {
  420. 418.  -               extend(opts, {target: cur.audioAlbumsWrap, onDragOver: Audio.onDragOver, onDragOut: Audio.onDragOut});
  421. 419.  -             }
  422. 420.  -             sorter.init(cur.aContent, opts);
  423. 421.  -           }, 0);
  424. 422.  -         }
  425. 423.  -       }
  426. 424.  -       if (cur.searchCount && isVisible(cur.sContent)) {
  427. 425.  -         show(cur.sWrap);
  428. 426.  -         cur.sContent.style.paddingTop = '12px';
  429. 427.  -         cur.sSummary.innerHTML = langNumeric(cur.searchCount, cur.summaryLang['list_found'], true);
  430. 428.  -       }
  431. 429.  -       if (_a && _a.showCurrentTrack) _a.showCurrentTrack();
  432. 430.  -     }
  433. 431.  -     setTimeout(Audio.handleFilterPos, 0);
  434. 432.  -     var aid = currentAudioId(), clubList = (cur.curSection && cur.curSection.substr(0, 4) == 'club');
  435. 433.  -     if (_a && _a.gpDisabled && aid) {
  436. 434.  -       var track_id = aid.split('_')[1];
  437. 435.  -       if (!cur.audios[track_id]) _a.stop();
  438. 436.  -     }
  439. 437.  -     if (cur.justShuffled) {
  440. 438.  -       toggle(cur.showMore, cur.shownAudios < cur.sectionCount);
  441. 439.  -       return;
  442. 440.  -     }
  443. 441.  -     if (clubList) {
  444. 442.  -       Audio.hideSearchResults();
  445. 443.  -     }
  446. 444.  -     if (force) return;
  447. 445.  -     if (cur.shownAudios >= cur.sectionCount) {
  448. 446.  -       hide(cur.showMore);
  449. 447.  -       if (cur.searchStr && !clubList) {
  450. 448.  -         this.loadRows();
  451. 449.  -       } else {
  452. 450.  -         Audio.setQLoc(cur.searchStr);
  453. 451.  -       }
  454. 452.  -     } else {
  455. 453.  -       show(cur.showMore);
  456. 454.  -       Audio.setQLoc(cur.searchStr);
  457. 455.  -     }
  458. 456.  -   },
  459. 457.  -
  460. 458.  -   loadRows: function() {
  461. 459.  -     if (cur.sPreload.innerHTML) {
  462. 460.  -       while (cur.sPreload.firstChild) {
  463. 461.  -         var el = cur.sPreload.firstChild
  464. 462.  -         cur.sContent.appendChild(el);
  465. 463.  -       }
  466. 464.  -     }
  467. 465.  -     clearTimeout(this.searchTimeout);
  468. 466.  -     this.searchTimeout = setTimeout((function() {
  469. 467.  -       Audio.searchRequest(cur.searchStr, cur.searchOffset);
  470. 468.  -     }).bind(this), 300);
  471. 469.  -   },
  472. 470.  -
  473. 471.  -   searchRequest: function(val, offset) {
  474. 472.  -     if (!val) return;
  475. 473.  -     if (val[val.length - 1] == ' ') {
  476. 474.  -       val[val.length - 1] = '_';
  477. 475.  -     }
  478. 476.  -     addClass(cur.searchCont, 'loading');
  479. 477.  -     setStyle(cur.clearSearch, {opacity: .6});
  480. 478.  -     var query = {act: 'search', q: val, offset: offset, id: cur.id, gid: cur.gid, performer: cur.searchTypeMenu ? cur.searchTypeMenu.val() : 0};
  481. 479.  -     var l = ge('audio_lyrics_filter');
  482. 480.  -     var s = ge('selectedItems');
  483. 481.  -     if (l && parseInt(l.value)) query.lyrics = 1;
  484. 482.  -     if (s) query.sort = s.value;
  485. 483.  -     if (cur.autoComplete) query.autocomplete = cur.autoComplete;
  486. 484.  -     if (nav.objLoc.claim) query.claim = nav.objLoc.claim;
  487. 485.  -     ajax.post(Audio.address, query, {onDone: function(res, preload, options) {
  488. 486.  -         removeClass(cur.searchCont, 'loading');
  489. 487.  -         var newVal = cur.searchStr;
  490. 488.  -         if (newVal[newVal.length - 1] == ' ') {
  491. 489.  -           newVal[newVal.length - 1] = '_';
  492. 490.  -         }
  493. 491.  -         if (val != newVal) {
  494. 492.  -           return;
  495. 493.  -         }
  496. 494.  -         if (res) {
  497. 495.  -           cur.sContent.innerHTML = res;
  498. 496.  -         }
  499. 497.  -         if (preload) {
  500. 498.  -           cur.sPreload.innerHTML = preload;
  501. 499.  -         }
  502. 500.  -         Audio.applyOptions(options, offset);
  503. 501.  -         show(cur.sContent);
  504. 502.  -         if (!cur.sectionCount) {
  505. 503.  -           hide(cur.sWrap);
  506. 504.  -           cur.sContent.style.paddingTop = '0px';
  507. 505.  -           Audio.changeSummary(true);
  508. 506.  -           cur.aContent.innerHTML = '';
  509. 507.  -           if (!cur.searchCount && !res && !preload) {
  510. 508.  -             msg = getLang('audio_no_audios_found').split('{query}').join('<b>'+cur.searchStr.replace(/([<>&#]*)/g, '')+'</b>');
  511. 509.  -             cur.aContent.innerHTML = '<div id="not_found" class="info_msg">'+msg+'</div>';
  512. 510.  -             hide(cur.showMore);
  513. 511.  -             hide(cur.sContent);
  514. 512.  -           }
  515. 513.  -         } else {
  516. 514.  -           cur.sContent.style.paddingTop = '12px';
  517. 515.  -           if (cur.searchCount) {
  518. 516.  -             cur.sSummary.innerHTML = langNumeric(cur.searchCount, cur.summaryLang['list_found'], true);
  519. 517.  -             show(cur.sWrap);
  520. 518.  -           } else {
  521. 519.  -             Audio.hideSearchResults();
  522. 520.  -             hide(cur.sWrap);
  523. 521.  -           }
  524. 522.  -         }
  525. 523.  -         Audio.scrollCheck();
  526. 524.  -         if (!offset) Audio.setQLoc(cur.searchStr);
  527. 525.  -         var _a = window.audioPlayer;
  528. 526.  -         if (_a && _a.showCurrentTrack) _a.showCurrentTrack();
  529. 527.  -       },
  530. 528.  -       onFail: function() {
  531. 529.  -         removeClass(cur.searchCont, 'loading');
  532. 530.  -       },
  533. 531.  -       showProgress: function () {
  534. 532.  -         cur.isAudioLoading = true;
  535. 533.  -       },
  536. 534.  -       hideProgress: function () {
  537. 535.  -         cur.isAudioLoading = false;
  538. 536.  -       }
  539. 537.  -     });
  540. 538.  -   },
  541. 539.  -
  542. 540.  -   changeSearchFilters: function() {
  543. 541.  -     cur.searchOffset = 0;
  544. 542.  -     Audio.searchRequest(cur.searchStr, 0);
  545. 543.  -   },
  546. 544.  -
  547. 545.  -   hideSearchResults: function() {
  548. 546.  -     setTimeout(function(){
  549. 547.  -       cur.sContent.innerHTML = '';
  550. 548.  -       if (cur.curSection != 'recommendations' && cur.curSection != 'popular' && cur.curSection != 'feed') cur.sPreload.innerHTML = '';
  551. 549.  -       hide(cur.sContent);
  552. 550.  -       hide(cur.sWrap);
  553. 551.  -       hide(cur.sShowMore);
  554. 552.  -       Audio.scrollCheck();
  555. 553.  -     }, 0);
  556. 554.  -   },
  557. 555.  -
  558. 556.  -   drawAudio: function(audio) {
  559. 557.  -     return cur.audioTpl(audio, cur.curSection);
  560. 558.  -   },
  561. 559.  -
  562. 560.  -   applyOptions: function(options, offset) {
  563. 561.  -     extend(cur, options);
  564. 562.  -     if (!cur.has_more) {
  565. 563.  -       hide(cur.sShowMore);
  566. 564.  -     } else {
  567. 565.  -       show(cur.sShowMore);
  568. 566.  -     }
  569. 567.  -     if (!offset) {
  570. 568.  -       if (options.searchInfo) {
  571. 569.  -         cur.searchInfoCont.innerHTML = options.searchInfo;
  572. 570.  -         if (!isVisible(cur.searchInfoCont)) {
  573. 571.  -           show(cur.searchInfoCont);
  574. 572.  -         }
  575. 573.  -         each(geByClass('audio_friend_name_now', cur.searchInfoCont), function() {
  576. 574.  -           if (this.scrollWidth > this.clientWidth) {
  577. 575.  -             this.setAttribute('title', this.innerText || this.textContent);
  578. 576.  -           } else {
  579. 577.  -             this.removeAttribute('title');
  580. 578.  -           }
  581. 579.  -         })
  582. 580.  -       } else if (isVisible(cur.searchInfoCont)) {
  583. 581.  -         hide(cur.searchInfoCont);
  584. 582.  -       }
  585. 583.  -     }
  586. 584.  -   },
  587. 585.  -
  588. 586.  -   handleFilterPos: function() {
  589. 587.  -     if (!Audio.fixedScroll || !cur.audioEl) return false;
  590. 588.  -     var headH = cur.audioEl.head.clientHeight, audioNavH = cur.audioEl.bar.offsetHeight,
  591. 589.  -         contentY = headH + audioNavH,
  592. 590.  -         st = Math.max(0, scrollGetY()), wh = window.lastWindowHeight || 0, pos = 0,
  593. 591.  -         filt = ge('side_panel'), filtPos = getXY(filt)[1], filtY = getSize(filt)[1],
  594. 592.  -         sf = ge('side_filters'), sfPos = (getStyle(sf, 'position') == 'fixed') ? parseInt(getStyle(sf, 'top')) : getXY(sf)[1], sfY = getSize(sf)[1],
  595. 593.  -         bottomPad = Math.max(0, st + wh - filtY - contentY),
  596. 594.  -         tooBig = (filtPos + filtY - sfPos - sfY < 20),
  597. 595.  -         lastPos = cur.filterLastPos || 100, lastSt = cur.lastSt || 0;
  598. 596.  -
  599. 597.  -     if  (!tooBig) {
  600. 598.  -       addClass(sf, 'fixed');
  601. 599.  -       pos = (wh > sfY + contentY) ? Math.min(contentY, wh - sfY - bottomPad) : Math.max(Math.min(contentY, lastPos + lastSt - st), wh - sfY - bottomPad);
  602. 600.  -     } else {
  603. 601.  -       removeClass(sf, 'fixed');
  604. 602.  -       pos = 0;
  605. 603.  -     }
  606. 604.  -     cur.filterLastPos = pos;
  607. 605.  -     cur.lastSt = st;
  608. 606.  -     setStyle(sf, {top: pos + 'px'});
  609. 607.  -
  610. 608.  -     if (!browser.mozilla && !browser.msie && cur.lastWW !== lastWindowWidth) {
  611. 609.  -       cur.lastWW = lastWindowWidth;
  612. 610.  -       var goodLeft1 = ge('page_layout').offsetLeft,
  613. 611.  -           goodLeft2 = goodLeft1 + cur.audioEl.cont.offsetLeft,
  614. 612.  -           goodLeft3 = goodLeft2 + getSize(cur.audioEl.cont)[0] - getSize(cur.audioEl.filters)[0] - 10;
  615. 613.  -       cur.audioEl.head.style.left = ge('side_bar').style.left = goodLeft1 + 'px';
  616. 614.  -       cur.audioEl.bar.style.left = goodLeft2 + 'px';
  617. 615.  -       cur.audioEl.filters.style.left = goodLeft3 + 'px';
  618. 616.  -       setTimeout(Audio.resetStyles, 0);
  619. 617.  -     }
  620. 618.  -   },
  621. 619.  -
  622. 620.  -   resetStyles: function() {
  623. 621.  -     cur.audioEl.head.style.left = ge('side_bar').style.left =
  624. 622.  -     cur.audioEl.bar.style.left = cur.audioEl.filters.style.left = '';
  625. 623.  -   },
  626. 624.  -
  627. 625.  -   scrollCheck: function () {
  628. 626.  -     Audio.handleFilterPos();
  629. 627.  -     if (browser.mobile || cur.isAudioLoading  || cur.disableAutoMore) return;
  630. 628.  -
  631. 629.  -     if (!isVisible(cur.showMore) && !isVisible(cur.sShowMore)) return;
  632. 630.  -     if (!cur.curList) {
  633. 631.  -       setTimeout(Audio.scrollCheck, 50);
  634. 632.  -       return;
  635. 633.  -     }
  636. 634.  -
  637. 635.  -     var docEl = document.documentElement;
  638. 636.  -     var ch = window.innerHeight || docEl.clientHeight || bodyNode.clientHeight;
  639. 637.  -     var st = scrollGetY();
  640. 638.  -
  641. 639.  -     if (isVisible(cur.showMore) && st + ch + 400 > cur.showMore.offsetTop) {
  642. 640.  -       Audio.showRows();
  643. 641.  -     }
  644. 642.  -     if (isVisible(cur.sShowMore) && st + ch + 400 > cur.sShowMore.offsetTop) {
  645. 643.  -       Audio.loadRows();
  646. 644.  -     }
  647. 645.  -   },
  648. 646.  -
  649. 647.  -   updateList: function(e, obj, force, showAlbums, fromIndex) {
  650. 648.  -     if (cur.silent) {
  651. 649.  -       cur.onSilentLoad = function() {
  652. 650.  -         Audio.updateList(e, obj, force, showAlbums);
  653. 651.  -       };
  654. 652.  -       return;
  655. 653.  -     }
  656. 654.  -     if (e && (e.keyCode == 10 || e.keyCode == 13) || cur.forceNoAutoComplete) {
  657. 655.  -       delete cur.forceNoAutoComplete
  658. 656.  -       delete cur.autoComplete;
  659. 657.  -     } else {
  660. 658.  -       cur.autoComplete = 1;
  661. 659.  -     }
  662. 660.  -     clearTimeout(this.filterTimeout);
  663. 661.  -     this.filterTimeout = setTimeout((function() {
  664. 662.  -       var str = trim(obj.value), el;
  665. 663.  -       if (str == cur.searchStr && cur.autoComplete && !cur.ignoreEqual) {
  666. 664.  -         return;
  667. 665.  -       }
  668. 666.  -       delete cur.ignoreEqual;
  669. 667.  -       delete nav.objLoc.album_id;
  670. 668.  -       delete nav.objLoc.audio_id;
  671. 669.  -       if (nav.objLoc.act == 'recommendations' || nav.objLoc.act == 'popular' || nav.objLoc.act == 'feed' || nav.objLoc.act == 'albums') delete nav.objLoc.act;
  672. 670.  -       if (showAlbums) {
  673. 671.  -         nav.objLoc.act = 'albums';
  674. 672.  -       }
  675. 673.  -       if (cur.allAudiosIndex == 'all') {
  676. 674.  -         cur.album_id = 0;
  677. 675.  -       }
  678. 676.  -       each(geByClass('audio_filter', cur.albumFilters), function(i, e) {
  679. 677.  -         removeClass(e, 'selected');
  680. 678.  -       });
  681. 679.  -       var c = Audio.allAudios().length;
  682. 680.  -       if (str) {
  683. 681.  -         el = cur.albumFiltered;
  684. 682.  -         hide(cur.audioFriends, cur.audioAlbums);
  685. 683.  -         addClass(cur.clearSearch, 'shown');
  686. 684.  -         show(cur.searchFilters);
  687. 685.  -         hide(cur.searchInfoCont);
  688. 686.  -         if (!c && cur.allAudiosIndex == 'all') removeClass(cur.audioWrap, 'audio_no_recs');
  689. 687.  -       } else {
  690. 688.  -         if (showAlbums || cur.oid != vk.id) {
  691. 689.  -           if (cur.allAudiosIndex == 'all') {
  692. 690.  -             el = ge('audios_albums') || ge('album0');
  693. 691.  -           }
  694. 692.  -           hide(cur.audioFriends);
  695. 693.  -           show(cur.audioAlbums);
  696. 694.  -           Audio.updateAlbums();
  697. 695.  -         } else if (fromIndex == 2) {
  698. 696.  -           hide(cur.audioAlbums);
  699. 697.  -           hide(cur.audioFriends);
  700. 698.  -           cur.searchInfoCont.innerHTML = cur.performerInfo[cur.allAudiosIndex];
  701. 699.  -           show(cur.searchInfoCont);
  702. 700.  -         } else {
  703. 701.  -           hide(cur.audioAlbums);
  704. 702.  -           show(cur.audioFriends);
  705. 703.  -           hide(cur.searchInfoCont);
  706. 704.  -           if (cur.allAudiosIndex == 'all') {
  707. 705.  -             el = ge('album0');
  708. 706.  -             var curEl = geByClass1('current', ge('audio_friends_list'));
  709. 707.  -             if (curEl) removeClass(curEl, 'current');
  710. 708.  -           }
  711. 709.  -         }
  712. 710.  -         removeClass(cur.clearSearch, 'shown');
  713. 711.  -         removeClass(cur.albumFiltered, 'selected');
  714. 712.  -         hide(cur.searchFilters);
  715. 713.  -         if (!c && cur.allAudiosIndex == 'all' && cur.oid <= 0) addClass(cur.audioWrap, 'audio_no_recs');
  716. 714.  -       }
  717. 715.  -       if (el) addClass(el, 'selected');
  718. 716.  -       hide(cur.popularFilters, cur.popularOwners);
  719. 717.  -       cur.searchStr = str;
  720. 718.  -       this.searchAudios(str, cur.allAudiosIndex, force);
  721. 719.  -
  722. 720.  -       scrollToTop();
  723. 721.  -     }).bind(this), fromIndex ? 0 :10);
  724. 722.  -   },
  725. 723.  -
  726. 724.  -   selectPerformer: function(event, name) {
  727. 725.  -     cur.aSearch.setValue(name);
  728. 726.  -     cur.forceNoAutoComplete = true;
  729. 727.  -     if (event) {
  730. 728.  -       cur.searchTypeMenu.value = 1;
  731. 729.  -       cur.searchTypeChanged({target: {index: 1}}, true);
  732. 730.  -     }
  733. 731.  -     Audio.updateList(null, cur.aSearch);
  734. 732.  -     if (event) cancelEvent(event);
  735. 733.  -   },
  736. 734.  -
  737. 735.  -   searchAudios: function(str, type, force) {
  738. 736.  -     cur.shownAudios = 0;
  739. 737.  -     cur.curSection = type;
  740. 738.  -     var clubList = (type && type.substr(0, 4) == 'club');
  741. 739.  -     if (!clubList && cur.searchSortFilter) {
  742. 740.  -       cur.searchSortFilter.disable(false);
  743. 741.  -       cur.searchLyricsFilter.disable(false);
  744. 742.  -       removeClass(cur.albumFiltered, 'club_shown');
  745. 743.  -       delete cur.club;
  746. 744.  -     }
  747. 745.  -     if (str) {
  748. 746.  -       var htmlentities = function(s){
  749. 747.  -         var el = document.createElement('div');
  750. 748.  -         el.innerText = el.textContent = s;
  751. 749.  -         s = el.innerHTML;
  752. 750.  -         delete el;
  753. 751.  -         return s.split('"').join('&quot;');
  754. 752.  -       }
  755. 753.  -       var htmlencode = function(str){
  756. 754.  -         return str.toLowerCase().replace(/\u2013|\u2014/g, '-');
  757. 755.  -         var aStr = str.toLowerCase().replace(/\u2013|\u2014/g, '-').split(''), i = aStr.length, aRet = [];
  758. 756.  -         while (i--) {
  759. 757.  -           var iC = aStr[i].charCodeAt();
  760. 758.  -           if ((iC > 127 && iC < 994)) {
  761. 759.  -             aRet.push('&#'+iC+';');
  762. 760.  -           } else if (iC == 36) {
  763. 761.  -             aRet.push('&#0'+iC+';');
  764. 762.  -           } else {
  765. 763.  -             aRet.push(htmlentities(aStr[i]));
  766. 764.  -           }
  767. 765.  -         }
  768. 766.  -         return aRet.reverse().join('');
  769. 767.  -       }
  770. 768.  -       var res = cur.audiosIndex.search(htmlencode(str));
  771. 769.  -       var newList = cur.curSection;
  772. 770.  -       newList += '_search_'+str;
  773. 771.  -
  774. 772.  -       cur.curList = newList;
  775. 773.  -       cur.audiosList[cur.curList] = res.sort(function(a,b) {return a._order - b._order});
  776. 774.  -       audioPlayer.genPlaylist(res, false);
  777. 775.  -
  778. 776.  -       if (str) {
  779. 777.  -         str += ' '+(parseLatin(str) || '');
  780. 778.  -         str = trim(escapeRE(str.replace(/\)/g, '')).split('&').join('&amp;'));
  781. 779.  -         cur.selection = {
  782. 780.  -           re: new RegExp('('+str.replace(cur.audiosIndex.delimiter, '|').replace(/(^\||\|$|\?)/g, '')+')', 'gi'),
  783. 781.  -           val: '<span>$1</span>'
  784. 782.  -         };
  785. 783.  -       }
  786. 784.  -     } else {
  787. 785.  -       if (!clubList) Audio.hideSearchResults();
  788. 786.  -       cur.curList = cur.curSection;
  789. 787.  -       audioPlayer.genPlaylist(cur.audiosList[cur.curList], false, cur.curList == 'all' && cur.oid == vk.id);
  790. 788.  -       cur.selection = false;
  791. 789.  -     }
  792. 790.  -
  793. 791.  -     cur.sectionCount = (cur.audiosList[cur.curList]) ? cur.audiosList[cur.curList].length : 0;
  794. 792.  -     this.filterTimeout = setTimeout((function() {
  795. 793.  -       if (!force) {
  796. 794.  -         hide(cur.sShowMore);
  797. 795.  -         cur.searchOffset = 0;
  798. 796.  -       }
  799. 797.  -       this.showRows(null, null, force);
  800. 798.  -       if (cur.sectionCount || !cur.searchStr) {
  801. 799.  -         this.changeSummary();
  802. 800.  -       }
  803. 801.  -       if (cur.justShuffled) {
  804. 802.  -         delete cur.justShuffled;
  805. 803.  -         var aid = currentAudioId();
  806. 804.  -         if (cur.nextPlaylist && (!aid || window.audioPlaylist && !window.audioPlaylist[aid])) {
  807. 805.  -           window.audioPlaylist = clone(cur.nextPlaylist);
  808. 806.  -         }
  809. 807.  -         if (Pads.updateAudioPlaylist) {
  810. 808.  -           Pads.updateAudioPlaylist();
  811. 809.  -         }
  812. 810.  -       }
  813. 811.  -     }).bind(this), 10);
  814. 812.  -   },
  815. 813.  -
  816. 814.  -   indexAll: function(callback) {
  817. 815.  -     var all = Audio.allAudios(),
  818. 816.  -     replacer = function(str, p) {
  819. 817.  -       var c = intval(p);
  820. 818.  -       return (c >= 33 && c < 48) ? String.fromCharCode(c) : str;
  821. 819.  -     };
  822. 820.  -
  823. 821.  -     cur.audiosIndex = new vkIndexer(all, function(obj) {
  824. 822.  -       cur.audios[parseInt(obj[1])] = obj;
  825. 823.  -       return (obj[5]+' '+obj[6]).replace(/\&\#(\d+);?/gi, replacer);
  826. 824.  -     }, function() {
  827. 825.  -         if (callback) {
  828. 826.  -           callback();
  829. 827.  -         }
  830. 828.  -     });
  831. 829.  -   },
  832. 830.  -
  833. 831.  -   changeAllIndex: function(index, albumSelected, showAlbums, owner) {
  834. 832.  -     if (!cur.audiosList[index]) return;
  835. 833.  -     cur.allAudiosIndex = cur.curList = index;
  836. 834.  -     this.indexAll(function() {
  837. 835.  -       var _a = window.audioPlayer;
  838. 836.  -       Audio.mixAllAudios(_a && _a.shuffle, true);
  839. 837.  -       audioPlayer.genPlaylist(cur.audiosList[cur.curList], false, index == 'all' && cur.oid == vk.id);
  840. 838.  -       each(geByTag('div', cur.albumFilters), function(i, e) {
  841. 839.  -         removeClass(e, 'loading');
  842. 840.  -       });
  843. 841.  -       cur.ignoreEqual = true;
  844. 842.  -
  845. 843.  -       setStyle(cur.clearSearch, {opacity: .6});
  846. 844.  -       val(cur.aSearch, '');
  847. 845.  -       removeClass(cur.clearSearch, 'shown');
  848. 846.  -       cur.searchStr = '';
  849. 847.  -       Audio.hideSearchResults();
  850. 848.  -       if (albumSelected) {
  851. 849.  -         Audio.loadAlbum(albumSelected);
  852. 850.  -       } else {
  853. 851.  -         Audio.updateList(null, cur.aSearch, undefined, showAlbums, owner ? 2 : 1);
  854. 852.  -       }
  855. 853.  -     });
  856. 854.  -   },
  857. 855.  -
  858. 856.  -   generateAlbums: function() {
  859. 857.  -     for (var i in cur.audiosList) {
  860. 858.  -       if (i.substr(0, 5) == 'album') cur.audiosList[i] = [];
  861. 859.  -     }
  862. 860.  -     var all = Audio.allAudios();
  863. 861.  -     for (var i in all) {
  864. 862.  -       var el = all[i];
  865. 863.  -       if (el[8] && parseInt(el[8])) {
  866. 864.  -         if (!cur.audiosList['album'+el[8]]) cur.audiosList['album'+el[8]] = [];
  867. 865.  -         cur.audiosList['album'+el[8]].push(el);
  868. 866.  -       }
  869. 867.  -     }
  870. 868.  -   },
  871. 869.  -
  872. 870.  -   changeHTitle: function(count, from_search) {
  873. 871.  -     // Updating document title
  874. 872.  -     var htitle = cur.htitle;
  875. 873.  -     if (cur.curSection && !cur.curSection.indexOf('album')) {
  876. 874.  -       htitle = ge(cur.curSection).innerHTML;
  877. 875.  -     } else if (cur.curSection && cur.curSection == 'recommendations') {
  878. 876.  -       htitle = cur.recommendTitle ? cur.recommendTitle : getLang('audio_recommended_audios');
  879. 877.  -     } else if (cur.curSection && cur.curSection == 'popular') {
  880. 878.  -       htitle = cur.popularTitle ? cur.popularTitle : getLang('audio_popular_audios');
  881. 879.  -     } else if (cur.curSection && cur.curSection.indexOf('owner') === 0) {
  882. 880.  -       htitle = cur.allFriendsHTitles[cur.audioFriend];
  883. 881.  -     } else if (from_search) {
  884. 882.  -       htitle = getLang('audio_title_search').replace('{q}', val('s_search'));
  885. 883.  -     } else if (cur.curSection && !cur.curSection.indexOf('club')) {
  886. 884.  -       htitle = cur.allClubsHTitles[cur.club] || htitle;
  887. 885.  -     } else if (cur.audioFriend && cur.allAudiosIndex && !cur.allAudiosIndex.indexOf('friend')) {
  888. 886.  -       htitle = cur.allFriendsHTitles[cur.audioFriend];
  889. 887.  -     }
  890. 888.  -     if (count && cur.lang.audio_N_recs) {
  891. 889.  -       htitle += ' | ' + getLang('audio_N_recs', count);
  892. 890.  -     }
  893. 891.  -     document.title = replaceEntities(stripHTML(htitle));
  894. 892.  -   },
  895. 893.  -
  896. 894.  -   changeSummary: function(from_search) {
  897. 895.  -     var count = (from_search) ? cur.searchCount : cur.sectionCount;
  898. 896.  -     Audio.changeHTitle(count, from_search);
  899. 897.  -   },
  900. 898.  -
  901. 899.  -   setQLoc: function(query) {
  902. 900.  -     clearTimeout(this.qTimeout);
  903. 901.  -     this.qTimeout = setTimeout(function() {
  904. 902.  -       if (cur.allAudiosIndex != 'all') {
  905. 903.  -         if (cur.allAudiosIndex && cur.allAudiosIndex.substr(0, 5) == 'owner') {
  906. 904.  -           extend(nav.objLoc, {owner: cur.audioFriend});
  907. 905.  -         } else {
  908. 906.  -           extend(nav.objLoc, {friend: cur.audioFriend});
  909. 907.  -         }
  910. 908.  -       } else {
  911. 909.  -         delete nav.objLoc.owner;
  912. 910.  -         delete nav.objLoc.friend;
  913. 911.  -       }
  914. 912.  -       if (cur.curSection && cur.curSection.substr(0, 4) == 'club') {
  915. 913.  -         extend(nav.objLoc, {club: cur.club});
  916. 914.  -       } else {
  917. 915.  -         delete nav.objLoc.club;
  918. 916.  -         delete nav.objLoc.genre;
  919. 917.  -       }
  920. 918.  -       if (query) {
  921. 919.  -         extend(nav.objLoc, {q: query});
  922. 920.  -         var performer = cur.searchTypeMenu ? parseInt(cur.searchTypeMenu.val()) : 0;
  923. 921.  -         if (performer) {
  924. 922.  -           extend(nav.objLoc, {performer: performer});
  925. 923.  -         } else {
  926. 924.  -           delete nav.objLoc.performer;
  927. 925.  -         }
  928. 926.  -       } else {
  929. 927.  -         delete nav.objLoc.q;
  930. 928.  -       }
  931. 929.  -       nav.setLoc(nav.objLoc);
  932. 930.  -     }, 500);
  933. 931.  -   },
  934. 932.  -
  935. 933.  -   filterClaimed: function(arr) {
  936. 934.  -     var len = arr.length;
  937. 935.  -     var res = [];
  938. 936.  -     for (var i = 0; i < len; i++) {
  939. 937.  -       var t = arr[i];
  940. 938.  -       if (t && (!(t[11] && parseInt(t[11])) || t[12] && parseInt(t[12])) || nav.objLoc.claim) {
  941. 939.  -         res.push(t);
  942. 940.  -       }
  943. 941.  -     }
  944. 942.  -     return res;
  945. 943.  -   },
  946. 944.  -
  947. 945.  -   filterDeleted: function(arr) {
  948. 946.  -     var len = arr.length;
  949. 947.  -     var res = [];
  950. 948.  -     for (var i = 0; i < len; i++) {
  951. 949.  -       var t = arr[i];
  952. 950.  -       if (cur.audios && cur.audios[t[1]] && !cur.audios[t[1]].deleted) {
  953. 951.  -         res.push(t);
  954. 952.  -       }
  955. 953.  -     }
  956. 954.  -     return res;
  957. 955.  -   },
  958. 956.  -
  959. 957.  -   filterByAlbum: function(arr, album) {
  960. 958.  -     var len = arr.length;
  961. 959.  -     var res = [];
  962. 960.  -     for (var i = 0; i < len; i++) {
  963. 961.  -       var t = arr[i];
  964. 962.  -       if (album == t[8]) {
  965. 963.  -         res.push(t);
  966. 964.  -       }
  967. 965.  -     }
  968. 966.  -     return res;
  969. 967.  -   },
  970. 968.  -
  971. 969.  -   animateAdded: function(el, speed) {
  972. 970.  -     var c = se('<div class="audio_add_wrap anim fl_r"><div class="audio_add_anim_wrap"><div class="audio_add_anim clear_fix"><div class="audio_add fl_l"></div><div class="audio_add done fl_l"></div></div></div></div>');
  973. 971.  -     el.parentNode.replaceChild(c, el);
  974. 972.  -     el = c;
  975. 973.  -     setTimeout(function() {
  976. 974.  -       var anim = geByClass1('audio_add_anim', el), add = anim.firstChild, added = add.nextSibling;
  977. 975.  -       cssAnim(anim, {left: '-15px'}, {duration: speed}, function() {
  978. 976.  -         setStyle(anim.parentNode, {width: '15px'});
  979. 977.  -         setStyle(anim.parentNode.parentNode, {paddingLeft: '2px'});
  980. 978.  -         setStyle(anim, {left: '-13px'});
  981. 979.  -       });
  982. 980.  -       cssAnim(add, {opacity: 0}, {duration: speed});
  983. 981.  -       cssAnim(added, {opacity: 1}, {duration: speed});
  984. 982.  -     }, 0);
  985. 983.  -     return el;
  986. 984.  -   },
  987. 985.  -
  988. 986.  -   addShareAudio: function(el, aid, oid, hash, gid, top) {
  989. 987.  -     if (el.tt) el.tt.hide();
  990. 988.  -     el = Audio.animateAdded(el, 200);
  991. 989.  -     var query = {act:'add', aid:aid, oid:oid, hash:hash, top:top};
  992. 990.  -     if (gid) query.gid = cur.gid;
  993. 991.  -     if (cur.curSection == 'recommendations') query.recommendation = 1;
  994. 992.  -     if ((cur.module == 'audio' || cur.module == 'feed') && nav.objLoc['q'] || cur.module == 'search' && nav.objLoc['c[q]']) query.search = 1;
  995. 993.  -     ajax.post(Audio.address, query, {
  996. 994.  -       onDone: function (data, res) {
  997. 995.  -         var obj = eval('('+data+')');
  998. 996.  -         if (((!cur.gid && cur.id == vk.id) || (cur.gid && gid)) && obj) {
  999. 997.  -           setTimeout(function(){
  1000. 998.  -             obj = obj['all'][0];
  1001. 999.  -             var all_list = cur.audiosList['all'];
  1002. 1000.  -             if (all_list && all_list.length) {
  1003. 1001.  -               obj._order = all_list[0]._order - 1;
  1004. 1002.  -               cur.audiosList['all'].splice(0,0,obj);
  1005. 1003.  -             } else {
  1006. 1004.  -               obj._order = 0;
  1007. 1005.  -               cur.audiosList['all'] = [obj];
  1008. 1006.  -             }
  1009. 1007.  -             cur.audios[obj[1]] = obj;
  1010. 1008.  -             if (cur.allAudiosIndex == 'all') {
  1011. 1009.  -               cur.audiosIndex.add(obj);
  1012. 1010.  -             }
  1013. 1011.  -           }, 0);
  1014. 1012.  -         }
  1015. 1013.  -         var showShare = function() {
  1016. 1014.  -           addClass(ge('audio'+oid+'_'+aid), 'tt_shown');
  1017. 1015.  -           showTooltip(el, {
  1018. 1016.  -             content: res.content,
  1019. 1017.  -             slide: 15,
  1020. 1018.  -             shift: [59, 5, 0],
  1021. 1019.  -             black: 1,
  1022. 1020.  -             hidedt: 200,
  1023. 1021.  -             className: 'audio_add_tt wall_tt rich',
  1024. 1022.  -             onHide: function() {
  1025. 1023.  -               removeClass(ge('audio'+oid+'_'+aid), 'tt_shown');
  1026. 1024.  -             }
  1027. 1025.  -           });
  1028. 1026.  -           var tip = el.tt;
  1029. 1027.  -           if (tip && !tip.inited) {
  1030. 1028.  -             var a = geByClass('add_cont', tip.container)[0];
  1031. 1029.  -             tip.onClean = function() {
  1032. 1030.  -               tip.inited = false;
  1033. 1031.  -               removeEvent(tip.container, 'mouseover', tip.show);
  1034. 1032.  -               removeEvent(tip.container, 'mouseout', tip.hide);
  1035. 1033.  -             }
  1036. 1034.  -             addEvent(tip.container, 'mouseover', tip.show);
  1037. 1035.  -             addEvent(tip.container, 'mouseout', tip.hide);
  1038. 1036.  -             addEvent(a, 'click', function(){
  1039. 1037.  -               toggleClass(this, 'on');
  1040. 1038.  -               var share_q = {act: 'share_audio', audio:res.audio, status: tip.status? tip.status : 0, check: hasClass(a, 'on')?1:0, hash: res.hash};
  1041. 1039.  -               if (gid) share_q.gid = cur.gid;
  1042. 1040.  -               ajax.post(Audio.address, share_q, {
  1043. 1041.  -                 onDone: function(data) {
  1044. 1042.  -                   if (data) tip.status = data;
  1045. 1043.  -                 }
  1046. 1044.  -               });
  1047. 1045.  -             });
  1048. 1046.  -             tip.inited = true;
  1049. 1047.  -           }
  1050. 1048.  -         }
  1051. 1049.  -         addEvent(el, 'mouseover', showShare);
  1052. 1050.  -         if (!cur.addedIds) cur.addedIds = {};
  1053. 1051.  -         cur.addedIds[oid+'_'+aid] = 1;
  1054. 1052.  -         if (window.audioPlayer && currentAudioId()) {
  1055. 1053.  -           var cur_aids = currentAudioId().split('_');
  1056. 1054.  -           if (cur_aids[0] == oid && cur_aids[1] == aid) {
  1057. 1055.  -             audioPlayer.showCurrentAdded();
  1058. 1056.  -           }
  1059. 1057.  -         }
  1060. 1058.  -       }
  1061. 1059.  -     });
  1062. 1060.  -   },
  1063. 1061.  -
  1064. 1062.  -   alistOver: function(obj){
  1065. 1063.  -     if (!hasClass(obj, 'audio_list_cell_on')) {
  1066. 1064.  -       obj.className = 'audio_list_cell_over';
  1067. 1065.  -     }
  1068. 1066.  -   },
  1069. 1067.  -
  1070. 1068.  -   alistOff: function(obj) {
  1071. 1069.  -     if (!hasClass(obj, 'audio_list_cell_on')){
  1072. 1070.  -       obj.className = 'audio_list_cell';
  1073. 1071.  -     }
  1074. 1072.  -   },
  1075. 1073.  -
  1076. 1074.  -   listOut: function(obj) {
  1077. 1075.  -     removeClass(obj, 'over');
  1078. 1076.  -   },
  1079. 1077.  -
  1080. 1078.  -   listOver: function(obj) {
  1081. 1079.  -     addClass(obj, 'over');
  1082. 1080.  -   },
  1083. 1081.  -
  1084. 1082.  -   loadAlbum: function(album_id, filter, showAlbums) {
  1085. 1083.  -     if (cur.silent) {
  1086. 1084.  -       cur.onSilentLoad = function() {
  1087. 1085.  -         Audio.loadAlbum(album_id, filter, showAlbums);
  1088. 1086.  -       };
  1089. 1087.  -       return;
  1090. 1088.  -     }
  1091. 1089.  -     if (!album_id && !showAlbums && (cur.oid == vk.id) && isVisible('audio_more_friends')) {
  1092. 1090.  -       cur.shownFriends = [];
  1093. 1091.  -       Audio.showMoreFriends(addClass.pbind(ge('album0'), 'loading'), removeClass.pbind(ge('album0'), 'loading'));
  1094. 1092.  -     }
  1095. 1093.  -     //if (cur.searchStr && isVisible(cur.searchInfoCont)) {
  1096. 1094.  -     hide(cur.searchInfoCont);
  1097. 1095.  -     //}
  1098. 1096.  -     if (cur.allAudiosIndex != 'all') {
  1099. 1097.  -       Audio.loadFriendsAudios(vk.id, 'all', album_id, showAlbums);
  1100. 1098.  -       return;
  1101. 1099.  -     }
  1102. 1100.  -     if (!Audio.allAudios().length && cur.allAudiosIndex == 'all' && cur.oid <= 0) {
  1103. 1101.  -       addClass(cur.audioWrap, 'audio_no_recs');
  1104. 1102.  -     }
  1105. 1103.  -     if (filter) {
  1106. 1104.  -       cur.filterUnsorted = 1;
  1107. 1105.  -     } else {
  1108. 1106.  -       delete cur.filterUnsorted;
  1109. 1107.  -     }
  1110. 1108.  -     var curSel = cur.filterUnsorted ? ge('album_unsorted') : (showAlbums ? ge('audios_albums') : ge('album' + album_id));
  1111. 1109.  -     cur.lastAct = 'album' + album_id;
  1112. 1110.  -     album_id = album_id || 0;
  1113. 1111.  -     each(geByClass('audio_filter', cur.albumFilters), function(i, e) {
  1114. 1112.  -       removeClass(e, 'selected');
  1115. 1113.  -     });
  1116. 1114.  -     if (curSel) addClass(curSel, 'selected');
  1117. 1115.  -     removeClass(cur.albumFiltered, 'selected');
  1118. 1116.  -     hide(cur.popularFilters, cur.popularOwners, cur.searchFilters);
  1119. 1117.  -     if (album_id == 0 && !showAlbums && (cur.oid == vk.id)) {
  1120. 1118.  -       hide(cur.audioAlbums);
  1121. 1119.  -       show(cur.audioFriends);
  1122. 1120.  -       var curEl = geByClass1('current', ge('audio_friends_list'));
  1123. 1121.  -       if (curEl) removeClass(curEl, 'current');
  1124. 1122.  -     } else {
  1125. 1123.  -       hide(cur.audioFriends);
  1126. 1124.  -       show(cur.audioAlbums);
  1127. 1125.  -     }
  1128. 1126.  -     if (showAlbums && !filter && !album_id) {
  1129. 1127.  -       Audio.updateAlbums();
  1130. 1128.  -     }
  1131. 1129.  -     delete nav.objLoc.q;
  1132. 1130.  -     delete nav.objLoc.owner;
  1133. 1131.  -     delete nav.objLoc.friend;
  1134. 1132.  -     delete cur.recsOffset;
  1135. 1133.  -     delete cur.popularOffset;
  1136. 1134.  -     delete nav.objLoc.club;
  1137. 1135.  -     delete nav.objLoc.genre;
  1138. 1136.  -     delete nav.objLoc.audio_id;
  1139. 1137.  -     delete cur._back;
  1140. 1138.  -     if (nav.objLoc.act == 'recommendations' || nav.objLoc.act == 'popular' || nav.objLoc.act == 'feed' || nav.objLoc.act == 'albums') delete nav.objLoc.act;
  1141. 1139.  -     if (album_id) {
  1142. 1140.  -       extend(nav.objLoc, {album_id: album_id});
  1143. 1141.  -     } else if (showAlbums) {
  1144. 1142.  -       extend(nav.objLoc, {act: 'albums'});
  1145. 1143.  -     } else {
  1146. 1144.  -       delete nav.objLoc.album_id;
  1147. 1145.  -     }
  1148. 1146.  -     nav.setLoc(nav.objLoc);
  1149. 1147.  -     clearTimeout(this.filterTimeout);
  1150. 1148.  -     this.filterTimeout = setTimeout((function() {
  1151. 1149.  -       val(cur.aSearch, '');
  1152. 1150.  -       removeClass(cur.clearSearch, 'shown');
  1153. 1151.  -       cur.searchStr = '';
  1154. 1152.  -       cur.album_id = album_id;
  1155. 1153.  -       var type = (album_id) ? 'album'+album_id : cur.allAudiosIndex;
  1156. 1154.  -       this.searchAudios('', type);
  1157. 1155.  -       this.hideSearchResults();
  1158. 1156.  -       scrollToTop();
  1159. 1157.  -     }).bind(this), 10);
  1160. 1158.  -     if (cur.oid == vk.id) {
  1161. 1159.  -       ajax.post(Audio.address, {act: 'list_stats', albums: (album_id || showAlbums) ? 1 : 0});
  1162. 1160.  -     }
  1163. 1161.  -   },
  1164. 1162.  -
  1165. 1163.  -   addAudio: function(params, event) {
  1166. 1164.  -     if (cur.uploadBanned) {
  1167. 1165.  -       setTimeout(showFastBox(getLang('audio_no_upload_title'), getLang('audio_claims_no_upload')).hide, 5000);
  1168. 1166.  -       if (event) cancelEvent(event);
  1169. 1167.  -       return false;
  1170. 1168.  -     }
  1171. 1169.  -     showBox(Audio.address, extend(params || {}, {act: 'new_audio', gid: cur.gid}), {
  1172. 1170.  -       params: {width: '440px', bodyStyle: 'padding: 0px; position: relative;'}
  1173. 1171.  -     });
  1174. 1172.  -     if (event) cancelEvent(event);
  1175. 1173.  -     return false;
  1176. 1174.  -   },
  1177. 1175.  -
  1178. 1176.  -   mixAllAudios: function(mix, noShuffle) {
  1179. 1177.  -     var all_list = Audio.allAudios(), _a = window.audioPlayer, current = 0;
  1180. 1178.  -     if (!all_list) return;
  1181. 1179.  -     if (mix) {
  1182. 1180.  -       if (all_list[0] && all_list[0]._old_order !== undefined) return;
  1183. 1181.  -       for (var i = all_list.length; i; ) {
  1184. 1182.  -         var j = parseInt(Math.random() * i)
  1185. 1183.  -         var x = all_list[--i];
  1186. 1184.  -         all_list[i] = all_list[j];
  1187. 1185.  -         all_list[i]._old_order = all_list[i]._order;
  1188. 1186.  -         all_list[i]._order = i;
  1189. 1187.  -         if (currentAudioId() == all_list[i][0]+'_'+all_list[i][1]) {
  1190. 1188.  -           current = i;
  1191. 1189.  -         }
  1192. 1190.  -         all_list[j] = x;
  1193. 1191.  -       };
  1194. 1192.  -       if (current) {
  1195. 1193.  -         var x = all_list[current];
  1196. 1194.  -         all_list[current] = all_list[0];
  1197. 1195.  -         all_list[current]._order = current;
  1198. 1196.  -         all_list[0] = x;
  1199. 1197.  -         all_list[0]._order = 0;
  1200. 1198.  -       }
  1201. 1199.  -     } else {
  1202. 1200.  -       for (var i in all_list) {
  1203. 1201.  -         if (all_list[i]._old_order !== undefined) {
  1204. 1202.  -           all_list[i]._order = all_list[i]._old_order;
  1205. 1203.  -           delete all_list[i]._old_order;
  1206. 1204.  -         }
  1207. 1205.  -       };
  1208. 1206.  -     }
  1209. 1207.  -     if (!noShuffle) cur.justShuffled = true;
  1210. 1208.  -   },
  1211. 1209.  -   mixAudios: function() {
  1212. 1210.  -     if (cur.curSection == 'recommendations') {
  1213. 1211.  -       Audio.loadRecommendations({update: 'remix'});
  1214. 1212.  -       return;
  1215. 1213.  -     }
  1216. 1214.  -     if (cur.curSection == 'popular') {
  1217. 1215.  -       Audio.loadPopular('remix');
  1218. 1216.  -       return;
  1219. 1217.  -     }
  1220. 1218.  -     if (cur.silent) {
  1221. 1219.  -       cur.onSilentLoad = function() {
  1222. 1220.  -         Audio.mixAudios();
  1223. 1221.  -       };
  1224. 1222.  -       return;
  1225. 1223.  -     }
  1226. 1224.  -     var _a = window.audioPlayer;
  1227. 1225.  -     Audio.mixAllAudios(_a && _a.shuffle);
  1228. 1226.  -     cur.ignoreEqual = true;
  1229. 1227.  -     if (cur.album_id) {
  1230. 1228.  -       this.loadAlbum(cur.album_id);
  1231. 1229.  -     } else {
  1232. 1230.  -       this.updateList(null, cur.aSearch, undefined, nav.objLoc.act == 'albums');
  1233. 1231.  -     }
  1234. 1232.  -     cur.shuffled = _a && _a.shuffle;
  1235. 1233.  -   },
  1236. 1234.  -
  1237. 1235.  -   loadRecommendations: function(opts) {
  1238. 1236.  -     if (cur.loadingRecs) return;
  1239. 1237.  -     opts = opts || {};
  1240. 1238.  -     var update = opts.update, audioId = opts.audioId;
  1241. 1239.  -     if (update) {
  1242. 1240.  -       delete cur.recsOffset;
  1243. 1241.  -       delete cur.recommendIds;
  1244. 1242.  -       delete cur.recommendAudios;
  1245. 1243.  -       delete cur.preloadJSON;
  1246. 1244.  -     }
  1247. 1245.  -     if (audioId) {
  1248. 1246.  -       cur.recsAudioId = audioId;
  1249. 1247.  -     } else if (update === true) {
  1250. 1248.  -       delete cur.recsAudioId;
  1251. 1249.  -     }
  1252. 1250.  -     each(geByClass('audio_filter', cur.albumFilters), function(i, e) {
  1253. 1251.  -       removeClass(e, 'selected');
  1254. 1252.  -     });
  1255. 1253.  -     if (cur.searchStr && isVisible(cur.searchInfoCont)) {
  1256. 1254.  -       hide(cur.searchInfoCont);
  1257. 1255.  -     }
  1258. 1256.  -     var rec_filter = ge('recommendations');
  1259. 1257.  -     addClass(rec_filter, 'selected');
  1260. 1258.  -     removeClass(cur.albumFiltered, 'selected');
  1261. 1259.  -     hide(cur.searchFilters, cur.popularFilters);
  1262. 1260.  -     if (cur.oid == vk.id) {
  1263. 1261.  -       hide(cur.audioFriends, cur.audioAlbums);
  1264. 1262.  -       hide(cur.searchInfoCont);
  1265. 1263.  -     }
  1266. 1264.  -     removeClass(cur.albumFiltered, 'club_shown');
  1267. 1265.  -     Audio.handleFilterPos();
  1268. 1266.  -     cur.lastSection = cur.curSection;
  1269. 1267.  -     cur.curSection = 'recommendations';
  1270. 1268.  -     if (cur.recsOffset === undefined) {
  1271. 1269.  -       cur.recsOffset = 0;
  1272. 1270.  -     } else {
  1273. 1271.  -       addClass(cur.showMore, 'loading');
  1274. 1272.  -     }
  1275. 1273.  -     if (cur.recommendIds === undefined) cur.recommendIds = [];
  1276. 1274.  -     if (cur.recommendAudios === undefined) cur.recommendAudios = [];
  1277. 1275.  -     if (cur.recsCount === undefined) cur.recsCount = 0;
  1278. 1276.  -     if (cur.sPreload.innerHTML) {
  1279. 1277.  -       while (cur.sPreload.firstChild) {
  1280. 1278.  -         var el = cur.sPreload.firstChild;
  1281. 1279.  -         cur.aContent.appendChild(el);
  1282. 1280.  -         cur.recsCount++;
  1283. 1281.  -       }
  1284. 1282.  -     }
  1285. 1283.  -     if (cur.preloadJSON) {
  1286. 1284.  -       json = cur.preloadJSON['all'];
  1287. 1285.  -       var cur_order = cur.recsCount;
  1288. 1286.  -       for (var i in json) {
  1289. 1287.  -         var audio = json[i];
  1290. 1288.  -         audio._order = cur_order++;
  1291. 1289.  -         if (indexOf(cur.recommendIds, audio[0]+"_"+audio[1]) == -1) {
  1292. 1290.  -           cur.recommendIds.push(audio[0]+"_"+audio[1]);
  1293. 1291.  -           cur.recommendAudios.push(audio);
  1294. 1292.  -         }
  1295. 1293.  -       }
  1296. 1294.  -       var aid = currentAudioId(), needs_update = (aid && cur.recommendIds && indexOf(cur.recommendIds, aid) != -1);
  1297. 1295.  -       audioPlayer.genPlaylist(cur.recommendAudios, needs_update);
  1298. 1296.  -     }
  1299. 1297.  -     if (cur.noRecommendations) {
  1300. 1298.  -       hide(cur.showMore);
  1301. 1299.  -       delete cur.noRecommendations;
  1302. 1300.  -       return;
  1303. 1301.  -     }
  1304. 1302.  -     if (opts.tt) {
  1305. 1303.  -       opts.tt.hide();
  1306. 1304.  -     }
  1307. 1305.  -     cur.loadingRecs = true;
  1308. 1306.  -     cur.lastAct = 'recommendations';
  1309. 1307.  -     var offset = cur.recsOffset, query = {act: 'get_recommendations', id: cur.id, offset: offset},
  1310. 1308.  -         needsUpdate = window.audioPlayer && audioPlayer.shuffle;
  1311. 1309.  -     if (update == 'remix' || needsUpdate != cur.recsRemix) {
  1312. 1310.  -       cur.recsRemix = needsUpdate;
  1313. 1311.  -       query.remix = needsUpdate ? 1 : 0;
  1314. 1312.  -       var aid = currentAudioId();
  1315. 1313.  -       if (aid && window.audioPlaylist && audioPlaylist[aid] && audioPlaylist.address && audioPlaylist.address.indexOf('act=recommendations') > 0) {
  1316. 1314.  -         var a = audioPlaylist[aid];
  1317. 1315.  -         if (a[10]) query.current = a[10]+' '+aid;
  1318. 1316.  -       }
  1319. 1317.  -     }
  1320. 1318.  -     if (cur.recsAudioId) {
  1321. 1319.  -       query.audio_id = cur.recsAudioId;
  1322. 1320.  -     }
  1323. 1321.  -     ajax.post(Audio.address, query, {
  1324. 1322.  -       onDone: function(rows, preload, json, preload_json, options, ownersRows) {
  1325. 1323.  -         delete cur.loadingRecs;
  1326. 1324.  -         if (cur.lastAct != 'recommendations') return;
  1327. 1325.  -         if (!offset) {
  1328. 1326.  -           if (ownersRows) {
  1329. 1327.  -             val('audio_popular_owners_rows', ownersRows);
  1330. 1328.  -             show(cur.popularOwners);
  1331. 1329.  -           } else {
  1332. 1330.  -             hide(cur.popularOwners);
  1333. 1331.  -           }
  1334. 1332.  -         }
  1335. 1333.  -         if (options.recsCount === 0 && offset) {
  1336. 1334.  -           cur.noRecommendations = true;
  1337. 1335.  -           delete options.recsOffset;
  1338. 1336.  -         }
  1339. 1337.  -         if (json) {
  1340. 1338.  -           json = eval('('+json+')');
  1341. 1339.  -           json = json['all'];
  1342. 1340.  -           var cur_order = cur.recsCount;
  1343. 1341.  -           for (var i in json) {
  1344. 1342.  -             var audio = json[i];
  1345. 1343.  -             audio._order = cur_order++;
  1346. 1344.  -             if (indexOf(cur.recommendIds, audio[0]+"_"+audio[1]) == -1) {
  1347. 1345.  -               cur.recommendIds.push(audio[0]+"_"+audio[1]);
  1348. 1346.  -               cur.recommendAudios.push(audio);
  1349. 1347.  -             }
  1350. 1348.  -           }
  1351. 1349.  -           var aid = currentAudioId(), needs_update = (aid && cur.recommendIds && indexOf(cur.recommendIds, aid) != -1);
  1352. 1350.  -           audioPlayer.genPlaylist(cur.recommendAudios, needs_update);
  1353. 1351.  -           if (query.audio_id) {
  1354. 1352.  -             cur.nextPlaylist.rec = 1;
  1355. 1353.  -           }
  1356. 1354.  -         }
  1357. 1355.  -         removeClass(cur.showMore, 'loading');
  1358. 1356.  -         if (offset) {
  1359. 1357.  -           delete options.recsCount;
  1360. 1358.  -         }
  1361. 1359.  -         if (options) extend(cur, options);
  1362. 1360.  -         if (!offset) {
  1363. 1361.  -           cur.aContent.innerHTML = rows;
  1364. 1362.  -         }
  1365. 1363.  -
  1366. 1364.  -         cur.preloadJSON = preload_json ? eval('('+preload_json+')') : false;
  1367. 1365.  -         cur.sPreload.innerHTML = '';
  1368. 1366.  -         var au = ce('div', {innerHTML: preload});
  1369. 1367.  -         while (au.firstChild) {
  1370. 1368.  -           if (!ge(au.firstChild.id)) {
  1371. 1369.  -             var el = au.firstChild;
  1372. 1370.  -             cur.sPreload.appendChild(el);
  1373. 1371.  -           } else {
  1374. 1372.  -             au.removeChild(au.firstChild);
  1375. 1373.  -           }
  1376. 1374.  -         }
  1377. 1375.  -
  1378. 1376.  -         if (cur.recsCount && !query.audio_id) {
  1379. 1377.  -           show(cur.showMore);
  1380. 1378.  -         } else {
  1381. 1379.  -           hide(cur.showMore);
  1382. 1380.  -         }
  1383. 1381.  -         if (query.remix) {
  1384. 1382.  -           cur.justShuffled = true;
  1385. 1383.  -         }
  1386. 1384.  -         Audio.changeHTitle();
  1387. 1385.  -         val(cur.aSearch, '');
  1388. 1386.  -         removeClass(cur.clearSearch, 'shown');
  1389. 1387.  -         cur.searchStr = '';
  1390. 1388.  -         cur.album_id = 0;
  1391. 1389.  -         Audio.hideSearchResults();
  1392. 1390.  -         hide(cur.sShowMore);
  1393. 1391.  -         if (!offset) scrollToTop();
  1394. 1392.  -         delete nav.objLoc.q;
  1395. 1393.  -         delete nav.objLoc.owner;
  1396. 1394.  -         delete nav.objLoc.friend;
  1397. 1395.  -         delete nav.objLoc.album_id;
  1398. 1396.  -         delete nav.objLoc.club;
  1399. 1397.  -         delete nav.objLoc.genre;
  1400. 1398.  -         delete cur._back;
  1401. 1399.  -         extend(nav.objLoc, {act: 'recommendations'});
  1402. 1400.  -         if (query.audio_id) {
  1403. 1401.  -           extend(nav.objLoc, {audio_id: query.audio_id});
  1404. 1402.  -         } else {
  1405. 1403.  -           delete nav.objLoc.audio_id;
  1406. 1404.  -         }
  1407. 1405.  -         nav.setLoc(nav.objLoc);
  1408. 1406.  -         var _a = window.audioPlayer;
  1409. 1407.  -         if (_a && _a.showCurrentTrack) _a.showCurrentTrack();
  1410. 1408.  -         if (window.Pads && Pads.updateAudioPlaylist) {
  1411. 1409.  -           Pads.updateAudioPlaylist();
  1412. 1410.  -         }
  1413. 1411.  -       },
  1414. 1412.  -       onFail: function(msg) {
  1415. 1413.  -         delete cur.loadingRecs;
  1416. 1414.  -         cur.curSection = cur.lastSection;
  1417. 1415.  -         removeClass(ge('recommendations'), 'selected');
  1418. 1416.  -         setTimeout(showFastBox(getLang('global_error'), msg).hide, 3000);
  1419. 1417.  -         return true;
  1420. 1418.  -       },
  1421. 1419.  -       showProgress: function () {
  1422. 1420.  -         addClass(rec_filter, 'loading');
  1423. 1421.  -       },
  1424. 1422.  -       hideProgress: function () {
  1425. 1423.  -         removeClass(rec_filter, 'loading');
  1426. 1424.  -       }
  1427. 1425.  -     });
  1428. 1426.  -     cur.recsOffset += offset ? 50 : 100;
  1429. 1427.  -   },
  1430. 1428.  -
  1431. 1429.  -   loadPopular: function(update, genre) {
  1432. 1430.  -     if (cur.silent) {
  1433. 1431.  -       cur.onSilentLoad = function() {
  1434. 1432.  -         Audio.loadPopular(update, genre);
  1435. 1433.  -       };
  1436. 1434.  -       return;
  1437. 1435.  -     }
  1438. 1436.  -     if (cur.loadingPopular) return;
  1439. 1437.  -     if (cur.popularAudios === undefined) {
  1440. 1438.  -       cur.popularAudios = [];
  1441. 1439.  -     }
  1442. 1440.  -     if (update) {
  1443. 1441.  -       delete cur.popularOffset;
  1444. 1442.  -       delete cur.popularIds;
  1445. 1443.  -       delete cur.popularAudios[genre];
  1446. 1444.  -       delete cur.preloadJSON;
  1447. 1445.  -       if (genre !== undefined) {
  1448. 1446.  -         cur.genre = genre;
  1449. 1447.  -       }
  1450. 1448.  -     }
  1451. 1449.  -     each(geByClass('audio_filter', cur.albumFilters), function(i, e) {
  1452. 1450.  -       removeClass(e, 'selected');
  1453. 1451.  -     });
  1454. 1452.  -     if (cur.searchStr && isVisible(cur.searchInfoCont)) {
  1455. 1453.  -       hide(cur.searchInfoCont);
  1456. 1454.  -     }
  1457. 1455.  -     var genre_filter = false;
  1458. 1456.  -     if (cur.genre) {
  1459. 1457.  -       var prevGenre = geByClass1('selected', ge('audio_genres'));
  1460. 1458.  -       if (prevGenre) {
  1461. 1459.  -         removeClass(prevGenre, 'selected');
  1462. 1460.  -       }
  1463. 1461.  -
  1464. 1462.  -       genre_filter = ge('audio_genre_'+cur.genre);
  1465. 1463.  -       if (genre_filter) {
  1466. 1464.  -         addClass(genre_filter, 'selected');
  1467. 1465.  -       } else {
  1468. 1466.  -         cur.genre = 0;
  1469. 1467.  -       }
  1470. 1468.  -     }
  1471. 1469.  -     var pop_filter = ge('top_audios');
  1472. 1470.  -     addClass(pop_filter, 'selected');
  1473. 1471.  -     removeClass(cur.albumFiltered, 'selected');
  1474. 1472.  -     toggle(cur.audioFriends, false);
  1475. 1473.  -     hide(cur.searchInfoCont);
  1476. 1474.  -     if (cur.popularFilters) {
  1477. 1475.  -       show(cur.popularFilters);
  1478. 1476.  -       hide(cur.audioAlbums);
  1479. 1477.  -     } else {
  1480. 1478.  -       show(cur.audioAlbums);
  1481. 1479.  -       Audio.updateAlbums();
  1482. 1480.  -     }
  1483. 1481.  -     removeClass(cur.albumFiltered, 'club_shown');
  1484. 1482.  -     hide(cur.searchFilters, cur.popularOwners);
  1485. 1483.  -     Audio.handleFilterPos();
  1486. 1484.  -     cur.curSection = 'popular';
  1487. 1485.  -     if (cur.popularOffset === undefined) {
  1488. 1486.  -       cur.popularOffset = 0;
  1489. 1487.  -     } else {
  1490. 1488.  -       addClass(cur.showMore, 'loading');
  1491. 1489.  -     }
  1492. 1490.  -     if (cur.popularIds === undefined) cur.popularIds = [];
  1493. 1491.  -     if (cur.popularAudios[genre] === undefined) cur.popularAudios[genre] = [];
  1494. 1492.  -     if (cur.popularCount === undefined) cur.popularCount = 0;
  1495. 1493.  -     if (cur.sPreload.innerHTML) {
  1496. 1494.  -       while (cur.sPreload.firstChild) {
  1497. 1495.  -         var el = cur.sPreload.firstChild;
  1498. 1496.  -         cur.aContent.appendChild(el);
  1499. 1497.  -         cur.popularCount++;
  1500. 1498.  -       }
  1501. 1499.  -     }
  1502. 1500.  -     if (cur.preloadJSON) {
  1503. 1501.  -       json = cur.preloadJSON['all'];
  1504. 1502.  -       var cur_order = cur.popularCount;
  1505. 1503.  -       for (var i in json) {
  1506. 1504.  -         var audio = json[i];
  1507. 1505.  -         audio._order = cur_order++;
  1508. 1506.  -         if (indexOf(cur.popularIds, audio[0]+"_"+audio[1]) == -1) {
  1509. 1507.  -           cur.popularIds.push(audio[0]+"_"+audio[1]);
  1510. 1508.  -           cur.popularAudios[genre].push(audio);
  1511. 1509.  -         }
  1512. 1510.  -       }
  1513. 1511.  -       var aid = currentAudioId(), needs_update = (aid && cur.popularIds && indexOf(cur.popularIds, aid) != -1);
  1514. 1512.  -       audioPlayer.genPlaylist(cur.popularAudios[genre], needs_update);
  1515. 1513.  -     }
  1516. 1514.  -     if (cur.noPopular) {
  1517. 1515.  -       hide(cur.showMore);
  1518. 1516.  -       delete cur.noPopular;
  1519. 1517.  -       return;
  1520. 1518.  -     }
  1521. 1519.  -     cur.loadingPopular = true;
  1522. 1520.  -     cur.lastAct = 'popular';
  1523. 1521.  -     var offset = cur.popularOffset, query = {act: 'get_popular', offset: offset},
  1524. 1522.  -         needsUpdate = window.audioPlayer && audioPlayer.shuffle;
  1525. 1523.  -     if (nav.objLoc.update)  {
  1526. 1524.  -       query.update = 1;
  1527. 1525.  -     }
  1528. 1526.  -     if (needsUpdate && !offset) query.offset = -1;
  1529. 1527.  -     if (update == 'remix' || needsUpdate != cur.popRemix) {
  1530. 1528.  -       cur.popRemix = needsUpdate;
  1531. 1529.  -       query.remix = needsUpdate ? 1 : 0;
  1532. 1530.  -       var aid = currentAudioId();
  1533. 1531.  -       if (aid && window.audioPlaylist && audioPlaylist[aid] && audioPlaylist.address && audioPlaylist.address.indexOf('act=popular') > 0) {
  1534. 1532.  -         query.current = aid;
  1535. 1533.  -       }
  1536. 1534.  -     }
  1537. 1535.  -     if (cur.topType !== undefined) {
  1538. 1536.  -       query.type = cur.topType;
  1539. 1537.  -       delete cur.topType;
  1540. 1538.  -     }
  1541. 1539.  -     if (cur.genre) {
  1542. 1540.  -       query.genre = cur.genre;
  1543. 1541.  -     }
  1544. 1542.  -     ajax.post(Audio.address, query, {
  1545. 1543.  -       onDone: function(rows, preload, json, preload_json, options, genres) {
  1546. 1544.  -         delete cur.loadingPopular;
  1547. 1545.  -         if (cur.lastAct != 'popular') return;
  1548. 1546.  -         if (options.popularCount === 0 && offset) {
  1549. 1547.  -           cur.noPopular = true;
  1550. 1548.  -           delete options.popularOffset;
  1551. 1549.  -         }
  1552. 1550.  -         if (json) {
  1553. 1551.  -           json = eval('('+json+')');
  1554. 1552.  -           json = json['all'];
  1555. 1553.  -           var cur_order = cur.popularCount;
  1556. 1554.  -           for (var i in json) {
  1557. 1555.  -             var audio = json[i];
  1558. 1556.  -             audio._order = cur_order++;
  1559. 1557.  -             if (indexOf(cur.popularIds, audio[0]+"_"+audio[1]) == -1) {
  1560. 1558.  -               cur.popularIds.push(audio[0]+"_"+audio[1]);
  1561. 1559.  -               cur.popularAudios[genre].push(audio);
  1562. 1560.  -             }
  1563. 1561.  -           }
  1564. 1562.  -           var aid = currentAudioId(), needs_update = (aid && cur.popularIds && indexOf(cur.popularIds, aid) != -1);
  1565. 1563.  -           audioPlayer.genPlaylist(cur.popularAudios[genre], needs_update);
  1566. 1564.  -         }
  1567. 1565.  -         removeClass(cur.showMore, 'loading');
  1568. 1566.  -         if (offset) {
  1569. 1567.  -           delete options.popularCount;
  1570. 1568.  -         }
  1571. 1569.  -         if (options) extend(cur, options);
  1572. 1570.  -         if (!offset) {
  1573. 1571.  -           cur.aContent.innerHTML = rows;
  1574. 1572.  -         }
  1575. 1573.  -
  1576. 1574.  -         if (preload_json) {
  1577. 1575.  -           cur.preloadJSON = eval('('+preload_json+')');
  1578. 1576.  -         } else {
  1579. 1577.  -           cur.preloadJSON = {};
  1580. 1578.  -         }
  1581. 1579.  -         cur.sPreload.innerHTML = '';
  1582. 1580.  -         var au = ce('div', {innerHTML: preload});
  1583. 1581.  -         while (au.firstChild) {
  1584. 1582.  -           if (!ge(au.firstChild.id)) {
  1585. 1583.  -             var el = au.firstChild;
  1586. 1584.  -             cur.sPreload.appendChild(el);
  1587. 1585.  -           } else {
  1588. 1586.  -             au.removeChild(au.firstChild);
  1589. 1587.  -           }
  1590. 1588.  -         }
  1591. 1589.  -
  1592. 1590.  -         if (cur.popularCount) {
  1593. 1591.  -           show(cur.showMore);
  1594. 1592.  -         } else {
  1595. 1593.  -           hide(cur.showMore);
  1596. 1594.  -         }
  1597. 1595.  -         if (update == 'remix') {
  1598. 1596.  -           cur.justShuffled = true;
  1599. 1597.  -         }
  1600. 1598.  -         if (genres) {
  1601. 1599.  -           ge('audio_genres').innerHTML = genres;
  1602. 1600.  -         }
  1603. 1601.  -         Audio.changeHTitle();
  1604. 1602.  -         val(cur.aSearch, '');
  1605. 1603.  -         removeClass(cur.clearSearch, 'shown');
  1606. 1604.  -         cur.searchStr = '';
  1607. 1605.  -         cur.album_id = 0;
  1608. 1606.  -         Audio.hideSearchResults();
  1609. 1607.  -         hide(cur.sShowMore);
  1610. 1608.  -         if (!offset) scrollToTop();
  1611. 1609.  -         delete nav.objLoc.q;
  1612. 1610.  -         delete nav.objLoc.owner;
  1613. 1611.  -         delete nav.objLoc.friend;
  1614. 1612.  -         delete nav.objLoc.album_id;
  1615. 1613.  -         delete nav.objLoc.club;
  1616. 1614.  -         delete nav.objLoc.genre;
  1617. 1615.  -         delete nav.objLoc.audio_id;
  1618. 1616.  -         nav.objLoc.act = 'popular';
  1619. 1617.  -         if (cur.genre) {
  1620. 1618.  -           nav.objLoc.genre = cur.genre;
  1621. 1619.  -         } else {
  1622. 1620.  -           delete nav.objLoc.genre;
  1623. 1621.  -         }
  1624. 1622.  -         nav.setLoc(nav.objLoc);
  1625. 1623.  -         var _a = window.audioPlayer;
  1626. 1624.  -         if (_a && _a.showCurrentTrack) _a.showCurrentTrack();
  1627. 1625.  -         if (window.tooltips) {
  1628. 1626.  -           tooltips.destroyAll();
  1629. 1627.  -         }
  1630. 1628.  -         if (window.Pads && Pads.updateAudioPlaylist) {
  1631. 1629.  -           Pads.updateAudioPlaylist();
  1632. 1630.  -         }
  1633. 1631.  -         if (options.infoJS) {
  1634. 1632.  -           eval('(function(){' + options.infoJS + ';})()');
  1635. 1633.  -         }
  1636. 1634.  -       },
  1637. 1635.  -       showProgress: function () {
  1638. 1636.  -         addClass(genre_filter || pop_filter, 'loading');
  1639. 1637.  -       },
  1640. 1638.  -       hideProgress: function () {
  1641. 1639.  -         removeClass(genre_filter || pop_filter, 'loading');
  1642. 1640.  -       }
  1643. 1641.  -     });
  1644. 1642.  -     cur.popularOffset += offset ? 50 : 100;
  1645. 1643.  -   },
  1646. 1644.  -
  1647. 1645.  -   loadFeed: function(update) {
  1648. 1646.  -     if (cur.silent) {
  1649. 1647.  -       cur.onSilentLoad = function() {
  1650. 1648.  -         Audio.loadFeed(update);
  1651. 1649.  -       };
  1652. 1650.  -       return;
  1653. 1651.  -     }
  1654. 1652.  -     if (cur.isFeedLoading) return;
  1655. 1653.  -     cur.isFeedLoading = true;
  1656. 1654.  -     if (cur.audiosList['all'] && cur.allAudiosIndex != 'all') {
  1657. 1655.  -       cur.allAudiosIndex = 'all';
  1658. 1656.  -       this.indexAll();
  1659. 1657.  -       var curEl = geByClass1('current', ge('audio_friends_list'));
  1660. 1658.  -       if (curEl) removeClass(curEl, 'current');
  1661. 1659.  -     }
  1662. 1660.  -     if (update) {
  1663. 1661.  -       delete cur.feedFrom;
  1664. 1662.  -       delete cur.feedOffset;
  1665. 1663.  -       delete cur.feedIds;
  1666. 1664.  -       delete cur.feedAudios;
  1667. 1665.  -       if (update === 'reload') {
  1668. 1666.  -         var params = {act: 'feed', part: 1, update: 1}, q = Audio.address + '#' + ajx2q(params);
  1669. 1667.  -         delete window.ajaxCache[q];
  1670. 1668.  -       }
  1671. 1669.  -     }
  1672. 1670.  -     each(geByClass('audio_filter', cur.albumFilters), function(i, e) {
  1673. 1671.  -       removeClass(e, 'selected');
  1674. 1672.  -     });
  1675. 1673.  -     if (cur.searchStr && isVisible(cur.searchInfoCont)) {
  1676. 1674.  -       hide(cur.searchInfoCont);
  1677. 1675.  -     }
  1678. 1676.  -     var feed_filter = ge('feed_filter');
  1679. 1677.  -     addClass(feed_filter, 'selected');
  1680. 1678.  -     removeClass(cur.albumFiltered, 'selected');
  1681. 1679.  -     hide(cur.searchFilters, cur.popularFilters, cur.popularOwners);
  1682. 1680.  -     if (cur.oid == vk.id) {
  1683. 1681.  -       show(cur.audioFriends);
  1684. 1682.  -       hide(cur.searchInfoCont);
  1685. 1683.  -       hide(cur.audioAlbums);
  1686. 1684.  -     }
  1687. 1685.  -     removeClass(cur.albumFiltered, 'club_shown');
  1688. 1686.  -     Audio.handleFilterPos();
  1689. 1687.  -     cur.lastSection = cur.curSection;
  1690. 1688.  -     cur.curSection = 'feed';
  1691. 1689.  -     if (!update) {
  1692. 1690.  -       addClass(cur.showMore, 'loading');
  1693. 1691.  -     }
  1694. 1692.  -     cur.lastAct = 'feed';
  1695. 1693.  -     ajax.post(Audio.address, {act: 'feed', offset: cur.feedOffset, from: cur.feedFrom, part: 1, update: update ? 1 : ''}, {
  1696. 1694.  -       onDone: function (rows, script) {
  1697. 1695.  -         if (cur.lastAct != 'feed') return;
  1698. 1696.  -         if (rows) {
  1699. 1697.  -           if (update) {
  1700. 1698.  -             cur.aContent.innerHTML = rows;
  1701. 1699.  -           } else {
  1702. 1700.  -             var au = ce('div'), par = geByClass1('wall_module', cur.aContent), row;
  1703. 1701.  -             au.innerHTML = rows;
  1704. 1702.  -             if (par && update) {
  1705. 1703.  -               par.innerHTML = '';
  1706. 1704.  -             }
  1707. 1705.  -             while (row = au.firstChild) {
  1708. 1706.  -               if (!row.id || ge(row.id)) {
  1709. 1707.  -                 au.removeChild(row);
  1710. 1708.  -                 continue;
  1711. 1709.  -               }
  1712. 1710.  -               if (par) {
  1713. 1711.  -                 par.appendChild(row);
  1714. 1712.  -               }
  1715. 1713.  -             }
  1716. 1714.  -           }
  1717. 1715.  -         } else {
  1718. 1716.  -           hide(cur.showMore);
  1719. 1717.  -         }
  1720. 1718.  -         if (script) {
  1721. 1719.  -           eval(script);
  1722. 1720.  -         }
  1723. 1721.  -         var aid = currentAudioId(), needs_update = (aid && cur.feedIds && indexOf(cur.feedIds, aid) != -1);
  1724. 1722.  -         audioPlayer.genPlaylist(cur.feedAudios, needs_update);
  1725. 1723.  -         removeClass(cur.showMore, 'loading');
  1726. 1724.  -         Audio.changeHTitle();
  1727. 1725.  -         val(cur.aSearch, '');
  1728. 1726.  -         removeClass(cur.clearSearch, 'shown');
  1729. 1727.  -         cur.searchStr = '';
  1730. 1728.  -         cur.album_id = 0;
  1731. 1729.  -         Audio.hideSearchResults();
  1732. 1730.  -         hide(cur.sShowMore);
  1733. 1731.  -         if (update) scrollToTop();
  1734. 1732.  -         delete nav.objLoc.q;
  1735. 1733.  -         delete nav.objLoc.owner;
  1736. 1734.  -         delete nav.objLoc.friend;
  1737. 1735.  -         delete nav.objLoc.album_id;
  1738. 1736.  -         delete nav.objLoc.club;
  1739. 1737.  -         delete nav.objLoc.genre;
  1740. 1738.  -         delete nav.objLoc.audio_id;
  1741. 1739.  -         delete cur._back;
  1742. 1740.  -         extend(nav.objLoc, {act: 'feed'});
  1743. 1741.  -         nav.setLoc(nav.objLoc);
  1744. 1742.  -         var _a = window.audioPlayer;
  1745. 1743.  -         if (_a && _a.showCurrentTrack) _a.showCurrentTrack();
  1746. 1744.  -       },
  1747. 1745.  -       showProgress: function () {
  1748. 1746.  -         cur.isFeedLoading = true;
  1749. 1747.  -         addClass(feed_filter, 'loading');
  1750. 1748.  -       },
  1751. 1749.  -       hideProgress: function () {
  1752. 1750.  -         cur.isFeedLoading = false;
  1753. 1751.  -         removeClass(feed_filter, 'loading');
  1754. 1752.  -       },
  1755. 1753.  -       cache: 1
  1756. 1754.  -     });
  1757. 1755.  -   },
  1758. 1756.  -
  1759. 1757.  -   reorderPlaylist: function(aid, before_id, after_id) {
  1760. 1758.  -     each([window.audioPlaylist, cur.nextPlaylist], function(i, e) {
  1761. 1759.  -       var list = e;
  1762. 1760.  -       if (before_id && !after_id && list && list[before_id]) {
  1763. 1761.  -         after_id = list[before_id]._prev;
  1764. 1762.  -       }
  1765. 1763.  -       if (list && list[aid] && after_id && list[after_id] && after_id != aid) {
  1766. 1764.  -         var next_id = list[aid]._next, prev_id = list[aid]._prev;
  1767. 1765.  -         if (next_id != aid) {
  1768. 1766.  -           list[next_id]._prev = prev_id;
  1769. 1767.  -           list[prev_id]._next = next_id;
  1770. 1768.  -           list[aid]._prev = after_id;
  1771. 1769.  -           list[aid]._next = list[after_id]._next;
  1772. 1770.  -           list[after_id]._next = list[list[after_id]._next]._prev = aid;
  1773. 1771.  -         }
  1774. 1772.  -       }
  1775. 1773.  -     });
  1776. 1774.  -     var plist = ls.get('pad_playlist');
  1777. 1775.  -     if (plist && plist[aid] && after_id && plist[after_id] && after_id != aid && window.audioPlayer) {
  1778. 1776.  -       audioPlayer.setPadPlaylist();
  1779. 1777.  -     }
  1780. 1778.  -   },
  1781. 1779.  -
  1782. 1780.  -   removeFromPlaylist: function(aid) {
  1783. 1781.  -     each([window.audioPlaylist, cur.nextPlaylist], function(i, e) {
  1784. 1782.  -       var list = e;
  1785. 1783.  -       if (list && list[aid]) {
  1786. 1784.  -         var next_id = list[aid]._next, prev_id = list[aid]._prev;
  1787. 1785.  -         if (next_id != aid) {
  1788. 1786.  -           // delete list[aid];
  1789. 1787.  -           list[next_id]._prev = prev_id;
  1790. 1788.  -           list[prev_id]._next = next_id;
  1791. 1789.  -         }
  1792. 1790.  -       }
  1793. 1791.  -     });
  1794. 1792.  -     var plist = ls.get('pad_playlist');
  1795. 1793.  -     if (plist && plist[aid] && window.audioPlayer) {
  1796. 1794.  -       audioPlayer.setPadPlaylist();
  1797. 1795.  -     }
  1798. 1796.  -   },
  1799. 1797.  -
  1800. 1798.  -   backToPlaylist: function(aid) {
  1801. 1799.  -     each([window.audioPlaylist, cur.nextPlaylist], function(i, e) {
  1802. 1800.  -       var list = e;
  1803. 1801.  -       if (list && list[aid]) {
  1804. 1802.  -         var next_id = list[aid]._next, prev_id = list[aid]._prev;
  1805. 1803.  -         if (next_id != aid) {
  1806. 1804.  -           list[next_id]._prev = list[prev_id]._next = aid;
  1807. 1805.  -         }
  1808. 1806.  -       }
  1809. 1807.  -     });
  1810. 1808.  -     var plist = ls.get('pad_playlist');
  1811. 1809.  -     if (plist && plist[aid] && window.audioPlayer) {
  1812. 1810.  -       audioPlayer.setPadPlaylist();
  1813. 1811.  -     }
  1814. 1812.  -   },
  1815. 1813.  -
  1816. 1814.  -   hideRecommendation: function(aid, q, hash, event) {
  1817. 1815.  -     if (window.audioPlayer && currentAudioId() == aid) {
  1818. 1816.  -       audioPlayer.nextTrack(true);
  1819. 1817.  -     }
  1820. 1818.  -     var recRow = ge('audio'+aid);
  1821. 1819.  -     if (recRow) {
  1822. 1820.  -       if (window.tooltips) {
  1823. 1821.  -         tooltips.hide(ge('remove'+aid))
  1824. 1822.  -       }
  1825. 1823.  -       slideUp(recRow, 200, function() {
  1826. 1824.  -         recRow.parentNode.removeChild(recRow);
  1827. 1825.  -         Audio.removeFromPlaylist(aid);
  1828. 1826.  -         cur.recsCount--;
  1829. 1827.  -         Audio.changeHTitle();
  1830. 1828.  -       });
  1831. 1829.  -     }
  1832. 1830.  -     ajax.post(Audio.address, {act: 'hide_recommendation', q: q, hash: hash});
  1833. 1831.  -     if (event) cancelEvent(event);
  1834. 1832.  -     return false;
  1835. 1833.  -   },
  1836. 1834.  -
  1837. 1835.  -   _animDelX: function(el, opacity, set_active) {
  1838. 1836.  -     if (!el) return;
  1839. 1837.  -     if (set_active !== undefined) {
  1840. 1838.  -       el.active = set_active;
  1841. 1839.  -     } else if (el.active) {
  1842. 1840.  -       return;
  1843. 1841.  -     }
  1844. 1842.  -     animate(el, {opacity: opacity}, 200);
  1845. 1843.  -   },
  1846. 1844.  -
  1847. 1845.  -   rowActive: function(el, tt, sh) {
  1848. 1846.  -     Audio._animDelX(el, 1, 1);
  1849. 1847.  -     if (tt) showTooltip(el, {text: tt, showdt: 0, black: 1, shift: (sh ? sh : [12, 4, 0])});
  1850. 1848.  -   },
  1851. 1849.  -   rowInactive: function(el, light) {
  1852. 1850.  -     var opacity = light ? 0.6 : 0.4;
  1853. 1851.  -     Audio._animDelX(el, opacity, 0);
  1854. 1852.  -   },
  1855. 1853.  -
  1856. 1854.  -   switchToFriends: function() {
  1857. 1855.  -     each(geByClass('audio_filter', cur.albumFilters), function(i, e) {
  1858. 1856.  -       removeClass(e, 'selected');
  1859. 1857.  -     });
  1860. 1858.  -     addClass(ge('friends_audios'), 'selected');
  1861. 1859.  -     removeClass(cur.albumFiltered, 'selected');
  1862. 1860.  -     var showFriends = function() {
  1863. 1861.  -       show(cur.audioFriends);
  1864. 1862.  -       hide(cur.searchInfoCont);
  1865. 1863.  -       hide(cur.audioAlbums, cur.searchFilters, cur.popularFilters, cur.popularOwners);
  1866. 1864.  -     }
  1867. 1865.  -     if (!cur.audioFriendPlaying && cur.shownFriends.length <= 10) {
  1868. 1866.  -       Audio.cacheFriendsList();
  1869. 1867.  -       showFriends();
  1870. 1868.  -       Audio.selectFriend(cur.audioFriend);
  1871. 1869.  -     } else {
  1872. 1870.  -       addClass(ge('friends_audios'), 'loading');
  1873. 1871.  -       var query = {act: 'more_friends'};
  1874. 1872.  -       if (cur.audioFriendPlaying) query.owner = cur.audioFriendPlaying;
  1875. 1873.  -       else if (cur.audioFriend) query.owner = cur.audioFriend;
  1876. 1874.  -       ajax.post(Audio.address, query, {
  1877. 1875.  -         cache: 1,
  1878. 1876.  -         onDone: function(cont, friends) {
  1879. 1877.  -           if (cont) {
  1880. 1878.  -             ge('audio_friends_list').innerHTML = cont;
  1881. 1879.  -           }
  1882. 1880.  -           addClass(ge('audio_friend'+cur.audioFriend), 'current');
  1883. 1881.  -           removeClass(ge('friends_audios'), 'loading');
  1884. 1882.  -           showFriends();
  1885. 1883.  -           cur.shownFriends = friends;
  1886. 1884.  -           var fid = cur.audioFriendPlaying ? cur.audioFriendPlaying : cur.audioFriend;
  1887. 1885.  -           Audio.selectFriend(fid);
  1888. 1886.  -         },
  1889. 1887.  -         onFail: function() {removeClass(ge('friends_audios'), 'loading');}
  1890. 1888.  -       });
  1891. 1889.  -     }
  1892. 1890.  -   },
  1893. 1891.  -   selectFriend: function(id, ev) {
  1894. 1892.  -     if (cur.skipSelectFriend) {
  1895. 1893.  -       cur.skipSelectFriend = false;
  1896. 1894.  -       return;
  1897. 1895.  -     }
  1898. 1896.  -     each(geByTag('div', cur.audioFriends), function(i, e) {
  1899. 1897.  -       removeClass(e, 'current');
  1900. 1898.  -     });
  1901. 1899.  -     addClass(ge('audio_friend' + id), 'current');
  1902. 1900.  -     addClass(ge('album0'), 'loading');
  1903. 1901.  -     each(geByClass('audio_filter', cur.albumFilters), function(i, e) {
  1904. 1902.  -       removeClass(e, 'selected');
  1905. 1903.  -     });
  1906. 1904.  -     Audio.loadFriendsAudios(id, 'friend'+id);
  1907. 1905.  -     if (id && cur.oid == vk.id) {
  1908. 1906.  -       ajax.post(Audio.address, {act: 'list_stats', owner: id});
  1909. 1907.  -     }
  1910. 1908.  -     return ev ? cancelEvent(ev) : false;
  1911. 1909.  -   },
  1912. 1910.  -   skipSelectFriend: function() {
  1913. 1911.  -     cur.skipSelectFriend = true;
  1914. 1912.  -   },
  1915. 1913.  -   selectCommunity: function(id, ev) {
  1916. 1914.  -     if (cur.skipSelectCommunity) {
  1917. 1915.  -       cur.skipSelectCommunity = false;
  1918. 1916.  -       return;
  1919. 1917.  -     }
  1920. 1918.  -     each(geByClass('audio_friend', cur.searchInfoCont), function(i, e) {
  1921. 1919.  -       removeClass(e, 'current');
  1922. 1920.  -     });
  1923. 1921.  -     addClass(ge('audio_community' + id), 'current');
  1924. 1922.  -     mentionOver(ge('audio_community' + id), {shift: [47, 7, 7]});
  1925. 1923.  -     each(geByClass('audio_filter', cur.albumFilters), function(i, e) {
  1926. 1924.  -       removeClass(e, 'selected');
  1927. 1925.  -     });
  1928. 1926.  -     addClass(cur.albumFiltered, 'club_shown');
  1929. 1927.  -     cur.searchSortFilter.disable(true);
  1930. 1928.  -     cur.searchLyricsFilter.disable(true);
  1931. 1929.  -     removeClass(cur.albumFiltered, 'selected');
  1932. 1930.  -     cur.club = id;
  1933. 1931.  -     Audio.loadCommunityAudios(id, 'club'+id);
  1934. 1932.  -     if (id && cur.oid == vk.id) {
  1935. 1933.  -       ajax.post(Audio.address, {act: 'list_stats', club: id});
  1936. 1934.  -     }
  1937. 1935.  -     return ev ? cancelEvent(ev) : false;
  1938. 1936.  -   },
  1939. 1937.  -   skipSelectCommunity: function() {
  1940. 1938.  -     cur.skipSelectCommunity = true;
  1941. 1939.  -   },
  1942. 1940.  -   backToSearch: function() {
  1943. 1941.  -     if (cur.curSection && cur.curSection.substr(0, 4) == 'club') {
  1944. 1942.  -       cur.ignoreEqual = true;
  1945. 1943.  -       each(geByClass('audio_friend', cur.searchInfoCont), function() {
  1946. 1944.  -         removeClass(this, 'current');
  1947. 1945.  -       });
  1948. 1946.  -       this.updateList(null, cur.aSearch);
  1949. 1947.  -     }
  1950. 1948.  -   },
  1951. 1949.  -   playCurrent: function(el, hash, ev) {
  1952. 1950.  -     var _a = window.audioPlayer, aid = currentAudioId(), audioId = el.getAttribute('data-audio');
  1953. 1951.  -     if (_a) _a.gpDisabled = false;
  1954. 1952.  -     if ((window.audioPlaylist || {})[audioId]) {
  1955. 1953.  -       if (!_a || aid != audioId || _a.player.paused()) playAudioNew(audioId);
  1956. 1954.  -       return cancelEvent(ev);
  1957. 1955.  -     }
  1958. 1956.  -
  1959. 1957.  -     var prg = el.nextSibling || el.parentNode.appendChild(ce('span', {className: 'progress_inline current_audio_prg'}));
  1960. 1958.  -     stManager.add(['audioplayer.css', 'audioplayer.js']);
  1961. 1959.  -     ajax.post(Audio.address, {act: 'play_audio_status', id: audioId, hash: hash}, {
  1962. 1960.  -       onDone: function(info, data, uid) {
  1963. 1961.  -         if (data && uid && window.audioPlayer) {
  1964. 1962.  -           audioPlayer.statusData = audioPlayer.statusData || {};
  1965. 1963.  -           audioPlayer.statusData[uid] = data;
  1966. 1964.  -         }
  1967. 1965.  -         if (!info) return;
  1968. 1966.  -
  1969. 1967.  -         if (!window.audioPlaylist) {
  1970. 1968.  -           window.audioPlaylist = {};
  1971. 1969.  -         }
  1972. 1970.  -         audioPlaylist[audioId] = info;
  1973. 1971.  -         audioPlaylist.start = audioId;
  1974. 1972.  -         if (!audioPlaylist.searchStr) {
  1975. 1973.  -           window.lastPlaylist = clone(audioPlaylist);
  1976. 1974.  -         }
  1977. 1975.  -         if (window.audioPlayer) {
  1978. 1976.  -           audioPlayer.setPadPlaylist();
  1979. 1977.  -         }
  1980. 1978.  -         delete audioPlaylist.searchStr;
  1981. 1979.  -         playAudioNew(audioId);
  1982. 1980.  -       },
  1983. 1981.  -       showProgress: function() {
  1984. 1982.  -         show(prg);
  1985. 1983.  -         hide(el);
  1986. 1984.  -       },
  1987. 1985.  -       hideProgress: function() {
  1988. 1986.  -         hide(prg);
  1989. 1987.  -         show(el);
  1990. 1988.  -       }
  1991. 1989.  -     });
  1992. 1990.  -     return cancelEvent(ev);
  1993. 1991.  -   },
  1994. 1992.  -   loadFriendsAudios: function(id, index, album, showAlbums, owner) {
  1995. 1993.  -     if (cur.silent) {
  1996. 1994.  -       cur.onSilentLoad = function() {
  1997. 1995.  -         Audio.loadFriendsAudios(id, index, album, showAlbums);
  1998. 1996.  -       };
  1999. 1997.  -       return;
  2000. 1998.  -     }
  2001. 1999.  -     if (!cur.audiosList[index]) {
  2002. 2000.  -       if (index == 'all') {
  2003. 2001.  -         each(geByClass('audio_filter', cur.albumFilters), function(i, e) {
  2004. 2002.  -           removeClass(e, 'selected');
  2005. 2003.  -         });
  2006. 2004.  -         if (showAlbums) {
  2007. 2005.  -           addClass(ge('audios_albums'), 'selected loading');
  2008. 2006.  -         } else {
  2009. 2007.  -           addClass(ge('album0'), 'selected loading');
  2010. 2008.  -         }
  2011. 2009.  -         removeClass(cur.albumFiltered, 'selected');
  2012. 2010.  -       }
  2013. 2011.  -       cur.lastAct = index;
  2014. 2012.  -       var query = {act: 'load_audios_silent', id: id, please_dont_ddos: 3};
  2015. 2013.  -       if (owner) {
  2016. 2014.  -         query.is_owner = 1;
  2017. 2015.  -       }
  2018. 2016.  -       if (index != 'all' && !ge('audio_friend' + id) && !owner) {
  2019. 2017.  -         cur.shownFriends = [];
  2020. 2018.  -         var txt = domFC(ge('audio_more_friends')), prg = domLC(ge('audio_more_friends'));
  2021. 2019.  -         Audio.showMoreFriends(function() {
  2022. 2020.  -           hide(txt);
  2023. 2021.  -           show(prg);
  2024. 2022.  -         }, function() {
  2025. 2023.  -           hide(prg);
  2026. 2024.  -           show(txt);
  2027. 2025.  -         }, id);
  2028. 2026.  -       }
  2029. 2027.  -       ajax.post(Audio.address, query, {
  2030. 2028.  -         cache: 1,
  2031. 2029.  -         onDone: function(data, opts) {
  2032. 2030.  -           if (cur.lastAct != index) return;
  2033. 2031.  -           opts = eval('('+opts+')');
  2034. 2032.  -           if (id < 0) {
  2035. 2033.  -             cur.allFriendsHTitles = cur.allFriendsHTitles || {};
  2036. 2034.  -             cur.allFriendsHTitles[id] = opts.summaryLang.all_club_htitle;
  2037. 2035.  -           } else {
  2038. 2036.  -             cur.allFriendsTitles = cur.allFriendsTitles || {};
  2039. 2037.  -             cur.allFriendsTitles[id] = opts.summaryLang.all_friend_title;
  2040. 2038.  -             cur.allFriendsHTitles = cur.allFriendsHTitles || {};
  2041. 2039.  -             cur.allFriendsHTitles[id] = opts.summaryLang.all_friend_htitle;
  2042. 2040.  -           }
  2043. 2041.  -           var obj = eval('('+data+')');
  2044. 2042.  -           if (!obj) return;
  2045. 2043.  -           cur.audiosList[index] = obj['all'];
  2046. 2044.  -           if (id == vk.id && index == 'all') {
  2047. 2045.  -             cur.allAudiosIndex = 'all';
  2048. 2046.  -             Audio.generateAlbums();
  2049. 2047.  -           }
  2050. 2048.  -           if (!cur.performerInfo) {
  2051. 2049.  -             cur.performerInfo = {};
  2052. 2050.  -           }
  2053. 2051.  -           cur.performerInfo[index] = opts.performerInfo;
  2054. 2052.  -           if (opts.backLink) {
  2055. 2053.  -             cur.backLink = opts.backLink;
  2056. 2054.  -             showBackLink('/audio?act=popular'+(cur.genre ? '&genre='+cur.genre : ''), cur.backLink);
  2057. 2055.  -           }
  2058. 2056.  -           if (index != 'all') cur.audioFriend = id;
  2059. 2057.  -           Audio.changeAllIndex(index, album, showAlbums, owner);
  2060. 2058.  -           Audio.cacheFriendsList();
  2061. 2059.  -         }
  2062. 2060.  -       });
  2063. 2061.  -     } else {
  2064. 2062.  -       if (index != 'all') cur.audioFriend = id;
  2065. 2063.  -       if (owner) {
  2066. 2064.  -         showBackLink('/audio?act=popular'+(cur.genre ? '&genre='+cur.genre : ''), cur.backLink);
  2067. 2065.  -       }
  2068. 2066.  -       Audio.changeAllIndex(index, album, showAlbums, owner);
  2069. 2067.  -     }
  2070. 2068.  -   },
  2071. 2069.  -   loadCommunityAudios: function(gid, index) {
  2072. 2070.  -     if (cur.silent) {
  2073. 2071.  -       cur.onSilentLoad = function() {
  2074. 2072.  -         Audio.loadCommunityAudios(gid, index);
  2075. 2073.  -       };
  2076. 2074.  -       return;
  2077. 2075.  -     }
  2078. 2076.  -     if (!cur.audiosList[index]) {
  2079. 2077.  -       cur.lastAct = index;
  2080. 2078.  -       ajax.post(Audio.address, {act: 'load_audios_silent', gid: gid, please_dont_ddos: 1}, {
  2081. 2079.  -         cache: 1,
  2082. 2080.  -         showProgress: addClass.pbind(ge('album0'), 'loading'),
  2083. 2081.  -         hideProgress: removeClass.pbind(ge('album0'), 'loading'),
  2084. 2082.  -         onDone: function(data, opts) {
  2085. 2083.  -           if (cur.lastAct != index) return;
  2086. 2084.  -           opts = eval('('+opts+')');
  2087. 2085.  -           cur.allClubsHTitles = cur.allClubsHTitles || {};
  2088. 2086.  -           cur.allClubsHTitles[gid] = opts.summaryLang.all_club_htitle;
  2089. 2087.  -           var obj = eval('('+data+')');
  2090. 2088.  -           if (!obj) return;
  2091. 2089.  -           cur.audiosList[index] = obj['all'];
  2092. 2090.  -           Audio.searchAudios('', index);
  2093. 2091.  -           scrollToTop();
  2094. 2092.  -         }
  2095. 2093.  -       });
  2096. 2094.  -     } else {
  2097. 2095.  -       Audio.searchAudios('', index);
  2098. 2096.  -       scrollToTop();
  2099. 2097.  -     }
  2100. 2098.  -   },
  2101. 2099.  -   showMoreFriends: function(showProgress, hideProgress, friend) {
  2102. 2100.  -     if (cur.moreFriendsSent) {
  2103. 2101.  -       return;
  2104. 2102.  -     }
  2105. 2103.  -     cur.moreFriendsSent = true;
  2106. 2104.  -     var query = {act: 'more_friends', ids: cur.shownFriends};
  2107. 2105.  -     if (friend) {
  2108. 2106.  -       query.owner = friend;
  2109. 2107.  -     }
  2110. 2108.  -     ajax.post(Audio.address, query, {
  2111. 2109.  -       onDone: function(cont, friends, reset) {
  2112. 2110.  -         cur.moreFriendsSent = false;
  2113. 2111.  -         if (cont) {
  2114. 2112.  -           var list = ge('audio_friends_list');
  2115. 2113.  -           re('audio_friends_old');
  2116. 2114.  -           var old = ce('div', {innerHTML: '<div id="audio_friends_old" style="position: absolute;">'+list.innerHTML+'</div>'}).firstChild;
  2117. 2115.  -           list.parentNode.insertBefore(old, list);
  2118. 2116.  -           list.innerHTML = '';
  2119. 2117.  -           setStyle(list, {display: 'none'});
  2120. 2118.  -           list.innerHTML = cont;
  2121. 2119.  -           var oldRows = geByClass('audio_friend', old), oldCnt = oldRows.length,
  2122. 2120.  -               newCnt = geByClass('audio_friend', list).length;
  2123. 2121.  -           if (oldCnt > newCnt) {
  2124. 2122.  -             oldRows = oldRows.slice(newCnt);
  2125. 2123.  -             each(oldRows, function() {
  2126. 2124.  -               re(this);
  2127. 2125.  -             });
  2128. 2126.  -           }
  2129. 2127.  -           setTimeout(Audio.handleFilterPos, 0);
  2130. 2128.  -           fadeIn(list, 400, re.pbind(old));
  2131. 2129.  -           if (friends) {
  2132. 2130.  -             cur.shownFriends = reset ? friends : cur.shownFriends.concat(friends);
  2133. 2131.  -           }
  2134. 2132.  -         } else {
  2135. 2133.  -           hide(el.parentNode.parentNode);
  2136. 2134.  -           Audio.handleFilterPos();
  2137. 2135.  -         }
  2138. 2136.  -       },
  2139. 2137.  -       onFail: function() {
  2140. 2138.  -         cur.moreFriendsSent = false;
  2141. 2139.  -       },
  2142. 2140.  -       showProgress: showProgress,
  2143. 2141.  -       hideProgress: hideProgress
  2144. 2142.  -     });
  2145. 2143.  -   },
  2146. 2144.  -   cacheFriendsList: function() {
  2147. 2145.  -     var query = {act: 'more_friends'};
  2148. 2146.  -     if (cur.audioFriendPlaying) query.owner = cur.audioFriendPlaying;
  2149. 2147.  -     else if (cur.audioFriend) query.owner = cur.audioFriend;
  2150. 2148.  -     ajax.post(Audio.address, query, {cache: 1});
  2151. 2149.  -   },
  2152. 2150.  -
  2153. 2151.  -   // Audio Edit functions
  2154. 2152.  -
  2155. 2153.  -   showAudioClaimWarning: function(aid, claim_id, title, reason) {
  2156. 2154.  -     if (cur.silent) {
  2157. 2155.  -       cur.onSilentLoad = function() {
  2158. 2156.  -         Audio.showAudioClaimWarning(aid, claim_id, title, reason);
  2159. 2157.  -       };
  2160. 2158.  -       return;
  2161. 2159.  -     }
  2162. 2160.  -     var claimText, claimTitle;
  2163. 2161.  -     if (reason == 'crap') {
  2164. 2162.  -       claimText = getLang(claim_id >= 0 ? 'audio_crap_warning_text' : 'audio_crap_warning') || getLang(claim_id > 0 ? 'audio_claim_warning_objection' : (claim_id == 0 ? 'audio_claim_warning_text' : 'audio_claim_warning'));
  2165. 2163.  -       claimTitle = getLang('audio_crap_warning_title') || getLang('audio_claim_warning_title');
  2166. 2164.  -     } else {
  2167. 2165.  -       claimText = (claim_id > 0) ? getLang('audio_claim_warning_objection') : (claim_id == 0 ? getLang('audio_claim_warning_text') : getLang('audio_claim_warning'));
  2168. 2166.  -       claimTitle = getLang('audio_claim_warning_title');
  2169. 2167.  -     }
  2170. 2168.  -     claimText = claimText.split('{audio}').join('<b>' + title + '</b>');
  2171. 2169.  -     claimText = claimText.split('{objection_link}').join('<a href="/help?act=cc_objection&claim=' + claim_id + '&content=audio' + aid + '">' + getLang('audio_claim_objection') + '</a>');
  2172. 2170.  -     claimText = claimText.split('{delete_link}').join('<a href="#" onclick="Audio.deleteAudio(\'' + aid + '\'); return false;">' + getLang('audio_claim_delete') + '</a>');
  2173. 2171.  -     cur.claimWarning = showFastBox(claimTitle, claimText);
  2174. 2172.  -   },
  2175. 2173.  -
  2176. 2174.  -   deleteAudio: function(id) {
  2177. 2175.  -     if (cur.silent) {
  2178. 2176.  -       cur.onSilentLoad = function() {
  2179. 2177.  -         Audio.deleteAudio(id);
  2180. 2178.  -       };
  2181. 2179.  -       return;
  2182. 2180.  -     }
  2183. 2181.  -     if (cur.deleting) {
  2184. 2182.  -       return false;
  2185. 2183.  -     }
  2186. 2184.  -     cur.deleting = true;
  2187. 2185.  -     var el = ge('audio' + id), aid = id.split('_')[1];
  2188. 2186.  -     if (!cur.deletedAudios) cur.deletedAudios = [];
  2189. 2187.  -     cur.deletedAudios[aid] = el.innerHTML;
  2190. 2188.  -     var acts = geByClass1('actions', el);
  2191. 2189.  -     each(acts.children, function(){if (this.tt && this.tt.hide) this.tt.hide()});
  2192. 2190.  -     var a = (cur.audios || {})[aid] || [], lyrics = isVisible(ge('lyrics'+id)),
  2193. 2191.  -         _tw = el && geByClass1('title_wrap', el),
  2194. 2192.  -         performer = a[5] || _tw && (geByTag1('a', _tw) || {}).innerHTML || '',
  2195. 2193.  -         title = a[6] || _tw && (geByClass1('title', _tw) || {}).innerHTML || '';
  2196. 2194.  -     el.innerHTML = rs(cur.deletedTpl, {
  2197. 2195.  -       audio_id: id,
  2198. 2196.  -       performer: performer.split('<span>').join('').split('</span>').join(''),
  2199. 2197.  -       title: title,
  2200. 2198.  -       delete_all: ''
  2201. 2199.  -     });
  2202. 2200.  -     var _a = window.audioPlayer;
  2203. 2201.  -     if (currentAudioId() == id) {
  2204. 2202.  -       _a.showCurrentTrack();
  2205. 2203.  -     }
  2206. 2204.  -     if (lyrics) {
  2207. 2205.  -       Audio.updateSorterRows(ge('audio'+id));
  2208. 2206.  -     }
  2209. 2207.  -     var addBtn = ge('audio_add'+id);
  2210. 2208.  -     if (addBtn) {
  2211. 2209.  -       addBtn.onmouseover = function() {};
  2212. 2210.  -     }
  2213. 2211.  -     ajax.post(Audio.address, {act: 'delete_audio', oid: cur.oid, aid: aid, hash: cur.hashes.delete_hash, restore: 1}, {
  2214. 2212.  -       onDone: function(action, delete_all) {
  2215. 2213.  -         cur.deleting = false;
  2216. 2214.  -         if (cur.claimWarning) {
  2217. 2215.  -           cur.claimWarning.hide();
  2218. 2216.  -         }
  2219. 2217.  -         var acts = geByClass1('actions', el);
  2220. 2218.  -         each(acts.children, function(){if (this.tt) this.tt.hide()});
  2221. 2219.  -         el.innerHTML = rs(cur.deletedTpl, {
  2222. 2220.  -           audio_id: id,
  2223. 2221.  -           performer: performer.split('<span>').join('').split('</span>').join(''),
  2224. 2222.  -           title: title,
  2225. 2223.  -           delete_all: action ? action : ''
  2226. 2224.  -         });
  2227. 2225.  -         el.style.cursor = 'auto';
  2228. 2226.  -         el.setAttribute('nosorthandle', '1');
  2229. 2227.  -         if (currentAudioId() == id) {
  2230. 2228.  -           _a.showCurrentTrack();
  2231. 2229.  -         }
  2232. 2230.  -         if (delete_all) {
  2233. 2231.  -           cur.lang = cur.lang || {};
  2234. 2232.  -           cur.lang.audio_delete_all = delete_all;
  2235. 2233.  -         }
  2236. 2234.  -         if (cur.audios[aid]) {
  2237. 2235.  -           cur.audiosIndex.remove(cur.audios[aid]);
  2238. 2236.  -           cur.audios[aid].deleted = true;
  2239. 2237.  -         }
  2240. 2238.  -         Audio.removeFromPlaylist(id);
  2241. 2239.  -         cur.sectionCount--;
  2242. 2240.  -         if (cur.shownAudios) cur.shownAudios--;
  2243. 2241.  -         Audio.changeSummary();
  2244. 2242.  -       },
  2245. 2243.  -       onFail: function() {
  2246. 2244.  -         cur.deleting = false;
  2247. 2245.  -       }
  2248. 2246.  -     });
  2249. 2247.  -     return false;
  2250. 2248.  -   },
  2251. 2249.  -
  2252. 2250.  -   restoreAudio: function(id) {
  2253. 2251.  -     if (cur.restoring) {
  2254. 2252.  -       return;
  2255. 2253.  -     }
  2256. 2254.  -     cur.restoring = true;
  2257. 2255.  -     var el = ge('audio' + id), aid = id.split('_')[1];
  2258. 2256.  -     ajax.post(Audio.address, {act: 'restore_audio', oid: cur.oid, aid: aid, hash: cur.hashes.restore_hash}, {
  2259. 2257.  -       onDone: function() {
  2260. 2258.  -         cur.restoring = false;
  2261. 2259.  -         var acts = geByClass1('actions', el);
  2262. 2260.  -         each(acts.children, function(){if (this.tt) this.tt.hide()});
  2263. 2261.  -         el.innerHTML = cur.deletedAudios[aid];
  2264. 2262.  -         var lyrics = isVisible(ge('lyrics'+id));
  2265. 2263.  -         if (lyrics) {
  2266. 2264.  -           Audio.updateSorterRows(ge('audio'+id));
  2267. 2265.  -         }
  2268. 2266.  -         el.removeAttribute('nosorthandle');
  2269. 2267.  -         if (cur.audios[aid]) {
  2270. 2268.  -           cur.audiosIndex.add(cur.audios[aid]);
  2271. 2269.  -           cur.audios[aid].deleted = false;
  2272. 2270.  -         }
  2273. 2271.  -         Audio.backToPlaylist(id);
  2274. 2272.  -         cur.sectionCount++;
  2275. 2273.  -         if (cur.shownAudios) cur.shownAudios++;
  2276. 2274.  -         Audio.changeSummary();
  2277. 2275.  -         toggleClass(ge('play'+id), 'playing', id == currentAudioId());
  2278. 2276.  -       },
  2279. 2277.  -       onFail: function() {
  2280. 2278.  -         cur.restoring = false;
  2281. 2279.  -       }
  2282. 2280.  -     });
  2283. 2281.  -   },
  2284. 2282.  -
  2285. 2283.  -   deleteAll: function(object_id, from_id, to_id, hash) {
  2286. 2284.  -     var box = showFastBox(getLang('audio_delete_all_title'), getLang('audio_delete_all') || '', getLang('global_delete'), function(btn){
  2287. 2285.  -       ajax.post(Audio.address, {act: 'delete_all', object_id: object_id, to_id: to_id, from_id: from_id, hash: hash}, {
  2288. 2286.  -         showProgress: lockButton.pbind(btn),
  2289. 2287.  -         onDone: function() {
  2290. 2288.  -           nav.reload();
  2291. 2289.  -         },
  2292. 2290.  -         onFail: box.hide
  2293. 2291.  -       });
  2294. 2292.  -     }, getLang('global_cancel'));
  2295. 2293.  -   },
  2296. 2294.  -
  2297. 2295.  -   editAudio: function(aid, event){
  2298. 2296.  -     showBox(Audio.address, {act: 'edit_audio_box', aid: aid}, {
  2299. 2297.  -       params: {width: '430px', bodyStyle: 'padding: 15px;'}
  2300. 2298.  -     });
  2301. 2299.  -     if (event) cancelEvent(event);
  2302. 2300.  -     return false;
  2303. 2301.  -   },
  2304. 2302.  -
  2305. 2303.  -   editTopAudio: function(full_aid, event) {
  2306. 2304.  -     showBox('al_search.php', {act: 'audio_top_edit_box', id: full_aid, full_id: full_aid}, {
  2307. 2305.  -       params: {width: '430px', bodyStyle: 'padding: 15px;'}
  2308. 2306.  -     });
  2309. 2307.  -     if (event) cancelEvent(event);
  2310. 2308.  -     return false;
  2311. 2309.  -   },
  2312. 2310.  -
  2313. 2311.  -   removeFromTop: function(audio_hash, hash, full_aid, event) {
  2314. 2312.  -     ajax.post('al_search.php', {act: 'save_top_audio', deleted: 1, audio_hash: audio_hash, hash: hash, id: full_aid}, {
  2315. 2313.  -       onDone: function() {
  2316. 2314.  -         var audioRow = ge('audio'+full_aid);
  2317. 2315.  -         slideUp(audioRow, 100);
  2318. 2316.  -       }
  2319. 2317.  -     })
  2320. 2318.  -   },
  2321. 2319.  -
  2322. 2320.  -   updateAlbums: function() {
  2323. 2321.  -     if (!cur.canEdit || browser.mobile) return;
  2324. 2322.  -     each (cur.audioAlbumsWrap.sorter.elems, function() {
  2325. 2323.  -       setStyle(this, {top: 'auto', left: 'auto', width: 'auto'});
  2326. 2324.  -     });
  2327. 2325.  -     cur.audioAlbumsWrap.sorter.destroy();
  2328. 2326.  -     this.initAlbumsSort();
  2329. 2327.  -     this.updateAlbumsTitles();
  2330. 2328.  -   },
  2331. 2329.  -
  2332. 2330.  -   updateAlbumsTitles: function() {
  2333. 2331.  -     if (!cur.audioAlbumsWrap) return;
  2334. 2332.  -
  2335. 2333.  -     each (geByClass('label', cur.audioAlbumsWrap), function() {
  2336. 2334.  -       if (this.scrollWidth > this.clientWidth) {
  2337. 2335.  -         this.setAttribute('title', this.innerText || this.textContent);
  2338. 2336.  -       } else {
  2339. 2337.  -         this.removeAttribute('title');
  2340. 2338.  -       }
  2341. 2339.  -     });
  2342. 2340.  -   },
  2343. 2341.  -
  2344. 2342.  -   initAlbumsSort: function() {
  2345. 2343.  -     if (!cur.canEdit || browser.mobile || !cur.audioAlbumsWrap) return;
  2346. 2344.  -     sorter.init(cur.audioAlbumsWrap, {onMouseDown: Audio.hideAlbumsTT, onReorder: Audio.onAlbumReorder, noMoveCursor: 1});
  2347. 2345.  -   },
  2348. 2346.  -
  2349. 2347.  -   hideAlbumsTT: function() {
  2350. 2348.  -     each(geByClass('icon_wrap', cur.audioAlbumsWrap), function() {
  2351. 2349.  -       if (this.tt) this.tt.hide();
  2352. 2350.  -     })
  2353. 2351.  -   },
  2354. 2352.  -
  2355. 2353.  -   onAlbumReorder: function(album, before, after) {
  2356. 2354.  -     var aid = album.id.replace('album', '');
  2357. 2355.  -     var before_id = (before && before.id || '').replace('album', '');
  2358. 2356.  -     var after_id = (after && after.id || '').replace('album', '');
  2359. 2357.  -     ajax.post(Audio.address, {act: 'reorder_albums', oid: cur.oid, aid: aid, before: before_id, after: after_id, hash: cur.hashes.reorder_hash});
  2360. 2358.  -   },
  2361. 2359.  -
  2362. 2360.  -   editAlbum: function(aid){
  2363. 2361.  -     if (cur.silent) {
  2364. 2362.  -       cur.onSilentLoad = function() {
  2365. 2363.  -         Audio.editAlbum(aid);
  2366. 2364.  -       };
  2367. 2365.  -       return;
  2368. 2366.  -     }
  2369. 2367.  -     if (!cur.audiosList) {
  2370. 2368.  -       return;
  2371. 2369.  -     }
  2372. 2370.  -     var box = showTabbedBox(Audio.address, {act: 'edit_album_box', album_id: aid, oid: cur.oid}, {stat: ['privacy.js', 'privacy.css', 'ui_controls.js', 'ui_controls.css', 'indexer.js']});
  2373. 2371.  -     cur.onOListSave = Audio.saveAlbum.pbind(box, aid);
  2374. 2372.  -     return false;
  2375. 2373.  -   },
  2376. 2374.  -
  2377. 2375.  -   createAlbum: function() {
  2378. 2376.  -     return this.editAlbum(0);
  2379. 2377.  -   },
  2380. 2378.  -
  2381. 2379.  -   saveAlbum: function(box, aid, audio_ids) {
  2382. 2380.  -     var btn = geByClass1('button_blue', box.bodyNode.nextSibling).firstChild,
  2383. 2381.  -         albumName = val('album_name');
  2384. 2382.  -     if (!albumName) {
  2385. 2383.  -       notaBene('album_name');
  2386. 2384.  -       return false;
  2387. 2385.  -     }
  2388. 2386.  -     var query = {act: 'save_album', album_id: aid, name: albumName, gid: cur.gid, Audios: audio_ids.join(','), hash: cur.hashes.save_album_hash};
  2389. 2387.  -     ajax.post(Audio.address, query, {
  2390. 2388.  -       showProgress: lockButton.pbind(btn),
  2391. 2389.  -       hideProgress: unlockButton.pbind(btn),
  2392. 2390.  -       onFail: box.hide,
  2393. 2391.  -       onDone: function(album_id, audio_ids, filters) {
  2394. 2392.  -         try{
  2395. 2393.  -           cur.audioAlbumsWrap.innerHTML = filters;
  2396. 2394.  -           var old = cur.audiosList['album'+album_id];
  2397. 2395.  -           if (old) {
  2398. 2396.  -             for (var i in old) {
  2399. 2397.  -               cur.audios[old[i][1]][8] = 0;
  2400. 2398.  -             }
  2401. 2399.  -           }
  2402. 2400.  -           for (var i in audio_ids) {
  2403. 2401.  -             cur.audios[audio_ids[i]][8] = album_id;
  2404. 2402.  -           }
  2405. 2403.  -           cur.albums[album_id] = {id: album_id, title: clean(albumName)};
  2406. 2404.  -           Audio.generateAlbums();
  2407. 2405.  -           Audio.loadAlbum(album_id);
  2408. 2406.  -           Audio.initAlbumsSort();
  2409. 2407.  -           Audio.updateAlbumsTitles();
  2410. 2408.  -           box.hide();
  2411. 2409.  -         }catch(e){}
  2412. 2410.  -       }
  2413. 2411.  -     });
  2414. 2412.  -     return false;
  2415. 2413.  -   },
  2416. 2414.  -
  2417. 2415.  -   deleteAlbum: function(aid, hash){
  2418. 2416.  -     var box = showFastBox(getLang('audio_delete_album_title'), getLang('audio_delete_album_are_you_sure'), getLang('audio_delete_album_button'), function(btn){
  2419. 2417.  -       ajax.post(Audio.address, {act: 'delete_album', album_id: aid, hash: hash, gid: cur.gid}, {
  2420. 2418.  -         showProgress: lockButton.pbind(btn),
  2421. 2419.  -         hideProgress: unlockButton.pbind(btn),
  2422. 2420.  -         onDone: function(audio_ids, filters){
  2423. 2421.  -           try{
  2424. 2422.  -             re('album'+aid);
  2425. 2423.  -             boxQueue.hideAll();
  2426. 2424.  -             for (var i in audio_ids) {
  2427. 2425.  -               cur.audios[audio_ids[i]][8] = 0;
  2428. 2426.  -             }
  2429. 2427.  -             delete cur.albums[aid];
  2430. 2428.  -             Audio.generateAlbums();
  2431. 2429.  -             if (cur.album_id == aid) {
  2432. 2430.  -               Audio.loadAlbum(0, undefined, true);
  2433. 2431.  -             }
  2434. 2432.  -             Audio.updateAlbums();
  2435. 2433.  -           }catch(e){}
  2436. 2434.  -         },
  2437. 2435.  -         onFail: function(){
  2438. 2436.  -           box.hide(200);
  2439. 2437.  -         }
  2440. 2438.  -       });
  2441. 2439.  -     }, getLang('global_cancel'));
  2442. 2440.  -   },
  2443. 2441.  -
  2444. 2442.  -   moveAudio: function(full_id, album_id) {
  2445. 2443.  -     var id = full_id.split('_')[1];
  2446. 2444.  -     ajax.post(Audio.address, {act:'move_to_album', album_id:album_id, audio_id:id, gid:cur.gid, hash:cur.hashes.move_hash}, {
  2447. 2445.  -       onDone: function(text) {
  2448. 2446.  -         if((cur.album_id && cur.album_id != album_id) || cur.filterUnsorted){
  2449. 2447.  -           var el = ge('audio'+full_id);
  2450. 2448.  -           fadeOut(el, 300, function(){
  2451. 2449.  -             el.parentNode.removeChild(el);
  2452. 2450.  -             each (cur.aContent.sorter.elems, function() {
  2453. 2451.  -               setStyle(this, {top: 'auto', left: 'auto'});
  2454. 2452.  -             });
  2455. 2453.  -             cur.aContent.sorter.destroy();
  2456. 2454.  -             var opts = {onReorder: Audio.onAudioReorder, onMouseDown: Audio.onDragStart, onMouseUp: Audio.onDragEnd, noMoveCursor: 1};
  2457. 2455.  -             if (cur.albumFilters) {
  2458. 2456.  -               extend(opts, {target: cur.albumFilters, onDragOver: Audio.onDragOver, onDragOut: Audio.onDragOut});
  2459. 2457.  -             }
  2460. 2458.  -             sorter.init(cur.aContent, opts);
  2461. 2459.  -             cur.sectionCount--;
  2462. 2460.  -             Audio.changeSummary();
  2463. 2461.  -             if (cur.sectionCount == 0) {
  2464. 2462.  -               cur.aContent.innerHTML = '<div id="not_found" class="info_msg">'+getLang('audio_album_no_recs')+'</div>';
  2465. 2463.  -             }
  2466. 2464.  -             hide(cur.showMore);
  2467. 2465.  -           });
  2468. 2466.  -         }
  2469. 2467.  -         cur.audios[id][8] = album_id;
  2470. 2468.  -         Audio.generateAlbums();
  2471. 2469.  -       }
  2472. 2470.  -     });
  2473. 2471.  -   },
  2474. 2472.  -
  2475. 2473.  -   onAudioReorder: function(audio, before, after) {
  2476. 2474.  -     var aid = audio.id.replace('audio', '').split('_')[1];
  2477. 2475.  -     var before_id = (before && before.id || '').replace('audio', '').split('_')[1];
  2478. 2476.  -     var after_id = (after && after.id || '').replace('audio', '').split('_')[1];
  2479. 2477.  -     ajax.post(Audio.address, {act: 'reorder_audios', oid: cur.oid, aid: aid, before: before_id, after: after_id, hash: cur.hashes.reorder_hash}, {
  2480. 2478.  -       onDone: function(data) {
  2481. 2479.  -         var val;
  2482. 2480.  -         if (before_id && !after_id) {
  2483. 2481.  -           val = cur.audios[before_id]._order - 0.01;
  2484. 2482.  -         } else {
  2485. 2483.  -           val = cur.audios[after_id]._order + 0.01;
  2486. 2484.  -         }
  2487. 2485.  -         cur.audios[aid]._order = val;
  2488. 2486.  -         Audio.reorderPlaylist(cur.oid + '_' + aid, before_id ? cur.oid + '_' + before_id : '', after_id ? cur.oid + '_' + after_id : '');
  2489. 2487.  -       }
  2490. 2488.  -     });
  2491. 2489.  -   },
  2492. 2490.  -
  2493. 2491.  -   onDragStart: function(el) {
  2494. 2492.  -     // addClass(ge('page_body'), 'no_overflow');
  2495. 2493.  -     cur.dragStartTimer = setTimeout(function() {
  2496. 2494.  -       addClass(cur.audioAlbumsWrap, 'drag');
  2497. 2495.  -       hide('album_add');
  2498. 2496.  -       var ids = el.id.substr(5), id = parseInt(ids.split('_')[1]);
  2499. 2497.  -       var album_id = (cur.audios) ? cur.audios[id][8] : cur.album_id;
  2500. 2498.  -       each(geByClass('audio_filter', cur.audioAlbumsWrap), function(i,v) {
  2501. 2499.  -         if ('album'+album_id == v.id || (album_id == 0 && v.id == 'album_unsorted')) {
  2502. 2500.  -           return;
  2503. 2501.  -         }
  2504. 2502.  -         addClass(v, 'drag_on');
  2505. 2503.  -       });
  2506. 2504.  -       animate(el, {opacity: .8}, 200);
  2507. 2505.  -     }, 300);
  2508. 2506.  -   },
  2509. 2507.  -
  2510. 2508.  -   onDragEnd: function(el, target) {
  2511. 2509.  -     if (cur.dragStartTimer) clearTimeout(cur.dragStartTimer);
  2512. 2510.  -     // removeClass(ge('page_body'), 'no_overflow');
  2513. 2511.  -     each(geByClass('audio_filter', cur.audioAlbumsWrap), function(i,v) {
  2514. 2512.  -       removeClass(v, 'drag_on');
  2515. 2513.  -     });
  2516. 2514.  -     show('album_add');
  2517. 2515.  -     if (target) {
  2518. 2516.  -       var new_album, full_id = el.id.substr(5), aid = parseInt(full_id.split('_')[1]);
  2519. 2517.  -       var album_id = (cur.audios) ? cur.audios[aid][8] : cur.album_id;
  2520. 2518.  -       if (target.id != 'album_unsorted') {
  2521. 2519.  -         new_album = parseInt(target.id.substr(5));
  2522. 2520.  -       } else {
  2523. 2521.  -         new_album = 0;
  2524. 2522.  -       }
  2525. 2523.  -       if (new_album != album_id) {
  2526. 2524.  -         Audio.moveAudio(full_id, new_album);
  2527. 2525.  -       }
  2528. 2526.  -     }
  2529. 2527.  -     removeClass(cur.audioAlbumsWrap, 'drag');
  2530. 2528.  -     animate(el, {opacity: 1}, 200);
  2531. 2529.  -   },
  2532. 2530.  -
  2533. 2531.  -   onDragOver: function(el, target) {
  2534. 2532.  -     cur.targetId = target.id || '';
  2535. 2533.  -     var ids = el.id.substr(5), id = parseInt(ids.split('_')[1]);
  2536. 2534.  -     var album_id = (cur.audios) ? cur.audios[id][8] : cur.album_id;
  2537. 2535.  -     if ('album'+album_id == target.id || (album_id == 0 && target.id == 'album_unsorted')) {
  2538. 2536.  -       return;
  2539. 2537.  -     }
  2540. 2538.  -     if (cur.dragOutTimer) {
  2541. 2539.  -       clearTimeout(cur.dragOutTimer);
  2542. 2540.  -     }
  2543. 2541.  -     addClass(target, 'drag_over');
  2544. 2542.  -     setStyle(el, {opacity: .4});
  2545. 2543.  -   },
  2546. 2544.  -
  2547. 2545.  -   onDragOut: function(el, target) {
  2548. 2546.  -     removeClass(target, 'drag_over');
  2549. 2547.  -     if (target.id && cur.targetId != target.id) return;
  2550. 2548.  -     cur.dragOutTimer = setTimeout(function(){setStyle(el, {opacity: .8});}, 200);
  2551. 2549.  -   },
  2552. 2550.  -
  2553. 2551.  -   ignoreOwner: function (post_raw, owner_id, hash, btn) {
  2554. 2552.  -     triggerEvent(ge('delete_post' + post_raw), 'mouseout');
  2555. 2553.  -     cur.feedEntriesHTML = cur.feedEntriesHTML || {};
  2556. 2554.  -     if (post_raw) {
  2557. 2555.  -       cur.feedEntriesHTML[post_raw + '_ignored'] = val('post' + post_raw);
  2558. 2556.  -     }
  2559. 2557.  -     ajax.post(Audio.address, {act: 'a_ignore_owner', post_raw: post_raw, owner_id: owner_id, hash: hash}, {
  2560. 2558.  -       onDone:function(html) {
  2561. 2559.  -         val('post' + post_raw, html);
  2562. 2560.  -         each(geByClass('post', cur.aContent), function(i,v) {
  2563. 2561.  -           var ids = this.id.match(/post((-?\d+)_(-?\d+)(_\d+)?)/);
  2564. 2562.  -           if (ids[1] != post_raw && (!ids[4] && ids[2] == owner_id || ids[4] && ids[3] == owner_id)) {
  2565. 2563.  -             hide(this);
  2566. 2564.  -           }
  2567. 2565.  -         });
  2568. 2566.  -       }
  2569. 2567.  -     });
  2570. 2568.  -   },
  2571. 2569.  -
  2572. 2570.  -   unignoreOwner: function (post_raw, owner_id, hash) {
  2573. 2571.  -     ajax.post(Audio.address, {act: 'a_unignore_owner', post_raw: post_raw || '', owner_id: owner_id, hash: hash}, {
  2574. 2572.  -       onDone:function(html) {
  2575. 2573.  -         if (post_raw) {
  2576. 2574.  -           val('post' + post_raw, cur.feedEntriesHTML[post_raw + '_ignored']);
  2577. 2575.  -         } else {
  2578. 2576.  -           val('ignore_row' + owner_id, html);
  2579. 2577.  -         }
  2580. 2578.  -         each(geByClass('post', cur.aContent), function(i,v) {
  2581. 2579.  -           var ids = this.id.match(/post((-?\d+)_(-?\d+)(_\d+)?)/);
  2582. 2580.  -           if (!ids[4] && ids[2] == owner_id || ids[4] && ids[3] == owner_id) {
  2583. 2581.  -             show(this);
  2584. 2582.  -           }
  2585. 2583.  -         });
  2586. 2584.  -       }
  2587. 2585.  -     });
  2588. 2586.  -   },
  2589. 2587.  -
  2590. 2588.  -   editHidden: function () {
  2591. 2589.  -     showTabbedBox('al_settings.php', {act: 'a_edit_owners_list', list: 'audio', height: lastWindowHeight}, {stat: ['privacy.js', 'privacy.css', 'ui_controls.js', 'ui_controls.css', 'indexer.js']});
  2592. 2590.  -     cur.onOListSave = Audio.onHiddenSave;
  2593. 2591.  -     return false;
  2594. 2592.  -   },
  2595. 2593.  -
  2596. 2594.  -   onHiddenSave: function(white, black, list, options) {
  2597. 2595.  -     var box = curBox(), params = {act: 'a_ignore_olist', hash: options.hash};
  2598. 2596.  -     if (white.length < black.length) {
  2599. 2597.  -       params.White = white.join(',');
  2600. 2598.  -     } else {
  2601. 2599.  -       params.Black = black.join(',');
  2602. 2600.  -     }
  2603. 2601.  -     ajax.post(Audio.address, params, {
  2604. 2602.  -       onDone: function(control, rules) {
  2605. 2603.  -         box.hide();
  2606. 2604.  -         Audio.loadFeed('reload');
  2607. 2605.  -       },
  2608. 2606.  -       showProgress: box.showProgress,
  2609. 2607.  -       hiderogress: box.hideProgress
  2610. 2608.  -     });
  2611. 2609.  -     return false;
  2612. 2610.  -   },
  2613. 2611.  -
  2614. 2612.  -   loadGenre: function(genre_id, ev) {
  2615. 2613.  -     if (checkEvent(ev)) {
  2616. 2614.  -       return true;
  2617. 2615.  -     }
  2618. 2616.  -     Audio.loadPopular(true, genre_id);
  2619. 2617.  -     return cancelEvent(ev);
  2620. 2618.  -   },
  2621. 2619.  -
  2622. 2620.  -   loadPerformer: function(oid, ev) {
  2623. 2621.  -     if (checkEvent(ev)) {
  2624. 2622.  -       return true;
  2625. 2623.  -     }
  2626. 2624.  -     var index = 'owner'+oid;
  2627. 2625.  -     Audio.loadFriendsAudios(oid, index, undefined, undefined, true);
  2628. 2626.  -     return cancelEvent(ev);
  2629. 2627.  -   },
  2630. 2628.  -
  2631. 2629.  -   moreCatalog: function(obj) {
  2632. 2630.  -     if (hasClass(obj, 'audio_performer_shown')) {
  2633. 2631.  -       var height = getSize(ge('audio_more_performers'))[1];
  2634. 2632.  -       removeClass(obj, 'audio_performer_shown');
  2635. 2633.  -       hide('audio_more_performers');
  2636. 2634.  -       if (height > 300) {
  2637. 2635.  -         scrollToTop(0);
  2638. 2636.  -       }
  2639. 2637.  -     } else {
  2640. 2638.  -       if (ge('audio_more_performers')) {
  2641. 2639.  -         show('audio_more_performers')
  2642. 2640.  -         addClass(obj, 'audio_performer_shown');
  2643. 2641.  -         return false;
  2644. 2642.  -       }
  2645. 2643.  -       var exclude = [];
  2646. 2644.  -       var nodes = ge('audio_performers').childNodes;
  2647. 2645.  -       for (var i in nodes) {
  2648. 2646.  -         if (hasClass(nodes[i], 'audio_owner')) {
  2649. 2647.  -           exclude.push(intval(nodes[i].getAttribute('ref')));
  2650. 2648.  -         }
  2651. 2649.  -       }
  2652. 2650.  -       ajax.post('al_audio.php', {act: 'get_more_performers', offset: 4, exclude: exclude.join(','), genre: parseInt(cur.genre)}, {
  2653. 2651.  -         onDone: function(rows) {
  2654. 2652.  -           ge('audio_performers').appendChild(ce('div', {
  2655. 2653.  -             id: 'audio_more_performers',
  2656. 2654.  -             innerHTML: rows
  2657. 2655.  -           }));
  2658. 2656.  -           addClass(obj, 'audio_performer_shown');
  2659. 2657.  -         },
  2660. 2658.  -         showProgress: addClass.pbind(obj, 'audio_performer_loading'),
  2661. 2659.  -         hideProgress: removeClass.pbind(obj, 'audio_performer_loading')
  2662. 2660.  -       });
  2663. 2661.  -     }
  2664. 2662.  -   },
  2665. 2663.  -
  2666. 2664.  -   _eof: 1
  2667. 2665.  - }
  2668. 2666.  - try{stManager.done('audio.js');}catch(e){}
  2669. ------
  2670. Файл - friends.js (Старый размер - 62624 | Новый - 0):
  2671. 0.  - var Friends = {
  2672. 1.  -   init: function(obj, friendsTpl, commonTpl) {
  2673. 2.  -     extend(cur, {
  2674. 3.  -       fSearch: ge('s_search'),
  2675. 4.  -       module: 'friends',
  2676. 5.  -       fListEl: ge('friends_list'),
  2677. 6.  -       showMore: ge('show_more'),
  2678. 7.  -       pageEnd: ge('page_end'),
  2679. 8.  -       fContent: ge('list_content'),
  2680. 9.  -       friendsTpl: friendsTpl,
  2681. 10.  -       commonTpl: commonTpl,
  2682. 11.  -       savedMasks: {},
  2683. 12.  -       bigphCache: {},
  2684. 13.  -       bigphShown: {}
  2685. 14.  -     });
  2686. 15.  -     extend(cur, obj);
  2687. 16.  -
  2688. 17.  -     if (!cur.secData) {
  2689. 18.  -       cur.secData = {};
  2690. 19.  -     }
  2691. 20.  -
  2692. 21.  -     cur.curList = cur.section;
  2693. 22.  -
  2694. 23.  -     placeholderSetup(cur.fSearch, {back: true})
  2695. 24.  -     elfocus(cur.fSearch);
  2696. 25.  -
  2697. 26.  -     Friends.scrollNode = browser.msie6 ? pageNode : window;
  2698. 27.  -
  2699. 28.  -     addEvent(Friends.scrollNode, 'scroll', Friends.scrollResize);
  2700. 29.  -
  2701. 30.  -     setTimeout(function() {
  2702. 31.  -       cur.destroy.push(function() {
  2703. 32.  -         clearTimeout(cur.resizeTimeout);
  2704. 33.  -         removeEvent(Friends.scrollNode, 'scroll', Friends.scrollResize);
  2705. 34.  -       });
  2706. 35.  -     }, 0);
  2707. 36.  -
  2708. 37.  -     cur.friends = {};
  2709. 38.  -
  2710. 39.  -     if (!cur.silent) {
  2711. 40.  -       this.indexAll(function() {
  2712. 41.  -         if (cur.section.substr(0, 4) == 'list') {
  2713. 42.  -           cur.friendsList[cur.section] = Friends.filter(cur.friendsList['all'], cur.section);
  2714. 43.  -         }
  2715. 44.  -         if (!cur.friendsList[cur.section] || !cur.friendsList[cur.section].length) {
  2716. 45.  -           if (cur.section != 'requests' || !cur.suggCount) {
  2717. 46.  -             show('not_found');
  2718. 47.  -           }
  2719. 48.  -         }
  2720. 49.  -       });
  2721. 50.  -     }
  2722. 51.  -
  2723. 52.  -     cur.timeouts = {};
  2724. 53.  -
  2725. 54.  -     cur.nav.push((function(changed, old, n) {
  2726. 55.  -       if ('id' in changed || 'sort' in changed || isEmpty(changed)) {
  2727. 56.  -         return true;
  2728. 57.  -       }
  2729. 58.  -       if (n[0] == 'friends' || n[0] == 'al_friends.php' && (changed.section)) {
  2730. 59.  -         var s = changed.section;
  2731. 60.  -
  2732. 61.  -         if ((s == 'requests' || s == 'all_requests' || s == 'out_requests') && !cur.requestsCount && !cur.suggCount && !cur.allRequestsCount && !cur.outRequestsCount) {
  2733. 62.  -           return nav.change({section: 'all'});
  2734. 63.  -         } else if (s == 'requests' && !cur.requestsCount && !cur.suggCount) {
  2735. 64.  -           return nav.change({section: cur.allRequestsCount ? 'all_requests' : 'out_requests'});
  2736. 65.  -         } else if (s == 'all_requests' && !cur.allRequestsCount) {
  2737. 66.  -           return nav.change({section: cur.requestsCount || cur.suggCount ? 'requests' : 'out_requests'});
  2738. 67.  -         } else if (s == 'out_requests' && !cur.outRequestsCount) {
  2739. 68.  -           return nav.change({section: 'all'});
  2740. 69.  -         }
  2741. 70.  -
  2742. 71.  -         if (s == 'all' || s == 'online' || s == 'requests' || s == 'all_requests' || s == 'out_requests') {
  2743. 72.  -           __adsUpdate('force');
  2744. 73.  -         }
  2745. 74.  -         if (s == 'all_requests' && !('sort' in changed) && !cur.sortByDate) {
  2746. 75.  -           delete n.sort;
  2747. 76.  -           setTimeout(Friends.changeSummary, 0);
  2748. 77.  -         }
  2749. 78.  -         this.section(n.section, (function() {
  2750. 79.  -           this.changeSummary();
  2751. 80.  -           nav.setLoc(n);
  2752. 81.  -         }).bind(this));
  2753. 82.  -         return false;
  2754. 83.  -       } else if (n[0] == 'al_friends.php' || n[0] == 'friends') {
  2755. 84.  -         return false;
  2756. 85.  -       }
  2757. 86.  -     }).bind(this));
  2758. 87.  -
  2759. 88.  -     if (cur.silent) {
  2760. 89.  -       addClass(cur.showMore, 'load_more');
  2761. 90.  -       ajax.post('al_friends.php', {act: 'load_friends_silent', id: cur.oid, gid: cur.gid, sort: nav.objLoc.sort}, {
  2762. 91.  -         onDone: (function(data, universities, filters) {
  2763. 92.  -           removeClass(cur.showMore, 'load_more');
  2764. 93.  -           cur.silent = false;
  2765. 94.  -           var obj = eval('('+data+')');
  2766. 95.  -           // load friends json
  2767. 96.  -           if (!obj) {
  2768. 97.  -             return;
  2769. 98.  -           }
  2770. 99.  -           cur.universities = universities;
  2771. 100.  -           for (var i in obj) {
  2772. 101.  -             cur.friendsList[i] = obj[i];
  2773. 102.  -           }
  2774. 103.  -           this.indexAll(function() {
  2775. 104.  -             //Friends.selectTabAndSection(cur.section);
  2776. 105.  -             if (cur.section.substr(0, 4) == 'list') {
  2777. 106.  -               cur.friendsList[cur.section] = Friends.filter(cur.friendsList['all'], cur.section);
  2778. 107.  -             }
  2779. 108.  -             (cur.onSilentLoad || Friends.showMore)();
  2780. 109.  -           });
  2781. 110.  -           if (filters.cities) {
  2782. 111.  -             stManager.add(['ui_controls.js', 'ui_controls.css'], function() {
  2783. 112.  -               cur.cityFilter.setData(filters.cities);
  2784. 113.  -               if (cur.cityFilterOpened) {
  2785. 114.  -                 hide('friends_fltr_progress');
  2786. 115.  -                 cur.cityFilter.showDefaultList()
  2787. 116.  -               }
  2788. 117.  -             });
  2789. 118.  -           }
  2790. 119.  -         }).bind(this), local: 1
  2791. 120.  -       });
  2792. 121.  -     }
  2793. 122.  -
  2794. 123.  -   },
  2795. 124.  -   indexAll: function(callback) {
  2796. 125.  -     var all = cur.friendsList['all'];
  2797. 126.  -
  2798. 127.  -     cur.friendsIndex = new vkIndexer(all, function(obj) {
  2799. 128.  -       var mid = parseInt(obj[0]);
  2800. 129.  -       if (cur.friends && mid) {
  2801. 130.  -         cur.friends[mid] = obj;
  2802. 131.  -       }
  2803. 132.  -       return obj[5] || '';
  2804. 133.  -     }, function() {
  2805. 134.  -       if (!cur.silent) {
  2806. 135.  -         cur.friendsList['online'] = Friends.filter(all, 'online');
  2807. 136.  -         if (cur.section == 'common') {
  2808. 137.  -           cur.friendsList['common'] = Friends.filter(all, 'common');
  2809. 138.  -         }
  2810. 139.  -         if (callback) {
  2811. 140.  -           callback();
  2812. 141.  -         }
  2813. 142.  -       }
  2814. 143.  -       Friends.initBackFunc();
  2815. 144.  -     });
  2816. 145.  -
  2817. 146.  -     if (cur.section == 'phonebook') {
  2818. 147.  -       Friends.indexPhone();
  2819. 148.  -     }
  2820. 149.  -   },
  2821. 150.  -   indexPhone: function() {
  2822. 151.  -     cur.phoneIndex = new vkIndexer(cur.friendsList['phonebook'], function(obj) {
  2823. 152.  -       var mobile = obj[10][0] || '';
  2824. 153.  -       var home = obj[10][1] || '';
  2825. 154.  -       return [obj[5], mobile, mobile.replace(/[^0-9\+]/g, ''), home, home.replace(/[^0-9\+]/g, '')].join(' ');
  2826. 155.  -     });
  2827. 156.  -   },
  2828. 157.  -   initBackFunc: function() {
  2829. 158.  -     cur._back = {show: [function() {
  2830. 159.  -       addEvent(Friends.scrollNode, 'scroll', Friends.scrollResize);
  2831. 160.  -     }], hide: [function() {
  2832. 161.  -       if (Friends.searchTimout) {
  2833. 162.  -         clearTimeout(Friends.searchTimout);
  2834. 163.  -       }
  2835. 164.  -       if (cur.timeouts) {
  2836. 165.  -         for (var i in cur.timeouts) {
  2837. 166.  -           clearTimeout(cur.timeouts);
  2838. 167.  -         }
  2839. 168.  -       }
  2840. 169.  -       for (var i in cur.bigphShown) {
  2841. 170.  -         animate(cur.bigphShown[i], {marginTop: 100}, 0);
  2842. 171.  -       }
  2843. 172.  -       cur.bigphShown = {};
  2844. 173.  -       removeEvent(Friends.scrollNode, 'scroll', Friends.scrollResize);
  2845. 174.  -     }], text: cur.backLang};
  2846. 175.  -   },
  2847. 176.  -   switchTab: function(section, ev) {
  2848. 177.  -     var param = {'0':'friends', section: section};
  2849. 178.  -     return checkEvent(ev) || nav.change(param);
  2850. 179.  -   },
  2851. 180.  -   filter: function(arr, type) {
  2852. 181.  -     var len = (arr) ? arr.length : 0;
  2853. 182.  -     var res = [];
  2854. 183.  -     if (type.substr(0, 4) == 'list') {
  2855. 184.  -       var listNum = parseInt(type.substr(4));
  2856. 185.  -       type = 'list';
  2857. 186.  -     }
  2858. 187.  -     for (var i = 0; i < len; i++) {
  2859. 188.  -       var obj = arr[i];
  2860. 189.  -       if (cur.filterIds && !cur.filterIds[parseInt(obj[0])]) {
  2861. 190.  -         continue;
  2862. 191.  -       }
  2863. 192.  -       switch (type) {
  2864. 193.  -         case 'online':
  2865. 194.  -           if (intval(obj[4])) {
  2866. 195.  -             res.push(obj);
  2867. 196.  -           }
  2868. 197.  -           break;
  2869. 198.  -         case 'common':
  2870. 199.  -           if (cur.commonCount && obj[10]) {
  2871. 200.  -             res.push(obj);
  2872. 201.  -           }
  2873. 202.  -           break;
  2874. 203.  -         case 'list':
  2875. 204.  -           if (parseInt(obj[6]) & (1 << listNum)) {
  2876. 205.  -             res.push(obj);
  2877. 206.  -           }
  2878. 207.  -           break;
  2879. 208.  -         default:
  2880. 209.  -           res.push(obj);
  2881. 210.  -           break;
  2882. 211.  -       }
  2883. 212.  -     }
  2884. 213.  -     return res;
  2885. 214.  -   },
  2886. 215.  -   loadMore: function(start, end) {
  2887. 216.  -     var section = cur.section;
  2888. 217.  -     var list = cur.curList;
  2889. 218.  -     var curData = cur.secData[section];
  2890. 219.  -     if (curData.loading) {
  2891. 220.  -       return;
  2892. 221.  -     }
  2893. 222.  -     curData.loading = true;
  2894. 223.  -     addClass(cur.showMore, 'load_more');
  2895. 224.  -     show(cur.showMore);
  2896. 225.  -     ajax.post('/friends', extend({
  2897. 226.  -       act: 'get_section_friends',
  2898. 227.  -       section: section,
  2899. 228.  -       offset: start,
  2900. 229.  -       gid: cur.gid,
  2901. 230.  -       sort: nav.objLoc.sort,
  2902. 231.  -       sugg_rev: cur.suggRev
  2903. 232.  -     }, cur.filter), {
  2904. 233.  -       onDone: (function(data, preload) {
  2905. 234.  -         removeClass(cur.showMore, 'load_more');
  2906. 235.  -         var response = eval('('+data+')')
  2907. 236.  -         if (!cur.friendsList) {
  2908. 237.  -           return;
  2909. 238.  -         }
  2910. 239.  -         if (!cur.friendsList[list]) {
  2911. 240.  -           cur.friendsList[list] = [];
  2912. 241.  -         }
  2913. 242.  -         Array.prototype.push.apply(cur.friendsList[list], response[section]);
  2914. 243.  -         if (list == 'requests' && response['sugg_requests']) {
  2915. 244.  -           Array.prototype.push.apply(cur.friendsList['sugg_requests'], response['sugg_requests']);
  2916. 245.  -         }
  2917. 246.  -         this.showMore(false, start, end);
  2918. 247.  -         curData.loading = false;
  2919. 248.  -         curData.preload = preload;
  2920. 249.  -       }).bind(this)
  2921. 250.  -     });
  2922. 251.  -   },
  2923. 252.  -   canSugSwitch: function(list) {
  2924. 253.  -     if (!list) {
  2925. 254.  -       return cur.suggCount ? true : true;
  2926. 255.  -     }
  2927. 256.  -     if (cur.suggRev) {
  2928. 257.  -       return list.length >= cur.suggCount || !cur.secData.requests.preload;
  2929. 258.  -     } else {
  2930. 259.  -       return list.length >= cur.requestsCount || !cur.secData.requests.preload;
  2931. 260.  -     }
  2932. 261.  -   },
  2933. 262.  -   showMore: function(clear, start, end, plain) {
  2934. 263.  -     if (!cur.friendsList) {
  2935. 264.  -       return false;
  2936. 265.  -     }
  2937. 266.  -     var clist = cur.curList;
  2938. 267.  -     var list = cur.friendsList[clist];
  2939. 268.  -     if (start == undefined) {
  2940. 269.  -       start = cur.shownFriends;
  2941. 270.  -     }
  2942. 271.  -     if (end == undefined) {
  2943. 272.  -       end = cur.shownFriends + cur.friendsPerPage;
  2944. 273.  -     }
  2945. 274.  -     if (cur.section == 'requests') {
  2946. 275.  -       if (cur.suggRev) {
  2947. 276.  -         list = (cur.friendsList['sugg_requests'] || []).slice();
  2948. 277.  -         if (Friends.canSugSwitch(list)) {
  2949. 278.  -           var suggSwitch = parseInt(cur.suggCount);
  2950. 279.  -           list.push.apply(list, cur.friendsList[cur.curList] || []);
  2951. 280.  -         }
  2952. 281.  -       } else if (!cur.suggRev && cur.requestsCount < end && Friends.canSugSwitch(list)) {
  2953. 282.  -         list = (list || []).slice();
  2954. 283.  -         var suggSwitch = parseInt(cur.requestsCount);
  2955. 284.  -         list.push.apply(list, cur.friendsList['sugg_requests']);
  2956. 285.  -       }
  2957. 286.  -     }
  2958. 287.  -     if (!list || !list.length) {
  2959. 288.  -       if (cur.shownFriends == 0 && !cur.searchCount) {
  2960. 289.  -         if (cur.isLoading) {
  2961. 290.  -           return false; // Dont show empty msg while search
  2962. 291.  -         }
  2963. 292.  -         if (cur.searchStr) {
  2964. 293.  -           addClass(ge('not_found'), 'f_search');
  2965. 294.  -           ge('search_ph').innerHTML = cur.searchStr.replace(/([<>&#]*)/g, '');
  2966. 295.  -         } else {
  2967. 296.  -           removeClass(ge('not_found'), 'f_search');
  2968. 297.  -         }
  2969. 298.  -         var text = '';
  2970. 299.  -         if (cur.curList.substr(0, 4) == 'list') {
  2971. 300.  -           if (cur.filterIds) {
  2972. 301.  -             text = cur.summaryLang['list_not_found_filter'];
  2973. 302.  -             text = text.replace('{link}', '<a onclick="Friends.clearFilter(true);">').replace('{/link}', '</a>');
  2974. 303.  -           } else {
  2975. 304.  -             text = cur.summaryLang['list_not_found'];
  2976. 305.  -             text = text.replace('{link}', '<a onclick="Friends.editList(-1);">').replace('{/link}', '</a>');
  2977. 306.  -           }
  2978. 307.  -         } else if (cur.filter) {
  2979. 308.  -           text = cur.summaryLang['not_found_filter'];
  2980. 309.  -           text = text.replace('{link}', '<a onclick="Friends.clearFilter(true);">').replace('{/link}', '</a>');
  2981. 310.  -         } else {
  2982. 311.  -           text = cur.summaryLang['not_found'];
  2983. 312.  -         }
  2984. 313.  -         ge('not_found_text').innerHTML = text;
  2985. 314.  -         show('not_found');
  2986. 315.  -       }
  2987. 316.  -       if (clear) {
  2988. 317.  -         cur.fContent.innerHTML = '';
  2989. 318.  -       }
  2990. 319.  -       if (cur.searchCount) {
  2991. 320.  -         Friends.serverSearchMore();
  2992. 321.  -       }
  2993. 322.  -       hide('show_more');
  2994. 323.  -       return;
  2995. 324.  -     } else if (isVisible('not_found')) {
  2996. 325.  -       hide('not_found');
  2997. 326.  -     }
  2998. 327.  -
  2999. 328.  -     var friends = list.slice(start, end);
  3000. 329.  -     if (!friends.length) {
  3001. 330.  -       // can upload
  3002. 331.  -       var secData = cur.secData[cur.section];
  3003. 332.  -       if (secData && secData.preload) {
  3004. 333.  -         Friends.loadMore(start, end);
  3005. 334.  -       }
  3006. 335.  -       if (cur.searchCount) {
  3007. 336.  -         Friends.serverSearchMore();
  3008. 337.  -       }
  3009. 338.  -       if (cur.shownFriends >= cur.sectionCount) {
  3010. 339.  -         hide('show_more');
  3011. 340.  -       }
  3012. 341.  -       return;
  3013. 342.  -     }
  3014. 343.  -     var html = [];
  3015. 344.  -     var first = (cur.shownFriends == 0) ? ' user_block_first' : '';
  3016. 345.  -     if (clear) {
  3017. 346.  -       cur.fContent.innerHTML = '';
  3018. 347.  -     }
  3019. 348.  -     for (i in friends) {
  3020. 349.  -       var iSt = parseInt(i) + start;
  3021. 350.  -       if (suggSwitch && suggSwitch == iSt) {
  3022. 351.  -         if (cur.suggRev) {
  3023. 352.  -           var summaryText = langNumeric(cur.requestsCount, cur.summaryLang['requests']);
  3024. 353.  -           if (nav.objLoc.sort != 'date') {
  3025. 354.  -             summaryText += '<span class="divide">|</span><span><a href="/friends?section=' + cur.section + '&sort=date">' + cur.summaryLang['friends_sort_by_date'] + '</a></span>';
  3026. 355.  -           } else {
  3027. 356.  -             summaryText += '<span class="divide">|</span><span><a href="/friends?section=' + cur.section + '">' + cur.summaryLang['friends_sort_by_common'] + '</a></span>';
  3028. 357.  -           }
  3029. 358.  -         } else {
  3030. 359.  -           var summaryText = langNumeric(cur.suggCount, cur.summaryLang['friends_sugg_summary']);
  3031. 360.  -         }
  3032. 361.  -         html.push('<div id="friends_sub_summary" class="summary_wrap"><div class="summary">',summaryText,'</div></div>');
  3033. 362.  -         first = ' user_block_first';
  3034. 363.  -       }
  3035. 364.  -       if (cur.selection) {
  3036. 365.  -         var friend = friends[i].slice();
  3037. 366.  -         friend[5] = friend[5].replace(cur.selection.re, cur.selection.val);
  3038. 367.  -       } else {
  3039. 368.  -         var friend = friends[i];
  3040. 369.  -       }
  3041. 370.  -       if (cur.importCount && cur.importCount == cur.shownFriends && cur.section == 'suggestions') {
  3042. 371.  -         html.push('<div id="friends_sub_summary" class="summary_wrap"><div class="summary">',cur.summaryLang['suggestions'],'</div></div>');
  3043. 372.  -         first = ' user_block_first';
  3044. 373.  -       }
  3045. 374.  -       /*if (friend[0] && ge('user_block' + friend[0])) { // bad with search
  3046. 375.  -         debugLog('here');
  3047. 376.  -         continue;
  3048. 377.  -       }*/
  3049. 378.  -       ++cur.shownFriends;
  3050. 379.  -       if (!friend) {
  3051. 380.  -         continue;
  3052. 381.  -       }
  3053. 382.  -       var tplType = '';
  3054. 383.  -       if (cur.section == 'requests') {
  3055. 384.  -         if (suggSwitch <= iSt) {
  3056. 385.  -           tplType = (!cur.suggRev ? 'sugg_requests' : '');
  3057. 386.  -         } else {
  3058. 387.  -           tplType = (!cur.suggRev ? '' : 'sugg_requests');
  3059. 388.  -         }
  3060. 389.  -       }
  3061. 390.  -       Array.prototype.push.apply(html, Friends.drawFriend(friend, first, tplType));
  3062. 391.  -       first = '';
  3063. 392.  -     }
  3064. 393.  -     if (plain) {
  3065. 394.  -       return '<div>'+html.join('')+'</div>';
  3066. 395.  -     }
  3067. 396.  -     cur.fContent.appendChild(ce('div', {innerHTML: html.join('')}));
  3068. 397.  -     if (cur.shownFriends >= cur.sectionCount) {
  3069. 398.  -       hide('show_more');
  3070. 399.  -     } else {
  3071. 400.  -       show('show_more');
  3072. 401.  -     }
  3073. 402.  -   },
  3074. 403.  -
  3075. 404.  -   updateList: function(e, obj, force) {
  3076. 405.  -     if (!obj || e.keyCode == KEY.ESC) {
  3077. 406.  -       obj = cur.fSearch;
  3078. 407.  -       val(obj, '');
  3079. 408.  -       cur.searchStr = '';
  3080. 409.  -     }
  3081. 410.  -     if (cur.silent) {
  3082. 411.  -       cur.onSilentLoad = function() {
  3083. 412.  -         Friends.updateList(e, obj, true);
  3084. 413.  -       };
  3085. 414.  -       if (trim(obj.value)) {
  3086. 415.  -         hide(cur.showMore);
  3087. 416.  -         cur.fContent.innerHTML = '<div class="wide_loading"></div>';
  3088. 417.  -       }
  3089. 418.  -       return;
  3090. 419.  -     }
  3091. 420.  -     clearTimeout(this.searchTimout);
  3092. 421.  -     this.searchTimout = setTimeout((function() {
  3093. 422.  -       var str = trim(obj.value);
  3094. 423.  -       if (str && cur.searchStr == str) return;
  3095. 424.  -       cur.searchStr = str;
  3096. 425.  -       if (str) {
  3097. 426.  -         if (cur.section != 'all' && cur.section != 'phonebook') {
  3098. 427.  -           this.selectTab('all');
  3099. 428.  -           this.selectSection('all');
  3100. 429.  -           cur.curList = cur.section = 'all';
  3101. 430.  -
  3102. 431.  -           nav.setLoc(extend(nav.objLoc, {'section': 'all'}));
  3103. 432.  -         }
  3104. 433.  -         this.search(str, cur.section);
  3105. 434.  -         this.changeSummary();
  3106. 435.  -       } else if (cur.section != cur.curList || force) {
  3107. 436.  -         this.showSection();
  3108. 437.  -         this.changeSummary();
  3109. 438.  -         this.showMore();
  3110. 439.  -       } else {
  3111. 440.  -         this.hideLoading();
  3112. 441.  -         cur.searchCount = 0;
  3113. 442.  -         this.showMore();
  3114. 443.  -       }
  3115. 444.  -     }).bind(this), 10);
  3116. 445.  -   },
  3117. 446.  -   showSection: function(section) {
  3118. 447.  -     cur.shownFriends = 0;
  3119. 448.  -     cur.curList = cur.section = section || cur.section;
  3120. 449.  -     if (vk.id == cur.oid) {
  3121. 450.  -       if (cur.section == 'requests' || cur.section == 'all_requests' || cur.section == 'out_requests') {
  3122. 451.  -         hide('friends_search');
  3123. 452.  -         var tabsCount = ((cur.requestsCount || cur.suggCount) ? 1 : 0) + (cur.allRequestsCount ? 1 : 0) + (cur.outRequestsCount ? 1 : 0);
  3124. 453.  -         toggle('friends_req_tabs', tabsCount > 1);
  3125. 454.  -         toggle('friends_hide_all', (cur.section == 'requests') && (cur.requestsCount > 1 || cur.suggCount));
  3126. 455.  -         toggle(ge('sum_tab_requests').parentNode, cur.requestsCount > 0 || cur.suggCount > 0);
  3127. 456.  -         toggle(ge('sum_tab_all_requests').parentNode, cur.allRequestsCount > 0);
  3128. 457.  -         toggle(ge('sum_tab_out_requests').parentNode, cur.outRequestsCount > 0);
  3129. 458.  -         show('tab_requests');
  3130. 459.  -         addClass(ge('main_class'), 'wide');
  3131. 460.  -       } else {
  3132. 461.  -         show('friends_search');
  3133. 462.  -         hide('friends_req_tabs');
  3134. 463.  -         (cur.allFriendsCount ? removeClass : addClass)(ge('main_class'), 'wide');
  3135. 464.  -       }
  3136. 465.  -       toggle('tab_requests', nav.objLoc.act != 'invite' && (cur.requestsCount || cur.allRequestsCount || cur.outRequestsCount || cur.suggCount));
  3137. 466.  -     }
  3138. 467.  -     if (cur.filterIds) {
  3139. 468.  -       cur.curList += '_filter';
  3140. 469.  -     }
  3141. 470.  -     var list = cur.friendsList[cur.curList];
  3142. 471.  -     if (!list) {
  3143. 472.  -       if (section == 'recent' || section == 'phonebook' || section == 'requests') {
  3144. 473.  -         var friendsList = section;
  3145. 474.  -       } else {
  3146. 475.  -         var friendsList = 'all';
  3147. 476.  -       }
  3148. 477.  -       list = cur.friendsList[cur.curList] = this.filter(cur.friendsList[friendsList], cur.section);
  3149. 478.  -     }
  3150. 479.  -     cur.sectionCount = (list) ? list.length : 0;
  3151. 480.  -     cur.selection = false;
  3152. 481.  -     if (cur.filter && !cur.filterIds && section != 'suggestions') {
  3153. 482.  -       Friends.changeFilter();
  3154. 483.  -       if (!cur.searchStr) {
  3155. 484.  -         hide('friends_reset_search');
  3156. 485.  -         this.clearServerSearch();
  3157. 486.  -       }
  3158. 487.  -       return false;
  3159. 488.  -     }
  3160. 489.  -     this.showMore(true);
  3161. 490.  -     if (!cur.searchStr) {
  3162. 491.  -       hide('friends_reset_search');
  3163. 492.  -       this.clearServerSearch();
  3164. 493.  -     }
  3165. 494.  -   },
  3166. 495.  -
  3167. 496.  -   updateView: function() {
  3168. 497.  -     cur.fContent.innerHTML = this.showMore(false, 0, cur.shownFriends, true);
  3169. 498.  -   },
  3170. 499.  -
  3171. 500.  -   showLoading: function() {
  3172. 501.  -     cur.isLoading = 1;
  3173. 502.  -     show('friends_loading');
  3174. 503.  -     hide('friends_reset_search');
  3175. 504.  -   },
  3176. 505.  -
  3177. 506.  -   hideLoading: function() {
  3178. 507.  -     cur.isLoading = 0;
  3179. 508.  -     hide('friends_loading');
  3180. 509.  -     if (cur.searchStr) {
  3181. 510.  -       show('friends_reset_search');
  3182. 511.  -     }
  3183. 512.  -   },
  3184. 513.  -
  3185. 514.  -   serverSearchMore: function() {
  3186. 515.  -     if (cur.serverLoadingMore) {
  3187. 516.  -       return;
  3188. 517.  -     }
  3189. 518.  -     if (cur.searchFinished) {
  3190. 519.  -       return;
  3191. 520.  -     }
  3192. 521.  -     cur.serverLoadingMore = true;
  3193. 522.  -     ajax.post('friends', {
  3194. 523.  -       act: 'server_search',
  3195. 524.  -       q: cur.searchStr,
  3196. 525.  -       offset: cur.searchOffset
  3197. 526.  -     }, {
  3198. 527.  -       onDone: function(html, found, summary, newOffset) {
  3199. 528.  -         cur.searchFinished = !found;
  3200. 529.  -         if (cur.searchFinished) {
  3201. 530.  -           hide('friends_search_more');
  3202. 531.  -         }
  3203. 532.  -         cur.searchOffset = newOffset;
  3204. 533.  -         cur.serverLoadingMore = false;
  3205. 534.  -         ge('friends_search_cont').appendChild(ce('div', {innerHTML: html}));
  3206. 535.  -       },
  3207. 536.  -       showProgress: function() {
  3208. 537.  -         addClass(ge('friends_search_more'), 'load_more');
  3209. 538.  -       },
  3210. 539.  -       hideProgress: function() {
  3211. 540.  -         removeClass(ge('friends_search_more'), 'load_more');
  3212. 541.  -       }
  3213. 542.  -     });
  3214. 543.  -   },
  3215. 544.  -
  3216. 545.  -   serverSearch: function(str, count, exclude) {
  3217. 546.  -     cur.searchCount = 0;
  3218. 547.  -     Friends.showLoading();
  3219. 548.  -     cur.serverSearchStr = str;
  3220. 549.  -     clearTimeout(cur.serverSearchTimeout);
  3221. 550.  -     var excludeList = [];
  3222. 551.  -     for (var i in exclude) {
  3223. 552.  -       excludeList.push(exclude[i][0]);
  3224. 553.  -     }
  3225. 554.  -     cur.serverSearchTimeout = setTimeout((function() {
  3226. 555.  -       ajax.post('friends', {
  3227. 556.  -         act: 'server_search',
  3228. 557.  -         q: str,
  3229. 558.  -         exclude: excludeList.join(',')
  3230. 559.  -       }, {
  3231. 560.  -         onDone: function(html, found, summary, newOffset) {
  3232. 561.  -           cur.searchOffset = newOffset;
  3233. 562.  -           cur.searchFinished = !found;
  3234. 563.  -           Friends.hideLoading();
  3235. 564.  -           if (cur.searchStr != str) return;
  3236. 565.  -           var cont = ge('friends_search_cont');
  3237. 566.  -           cur.searchCount = found;
  3238. 567.  -           if (cur.shownFriends == 0) {
  3239. 568.  -             hide(cont);
  3240. 569.  -             cur.fContent.innerHTML = '';
  3241. 570.  -             Friends.showMore();
  3242. 571.  -           }
  3243. 572.  -           if (!found) {
  3244. 573.  -             Friends.changeSummary();
  3245. 574.  -             return;
  3246. 575.  -           }
  3247. 576.  -           if (cur.searchFinished) {
  3248. 577.  -             hide('friends_search_more');
  3249. 578.  -           } else {
  3250. 579.  -             show('friends_search_more');
  3251. 580.  -           }
  3252. 581.  -           cur.searchSummary = summary;
  3253. 582.  -           if (count) {
  3254. 583.  -             html = '<div class="summary_wrap"><div class="summary">'+summary+'</div></div>'+html;
  3255. 584.  -           }
  3256. 585.  -           cont.innerHTML = html;
  3257. 586.  -           show(cont);
  3258. 587.  -           Friends.changeSummary();
  3259. 588.  -           hide('not_found');
  3260. 589.  -         },
  3261. 590.  -         onFail: Friends.hideLoading
  3262. 591.  -       });
  3263. 592.  -     }).bind(this), 300);
  3264. 593.  -   },
  3265. 594.  -
  3266. 595.  -   clearServerSearch: function() {
  3267. 596.  -     hide('friends_search_cont');
  3268. 597.  -     hide('friends_search_more');
  3269. 598.  -     cur.searchCount = 0;
  3270. 599.  -   },
  3271. 600.  -
  3272. 601.  -   goToSearch: function(obj) {
  3273. 602.  -     nav.go('search?c%5Bname%5D=1&c%5Bq%5D='+encodeURIComponent(cur.searchStr)+'&c%5Bsection%5D=people');
  3274. 603.  -   },
  3275. 604.  -
  3276. 605.  -   search: function(str, type, callback, filter) {
  3277. 606.  -     cur.shownFriends = 0;
  3278. 607.  -     cur.section = type;
  3279. 608.  -     if (str) {
  3280. 609.  -       var index = (type == 'phonebook') ? cur.phoneIndex : cur.friendsIndex;
  3281. 610.  -       var checkTime = new Date().getTime();
  3282. 611.  -       if (str == -1) {
  3283. 612.  -         if (type == 'recent' || type == 'phonebook') {
  3284. 613.  -           var friendsList = type;
  3285. 614.  -         } else {
  3286. 615.  -           var friendsList = 'all';
  3287. 616.  -         }
  3288. 617.  -         var res = this.filter(cur.friendsList[friendsList], type);
  3289. 618.  -         str = '';
  3290. 619.  -         if (str != cur.searchStr) {
  3291. 620.  -           this.clearServerSearch();
  3292. 621.  -         }
  3293. 622.  -       } else {
  3294. 623.  -         var res = index.search(str);
  3295. 624.  -         if (cur.filterIds) {
  3296. 625.  -           res = this.filter(res, type);
  3297. 626.  -         }
  3298. 627.  -         var count = res.length;
  3299. 628.  -         if (count) {
  3300. 629.  -           if (str != cur.serverSearchStr && !cur.sectionCount) {
  3301. 630.  -             this.clearServerSearch();
  3302. 631.  -           }
  3303. 632.  -         }
  3304. 633.  -         if (count < 5 && cur.oid == vk.id) { // try to find some on the server side
  3305. 634.  -           this.serverSearch(str, count, res);
  3306. 635.  -         }
  3307. 636.  -       }
  3308. 637.  -       var newList = cur.section;
  3309. 638.  -       if (cur.filterIds) {
  3310. 639.  -         newList += '_filter';
  3311. 640.  -       }
  3312. 641.  -       if (str) {
  3313. 642.  -         newList += '_search_'+str;
  3314. 643.  -       }
  3315. 644.  -       if (cur.curList == newList && !filter) {
  3316. 645.  -         return; // now at this section
  3317. 646.  -       }
  3318. 647.  -       cur.curList = newList;
  3319. 648.  -       cur.friendsList[cur.curList] = res;
  3320. 649.  -
  3321. 650.  -       if (str) {
  3322. 651.  -         str += ' '+(parseLatin(str) || '');
  3323. 652.  -         str = trim(escapeRE(str.replace(/[,]/g, '')));
  3324. 653.  -         cur.selection = {
  3325. 654.  -           re: new RegExp('('+str.replace(index.delimiter, '|').replace(/(^\||\|$|\?)/g, '')+')', 'gi'),
  3326. 655.  -           val: '<em>$1</em>'
  3327. 656.  -         };
  3328. 657.  -       }
  3329. 658.  -       if (!cur.isLoading) {
  3330. 659.  -         show('friends_reset_search');
  3331. 660.  -       }
  3332. 661.  -     } else {
  3333. 662.  -       cur.curList = cur.section;
  3334. 663.  -       cur.selection = false;
  3335. 664.  -       hide('friends_reset_search');
  3336. 665.  -       if (cur.searchStr) {
  3337. 666.  -         this.clearServerSearch();
  3338. 667.  -       }
  3339. 668.  -     }
  3340. 669.  -
  3341. 670.  -     cur.sectionCount = cur.friendsList[cur.curList].length;
  3342. 671.  -     this.searchTimout = setTimeout((function() {
  3343. 672.  -       this.showMore(true);
  3344. 673.  -       if (callback) {
  3345. 674.  -         Friends.onSectionChange();
  3346. 675.  -         callback();
  3347. 676.  -       }
  3348. 677.  -     }).bind(this), 10);
  3349. 678.  -   },
  3350. 679.  -
  3351. 680.  -   changeSummary: function() {
  3352. 681.  -     var sum = ge('friends_summary');
  3353. 682.  -     var html = '';
  3354. 683.  -     if (cur.curList.indexOf('_search_') != -1 || cur.filterIds) {
  3355. 684.  -       if (!cur.sectionCount) {
  3356. 685.  -         if (cur.searchCount) {
  3357. 686.  -           html = cur.searchSummary;
  3358. 687.  -         } else {
  3359. 688.  -           if (cur.isLoading) {
  3360. 689.  -             return; // no update while loading
  3361. 690.  -           }
  3362. 691.  -           html = cur.summaryLang['search_no'];
  3363. 692.  -         }
  3364. 693.  -       } else {
  3365. 694.  -         html = langNumeric(cur.sectionCount, cur.summaryLang['search'], true);
  3366. 695.  -       }
  3367. 696.  -     } else if (cur.curList.slice(0, 4) == 'list') {
  3368. 697.  -       var langKey = (parseInt(cur.curList.slice(4)) < 25) ? 'list' : 'pub_list';
  3369. 698.  -       if (cur.sectionCount) {
  3370. 699.  -         html = langNumeric(cur.sectionCount, cur.summaryLang[langKey], true);
  3371. 700.  -       } else {
  3372. 701.  -         html = cur.summaryLang[langKey+'_no'];
  3373. 702.  -       }
  3374. 703.  -     } else if (cur.section == 'suggestions') {
  3375. 704.  -       if (!cur.importCount) {
  3376. 705.  -         html = cur.summaryLang['suggestions'];
  3377. 706.  -       } else {
  3378. 707.  -         html = cur.summaryLang['import'];
  3379. 708.  -       }
  3380. 709.  -     } else if (cur.section == 'recent') {
  3381. 710.  -       html = cur.summaryLang['recent'];
  3382. 711.  -     } else if (cur.section == 'requests' && cur.requestsCount > 0) {
  3383. 712.  -       if (cur.suggRev && cur.suggCount > 0) {
  3384. 713.  -         html = langNumeric(cur.suggCount, cur.summaryLang['friends_sugg_summary'], true);
  3385. 714.  -       } else {
  3386. 715.  -         html = langNumeric(cur.requestsCount, cur.summaryLang[cur.section], true);
  3387. 716.  -       }
  3388. 717.  -     } else if (cur.section == 'requests' && cur.suggCount > 0) {
  3389. 718.  -       html = langNumeric(cur.suggCount, cur.summaryLang['friends_sugg_summary'], true);
  3390. 719.  -     } else if (cur.section == 'all_requests' && cur.sectionCount > 0) {
  3391. 720.  -       html = langNumeric(cur.allRequestsCount, cur.summaryLang[cur.section], true);
  3392. 721.  -     } else if (cur.section == 'out_requests' && cur.sectionCount > 0) {
  3393. 722.  -       html = langNumeric(cur.outRequestsCount, cur.summaryLang[cur.section], true);
  3394. 723.  -     } else if (cur.sectionCount > 0) {
  3395. 724.  -       html = langNumeric(cur.sectionCount, cur.summaryLang[cur.section], true);
  3396. 725.  -     } else {
  3397. 726.  -       html = cur.summaryLang['all_no'];
  3398. 727.  -     }
  3399. 728.  -     if (cur.section.indexOf('list') == 0 && cur.oid == vk.id) {
  3400. 729.  -       listNum = parseInt(cur.curList.substr(4));
  3401. 730.  -       var list_edit_text = cur.summaryLang[(cur.sectionCount ? 'list_edit': 'list_start_edit')];
  3402. 731.  -       html += '<span class="divider">|</span><span><a onclick="Friends.editList('+listNum+');">'+list_edit_text+'</a></span>';
  3403. 732.  -       if (listNum < 25) {
  3404. 733.  -         html += '<span class="divider">|</span><span><a onclick="Friends.deleteList('+listNum+');">'+cur.summaryLang['list_delete']+'</a></span>';
  3405. 734.  -       }
  3406. 735.  -     }
  3407. 736.  -     if (vk.id != cur.oid) {
  3408. 737.  -       html += '<span class="divider">|</span><span>' + cur.summaryLang['to_users_page'] + '</span>';
  3409. 738.  -     }
  3410. 739.  -     if ((cur.section == 'requests' && cur.requestsCount > 50) || cur.section == 'all_requests') {
  3411. 740.  -       if (!cur.suggRev || !cur.suggCount) {
  3412. 741.  -         if (nav.objLoc.sort != 'date') {
  3413. 742.  -           html += '<span class="divide">|</span><span><a href="/friends?section=' + cur.section + '&sort=date">' + cur.summaryLang['friends_sort_by_date'] + '</a></span>';
  3414. 743.  -         } else {
  3415. 744.  -           html += '<span class="divide">|</span><span><a href="/friends?section=' + cur.section + '">' + cur.summaryLang['friends_sort_by_common'] + '</a></span>';
  3416. 745.  -         }
  3417. 746.  -       }
  3418. 747.  -
  3419. 748.  -     }
  3420. 749.  -     sum.innerHTML = html;
  3421. 750.  -
  3422. 751.  -     document.title = replaceEntities(stripHTML(cur.htitles[cur.section] || cur.htitles.all));
  3423. 752.  -   },
  3424. 753.  -   selectTab: function(tab) {
  3425. 754.  -     var section = geByClass1('active_link', ge('friends_tabs'));
  3426. 755.  -     removeClass(section, 'active_link');
  3427. 756.  -     addClass(ge('tab_' + tab), 'active_link');
  3428. 757.  -     if (cur.oid != vk.id) {
  3429. 758.  -       toggleClass(ge('main_class'), 'wide', tab != 'all' || !cur.allFriendsCount);
  3430. 759.  -     }
  3431. 760.  -   },
  3432. 761.  -   selectSection: function(tab) {
  3433. 762.  -     var section = geByClass1('cur_section', ge('sections_block'));
  3434. 763.  -     removeClass(section, 'cur_section');
  3435. 764.  -     addClass(ge('section_' + tab), 'cur_section');
  3436. 765.  -   },
  3437. 766.  -   selectSumTab: function(tab) {
  3438. 767.  -     var section = geByClass1('summary_tab_sel', ge('friends_req_tabs'));
  3439. 768.  -     removeClass(section, 'summary_tab_sel');
  3440. 769.  -     addClass(section, 'summary_tab');
  3441. 770.  -     var el = ge('sum_tab_' + tab).parentNode;
  3442. 771.  -     removeClass(el, 'summary_tab');
  3443. 772.  -     addClass(el, 'summary_tab_sel');
  3444. 773.  -   },
  3445. 774.  -   selectTabAndSection: function(type) {
  3446. 775.  -     if (type == 'all' || type == 'online' || type == 'common' || type == 'members') {
  3447. 776.  -       this.selectTab(type);
  3448. 777.  -       this.selectSection('all');
  3449. 778.  -     } else if (type == 'all_requests' || type == 'requests' || type == 'out_requests') {
  3450. 779.  -       this.selectTab('requests');
  3451. 780.  -       this.selectSumTab(type);
  3452. 781.  -     } else {
  3453. 782.  -       this.selectTab('all');
  3454. 783.  -       this.selectSection(type);
  3455. 784.  -     }
  3456. 785.  -   },
  3457. 786.  -   onSectionChange: function() {
  3458. 787.  -     if (window.tooltips) {
  3459. 788.  -       tooltips.hideAll();
  3460. 789.  -     }
  3461. 790.  -   },
  3462. 791.  -   section: function(type, callback, updateData) {
  3463. 792.  -     Friends.clearServerSearch();
  3464. 793.  -     if (!type) {
  3465. 794.  -       type = 'all';
  3466. 795.  -     }
  3467. 796.  -     //if (!updateData && (type != 'all' || cur.section != type) && type.substr(0, 4) != 'list') {
  3468. 797.  -     if (!updateData && ((type == 'online' && cur.oid != vk.id) || type.indexOf('requests') != -1) && type.substr(0, 4) != 'list') {
  3469. 798.  -       Friends.clearFilter();
  3470. 799.  -     }
  3471. 800.  -     if (!type) {
  3472. 801.  -       if ((cur.requestsCount && cur.requestsCount > 0 && cur.requestsCount < 100) || cur.suggCount) {
  3473. 802.  -         type = 'requests';
  3474. 803.  -       } else {
  3475. 804.  -         type = 'all';
  3476. 805.  -       }
  3477. 806.  -     }
  3478. 807.  -     if (!cur.requestsCount && !cur.suggCount && !cur.allRequestsCount && !cur.outRequestsCount) {
  3479. 808.  -       hide('tab_requests');
  3480. 809.  -     }
  3481. 810.  -     if (type != cur.section) {
  3482. 811.  -       cur.fSearch.setValue('');
  3483. 812.  -       cur.searchStr = '';
  3484. 813.  -     }
  3485. 814.  -     // Select section filter
  3486. 815.  -     this.selectTabAndSection(type);
  3487. 816.  -
  3488. 817.  -     if (cur.silent && type != 'suggestions' && type != 'out_requests') {
  3489. 818.  -       cur.onSilentLoad = function() {
  3490. 819.  -         Friends.section(type, callback);
  3491. 820.  -       };
  3492. 821.  -       if (type != cur.section) {
  3493. 822.  -         hide(cur.showMore);
  3494. 823.  -         cur.fContent.innerHTML = '<div class="wide_loading"></div>';
  3495. 824.  -       }
  3496. 825.  -       return;
  3497. 826.  -     }
  3498. 827.  -
  3499. 828.  -
  3500. 829.  -     if (!cur.secData[type]) {
  3501. 830.  -       cur.secData[type] = {};
  3502. 831.  -     }
  3503. 832.  -     // from cache
  3504. 833.  -     if (!updateData && cur.friendsList[type] || type == 'all' || (type == 'requests' && cur.friendsList['sugg_requests'])) {
  3505. 834.  -       if (!cur.filter || type != 'suggestions') {
  3506. 835.  -         this.showSection(type);
  3507. 836.  -         callback();
  3508. 837.  -         Friends.onSectionChange();
  3509. 838.  -         return;
  3510. 839.  -       }
  3511. 840.  -     }
  3512. 841.  -     // generate
  3513. 842.  -     switch (type) {
  3514. 843.  -       case 'online':
  3515. 844.  -       case 'common':
  3516. 845.  -         this.search(-1, type, callback);
  3517. 846.  -         break;
  3518. 847.  -       case 'phonebook':
  3519. 848.  -         this.loadingState('phonebook');
  3520. 849.  -         ajax.post('/al_friends.php', {act: 'phonebook', id: nav.objLoc.id}, {onDone: (function(data) {
  3521. 850.  -           if (!data) {
  3522. 851.  -             return;
  3523. 852.  -           }
  3524. 853.  -           cur.shownFriends = 0;
  3525. 854.  -           cur.curList = cur.section = type;
  3526. 855.  -           var list = cur.friendsList['all'];
  3527. 856.  -           var phoneList = [];
  3528. 857.  -           if (list) {
  3529. 858.  -             for (var i = 0, len = list.length; i < len; i++) {
  3530. 859.  -               var friend = list[i];
  3531. 860.  -               var phone = data[friend[0]];
  3532. 861.  -               if (phone) {
  3533. 862.  -                 friend.push(phone);
  3534. 863.  -                 phoneList.push(friend);
  3535. 864.  -               }
  3536. 865.  -             }
  3537. 866.  -           }
  3538. 867.  -           cur.friendsList[cur.section] = phoneList;
  3539. 868.  -           cur.sectionCount = phoneList.length;
  3540. 869.  -           cur.fContent.innerHTML = '';
  3541. 870.  -           this.loadingState('phonebook', true);
  3542. 871.  -           Friends.onSectionChange();
  3543. 872.  -           callback();
  3544. 873.  -           Friends.indexPhone();
  3545. 874.  -           if (cur.filterIds) {
  3546. 875.  -             cur.curList += '_filter';
  3547. 876.  -             Friends.search(cur.searchStr || -1, cur.section, false, true);
  3548. 877.  -             Friends.changeSummary();
  3549. 878.  -             return;
  3550. 879.  -           }
  3551. 880.  -           this.showMore();
  3552. 881.  -         }).bind(this)});
  3553. 882.  -         break;
  3554. 883.  -       case 'recent':
  3555. 884.  -         this.loadingState('recent');
  3556. 885.  -         ajax.post('/al_friends.php', {act: 'recent'}, {onDone: (function(data) {
  3557. 886.  -           if (!data) {
  3558. 887.  -             return;
  3559. 888.  -           }
  3560. 889.  -           cur.shownFriends = 0;
  3561. 890.  -           cur.curList = cur.section = type;
  3562. 891.  -           var list = [];
  3563. 892.  -           len = data.length;
  3564. 893.  -           for (var i = 0; i < len; i++) {
  3565. 894.  -             var f = cur.friends[data[i]];
  3566. 895.  -             if (f) {
  3567. 896.  -               list.push(f);
  3568. 897.  -             }
  3569. 898.  -           }
  3570. 899.  -           cur.friendsList[cur.section] = list;
  3571. 900.  -           cur.sectionCount = list.length;
  3572. 901.  -           cur.fContent.innerHTML = '';
  3573. 902.  -           this.loadingState('recent', true);
  3574. 903.  -           Friends.onSectionChange();
  3575. 904.  -           callback();
  3576. 905.  -           if (cur.filterIds) {
  3577. 906.  -             cur.curList += '_filter';
  3578. 907.  -             Friends.search(cur.searchStr || -1, cur.section, false, true);
  3579. 908.  -             Friends.changeSummary();
  3580. 909.  -             return;
  3581. 910.  -           }
  3582. 911.  -           this.showMore();
  3583. 912.  -         }).bind(this)});
  3584. 913.  -         break;
  3585. 914.  -       case 'suggestions':
  3586. 915.  -         this.loadingState('suggestions');
  3587. 916.  -         ajax.post('/friends', extend({
  3588. 917.  -           act: 'get_section_friends',
  3589. 918.  -           section: 'suggestions'
  3590. 919.  -         }, cur.filter || {}), {
  3591. 920.  -           onDone: (function(list, preload, data) {
  3592. 921.  -             var list = eval('('+list+')');
  3593. 922.  -             extend(cur, data || {});
  3594. 923.  -             var keyType = type + (cur.filterIds ? '_filter' : '');
  3595. 924.  -             cur.friendsList[keyType] = list[type];
  3596. 925.  -             this.loadingState(type, true);
  3597. 926.  -             this.showSection(type);
  3598. 927.  -             cur.secData[type].preload = preload;
  3599. 928.  -             Friends.onSectionChange();
  3600. 929.  -             callback();
  3601. 930.  -           }).bind(this)
  3602. 931.  -         });
  3603. 932.  -         break;
  3604. 933.  -       case 'out_requests':
  3605. 934.  -         hide(cur.showMore, 'friends_hide_all');
  3606. 935.  -         cur.fContent.innerHTML = '<div class="wide_loading"></div>';
  3607. 936.  -         ajax.post('/friends', {act: 'out_requests'}, {onDone: (function(data, universities) {
  3608. 937.  -           var obj = eval('('+data+')');
  3609. 938.  -
  3610. 939.  -           // load friends json
  3611. 940.  -           if (!obj) {
  3612. 941.  -             return;
  3613. 942.  -           }
  3614. 943.  -           extend(cur.universities, universities);
  3615. 944.  -           extend(cur.friendsList, obj);
  3616. 945.  -
  3617. 946.  -           this.indexAll(function() {
  3618. 947.  -             Friends.section(type, callback);
  3619. 948.  -           });
  3620. 949.  -         }).bind(this)});
  3621. 950.  -         break;
  3622. 951.  -       default:
  3623. 952.  -         if (type.substr(0, 4) == 'list') {
  3624. 953.  -           this.search(-1, type, callback);
  3625. 954.  -         }
  3626. 955.  -
  3627. 956.  -     }
  3628. 957.  -   },
  3629. 958.  -   loadingState: function(section, state) {
  3630. 959.  -     if (state) {
  3631. 960.  -       if (cur.oldSection) {
  3632. 961.  -         removeClass(cur.oldSection, 'loading');
  3633. 962.  -       }
  3634. 963.  -     } else {
  3635. 964.  -       cur.oldSection = ge('section_' + section);
  3636. 965.  -       addClass(cur.oldSection, 'loading');
  3637. 966.  -     }
  3638. 967.  -   },
  3639. 968.  -   scrollResize: function() {
  3640. 969.  -     if (browser.mobile) return;
  3641. 970.  -     var docEl = document.documentElement;
  3642. 971.  -     var ch = window.innerHeight || docEl.clientHeight || bodyNode.clientHeight;
  3643. 972.  -     var st = scrollGetY();
  3644. 973.  -     if (!cur.pageEnd) {
  3645. 974.  -       return;
  3646. 975.  -     }
  3647. 976.  -     if (st + ch * 3 > cur.pageEnd.offsetTop) {
  3648. 977.  -       setTimeout(function() {
  3649. 978.  -         Friends.showMore();
  3650. 979.  -       }, 0);
  3651. 980.  -     }
  3652. 981.  -   },
  3653. 982.  -   drawFriend: function(friend, first, type) {
  3654. 983.  -     if (cur.section == 'requests' || cur.section == 'all_requests' || cur.section == 'out_requests' || cur.section == 'suggestions') {
  3655. 984.  -       return cur.commonTpl(friend, type || cur.section, first);
  3656. 985.  -     } else {
  3657. 986.  -       return cur.friendsTpl(friend, cur.section, first);
  3658. 987.  -     }
  3659. 988.  -   },
  3660. 989.  -
  3661. 990.  -   inviteToGroup: function(ev, gid, mid, invited, hash) {
  3662. 991.  -     var setInvited = function(invited) {
  3663. 992.  -       for(var i in cur.friendsList[cur.curList]) {
  3664. 993.  -         var row = cur.friendsList[cur.curList][i];
  3665. 994.  -         if (row[0] == mid) {
  3666. 995.  -           row[10] = invited;
  3667. 996.  -           //Friends.updateView();
  3668. 997.  -           var block = ge('user_block'+mid), link = '';
  3669. 998.  -           if (invited) {
  3670. 999.  -             link = '<a href="" onclick="return Friends.inviteToGroup(event, '+gid+', '+mid+', 1, \''+row[11]+'\')">'+getLang('friends_cancel_invite')+'</a>';
  3671. 1000.  -           } else {
  3672. 1001.  -             link = '<a href="" onclick="return Friends.inviteToGroup(event, '+gid+', '+mid+', 0, \''+row[11]+'\')">'+getLang('friends_send_invite')+'</a>';
  3673. 1002.  -           }
  3674. 1003.  -           geByClass('actions', block)[0].innerHTML = link;
  3675. 1004.  -           break;
  3676. 1005.  -         }
  3677. 1006.  -       }
  3678. 1007.  -     }
  3679. 1008.  -     if (invited) {
  3680. 1009.  -       ajax.post('/al_page.php', {act:'a_cancel_invite', mid:mid, gid:gid, hash:hash}, {onDone:function(res){ }});
  3681. 1010.  -       setInvited(0);
  3682. 1011.  -     } else {
  3683. 1012.  -       ajax.post('/al_page.php', {act:'a_invite', mid:mid, gid:gid, hash:hash}, {onDone:function(res, message) {
  3684. 1013.  -         if (!res) {
  3685. 1014.  -           setInvited(0);
  3686. 1015.  -           ge('res'+mid).innerHTML = '<div class="res">'+message+'</div>';
  3687. 1016.  -           hide('lists'+mid);
  3688. 1017.  -           var block = ge('user_block'+mid);
  3689. 1018.  -           hide(geByClass('actions', block)[0]);
  3690. 1019.  -         }
  3691. 1020.  -       }});
  3692. 1021.  -       setInvited(1);
  3693. 1022.  -     }
  3694. 1023.  -     return false;
  3695. 1024.  -   },
  3696. 1025.  -
  3697. 1026.  -   acceptRequest: function(mid, hash, el) {
  3698. 1027.  -     var controls = ge('request_controls_'+mid);
  3699. 1028.  -     var controlsCont = controls.parentNode;
  3700. 1029.  -     if (!el) {
  3701. 1030.  -       controls.innerHTML = '<div align="center"><img src="/images/upload.gif"></div>';
  3702. 1031.  -     }
  3703. 1032.  -     ajax.post('al_friends.php', {act: 'add', mid: mid, hash: hash, request: 1, 'select_list': 1}, {onDone: function(text) {
  3704. 1033.  -       controls.innerHTML = text;
  3705. 1034.  -       delete cur.friendsList['recent'];
  3706. 1035.  -     }, onFail: function(text) {
  3707. 1036.  -       if (!text) return;
  3708. 1037.  -
  3709. 1038.  -       showFastBox(getLang('global_error'), text);
  3710. 1039.  -       return true;
  3711. 1040.  -     }, showProgress: lockButton.pbind(el), hideProgress: unlockButton.pbind(el)});
  3712. 1041.  -     Friends.processRequest(mid, true);
  3713. 1042.  -     delete cur.friendsList['online'];
  3714. 1043.  -     Friends.indexAll();
  3715. 1044.  -   },
  3716. 1045.  -
  3717. 1046.  -   declineRequest: function(mid, hash, el) {
  3718. 1047.  -     var controls = ge('request_controls_'+mid);
  3719. 1048.  -     var controlsCont = controls.parentNode;
  3720. 1049.  -     if (!el) {
  3721. 1050.  -       controls.innerHTML = '<div align="center"><img src="/images/upload.gif"></div>';
  3722. 1051.  -     }
  3723. 1052.  -     ajax.post('al_friends.php', {act: 'remove', mid: mid, hash: hash, report_spam: 1, from_section: cur.section}, {onDone: function(text) {
  3724. 1053.  -       controls.innerHTML = text;
  3725. 1054.  -     }, onFail: function(text) {
  3726. 1055.  -       if (!text) return;
  3727. 1056.  -
  3728. 1057.  -       showFastBox(getLang('global_error'), text);
  3729. 1058.  -       return true;
  3730. 1059.  -     }, showProgress: lockButton.pbind(el), hideProgress: unlockButton.pbind(el)});
  3731. 1060.  -
  3732. 1061.  -     Friends.processRequest(mid, false);
  3733. 1062.  -   },
  3734. 1063.  -
  3735. 1064.  -   processRequest: function(mid, add, sugg) {
  3736. 1065.  -     var reqs = cur.friendsList[sugg ? 'sugg_requests' : 'requests'] || [];
  3737. 1066.  -     var len = reqs.length, found = false;
  3738. 1067.  -     while (len--) {
  3739. 1068.  -       if (reqs[len][0] == mid) {
  3740. 1069.  -         var friend = reqs.splice(len, 1)[0];
  3741. 1070.  -         if (sugg) {
  3742. 1071.  -           --cur.suggCount;
  3743. 1072.  -         } else {
  3744. 1073.  -           --cur.requestsCount;
  3745. 1074.  -         }
  3746. 1075.  -         val(geByClass1('tab_word', ge('tab_requests')), cur.summaryLang['requests_title'] + (cur.requestsCount ? ('<span class="count">+' + cur.requestsCount + '</span>') : ''));
  3747. 1076.  -         toggleClass(ge('tab_requests'), 'count', !!cur.requestsCount);
  3748. 1077.  -         if (add) {
  3749. 1078.  -           found = true;
  3750. 1079.  -           friend.pop();
  3751. 1080.  -           if (cur.friendsList['all']) {
  3752. 1081.  -             cur.friendsList['all'].push(friend);
  3753. 1082.  -           } else {
  3754. 1083.  -             cur.friendsList['all'] = [friend];
  3755. 1084.  -           }
  3756. 1085.  -           cur.friends[friend[0]] = friend;
  3757. 1086.  -         }
  3758. 1087.  -       }
  3759. 1088.  -     }
  3760. 1089.  -     if (add) {
  3761. 1090.  -       var reqs = cur.friendsList['all_requests'] || [];
  3762. 1091.  -       var len = reqs.length;
  3763. 1092.  -       while (len--) {
  3764. 1093.  -         if (reqs[len][0] == mid) {
  3765. 1094.  -           var friend = reqs.splice(len, 1)[0];
  3766. 1095.  -           --cur.allRequestsCount;
  3767. 1096.  -           if (!found) {
  3768. 1097.  -             friend.pop();
  3769. 1098.  -             if (cur.friendsList['all']) {
  3770. 1099.  -               cur.friendsList['all'].push(friend);
  3771. 1100.  -             } else {
  3772. 1101.  -               cur.friendsList['all'] = [friend];
  3773. 1102.  -             }
  3774. 1103.  -             cur.friends[friend[0]] = friend;
  3775. 1104.  -           }
  3776. 1105.  -         }
  3777. 1106.  -       }
  3778. 1107.  -     } else {
  3779. 1108.  -       var reqs = cur.friendsList['out_requests'] || [];
  3780. 1109.  -       var len = reqs.length;
  3781. 1110.  -       while (len--) {
  3782. 1111.  -         if (reqs[len][0] == mid) {
  3783. 1112.  -           var friend = reqs.splice(len, 1)[0];
  3784. 1113.  -           --cur.outRequestsCount;
  3785. 1114.  -         }
  3786. 1115.  -       }
  3787. 1116.  -     }
  3788. 1117.  -   },
  3789. 1118.  -
  3790. 1119.  -   reportSpam: function(mid, hash) {
  3791. 1120.  -     var controls = ge('request_controls_' + mid);
  3792. 1121.  -     if (!controls) {
  3793. 1122.  -       controls = ge('result_msg');
  3794. 1123.  -       removeClass(controls, 'msg');
  3795. 1124.  -     }
  3796. 1125.  -     controls.innerHTML = '<div align="center"><img src="/images/upload.gif"></div>';
  3797. 1126.  -     ajax.post('al_friends.php', {act: 'report_spam', mid: mid, hash: hash}, {onDone: function(text) {
  3798. 1127.  -       controls.innerHTML = text;
  3799. 1128.  -     }});
  3800. 1129.  -   },
  3801. 1130.  -
  3802. 1131.  -   restoreFriend: function(el, id) {
  3803. 1132.  -     var back = el.innerHTML;
  3804. 1133.  -     ajax.post('al_friends.php', {act: 'add', mid: id, hash: cur.userHash, cats: cur.savedMasks[id]}, {
  3805. 1134.  -       onDone: Friends.onRemoveFriend.pbind(id, true),
  3806. 1135.  -       showProgress: function() {
  3807. 1136.  -         el.innerHTML = '<center><img src="/images/upload.gif" /></center>';
  3808. 1137.  -       },
  3809. 1138.  -       hideProgress: function() {
  3810. 1139.  -         el.innerHTML = back;
  3811. 1140.  -       }
  3812. 1141.  -     });
  3813. 1142.  -   },
  3814. 1143.  -
  3815. 1144.  -   deleteFriend: function(e, id, el) {
  3816. 1145.  -     var back = el.innerHTML;
  3817. 1146.  -     ajax.post('al_friends.php', {act: 'remove', mid: id, hash: cur.userHash}, {
  3818. 1147.  -       onDone: Friends.onRemoveFriend.pbind(id, false),
  3819. 1148.  -       showProgress: function() {
  3820. 1149.  -         el.innerHTML = '<center><img src="/images/upload.gif" /></center>';
  3821. 1150.  -       },
  3822. 1151.  -       hideProgress: function() {
  3823. 1152.  -         el.innerHTML = back;
  3824. 1153.  -       }
  3825. 1154.  -     });
  3826. 1155.  -     return false;
  3827. 1156.  -   },
  3828. 1157.  -
  3829. 1158.  -   onRemoveFriend: function(mid, res) {
  3830. 1159.  -     var needUpdateView = (cur.friendsList[cur.curList] || []).length < 10;
  3831. 1160.  -
  3832. 1161.  -     for (var i in cur.friendsList) {
  3833. 1162.  -       if (i != 'all' && i != 'requests' && i != 'all_requests' && i != 'out_requests' && i != 'suggestions') {
  3834. 1163.  -         delete cur.friendsList[i];
  3835. 1164.  -       }
  3836. 1165.  -     }
  3837. 1166.  -     var list = cur.friendsList['all'];
  3838. 1167.  -     var len = list.length;
  3839. 1168.  -     mid = positive(mid);
  3840. 1169.  -
  3841. 1170.  -     var block = ge('user_block' + mid);
  3842. 1171.  -     var fr = cur.friends[mid];
  3843. 1172.  -     if (fr && block) {
  3844. 1173.  -       if (res) {
  3845. 1174.  -         fr[6] = cur.savedMasks[mid];
  3846. 1175.  -         delete(cur.savedMasks[mid]);
  3847. 1176.  -       } else {
  3848. 1177.  -         cur.savedMasks[mid] = fr[6];
  3849. 1178.  -         fr[6] = 0; // zero mask - removed friend
  3850. 1179.  -       }
  3851. 1180.  -       block.parentNode.replaceChild(ce('div', {innerHTML: cur.friendsTpl(fr, cur.section, hasClass(block, 'user_block_first') ? ' user_block_first' : '').join('')}).firstChild, block);
  3852. 1181.  -     } else {
  3853. 1182.  -       re(block);
  3854. 1183.  -     }
  3855. 1184.  -
  3856. 1185.  -     Friends.indexAll(function() {
  3857. 1186.  -     });
  3858. 1187.  -   },
  3859. 1188.  -   showCommonBox: function(e, id, hash) {
  3860. 1189.  -     if (checkEvent(e)) return true;
  3861. 1190.  -     showBox('al_friends.php', {act: 'common_friends', mid: id, hash: hash}, {params: {bodyStyle: "padding: 0px;"}});
  3862. 1191.  -     return false;
  3863. 1192.  -   },
  3864. 1193.  -   toList: function(num) {
  3865. 1194.  -     nav.change({'0':'al_friends.php', section:'list' + num});
  3866. 1195.  -     scrollToTop(0);
  3867. 1196.  -     return false;
  3868. 1197.  -   },
  3869. 1198.  -
  3870. 1199.  -   /*ddShowSearchActs: function(obj, ev, uid) {
  3871. 1200.  -     var elems = [];
  3872. 1201.  -     elems.push('<a class="friends_dd_item" onclick="Friends.ddHide(ge(\'friends_dd_menu_'+uid+'\'), '+uid+');return showWriteMessageBox(event, '+uid+')">'+cur.summaryLang['global_write_msg']+'</a>');
  3873. 1202.  -     Friends.ddShowCustom(obj, ev, elems, uid);
  3874. 1203.  -   },*/
  3875. 1204.  -
  3876. 1205.  -   ttActToggle: function(obj, uid, hash, add) {
  3877. 1206.  -     var back = obj.innerHTML;
  3878. 1207.  -     ajax.post('al_friends.php', {act: add ? 'add' : 'remove', mid: uid, hash: hash, from: 'friends'}, {
  3879. 1208.  -       onDone: function(text) {
  3880. 1209.  -         //re(obj);
  3881. 1210.  -         cur['friends_info'+uid] = add;
  3882. 1211.  -         showDoneBox('<div class="friends_done">'+text+'</div>')
  3883. 1212.  -         tooltips.destroyAll();
  3884. 1213.  -         //ge('friends_tt_cont_'+uid).tt.close();
  3885. 1214.  -       },
  3886. 1215.  -       showProgress: function() {
  3887. 1216.  -         obj.innerHTML = '<center><img src="/images/upload.gif" /></center>';
  3888. 1217.  -       },
  3889. 1218.  -       hideProgress: function() {
  3890. 1219.  -         obj.innerHTML = back;
  3891. 1220.  -       }
  3892. 1221.  -     })
  3893. 1222.  -   },
  3894. 1223.  -
  3895. 1224.  -   ttActGift: function(uid) {
  3896. 1225.  -     return !showBox('al_gifts.php', {act: 'get_gift_box', mid: uid, fr: (uid == vk.id ? 1 : 0)}, {stat: ['gifts.css', 'ui_controls.js', 'ui_controls.css'], cache: 1}, false);
  3897. 1226.  -   },
  3898. 1227.  -
  3899. 1228.  -   ttActsMenu: function(obj, ev, uid, hash) {
  3900. 1229.  -     if (obj.tt) {
  3901. 1230.  -       if (!obj.tt.show) return;
  3902. 1231.  -       return obj.tt.show();
  3903. 1232.  -     }
  3904. 1233.  -     if (window.tooltips) {
  3905. 1234.  -       tooltips.hideAll();
  3906. 1235.  -     }
  3907. 1236.  -     var info = cur['friends_info'+uid] || '';
  3908. 1237.  -     var html = ['<div class="friends_tt_menu">'];
  3909. 1238.  -     html.push('<a class="friends_tt_item" onclick="return showWriteMessageBox(event, '+uid+')"><div class="friends_tt_icon friends_tt_msg"></div>'+cur.summaryLang['global_write_msg']+'</a>');
  3910. 1239.  -     if (info) {
  3911. 1240.  -       html.push('<a class="friends_tt_item" onclick="return Friends.ttActToggle(this, '+uid+', \''+hash+'\', 0);"><div class="friends_tt_icon friends_tt_cancel"></div>'+cur.summaryLang['friends_add_cancel']+'</a>');
  3912. 1241.  -     } else if (!cur.friends[uid]) {
  3913. 1242.  -       html.push('<a class="friends_tt_item" onclick="return Friends.ttActToggle(this, '+uid+', \''+hash+'\', 1);"><div class="friends_tt_icon friends_tt_add"></div>'+cur.summaryLang['friends_add_act']+'</a>');
  3914. 1243.  -     }
  3915. 1244.  -     html.push('<a class="friends_tt_item" onclick="return Friends.ttActGift('+uid+');"><div class="friends_tt_icon friends_tt_gift"></div>'+cur.summaryLang['friends_gift_act']+'</a>');
  3916. 1245.  -     html.push('</div>');
  3917. 1246.  -     showTooltip(obj, {
  3918. 1247.  -       text: html.join(''),
  3919. 1248.  -       className: 'friends_tt wall_tt',
  3920. 1249.  -       shift: [0, 0, -2],
  3921. 1250.  -       forcetodown: 1,
  3922. 1251.  -       hasover: 1,
  3923. 1252.  -       center: 1
  3924. 1253.  -     });
  3925. 1254.  -   },
  3926. 1255.  -
  3927. 1256.  -   ddShow: function(uid, obj, ev) {
  3928. 1257.  -     if (cur.silent) {
  3929. 1258.  -       cur.onSilentLoad = function() {
  3930. 1259.  -         Friends.ddShow(uid, obj, ev);
  3931. 1260.  -       };
  3932. 1261.  -       return;
  3933. 1262.  -     }
  3934. 1263.  -
  3935. 1264.  -     var friend = cur.friends[parseInt(uid)];
  3936. 1265.  -     var cats = parseInt(friend[6]);
  3937. 1266.  -
  3938. 1267.  -     var elems = [];
  3939. 1268.  -
  3940. 1269.  -     var publicLists = [28, 29, 27, 25, 26];
  3941. 1270.  -     for (var j = 0, i; j < 5; ++j) {
  3942. 1271.  -       i = publicLists[j];
  3943. 1272.  -       if (cur.publicLists[i]) {
  3944. 1273.  -         elems.push('<a class="friends_dd_item'+((cats & (1 << parseInt(i))) ? ' checked' : '')+'" onclick="Friends.checkCat(this, '+uid+', '+i+');">'+cur.publicLists[i]+'</a>');
  3945. 1274.  -       }
  3946. 1275.  -     }
  3947. 1276.  -     for (var i in cur.userLists) {
  3948. 1277.  -       if (i < 25) {
  3949. 1278.  -         var lname = cur.userLists[i];
  3950. 1279.  -         if (lname.length > 20) {
  3951. 1280.  -           lname = trim(lname.substr(0, 18))+'...';
  3952. 1281.  -         }
  3953. 1282.  -         elems.push('<a class="friends_dd_item'+((cats & (1 << parseInt(i))) ? ' checked' : '')+'" onclick="Friends.checkCat(this, '+uid+', '+i+');">'+lname+'</a>');
  3954. 1283.  -       }
  3955. 1284.  -     }
  3956. 1285.  -     Friends.ddShowCustom(obj, ev, elems, uid);
  3957. 1286.  -   },
  3958. 1287.  -
  3959. 1288.  -   ddShowCustom: function(obj, event, elems, ddId) {
  3960. 1289.  -     var text = obj.innerHTML;
  3961. 1290.  -     var pos = getXY(obj);
  3962. 1291.  -     var height = window.innerHeight ? window.innerHeight : (document.documentElement.clientHeight ? document.documentElement.clientHeight : document.body.offsetHeight);
  3963. 1292.  -     var posY = pos[1] - scrollGetY();
  3964. 1293.  -     var ddHeight = elems.length * 22;
  3965. 1294.  -
  3966. 1295.  -     var params = {
  3967. 1296.  -       className: 'lists_menu'
  3968. 1297.  -     }
  3969. 1298.  -
  3970. 1299.  -     var styleAdd = '';
  3971. 1300.  -     var headerAdd = '';
  3972. 1301.  -
  3973. 1302.  -     if (posY > (height / 2) && (height - posY) < ddHeight) {
  3974. 1303.  -       headerAdd = ' friends_header_up';
  3975. 1304.  -       elems = elems.reverse();
  3976. 1305.  -       styleAdd = ' style="margin-top: -'+(ddHeight + 1)+'px;"';
  3977. 1306.  -     }
  3978. 1307.  -
  3979. 1308.  -     var htmlH = ['<div id="friends_dd_menu_',ddId,'" onmouseout="Friends.ddHide(this, ',ddId,');" onmouseover="Friends.ddActive(this, ',ddId,');"><div class="lists_header', headerAdd,'"><div>', text, '</div></div><div class="lists_body" ', styleAdd,'><table cellspacing="0" cellpadding="0"><tbody><tr><td class="lists_shad_l"><div></div></td><td><div class="lists_shad_t2"></div><div class="lists_shad_t"></div><div class="lists_rows"><div id="rows3">'];
  3980. 1309.  -
  3981. 1310.  -     var htmlF = '</div></div><div class="lists_shad_b"></div><div class="lists_shad_b2"></div></td><td class="lists_shad_r"><div> </div></td></tr></tbody></table></div></div>';
  3982. 1311.  -
  3983. 1312.  -     params.innerHTML = htmlH.join('') + elems.join('') + htmlF;
  3984. 1313.  -
  3985. 1314.  -     var dd = ce('div', params);
  3986. 1315.  -
  3987. 1316.  -     obj.parentNode.insertBefore(dd, obj);
  3988. 1317.  -     cur.onMouseClick = function(ev) {
  3989. 1318.  -       var menuId = 'friends_dd_menu_'+ddId;
  3990. 1319.  -       var obj = ev.target;
  3991. 1320.  -       while (obj) {
  3992. 1321.  -         if (hasClass(obj, 'lists_select') || obj.id == menuId) {
  3993. 1322.  -           return false;
  3994. 1323.  -         }
  3995. 1324.  -         obj = obj.parentNode;
  3996. 1325.  -       }
  3997. 1326.  -       if (ev.target)
  3998. 1327.  -       Friends.ddHide(ge(menuId), ddId, 1);
  3999. 1328.  -     }
  4000. 1329.  -   },
  4001. 1330.  -
  4002. 1331.  -   ddHide: function(obj, ddId, fast) {
  4003. 1332.  -     cur.timeouts['dd_fade'+ddId] = setTimeout(function() {
  4004. 1333.  -       fadeOut(obj, fast ? 0 : 100, function() {
  4005. 1334.  -         var parentEl = obj.parentNode.parentNode;
  4006. 1335.  -         if (parentEl) {
  4007. 1336.  -           parentEl.removeChild(obj.parentNode);
  4008. 1337.  -         }
  4009. 1338.  -       });
  4010. 1339.  -     }, fast ? 0 : 600);
  4011. 1340.  -   },
  4012. 1341.  -   ddActive: function(obj, ddId) {
  4013. 1342.  -     if (cur.timeouts['dd_fade'+ddId]) {
  4014. 1343.  -       clearTimeout(cur.timeouts['dd_fade'+ddId]);
  4015. 1344.  -     }
  4016. 1345.  -   },
  4017. 1346.  -   checkCat: function(obj, uid, listId, from) {
  4018. 1347.  -     if (from == 1) {
  4019. 1348.  -       var checked = isChecked(obj);
  4020. 1349.  -     } else {
  4021. 1350.  -       var checked = hasClass(obj, 'checked');
  4022. 1351.  -       var lists = ge('lists' + uid);
  4023. 1352.  -     }
  4024. 1353.  -     var friend = cur.friends[uid];
  4025. 1354.  -     if (!friend) {
  4026. 1355.  -       return false;
  4027. 1356.  -     }
  4028. 1357.  -     friend[6] = parseInt(friend[6]);
  4029. 1358.  -     if (checked) {
  4030. 1359.  -       if (friend[6] & (1 << listId)) {
  4031. 1360.  -         friend[6] -= (1 << listId);
  4032. 1361.  -       }
  4033. 1362.  -       if (lists) {
  4034. 1363.  -         lists.innerHTML = Friends.getLists(friend[6]);
  4035. 1364.  -       }
  4036. 1365.  -     } else {
  4037. 1366.  -       if (!(friend[6] & (1 << listId))) {
  4038. 1367.  -         friend[6] += (1 << listId);
  4039. 1368.  -       }
  4040. 1369.  -       if (lists) {
  4041. 1370.  -         lists.innerHTML = Friends.getLists(friend[6]);
  4042. 1371.  -       }
  4043. 1372.  -     }
  4044. 1373.  -
  4045. 1374.  -     if (from == 1) {
  4046. 1375.  -       checkbox(obj);
  4047. 1376.  -     } else {
  4048. 1377.  -       (checked ? removeClass : addClass)(obj, 'checked');
  4049. 1378.  -     }
  4050. 1379.  -     if (cur.timeouts['list'+uid]) {
  4051. 1380.  -       clearTimeout(cur.timeouts['list'+uid]);
  4052. 1381.  -     }
  4053. 1382.  -     delete cur.friendsList['list'+listId];
  4054. 1383.  -     delete cur.friendsList['list'+friend[6]]
  4055. 1384.  -     cur.timeouts['list'+uid] = setTimeout(function() {
  4056. 1385.  -       ajax.post('al_friends.php', {act: 'save_cats', uid: uid, cats: friend[6], hash: cur.userHash}, {
  4057. 1386.  -         onDone: function(text) {
  4058. 1387.  -           if (from) {
  4059. 1388.  -             var info = ge('friends_added_'+uid);
  4060. 1389.  -             if (!cur['fr_add_text_'+uid] && info) {
  4061. 1390.  -               cur['fr_add_text_'+uid] = info.innerHTML;
  4062. 1391.  -             }
  4063. 1392.  -             fadeTo(info, 100, 0, function() {
  4064. 1393.  -               info.innerHTML = text;
  4065. 1394.  -               fadeTo(info, 100, 1);
  4066. 1395.  -             });
  4067. 1396.  -             clearTimeout(cur['fr_add_timeout_'+uid]);
  4068. 1397.  -             cur['fr_add_timeout_'+uid] = setTimeout(function() {
  4069. 1398.  -               fadeTo(info, 100, 0, function() {
  4070. 1399.  -                 info.innerHTML = cur['fr_add_text_'+uid];
  4071. 1400.  -                 fadeTo(info, 100, 1);
  4072. 1401.  -               });
  4073. 1402.  -             }, 2000);
  4074. 1403.  -           }
  4075. 1404.  -         }
  4076. 1405.  -       });
  4077. 1406.  -     });
  4078. 1407.  -   },
  4079. 1408.  -   getLists: function(cats) {
  4080. 1409.  -     var info = [];
  4081. 1410.  -     for (var i = 29; i >= 25; i--) {
  4082. 1411.  -       if ((1 << i) & cats && cur.publicLists[i]) {
  4083. 1412.  -         info.push('<span class="group', (i - 1) % 8 + 1, ' fl_l" onmousedown="Friends.toList(', i, ');">', cur.publicLists[i], '</span>');
  4084. 1413.  -       }
  4085. 1414.  -     }
  4086. 1415.  -     if (vk.id == cur.oid) {
  4087. 1416.  -       for (var i in cur.userLists) {
  4088. 1417.  -         if ((1 << i) & cats && !cur.publicLists[i] && cur.userLists[i]) {
  4089. 1418.  -           info.push('<span class="group', (i - 1) % 8 + 1, ' fl_l" onmousedown="Friends.toList(', i, ');">', cur.userLists[i], '</span>');
  4090. 1419.  -         }
  4091. 1420.  -       }
  4092. 1421.  -     }
  4093. 1422.  -     return info.join('');
  4094. 1423.  -   },
  4095. 1424.  -   subscribeAllRequests: function(obj, hash) {
  4096. 1425.  -     ajax.post('al_friends.php', {act: 'subscribe_all_requests', hash: hash, once: 1}, {
  4097. 1426.  -       showProgress: lockButton.pbind(obj),
  4098. 1427.  -       hideProgress: unlockButton.pbind(obj)
  4099. 1428.  -     });
  4100. 1429.  -   },
  4101. 1430.  -   onAllRequestsRemove: function() {
  4102. 1431.  -     return nav.go('/friends?section=all_requests', false, {nocur: true});
  4103. 1432.  -   },
  4104. 1433.  -   editList: function(listId) {
  4105. 1434.  -     var checked = [];
  4106. 1435.  -     if (listId == -1) {
  4107. 1436.  -       listId = intval(cur.curList.substr(4));
  4108. 1437.  -     }
  4109. 1438.  -     if (listId) {
  4110. 1439.  -       var list = Friends.filter(cur.friendsList['all'], cur.curList);
  4111. 1440.  -       var len = list.length;
  4112. 1441.  -       while (len--) {
  4113. 1442.  -         checked.push(list[len][0]);
  4114. 1443.  -       }
  4115. 1444.  -     } else {
  4116. 1445.  -       listId = 0;
  4117. 1446.  -     }
  4118. 1447.  -     showTabbedBox('al_friends.php', {
  4119. 1448.  -       act: 'select_friends_box',
  4120. 1449.  -       Checked: checked.join(','),
  4121. 1450.  -       from: 'list',
  4122. 1451.  -       list_name: (listId ? cur.userLists[listId] : ''),
  4123. 1452.  -       list_id: listId
  4124. 1453.  -     }, {
  4125. 1454.  -       stat: ['privacy.js', 'ui_controls.js', 'ui_controls.css'],
  4126. 1455.  -       cache: 1,
  4127. 1456.  -       onFail: function(text) {
  4128. 1457.  -         setTimeout(showFastBox(getLang('global_error'), text).hide, 3000);
  4129. 1458.  -         return true;
  4130. 1459.  -       }
  4131. 1460.  -     });
  4132. 1461.  -     cur.onFlistSave = function (ids, list, hash, title) {
  4133. 1462.  -       var friendsList = [];
  4134. 1463.  -       for (var i in list) {
  4135. 1464.  -         friendsList.push(parseInt(i));
  4136. 1465.  -       }
  4137. 1466.  -
  4138. 1467.  -       ajax.post('al_friends.php', {act: 'save_list', title: title, cat_id: listId, Friends: friendsList.join(','), hash: hash}, {
  4139. 1468.  -         onDone: function(id, title) {
  4140. 1469.  -           Friends.editListClient(listId, id, title, friendsList);
  4141. 1470.  -         },
  4142. 1471.  -         onFail: function(text) {
  4143. 1472.  -           setTimeout(showFastBox({title: getLang('global_error')}, text, getLang('global_close')).hide, 4000);
  4144. 1473.  -           return true;
  4145. 1474.  -         }
  4146. 1475.  -       });
  4147. 1476.  -
  4148. 1477.  -       Friends.clearFilter();
  4149. 1478.  -
  4150. 1479.  -       return false;
  4151. 1480.  -     };
  4152. 1481.  -
  4153. 1482.  -   },
  4154. 1483.  -   editListClient: function(listId, id, title, friendsList) {
  4155. 1484.  -     var listName = 'list' + id;
  4156. 1485.  -     if (listId == 0) {
  4157. 1486.  -       var html = '<a onmousedown="return nav.change({\'0\':\'al_friends.php\', section:\'list'+id+'\'});" id="section_list'+id+'" class="side_filter">'+title+'</a>';
  4158. 1487.  -       ge('sections_block').insertBefore(ce('div', {
  4159. 1488.  -         innerHTML: html
  4160. 1489.  -       }), ge('friends_create_list'));
  4161. 1490.  -       var len = friendsList.length;
  4162. 1491.  -       var mask = 1 << parseInt(id);
  4163. 1492.  -       cur.friendsList[listName] = [];
  4164. 1493.  -       while (len--) {
  4165. 1494.  -         var friend = cur.friends[friendsList[len]];
  4166. 1495.  -         friend[6] = parseInt(friend[6]);
  4167. 1496.  -
  4168. 1497.  -         if (!(friend[6] & mask)) {
  4169. 1498.  -           friend[6] += mask;
  4170. 1499.  -           cur.friendsList[listName].push(friend)
  4171. 1500.  -         }
  4172. 1501.  -       }
  4173. 1502.  -       cur.userLists[id] = title;
  4174. 1503.  -       //Friends.indexAll();
  4175. 1504.  -       Friends.indexAll();
  4176. 1505.  -       removeClass(ge('main_class'), 'no_lists');
  4177. 1506.  -       return nav.change({'0':'friends', section: listName});
  4178. 1507.  -     } else {
  4179. 1508.  -       if (id < 25) {
  4180. 1509.  -         ge('section_list'+id).innerHTML = title;
  4181. 1510.  -         cur.userLists[id] = title;
  4182. 1511.  -       }
  4183. 1512.  -       var mask = (1 << id);
  4184. 1513.  -       cur.friendsList[listName] = [];
  4185. 1514.  -       for (var i in cur.friends) {
  4186. 1515.  -         var friend = cur.friends[i];
  4187. 1516.  -         var inList = (friendsList.indexOf(parseInt(friend[0])) != -1);
  4188. 1517.  -         if (inList) {
  4189. 1518.  -           cur.friendsList[listName].push(friend);
  4190. 1519.  -         }
  4191. 1520.  -         friend[6] = parseInt(friend[6]);
  4192. 1521.  -         if (friend[6] & mask) {
  4193. 1522.  -           if (!inList) {
  4194. 1523.  -             friend[6] -= mask;
  4195. 1524.  -           }
  4196. 1525.  -         } else {
  4197. 1526.  -           if (inList) {
  4198. 1527.  -             friend[6] += mask;
  4199. 1528.  -           }
  4200. 1529.  -         }
  4201. 1530.  -       }
  4202. 1531.  -       Friends.indexAll();
  4203. 1532.  -       return Friends.section(listName, function() {
  4204. 1533.  -         Friends.changeSummary();
  4205. 1534.  -         nav.setLoc({'0':'friends', section: listName});
  4206. 1535.  -       });
  4207. 1536.  -     }
  4208. 1537.  -   },
  4209. 1538.  -   createList: function(event) {
  4210. 1539.  -     Friends.editList(0);
  4211. 1540.  -   },
  4212. 1541.  -   deleteList: function(listId) {
  4213. 1542.  -     showBox('al_friends.php', {act: 'delete_list_box', list_id: listId});
  4214. 1543.  -   },
  4215. 1544.  -   deleteListClient: function(listId) {
  4216. 1545.  -     var listSection = ge('section_list'+listId);
  4217. 1546.  -     listSection.parentNode.removeChild(listSection);
  4218. 1547.  -     var mask = (1 << listId);
  4219. 1548.  -     for (var i in cur.friends) {
  4220. 1549.  -       if (cur.friends[i][6] & mask) {
  4221. 1550.  -         cur.friends[i][6] -= mask;
  4222. 1551.  -       }
  4223. 1552.  -     }
  4224. 1553.  -     delete cur.userLists[listId];
  4225. 1554.  -     var listsCount = 0;
  4226. 1555.  -     for (var i in cur.userLists) listsCount++;
  4227. 1556.  -     if (!listsCount) {
  4228. 1557.  -       addClass(ge('main_class'), 'no_lists');
  4229. 1558.  -     }
  4230. 1559.  -     //Friends.indexAll();
  4231. 1560.  -     return nav.change({'0':'friends', section:'all'});
  4232. 1561.  -   },
  4233. 1562.  -   searchForFriends: function() {
  4234. 1563.  -     showBox('al_friends.php', {act: 'search'}, {stat: ['friends_search.js', 'friends_search.css'], dark: 1});
  4235. 1564.  -   },
  4236. 1565.  -   selectList: function(obj, id, event) {
  4237. 1566.  -     Friends.ddShow(id, obj, event);
  4238. 1567.  -   },
  4239. 1568.  -   _animDelX: function(color, new_active, post) {
  4240. 1569.  -     if (post === undefined) {
  4241. 1570.  -       post = new_active;
  4242. 1571.  -       new_active = undefined;
  4243. 1572.  -     }
  4244. 1573.  -     var el = ge('delete_row' + post);
  4245. 1574.  -     if (!el) return;
  4246. 1575.  -     if (new_active !== undefined) {
  4247. 1576.  -       el.active = new_active;
  4248. 1577.  -     } else if (el.active) {
  4249. 1578.  -       return;
  4250. 1579.  -     }
  4251. 1580.  -     animate(el, {backgroundColor: color}, 200);
  4252. 1581.  -   },
  4253. 1582.  -   hideSuggestion: function(mid, hash, el) {
  4254. 1583.  -     var controls = ge('request_controls_'+mid);
  4255. 1584.  -     var controlsCont = controls.parentNode;
  4256. 1585.  -     (el || controls).innerHTML = '<div align="center"><img src="/images/upload.gif"></div>';
  4257. 1586.  -     ajax.post('al_friends.php', {act: 'hide_suggestion', mid: mid, hash: hash, report_spam: 1}, {onDone: function(text) {
  4258. 1587.  -       controls.innerHTML = text;
  4259. 1588.  -       cur.suggCount -= 1;
  4260. 1589.  -     }, onFail: function(text) {
  4261. 1590.  -       if (!text) return;
  4262. 1591.  -
  4263. 1592.  -       showFastBox(getLang('global_error'), text);
  4264. 1593.  -       return true;
  4265. 1594.  -     }});
  4266. 1595.  -     Friends.processRequest(mid, false, true);
  4267. 1596.  -
  4268. 1597.  -   },
  4269. 1598.  -   addRecommend: function(mid, uid, hash, obj) {
  4270. 1599.  -     obj = obj.parentNode;
  4271. 1600.  -     obj.innerHTML = '<img src="/images/upload.gif" />';
  4272. 1601.  -     ajax.post('al_friends.php', {
  4273. 1602.  -       act: 'a_suggest_friends',
  4274. 1603.  -       mid: mid,
  4275. 1604.  -       uids: uid,
  4276. 1605.  -       hash: hash,
  4277. 1606.  -       from: 'add'
  4278. 1607.  -     }, {
  4279. 1608.  -       onDone: function(text) {
  4280. 1609.  -         obj.innerHTML = text;
  4281. 1610.  -       },
  4282. 1611.  -       onFail: function(text) {
  4283. 1612.  -         obj.innerHTML = text;
  4284. 1613.  -       }
  4285. 1614.  -     })
  4286. 1615.  -
  4287. 1616.  -   },
  4288. 1617.  -   suggestBox: function(mid) {
  4289. 1618.  -     var box = showBox('al_friends.php', {
  4290. 1619.  -       act: 'select_friends_box',
  4291. 1620.  -       from: 'suggest_friends',
  4292. 1621.  -       friend_id: mid
  4293. 1622.  -     }, {stat: ['privacy.js', 'privacy.css', 'indexer.js', 'profile.css']});
  4294. 1623.  -     box.leaveOnSave = true;
  4295. 1624.  -     cur.onFlistSave = function(ids, list, hash) {
  4296. 1625.  -       //if (!ids || !ids.length) return;
  4297. 1626.  -       ajax.post('al_friends.php', {
  4298. 1627.  -         act: 'a_suggest_friends',
  4299. 1628.  -         mid: mid,
  4300. 1629.  -         ids: ids.join(','),
  4301. 1630.  -         hash: hash
  4302. 1631.  -       }, {
  4303. 1632.  -         onDone: function(text) {
  4304. 1633.  -           box.hide();
  4305. 1634.  -           showDoneBox(text);
  4306. 1635.  -         },
  4307. 1636.  -         showProgress: box.showProgress,
  4308. 1637.  -         hideProgress: box.hideProgress
  4309. 1638.  -       });
  4310. 1639.  -     }
  4311. 1640.  -   },
  4312. 1641.  -   getAgeFromData: function(max, opts) {
  4313. 1642.  -     max = parseInt(max);
  4314. 1643.  -     if (!max > 0) max = opts.ageTo;
  4315. 1644.  -     return Friends.getRangeData(opts.ageFrom, max, 1, opts.langAgeFrom+' ', opts.langAgeFromEmpty);
  4316. 1645.  -   },
  4317. 1646.  -   getAgeToData: function(min, opts) {
  4318. 1647.  -     min = parseInt(min);
  4319. 1648.  -     if (!min > 0) min = opts.ageFrom;
  4320. 1649.  -     return Friends.getRangeData(min, opts.ageTo, 1, opts.langAgeTo+' ', opts.langAgeToEmpty);
  4321. 1650.  -   },
  4322. 1651.  -   getRangeData: function(min, max, step, prefix, label) {
  4323. 1652.  -     if (min > max) return false;
  4324. 1653.  -     var ret = [[0, label]];
  4325. 1654.  -     if (step < 0) {
  4326. 1655.  -       for (var i = max; i >= min; i += step)
  4327. 1656.  -         ret.push([i, prefix + i]);
  4328. 1657.  -     } else if (step > 0) {
  4329. 1658.  -       for (var i = min; i <= max; i += step)
  4330. 1659.  -         ret.push([i, prefix + i]);
  4331. 1660.  -     }
  4332. 1661.  -     return ret;
  4333. 1662.  -   },
  4334. 1663.  -   radioFilter: function(el, value, fireEvent) {
  4335. 1664.  -     radiobtn(el, value, 'friends_radio_sex');
  4336. 1665.  -     if (fireEvent || fireEvent == undefined) {
  4337. 1666.  -       Friends.changeFilter();
  4338. 1667.  -     }
  4339. 1668.  -   },
  4340. 1669.  -   initFilters: function(opts) {
  4341. 1670.  -     stManager.add(['ui_controls.js', 'ui_controls.css'], function() {
  4342. 1671.  -       cur.cityFilter = new Dropdown(ge('friends_fltr_city'), opts.cities, {
  4343. 1672.  -         width: 150,
  4344. 1673.  -         zeroPlaceholder: true,
  4345. 1674.  -         placeholder: opts.citiesPl,
  4346. 1675.  -         placeholderColor: '#777',
  4347. 1676.  -         //selectedItems: '{$school_year}',
  4348. 1677.  -         onChange: Friends.changeFilter,
  4349. 1678.  -         onShow: function() {
  4350. 1679.  -           if (cur.silent) {
  4351. 1680.  -             cur.cityFilterOpened = true;
  4352. 1681.  -             show('friends_fltr_progress');
  4353. 1682.  -           }
  4354. 1683.  -         }
  4355. 1684.  -       });
  4356. 1685.  -
  4357. 1686.  -       cur.ageFromFilter = new Dropdown(ge('friends_age_from'), Friends.getAgeFromData(opts.ageTo, opts), {
  4358. 1687.  -         zeroPlaceholder: true,
  4359. 1688.  -         placeholderColor: '#777',
  4360. 1689.  -         width: 70,
  4361. 1690.  -         onChange: function(value){
  4362. 1691.  -          cur.ageToFilter.setData(Friends.getAgeToData(value, opts));
  4363. 1692.  -          Friends.changeFilter();
  4364. 1693.  -         }
  4365. 1694.  -       });
  4366. 1695.  -
  4367. 1696.  -       cur.ageToFilter = new Dropdown(ge('friends_age_to'), Friends.getAgeToData(opts.ageFrom, opts), {
  4368. 1697.  -         zeroPlaceholder: true,
  4369. 1698.  -         placeholderColor: '#777',
  4370. 1699.  -         width: 70,
  4371. 1700.  -         onChange: function(value){
  4372. 1701.  -           cur.ageFromFilter.setData(Friends.getAgeFromData(value, opts));
  4373. 1702.  -           Friends.changeFilter();
  4374. 1703.  -         }
  4375. 1704.  -       });
  4376. 1705.  -
  4377. 1706.  -       window.radioBtns['friends_radio_sex'] = {
  4378. 1707.  -         els: Array.prototype.slice.apply(geByClass('radiobtn', ge('friends_radio_sex'))),
  4379. 1708.  -         val: 0
  4380. 1709.  -       }
  4381. 1710.  -     });
  4382. 1711.  -   },
  4383. 1712.  -   clearFilter: function(fireEvent) {
  4384. 1713.  -     if (!cur.cityFilter) return;
  4385. 1714.  -     cur.cityFilter.selectItem(0, false);
  4386. 1715.  -     cur.ageFromFilter.selectItem(0, false);
  4387. 1716.  -     cur.ageToFilter.selectItem(0, false);
  4388. 1717.  -     Friends.radioFilter(ge('friends_radio_any'), 0, false);
  4389. 1718.  -     cur.filterIds = false;
  4390. 1719.  -     cur.filter = false;
  4391. 1720.  -     if (fireEvent) {
  4392. 1721.  -       Friends.changeFilter();
  4393. 1722.  -     }
  4394. 1723.  -   },
  4395. 1724.  -   filterParams: function() {
  4396. 1725.  -     var p = {
  4397. 1726.  -       city: parseInt(cur.cityFilter.val()),
  4398. 1727.  -       sex: parseInt(radioBtns['friends_radio_sex'].val),
  4399. 1728.  -       age_from: parseInt(cur.ageFromFilter.val()),
  4400. 1729.  -       age_to: parseInt(cur.ageToFilter.val())
  4401. 1730.  -     }
  4402. 1731.  -     if (p.city || p.sex || p.age_from || p.age_to) {
  4403. 1732.  -       return p;
  4404. 1733.  -     } else {
  4405. 1734.  -       return false;
  4406. 1735.  -     }
  4407. 1736.  -   },
  4408. 1737.  -   changeFilter: function() {
  4409. 1738.  -     if (cur.silent) {
  4410. 1739.  -       cur.onSilentLoad = function() {
  4411. 1740.  -         Friends.changeFilter();
  4412. 1741.  -       };
  4413. 1742.  -       hide(cur.showMore);
  4414. 1743.  -       cur.fContent.innerHTML = '<div class="wide_loading"></div>';
  4415. 1744.  -       return;
  4416. 1745.  -     }
  4417. 1746.  -     cur.filter = Friends.filterParams();
  4418. 1747.  -     if (cur.section == 'suggestions') {
  4419. 1748.  -       return Friends.section(cur.section, function() {}, cur.filter || true);
  4420. 1749.  -     }
  4421. 1750.  -     if (cur.filter) {
  4422. 1751.  -       ajax.post('friends', extend({act: 'filter_friends', uid: cur.oid}, cur.filter), {
  4423. 1752.  -         onDone: function(ids) {
  4424. 1753.  -           cur.filterIds = {};
  4425. 1754.  -           for (var i in ids) {
  4426. 1755.  -             cur.filterIds[ids[i]] = 1;
  4427. 1756.  -           }
  4428. 1757.  -           for (var i in cur.friendsList) {
  4429. 1758.  -             if (i.split('_').pop() == 'filter') {
  4430. 1759.  -               delete cur.friendsList[i];
  4431. 1760.  -             }
  4432. 1761.  -           }
  4433. 1762.  -           Friends.search(cur.searchStr || -1, cur.section, false, true);
  4434. 1763.  -           Friends.changeSummary();
  4435. 1764.  -         },
  4436. 1765.  -         progress: 'friends_fltr_progress',
  4437. 1766.  -         cache: 1
  4438. 1767.  -       })
  4439. 1768.  -     } else {
  4440. 1769.  -       if (cur.filterIds) {
  4441. 1770.  -         cur.filterIds = false;
  4442. 1771.  -       }
  4443. 1772.  -       Friends.updateList();
  4444. 1773.  -     }
  4445. 1774.  -   },
  4446. 1775.  -
  4447. 1776.  -   bigphOver: function(obj, uid) {
  4448. 1777.  -     if (!window.lang || !lang.global_photo_full_size || browser.mobile) return;
  4449. 1778.  -     var o = obj.firstChild, ch = cur.bigphCache[uid];
  4450. 1779.  -     if (o.tagName != 'A' || o.className != 'friends_bigph') {
  4451. 1780.  -       (o = obj.insertBefore(ce('a', {className: 'friends_bigph', href: ch && ch._id ? ('/photo' + ch._id + '?all=1') : ('/albums' + uid), innerHTML: '<span class="friends_bigph_label">' + getLang('global_photo_full_size') + '</span>'}), obj.firstChild)).onclick = Friends.bigphClick.pbind(uid);
  4452. 1781.  -       o._uid = uid;
  4453. 1782.  -     }
  4454. 1783.  -
  4455. 1784.  -     clearTimeout(o.hideTO);
  4456. 1785.  -     animate(o, {marginTop: 75}, {duration: 200, transition: Fx.Transitions.easeOutCirc});
  4457. 1786.  -     cur.bigphShown[uid] = o;
  4458. 1787.  -
  4459. 1788.  -     if (ch === undefined) {
  4460. 1789.  -       cur.bigphCache[uid] = 'load';
  4461. 1790.  -       ajax.post('al_photos.php', {act: 'fast_get_photo', oid: uid}, {onDone: function(res) {
  4462. 1791.  -         if (!res) {
  4463. 1792.  -           obj.onmouseover = function() {};
  4464. 1793.  -           re(obj.firstChild);
  4465. 1794.  -           return;
  4466. 1795.  -         }
  4467. 1796.  -         var sh = (cur.bigphCache[uid] == 'show');
  4468. 1797.  -         cur.bigphCache[uid] = res;
  4469. 1798.  -         o.href = '/photo' + res._id + '?all=1';
  4470. 1799.  -         if (sh) Friends.bigphClick(uid);
  4471. 1800.  -       }, onFail: function() {
  4472. 1801.  -         obj.onmouseover = function() {};
  4473. 1802.  -         re(obj.firstChild);
  4474. 1803.  -         return true;
  4475. 1804.  -       }});
  4476. 1805.  -     }
  4477. 1806.  -
  4478. 1807.  -     if (!obj.onmouseout) obj.onmouseout = Friends.bigphOut.pbind(obj);
  4479. 1808.  -   },
  4480. 1809.  -   bigphOut: function(obj) {
  4481. 1810.  -     var o = obj.firstChild;
  4482. 1811.  -     if (!o || o.tagName != 'A' || o.className != 'friends_bigph') return;
  4483. 1812.  -
  4484. 1813.  -     clearTimeout(o.hideTO);
  4485. 1814.  -     o.hideTO = setTimeout(function() {
  4486. 1815.  -       animate(o, {marginTop: 100}, 200);
  4487. 1816.  -       delete(cur.bigphShown[o._uid]);
  4488. 1817.  -     }, 150);
  4489. 1818.  -   },
  4490. 1819.  -   bigphClick: function(uid, ev) {
  4491. 1820.  -     if (checkEvent(ev) !== false) return;
  4492. 1821.  -
  4493. 1822.  -     var ch = cur.bigphCache[uid];
  4494. 1823.  -     if (ch == 'load' || ch == 'show') {
  4495. 1824.  -       cur.bigphCache[uid] = 'show';
  4496. 1825.  -       return cancelEvent(ev);
  4497. 1826.  -     }
  4498. 1827.  -     if (!ch) return;
  4499. 1828.  -     return showPhoto(ch._id, 'album' + uid + '_0/rev', extend({jumpTo: {z: 'albums' + uid}}, ch), ev);
  4500. 1829.  -   }
  4501. 1830.  -
  4502. 1831.  - }
  4503. 1832.  -
  4504. 1833.  - extend(Friends, {
  4505. 1834.  -   rowOver: Friends._animDelX.pbind('#C4D2E1'),
  4506. 1835.  -   rowOut: Friends._animDelX.pbind('#FFF'),
  4507. 1836.  -   activeDeleteRow: function(post, tt) {
  4508. 1837.  -     Friends._animDelX('#6B8DB1', 1, post);
  4509. 1838.  -     if (tt) showTooltip(ge('delete_row' + post), {text: tt, showdt: 500, black: 1});
  4510. 1839.  -   },
  4511. 1840.  -   deactiveDeleteRow: Friends._animDelX.pbind('#C4D2E1', 0),
  4512. 1841.  -   deleteRow: function(row, hash) {
  4513. 1842.  -     rowInfo = row.split('_');
  4514. 1843.  -     var obj = ge('suggestion'+row);
  4515. 1844.  -     if (hasClass(obj, 'user_block_first')) {
  4516. 1845.  -       nobj = obj.nextSibling;
  4517. 1846.  -       while (nobj && !isVisible(nobj)) {
  4518. 1847.  -         nobj = nobj.nextSibling;
  4519. 1848.  -       }
  4520. 1849.  -       if (nobj) {
  4521. 1850.  -         if (nobj.id == 'friends_sub_summary') {
  4522. 1851.  -           var summ = nobj.childNodes[0].innerHTML;
  4523. 1852.  -           ge('friends_summary').innerHTML = summ;
  4524. 1853.  -           re(nobj);
  4525. 1854.  -         } else if (nobj.className) {
  4526. 1855.  -           addClass(nobj, 'user_block_first')
  4527. 1856.  -         }
  4528. 1857.  -       }
  4529. 1858.  -     }
  4530. 1859.  -     slideUp('suggestion' + row, 100);
  4531. 1860.  -     if (tooltips) {
  4532. 1861.  -       tooltips.hide(ge('delete_row' + row))
  4533. 1862.  -     }
  4534. 1863.  -     ajax.post('al_friends.php', {act: 'hide_possible', mid: rowInfo[1], hash: hash}, {onDone: function() {
  4535. 1864.  -     }});
  4536. 1865.  -     var list = cur.friendsList['suggestions'];
  4537. 1866.  -     row = row.split('_');
  4538. 1867.  -     for (var i in list) {
  4539. 1868.  -       if (parseInt(list[i][0]) == parseInt(row[1])) {
  4540. 1869.  -         cur.friendsList['suggestions'].splice(i, 1);
  4541. 1870.  -       }
  4542. 1871.  -     }
  4543. 1872.  -     cur.importCount -= 1;
  4544. 1873.  -   }
  4545. 1874.  - });
  4546. 1875.  -
  4547. 1876.  - try{stManager.done('friends.js');}catch(e){}
  4548. ------
  4549. Файл - video.js (Старый размер - 44157 | Новый - 0):
  4550. 0.  - var Video = {
  4551. 1.  -   regBR: new RegExp('<br>', 'g'),
  4552. 2.  -   init: function(obj) {
  4553. 3.  -     extend(cur, obj);
  4554. 4.  -     extend(cur, {
  4555. 5.  -       vSearch: ge('v_search'),
  4556. 6.  -       videoSearch: ge('video_search'),
  4557. 7.  -       vRows: ge('video_rows'),
  4558. 8.  -       vList: ge('video_list'),
  4559. 9.  -       vSearchRows: ge('video_search_rows'),
  4560. 10.  -       more: ge('show_more'),
  4561. 11.  -       notFound: ge('not_found'),
  4562. 12.  -       pageEnd: ge('page_end'),
  4563. 13.  -       summary: ge('video_summary'),
  4564. 14.  -       hTab: ge('video_tab_hidden'),
  4565. 15.  -       searchSummary: ge('video_search_summary'),
  4566. 16.  -       secFilter: ge('video_section_filter'),
  4567. 17.  -       albumsCont: ge('video_albums_wrap'),
  4568. 18.  -       albumsContMore: ge('video_albums_more'),
  4569. 19.  -       module: 'video',
  4570. 20.  -       vOrder: 2
  4571. 21.  -     });
  4572. 22.  -     placeholderSetup(cur.vSearch, {back: true});
  4573. 23.  -     onDomReady(function() {
  4574. 24.  -       elfocus(cur.vSearch);
  4575. 25.  -     });
  4576. 26.  -     if (browser.mobile) {
  4577. 27.  -       cur.cansort = false;
  4578. 28.  -     }
  4579. 29.  -
  4580. 30.  -     cur.perPage = 15;
  4581. 31.  -     cur.searchCount = {};
  4582. 32.  -     if (!cur.searchData) {
  4583. 33.  -       cur.searchData = {};
  4584. 34.  -     }
  4585. 35.  -
  4586. 36.  -     cur.restoreRaw = {};
  4587. 37.  -
  4588. 38.  -     var list = cur.videoList[cur.vSection];
  4589. 39.  -
  4590. 40.  -     if (cur.vSection != 'all' && list) {
  4591. 41.  -       len = list.length;
  4592. 42.  -     }
  4593. 43.  -
  4594. 44.  -     this.scrollNode = browser.msie6 ? pageNode : window;
  4595. 45.  -
  4596. 46.  -     addEvent(this.scrollNode, 'scroll', this.scrollResize);
  4597. 47.  -
  4598. 48.  -     setTimeout((function() {
  4599. 49.  -       cur.destroy.push(function() {
  4600. 50.  -         removeEvent(this.scrollNode, 'scroll', this.scrollResize);
  4601. 51.  -       });
  4602. 52.  -     }).bind(this), 0);
  4603. 53.  -
  4604. 54.  -     setTimeout((function() {
  4605. 55.  -       this.indexAll(cur.onIndexFinish);
  4606. 56.  -     }).bind(this), 0);
  4607. 57.  -
  4608. 58.  -
  4609. 59.  -     cur.timeouts = {};
  4610. 60.  -     cur.destroy.push(function() {
  4611. 61.  -       if (cur.timeouts) {
  4612. 62.  -         for (var i in cur.timeouts) {
  4613. 63.  -           clearTimeout(cur.timeouts);
  4614. 64.  -         }
  4615. 65.  -       }
  4616. 66.  -       removeEvent(Video.scrollNode, 'scroll', Video.scrollResize);
  4617. 67.  -     });
  4618. 68.  -
  4619. 69.  -     if (cur.cansort) {
  4620. 70.  -       cur.qsorterRowClass = 'video_row_cont';
  4621. 71.  -       cur.qsorterRowUpClass = 'video_row_cont video_row_up';
  4622. 72.  -       var videoRows = ge('video_rows');
  4623. 73.  -       if (videoRows) {
  4624. 74.  -         cur.sorter = qsorter.init(videoRows, {
  4625. 75.  -           onReorder: Video.onReorder,
  4626. 76.  -           xsize: 2,
  4627. 77.  -           width: 308,
  4628. 78.  -           height: 188,
  4629. 79.  -           noMoveCursor: 1,
  4630. 80.  -           canDrag: function(el) {
  4631. 81.  -             if (hasClass(el.firstChild.firstChild, 'video_row_deleted')) {
  4632. 82.  -               return 0;
  4633. 83.  -             }
  4634. 84.  -             if (cur.vSection == 'tagged') {
  4635. 85.  -               return 0;
  4636. 86.  -             }
  4637. 87.  -             return hasClass(el.firstChild, 'video_can_edit') ? 1 : 0;
  4638. 88.  -           },
  4639. 89.  -           dragCont: cur.albumsCont,
  4640. 90.  -           dragEls: geByClass('video_album_candrop', cur.albumsCont),
  4641. 91.  -           onDrop: Video.albumDrop,
  4642. 92.  -           onDragOver: Video.albumDragOver,
  4643. 93.  -           onDragOut: Video.albumDragOut
  4644. 94.  -         });
  4645. 95.  -       }
  4646. 96.  -     }
  4647. 97.  -     if (cur.canEditAlbums && cur.albumsCont) {
  4648. 98.  -       cur.qsorterRowClass = 'video_album video_album_candrop';
  4649. 99.  -       cur.qsorterRowUpClass = 'video_album video_album_candrop video_row_up';
  4650. 100.  -       cur.albumsSorter = qsorter.init(cur.albumsCont, {
  4651. 101.  -         onReorder: Video.onAlbumReorder,
  4652. 102.  -         xsize: 3,
  4653. 103.  -         width: 205,
  4654. 104.  -         height: 157,
  4655. 105.  -         noMoveCursor: 1
  4656. 106.  -       });
  4657. 107.  -     }
  4658. 108.  -
  4659. 109.  -     cur.nav.push((function(changed, old, n, opts) {
  4660. 110.  -       if (typeof(changed.act) != 'undefined') {
  4661. 111.  -         return;
  4662. 112.  -       }
  4663. 113.  -       if (window.mvcur) {
  4664. 114.  -         var m = (changed[0] || '').match(/^video(-?\d+_\d+)/), owner;
  4665. 115.  -         if (m) {
  4666. 116.  -           if (!mvcur.mvShown || mvcur.videoRaw == m[1]) {
  4667. 117.  -             showVideo(m[1], '', {});
  4668. 118.  -             return false;
  4669. 119.  -           }
  4670. 120.  -         }
  4671. 121.  -         if (!m && mvcur.mvShown && (owner = old[0].match(/^video(-?\d+)_\d+/))) {
  4672. 122.  -           owner = intval(owner[1]);
  4673. 123.  -           if (n[0] == 'video' && (owner == vk.id && !n.gid || owner < 0 && n.gid == -owner) || owner > 0 && n[0] == 'videos' + owner) {
  4674. 124.  -             videoview.hide(opts.hist ? 2 : false);
  4675. 125.  -             return false;
  4676. 126.  -           }
  4677. 127.  -         }
  4678. 128.  -       }
  4679. 129.  -       if (changed.q !== undefined) {
  4680. 130.  -         cur.vSearch.value = changed.q;
  4681. 131.  -         Video.searchVideos(changed.q);
  4682. 132.  -       }
  4683. 133.  -       if (old[0] == n[0] && (n.section || changed.section != undefined)) {
  4684. 134.  -         if (!changed.id) {
  4685. 135.  -           this.section(n.section);
  4686. 136.  -           if (n.section != 'search') {
  4687. 137.  -             delete n.q;
  4688. 138.  -           }
  4689. 139.  -           nav.setLoc(n);
  4690. 140.  -           return false;
  4691. 141.  -         }
  4692. 142.  -       }
  4693. 143.  -     }).bind(this));
  4694. 144.  -
  4695. 145.  -     if (cur.silent) {
  4696. 146.  -       this.loadSilent();
  4697. 147.  -     } else {
  4698. 148.  -       Video.onListInit();
  4699. 149.  -     }
  4700. 150.  -
  4701. 151.  -     if (cur.editmode) {
  4702. 152.  -       VideoEdit.init();
  4703. 153.  -     }
  4704. 154.  -     cur.deleteAllToggle = Video.deleteAllToggle;
  4705. 155.  -   },
  4706. 156.  -   deleteAllToggle: function(obj) {
  4707. 157.  -     var msg = geByClass1('video_row_deleted_msg', obj);
  4708. 158.  -     if (msg) {
  4709. 159.  -       var backTop = getStyle(msg, 'marginTop');
  4710. 160.  -       setStyle(msg, {marginTop: 10});
  4711. 161.  -       cur.cancelDeleteAllToggle = function(obj) {
  4712. 162.  -         setStyle(msg, {marginTop: backTop});
  4713. 163.  -       }
  4714. 164.  -     }
  4715. 165.  -   },
  4716. 166.  -   privateTooltip: function(obj) {
  4717. 167.  -     showTooltip(obj, {
  4718. 168.  -       black: 1,
  4719. 169.  -       text: '<div style="padding: 2px;">'+getLang('video_is_private_tt')+'</div>',
  4720. 170.  -       center: 0,
  4721. 171.  -       shift: [14, 6, 0],
  4722. 172.  -     });
  4723. 173.  -
  4724. 174.  -   },
  4725. 175.  -   privateClick: function(obj, ev) {
  4726. 176.  -     geByClass1('video_row_icon_edit', obj.parentNode.parentNode.parentNode).click();
  4727. 177.  -     return cancelEvent(ev);
  4728. 178.  -
  4729. 179.  -   },
  4730. 180.  -   onReorder: function(video, before, after) {
  4731. 181.  -     var video_id = video.id.replace('video_cont', '');
  4732. 182.  -     var before_id = (before && before.id || '').replace('video_cont', '');
  4733. 183.  -     var after_id = (after && after.id || '').replace('video_cont', '');
  4734. 184.  -     ajax.post('al_video.php', {act: 'reorder_videos', video: video_id, before: before_id, after: after_id, hash: cur.hash});
  4735. 185.  -     var list = cur.videoList[cur.vSection];
  4736. 186.  -     var element = false;
  4737. 187.  -     for (var i = 0, len = list.length; i < len; i++) {
  4738. 188.  -       if (list[i][0]+'_'+list[i][1] == video_id) {
  4739. 189.  -         element = list[i];
  4740. 190.  -         list.splice(i, 1);
  4741. 191.  -         break;
  4742. 192.  -       }
  4743. 193.  -     }
  4744. 194.  -     if (!element) return;
  4745. 195.  -     for (var i = 0, len = list.length; i < len; i++) {
  4746. 196.  -       if (list[i][0]+'_'+list[i][1] == before_id) {
  4747. 197.  -         list.splice(i, 0, element);
  4748. 198.  -         return;
  4749. 199.  -       }
  4750. 200.  -       if (list[i][0]+'_'+list[i][1] == after_id) {
  4751. 201.  -         list.splice(i+1, 0, element);
  4752. 202.  -         return;
  4753. 203.  -       }
  4754. 204.  -     }
  4755. 205.  -   },
  4756. 206.  -   onAlbumReorder: function(album, before, after) {
  4757. 207.  -     var album_id = album.id.replace('video_album_', '');
  4758. 208.  -     var before_id = (before && before.id || '').replace('video_album_', '');
  4759. 209.  -     var after_id = (after && after.id || '').replace('video_album_', '');
  4760. 210.  -     ajax.post('al_video.php', {act: 'reorder_albums', oid: cur.oid, aid: album_id, before: before_id, after: after_id, hash: cur.reorder_hash});
  4761. 211.  -
  4762. 212.  -     if (!cur.aIndex || !cur.aIndex.list) return;
  4763. 213.  -     var list = cur.aIndex.list;
  4764. 214.  -     var element = false;
  4765. 215.  -     for (var i = 0, len = list.length; i < len; i++) {
  4766. 216.  -       if (list[i][0] == album_id) {
  4767. 217.  -         element = list[i];
  4768. 218.  -         list.splice(i, 1);
  4769. 219.  -         break;
  4770. 220.  -       }
  4771. 221.  -     }
  4772. 222.  -     if (!element) return;
  4773. 223.  -     for (var i = 0, len = list.length; i < len; i++) {
  4774. 224.  -       if (list[i][0] == before_id) {
  4775. 225.  -         element._order = list[i]._order - 0.01;
  4776. 226.  -         list.splice(i, 0, element);
  4777. 227.  -         return;
  4778. 228.  -       }
  4779. 229.  -       if (list[i][0] == after_id) {
  4780. 230.  -         element._order = list[i]._order + 0.01;
  4781. 231.  -         list.splice(i + 1, 0, element);
  4782. 232.  -         return;
  4783. 233.  -       }
  4784. 234.  -     }
  4785. 235.  -   },
  4786. 236.  -   onListInit: function() {
  4787. 237.  -     if (!cur.videoList[cur.vSection] && cur.vSection != 'comments') {
  4788. 238.  -       this.generateList(cur.vSection);
  4789. 239.  -     }
  4790. 240.  -   },
  4791. 241.  -   loadSilent: function() {
  4792. 242.  -     cur.loadSilentRequests = (cur.loadSilentRequests || 0) + 1;
  4793. 243.  -     if (cur.loadSilentRequests > 3) {
  4794. 244.  -       return true;
  4795. 245.  -     }
  4796. 246.  -     ajax.post('al_video.php', {act: 'load_videos_silent', oid: cur.oid, offset: (cur.silentAll) ? 0 : cur.videoList['all'].length}, {
  4797. 247.  -       onDone: function(list) {
  4798. 248.  -         var list = eval('('+list+')');
  4799. 249.  -         /*wideLoading = ge('video_wide_loading');
  4800. 250.  -         if (wideLoading) {
  4801. 251.  -           cur.vRows.removeChild(wideLoading);
  4802. 252.  -         }*/
  4803. 253.  -         cur.silent = false;
  4804. 254.  -         for (var i in list) {
  4805. 255.  -           if (!cur.videoList[i]) {
  4806. 256.  -             cur.videoList[i] = list[i];
  4807. 257.  -           } else {
  4808. 258.  -             if (cur.silentAll) {
  4809. 259.  -               cur.videoList[i] = list[i];
  4810. 260.  -             } else {
  4811. 261.  -               Array.prototype.push.apply(cur.videoList[i], list[i]);
  4812. 262.  -             }
  4813. 263.  -           }
  4814. 264.  -         }
  4815. 265.  -
  4816. 266.  -         if (cur.onSilentLoad) {
  4817. 267.  -           cur.onSilentLoad();
  4818. 268.  -         }
  4819. 269.  -         Video.onListInit();
  4820. 270.  -
  4821. 271.  -         Video.scrollResize();
  4822. 272.  -         Video.indexAll();
  4823. 273.  -       },
  4824. 274.  -       onFail: function(text) {
  4825. 275.  -         Video.loadSilent();
  4826. 276.  -       }, local: 1
  4827. 277.  -     });
  4828. 278.  -   },
  4829. 279.  -   show: function(e, videoId, opts, obj) {
  4830. 280.  -     if (obj && hasClass(obj, 'video_row_deleted')) {
  4831. 281.  -       return false;
  4832. 282.  -     }
  4833. 283.  -     if (!vk.id && obj && hasClass(obj, 'video_row_not_public')) {
  4834. 284.  -       showDoneBox(getLang('video_please_sign_in'));
  4835. 285.  -       return false;
  4836. 286.  -     }
  4837. 287.  -     var options = extend({root: 1, autoplay: 1}, opts || {});
  4838. 288.  -     var videoData = videoId.split('_')
  4839. 289.  -     if (cur.vSection == 'search' && parseInt(videoData[0]) != vk.id) {
  4840. 290.  -       options.hideInfo = true;
  4841. 291.  -     }
  4842. 292.  -     if (cur.oid < 0) {
  4843. 293.  -       var listId = 'club' + (-cur.oid);
  4844. 294.  -     } else if (cur.vSection == 'tagged') {
  4845. 295.  -       var listId = 'tag'+cur.oid;
  4846. 296.  -     } else if (cur.pvVideoTagsShown && cur.pvShown) {
  4847. 297.  -       var listId = 'tag'+cur.pvVideoTagsShown;
  4848. 298.  -     } else {
  4849. 299.  -       var listId = '';
  4850. 300.  -     }
  4851. 301.  -     return showVideo(videoId, listId, options, e);
  4852. 302.  -   },
  4853. 303.  -   indexAll: function(callback, onlyAlbums) {
  4854. 304.  -     var all = cur.videoList['all'];
  4855. 305.  -     var indexed = 0;
  4856. 306.  -     var hub = new callHub(callback, onlyAlbums ? 1 : 2);
  4857. 307.  -     if (!onlyAlbums) {
  4858. 308.  -       cur.vIndex = new vkIndexer(all, function(obj) {
  4859. 309.  -         return obj[3];
  4860. 310.  -       }, function() {
  4861. 311.  -         if (callback) {
  4862. 312.  -           hub.done();
  4863. 313.  -         }
  4864. 314.  -       });
  4865. 315.  -     }
  4866. 316.  -     var albums = [];
  4867. 317.  -     for(var i in cur.sections) {
  4868. 318.  -       if (cur.sections[i][0] > 0) {
  4869. 319.  -         albums.push(cur.sections[i]);
  4870. 320.  -       }
  4871. 321.  -     }
  4872. 322.  -     cur.aIndex = new vkIndexer(albums, function(obj) {
  4873. 323.  -       return obj[1];
  4874. 324.  -     }, function() {
  4875. 325.  -       if (callback) {
  4876. 326.  -         hub.done();
  4877. 327.  -       }
  4878. 328.  -     });
  4879. 329.  -   },
  4880. 330.  -   addToList: function(list, row, silent) {
  4881. 331.  -     if (!cur.videoList) return;
  4882. 332.  -     var restore = cur.restoreRaw['d_'+row[0]+'_'+row[1]];
  4883. 333.  -     if (restore) {
  4884. 334.  -       for (var i in restore) {
  4885. 335.  -         cur.videoList[restore[i].section].splice(restore[i].pos, 0, restore[i].val)
  4886. 336.  -       }
  4887. 337.  -       delete cur.restoreRaw['d_'+row[0]+'_'+row[1]];
  4888. 338.  -     } else {
  4889. 339.  -       cur.videoList[list].unshift(row);
  4890. 340.  -     }
  4891. 341.  -     cur.vIndex.add(row);
  4892. 342.  -     if (!silent && cur.vSection != 'search') {
  4893. 343.  -       Video.clearOutput();
  4894. 344.  -       Video.showMore();
  4895. 345.  -     }
  4896. 346.  -   },
  4897. 347.  -   onTagConfirm: function(mvData) {
  4898. 348.  -     if (cur.videoList['tagged']) {
  4899. 349.  -       var len = cur.videoList['tagged'].length;
  4900. 350.  -       while(len--) {
  4901. 351.  -         var item = cur.videoList['tagged'][len];
  4902. 352.  -         if (item[0]+'_'+item[1] == mvData && item[8] & 2) {
  4903. 353.  -           item[8] -= 2;
  4904. 354.  -         }
  4905. 355.  -       }
  4906. 356.  -     }
  4907. 357.  -     var videoRow = ge('video_row'+mvData);
  4908. 358.  -     if (videoRow) {
  4909. 359.  -       hide(geByClass1('video_tag_label', videoRow));
  4910. 360.  -     }
  4911. 361.  -     delete ajaxCache['/al_video.php#act=show&list=&module=video&video='+mvData];
  4912. 362.  -     delete ajaxCache['/al_video.php#act=show&autoplay=1&list=&module=video&video='+mvData];
  4913. 363.  -   },
  4914. 364.  -   removeFromLists: function(mvData, silent) {
  4915. 365.  -     cur.restoreRaw['d_'+mvData] = [];
  4916. 366.  -     for (var i in cur.videoList) {
  4917. 367.  -       var len = cur.videoList[i].length;
  4918. 368.  -       while(len--) {
  4919. 369.  -         var item = cur.videoList[i][len];
  4920. 370.  -         if (item[0]+'_'+item[1] == mvData) {
  4921. 371.  -           var val = cur.videoList[i].splice(len, 1)[0];
  4922. 372.  -           cur.restoreRaw['d_'+mvData].push({
  4923. 373.  -             section: i,
  4924. 374.  -             pos: len,
  4925. 375.  -             val: val
  4926. 376.  -           });
  4927. 377.  -           cur.vIndex.remove(item);
  4928. 378.  -         }
  4929. 379.  -       }
  4930. 380.  -     }
  4931. 381.  -     if (!silent) {
  4932. 382.  -       var videoRow = ge('video_row'+mvData);
  4933. 383.  -       if (videoRow) {
  4934. 384.  -         videoRow.parentNode.removeChild(videoRow);
  4935. 385.  -       }
  4936. 386.  -     }
  4937. 387.  -   },
  4938. 388.  -   onDeleteClick: function(vid, oid, hash, obj, ev) {
  4939. 389.  -     if (!cur.restoreRaw) cur.restoreRaw = {};
  4940. 390.  -     var vidCont = ge('video_row'+oid+'_'+vid);
  4941. 391.  -     cur.restoreRaw[oid+'_'+vid] = vidCont.innerHTML;
  4942. 392.  -     addClass(vidCont, 'video_row_loading');
  4943. 393.  -     videoview.deleteVideo(vid, oid, hash, false, 'list', this);
  4944. 394.  -     return cancelEvent(ev);
  4945. 395.  -   },
  4946. 396.  -   searchAlbums: function(str) {
  4947. 397.  -     if (str) {
  4948. 398.  -       var a = cur.aIndex.search(str);
  4949. 399.  -       a = a.sort(function(i,j) {return i._order - j._order});
  4950. 400.  -       var summary = langNumeric(a.length, cur.lang['video_albums_found_summary'])
  4951. 401.  -     } else {
  4952. 402.  -       var a = clone(cur.aIndex.list);
  4953. 403.  -       for(var i in cur.sections) {
  4954. 404.  -         if (cur.sections[i][0] == -1) {
  4955. 405.  -           a.unshift([-1, cur.sections[i][1]]);
  4956. 406.  -         }
  4957. 407.  -       }
  4958. 408.  -       var summary = langNumeric(a.length, cur.lang['video_albums_summary'])
  4959. 409.  -     }
  4960. 410.  -     if (a.length) {
  4961. 411.  -       ge('video_albums_summary').innerHTML = summary;
  4962. 412.  -       var html = more_html = '';
  4963. 413.  -       var num = 0;
  4964. 414.  -       for (var i in a) {
  4965. 415.  -         var alb = a[i][0];
  4966. 416.  -         for(var i in cur.sections) {
  4967. 417.  -           if (cur.sections[i][0] == alb) {
  4968. 418.  -             var v = cur.sections[i];
  4969. 419.  -           }
  4970. 420.  -         }
  4971. 421.  -         var title = v[1];
  4972. 422.  -         if (cur.selection && str) {
  4973. 423.  -           title = title.replace(cur.selection.re, cur.selection.val);
  4974. 424.  -         }
  4975. 425.  -         if (num >= 3) {
  4976. 426.  -           more_html += cur.albumsTpl(alb, v, title);
  4977. 427.  -         } else {
  4978. 428.  -           html += cur.albumsTpl(alb, v, title);
  4979. 429.  -         }
  4980. 430.  -         num += 1;
  4981. 431.  -       }
  4982. 432.  -       if (cur.albumsCont) {
  4983. 433.  -         cur.albumsCont.innerHTML = html;
  4984. 434.  -       }
  4985. 435.  -       if (cur.albumsContMore) {
  4986. 436.  -         cur.albumsContMore.innerHTML = more_html;
  4987. 437.  -       }
  4988. 438.  -       if (ge('video_albums_show_more')) {
  4989. 439.  -         ge('video_albums_show_more').innerHTML = langNumeric(a.length, cur.lang['video_show_all_albums']);
  4990. 440.  -         toggle(ge('video_albums_show_more'), num > 3);
  4991. 441.  -       }
  4992. 442.  -     } else {
  4993. 443.  -       addClass(ge('video_content'), 'video_albums_hidden');
  4994. 444.  -     }
  4995. 445.  -   },
  4996. 446.  -   updateAlbums: function(newList) {
  4997. 447.  -     for(var i in cur.sections) {
  4998. 448.  -       if (cur.sections[i][0] > 0) {
  4999. 449.  -         delete cur.sections[i];
  5000. 450.  -       }
  5001. 451.  -     }
  5002. 452.  -     for(var i in newList) {
  5003. 453.  -       cur.sections.push(newList[i]);
  5004. 454.  -     }
  5005. 455.  -     var num = 0;
  5006. 456.  -     for(var i in cur.sections) num += 1;
  5007. 457.  -     if (num) {
  5008. 458.  -       removeClass(ge('video_content'), 'video_no_albums');
  5009. 459.  -       hide('video_tabs_link');
  5010. 460.  -       removeClass(ge('video_content'), 'video_albums_hidden');
  5011. 461.  -     } else {
  5012. 462.  -       addClass(ge('video_content'), 'video_no_albums');
  5013. 463.  -       show('video_tabs_link');
  5014. 464.  -     }
  5015. 465.  -     Video.indexAll(function() {
  5016. 466.  -       Video.searchAlbums(cur.vSection == 'search' ? cur.vStr : false);
  5017. 467.  -       if (cur.canEditAlbums && cur.albumsSorter && !(trim(cur.vStr) && cur.vStr != '""')) {
  5018. 468.  -         qsorter.update(cur.albumsCont);
  5019. 469.  -       }
  5020. 470.  -       if (cur.cansort) {
  5021. 471.  -         qsorter.update(cur.vRows, {dragEls: geByClass('video_album_candrop', cur.albumsCont)});
  5022. 472.  -       }
  5023. 473.  -     }, true);
  5024. 474.  -   },
  5025. 475.  -   searchVideos: function(str, force) {
  5026. 476.  -     var hd = cur.vHD ? cur.vHD : 0;
  5027. 477.  -     cur.searchData[str + hd.toString() + cur.vOrder.toString()] = {
  5028. 478.  -       count: 0,
  5029. 479.  -       list: [],
  5030. 480.  -       offset: 0
  5031. 481.  -     };
  5032. 482.  -     cur.loading = false;
  5033. 483.  -     if (str) {
  5034. 484.  -       if (cur.vSection != 'search') {
  5035. 485.  -         cur.beforeSearch = cur.vSection;
  5036. 486.  -         cur.vStr = '';
  5037. 487.  -         /*if (browser.mobile) {
  5038. 488.  -           cur.vSection = 'search';
  5039. 489.  -         } else {*/
  5040. 490.  -           nav.change({section: 'search'});
  5041. 491.  -         /*}*/
  5042. 492.  -       }
  5043. 493.  -       show('video_search_options');
  5044. 494.  -       addClass(ge('video_reset_search'), 'video_reset_search_shown');
  5045. 495.  -       Video.showOptions();
  5046. 496.  -       var v = cur.vIndex.search(str);
  5047. 497.  -       cur.vStr = str;
  5048. 498.  -       var sec = cur.vSection+'_'+str;
  5049. 499.  -       if (cur.vHD) {
  5050. 500.  -         sec += '_opt_hd'+cur.vHD;
  5051. 501.  -       }
  5052. 502.  -       cur.videoList[sec] = v;
  5053. 503.  -       if (!str.replace(/\|/g, '').length) {
  5054. 504.  -         cur.selection = false;
  5055. 505.  -       } else {
  5056. 506.  -         cur.selection = {
  5057. 507.  -           re: new RegExp('('+str.replace(/\|/g, '').replace(cur.vIndex.delimiter, '|').replace(/^\||\|$/g, '').replace(/([\+\*\)\(])/g, '\\$1')+')', 'gi'),
  5058. 508.  -           val: '<em>$1</em>'
  5059. 509.  -         };
  5060. 510.  -       }
  5061. 511.  -       Video.searchAlbums(str);
  5062. 512.  -       var len = v.length;
  5063. 513.  -       if (len < 10) {
  5064. 514.  -         //show(cur.more);
  5065. 515.  -         //addClass(cur.more, 'load_more');
  5066. 516.  -         if (cur.searchTimout) {
  5067. 517.  -           clearTimeout(cur.searchTimout);
  5068. 518.  -         }
  5069. 519.  -         cur.loading = true;
  5070. 520.  -         cur.searchTimout = setTimeout((function() {
  5071. 521.  -           this.loadFromSearch(str);
  5072. 522.  -         }).bind(this), (force ? 0 : 500));
  5073. 523.  -         addClass(cur.videoSearch, 'v_loading');
  5074. 524.  -       }
  5075. 525.  -       if (len) {
  5076. 526.  -         this.clearOutput();
  5077. 527.  -         this.showMore();
  5078. 528.  -         if (cur.cansort) {
  5079. 529.  -           qsorter.update(cur.vRows, {dragEls: geByClass('video_album_candrop', cur.albumsCont)});
  5080. 530.  -         }
  5081. 531.  -         this.changeSummary();
  5082. 532.  -       } else {
  5083. 533.  -         cur.clearOnSearch = true;
  5084. 534.  -       }
  5085. 535.  -     } else {
  5086. 536.  -       Video.searchAlbums(str);
  5087. 537.  -       if (cur.vSection == 'search') {
  5088. 538.  -         hide('video_search_options');
  5089. 539.  -         if (cur.beforeSearch) {
  5090. 540.  -           nav.change({section: cur.beforeSearch});
  5091. 541.  -         }
  5092. 542.  -         removeClass(ge('video_reset_search'), 'video_reset_search_shown');
  5093. 543.  -         Video.hideOptions();
  5094. 544.  -         removeClass(cur.videoSearch, 'v_loading');
  5095. 545.  -         cur.vStr = '';
  5096. 546.  -         cur.selection = false;
  5097. 547.  -         cur.vSearch.focus();
  5098. 548.  -         /*this.clearOutput();
  5099. 549.  -         this.showMore();
  5100. 550.  -         this.changeSummary();
  5101. 551.  -         cur.vSearch.setValue('');
  5102. 552.  -         cur.vSearch.focus();*/
  5103. 553.  -       }
  5104. 554.  -       if (cur.canEditAlbums && cur.albumsSorter) {
  5105. 555.  -         qsorter.update(cur.albumsCont);
  5106. 556.  -       }
  5107. 557.  -     }
  5108. 558.  -     this.changeUrl();
  5109. 559.  -   },
  5110. 560.  -   toggleFilter: function (obj, target) {
  5111. 561.  -     if (hasClass(obj, 'filter_shut') || !isVisible(target)) {
  5112. 562.  -      addClass(obj, 'filter_open');
  5113. 563.  -      removeClass(obj, 'filter_shut');
  5114. 564.  -      var extraH = slideDown(target, 200).to.height;
  5115. 565.  -     } else {
  5116. 566.  -      slideUp(target, 200, function(){
  5117. 567.  -        addClass(obj, 'filter_shut');
  5118. 568.  -        removeClass(obj, 'filter_open');
  5119. 569.  -      });
  5120. 570.  -     }
  5121. 571.  -   },
  5122. 572.  -   toggleLength: function(el, value, noSearch) {
  5123. 573.  -     removeClass(geByClass1('video_length_sel', ge('video_search_controls')), 'video_length_sel');
  5124. 574.  -     addClass(el, 'video_length_sel');
  5125. 575.  -     cur.vLength = value;
  5126. 576.  -     if (!noSearch) {
  5127. 577.  -       this.searchVideos(cur.vStr);
  5128. 578.  -       this.doChangeUrl();
  5129. 579.  -     }
  5130. 580.  -   },
  5131. 581.  -   toggleHD: function(hd, noSearch) {
  5132. 582.  -     if (noSearch && hd) {
  5133. 583.  -       checkbox(ge('video_hd_option'));
  5134. 584.  -     }
  5135. 585.  -     cur.vHD = isChecked('video_hd_option') ? 1 : 0;
  5136. 586.  -     (cur.vHD ? show : hide)('video_hd2_option');
  5137. 587.  -     if (cur.vHD) {
  5138. 588.  -       show('video_hd2_option');
  5139. 589.  -       cur.vHD += isChecked('video_hd2_option') ? 1 : 0;
  5140. 590.  -     } else {
  5141. 591.  -       hide('video_hd2_option');
  5142. 592.  -     }
  5143. 593.  -     if (!noSearch) {
  5144. 594.  -       this.searchVideos(cur.vStr);
  5145. 595.  -       this.doChangeUrl();
  5146. 596.  -     }
  5147. 597.  -   },
  5148. 598.  -   toggleOrder: function(type) {
  5149. 599.  -     cur.vOrder = type;
  5150. 600.  -     this.searchVideos(cur.vStr);
  5151. 601.  -   },
  5152. 602.  -   toggleExt: function(type) {
  5153. 603.  -     cur.vExt = type;
  5154. 604.  -     this.searchVideos(cur.vStr);
  5155. 605.  -   },
  5156. 606.  -   toggleAdult: function() {
  5157. 607.  -     var updateAdult = function(val) {
  5158. 608.  -       cur.adult = val;
  5159. 609.  -       Video.searchVideos(cur.vStr);
  5160. 610.  -     }
  5161. 611.  -     var cancelAgreed = function() {
  5162. 612.  -       if (cur.isAdult || getCookie('adult_agreed')) {
  5163. 613.  -         return true;
  5164. 614.  -       }
  5165. 615.  -       addClass(ge('video_adult_option'), 'on');
  5166. 616.  -     }
  5167. 617.  -     var checkAgreed = function(val) {
  5168. 618.  -       if (!val || cur.isAdult || getCookie('adult_agreed')) {
  5169. 619.  -         return true;
  5170. 620.  -       }
  5171. 621.  -       var box = showFastBox({title: getLang('video_adult_box_title'), onHide: cancelAgreed}, getLang('video_adult_box_text'), getLang('global_continue'), function() {
  5172. 622.  -       cur.isAdult = true;
  5173. 623.  -       setCookie('adult_agreed', 1);
  5174. 624.  -       updateAdult(1);
  5175. 625.  -       box.hide();
  5176. 626.  -     }, getLang('global_cancel'), function() {
  5177. 627.  -       cancelAgreed();
  5178. 628.  -       box.hide();
  5179. 629.  -     });
  5180. 630.  -       return false;
  5181. 631.  -     }
  5182. 632.  -     var new_val = !isChecked('video_adult_option') ? 1 : 0
  5183. 633.  -     if (checkAgreed(new_val)) {
  5184. 634.  -       updateAdult(new_val);
  5185. 635.  -     }
  5186. 636.  -   },
  5187. 637.  -   setQuery: function(str) {
  5188. 638.  -     cur.onIndexFinish = function() {
  5189. 639.  -       cur.onIndexFinish = false;
  5190. 640.  -       vk.loaded = true;
  5191. 641.  -       Video.searchVideos(str, true);
  5192. 642.  -       cur.vSearch.setValue(str);
  5193. 643.  -     }
  5194. 644.  -   },
  5195. 645.  -   doChangeUrl: function() {
  5196. 646.  -     if (trim(cur.vStr) && cur.vStr != '""') {
  5197. 647.  -       nav.objLoc['q'] = cur.vStr;
  5198. 648.  -     } else {
  5199. 649.  -       delete nav.objLoc['q'];
  5200. 650.  -     }
  5201. 651.  -     if (cur.vLength) {
  5202. 652.  -       nav.objLoc['len'] = cur.vLength;
  5203. 653.  -     } else {
  5204. 654.  -       delete nav.objLoc['len'];
  5205. 655.  -     }
  5206. 656.  -     if (cur.vHD) {
  5207. 657.  -       nav.objLoc['hd'] = cur.vHD;
  5208. 658.  -     } else {
  5209. 659.  -       delete nav.objLoc['hd'];
  5210. 660.  -     }
  5211. 661.  -     nav.setLoc(nav.objLoc);
  5212. 662.  -   },
  5213. 663.  -   changeUrl: function() {
  5214. 664.  -     if (cur.timeouts && cur.timeouts.changeUrl) {
  5215. 665.  -       clearTimeout(cur.timeouts.changeUrl);
  5216. 666.  -     }
  5217. 667.  -     cur.timeouts.changeUrl = setTimeout(Video.doChangeUrl, 2000);
  5218. 668.  -   },
  5219. 669.  -   changeSummary: function() {
  5220. 670.  -     var str, searchStr, oldSearhSummary = false, htitle;
  5221. 671.  -     var sec = cur.vSection;
  5222. 672.  -     if (sec == 'comments') {
  5223. 673.  -       if (cur.commentsCount) {
  5224. 674.  -         cur.summary.innerHTML = langNumeric(cur.commentsCount, cur.lang['video_X_comms'], true);
  5225. 675.  -       } else {
  5226. 676.  -         cur.summary.innerHTML = getLang('video_no_comments');
  5227. 677.  -       }
  5228. 678.  -
  5229. 679.  -       hide(cur.searchSummary);
  5230. 680.  -       htitle = cur.htitle_comments + (cur.commentsCount ? ' | ' + getLang('video_X_comms', cur.commentsCount) : '');
  5231. 681.  -       document.title = replaceEntities(stripHTML(htitle));
  5232. 682.  -       hide('video_comments_link');
  5233. 683.  -
  5234. 684.  -       return true;
  5235. 685.  -     } else if (sec == 'recommendations') {
  5236. 686.  -       cur.summary.innerHTML = cur.recommsSummary;
  5237. 687.  -       document.title = replaceEntities(stripHTML(cur.recommsSummary));
  5238. 688.  -       hide('video_comments_link');
  5239. 689.  -       return true;
  5240. 690.  -     }
  5241. 691.  -     if (cur.vSection == 'search' && cur.vStr) {
  5242. 692.  -       var hd = cur.vHD ? cur.vHD : 0;
  5243. 693.  -       var searchData = cur.searchData[cur.vStr + hd.toString() + cur.vOrder.toString()];
  5244. 694.  -       var len = (searchData) ? searchData.count : 0;
  5245. 695.  -       if (len/* || !cur.loading*/) {
  5246. 696.  -         searchStr = langNumeric(len, cur.lang['video_num_found_files'], true);
  5247. 697.  -       }
  5248. 698.  -       if (!len && cur.loading) {
  5249. 699.  -         oldSearhSummary = true;
  5250. 700.  -       }
  5251. 701.  -       htitle = getLang('video_title_search').replace('{q}', cur.vStr) + (len ? ' | ' + getLang('video_title_search_X_found', len) : '');
  5252. 702.  -     }
  5253. 703.  -
  5254. 704.  -     var sec = cur.vSection;
  5255. 705.  -     if (cur.vSection == 'search') {
  5256. 706.  -       if (cur.vStr) {
  5257. 707.  -         sec += '_'+cur.vStr;
  5258. 708.  -       } else {
  5259. 709.  -         sec = 'all';
  5260. 710.  -       }
  5261. 711.  -       if (cur.vHD) {
  5262. 712.  -         sec += '_opt_hd'+cur.vHD;
  5263. 713.  -       }
  5264. 714.  -     }
  5265. 715.  -     if (cur.videoList[sec]) {
  5266. 716.  -       var len = cur.videoList[sec].length;
  5267. 717.  -     }
  5268. 718.  -
  5269. 719.  -     if (cur.vSection == 'tagged') {
  5270. 720.  -       htitle = cur.htitle_videos + (len ? ' | ' + langNumeric(len, cur.lang['video_title_X_videos_tagged'], true) : '').replace('{user}', cur.htitle_tagged_user);
  5271. 721.  -     }
  5272. 722.  -     if (!htitle) {
  5273. 723.  -       htitle = cur.htitle_videos + (len ? ' | ' + langNumeric(len, cur.lang['video_title_X_videos'], true) : '');
  5274. 724.  -     }
  5275. 725.  -     if (len) {
  5276. 726.  -       str = len + ' ' + langNumeric(len, cur.lang['videofile_num'], true);
  5277. 727.  -     }
  5278. 728.  -
  5279. 729.  -     var searchSummary = false;
  5280. 730.  -     if (str) {
  5281. 731.  -       if (searchStr) {
  5282. 732.  -         cur.searchSummary.innerHTML = '<div class="summary">' + searchStr + '</div>';
  5283. 733.  -         show(cur.searchSummary);
  5284. 734.  -       } else if (!oldSearhSummary) {
  5285. 735.  -         hide(cur.searchSummary);
  5286. 736.  -       }
  5287. 737.  -     } else {
  5288. 738.  -       if (searchStr) {
  5289. 739.  -         str = searchStr;
  5290. 740.  -         searchSummary = true;
  5291. 741.  -       } else {
  5292. 742.  -         str = cur.lang['video_novideo'];
  5293. 743.  -         show(cur.notFound);
  5294. 744.  -         if (cur.vSection.indexOf('album_') === 0) {
  5295. 745.  -           cur.notFound.className = 'video_info_msg video_v_album';
  5296. 746.  -         } else if (cur.vSection != 'search') {
  5297. 747.  -           cur.notFound.className = 'video_info_msg';
  5298. 748.  -         } else {
  5299. 749.  -           cur.notFound.className = 'video_info_msg video_v_search';
  5300. 750.  -           searchSummary = true;
  5301. 751.  -         }
  5302. 752.  -         if (cur.vSection.indexOf('album_') === 0) {
  5303. 753.  -           addClass(cur.notFound, 'video_v_album');
  5304. 754.  -         }
  5305. 755.  -         hide(cur.more);
  5306. 756.  -       }
  5307. 757.  -       hide(cur.searchSummary);
  5308. 758.  -     }
  5309. 759.  -     if (!searchSummary) {
  5310. 760.  -       if (cur.vSection.indexOf('album_') === 0) {
  5311. 761.  -         if (vk.id == cur.oid || (cur.oid < 0 && cur.isGroupAdmin)) {
  5312. 762.  -           str += '<span class="divider">|</span><span><a onclick="Video.deleteAlbum(\'' + cur.vSection + '\');">' + getLang('video_delete_album') + '</a></span>';
  5313. 763.  -         }
  5314. 764.  -       } else if (cur.vSection == 'tagged' && cur.tagsCount > 10) {
  5315. 765.  -         str += '<span class="divider">|</span><span><a onclick="Video.removeAllTags();">' + getLang('video_remove_all_tags') + '</a></span>';
  5316. 766.  -       }
  5317. 767.  -         show('video_comments_link')
  5318. 768.  -     } else {
  5319. 769.  -       hide('video_comments_link');
  5320. 770.  -     }
  5321. 771.  -     cur.summary.innerHTML = str;
  5322. 772.  -     document.title = replaceEntities(stripHTML(htitle));
  5323. 773.  -   },
  5324. 774.  -   loadFromSearch: function(str) {
  5325. 775.  -     var hd = cur.vHD ? cur.vHD : 0;
  5326. 776.  -     if (!cur.searchData[str+hd.toString()+cur.vOrder.toString()]) {
  5327. 777.  -       cur.searchData[str+hd.toString()+cur.vOrder.toString()] = {
  5328. 778.  -         count: 0,
  5329. 779.  -         list: [],
  5330. 780.  -         offset: 0
  5331. 781.  -       };
  5332. 782.  -     }
  5333. 783.  -     var searchData = cur.searchData[str+hd.toString()+cur.vOrder.toString()];
  5334. 784.  -     ajax.post('al_video.php', {
  5335. 785.  -       act: 'search_video',
  5336. 786.  -       q: str,
  5337. 787.  -       offset: searchData.offset,
  5338. 788.  -       hd: hd,
  5339. 789.  -       length: cur.vLength || 0,
  5340. 790.  -       show_adult: cur.adult ? 1 : 0,
  5341. 791.  -       ext: cur.vExt,
  5342. 792.  -       order: cur.vOrder
  5343. 793.  -     }, {
  5344. 794.  -       onDone: (function(count, data) {
  5345. 795.  -         if (!cur.silent) {
  5346. 796.  -           removeClass(cur.videoSearch, 'v_loading');
  5347. 797.  -           removeClass(cur.more, 'load_more');
  5348. 798.  -         } else {
  5349. 799.  -           cur.onSilentLoad = function() {
  5350. 800.  -             removeClass(cur.videoSearch, 'v_loading');
  5351. 801.  -             removeClass(cur.more, 'load_more');
  5352. 802.  -           }
  5353. 803.  -         }
  5354. 804.  -         data = eval('('+data+')');
  5355. 805.  -
  5356. 806.  -         Array.prototype.push.apply(searchData.list, data);
  5357. 807.  -         if (str != cur.vStr) {
  5358. 808.  -           return false;
  5359. 809.  -         }
  5360. 810.  -         if (cur.clearOnSearch) {
  5361. 811.  -           this.clearOutput();
  5362. 812.  -           cur.clearOnSearch = false;
  5363. 813.  -         }
  5364. 814.  -         if (data.length === 0) {
  5365. 815.  -           //cur.videoCount[sec][1] = cur.videoList[sec].length;
  5366. 816.  -           searchData.ended = true;
  5367. 817.  -           if (!searchData.count && !cur.shown) {
  5368. 818.  -             show(cur.notFound);
  5369. 819.  -             hide(cur.more);
  5370. 820.  -             cur.notFound.className = 'video_info_msg video_v_search';
  5371. 821.  -             ge('search_ph').innerHTML = cur.vStr.replace(/([<>&#]*)/g, '');
  5372. 822.  -           }
  5373. 823.  -         } else {
  5374. 824.  -           searchData.count = parseInt(count);
  5375. 825.  -           Video.showMore();
  5376. 826.  -           cur.loading = false;
  5377. 827.  -           if (cur.canEditAlbums && cur.albumsSorter && !(trim(str) && str != '""')) {
  5378. 828.  -             qsorter.update(cur.albumsCont);
  5379. 829.  -           }
  5380. 830.  -           if (cur.cansort) {
  5381. 831.  -             qsorter.update(cur.vRows, {dragEls: geByClass('video_album_candrop', cur.albumsCont)});
  5382. 832.  -           }
  5383. 833.  -         }
  5384. 834.  -         searchData.offset += data.length;
  5385. 835.  -         this.changeSummary();
  5386. 836.  -       }).bind(this),
  5387. 837.  -       cache: 1
  5388. 838.  -     });
  5389. 839.  -   },
  5390. 840.  -   clearOutput: function() {
  5391. 841.  -     cur.vRows.innerHTML = '';
  5392. 842.  -     cur.vSearchRows.innerHTML = '';
  5393. 843.  -     hide(cur.notFound);
  5394. 844.  -     hide(cur.searchSummary);
  5395. 845.  -     cur.shown = 0;
  5396. 846.  -     if (cur.editmode) {
  5397. 847.  -       VideoEdit.onChanging();
  5398. 848.  -     }
  5399. 849.  -   },
  5400. 850.  -   scrollResize: function() {
  5401. 851.  -     if (browser.mobile) return;
  5402. 852.  -     var docEl = document.documentElement;
  5403. 853.  -     var ch = window.innerHeight || docEl.clientHeight || bodyNode.clientHeight;
  5404. 854.  -     var st = scrollGetY();
  5405. 855.  -     if (!cur.pageEnd) {
  5406. 856.  -       return;
  5407. 857.  -     }
  5408. 858.  -     if (st + ch > cur.pageEnd.offsetTop) {
  5409. 859.  -       setTimeout(function() {
  5410. 860.  -         Video.showMore();
  5411. 861.  -       }, 0);
  5412. 862.  -     }
  5413. 863.  -   },
  5414. 864.  -   showMore: function() {
  5415. 865.  -     var sec = cur.vSection;
  5416. 866.  -     if (sec == 'search') {
  5417. 867.  -       if (cur.vStr) {
  5418. 868.  -         sec += '_'+cur.vStr;
  5419. 869.  -       } else {
  5420. 870.  -         sec = 'all';
  5421. 871.  -       }
  5422. 872.  -       if (cur.vHD) {
  5423. 873.  -         sec += '_opt_hd'+cur.vHD;
  5424. 874.  -       }
  5425. 875.  -     }
  5426. 876.  -     if (sec == 'comments' || sec == 'recommendations') {
  5427. 877.  -       if (cur.shown < cur[sec + 'Count']) {
  5428. 878.  -         this.loadSection(sec, cur.shown);
  5429. 879.  -         addClass(cur.more, 'load_more');
  5430. 880.  -         show(cur.more);
  5431. 881.  -         return;
  5432. 882.  -       }
  5433. 883.  -     }
  5434. 884.  -
  5435. 885.  -     var list = cur.videoList[sec];
  5436. 886.  -     if (!list) {
  5437. 887.  -       return;
  5438. 888.  -     }
  5439. 889.  -     var usersLen = list.length;
  5440. 890.  -
  5441. 891.  -     var added = false;
  5442. 892.  -
  5443. 893.  -     //var listLen = usersLen + searchCount;
  5444. 894.  -     var limit = cur.shown + cur.perPage;
  5445. 895.  -     if (usersLen < limit) {
  5446. 896.  -       limit = usersLen;
  5447. 897.  -     }
  5448. 898.  -     if (cur.vSection == 'tagged' || cur.vSection == 'uploaded') {
  5449. 899.  -       var linkAddr = '?'+cur.vSection+'='+cur.oid;
  5450. 900.  -     } else {
  5451. 901.  -       var linkAddr = '';
  5452. 902.  -     }
  5453. 903.  -     var linkAddr = '?section='+cur.vSection
  5454. 904.  -     for (var i = cur.shown; i < limit; i++) {
  5455. 905.  -       cur.vRows.appendChild(se(this.drawVideo(list[i], linkAddr)));
  5456. 906.  -       cur.shown++;
  5457. 907.  -       added = true;
  5458. 908.  -     }
  5459. 909.  -     if (cur.cansort) {
  5460. 910.  -       qsorter.added(cur.vRows);
  5461. 911.  -     }
  5462. 912.  -
  5463. 913.  -     if (cur.vSection == 'search' && cur.vStr) { // search
  5464. 914.  -       var hd = cur.vHD ? cur.vHD : 0;
  5465. 915.  -       var searchData = cur.searchData[cur.vStr+hd.toString()+cur.vOrder.toString()];
  5466. 916.  -
  5467. 917.  -       var searchCount = (searchData) ? searchData.count : 0;
  5468. 918.  -       var searchLen = (searchData) ? searchData.list.length : 0;
  5469. 919.  -       if (!cur.loading && cur.vStr && searchLen < searchCount && cur.shown + cur.perPage/* + 20*/ > searchLen) {
  5470. 920.  -         cur.loading = true;
  5471. 921.  -         this.loadFromSearch(cur.vStr);
  5472. 922.  -         //show(cur.more);
  5473. 923.  -         addClass(cur.more, 'load_more');
  5474. 924.  -       }
  5475. 925.  -
  5476. 926.  -       if (cur.shown >= usersLen) {
  5477. 927.  -         var startPos = cur.shown - usersLen;
  5478. 928.  -         //if (startPos < searchLen) {
  5479. 929.  -           for (var i = startPos; i < searchLen; i++) {
  5480. 930.  -             cur.vSearchRows.appendChild(se(this.drawVideo(searchData.list[i], linkAddr)));
  5481. 931.  -             cur.shown++;
  5482. 932.  -             added = true;
  5483. 933.  -           }
  5484. 934.  -         //}
  5485. 935.  -       }
  5486. 936.  -       if (usersLen + searchCount > cur.shown && !searchData.ended) {
  5487. 937.  -         show(cur.more);
  5488. 938.  -       } else {
  5489. 939.  -         hide(cur.more);
  5490. 940.  -       }
  5491. 941.  -     } else {
  5492. 942.  -       if (cur.silent && cur.shown == limit && cur.shown < cur.videoCount) {
  5493. 943.  -         addClass(cur.more, 'load_more');
  5494. 944.  -         show(cur.more);
  5495. 945.  -       } else if (usersLen > cur.shown) {
  5496. 946.  -         show(cur.more);
  5497. 947.  -       } else {
  5498. 948.  -         hide(cur.more);
  5499. 949.  -       }
  5500. 950.  -     }
  5501. 951.  -
  5502. 952.  -     if (cur.updateSorter) {
  5503. 953.  -       added = true;
  5504. 954.  -       delete cur.updateSorter;
  5505. 955.  -     }
  5506. 956.  -
  5507. 957.  -     if (added && cur.editmode) {
  5508. 958.  -       setTimeout(function() {
  5509. 959.  -         VideoEdit.onAdding();
  5510. 960.  -       }, 0);
  5511. 961.  -     }
  5512. 962.  -   },
  5513. 963.  -   drawVideo: function(video, linkAddr) {
  5514. 964.  -     v = video.slice();
  5515. 965.  -     if (cur.selection) {
  5516. 966.  -       v[3] = v[3].replace(cur.selection.re, cur.selection.val);
  5517. 967.  -     }
  5518. 968.  -     return cur.videoTpl(v, (v[11].substr(0, 1) != '_') ? ' video_can_edit' : '');
  5519. 969.  -   },
  5520. 970.  -   updateList: function(e, obj) {
  5521. 971.  -     if (e.keyCode == 27) {
  5522. 972.  -       return Video.searchVideos(false);
  5523. 973.  -     }
  5524. 974.  -     clearTimeout(cur.searchTimeout);
  5525. 975.  -     setTimeout((function() {
  5526. 976.  -       var str = trim(obj.value);
  5527. 977.  -       if (str != cur.vStr) {
  5528. 978.  -         this.searchVideos(str);
  5529. 979.  -       }
  5530. 980.  -     }).bind(this), 10);
  5531. 981.  -   },
  5532. 982.  -   recache: function(videoRaw) {
  5533. 983.  -     if (!videoRaw && window.mvcur && mvcur.mvData.videoRaw) {
  5534. 984.  -       videoRaw = mvcur.mvData.videoRaw;
  5535. 985.  -     }
  5536. 986.  -     delete ajaxCache['/al_video.php#act=show&list=&module=video&video=' + videoRaw];
  5537. 987.  -     delete ajaxCache['/al_video.php#act=show&autoplay=1&list=&module=video&video=' + videoRaw];
  5538. 988.  -   },
  5539. 989.  -   loadSection: function(section, offset) {
  5540. 990.  -     if (cur[section+'Loading']) {
  5541. 991.  -       return;
  5542. 992.  -     }
  5543. 993.  -     cur[section+'Loading'] = true;
  5544. 994.  -     if (offset == 0) {
  5545. 995.  -       addClass(ge('video_section_' + section), 'loading');
  5546. 996.  -       cur.vSection = section;
  5547. 997.  -     }
  5548. 998.  -     var params = {
  5549. 999.  -       act: 'load_section_'+section,
  5550. 1000.  -       oid: cur.oid,
  5551. 1001.  -       offset: offset
  5552. 1002.  -     };
  5553. 1003.  -     if (section == 'recommendations' && nav.objLoc.like) {
  5554. 1004.  -       params['like'] = nav.objLoc.like;
  5555. 1005.  -     }
  5556. 1006.  -     ajax.post('al_video.php', params, {
  5557. 1007.  -       onDone: function(count, shown, data, curExt) {
  5558. 1008.  -         if (curExt) {
  5559. 1009.  -           extend(cur, curExt);
  5560. 1010.  -         }
  5561. 1011.  -         if (offset == 0) {
  5562. 1012.  -           Video.clearOutput();
  5563. 1013.  -           cur[section + 'Count'] = count;
  5564. 1014.  -           removeClass(ge('video_section_' + section), 'loading');
  5565. 1015.  -         }
  5566. 1016.  -         removeClass(cur.more, 'load_more');
  5567. 1017.  -         hide(cur.more);
  5568. 1018.  -         cur.shown = shown;
  5569. 1019.  -         var cont = ce('div', {
  5570. 1020.  -           innerHTML: data
  5571. 1021.  -         });
  5572. 1022.  -         cur.vRows.appendChild(cont);
  5573. 1023.  -         Video.changeSummary();
  5574. 1024.  -         Video.onSwitchTabs(section);
  5575. 1025.  -         if (cur.cansort) {
  5576. 1026.  -           qsorter.update(cur.vRows, {dragEls: geByClass('video_album_candrop', cur.albumsCont)});
  5577. 1027.  -         }
  5578. 1028.  -         if (offset == 0 && shown == 0 && section != 'comments') {
  5579. 1029.  -           show(cur.notFound);
  5580. 1030.  -         }
  5581. 1031.  -         delete cur[section+'Loading'];
  5582. 1032.  -       },
  5583. 1033.  -
  5584. 1034.  -       onFail: function() {
  5585. 1035.  -         delete cur[section+'Loading'];
  5586. 1036.  -       },
  5587. 1037.  -       showProgress: function() {
  5588. 1038.  -         show('video_tabs_progress');
  5589. 1039.  -         hide('video_tabs_link');
  5590. 1040.  -       },
  5591. 1041.  -       hideProgress: function() {
  5592. 1042.  -         hide('video_tabs_progress');
  5593. 1043.  -         var num = 0;
  5594. 1044.  -         for(var i in cur.sections) num += 1;
  5595. 1045.  -         if (!num) {
  5596. 1046.  -           show('video_tabs_link');
  5597. 1047.  -         }
  5598. 1048.  -       }
  5599. 1049.  -     });
  5600. 1050.  -   },
  5601. 1051.  -   loadFrom: function(url, params, section) {
  5602. 1052.  -     addClass(ge('video_section_'+section), 'loading');
  5603. 1053.  -     cur.vSection = section;
  5604. 1054.  -     // pass
  5605. 1055.  -     ajax.post(url, params, {onDone: (function(count, data, obj) {
  5606. 1056.  -       removeClass(ge('video_section_'+section), 'loading');
  5607. 1057.  -       if (obj) {
  5608. 1058.  -         extend(cur, obj);
  5609. 1059.  -       }
  5610. 1060.  -       cur.vSection = section;
  5611. 1061.  -       data = eval('('+data+')');
  5612. 1062.  -       cur.videoList[section] = data;
  5613. 1063.  -       if (cur.vSection == section) {
  5614. 1064.  -         this.clearOutput();
  5615. 1065.  -         this.showMore();
  5616. 1066.  -         if (cur.canEditAlbums && cur.albumsSorter && !(trim(cur.vStr) && cur.vStr != '""')) {
  5617. 1067.  -           qsorter.update(cur.albumsCont);
  5618. 1068.  -         }
  5619. 1069.  -         if (cur.cansort) {
  5620. 1070.  -           qsorter.update(cur.vRows, {dragEls: geByClass('video_album_candrop', cur.albumsCont)});
  5621. 1071.  -         }
  5622. 1072.  -         this.changeSummary();
  5623. 1073.  -         this.onSwitchTabs(section);
  5624. 1074.  -       }
  5625. 1075.  -     }).bind(this)})
  5626. 1076.  -
  5627. 1077.  -   },
  5628. 1078.  -   filter: function(cond, list) {
  5629. 1079.  -     var all = cur.videoList['all'];
  5630. 1080.  -     var len = all.length;
  5631. 1081.  -     var result = [];
  5632. 1082.  -     for (var i = 0; i < len; i++) {
  5633. 1083.  -       var obj = all[i];
  5634. 1084.  -       if (cond(obj)) {
  5635. 1085.  -         result.push(obj);
  5636. 1086.  -       }
  5637. 1087.  -     }
  5638. 1088.  -     cur.videoList[list] = result;
  5639. 1089.  -
  5640. 1090.  -     len = result.length;
  5641. 1091.  -     return result;
  5642. 1092.  -   },
  5643. 1093.  -   clearSearch: function() {
  5644. 1094.  -     cur.selection = false;
  5645. 1095.  -     cur.vSearch.setValue('');
  5646. 1096.  -   },
  5647. 1097.  -   generateList: function(section) {
  5648. 1098.  -     if (!section) return;
  5649. 1099.  -     if (section == 'uploaded') {
  5650. 1100.  -       this.filter(function(obj) {
  5651. 1101.  -         return obj[8];
  5652. 1102.  -       }, section);
  5653. 1103.  -       this.onSwitchTabs(section);
  5654. 1104.  -     } else if (section == 'tagged') {
  5655. 1105.  -       this.loadFrom('al_video.php', {act: 'get_tagged_video', mid: cur.oid}, section);
  5656. 1106.  -       return false;
  5657. 1107.  -     } else if (section == 'recommendations') {
  5658. 1108.  -       this.loadSection(section, 0);
  5659. 1109.  -       return false;
  5660. 1110.  -     } else if (section == 'comments') {
  5661. 1111.  -       stManager.add(['videoview.js'], (function() {
  5662. 1112.  -         this.loadSection(section, 0);
  5663. 1113.  -       }).bind(this));
  5664. 1114.  -       return false;
  5665. 1115.  -     } else if (section.substr(0, 6) == 'album_') {
  5666. 1116.  -       var album = parseInt(section.substr(6));
  5667. 1117.  -       this.filter(function(obj) {
  5668. 1118.  -         return obj[6] == album;
  5669. 1119.  -       }, section);
  5670. 1120.  -       this.onSwitchTabs(section);
  5671. 1121.  -     }
  5672. 1122.  -     return true;
  5673. 1123.  -   },
  5674. 1124.  -   section: function(section) {
  5675. 1125.  -     if (!section) {
  5676. 1126.  -       section = 'all';
  5677. 1127.  -     }
  5678. 1128.  -
  5679. 1129.  -     if (cur.silent && section != 'tagged' && section != 'comments') {
  5680. 1130.  -       cur.onSilentLoad = function() {
  5681. 1131.  -         Video.section(section);
  5682. 1132.  -       }
  5683. 1133.  -       Video.clearOutput();
  5684. 1134.  -       cur.vRows.innerHTML = '<div id="video_wide_loading" class="wide_loading"></div>';
  5685. 1135.  -       hide(cur.more);
  5686. 1136.  -       cur.vSection = section;
  5687. 1137.  -       return true;
  5688. 1138.  -     }
  5689. 1139.  -     if (section != 'search') {
  5690. 1140.  -       this.clearSearch();
  5691. 1141.  -       hide('video_addition_options', 'video_sort_dd', 'video_external_dd_wrap');
  5692. 1142.  -     } else {
  5693. 1143.  -       if (cur.vStr) {
  5694. 1144.  -         cur.vSearch.setValue(cur.vStr);
  5695. 1145.  -       }
  5696. 1146.  -       if (!cur.editmode) {
  5697. 1147.  -         show('video_addition_options', 'video_sort_dd', 'video_external_dd_wrap');
  5698. 1148.  -       } else {
  5699. 1149.  -         hide('video_addition_options', 'video_sort_dd', 'video_external_dd_wrap');
  5700. 1150.  -       }
  5701. 1151.  -     }
  5702. 1152.  -
  5703. 1153.  -     /*if (section != 'all') {
  5704. 1154.  -       addClass(ge('video_content'), 'video_albums_hidden');
  5705. 1155.  -     } else {
  5706. 1156.  -       removeClass(ge('video_content'), 'video_albums_hidden');
  5707. 1157.  -     }*/
  5708. 1158.  -
  5709. 1159.  -     if (!cur.videoList[section]) {
  5710. 1160.  -       if (!this.generateList(section)) {
  5711. 1161.  -         return;
  5712. 1162.  -       }
  5713. 1163.  -     }
  5714. 1164.  -     /*if (!cur.videoCount[section] && cur.videoList[section]) {
  5715. 1165.  -       var len = cur.videoList[section].length;
  5716. 1166.  -       cur.videoCount[section] = [len, len, 0];
  5717. 1167.  -     }*/
  5718. 1168.  -     cur.vSection = section;
  5719. 1169.  -     this.clearOutput();
  5720. 1170.  -     this.showMore();
  5721. 1171.  -     if (cur.cansort) {
  5722. 1172.  -       qsorter.update(cur.vRows, {dragEls: geByClass('video_album_candrop', cur.albumsCont)});
  5723. 1173.  -     }
  5724. 1174.  -     this.changeSummary();
  5725. 1175.  -     if (section != 'search' || !cur.vStr) {
  5726. 1176.  -       removeClass(ge('video_reset_search'), 'video_reset_search_shown');
  5727. 1177.  -       Video.hideOptions();
  5728. 1178.  -     } else {
  5729. 1179.  -       addClass(ge('video_reset_search'), 'video_reset_search_shown');
  5730. 1180.  -       Video.showOptions();
  5731. 1181.  -     }
  5732. 1182.  -     this.onSwitchTabs(section);
  5733. 1183.  -     if (cur.canEditAlbums && cur.albumsSorter && !(trim(cur.vStr) && cur.vStr != '""')) {
  5734. 1184.  -       qsorter.update(cur.albumsCont);
  5735. 1185.  -     }
  5736. 1186.  -   },
  5737. 1187.  -   onSwitchTabs: function(section) {
  5738. 1188.  -     var newTab = ge('video_tab_'+(section == 'search' ? 'all' : section));
  5739. 1189.  -     var oldTab = geByClass1('active_link', ge('video_tabs'));
  5740. 1190.  -     if (newTab != oldTab) {
  5741. 1191.  -       removeClass(oldTab, 'active_link');
  5742. 1192.  -       addClass(newTab, 'active_link');
  5743. 1193.  -     }
  5744. 1194.  -
  5745. 1195.  -     if (section.substr(0, 6) == 'album_' || section == 'tagged' || section == 'comments') {
  5746. 1196.  -       cur.hTab.className = 'active_link';
  5747. 1197.  -       if (section == 'comments') {
  5748. 1198.  -         var tabName = getLang('video_comments_review');
  5749. 1199.  -       } else {
  5750. 1200.  -         var tabName = '';
  5751. 1201.  -         for (var i in cur.sections) {
  5752. 1202.  -           if (cur.sections[i][0] == ((section == 'tagged') ? -1 :  parseInt(section.substr(6)))) {
  5753. 1203.  -             tabName = cur.sections[i][1];
  5754. 1204.  -           }
  5755. 1205.  -
  5756. 1206.  -         }
  5757. 1207.  -       }
  5758. 1208.  -       geByClass1('tab_word', cur.hTab).firstChild.innerHTML = tabName;
  5759. 1209.  -
  5760. 1210.  -       addClass(ge('video_content'), 'video_albums_hidden');
  5761. 1211.  -     } else {
  5762. 1212.  -       cur.hTab.className = 'video_tab_hidden';
  5763. 1213.  -       if (section != 'search') {
  5764. 1214.  -         removeClass(ge('video_content'), 'video_albums_hidden');
  5765. 1215.  -       }
  5766. 1216.  -     }
  5767. 1217.  -     toggleClass(ge('video_rows'), 'wall_module', section == 'comments');
  5768. 1218.  -     if (cur.sorter) {
  5769. 1219.  -       cur.sorter.updateDragCont();
  5770. 1220.  -     }
  5771. 1221.  -   },
  5772. 1222.  -   showAlbums: function(obj) {
  5773. 1223.  -     while (ge('video_albums_more') && ge('video_albums_more').firstChild) {
  5774. 1224.  -       var el = ge('video_albums_more').firstChild;
  5775. 1225.  -       ge('video_albums_wrap').appendChild(el);
  5776. 1226.  -     }
  5777. 1227.  -     hide(obj);
  5778. 1228.  -     if (cur.canEditAlbums && cur.albumsSorter && !(trim(cur.vStr) && cur.vStr != '""')) {
  5779. 1229.  -       qsorter.added(cur.albumsCont);
  5780. 1230.  -     }
  5781. 1231.  -     if (cur.cansort) {
  5782. 1232.  -       qsorter.update(cur.vRows, {dragEls: geByClass('video_album_candrop', cur.albumsCont)});
  5783. 1233.  -     }
  5784. 1234.  -   },
  5785. 1235.  -   deleteAlbum: function(section, ev) {
  5786. 1236.  -     showBox('al_video.php', {act: 'delete_album', aid: section.substr(6), oid: cur.oid}, {dark: 1});
  5787. 1237.  -     return cancelEvent(ev);
  5788. 1238.  -   },
  5789. 1239.  -   editAlbum: function(aid, ev) {
  5790. 1240.  -     showBox('al_video.php', {act: 'edit_album', oid: cur.oid, aid: aid, oid: cur.oid}, {dark: 1});
  5791. 1241.  -     return cancelEvent(ev);
  5792. 1242.  -   },
  5793. 1243.  -   createAlbum: function() {
  5794. 1244.  -     showBox('al_video.php', {act: 'edit_album', oid: cur.oid}, {dark: 1});
  5795. 1245.  -   },
  5796. 1246.  -   uploadVideoBox: function() {
  5797. 1247.  -     if (cur.uploadBanned) {
  5798. 1248.  -       setTimeout(showFastBox({title: getLang('video_no_upload_title'), dark: 1}, getLang('video_claims_no_upload')).hide, 5000);
  5799. 1249.  -       return false;
  5800. 1250.  -     }
  5801. 1251.  -     var box = showTabbedBox('al_video.php', {act: 'upload_box', oid: cur.oid}, {stat: ['video_edit.css', 'privacy.css', 'privacy.js'], params: {bodyStyle: 'position: relative;', dark: 1}});
  5802. 1252.  -     return false;
  5803. 1253.  -   },
  5804. 1254.  -   removeAllTags: function() {
  5805. 1255.  -     showBox('al_video.php', {act: 'remove_all_tags_box'}, {dark: 1});
  5806. 1256.  -   },
  5807. 1257.  -
  5808. 1258.  -   xRow: function(event, opacity, row, hint) {
  5809. 1259.  -     if (hint) showTooltip(row, {text: hint, showdt: 500});
  5810. 1260.  -     animate(hasClass(row, 'video_close') ? row : geByClass1('video_close', row), {opacity: opacity}, 200);
  5811. 1261.  -     return cancelEvent(event);
  5812. 1262.  -   },
  5813. 1263.  -
  5814. 1264.  -   removeRecomm: function(obj) {
  5815. 1265.  -     var el = obj.parentNode;
  5816. 1266.  -     while(el && !hasClass(el, 'video_row_cont')) {
  5817. 1267.  -       el = el.parentNode;
  5818. 1268.  -     }
  5819. 1269.  -     if (!el) return;
  5820. 1270.  -     slideUp(el, 50);
  5821. 1271.  -     ajax.post('al_video.php', {act: 'hide_recommendation', video: el.id.substr(9), hash: cur.hash});
  5822. 1272.  -   },
  5823. 1273.  -   albumOver: function(obj) {
  5824. 1274.  -     if (cur.canEditAlbums && obj.id.split('_')[2] > 0) {
  5825. 1275.  -       Video.activate(geByClass1('video_album_controls', obj));
  5826. 1276.  -     }
  5827. 1277.  -   },
  5828. 1278.  -   albumOut: function(obj) {
  5829. 1279.  -     if (cur.canEditAlbums) {
  5830. 1280.  -       Video.deactivate(geByClass1('video_album_controls', obj), 0);
  5831. 1281.  -     }
  5832. 1282.  -   },
  5833. 1283.  -
  5834. 1284.  -   addFromList: function(videoRaw, hash, ev) {
  5835. 1285.  -     var videoCont = ge('video_cont'+videoRaw);
  5836. 1286.  -     if (hasClass(videoCont, 'video_row_added')) {
  5837. 1287.  -       return cancelEvent(ev);
  5838. 1288.  -     }
  5839. 1289.  -     videoview.addVideo(videoRaw, hash, false, false, false, 'list');
  5840. 1290.  -       var videoEl = geByClass1('video_row_icon_add', videoCont);
  5841. 1291.  -       if (videoEl && videoEl.tt) {
  5842. 1292.  -         videoEl.tt.hide();
  5843. 1293.  -       }
  5844. 1294.  -     return cancelEvent(ev);
  5845. 1295.  -   },
  5846. 1296.  -
  5847. 1297.  -   rowOver: function(obj) {
  5848. 1298.  -     var animEl = geByClass1((hasClass(obj.parentNode, 'video_can_edit')) ? 'video_row_controls' :  'video_row_add', obj);
  5849. 1299.  -     Video.activate(animEl);
  5850. 1300.  -     if (hasClass(obj, 'video_row_overed')) {
  5851. 1301.  -       return;
  5852. 1302.  -     }
  5853. 1303.  -     addClass(obj, 'video_row_overed')
  5854. 1304.  -     var line = geByClass1('video_row_info_line', obj);
  5855. 1305.  -     var name = geByClass1('video_raw_info_name', obj);
  5856. 1306.  -     var size = getSize(name);
  5857. 1307.  -     var height = Math.max(16, Math.min(size[1], 54));
  5858. 1308.  -     cssAnim(line, {height: height, marginTop: 150 - (height - 16)}, {duration: 200, transition: Fx.Transitions.easeOutCubic});
  5859. 1309.  -   },
  5860. 1310.  -   rowOut: function(obj) {
  5861. 1311.  -     var animEl = geByClass1((hasClass(obj.parentNode, 'video_can_edit')) ? 'video_row_controls' :  'video_row_add', obj);
  5862. 1312.  -     Video.deactivate(animEl, 0);
  5863. 1313.  -     var line = geByClass1('video_row_info_line', obj);
  5864. 1314.  -     removeClass(obj, 'video_row_overed')
  5865. 1315.  -     cssAnim(line, {height: 16, marginTop: 150}, {duration: 200, transition: Fx.Transitions.easeOutCubic});
  5866. 1316.  -   },
  5867. 1317.  -   activate: function(obj, ttLng, check) {
  5868. 1318.  -     animate(obj, {opacity: 1}, 100);
  5869. 1319.  -     if (ttLng) {
  5870. 1320.  -       if (check == 1 && hasClass(obj.parentNode.parentNode.parentNode.parentNode, 'video_row_added')) {
  5871. 1321.  -         return false;
  5872. 1322.  -       }
  5873. 1323.  -       showTooltip(obj, {
  5874. 1324.  -         black: 1,
  5875. 1325.  -         center: 1,
  5876. 1326.  -         shift: [0,2,0],
  5877. 1327.  -         text: getLang('video_'+ttLng)
  5878. 1328.  -       });
  5879. 1329.  -     }
  5880. 1330.  -   },
  5881. 1331.  -   deactivate: function(obj, value) {
  5882. 1332.  -     animate(obj, {opacity: value === undefined ? 0.8 : value}, 100);
  5883. 1333.  -   },
  5884. 1334.  -   albumDragOver: function(el) {
  5885. 1335.  -     fadeOut(geByClass1('video_album_info', el), 200);
  5886. 1336.  -     fadeOut(geByClass1('videos_album_tags', el), 200);
  5887. 1337.  -     var moveEl = geByClass1('videos_album_move', el)
  5888. 1338.  -     if (!moveEl) {
  5889. 1339.  -       moveEl = ce('div', {className: 'videos_album_move'})
  5890. 1340.  -       el.insertBefore(moveEl, el.firstChild);
  5891. 1341.  -     }
  5892. 1342.  -     moveEl.innerHTML = getLang('video_drop_to_move');
  5893. 1343.  -     setStyle(moveEl, {marginTop: getSize(el)[1] / 2 - getSize(moveEl)[1] / 2})
  5894. 1344.  -     fadeIn(moveEl, 200);
  5895. 1345.  -   },
  5896. 1346.  -   albumDragOut: function(el) {
  5897. 1347.  -     fadeIn(geByClass1('video_album_info', el), 200);
  5898. 1348.  -     fadeIn(geByClass1('videos_album_tags', el), 200);
  5899. 1349.  -     fadeOut(geByClass1('videos_album_move', el), 200);
  5900. 1350.  -   },
  5901. 1351.  -   updateVideoAlbum: function(vid, albumId) {
  5902. 1352.  -     var oldAlbum = 0;
  5903. 1353.  -     var list = cur.videoList['all'];
  5904. 1354.  -     for (var i in list) {
  5905. 1355.  -       if (list[i][1] == vid) {
  5906. 1356.  -         oldAlbum = list[i][6];
  5907. 1357.  -         if (oldAlbum == albumId) {
  5908. 1358.  -           return false;
  5909. 1359.  -         }
  5910. 1360.  -         list[i][6] = albumId;
  5911. 1361.  -       }
  5912. 1362.  -     }
  5913. 1363.  -     delete cur.videoList['album_'+oldAlbum];
  5914. 1364.  -     delete cur.videoList['album_'+albumId];
  5915. 1365.  -     if (cur.vSection == 'album_'+oldAlbum) {
  5916. 1366.  -       Video.section('album_'+oldAlbum);
  5917. 1367.  -     }
  5918. 1368.  -   },
  5919. 1369.  -   albumDrop: function(el, obj) {
  5920. 1370.  -     var moveEl = geByClass1('videos_album_move', el)
  5921. 1371.  -     if (moveEl) {
  5922. 1372.  -       moveEl.innerHTML = '<div class="progress_inline progress_inv" style="height: '+(getSize(moveEl)[1] - 16)+'px"></div>';
  5923. 1373.  -     }
  5924. 1374.  -     var videoId = obj.id.replace('video_cont', '').split('_');
  5925. 1375.  -     var oid = videoId[0];
  5926. 1376.  -     var vid = videoId[1];
  5927. 1377.  -     var albumId = el.id.replace('video_album_', '');
  5928. 1378.  -     ajax.post('al_video.php', {act: 'move_to_album', album_id: albumId, hash: cur.moveHash, oid: oid, vid: vid, from: 'list'}, {
  5929. 1379.  -       onDone: function(text, newList) {
  5930. 1380.  -         showDoneBox(text);
  5931. 1381.  -         Video.updateAlbums(newList);
  5932. 1382.  -         /*moveEl.innerHTML = text;
  5933. 1383.  -         setStyle(moveEl, {height: 'auto'});
  5934. 1384.  -         setStyle(moveEl, {marginTop: getSize(el)[1] / 2 - getSize(moveEl)[1] / 2})
  5935. 1385.  -         setTimeout(Video.albumDragOut.pbind(el), 3000);*/
  5936. 1386.  -         Video.updateVideoAlbum(vid, albumId);
  5937. 1387.  -       }
  5938. 1388.  -     });
  5939. 1389.  -     return true;
  5940. 1390.  -   },
  5941. 1391.  -   showOptions: function() {
  5942. 1392.  -     if (cur.shownOptions) return;
  5943. 1393.  -     cur.shownOptions = true;
  5944. 1394.  -     addClass(cur.videoSearch, 'video_search_extended');
  5945. 1395.  -   },
  5946. 1396.  -   hideOptions: function() {
  5947. 1397.  -     if (!cur.shownOptions) return;
  5948. 1398.  -     cur.shownOptions = false;
  5949. 1399.  -     removeClass(cur.videoSearch, 'video_search_extended');
  5950. 1400.  -   }
  5951. 1401.  - }
  5952. 1402.  -
  5953. 1403.  - try{stManager.done('video.js');}catch(e){}
  5954. ------
  5955. Файл - groups_list.js (Старый размер - 35510 | Новый - 0):
  5956. 0.  - var GroupsList = {
  5957. 1.  -   rand: function() {
  5958. 2.  -     return Math.floor(Math.random() * 10000);
  5959. 3.  -   },
  5960. 4.  -   enter: function(el, gid, hash, act, past) {
  5961. 5.  -     if (cur.invSwitching) {
  5962. 6.  -       setTimeout(GroupsList.enter.pbind(el, gid, hash, act, past), 100);
  5963. 7.  -       return false;
  5964. 8.  -     }
  5965. 9.  -     var sp, hp, tab = cur.scrollList.tab;
  5966. 10.  -
  5967. 11.  -     if (el.tagName.toLowerCase() != 'button') {
  5968. 12.  -       if (!el.backhtml) {
  5969. 13.  -         el.backhtml = el.innerHTML;
  5970. 14.  -       }
  5971. 15.  -       sp = function() {
  5972. 16.  -         var w = getSize(el)[0];
  5973. 17.  -         el.innerHTML = '<span class="progress_inline"></span>';
  5974. 18.  -         setStyle(el, {width: w - 30});
  5975. 19.  -       }
  5976. 20.  -       hp = function() {
  5977. 21.  -         el.innerHTML = el.backhtml;
  5978. 22.  -       }
  5979. 23.  -     } else {
  5980. 24.  -       sp = lockButton.pbind(el);
  5981. 25.  -       hp = unlockButton.pbind(el);
  5982. 26.  -     }
  5983. 27.  -
  5984. 28.  -     var key = GroupsList.rand(), value = GroupsList.rand();
  5985. 29.  -     cur.scrollList[key] = value;
  5986. 30.  -
  5987. 31.  -     var context = (cur.scrollList.tab == 'groups') ? '2' : '1';
  5988. 32.  -
  5989. 33.  -     var shown = false;
  5990. 34.  -     cur.invSwitching = true;
  5991. 35.  -     if (GroupsList.switchInvite(gid, (act == 'decline' && !past))) {
  5992. 36.  -       shown = true;
  5993. 37.  -       sp = false;
  5994. 38.  -       hp = false;
  5995. 39.  -     }
  5996. 40.  -
  5997. 41.  -     ajax.post('al_groups.php', {
  5998. 42.  -       act: 'enter',
  5999. 43.  -       gid: gid,
  6000. 44.  -       hash: hash,
  6001. 45.  -       context: context + (act ? '_' + act : ''),
  6002. 46.  -       inv_shown: cur.scrollList.invShown
  6003. 47.  -     }, {
  6004. 48.  -       onDone: function(newRow, added) {
  6005. 49.  -         cur.invSwitching = false;
  6006. 50.  -         if (!cur.scrollList || cur.scrollList[key] != value) return;
  6007. 51.  -
  6008. 52.  -         var list = cur.scrollList.lists[tab], newStatus = past ? 5 : 1;
  6009. 53.  -         if (act == 'unsure') {
  6010. 54.  -           newStatus = past ? 5 : 3;
  6011. 55.  -         } else if (act == 'decline') {
  6012. 56.  -           newStatus = past ? -3 : -1;
  6013. 57.  -         } else if (act == 'undecided') {
  6014. 58.  -           newStatus = 4;
  6015. 59.  -         }
  6016. 60.  -         if (!list || list == 'loading' || list == 'update') {
  6017. 61.  -           cur.scrollList.processed[tab][gid] = newStatus;
  6018. 62.  -         } else {
  6019. 63.  -           for (var i = 0, count = list.length; i < count; ++i) {
  6020. 64.  -             if (list[i][2] == gid) {
  6021. 65.  -               list[i][1] = newStatus;
  6022. 66.  -             }
  6023. 67.  -           }
  6024. 68.  -         }
  6025. 69.  -
  6026. 70.  -         var row = ge('gl_' + tab + gid);
  6027. 71.  -
  6028. 72.  -         GroupsList.addInvite(newRow, added, act);
  6029. 73.  -
  6030. 74.  -         var rowEl = geByClass1('group_list_row', ge('groups_list_content'));
  6031. 75.  -         if (rowEl && rowEl.id == 'gl_' + tab + gid) {
  6032. 76.  -           setStyle(rowEl, {backgroundColor: '#FEFAE4'});
  6033. 77.  -           animate(rowEl, {backgroundColor: '#FFF'}, 2000);
  6034. 78.  -         }
  6035. 79.  -
  6036. 80.  -         if (shown) {
  6037. 81.  -           if (cur.switchedInvite && act == 'decline' && !past) {
  6038. 82.  -             var switchedHtml = getLang('groups_event_left') + ' <a onclick="GroupsList.spam(this.parentNode, ' + gid + ', \'' + hash + '\', cur.switchedInvite)">' + getLang('its_spam') + '</a>';
  6039. 83.  -             if (ge('clubinv' + gid)) switchedHtml += '<div class="group_row_blockinv"><a onclick="GroupsList.spam(domPN(domPN(this)), ' + gid + ', \'' + hash + '\', cur.switchedInvite, 1)">' + getLang('groups_block_clubinv').replace('{club}', '<b>' + val(domPS(ge('clubinv' + gid))) + '</b>') + '</a></div>';
  6040. 84.  -             cur.switchedInvite.innerHTML = switchedHtml;
  6041. 85.  -           }
  6042. 86.  -           return;
  6043. 87.  -         }
  6044. 88.  -
  6045. 89.  -         if (!row) return;
  6046. 90.  -
  6047. 91.  -         var status = geByClass1('group_row_status', row), actions = geByClass1('group_row_actions', row), old = status.basehtml;
  6048. 92.  -         var actOld = actions.basehtml;
  6049. 93.  -         status.basehtml = status.innerHTML;
  6050. 94.  -         actions.basehtml = actions.innerHTML;
  6051. 95.  -         if (act == 'undecided') {
  6052. 96.  -           actions.innerHTML = actOld || '';
  6053. 97.  -           status.innerHTML = old || '\
  6054. 98.  - <div class="group_row_buttons">\
  6055. 99.  -   <div class="group_row_button button_blue fl_l">\
  6056. 100.  -     <button onclick="GroupsList.enter(this, ' + gid + ', \'' + hash + '\', \'join\')">' + getLang('groups_event_go_btn') + '</button>\
  6057. 101.  -   </div>\
  6058. 102.  -   <div class="group_row_button button_blue fl_l">\
  6059. 103.  -     <button onclick="GroupsList.enter(this, ' + gid + ', \'' + hash + '\', \'unsure\')">' + getLang('groups_event_maybe_btn') + '</button>\
  6060. 104.  -   </div>\
  6061. 105.  -   <div class="group_row_button button_cancel fl_l">\
  6062. 106.  -     <div class="button" onclick="GroupsList.enter(this, ' + gid + ', \'' + hash + '\', \'decline\')">' + getLang('groups_event_cant_btn') + '</div>\
  6063. 107.  -   </div>\
  6064. 108.  - </div>';
  6065. 109.  -         } else if (act) {
  6066. 110.  -           if (past) {
  6067. 111.  -             var statHTML = getLang('groups_was_on_event');
  6068. 112.  -             if (act == 'decline') {
  6069. 113.  -               actions.innerHTML = '<a onclick="GroupsList.enter(this.parentNode, ' + gid + ', \'' + hash + '\', \'join\', true)">' + getLang('groups_return_event') + '</a>';
  6070. 114.  -             } else {
  6071. 115.  -               actions.innerHTML = '<a onclick="GroupsList.enter(this.parentNode, ' + gid + ', \'' + hash + '\', \'decline\', true)">' + getLang('groups_remove_event') + '</a>';
  6072. 116.  -             }
  6073. 117.  -           } else {
  6074. 118.  -             var acts = '<a onclick="GroupsList.enter(this.parentNode, ' + gid + ', \'' + hash + '\', \'undecided\')">' + getLang('groups_event_change') + '</a>';
  6075. 119.  -             if (act == 'unsure') {
  6076. 120.  -               var statHTML = getLang('groups_unsure_event');
  6077. 121.  -             } else if (act == 'decline') {
  6078. 122.  -               var statHTML = getLang('groups_event_left');
  6079. 123.  -               acts += '<span class="divider">|</span><a onclick="GroupsList.spam(this.parentNode, ' + gid + ', \'' + hash + '\')">' + getLang('its_spam') + '</a>';
  6080. 124.  -               if (ge('clubinv' + gid)) acts += '<div class="group_row_blockinv"><a onclick="GroupsList.spam(domPN(domPN(this)), ' + gid + ', \'' + hash + '\', false, 1)">' + getLang('groups_block_clubinv').replace('{club}', '<b>' + val(domPS(ge('clubinv' + gid))) + '</b>') + '</a></div>';
  6081. 125.  -             } else {
  6082. 126.  -               var statHTML = getLang('groups_you_in_event');
  6083. 127.  -             }
  6084. 128.  -             actions.innerHTML = acts;
  6085. 129.  -           }
  6086. 130.  -           status.innerHTML = '<div class="groups_acted_text">'+statHTML+'</div>';
  6087. 131.  -           cur.lst = status;
  6088. 132.  -         } else {
  6089. 133.  -           status.innerHTML = '<div class="groups_acted_text">'+getLang('groups_group_enter_message')+'</div>';
  6090. 134.  -           actions.innerHTML = '<a onclick="GroupsList.cancel(this.parentNode, ' + gid + ', \'' + hash + '\')">' + getLang('global_cancel') + '</a>';
  6091. 135.  -         }
  6092. 136.  -
  6093. 137.  -         if (tab == 'inv') {
  6094. 138.  -           var row = ge('gl_groups'+ gid);
  6095. 139.  -           if (row) {
  6096. 140.  -             var statusOne = geByClass1('group_row_status', row), actionsOne = geByClass1('group_row_actions', row);
  6097. 141.  -             statusOne.innerHTML = status.innerHTML;
  6098. 142.  -             actionsOne.innerHTML = actions.innerHTML;
  6099. 143.  -           }
  6100. 144.  -         }
  6101. 145.  -         if (act == 'join' || act == 'unsure') {
  6102. 146.  -           GroupsList.updateEventsList(gid);
  6103. 147.  -         } else if (act == 'undecided') {
  6104. 148.  -           GroupsList.updateEventsList(false);
  6105. 149.  -         }
  6106. 150.  -         /*var list = cur.scrollList.lists[tab];
  6107. 151.  -         if (act == 'join' || act == 'unsure' || act == 'decline') {
  6108. 152.  -           GroupsList.updateEventsList();
  6109. 153.  -           for(var i in list) {
  6110. 154.  -             if (list[i][2] == gid) {
  6111. 155.  -               cur['gid_restore_el'+gid] = [list.splice(i, 1), i];
  6112. 156.  -             }
  6113. 157.  -           }
  6114. 158.  -         } else if (act == 'undecided' && cur['gid_restore_el'+gid]) {
  6115. 159.  -           list.splice(cur['gid_restore_el'+gid][1], 0, cur['gid_restore_el'+gid][0][0]);
  6116. 160.  -         }*/
  6117. 161.  -       },
  6118. 162.  -       onFail: function(text) {
  6119. 163.  -         if (text) {
  6120. 164.  -           setTimeout(showFastBox(getLang('global_error'), text).hide, 3000);
  6121. 165.  -           return true;
  6122. 166.  -         }
  6123. 167.  -       },
  6124. 168.  -       showProgress: sp, hideProgress: hp
  6125. 169.  -     });
  6126. 170.  -   },
  6127. 171.  -
  6128. 172.  -   addInvite: function(newRow, added, act) {
  6129. 173.  -     if (newRow) {
  6130. 174.  -       var moreCont = ge('gle_invites_more');
  6131. 175.  -       moreCont.appendChild(se(newRow));
  6132. 176.  -       cur.scrollList.invShown += 1;
  6133. 177.  -       if (cur.scrollList.invSwitchGid) {
  6134. 178.  -         GroupsList.switchInvite(cur.scrollList.invSwitchGid);
  6135. 179.  -         cur.scrollList.invSwitchGid = false;
  6136. 180.  -       }
  6137. 181.  -     }
  6138. 182.  -
  6139. 183.  -     if (added && cur.scrollList.lists.groups) {
  6140. 184.  -       var l = cur.scrollList.lists.groups;
  6141. 185.  -       if (act == 'join' || act == 'unsure') {;
  6142. 186.  -         l.push(added);
  6143. 187.  -       } else if (!act) {
  6144. 188.  -         l.unshift(added); // add to the start
  6145. 189.  -       } else if (act == 'undecided') {
  6146. 190.  -         for (var i in l) {
  6147. 191.  -           if (l[i][2] == added[2]) {
  6148. 192.  -             l.splice(i, 1)
  6149. 193.  -           }
  6150. 194.  -         }
  6151. 195.  -       }
  6152. 196.  -       cur.scrollList.cache['groups'] = {all: []};
  6153. 197.  -       var c = cur.scrollList.cache['groups'];
  6154. 198.  -       for (var i in l) {
  6155. 199.  -         c.all.push(i);
  6156. 200.  -       }
  6157. 201.  -       cur.scrollList.index['groups'] = new vkIndexer(c.all, function(obj) {
  6158. 202.  -         return l[obj][0];
  6159. 203.  -       });
  6160. 204.  -       GroupsList.showMore(true);
  6161. 205.  -     }
  6162. 206.  -   },
  6163. 207.  -
  6164. 208.  -   switchInvite: function(gid, prepareActs) {
  6165. 209.  -     var tab = cur.scrollList.tab;
  6166. 210.  -     if (tab != 'groups') {
  6167. 211.  -       return false;
  6168. 212.  -     }
  6169. 213.  -
  6170. 214.  -     var row = ge('gl_' + tab + gid);
  6171. 215.  -
  6172. 216.  -     var moreCont = ge('gle_invites_more');
  6173. 217.  -     var newRows = moreCont.childNodes;
  6174. 218.  -     if (!newRows.length) {
  6175. 219.  -       if (cur.scrollList.invShown < cur.scrollList.invCount) {
  6176. 220.  -         cur.scrollList.invSwitchGid = gid;
  6177. 221.  -         return true;
  6178. 222.  -       }
  6179. 223.  -       return false;
  6180. 224.  -     }
  6181. 225.  -     var newRow = newRows[0];
  6182. 226.  -
  6183. 227.  -     if (!newRow) {
  6184. 228.  -       return false;
  6185. 229.  -     }
  6186. 230.  -
  6187. 231.  -     if (cur.switchedInvite) {
  6188. 232.  -       slideUp(cur.switchedInvite);
  6189. 233.  -     }
  6190. 234.  -     if (prepareActs) {
  6191. 235.  -       cur.switchedInvite = ce('div', {className: 'gle_invites_actions', innerHTML: '<div class="progress_inline"></div>'});
  6192. 236.  -       newRow.insertBefore(cur.switchedInvite, newRow.firstChild)
  6193. 237.  -     }
  6194. 238.  -
  6195. 239.  -     cur.scrollList.invShown -= 1;
  6196. 240.  -     cur.scrollList.invCount -= 1;
  6197. 241.  -
  6198. 242.  -     var cont = row.parentNode;
  6199. 243.  -     var size = getSize(cont);
  6200. 244.  -     setStyle(newRow, {opacity: 0, overflow: 'hidden', height: 1, position: 'absolute'});
  6201. 245.  -     cont.appendChild(newRow);
  6202. 246.  -     animate(newRow, {marginTop: -size[1], opacity: 1, height: size[1]}, 200, function() {
  6203. 247.  -       hide(row);
  6204. 248.  -       setStyle(newRow, {marginTop: 0, position: 'static', height: 'auto'});
  6205. 249.  -     });
  6206. 250.  -
  6207. 251.  -     if (cur.scrollList.invCount) {
  6208. 252.  -       ge('gle_inv_summary').innerHTML = langNumeric(cur.scrollList.invCount, cur.scrollList.summaries.inv);
  6209. 253.  -     } else {
  6210. 254.  -       ge('gle_inv_summary').innerHTML = cur.scrollList.summaries.invEmpty;
  6211. 255.  -     }
  6212. 256.  -     return true;
  6213. 257.  -   },
  6214. 258.  -
  6215. 259.  -   leave: function(el, gid, hash, pp) {
  6216. 260.  -     if (cur.invSwitching) {
  6217. 261.  -       setTimeout(GroupsList.leave.pbind(el, gid, hash, pp), 100);
  6218. 262.  -       return false;
  6219. 263.  -     }
  6220. 264.  -     var sp, hp, tab = cur.scrollList.tab;
  6221. 265.  -
  6222. 266.  -     if (el.firstChild && el.firstChild.className == 'progress_inline') return;
  6223. 267.  -     sp = function() {
  6224. 268.  -       var w = getSize(el)[0];
  6225. 269.  -       el.oldhtml = el.innerHTML;
  6226. 270.  -       el.innerHTML = '<span class="progress_inline"></span>';
  6227. 271.  -       setStyle(el, {width: w - 30});
  6228. 272.  -     }
  6229. 273.  -     hp = function() {
  6230. 274.  -       el.innerHTML = el.oldhtml;
  6231. 275.  -     }
  6232. 276.  -
  6233. 277.  -     var key = GroupsList.rand(), value = GroupsList.rand();
  6234. 278.  -     cur.scrollList[key] = value;
  6235. 279.  -
  6236. 280.  -     var shown = false;
  6237. 281.  -     cur.invSwitching = true;
  6238. 282.  -     if (GroupsList.switchInvite(gid, true)) {
  6239. 283.  -       shown = true;
  6240. 284.  -       sp = false;
  6241. 285.  -       hp = false;
  6242. 286.  -     }
  6243. 287.  -
  6244. 288.  -     var context = (cur.scrollList.tab == 'groups') ? '2' : '1';
  6245. 289.  -
  6246. 290.  -     ajax.post('al_groups.php', {
  6247. 291.  -       act: 'leave',
  6248. 292.  -       gid: gid,
  6249. 293.  -       hash: hash,
  6250. 294.  -       context: context,
  6251. 295.  -       inv_shown: cur.scrollList.invShown
  6252. 296.  -     }, {
  6253. 297.  -       onDone: function(newRow) {
  6254. 298.  -         cur.invSwitching = false;
  6255. 299.  -         if (!cur.scrollList || cur.scrollList[key] != value) return;
  6256. 300.  -
  6257. 301.  -         var list = cur.scrollList.lists[tab];
  6258. 302.  -         if (!list || list == 'loading' || list == 'update') {
  6259. 303.  -           cur.scrollList.processed[tab][gid] = -1;
  6260. 304.  -         } else {
  6261. 305.  -           for (var i = 0, count = list.length; i < count; ++i) {
  6262. 306.  -             if (list[i][2] == gid) {
  6263. 307.  -               list[i][1] = -1;
  6264. 308.  -             }
  6265. 309.  -           }
  6266. 310.  -         }
  6267. 311.  -
  6268. 312.  -         var row = ge('gl_' + tab + gid);
  6269. 313.  -         if (!row) return;
  6270. 314.  -
  6271. 315.  -         var acts = '<a onclick="GroupsList.cancel(this.parentNode, ' + gid + ', \'' + hash + '\')">' + getLang('global_cancel') + '</a><span class="divider">|</span><a onclick="GroupsList.spam(this.parentNode, ' + gid + ', \'' + hash + '\')">' + getLang('its_spam') + '</a>';
  6272. 316.  -
  6273. 317.  -         var text = '';
  6274. 318.  -         if (tab == 'groups') {
  6275. 319.  -           text = getLang(pp ? 'public_you_unsubscribed' : 'groups_group_left');
  6276. 320.  -         } else {
  6277. 321.  -           text = getLang('groups_group_deny_message');
  6278. 322.  -         }
  6279. 323.  -
  6280. 324.  -         GroupsList.addInvite(newRow, false, false);
  6281. 325.  -
  6282. 326.  -         if (shown) {
  6283. 327.  -           if (cur.switchedInvite) {
  6284. 328.  -             cur.switchedInvite.innerHTML = text+' <a onclick="GroupsList.spam(this.parentNode, ' + gid + ', \'' + hash + '\', cur.switchedInvite)">' + getLang('its_spam') + '</a>';
  6285. 329.  -           }
  6286. 330.  -           return;
  6287. 331.  -         }
  6288. 332.  -
  6289. 333.  -         var status = geByClass1('group_row_status', row), actions = geByClass1('group_row_actions', row);
  6290. 334.  -         status.basehtml = status.innerHTML;
  6291. 335.  -         actions.basehtml = actions.innerHTML;
  6292. 336.  -         status.innerHTML = text;
  6293. 337.  -         actions.innerHTML = acts;
  6294. 338.  -       },
  6295. 339.  -       showProgress: sp, hideProgress: hp
  6296. 340.  -     });
  6297. 341.  -   },
  6298. 342.  -   rejectAll: function(el, hash) {
  6299. 343.  -     var box = showFastBox(getLang('global_warning'), getLang('groups_sure_reject_all'), getLang('groups_members_application_decline'), function() {
  6300. 344.  -       ajax.post('al_groups.php', {act: 'reject_all', hash: hash}, {progress: box.progress});
  6301. 345.  -     }, getLang('global_cancel'));
  6302. 346.  -   },
  6303. 347.  -   spam: function(el, gid, hash, applyCont, block) {
  6304. 348.  -     var sp, hp, tab = cur.scrollList.tab;
  6305. 349.  -
  6306. 350.  -     if (el.firstChild && el.firstChild.className == 'progress_inline') return;
  6307. 351.  -     sp = function() {
  6308. 352.  -       el.oldhtml = el.innerHTML;
  6309. 353.  -       el.innerHTML = '<span class="progress_inline"></span>';
  6310. 354.  -     }
  6311. 355.  -     hp = function() {
  6312. 356.  -       el.innerHTML = el.oldhtml;
  6313. 357.  -     }
  6314. 358.  -
  6315. 359.  -     var key = GroupsList.rand(), value = GroupsList.rand();
  6316. 360.  -     cur.scrollList[key] = value;
  6317. 361.  -
  6318. 362.  -     ajax.post('al_groups.php', {act: 'spam', gid: gid, hash: hash, context: 1, block: block}, {
  6319. 363.  -       onDone: function(respText) {
  6320. 364.  -         if (!cur.scrollList || cur.scrollList[key] != value) return;
  6321. 365.  -         if (block > 0) {
  6322. 366.  -           respText = respText.replace('{club}', '<b>' + val(domPS(ge('clubinv' + gid))) + '</b>');
  6323. 367.  -         }
  6324. 368.  -         if (applyCont) {
  6325. 369.  -           if (block < 0) {
  6326. 370.  -             applyCont.innerHTML = applyCont.basehtml;
  6327. 371.  -           } else {
  6328. 372.  -             applyCont.basehtml = applyCont.innerHTML;
  6329. 373.  -             var applyContText = respText;
  6330. 374.  -             if (block > 0) {
  6331. 375.  -               respText += '<div class="group_row_blockinv"><a onclick="GroupsList.spam(domPN(domPN(this)), ' + gid + ', \'' + hash + '\', cur.switchedInvite, -1)">' + getLang('global_cancel') + '</div>';
  6332. 376.  -             } else if (ge('clubinv' + gid)) {
  6333. 377.  -               respText += '<div class="group_row_blockinv"><a onclick="GroupsList.spam(domPN(domPN(this)), ' + gid + ', \'' + hash + '\', cur.switchedInvite, 1)">' + getLang('groups_block_clubinv').replace('{club}', '<b>' + val(domPS(ge('clubinv' + gid))) + '</b>') + '</a></div>'
  6334. 378.  -             }
  6335. 379.  -             applyCont.innerHTML = respText;
  6336. 380.  -           }
  6337. 381.  -         }
  6338. 382.  -
  6339. 383.  -         if (!block) {
  6340. 384.  -           var list = cur.scrollList.lists[tab];
  6341. 385.  -           if (!list || list == 'loading' || list == 'update') {
  6342. 386.  -             cur.scrollList.processed[tab][gid] = -2;
  6343. 387.  -           } else {
  6344. 388.  -             for (var i = 0, count = list.length; i < count; ++i) {
  6345. 389.  -               if (list[i][2] == gid) {
  6346. 390.  -                 list[i][1] = -2;
  6347. 391.  -               }
  6348. 392.  -             }
  6349. 393.  -           }
  6350. 394.  -         }
  6351. 395.  -
  6352. 396.  -         var row = ge('gl_' + tab + gid);
  6353. 397.  -         if (!row) return;
  6354. 398.  -
  6355. 399.  -         var status = geByClass1('group_row_status', row), actions = geByClass1('group_row_actions', row);
  6356. 400.  -         if (block < 0) {
  6357. 401.  -           status.innerHTML = status.blockhtml;
  6358. 402.  -           actions.innerHTML = actions.blockhtml;
  6359. 403.  -         } else {
  6360. 404.  -           if (block) {
  6361. 405.  -             status.blockhtml = status.innerHTML;
  6362. 406.  -             actions.blockhtml = actions.innerHTML;
  6363. 407.  -             status.innerHTML = '<div class="group_row_blockinv">' + respText + '</div>';
  6364. 408.  -             actions.innerHTML = '<div class="group_row_blockinv"><a onclick="GroupsList.spam(domPN(domPN(this)), ' + gid + ', \'' + hash + '\', false, -1)">' + getLang('global_cancel') + '</a></div>';
  6365. 409.  -           } else {
  6366. 410.  -             status.basehtml = status.innerHTML;
  6367. 411.  -             actions.basehtml = actions.innerHTML;
  6368. 412.  -             status.innerHTML = getLang('groups_ajax_inv_declined_spam');
  6369. 413.  -             actions.innerHTML = '';
  6370. 414.  -           }
  6371. 415.  -         }
  6372. 416.  -       },
  6373. 417.  -       showProgress: sp, hideProgress: hp
  6374. 418.  -     });
  6375. 419.  -   },
  6376. 420.  -   cancel: function(el, gid, hash) {
  6377. 421.  -     var sp, hp, tab = cur.scrollList.tab;
  6378. 422.  -
  6379. 423.  -     if (el.firstChild && el.firstChild.className == 'progress_inline') return;
  6380. 424.  -     sp = function() {
  6381. 425.  -       el.oldhtml = el.innerHTML;
  6382. 426.  -       el.innerHTML = '<span class="progress_inline"></span>';
  6383. 427.  -     }
  6384. 428.  -     hp = function() {
  6385. 429.  -       el.innerHTML = el.oldhtml;
  6386. 430.  -     }
  6387. 431.  -
  6388. 432.  -     var key = GroupsList.rand(), value = GroupsList.rand();
  6389. 433.  -     cur.scrollList[key] = value;
  6390. 434.  -
  6391. 435.  -     ajax.post('al_groups.php', {act: 'cancel', gid: gid, hash: hash, context: 1}, {
  6392. 436.  -       onDone: function() {
  6393. 437.  -         if (!cur.scrollList || cur.scrollList[key] != value) return;
  6394. 438.  -
  6395. 439.  -         var list = cur.scrollList.lists[tab], elem = false;
  6396. 440.  -         if (!list || list == 'loading' || list == 'update') {
  6397. 441.  -           cur.scrollList.processed[tab][gid] = 0;
  6398. 442.  -         } else {
  6399. 443.  -           for (var i in list) {
  6400. 444.  -             if (list[i][2] == gid) {
  6401. 445.  -               list.splice(i, 1)
  6402. 446.  -             }
  6403. 447.  -           }
  6404. 448.  -           cur.scrollList.cache['groups'] = {all: []};
  6405. 449.  -           var c = cur.scrollList.cache['groups'];
  6406. 450.  -           for (var i in list) {
  6407. 451.  -             c.all.push(i);
  6408. 452.  -           }
  6409. 453.  -           cur.scrollList.index[tab] = new vkIndexer(c.all, function(obj) {
  6410. 454.  -             return list[obj][0];
  6411. 455.  -           });
  6412. 456.  -         }
  6413. 457.  -         /*} else {
  6414. 458.  -           for (var i = 0, count = list.length; i < count; ++i) {
  6415. 459.  -             if (list[i][2] == gid) {
  6416. 460.  -               list[i][1] = 0;
  6417. 461.  -               elem = list[i];
  6418. 462.  -               break;
  6419. 463.  -             }
  6420. 464.  -           }
  6421. 465.  -         }*/
  6422. 466.  -
  6423. 467.  -         var row = ge('gl_' + tab + gid);
  6424. 468.  -         if (!row) return;
  6425. 469.  -
  6426. 470.  -         if (elem) {
  6427. 471.  -           var name = elem[0], q = trim(cur.scrollList.query.value);
  6428. 472.  -           if (q) {
  6429. 473.  -             var highlight = GroupsList.getHighlight(q);
  6430. 474.  -             name = name.replace(highlight.re, highlight.val);
  6431. 475.  -           }
  6432. 476.  -           var newRow = (cur.scrollList.genRow(elem, name)) ? cur.scrollList.genInvRow(elem, name) : cur.scrollList.genRow(elem, name);
  6433. 477.  -           row.parentNode.replaceChild(ce('div', {innerHTML: newRow}).firstChild, row);
  6434. 478.  -         } else {
  6435. 479.  -           var status = geByClass1('group_row_status', row), actions = geByClass1('group_row_actions', row);
  6436. 480.  -           status.innerHTML = status.basehtml;
  6437. 481.  -           actions.innerHTML = actions.basehtml;
  6438. 482.  -         }
  6439. 483.  -       },
  6440. 484.  -       showProgress: sp, hideProgress: hp
  6441. 485.  -     });
  6442. 486.  -   },
  6443. 487.  -
  6444. 488.  -   scrollCheck: function() {
  6445. 489.  -     if (browser.mobile) return;
  6446. 490.  -     var lnk = ge(cur.scrollList.prefix + cur.scrollList.tab + '_more');
  6447. 491.  -     if (!isVisible(lnk)) {
  6448. 492.  -       return;
  6449. 493.  -     }
  6450. 494.  -
  6451. 495.  -     var docEl = document.documentElement;
  6452. 496.  -     var ch = window.innerHeight || docEl.clientHeight || bodyNode.clientHeight;
  6453. 497.  -     var st = scrollGetY();
  6454. 498.  -
  6455. 499.  -     if (st + ch > lnk.offsetTop || (cur.searchOffset && st + 2*ch > lnk.offsetTop)) {
  6456. 500.  -       GroupsList.showMore();
  6457. 501.  -     }
  6458. 502.  -   },
  6459. 503.  -   initScroll: function() {
  6460. 504.  -     addEvent((browser.msie6 ? pageNode : window), 'scroll', GroupsList.scrollCheck);
  6461. 505.  -     addEvent(window, 'resize', GroupsList.scrollCheck);
  6462. 506.  -   },
  6463. 507.  -
  6464. 508.  -   locNav: function(changed, oldLoc, newLoc) {
  6465. 509.  -     var changedTab = changed.tab, tab = changedTab || 'groups';
  6466. 510.  -     delete(changed.tab);
  6467. 511.  -     if (!isEmpty(changed) || changedTab === undefined) return;
  6468. 512.  -
  6469. 513.  -     ge('groups_tab_' + cur.scrollList.tab).className = '';
  6470. 514.  -     hide('groups_list_tab_' + cur.scrollList.tab);
  6471. 515.  -     cur.scrollList.tab = tab;
  6472. 516.  -     show('groups_list_tab_' + tab);
  6473. 517.  -     var tabEl = ge('groups_tab_' + tab);
  6474. 518.  -     tabEl.className = 'active_link';
  6475. 519.  -     show(tabEl);
  6476. 520.  -
  6477. 521.  -     if (cur.scrollList.events) {
  6478. 522.  -       toggle(cur.scrollList.events, tab == 'groups' && ge('gle_list_cont').innerHTML);
  6479. 523.  -       cur.scrollList.eventsShow = false;
  6480. 524.  -       if (isVisible(cur.scrollList.eventsMore)) {
  6481. 525.  -         hide(cur.scrollList.eventsMore);
  6482. 526.  -         show(cur.scrollList.eventsMoreLnk);
  6483. 527.  -       }
  6484. 528.  -     }
  6485. 529.  -     if (cur.scrollList.invites) {
  6486. 530.  -       toggle(cur.scrollList.invites, tab == 'groups');
  6487. 531.  -     }
  6488. 532.  -     if (cur.scrollList.invites || cur.scrollList.events) {
  6489. 533.  -       ((tab == 'groups') ? addClass : removeClass)(cur.scrollList.summary.parentNode, 'gl_summary_short');
  6490. 534.  -     }
  6491. 535.  -
  6492. 536.  -     toggle('gl_about_events', (tab == 'groups' || tab == 'inv'));
  6493. 537.  -
  6494. 538.  -     nav.setLoc(newLoc);
  6495. 539.  -     ge('groups_list_search').setValue('');
  6496. 540.  -     setTimeout(elfocus.pbind('groups_list_search'), 0);
  6497. 541.  -
  6498. 542.  -     cur.scrollList.summary.innerHTML = cur.scrollList.summaries[tab];
  6499. 543.  -     cur.scrollList.offset = ge('groups_list_' + tab).childNodes.length;
  6500. 544.  -
  6501. 545.  -     GroupsList.showMore(true);
  6502. 546.  -
  6503. 547.  -     return false;
  6504. 548.  -   },
  6505. 549.  -
  6506. 550.  -   init: function(opts) {
  6507. 551.  -     placeholderSetup('groups_list_search', {back: true});
  6508. 552.  -     setTimeout(elfocus.pbind('groups_list_search'), 0);
  6509. 553.  -     extend(cur, {
  6510. 554.  -       module: 'groups_list',
  6511. 555.  -       _back: {
  6512. 556.  -         text: getLang('groups_back_to_list'),
  6513. 557.  -         show: [GroupsList.initScroll],
  6514. 558.  -         hide: [function() {
  6515. 559.  -           removeEvent((browser.msie6 ? pageNode : window), 'scroll', GroupsList.scrollCheck);
  6516. 560.  -           removeEvent(window, 'resize', GroupsList.scrollCheck);
  6517. 561.  -         }]
  6518. 562.  -       },
  6519. 563.  -
  6520. 564.  -       scrollList: {
  6521. 565.  -         tab: opts.tab,
  6522. 566.  -
  6523. 567.  -         url: 'al_groups.php',
  6524. 568.  -         params: {act: 'get_list', mid: opts.mid},
  6525. 569.  -         prefix: 'groups_list_',
  6526. 570.  -         query: ge('groups_list_search'),
  6527. 571.  -         summary: ge('groups_list_summary'),
  6528. 572.  -         events: ge('gle_list_wrap'),
  6529. 573.  -         eventsMore: ge('gle_list_more'),
  6530. 574.  -         eventsMoreLnk: ge('gle_list_more_lnk'),
  6531. 575.  -         invites: ge('gle_invites_wrap'),
  6532. 576.  -         searchCont: ge('groups_list_search_cont'),
  6533. 577.  -
  6534. 578.  -         perpage: 20,
  6535. 579.  -         offset: ge('groups_list_' + opts.tab).childNodes.length,
  6536. 580.  -
  6537. 581.  -         lists: {},
  6538. 582.  -         cache: {},
  6539. 583.  -         index: {},
  6540. 584.  -         processed: {'groups': {}, 'admin': {}, 'inv': {}},
  6541. 585.  -         filtered: {},
  6542. 586.  -         queries: {},
  6543. 587.  -         summaries: opts.summaries,
  6544. 588.  -
  6545. 589.  -         genEmpty: opts.genEmpty,
  6546. 590.  -         genRow: opts.genRow,
  6547. 591.  -         genEvent: opts.genEvent,
  6548. 592.  -         genInvRow: opts.genInvRow,
  6549. 593.  -         genSummary: opts.genSummary,
  6550. 594.  -         genGroupsSummary: opts.genGroupsSummary,
  6551. 595.  -         invShown: opts.invShown,
  6552. 596.  -         invCount: opts.invCount
  6553. 597.  -       },
  6554. 598.  -       filter: opts.filter
  6555. 599.  -     });
  6556. 600.  -
  6557. 601.  -     cur.nav.push(GroupsList.locNav);
  6558. 602.  -
  6559. 603.  -     setTimeout(GroupsList.load, 0);
  6560. 604.  -     if (vk.version) {
  6561. 605.  -       addEvent(window, 'load', GroupsList.initScroll);
  6562. 606.  -     } else {
  6563. 607.  -       GroupsList.initScroll();
  6564. 608.  -     }
  6565. 609.  -   },
  6566. 610.  -   load: function(force, forceTab) {
  6567. 611.  -     var tab = forceTab || cur.scrollList.tab;
  6568. 612.  -     if (cur.scrollList.lists[tab]) return;
  6569. 613.  -
  6570. 614.  -     var key = GroupsList.rand(), value = GroupsList.rand();
  6571. 615.  -     cur.scrollList[key] = value;
  6572. 616.  -
  6573. 617.  -     cur.scrollList.lists[tab] = 'loading';
  6574. 618.  -     ajax.post(cur.scrollList.url, extend(cur.scrollList.params, {tab: tab}), {onDone: function(result) {
  6575. 619.  -       if (!cur.scrollList || cur.scrollList[key] != value) return;
  6576. 620.  -
  6577. 621.  -       var upd = (cur.scrollList.lists[tab] == 'update');
  6578. 622.  -       if (!upd && cur.scrollList.lists[tab] != 'loading') return;
  6579. 623.  -
  6580. 624.  -       cur.scrollList.cache[tab] = {all: []};
  6581. 625.  -       var processed = cur.scrollList.processed[tab], gid;
  6582. 626.  -       for (var i = 0, count = result.length; i < count; ++i) {
  6583. 627.  -         res = processed[result[i][2]];
  6584. 628.  -         if (res) {
  6585. 629.  -           result[i][1] = res;
  6586. 630.  -         }
  6587. 631.  -         cur.scrollList.cache[tab].all.push(i);
  6588. 632.  -       }
  6589. 633.  -       cur.scrollList.lists[tab] = result;
  6590. 634.  -
  6591. 635.  -       var callback = upd ? function() {
  6592. 636.  -         if (cur.scrollList && cur.scrollList[key] == value && cur.scrollList.tab == tab) {
  6593. 637.  -           GroupsList.showMore(force);
  6594. 638.  -         }
  6595. 639.  -       } : function() {};
  6596. 640.  -
  6597. 641.  -       cur.scrollList.index[tab] = new vkIndexer(cur.scrollList.cache[tab].all, function(obj) {
  6598. 642.  -         return cur.scrollList.lists[tab][obj][0];
  6599. 643.  -       }, callback);
  6600. 644.  -
  6601. 645.  -       if (cur.scrollList.eventsShow) {
  6602. 646.  -         GroupsList.eventsMore();
  6603. 647.  -       }
  6604. 648.  -     }, local: 1});
  6605. 649.  -   },
  6606. 650.  -
  6607. 651.  -   htmlencode: function(str) {
  6608. 652.  -     var res = [];
  6609. 653.  -     for (var i = 0, l = str.length; i < l; ++i) {
  6610. 654.  -       var c = str.charCodeAt(i);
  6611. 655.  -       if (c == 33 || c == 39 || (c > 127 && c < 1040) || c > 1103) {
  6612. 656.  -         res.push('&#' + c + ';');
  6613. 657.  -       } else if (c == 36) {
  6614. 658.  -         res.push('&#0' + c + ';');
  6615. 659.  -       } else {
  6616. 660.  -         c = str.charAt(i);
  6617. 661.  -         switch (c) {
  6618. 662.  -           case '>': res.push('&gt;'); break;
  6619. 663.  -           case '<': res.push('&lt;'); break;
  6620. 664.  -           case '"': res.push('&quot;'); break;
  6621. 665.  -           case '&': res.push('&amp;'); break;
  6622. 666.  -           default:  res.push(c); break;
  6623. 667.  -         }
  6624. 668.  -       }
  6625. 669.  -     }
  6626. 670.  -     return res.join('');
  6627. 671.  -   },
  6628. 672.  -   getHighlight: function(q) {
  6629. 673.  -     var indxr = cur.scrollList.index[cur.scrollList.tab], delimiter = indxr.delimiter, trimmer = indxr.trimmer;
  6630. 674.  -
  6631. 675.  -     q += ' ' + (parseLatin(q) || '');
  6632. 676.  -     q = escapeRE(q).replace(/&/g, '&amp;');
  6633. 677.  -     q = q.replace(trimmer, '').replace(delimiter, '|');
  6634. 678.  -     return {
  6635. 679.  -       re: new RegExp('(' + q + ')', 'gi'),
  6636. 680.  -       val: '<span class="group_row_highlight">$1</span>'
  6637. 681.  -     }
  6638. 682.  -   },
  6639. 683.  -   updateEvents: function() {
  6640. 684.  -     if (!cur.scrollList.events || cur.scrollList.tab != 'groups') return;
  6641. 685.  -     toggle(cur.scrollList.events, !cur.scrollList.query.value && ge('gle_list_cont').innerHTML);
  6642. 686.  -     cur.scrollList.eventsShow = false;
  6643. 687.  -     if (isVisible(cur.scrollList.eventsMore)) {
  6644. 688.  -       hide(cur.scrollList.eventsMore);
  6645. 689.  -       show(cur.scrollList.eventsMoreLnk);
  6646. 690.  -     }
  6647. 691.  -     if (cur.scrollList.invites) {
  6648. 692.  -       toggle(cur.scrollList.invites, !cur.scrollList.query.value);
  6649. 693.  -     }
  6650. 694.  -     (!cur.scrollList.query.value ? addClass : removeClass)(cur.scrollList.summary.parentNode, 'gl_summary_short');
  6651. 695.  -   },
  6652. 696.  -   updateEventsList: function(addedGid) {
  6653. 697.  -     ajax.post('groups', {act: 'update_events'}, {
  6654. 698.  -       onDone: function(html, more) {
  6655. 699.  -         var gleCont = ge('gle_list_cont');
  6656. 700.  -         val(gleCont, html);
  6657. 701.  -         toggle(cur.scrollList.events, !!html);
  6658. 702.  -         hide(cur.scrollList.eventsMore);
  6659. 703.  -         val(cur.scrollList.eventsMore, '');
  6660. 704.  -         val(cur.scrollList.eventsMoreLnk, more || '');
  6661. 705.  -         toggle(cur.scrollList.eventsMoreLnk, !!more);
  6662. 706.  -         cur.scrollList.eventsShow = false;
  6663. 707.  -         if (addedGid) {
  6664. 708.  -           var addedRow = ge('gle_block_'+addedGid);
  6665. 709.  -           if (addedRow) {
  6666. 710.  -             setStyle(addedRow, {backgroundColor: '#FEFAE4'});
  6667. 711.  -             animate(addedRow, {backgroundColor: '#FFF'}, 2000);
  6668. 712.  -           }
  6669. 713.  -         }
  6670. 714.  -       }
  6671. 715.  -     })
  6672. 716.  -   },
  6673. 717.  -   eventsMore: function() {
  6674. 718.  -     var list = cur.scrollList.lists['groups'];
  6675. 719.  -     if (!list || list == 'loading' || list == 'update') {
  6676. 720.  -       cur.scrollList.eventsShow = true;
  6677. 721.  -       return;
  6678. 722.  -     }
  6679. 723.  -
  6680. 724.  -     hide(cur.scrollList.eventsMoreLnk);
  6681. 725.  -     if (val(cur.scrollList.eventsMore)) {
  6682. 726.  -       show(cur.scrollList.eventsMore);
  6683. 727.  -     } else {
  6684. 728.  -       var res = {}, shown = {}, dates = {}, list = [], html = [];
  6685. 729.  -       each(ge('gle_list_cont').childNodes, function(k, v) {
  6686. 730.  -         var id = intval(((v || {}).id || '').replace(/^gle_block_/, ''));
  6687. 731.  -         if (id) shown[id] = true;
  6688. 732.  -       });
  6689. 733.  -       each(cur.scrollList.lists['groups'], function(k, v) {
  6690. 734.  -         var gid = intval(v[2]);
  6691. 735.  -         if (!v[11] || shown[gid]) return;
  6692. 736.  -         list.push(gid);
  6693. 737.  -         res[gid] = cur.scrollList.genEvent(v);
  6694. 738.  -         dates[gid] = intval(v[11].split('<*>')[0]);
  6695. 739.  -       });
  6696. 740.  -       list.sort(function(gid1, gid2) {
  6697. 741.  -         return (dates[gid1] < dates[gid2]) ? -1 : ((dates[gid2] < dates[gid1]) ? 1 : 0);
  6698. 742.  -       });
  6699. 743.  -       each(list, function(k, v) {
  6700. 744.  -         html.push(res[v]);
  6701. 745.  -       });
  6702. 746.  -       if (html.length) {
  6703. 747.  -         val(cur.scrollList.eventsMore, html.join(''));
  6704. 748.  -         show(cur.scrollList.eventsMore);
  6705. 749.  -       }
  6706. 750.  -     }
  6707. 751.  -   },
  6708. 752.  -   showMore: function(force) {
  6709. 753.  -     var tab = cur.scrollList.tab, list = cur.scrollList.lists[tab];
  6710. 754.  -     if (!list || list == 'loading' || list == 'update') {
  6711. 755.  -       if (!list) GroupsList.load(force);
  6712. 756.  -       cur.scrollList.lists[tab] = 'update';
  6713. 757.  -       return;
  6714. 758.  -     }
  6715. 759.  -
  6716. 760.  -     var tab = cur.scrollList.tab, list = cur.scrollList.cache[tab].all;
  6717. 761.  -
  6718. 762.  -     var q = trim(cur.scrollList.query.value);
  6719. 763.  -     cur.searchStr = q;
  6720. 764.  -     if (!cur.loadingShown) {
  6721. 765.  -       if (q) {
  6722. 766.  -         show('groups_reset_search');
  6723. 767.  -       } else {
  6724. 768.  -         hide('groups_reset_search');
  6725. 769.  -       }
  6726. 770.  -     }
  6727. 771.  -
  6728. 772.  -     if (cur.scrollList.queries[tab] === undefined) {
  6729. 773.  -       cur.scrollList.queries[tab] = '';
  6730. 774.  -     }
  6731. 775.  -     var refresh = (force || q != cur.scrollList.queries[tab]);
  6732. 776.  -     if (!refresh && force === false) return;
  6733. 777.  -
  6734. 778.  -     cur.scrollList.queries[tab] = q;
  6735. 779.  -
  6736. 780.  -     var highlight = false;
  6737. 781.  -     if (q) {
  6738. 782.  -       list = cur.scrollList.cache[tab]['_' + q];
  6739. 783.  -       if (list === undefined) {
  6740. 784.  -         var tmp = cur.scrollList.index[tab].search(q), mp = {};
  6741. 785.  -         list = [];
  6742. 786.  -         for (var i = 0, l = tmp.length; i < l; ++i) {
  6743. 787.  -           if (!mp[tmp[i]]) {
  6744. 788.  -             mp[tmp[i]] = true;
  6745. 789.  -             list.push(tmp[i]);
  6746. 790.  -           }
  6747. 791.  -         }
  6748. 792.  -         list.sort(function(a,b){return a-b;});
  6749. 793.  -         cur.scrollList.cache[tab]['_' + q] = list;
  6750. 794.  -       }
  6751. 795.  -       highlight = GroupsList.getHighlight(q);
  6752. 796.  -     }
  6753. 797.  -
  6754. 798.  -     var len = list.length;
  6755. 799.  -
  6756. 800.  -     var cont = ge(cur.scrollList.prefix + tab), more = ge(cur.scrollList.prefix + tab + '_more');
  6757. 801.  -     if (!len) {
  6758. 802.  -       if (q && tab == 'groups') {
  6759. 803.  -         if (refresh) {
  6760. 804.  -           GroupsList.serverSearch(cont, q, true);
  6761. 805.  -           hide(more);
  6762. 806.  -         } else if (cur.searchOffset) {
  6763. 807.  -           GroupsList.serverSearchMore(cont, q);
  6764. 808.  -         }
  6765. 809.  -       } else {
  6766. 810.  -         q = cur.scrollList.query.value;
  6767. 811.  -         cont.innerHTML = cur.scrollList.genEmpty(q);
  6768. 812.  -         cur.scrollList.summary.innerHTML = q ? cur.scrollList.genSummary(len) : cur.scrollList.summaries[tab];
  6769. 813.  -         hide(more);
  6770. 814.  -         hide(cur.scrollList.searchCont);
  6771. 815.  -         cur.searchOffset = 0;
  6772. 816.  -       }
  6773. 817.  -       return;
  6774. 818.  -     } else if (tab == 'groups' && cur.scrollList.params.mid == vk.id) {
  6775. 819.  -       cur.scrollList.summary.innerHTML = cur.scrollList.genGroupsSummary(len);
  6776. 820.  -     } else {
  6777. 821.  -       cur.scrollList.summary.innerHTML = q ? cur.scrollList.genSummary(len) : cur.scrollList.summaries[tab];
  6778. 822.  -     }
  6779. 823.  -
  6780. 824.  -     var start = refresh ? 0 : cur.scrollList.offset, end = Math.min(len, start + cur.scrollList.perpage);
  6781. 825.  -     var html = [];
  6782. 826.  -
  6783. 827.  -     for (var i = start; i < end; ++i) {
  6784. 828.  -       var row = cur.scrollList.lists[tab][list[i]];
  6785. 829.  -       if (!row) continue;
  6786. 830.  -       var name = row[0];
  6787. 831.  -       if (highlight) {
  6788. 832.  -         name = name.replace(highlight.re, highlight.val);
  6789. 833.  -       }
  6790. 834.  -       if (cur.scrollList.tab == 'inv') {
  6791. 835.  -         html.push(cur.scrollList.genInvRow(row, name));
  6792. 836.  -       } else {
  6793. 837.  -         html.push(cur.scrollList.genRow(row, name));
  6794. 838.  -       }
  6795. 839.  -     }
  6796. 840.  -
  6797. 841.  -     if (!q && (!start || refresh)) {
  6798. 842.  -       hide(cur.scrollList.searchCont);
  6799. 843.  -       cur.searchOffset = 0;
  6800. 844.  -     }
  6801. 845.  -
  6802. 846.  -     if (refresh) {
  6803. 847.  -       cont.innerHTML = html.join('');
  6804. 848.  -       cur.searchOffset = false;
  6805. 849.  -       if (list.length < 10 && q && tab == 'groups') {
  6806. 850.  -         var exclude = [];
  6807. 851.  -         for (var i in list) {
  6808. 852.  -           var el = cur.scrollList.lists[tab][list[i]];
  6809. 853.  -           exclude.push(el[2]);
  6810. 854.  -         }
  6811. 855.  -         GroupsList.serverSearch(cont, q, false, exclude);
  6812. 856.  -       } else {
  6813. 857.  -         hide(cur.scrollList.searchCont);
  6814. 858.  -         cur.searchOffset = 0;
  6815. 859.  -       }
  6816. 860.  -     } else {
  6817. 861.  -       cont.innerHTML += html.join('');
  6818. 862.  -       if (cur.searchOffset) {
  6819. 863.  -         GroupsList.serverSearchMore(cont, q);
  6820. 864.  -       }
  6821. 865.  -     }
  6822. 866.  -     cur.scrollList.offset = end;
  6823. 867.  -
  6824. 868.  -     if (!cur.searchOffset) {
  6825. 869.  -       (end < len ? show : hide)(more);
  6826. 870.  -     }
  6827. 871.  -   },
  6828. 872.  -
  6829. 873.  -   serverSearchMore: function(cont, q) {
  6830. 874.  -     if (cur.searchLoadingMore) return;
  6831. 875.  -     cur.searchLoadingMore = 1;
  6832. 876.  -     var more = ge(cur.scrollList.prefix + cur.scrollList.tab + '_more');
  6833. 877.  -     var back = more.innerHTML;
  6834. 878.  -     ajax.post('al_groups.php', {
  6835. 879.  -       act: 'server_search',
  6836. 880.  -       q: q,
  6837. 881.  -       offset: cur.searchOffset,
  6838. 882.  -       exclude: cur.searchExclude.join(',')
  6839. 883.  -     }, {
  6840. 884.  -       onDone: function(count, rows, finish) {
  6841. 885.  -         cur.searchLoadingMore = 0;
  6842. 886.  -         if (count) {
  6843. 887.  -           cur.searchOffset += count;
  6844. 888.  -           cur.scrollList.searchCont.appendChild(cf(rows));
  6845. 889.  -         } else {
  6846. 890.  -           cur.searchOffset = 0;
  6847. 891.  -         }
  6848. 892.  -         (finish ? hide : show)(cur.scrollList.prefix + cur.scrollList.tab + '_more');
  6849. 893.  -         debugLog((finish ? 'hide' : 'show'));
  6850. 894.  -       },
  6851. 895.  -       onFail: function() {
  6852. 896.  -         cur.searchLoadingMore = 0;
  6853. 897.  -       },
  6854. 898.  -       showProgress: function() {
  6855. 899.  -         more.innerHTML = '<img src="/images/upload.gif" />';
  6856. 900.  -       },
  6857. 901.  -       hideProgress: function() {
  6858. 902.  -         more.innerHTML = back;
  6859. 903.  -       }
  6860. 904.  -     })
  6861. 905.  -   },
  6862. 906.  -
  6863. 907.  -   serverSearch: function(cont, q, emptyLocal, exclude) {
  6864. 908.  -     if (cur.scrollList.tab != 'groups') {
  6865. 909.  -       return false;
  6866. 910.  -     }
  6867. 911.  -     clearTimeout(cur.searchTimeout);
  6868. 912.  -     cur.searchTimeout = setTimeout(function() {
  6869. 913.  -       if (cur.searchStr != q) return;
  6870. 914.  -       cur.searchExclude = exclude || [];
  6871. 915.  -       ajax.post('al_groups.php', {
  6872. 916.  -         act: 'server_search',
  6873. 917.  -         q: q,
  6874. 918.  -         empty: emptyLocal ? 1 : 0,
  6875. 919.  -         exclude: cur.searchExclude.join(',')
  6876. 920.  -       }, {
  6877. 921.  -         onDone: function(count, rows, summary, finish) {
  6878. 922.  -           if (cur.searchStr != q) return;
  6879. 923.  -           if (count) {
  6880. 924.  -             var last = geByClass('group_list_row', cont).pop();
  6881. 925.  -             if (last) {
  6882. 926.  -               addClass(last, 'groups_list_last_row');
  6883. 927.  -             }
  6884. 928.  -             cur.scrollList.searchCont.innerHTML = rows;
  6885. 929.  -             show(cur.scrollList.searchCont);
  6886. 930.  -             if (emptyLocal) {
  6887. 931.  -               cur.scrollList.summary.innerHTML = summary;
  6888. 932.  -               cont.innerHTML = '';
  6889. 933.  -             }
  6890. 934.  -             if (!finish) {
  6891. 935.  -               show(cur.scrollList.prefix + cur.scrollList.tab + '_more');
  6892. 936.  -             }
  6893. 937.  -           } else {
  6894. 938.  -             cur.scrollList.searchCont.innerHTML = '';
  6895. 939.  -             hide(cur.scrollList.searchCont);
  6896. 940.  -             if (emptyLocal) {
  6897. 941.  -               cont.innerHTML = cur.scrollList.genEmpty(q);
  6898. 942.  -               cur.scrollList.summary.innerHTML = cur.scrollList.genSummary(0);
  6899. 943.  -             }
  6900. 944.  -           }
  6901. 945.  -           cur.searchOffset = count;
  6902. 946.  -         },
  6903. 947.  -         showProgress: GroupsList.showLoading,
  6904. 948.  -         hideProgress: GroupsList.hideLoading
  6905. 949.  -       })
  6906. 950.  -     }, 300);
  6907. 951.  -   },
  6908. 952.  -
  6909. 953.  -   resetSearch: function() {
  6910. 954.  -     val(cur.scrollList.query, '');
  6911. 955.  -     GroupsList.showMore(true);
  6912. 956.  -     GroupsList.updateEvents();
  6913. 957.  -   },
  6914. 958.  -
  6915. 959.  -   showLoading: function() {
  6916. 960.  -     cur.loadingShown = 1;
  6917. 961.  -     show('groups_loading');
  6918. 962.  -     hide('groups_reset_search');
  6919. 963.  -   },
  6920. 964.  -
  6921. 965.  -   hideLoading: function() {
  6922. 966.  -     cur.loadingShown = 0;
  6923. 967.  -     hide('groups_loading');
  6924. 968.  -     if (cur.scrollList.query.value) {
  6925. 969.  -       show('groups_reset_search');
  6926. 970.  -     }
  6927. 971.  -   },
  6928. 972.  -
  6929. 973.  -   goToSearch: function() {
  6930. 974.  -     var q = trim(cur.scrollList.query.value);
  6931. 975.  -     nav.go('search?c%5Bq%5D='+encodeURIComponent(q)+'&c%5Bsection%5D=communities');
  6932. 976.  -   },
  6933. 977.  -
  6934. 978.  -   showInvites: function(obj) {
  6935. 979.  -     removeClass(obj.previousSibling, 'groups_list_last_row');
  6936. 980.  -     hide(obj);
  6937. 981.  -     show(obj.nextSibling);
  6938. 982.  -   },
  6939. 983.  -
  6940. 984.  -   ttShow: function(obj, text) {
  6941. 985.  -     var showsp = 200;
  6942. 986.  -     if (cur.groupMemTT && cur.groupMemTT != obj && window.tooltips) {
  6943. 987.  -       tooltips.hideAll();
  6944. 988.  -       cur.groupMemTT = false;
  6945. 989.  -       showsp = 0;
  6946. 990.  -     }
  6947. 991.  -     cur.groupMemTT = obj;
  6948. 992.  -     return showTooltip(obj, {
  6949. 993.  -       center: 1,
  6950. 994.  -       black: 1,
  6951. 995.  -       showsp: showsp,
  6952. 996.  -       shift: [0, 2, 10],
  6953. 997.  -       text: text
  6954. 998.  -     });
  6955. 999.  -   },
  6956. 1000.  -
  6957. 1001.  -   showMapBox: function(place, zoom, link) {
  6958. 1002.  -     if (window.showZeroZoneBox && showZeroZoneBox('places', function() {
  6959. 1003.  -       GroupsList.showMapBox(place, zoom, link);
  6960. 1004.  -     })) { return; }
  6961. 1005.  -
  6962. 1006.  -     showTabbedBox('places.php', {act: 'a_get_place_box', id: place}, {stat: ['places.css', 'map.css', 'maps.js', 'ui_controls.css', 'ui_controls.js']});
  6963. 1007.  -   },
  6964. 1008.  -
  6965. 1009.  -   feedbanGroup: function(el, gid, hash) {
  6966. 1010.  -     var oid = -gid;
  6967. 1011.  -     ajax.post('al_fans.php', {act: 'feedtgl', oid: oid, hash: hash}, {
  6968. 1012.  -       onDone: function(val, str) {
  6969. 1013.  -         el.innerHTML = str;
  6970. 1014.  -         if (!cur.scrollList.lists || !cur.scrollList.lists.groups) {
  6971. 1015.  -           return;
  6972. 1016.  -         }
  6973. 1017.  -         var lst = cur.scrollList.lists.groups;
  6974. 1018.  -         if (lst && lst.length) {
  6975. 1019.  -           for (var i = 0, l = lst.length; i < l; ++i) {
  6976. 1020.  -             if (lst[i][2] == gid) {
  6977. 1021.  -               cur.scrollList.lists.groups[i][12] = val;
  6978. 1022.  -               break;
  6979. 1023.  -             }
  6980. 1024.  -           }
  6981. 1025.  -         }
  6982. 1026.  -       },
  6983. 1027.  -       showProgress: function() {
  6984. 1028.  -         el.innerHTML = '<span class="progress_inline"></span>';
  6985. 1029.  -       }
  6986. 1030.  -     });
  6987. 1031.  -   }
  6988. 1032.  - }
  6989. 1033.  -
  6990. 1034.  - try{stManager.done('groups_list.js');}catch(e){}
  6991. ------
Advertisement
Add Comment
Please, Sign In to add comment