Hormold

VK Change (#1382545809)

Oct 23rd, 2013
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 112.78 KB | None | 0 0
  1. Файл - audio.js (Старый размер - 92513 | Новый - 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, claim: nav.objLoc.claim, 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 && !cur.club) {
  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);
  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 && !cur.club) {
  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 && window.audioPlaylist && audioPlaylist.address && audioPlaylist.address.indexOf('act=feed') != -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, claim: nav.objLoc.claim, 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, claim: nav.objLoc.claim, 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. ------
Advertisement
Add Comment
Please, Sign In to add comment