Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Файл - audio.js (Старый размер - 92413 | Новый - 0):
- 0. - var Audio = {
- 1. - address: '/audio',
- 2. - scrollnode: browser.msie6 ? pageNode : window,
- 3. - fixedScroll: !(browser.msie && browser.version < 8 || browser.mobile),
- 4. - init: function(obj, audioTpl) {
- 5. - extend(cur, {
- 6. - searchCont: ge('audio_search'),
- 7. - aSearch: ge('s_search'),
- 8. - clearSearch: ge('audio_query_reset'),
- 9. - aContent: ge('initial_list'),
- 10. - sContent: ge('search_list'),
- 11. - sPreload: ge('search_preload'),
- 12. - showMore: ge('more_link'),
- 13. - sShowMore: ge('s_more_link'),
- 14. - sWrap: ge('audio_search_wrap'),
- 15. - sSummary: ge('audio_search_summary'),
- 16. - albumFilters: ge('album_filters'),
- 17. - albumFiltered: ge('album_filtered'),
- 18. - searchFilters: ge('audio_search_filters'),
- 19. - popularFilters: ge('audio_popular_filters'),
- 20. - popularOwners: ge('audio_popular_owners'),
- 21. - audioFriends: ge('audio_friends'),
- 22. - audioAlbums: ge('audio_albums'),
- 23. - audioAlbumsWrap: ge('audio_albums_wrap'),
- 24. - audioWrap: ge('audio_wrap'),
- 25. - searchInfoCont: ge('audio_search_info'),
- 26. - searchStr: "",
- 27. - autoComplete: 1,
- 28. - audioTpl: audioTpl,
- 29. - audioEl: {
- 30. - head: ge('page_header'),
- 31. - bar: ge('ac'),
- 32. - cont: ge('audio'),
- 33. - filters: ge('side_filters')
- 34. - }
- 35. - });
- 36. -
- 37. - if (ge('ac') && window.audioPlayer) {
- 38. - audioPlayer.initEvents();
- 39. - audioPlayer.registerPlayer('ac', {
- 40. - container: ge('ac'),
- 41. - performer: ge('ac_performer'),
- 42. - title: ge('ac_title'),
- 43. - titleWrap: ge('ac_name'),
- 44. - duration: ge('ac_duration'),
- 45. - load: ge('ac_load_line'),
- 46. - progress: ge('ac_pr_line'),
- 47. - progressArea: ge('ac_pr'),
- 48. - volume: ge('ac_vol_line'),
- 49. - volumeArea: ge('ac_vol'),
- 50. - play: ge('ac_play'),
- 51. - prev: ge('ac_prev'),
- 52. - next: ge('ac_next'),
- 53. - add: ge('ac_add'),
- 54. - repeat: ge('ac_repeat'),
- 55. - shuffle: ge('ac_shuffle'),
- 56. - rec: ge('ac_rec'),
- 57. - status: ge('ac_status'),
- 58. - fixed: !(browser.msie && browser.version < 8 || browser.mobile)
- 59. - });
- 60. - }
- 61. - if (browser.mobile) {
- 62. - hide('ac_vol');
- 63. - setStyle('ac_duration', {margin: 0});
- 64. - }
- 65. -
- 66. - if (!cur.allAudiosIndex) cur.allAudiosIndex = 'all';
- 67. -
- 68. - extend(cur, obj);
- 69. - cur.module = 'audio';
- 70. - //cur.disableAutoMore = true;
- 71. - if (cur.aSearch) {
- 72. - cur.aSearch.value = cur.q;
- 73. - toggleClass(cur.clearSearch, 'shown', !!cur.q);
- 74. - placeholderSetup(cur.aSearch, {back: true});
- 75. - setTimeout(function() {
- 76. - cur.aSearch.focus();
- 77. - }, 0);
- 78. - }
- 79. -
- 80. - Audio.scrollnode = browser.msie6 ? pageNode : window;
- 81. - Audio.fixedScroll = !(browser.msie && browser.version < 8 || browser.mobile);
- 82. - window.scrollTop = bodyNode.scrollTop = pageNode.scrollTop = htmlNode.scrollTop = 0;
- 83. - Audio.startEvents();
- 84. - cur.destroy.push(function() {
- 85. - Audio.stopEvents();
- 86. - });
- 87. -
- 88. - cur.nav.push(function(changed, old, n) {
- 89. - if (changed.act == 'popular') {
- 90. - Audio.loadPopular(true, intval(n.genre));
- 91. - return false;
- 92. - }
- 93. - });
- 94. -
- 95. -
- 96. - var _a = window.audioPlayer;
- 97. - if (_a && _a.showCurrentTrack) {
- 98. - _a.shuffle = false;
- 99. - _a.showCurrentTrack();
- 100. - }
- 101. -
- 102. - cur.audios = {};
- 103. - hide(cur.sContent);
- 104. -
- 105. - cur.silent = true;
- 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};
- 107. - if (cur.allAudiosIndex != 'all') {
- 108. - Audio.cacheFriendsList();
- 109. - }
- 110. - if (cur.club) {
- 111. - cur.curSection = 'club' + cur.club;
- 112. - query.club = cur.club;
- 113. - cur.searchStr = cur.q;
- 114. - }
- 115. - ajax.post(Audio.address, query, {onDone: (function(data, opts) {
- 116. - opts = eval('('+opts+')');
- 117. - if (opts.exp) {
- 118. - _a.statusExport = opts.exp;
- 119. - checkbox('currinfo_audio', (_a.hasStatusExport()));
- 120. - if (_a && _a.showCurrentTrack) _a.showCurrentTrack();
- 121. - delete opts.exp;
- 122. - }
- 123. - extend(cur, opts);
- 124. - if (cur.hashes && cur.hashes.add_hash && !_a.addHash) {
- 125. - _a.addHash = cur.hashes.add_hash;
- 126. - }
- 127. - if (query.id > 0) {
- 128. - cur.allFriendsTitles = cur.allFriendsTitles || {};
- 129. - cur.allFriendsTitles[query.id] = opts.summaryLang.all_friend_title;
- 130. - cur.allFriendsHTitles = cur.allFriendsHTitles || {};
- 131. - cur.allFriendsHTitles[query.id] = opts.summaryLang.all_friend_htitle;
- 132. - }
- 133. - var obj = eval('('+data+')');
- 134. - if (!obj) {
- 135. - return;
- 136. - }
- 137. - cur.audiosList = cur.audiosList || {};
- 138. - if ((query.club || query.id < 0) && obj.club) {
- 139. - var club = query.club || -query.id;
- 140. - cur.allClubsHTitles = cur.allClubsHTitles || {};
- 141. - cur.allClubsHTitles[club] = opts.summaryLang.all_club_htitle || cur.htitle;
- 142. - cur.allFriendsHTitles = cur.allFriendsHTitles || {};
- 143. - cur.allFriendsHTitles[-club] = opts.summaryLang.all_club_htitle || cur.htitle;
- 144. - cur.curList = 'club' + club;
- 145. - cur.audiosList[cur.curList] = obj.club;
- 146. - } else {
- 147. - cur.curList = (cur.album_id) ? 'album'+cur.album_id : cur.allAudiosIndex;
- 148. - }
- 149. - cur.searchOffset = 0;
- 150. - cur.audiosList[cur.allAudiosIndex] = obj.all ? obj.all : [];
- 151. - if (cur.allAudiosIndex == 'all') Audio.generateAlbums();
- 152. - cur.sectionCount = (cur.audiosList[cur.curList] || []).length;
- 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) {
- 154. - if (cur.sectionCount) {
- 155. - var opts = {onReorder: Audio.onAudioReorder, onMouseDown: Audio.onDragStart, onMouseUp: Audio.onDragEnd, noMoveCursor: 1};
- 156. - if (cur.audioAlbumsWrap) {
- 157. - extend(opts, {target: cur.audioAlbumsWrap, onDragOver: Audio.onDragOver, onDragOut: Audio.onDragOut});
- 158. - }
- 159. - sorter.init(cur.aContent, opts);
- 160. - }
- 161. - }
- 162. - if (cur.albums) {
- 163. - Audio.initAlbumsSort();
- 164. - }
- 165. - this.indexAll(function() {
- 166. - cur.silent = false;
- 167. - if (cur.onSilentLoad) {
- 168. - cur.onSilentLoad();
- 169. - }
- 170. - if (!cur.q || cur.club) {
- 171. - if (cur.curSection == 'recommendations' || cur.curSection == 'popular' || cur.curSection == 'feed') {
- 172. - if (cur[cur.curSection+'Audios']) {
- 173. - var k = 0;
- 174. - for (var i in cur[cur.curSection+'Audios']) {
- 175. - cur[cur.curSection+'Audios'][i]._order = k++;
- 176. - }
- 177. - audioPlayer.genPlaylist(cur[cur.curSection+'Audios'], false);
- 178. - }
- 179. - } else {
- 180. - audioPlayer.genPlaylist(cur.audiosList[cur.curList], false, cur.curList == 'all' && cur.oid == vk.id);
- 181. - }
- 182. - } else if (!query.club) {
- 183. - Audio.selectPerformer(null, cur.q);
- 184. - }
- 185. - if (cur.audio_id) {
- 186. - var audio = cur.audios[cur.audio_id];
- 187. - if (audio) {
- 188. - var audio_id = audio[0] + '_' + audio[1];
- 189. - if (audio[11] && parseInt(audio[11])) {
- 190. - var claim = parseInt(audio[11]) || 0;
- 191. - if (claim == -2) claim = 0;
- 192. - Audio.showAudioClaimWarning(audio_id, claim, audio[5] + ' – ' + audio[6]);
- 193. - } else {
- 194. - try{
- 195. - playAudioNew(audio_id);
- 196. - }catch(e){};
- 197. - }
- 198. - }
- 199. - }
- 200. - });
- 201. - }).bind(this), local: 1});
- 202. - },
- 203. -
- 204. - startEvents: function() {
- 205. - addEvent(Audio.scrollnode, 'scroll', Audio.scrollCheck);
- 206. - addEvent(window, 'resize', Audio.scrollCheck);
- 207. - addEvent(cur.aSearch, 'blur', Audio.searchBlur);
- 208. - addEvent(cur.aSearch, 'focus', Audio.searchFocus);
- 209. - cur.gpHidden = true;
- 210. - toggleGlobalPlayer(false);
- 211. - if (Audio.fixedScroll) {
- 212. - var els = geByClass('top_info_wrap', ge('page_wrap'));
- 213. - each(els, function() { hide(this); });
- 214. - hide(_stlSide);
- 215. - setTimeout(function() {
- 216. - each(els, function() { hide(this); });
- 217. - hide(_stlSide);
- 218. - }, 110);
- 219. - var headH = cur.audioEl.head.clientHeight,
- 220. - headT = getXY(cur.audioEl.head)[1],
- 221. - audioNavH = cur.audioEl.bar.offsetHeight,
- 222. - headW = cur.audioEl.head.clientWidth,
- 223. - contentY = headH + audioNavH;
- 224. - setStyle(cur.audioEl.head, {width: headW, top: headT});
- 225. - setStyle('side_bar', {top: headH + headT});
- 226. - setStyle(cur.audioEl.bar, {top: headH + headT});
- 227. - setStyle(cur.audioEl.cont, {paddingTop: contentY});
- 228. - setStyle(cur.audioEl.filters, {top: contentY});
- 229. -
- 230. - addClass(bodyNode, 'audio_fixed_nav');
- 231. - _fixedNav = true;
- 232. - }
- 233. - Audio.updateAlbumsTitles();
- 234. - Audio.handleFilterPos();
- 235. - },
- 236. -
- 237. - stopEvents: function() {
- 238. - removeEvent(Audio.scrollnode, 'scroll', Audio.scrollCheck);
- 239. - removeEvent(window, 'resize', Audio.scrollCheck);
- 240. - removeEvent(cur.aSearch, 'blur', Audio.searchBlur);
- 241. - removeEvent(cur.aSearch, 'focus', Audio.searchFocus);
- 242. - if (Audio.fixedScroll) {
- 243. - var els = geByClass('top_info_wrap', ge('page_wrap'));
- 244. - each(els, function() { show(this); });
- 245. - setStyle(cur.audioEl.head, {width: '', top: ''});
- 246. - setStyle('side_bar', {top: ''});
- 247. -
- 248. - removeClass(bodyNode, 'audio_fixed_nav');
- 249. - _fixedNav = false;
- 250. -
- 251. - show(_stlSide);
- 252. - }
- 253. - audioPlayer.deregisterPlayer('ac');
- 254. - setTimeout(function() {
- 255. - toggleGlobalPlayer(true);
- 256. - updGlobalPlayer();
- 257. - }, 100);
- 258. - },
- 259. -
- 260. - searchFocus: function() {
- 261. - var alist = ge('audios_list');
- 262. - if (!hasClass(alist, 'light')) addClass(alist, 'light');
- 263. - },
- 264. -
- 265. - searchBlur: function() {
- 266. - var alist = ge('audios_list');
- 267. - if (hasClass(alist, 'light')) removeClass(alist, 'light');
- 268. - },
- 269. -
- 270. - clearSearch: function(el, event) {
- 271. - setStyle(el, {opacity: .6});
- 272. - cur.aSearch.focus();
- 273. - if (cur.allAudiosIndex == 'all') {
- 274. - Audio.loadAlbum(0);
- 275. - } else {
- 276. - this.filterTimeout = setTimeout((function() {
- 277. - val(cur.aSearch, '');
- 278. - removeClass(cur.clearSearch, 'shown');
- 279. - this.updateList(null, cur.aSearch);
- 280. - this.hideSearchResults();
- 281. - scrollToTop();
- 282. - }).bind(this), 10);
- 283. - }
- 284. - if (isVisible(cur.searchInfoCont)) {
- 285. - hide(cur.searchInfoCont);
- 286. - }
- 287. - },
- 288. -
- 289. - updateSorterRows: function(fromEl) {
- 290. - if (fromEl && fromEl.parentNode.sorter){
- 291. - sorter.update(fromEl);
- 292. - }
- 293. - },
- 294. -
- 295. - showLyrics: function(id, lid, top) {
- 296. - var lyrics_div = ge('lyrics'+id);
- 297. - if (!isVisible(lyrics_div)) {
- 298. - show(lyrics_div);
- 299. - lyrics_div.innerHTML = "<div style='text-align: center; height: 50px; padding: 30px 10px 10px 10px'><img valign='middle' src='/images/progress7.gif'></div>";
- 300. - Audio.updateSorterRows(ge('audio'+id));
- 301. - ajax.post(Audio.address, {act: 'get_lyrics', lid: lid, aid: id, top: top ? 1 : 0}, {cache: 1, onDone: (function(responseText) {
- 302. - lyrics_div.innerHTML = responseText;
- 303. - Audio.updateSorterRows(ge('audio'+id));
- 304. - }).bind(this)});
- 305. - } else {
- 306. - lyrics_div.innerHTML = "";
- 307. - hide(lyrics_div);
- 308. - Audio.updateSorterRows(ge('audio'+id));
- 309. - Audio.handleFilterPos();
- 310. - }
- 311. - },
- 312. -
- 313. - allAudios: function() {
- 314. - return cur.audiosList ? cur.audiosList[cur.allAudiosIndex] || [] : [];
- 315. - },
- 316. -
- 317. - showRows: function(start, end, force) {
- 318. - if (cur.curSection == 'recommendations') {
- 319. - Audio.loadRecommendations();
- 320. - return;
- 321. - } else if (cur.curSection == 'popular') {
- 322. - Audio.loadPopular();
- 323. - return;
- 324. - } else if (cur.curSection == 'feed') {
- 325. - Audio.loadFeed();
- 326. - return;
- 327. - }
- 328. - if (cur.silent) {
- 329. - cur.onSilentLoad = function() {
- 330. - Audio.showRows(start, end, force);
- 331. - };
- 332. - return;
- 333. - }
- 334. - var list = cur.audiosList[cur.curList] || [];
- 335. - if (list[0] && list[0]._order !== undefined) {
- 336. - list = list.sort(function(a,b) {return a._order - b._order});
- 337. - }
- 338. - list = Audio.filterClaimed(list);
- 339. - cur.sectionCount = list.length;
- 340. - if (!cur.searchStr) {
- 341. - list = Audio.filterDeleted(list);
- 342. - if (cur.filterUnsorted) {
- 343. - list = Audio.filterByAlbum(list, 0);
- 344. - }
- 345. - cur.sectionCount = list.length;
- 346. - }
- 347. - if (start == undefined) {
- 348. - start = cur.shownAudios;
- 349. - }
- 350. - if (end == undefined) {
- 351. - end = cur.shownAudios + cur.audiosPerPage;
- 352. - }
- 353. - if (window.tooltips && cur.tooltips) {
- 354. - for (var i = 0; i < cur.tooltips.length; ++i) {
- 355. - if (cur.tooltips[i].el) {
- 356. - if (hasClass(cur.tooltips[i].el, 'audio_friend')) continue;
- 357. - if (cur.tooltips[i].el.ttimer) {
- 358. - clearTimeout(cur.tooltips[i].el.ttimer);
- 359. - }
- 360. - }
- 361. - cur.tooltips[i].hide({fasthide: true});
- 362. - }
- 363. - }
- 364. - var _a = window.audioPlayer;
- 365. - if (!list || !list.length) {
- 366. - if (cur.shownAudios == 0 && (cur.album_id || (!Audio.allAudios().length && !cur.searchStr))) {
- 367. - var msg;
- 368. - if (Audio.allAudios().length) {
- 369. - msg = (cur.album_id) ? getLang('audio_album_no_recs') : getLang('audio_no_audios_found').split('{query}').join('<b>'+cur.searchStr.replace(/([<>&#]*)/g, '')+'</b>');
- 370. - } else {
- 371. - if (cur.oid > 0 && !cur.audioFriend) {
- 372. - if (cur.id == vk.id && cur.allAudiosIndex == 'all') {
- 373. - msg = getLang('audio_no_rec_load_msg').split('{link}').join('<a href="#" onclick="Audio.addAudio(); return false">').split('{/link}').join('</a>');
- 374. - } else {
- 375. - msg = getLang('audio_user_no_recs');
- 376. - }
- 377. - } else {
- 378. - msg = cur.audioFriend > 0 ? getLang('audio_user_no_recs') : getLang('audio_group_no_recs');
- 379. - }
- 380. - }
- 381. - cur.aContent.innerHTML = '<div id="not_found" class="info_msg">'+msg+'</div>';
- 382. - }
- 383. - hide(cur.showMore);
- 384. - } else {
- 385. - if (!cur.shownAudios) cur.aContent.innerHTML = '';
- 386. - var audios = list.slice(start, end);
- 387. - if (!audios.length) {
- 388. - if (cur.shownAudios >= cur.sectionCount) {
- 389. - hide(cur.showMore);
- 390. - if (cur.searchStr) {
- 391. - this.loadRows();
- 392. - }
- 393. - }
- 394. - return;
- 395. - }
- 396. - var html = [];
- 397. - for (i in audios) {
- 398. - var audio = audios[i].slice();
- 399. - if (cur.selection) {
- 400. - audio[5] = audio[5].replace(cur.selection.re, cur.selection.val).replace(/&#(\d*)<span>(\d+)<\/span>(\d*);/g, "&#$1$2$3;");
- 401. - audio[6] = audio[6].replace(cur.selection.re, cur.selection.val).replace(/&#(\d*)<span>(\d+)<\/span>(\d*);/g, "&#$1$2$3;");
- 402. - }
- 403. - html.push(this.drawAudio(audio));
- 404. - cur.shownAudios += 1;
- 405. - }
- 406. - var au = ce('div', {innerHTML: html.join('')});
- 407. - while (au.firstChild) {
- 408. - var el = au.firstChild;
- 409. - cur.aContent.appendChild(el);
- 410. - }
- 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) {
- 412. - if (start > 0) {
- 413. - setTimeout(sorter.added.pbind(cur.aContent), 0);
- 414. - } else {
- 415. - setTimeout(function(){
- 416. - var opts = {onReorder: Audio.onAudioReorder, onMouseDown: Audio.onDragStart, onMouseUp: Audio.onDragEnd, noMoveCursor: 1};
- 417. - if (cur.audioAlbumsWrap) {
- 418. - extend(opts, {target: cur.audioAlbumsWrap, onDragOver: Audio.onDragOver, onDragOut: Audio.onDragOut});
- 419. - }
- 420. - sorter.init(cur.aContent, opts);
- 421. - }, 0);
- 422. - }
- 423. - }
- 424. - if (cur.searchCount && isVisible(cur.sContent)) {
- 425. - show(cur.sWrap);
- 426. - cur.sContent.style.paddingTop = '12px';
- 427. - cur.sSummary.innerHTML = langNumeric(cur.searchCount, cur.summaryLang['list_found'], true);
- 428. - }
- 429. - if (_a && _a.showCurrentTrack) _a.showCurrentTrack();
- 430. - }
- 431. - setTimeout(Audio.handleFilterPos, 0);
- 432. - var aid = currentAudioId(), clubList = (cur.curSection && cur.curSection.substr(0, 4) == 'club');
- 433. - if (_a && _a.gpDisabled && aid) {
- 434. - var track_id = aid.split('_')[1];
- 435. - if (!cur.audios[track_id]) _a.stop();
- 436. - }
- 437. - if (cur.justShuffled) {
- 438. - toggle(cur.showMore, cur.shownAudios < cur.sectionCount);
- 439. - return;
- 440. - }
- 441. - if (clubList) {
- 442. - Audio.hideSearchResults();
- 443. - }
- 444. - if (force) return;
- 445. - if (cur.shownAudios >= cur.sectionCount) {
- 446. - hide(cur.showMore);
- 447. - if (cur.searchStr && !clubList) {
- 448. - this.loadRows();
- 449. - } else {
- 450. - Audio.setQLoc(cur.searchStr);
- 451. - }
- 452. - } else {
- 453. - show(cur.showMore);
- 454. - Audio.setQLoc(cur.searchStr);
- 455. - }
- 456. - },
- 457. -
- 458. - loadRows: function() {
- 459. - if (cur.sPreload.innerHTML) {
- 460. - while (cur.sPreload.firstChild) {
- 461. - var el = cur.sPreload.firstChild
- 462. - cur.sContent.appendChild(el);
- 463. - }
- 464. - }
- 465. - clearTimeout(this.searchTimeout);
- 466. - this.searchTimeout = setTimeout((function() {
- 467. - Audio.searchRequest(cur.searchStr, cur.searchOffset);
- 468. - }).bind(this), 300);
- 469. - },
- 470. -
- 471. - searchRequest: function(val, offset) {
- 472. - if (!val) return;
- 473. - if (val[val.length - 1] == ' ') {
- 474. - val[val.length - 1] = '_';
- 475. - }
- 476. - addClass(cur.searchCont, 'loading');
- 477. - setStyle(cur.clearSearch, {opacity: .6});
- 478. - var query = {act: 'search', q: val, offset: offset, id: cur.id, gid: cur.gid, performer: cur.searchTypeMenu ? cur.searchTypeMenu.val() : 0};
- 479. - var l = ge('audio_lyrics_filter');
- 480. - var s = ge('selectedItems');
- 481. - if (l && parseInt(l.value)) query.lyrics = 1;
- 482. - if (s) query.sort = s.value;
- 483. - if (cur.autoComplete) query.autocomplete = cur.autoComplete;
- 484. - if (nav.objLoc.claim) query.claim = nav.objLoc.claim;
- 485. - ajax.post(Audio.address, query, {onDone: function(res, preload, options) {
- 486. - removeClass(cur.searchCont, 'loading');
- 487. - var newVal = cur.searchStr;
- 488. - if (newVal[newVal.length - 1] == ' ') {
- 489. - newVal[newVal.length - 1] = '_';
- 490. - }
- 491. - if (val != newVal) {
- 492. - return;
- 493. - }
- 494. - if (res) {
- 495. - cur.sContent.innerHTML = res;
- 496. - }
- 497. - if (preload) {
- 498. - cur.sPreload.innerHTML = preload;
- 499. - }
- 500. - Audio.applyOptions(options, offset);
- 501. - show(cur.sContent);
- 502. - if (!cur.sectionCount) {
- 503. - hide(cur.sWrap);
- 504. - cur.sContent.style.paddingTop = '0px';
- 505. - Audio.changeSummary(true);
- 506. - cur.aContent.innerHTML = '';
- 507. - if (!cur.searchCount && !res && !preload) {
- 508. - msg = getLang('audio_no_audios_found').split('{query}').join('<b>'+cur.searchStr.replace(/([<>&#]*)/g, '')+'</b>');
- 509. - cur.aContent.innerHTML = '<div id="not_found" class="info_msg">'+msg+'</div>';
- 510. - hide(cur.showMore);
- 511. - hide(cur.sContent);
- 512. - }
- 513. - } else {
- 514. - cur.sContent.style.paddingTop = '12px';
- 515. - if (cur.searchCount) {
- 516. - cur.sSummary.innerHTML = langNumeric(cur.searchCount, cur.summaryLang['list_found'], true);
- 517. - show(cur.sWrap);
- 518. - } else {
- 519. - Audio.hideSearchResults();
- 520. - hide(cur.sWrap);
- 521. - }
- 522. - }
- 523. - Audio.scrollCheck();
- 524. - if (!offset) Audio.setQLoc(cur.searchStr);
- 525. - var _a = window.audioPlayer;
- 526. - if (_a && _a.showCurrentTrack) _a.showCurrentTrack();
- 527. - },
- 528. - onFail: function() {
- 529. - removeClass(cur.searchCont, 'loading');
- 530. - },
- 531. - showProgress: function () {
- 532. - cur.isAudioLoading = true;
- 533. - },
- 534. - hideProgress: function () {
- 535. - cur.isAudioLoading = false;
- 536. - }
- 537. - });
- 538. - },
- 539. -
- 540. - changeSearchFilters: function() {
- 541. - cur.searchOffset = 0;
- 542. - Audio.searchRequest(cur.searchStr, 0);
- 543. - },
- 544. -
- 545. - hideSearchResults: function() {
- 546. - setTimeout(function(){
- 547. - cur.sContent.innerHTML = '';
- 548. - if (cur.curSection != 'recommendations' && cur.curSection != 'popular' && cur.curSection != 'feed') cur.sPreload.innerHTML = '';
- 549. - hide(cur.sContent);
- 550. - hide(cur.sWrap);
- 551. - hide(cur.sShowMore);
- 552. - Audio.scrollCheck();
- 553. - }, 0);
- 554. - },
- 555. -
- 556. - drawAudio: function(audio) {
- 557. - return cur.audioTpl(audio, cur.curSection);
- 558. - },
- 559. -
- 560. - applyOptions: function(options, offset) {
- 561. - extend(cur, options);
- 562. - if (!cur.has_more) {
- 563. - hide(cur.sShowMore);
- 564. - } else {
- 565. - show(cur.sShowMore);
- 566. - }
- 567. - if (!offset) {
- 568. - if (options.searchInfo) {
- 569. - cur.searchInfoCont.innerHTML = options.searchInfo;
- 570. - if (!isVisible(cur.searchInfoCont)) {
- 571. - show(cur.searchInfoCont);
- 572. - }
- 573. - each(geByClass('audio_friend_name_now', cur.searchInfoCont), function() {
- 574. - if (this.scrollWidth > this.clientWidth) {
- 575. - this.setAttribute('title', this.innerText || this.textContent);
- 576. - } else {
- 577. - this.removeAttribute('title');
- 578. - }
- 579. - })
- 580. - } else if (isVisible(cur.searchInfoCont)) {
- 581. - hide(cur.searchInfoCont);
- 582. - }
- 583. - }
- 584. - },
- 585. -
- 586. - handleFilterPos: function() {
- 587. - if (!Audio.fixedScroll || !cur.audioEl) return false;
- 588. - var headH = cur.audioEl.head.clientHeight, audioNavH = cur.audioEl.bar.offsetHeight,
- 589. - contentY = headH + audioNavH,
- 590. - st = Math.max(0, scrollGetY()), wh = window.lastWindowHeight || 0, pos = 0,
- 591. - filt = ge('side_panel'), filtPos = getXY(filt)[1], filtY = getSize(filt)[1],
- 592. - sf = ge('side_filters'), sfPos = (getStyle(sf, 'position') == 'fixed') ? parseInt(getStyle(sf, 'top')) : getXY(sf)[1], sfY = getSize(sf)[1],
- 593. - bottomPad = Math.max(0, st + wh - filtY - contentY),
- 594. - tooBig = (filtPos + filtY - sfPos - sfY < 20),
- 595. - lastPos = cur.filterLastPos || 100, lastSt = cur.lastSt || 0;
- 596. -
- 597. - if (!tooBig) {
- 598. - addClass(sf, 'fixed');
- 599. - pos = (wh > sfY + contentY) ? Math.min(contentY, wh - sfY - bottomPad) : Math.max(Math.min(contentY, lastPos + lastSt - st), wh - sfY - bottomPad);
- 600. - } else {
- 601. - removeClass(sf, 'fixed');
- 602. - pos = 0;
- 603. - }
- 604. - cur.filterLastPos = pos;
- 605. - cur.lastSt = st;
- 606. - setStyle(sf, {top: pos + 'px'});
- 607. -
- 608. - if (!browser.mozilla && !browser.msie && cur.lastWW !== lastWindowWidth) {
- 609. - cur.lastWW = lastWindowWidth;
- 610. - var goodLeft1 = ge('page_layout').offsetLeft,
- 611. - goodLeft2 = goodLeft1 + cur.audioEl.cont.offsetLeft,
- 612. - goodLeft3 = goodLeft2 + getSize(cur.audioEl.cont)[0] - getSize(cur.audioEl.filters)[0] - 10;
- 613. - cur.audioEl.head.style.left = ge('side_bar').style.left = goodLeft1 + 'px';
- 614. - cur.audioEl.bar.style.left = goodLeft2 + 'px';
- 615. - cur.audioEl.filters.style.left = goodLeft3 + 'px';
- 616. - setTimeout(Audio.resetStyles, 0);
- 617. - }
- 618. - },
- 619. -
- 620. - resetStyles: function() {
- 621. - cur.audioEl.head.style.left = ge('side_bar').style.left =
- 622. - cur.audioEl.bar.style.left = cur.audioEl.filters.style.left = '';
- 623. - },
- 624. -
- 625. - scrollCheck: function () {
- 626. - Audio.handleFilterPos();
- 627. - if (browser.mobile || cur.isAudioLoading || cur.disableAutoMore) return;
- 628. -
- 629. - if (!isVisible(cur.showMore) && !isVisible(cur.sShowMore)) return;
- 630. - if (!cur.curList) {
- 631. - setTimeout(Audio.scrollCheck, 50);
- 632. - return;
- 633. - }
- 634. -
- 635. - var docEl = document.documentElement;
- 636. - var ch = window.innerHeight || docEl.clientHeight || bodyNode.clientHeight;
- 637. - var st = scrollGetY();
- 638. -
- 639. - if (isVisible(cur.showMore) && st + ch + 400 > cur.showMore.offsetTop) {
- 640. - Audio.showRows();
- 641. - }
- 642. - if (isVisible(cur.sShowMore) && st + ch + 400 > cur.sShowMore.offsetTop) {
- 643. - Audio.loadRows();
- 644. - }
- 645. - },
- 646. -
- 647. - updateList: function(e, obj, force, showAlbums, fromIndex) {
- 648. - if (cur.silent) {
- 649. - cur.onSilentLoad = function() {
- 650. - Audio.updateList(e, obj, force, showAlbums);
- 651. - };
- 652. - return;
- 653. - }
- 654. - if (e && (e.keyCode == 10 || e.keyCode == 13) || cur.forceNoAutoComplete) {
- 655. - delete cur.forceNoAutoComplete
- 656. - delete cur.autoComplete;
- 657. - } else {
- 658. - cur.autoComplete = 1;
- 659. - }
- 660. - clearTimeout(this.filterTimeout);
- 661. - this.filterTimeout = setTimeout((function() {
- 662. - var str = trim(obj.value), el;
- 663. - if (str == cur.searchStr && cur.autoComplete && !cur.ignoreEqual) {
- 664. - return;
- 665. - }
- 666. - delete cur.ignoreEqual;
- 667. - delete nav.objLoc.album_id;
- 668. - delete nav.objLoc.audio_id;
- 669. - if (nav.objLoc.act == 'recommendations' || nav.objLoc.act == 'popular' || nav.objLoc.act == 'feed' || nav.objLoc.act == 'albums') delete nav.objLoc.act;
- 670. - if (showAlbums) {
- 671. - nav.objLoc.act = 'albums';
- 672. - }
- 673. - if (cur.allAudiosIndex == 'all') {
- 674. - cur.album_id = 0;
- 675. - }
- 676. - each(geByClass('audio_filter', cur.albumFilters), function(i, e) {
- 677. - removeClass(e, 'selected');
- 678. - });
- 679. - var c = Audio.allAudios().length;
- 680. - if (str) {
- 681. - el = cur.albumFiltered;
- 682. - hide(cur.audioFriends, cur.audioAlbums);
- 683. - addClass(cur.clearSearch, 'shown');
- 684. - show(cur.searchFilters);
- 685. - hide(cur.searchInfoCont);
- 686. - if (!c && cur.allAudiosIndex == 'all') removeClass(cur.audioWrap, 'audio_no_recs');
- 687. - } else {
- 688. - if (showAlbums || cur.oid != vk.id) {
- 689. - if (cur.allAudiosIndex == 'all') {
- 690. - el = ge('audios_albums') || ge('album0');
- 691. - }
- 692. - hide(cur.audioFriends);
- 693. - show(cur.audioAlbums);
- 694. - Audio.updateAlbums();
- 695. - } else if (fromIndex == 2) {
- 696. - hide(cur.audioAlbums);
- 697. - hide(cur.audioFriends);
- 698. - cur.searchInfoCont.innerHTML = cur.performerInfo[cur.allAudiosIndex];
- 699. - show(cur.searchInfoCont);
- 700. - } else {
- 701. - hide(cur.audioAlbums);
- 702. - show(cur.audioFriends);
- 703. - hide(cur.searchInfoCont);
- 704. - if (cur.allAudiosIndex == 'all') {
- 705. - el = ge('album0');
- 706. - var curEl = geByClass1('current', ge('audio_friends_list'));
- 707. - if (curEl) removeClass(curEl, 'current');
- 708. - }
- 709. - }
- 710. - removeClass(cur.clearSearch, 'shown');
- 711. - removeClass(cur.albumFiltered, 'selected');
- 712. - hide(cur.searchFilters);
- 713. - if (!c && cur.allAudiosIndex == 'all' && cur.oid <= 0) addClass(cur.audioWrap, 'audio_no_recs');
- 714. - }
- 715. - if (el) addClass(el, 'selected');
- 716. - hide(cur.popularFilters, cur.popularOwners);
- 717. - cur.searchStr = str;
- 718. - this.searchAudios(str, cur.allAudiosIndex, force);
- 719. -
- 720. - scrollToTop();
- 721. - }).bind(this), fromIndex ? 0 :10);
- 722. - },
- 723. -
- 724. - selectPerformer: function(event, name) {
- 725. - cur.aSearch.setValue(name);
- 726. - cur.forceNoAutoComplete = true;
- 727. - if (event) {
- 728. - cur.searchTypeMenu.value = 1;
- 729. - cur.searchTypeChanged({target: {index: 1}}, true);
- 730. - }
- 731. - Audio.updateList(null, cur.aSearch);
- 732. - if (event) cancelEvent(event);
- 733. - },
- 734. -
- 735. - searchAudios: function(str, type, force) {
- 736. - cur.shownAudios = 0;
- 737. - cur.curSection = type;
- 738. - var clubList = (type && type.substr(0, 4) == 'club');
- 739. - if (!clubList && cur.searchSortFilter) {
- 740. - cur.searchSortFilter.disable(false);
- 741. - cur.searchLyricsFilter.disable(false);
- 742. - removeClass(cur.albumFiltered, 'club_shown');
- 743. - delete cur.club;
- 744. - }
- 745. - if (str) {
- 746. - var htmlentities = function(s){
- 747. - var el = document.createElement('div');
- 748. - el.innerText = el.textContent = s;
- 749. - s = el.innerHTML;
- 750. - delete el;
- 751. - return s.split('"').join('"');
- 752. - }
- 753. - var htmlencode = function(str){
- 754. - return str.toLowerCase().replace(/\u2013|\u2014/g, '-');
- 755. - var aStr = str.toLowerCase().replace(/\u2013|\u2014/g, '-').split(''), i = aStr.length, aRet = [];
- 756. - while (i--) {
- 757. - var iC = aStr[i].charCodeAt();
- 758. - if ((iC > 127 && iC < 994)) {
- 759. - aRet.push('&#'+iC+';');
- 760. - } else if (iC == 36) {
- 761. - aRet.push('�'+iC+';');
- 762. - } else {
- 763. - aRet.push(htmlentities(aStr[i]));
- 764. - }
- 765. - }
- 766. - return aRet.reverse().join('');
- 767. - }
- 768. - var res = cur.audiosIndex.search(htmlencode(str));
- 769. - var newList = cur.curSection;
- 770. - newList += '_search_'+str;
- 771. -
- 772. - cur.curList = newList;
- 773. - cur.audiosList[cur.curList] = res.sort(function(a,b) {return a._order - b._order});
- 774. - audioPlayer.genPlaylist(res, false);
- 775. -
- 776. - if (str) {
- 777. - str += ' '+(parseLatin(str) || '');
- 778. - str = trim(escapeRE(str.replace(/\)/g, '')).split('&').join('&'));
- 779. - cur.selection = {
- 780. - re: new RegExp('('+str.replace(cur.audiosIndex.delimiter, '|').replace(/(^\||\|$|\?)/g, '')+')', 'gi'),
- 781. - val: '<span>$1</span>'
- 782. - };
- 783. - }
- 784. - } else {
- 785. - if (!clubList) Audio.hideSearchResults();
- 786. - cur.curList = cur.curSection;
- 787. - audioPlayer.genPlaylist(cur.audiosList[cur.curList], false, cur.curList == 'all' && cur.oid == vk.id);
- 788. - cur.selection = false;
- 789. - }
- 790. -
- 791. - cur.sectionCount = (cur.audiosList[cur.curList]) ? cur.audiosList[cur.curList].length : 0;
- 792. - this.filterTimeout = setTimeout((function() {
- 793. - if (!force) {
- 794. - hide(cur.sShowMore);
- 795. - cur.searchOffset = 0;
- 796. - }
- 797. - this.showRows(null, null, force);
- 798. - if (cur.sectionCount || !cur.searchStr) {
- 799. - this.changeSummary();
- 800. - }
- 801. - if (cur.justShuffled) {
- 802. - delete cur.justShuffled;
- 803. - var aid = currentAudioId();
- 804. - if (cur.nextPlaylist && (!aid || window.audioPlaylist && !window.audioPlaylist[aid])) {
- 805. - window.audioPlaylist = clone(cur.nextPlaylist);
- 806. - }
- 807. - if (Pads.updateAudioPlaylist) {
- 808. - Pads.updateAudioPlaylist();
- 809. - }
- 810. - }
- 811. - }).bind(this), 10);
- 812. - },
- 813. -
- 814. - indexAll: function(callback) {
- 815. - var all = Audio.allAudios(),
- 816. - replacer = function(str, p) {
- 817. - var c = intval(p);
- 818. - return (c >= 33 && c < 48) ? String.fromCharCode(c) : str;
- 819. - };
- 820. -
- 821. - cur.audiosIndex = new vkIndexer(all, function(obj) {
- 822. - cur.audios[parseInt(obj[1])] = obj;
- 823. - return (obj[5]+' '+obj[6]).replace(/\&\#(\d+);?/gi, replacer);
- 824. - }, function() {
- 825. - if (callback) {
- 826. - callback();
- 827. - }
- 828. - });
- 829. - },
- 830. -
- 831. - changeAllIndex: function(index, albumSelected, showAlbums, owner) {
- 832. - if (!cur.audiosList[index]) return;
- 833. - cur.allAudiosIndex = cur.curList = index;
- 834. - this.indexAll(function() {
- 835. - var _a = window.audioPlayer;
- 836. - Audio.mixAllAudios(_a && _a.shuffle, true);
- 837. - audioPlayer.genPlaylist(cur.audiosList[cur.curList], false, index == 'all' && cur.oid == vk.id);
- 838. - each(geByTag('div', cur.albumFilters), function(i, e) {
- 839. - removeClass(e, 'loading');
- 840. - });
- 841. - cur.ignoreEqual = true;
- 842. -
- 843. - setStyle(cur.clearSearch, {opacity: .6});
- 844. - val(cur.aSearch, '');
- 845. - removeClass(cur.clearSearch, 'shown');
- 846. - cur.searchStr = '';
- 847. - Audio.hideSearchResults();
- 848. - if (albumSelected) {
- 849. - Audio.loadAlbum(albumSelected);
- 850. - } else {
- 851. - Audio.updateList(null, cur.aSearch, undefined, showAlbums, owner ? 2 : 1);
- 852. - }
- 853. - });
- 854. - },
- 855. -
- 856. - generateAlbums: function() {
- 857. - for (var i in cur.audiosList) {
- 858. - if (i.substr(0, 5) == 'album') cur.audiosList[i] = [];
- 859. - }
- 860. - var all = Audio.allAudios();
- 861. - for (var i in all) {
- 862. - var el = all[i];
- 863. - if (el[8] && parseInt(el[8])) {
- 864. - if (!cur.audiosList['album'+el[8]]) cur.audiosList['album'+el[8]] = [];
- 865. - cur.audiosList['album'+el[8]].push(el);
- 866. - }
- 867. - }
- 868. - },
- 869. -
- 870. - changeHTitle: function(count, from_search) {
- 871. - // Updating document title
- 872. - var htitle = cur.htitle;
- 873. - if (cur.curSection && !cur.curSection.indexOf('album')) {
- 874. - htitle = ge(cur.curSection).innerHTML;
- 875. - } else if (cur.curSection && cur.curSection == 'recommendations') {
- 876. - htitle = cur.recommendTitle ? cur.recommendTitle : getLang('audio_recommended_audios');
- 877. - } else if (cur.curSection && cur.curSection == 'popular') {
- 878. - htitle = cur.popularTitle ? cur.popularTitle : getLang('audio_popular_audios');
- 879. - } else if (cur.curSection && cur.curSection.indexOf('owner') === 0) {
- 880. - htitle = cur.allFriendsHTitles[cur.audioFriend];
- 881. - } else if (from_search) {
- 882. - htitle = getLang('audio_title_search').replace('{q}', val('s_search'));
- 883. - } else if (cur.curSection && !cur.curSection.indexOf('club')) {
- 884. - htitle = cur.allClubsHTitles[cur.club] || htitle;
- 885. - } else if (cur.audioFriend && cur.allAudiosIndex && !cur.allAudiosIndex.indexOf('friend')) {
- 886. - htitle = cur.allFriendsHTitles[cur.audioFriend];
- 887. - }
- 888. - if (count && cur.lang.audio_N_recs) {
- 889. - htitle += ' | ' + getLang('audio_N_recs', count);
- 890. - }
- 891. - document.title = replaceEntities(stripHTML(htitle));
- 892. - },
- 893. -
- 894. - changeSummary: function(from_search) {
- 895. - var count = (from_search) ? cur.searchCount : cur.sectionCount;
- 896. - Audio.changeHTitle(count, from_search);
- 897. - },
- 898. -
- 899. - setQLoc: function(query) {
- 900. - clearTimeout(this.qTimeout);
- 901. - this.qTimeout = setTimeout(function() {
- 902. - if (cur.allAudiosIndex != 'all') {
- 903. - if (cur.allAudiosIndex && cur.allAudiosIndex.substr(0, 5) == 'owner') {
- 904. - extend(nav.objLoc, {owner: cur.audioFriend});
- 905. - } else {
- 906. - extend(nav.objLoc, {friend: cur.audioFriend});
- 907. - }
- 908. - } else {
- 909. - delete nav.objLoc.owner;
- 910. - delete nav.objLoc.friend;
- 911. - }
- 912. - if (cur.curSection && cur.curSection.substr(0, 4) == 'club') {
- 913. - extend(nav.objLoc, {club: cur.club});
- 914. - } else {
- 915. - delete nav.objLoc.club;
- 916. - delete nav.objLoc.genre;
- 917. - }
- 918. - if (query) {
- 919. - extend(nav.objLoc, {q: query});
- 920. - var performer = cur.searchTypeMenu ? parseInt(cur.searchTypeMenu.val()) : 0;
- 921. - if (performer) {
- 922. - extend(nav.objLoc, {performer: performer});
- 923. - } else {
- 924. - delete nav.objLoc.performer;
- 925. - }
- 926. - } else {
- 927. - delete nav.objLoc.q;
- 928. - }
- 929. - nav.setLoc(nav.objLoc);
- 930. - }, 500);
- 931. - },
- 932. -
- 933. - filterClaimed: function(arr) {
- 934. - var len = arr.length;
- 935. - var res = [];
- 936. - for (var i = 0; i < len; i++) {
- 937. - var t = arr[i];
- 938. - if (t && (!(t[11] && parseInt(t[11])) || t[12] && parseInt(t[12])) || nav.objLoc.claim) {
- 939. - res.push(t);
- 940. - }
- 941. - }
- 942. - return res;
- 943. - },
- 944. -
- 945. - filterDeleted: function(arr) {
- 946. - var len = arr.length;
- 947. - var res = [];
- 948. - for (var i = 0; i < len; i++) {
- 949. - var t = arr[i];
- 950. - if (cur.audios && cur.audios[t[1]] && !cur.audios[t[1]].deleted) {
- 951. - res.push(t);
- 952. - }
- 953. - }
- 954. - return res;
- 955. - },
- 956. -
- 957. - filterByAlbum: function(arr, album) {
- 958. - var len = arr.length;
- 959. - var res = [];
- 960. - for (var i = 0; i < len; i++) {
- 961. - var t = arr[i];
- 962. - if (album == t[8]) {
- 963. - res.push(t);
- 964. - }
- 965. - }
- 966. - return res;
- 967. - },
- 968. -
- 969. - animateAdded: function(el, speed) {
- 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>');
- 971. - el.parentNode.replaceChild(c, el);
- 972. - el = c;
- 973. - setTimeout(function() {
- 974. - var anim = geByClass1('audio_add_anim', el), add = anim.firstChild, added = add.nextSibling;
- 975. - cssAnim(anim, {left: '-15px'}, {duration: speed}, function() {
- 976. - setStyle(anim.parentNode, {width: '15px'});
- 977. - setStyle(anim.parentNode.parentNode, {paddingLeft: '2px'});
- 978. - setStyle(anim, {left: '-13px'});
- 979. - });
- 980. - cssAnim(add, {opacity: 0}, {duration: speed});
- 981. - cssAnim(added, {opacity: 1}, {duration: speed});
- 982. - }, 0);
- 983. - return el;
- 984. - },
- 985. -
- 986. - addShareAudio: function(el, aid, oid, hash, gid, top) {
- 987. - if (el.tt) el.tt.hide();
- 988. - el = Audio.animateAdded(el, 200);
- 989. - var query = {act:'add', aid:aid, oid:oid, hash:hash, top:top};
- 990. - if (gid) query.gid = cur.gid;
- 991. - if (cur.curSection == 'recommendations') query.recommendation = 1;
- 992. - if ((cur.module == 'audio' || cur.module == 'feed') && nav.objLoc['q'] || cur.module == 'search' && nav.objLoc['c[q]']) query.search = 1;
- 993. - ajax.post(Audio.address, query, {
- 994. - onDone: function (data, res) {
- 995. - var obj = eval('('+data+')');
- 996. - if (((!cur.gid && cur.id == vk.id) || (cur.gid && gid)) && obj) {
- 997. - setTimeout(function(){
- 998. - obj = obj['all'][0];
- 999. - var all_list = cur.audiosList['all'];
- 1000. - if (all_list && all_list.length) {
- 1001. - obj._order = all_list[0]._order - 1;
- 1002. - cur.audiosList['all'].splice(0,0,obj);
- 1003. - } else {
- 1004. - obj._order = 0;
- 1005. - cur.audiosList['all'] = [obj];
- 1006. - }
- 1007. - cur.audios[obj[1]] = obj;
- 1008. - if (cur.allAudiosIndex == 'all') {
- 1009. - cur.audiosIndex.add(obj);
- 1010. - }
- 1011. - }, 0);
- 1012. - }
- 1013. - var showShare = function() {
- 1014. - addClass(ge('audio'+oid+'_'+aid), 'tt_shown');
- 1015. - showTooltip(el, {
- 1016. - content: res.content,
- 1017. - slide: 15,
- 1018. - shift: [59, 5, 0],
- 1019. - black: 1,
- 1020. - hidedt: 200,
- 1021. - className: 'audio_add_tt wall_tt rich',
- 1022. - onHide: function() {
- 1023. - removeClass(ge('audio'+oid+'_'+aid), 'tt_shown');
- 1024. - }
- 1025. - });
- 1026. - var tip = el.tt;
- 1027. - if (tip && !tip.inited) {
- 1028. - var a = geByClass('add_cont', tip.container)[0];
- 1029. - tip.onClean = function() {
- 1030. - tip.inited = false;
- 1031. - removeEvent(tip.container, 'mouseover', tip.show);
- 1032. - removeEvent(tip.container, 'mouseout', tip.hide);
- 1033. - }
- 1034. - addEvent(tip.container, 'mouseover', tip.show);
- 1035. - addEvent(tip.container, 'mouseout', tip.hide);
- 1036. - addEvent(a, 'click', function(){
- 1037. - toggleClass(this, 'on');
- 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};
- 1039. - if (gid) share_q.gid = cur.gid;
- 1040. - ajax.post(Audio.address, share_q, {
- 1041. - onDone: function(data) {
- 1042. - if (data) tip.status = data;
- 1043. - }
- 1044. - });
- 1045. - });
- 1046. - tip.inited = true;
- 1047. - }
- 1048. - }
- 1049. - addEvent(el, 'mouseover', showShare);
- 1050. - if (!cur.addedIds) cur.addedIds = {};
- 1051. - cur.addedIds[oid+'_'+aid] = 1;
- 1052. - if (window.audioPlayer && currentAudioId()) {
- 1053. - var cur_aids = currentAudioId().split('_');
- 1054. - if (cur_aids[0] == oid && cur_aids[1] == aid) {
- 1055. - audioPlayer.showCurrentAdded();
- 1056. - }
- 1057. - }
- 1058. - }
- 1059. - });
- 1060. - },
- 1061. -
- 1062. - alistOver: function(obj){
- 1063. - if (!hasClass(obj, 'audio_list_cell_on')) {
- 1064. - obj.className = 'audio_list_cell_over';
- 1065. - }
- 1066. - },
- 1067. -
- 1068. - alistOff: function(obj) {
- 1069. - if (!hasClass(obj, 'audio_list_cell_on')){
- 1070. - obj.className = 'audio_list_cell';
- 1071. - }
- 1072. - },
- 1073. -
- 1074. - listOut: function(obj) {
- 1075. - removeClass(obj, 'over');
- 1076. - },
- 1077. -
- 1078. - listOver: function(obj) {
- 1079. - addClass(obj, 'over');
- 1080. - },
- 1081. -
- 1082. - loadAlbum: function(album_id, filter, showAlbums) {
- 1083. - if (cur.silent) {
- 1084. - cur.onSilentLoad = function() {
- 1085. - Audio.loadAlbum(album_id, filter, showAlbums);
- 1086. - };
- 1087. - return;
- 1088. - }
- 1089. - if (!album_id && !showAlbums && (cur.oid == vk.id) && isVisible('audio_more_friends')) {
- 1090. - cur.shownFriends = [];
- 1091. - Audio.showMoreFriends(addClass.pbind(ge('album0'), 'loading'), removeClass.pbind(ge('album0'), 'loading'));
- 1092. - }
- 1093. - //if (cur.searchStr && isVisible(cur.searchInfoCont)) {
- 1094. - hide(cur.searchInfoCont);
- 1095. - //}
- 1096. - if (cur.allAudiosIndex != 'all') {
- 1097. - Audio.loadFriendsAudios(vk.id, 'all', album_id, showAlbums);
- 1098. - return;
- 1099. - }
- 1100. - if (!Audio.allAudios().length && cur.allAudiosIndex == 'all' && cur.oid <= 0) {
- 1101. - addClass(cur.audioWrap, 'audio_no_recs');
- 1102. - }
- 1103. - if (filter) {
- 1104. - cur.filterUnsorted = 1;
- 1105. - } else {
- 1106. - delete cur.filterUnsorted;
- 1107. - }
- 1108. - var curSel = cur.filterUnsorted ? ge('album_unsorted') : (showAlbums ? ge('audios_albums') : ge('album' + album_id));
- 1109. - cur.lastAct = 'album' + album_id;
- 1110. - album_id = album_id || 0;
- 1111. - each(geByClass('audio_filter', cur.albumFilters), function(i, e) {
- 1112. - removeClass(e, 'selected');
- 1113. - });
- 1114. - if (curSel) addClass(curSel, 'selected');
- 1115. - removeClass(cur.albumFiltered, 'selected');
- 1116. - hide(cur.popularFilters, cur.popularOwners, cur.searchFilters);
- 1117. - if (album_id == 0 && !showAlbums && (cur.oid == vk.id)) {
- 1118. - hide(cur.audioAlbums);
- 1119. - show(cur.audioFriends);
- 1120. - var curEl = geByClass1('current', ge('audio_friends_list'));
- 1121. - if (curEl) removeClass(curEl, 'current');
- 1122. - } else {
- 1123. - hide(cur.audioFriends);
- 1124. - show(cur.audioAlbums);
- 1125. - }
- 1126. - if (showAlbums && !filter && !album_id) {
- 1127. - Audio.updateAlbums();
- 1128. - }
- 1129. - delete nav.objLoc.q;
- 1130. - delete nav.objLoc.owner;
- 1131. - delete nav.objLoc.friend;
- 1132. - delete cur.recsOffset;
- 1133. - delete cur.popularOffset;
- 1134. - delete nav.objLoc.club;
- 1135. - delete nav.objLoc.genre;
- 1136. - delete nav.objLoc.audio_id;
- 1137. - delete cur._back;
- 1138. - if (nav.objLoc.act == 'recommendations' || nav.objLoc.act == 'popular' || nav.objLoc.act == 'feed' || nav.objLoc.act == 'albums') delete nav.objLoc.act;
- 1139. - if (album_id) {
- 1140. - extend(nav.objLoc, {album_id: album_id});
- 1141. - } else if (showAlbums) {
- 1142. - extend(nav.objLoc, {act: 'albums'});
- 1143. - } else {
- 1144. - delete nav.objLoc.album_id;
- 1145. - }
- 1146. - nav.setLoc(nav.objLoc);
- 1147. - clearTimeout(this.filterTimeout);
- 1148. - this.filterTimeout = setTimeout((function() {
- 1149. - val(cur.aSearch, '');
- 1150. - removeClass(cur.clearSearch, 'shown');
- 1151. - cur.searchStr = '';
- 1152. - cur.album_id = album_id;
- 1153. - var type = (album_id) ? 'album'+album_id : cur.allAudiosIndex;
- 1154. - this.searchAudios('', type);
- 1155. - this.hideSearchResults();
- 1156. - scrollToTop();
- 1157. - }).bind(this), 10);
- 1158. - if (cur.oid == vk.id) {
- 1159. - ajax.post(Audio.address, {act: 'list_stats', albums: (album_id || showAlbums) ? 1 : 0});
- 1160. - }
- 1161. - },
- 1162. -
- 1163. - addAudio: function(params, event) {
- 1164. - if (cur.uploadBanned) {
- 1165. - setTimeout(showFastBox(getLang('audio_no_upload_title'), getLang('audio_claims_no_upload')).hide, 5000);
- 1166. - if (event) cancelEvent(event);
- 1167. - return false;
- 1168. - }
- 1169. - showBox(Audio.address, extend(params || {}, {act: 'new_audio', gid: cur.gid}), {
- 1170. - params: {width: '440px', bodyStyle: 'padding: 0px; position: relative;'}
- 1171. - });
- 1172. - if (event) cancelEvent(event);
- 1173. - return false;
- 1174. - },
- 1175. -
- 1176. - mixAllAudios: function(mix, noShuffle) {
- 1177. - var all_list = Audio.allAudios(), _a = window.audioPlayer, current = 0;
- 1178. - if (!all_list) return;
- 1179. - if (mix) {
- 1180. - if (all_list[0] && all_list[0]._old_order !== undefined) return;
- 1181. - for (var i = all_list.length; i; ) {
- 1182. - var j = parseInt(Math.random() * i)
- 1183. - var x = all_list[--i];
- 1184. - all_list[i] = all_list[j];
- 1185. - all_list[i]._old_order = all_list[i]._order;
- 1186. - all_list[i]._order = i;
- 1187. - if (currentAudioId() == all_list[i][0]+'_'+all_list[i][1]) {
- 1188. - current = i;
- 1189. - }
- 1190. - all_list[j] = x;
- 1191. - };
- 1192. - if (current) {
- 1193. - var x = all_list[current];
- 1194. - all_list[current] = all_list[0];
- 1195. - all_list[current]._order = current;
- 1196. - all_list[0] = x;
- 1197. - all_list[0]._order = 0;
- 1198. - }
- 1199. - } else {
- 1200. - for (var i in all_list) {
- 1201. - if (all_list[i]._old_order !== undefined) {
- 1202. - all_list[i]._order = all_list[i]._old_order;
- 1203. - delete all_list[i]._old_order;
- 1204. - }
- 1205. - };
- 1206. - }
- 1207. - if (!noShuffle) cur.justShuffled = true;
- 1208. - },
- 1209. - mixAudios: function() {
- 1210. - if (cur.curSection == 'recommendations') {
- 1211. - Audio.loadRecommendations({update: 'remix'});
- 1212. - return;
- 1213. - }
- 1214. - if (cur.curSection == 'popular') {
- 1215. - Audio.loadPopular('remix');
- 1216. - return;
- 1217. - }
- 1218. - if (cur.silent) {
- 1219. - cur.onSilentLoad = function() {
- 1220. - Audio.mixAudios();
- 1221. - };
- 1222. - return;
- 1223. - }
- 1224. - var _a = window.audioPlayer;
- 1225. - Audio.mixAllAudios(_a && _a.shuffle);
- 1226. - cur.ignoreEqual = true;
- 1227. - if (cur.album_id) {
- 1228. - this.loadAlbum(cur.album_id);
- 1229. - } else {
- 1230. - this.updateList(null, cur.aSearch, undefined, nav.objLoc.act == 'albums');
- 1231. - }
- 1232. - cur.shuffled = _a && _a.shuffle;
- 1233. - },
- 1234. -
- 1235. - loadRecommendations: function(opts) {
- 1236. - if (cur.loadingRecs) return;
- 1237. - opts = opts || {};
- 1238. - var update = opts.update, audioId = opts.audioId;
- 1239. - if (update) {
- 1240. - delete cur.recsOffset;
- 1241. - delete cur.recommendIds;
- 1242. - delete cur.recommendAudios;
- 1243. - delete cur.preloadJSON;
- 1244. - }
- 1245. - if (audioId) {
- 1246. - cur.recsAudioId = audioId;
- 1247. - } else if (update === true) {
- 1248. - delete cur.recsAudioId;
- 1249. - }
- 1250. - each(geByClass('audio_filter', cur.albumFilters), function(i, e) {
- 1251. - removeClass(e, 'selected');
- 1252. - });
- 1253. - if (cur.searchStr && isVisible(cur.searchInfoCont)) {
- 1254. - hide(cur.searchInfoCont);
- 1255. - }
- 1256. - var rec_filter = ge('recommendations');
- 1257. - addClass(rec_filter, 'selected');
- 1258. - removeClass(cur.albumFiltered, 'selected');
- 1259. - hide(cur.searchFilters, cur.popularFilters);
- 1260. - if (cur.oid == vk.id) {
- 1261. - hide(cur.audioFriends, cur.audioAlbums);
- 1262. - hide(cur.searchInfoCont);
- 1263. - }
- 1264. - removeClass(cur.albumFiltered, 'club_shown');
- 1265. - Audio.handleFilterPos();
- 1266. - cur.lastSection = cur.curSection;
- 1267. - cur.curSection = 'recommendations';
- 1268. - if (cur.recsOffset === undefined) {
- 1269. - cur.recsOffset = 0;
- 1270. - } else {
- 1271. - addClass(cur.showMore, 'loading');
- 1272. - }
- 1273. - if (cur.recommendIds === undefined) cur.recommendIds = [];
- 1274. - if (cur.recommendAudios === undefined) cur.recommendAudios = [];
- 1275. - if (cur.recsCount === undefined) cur.recsCount = 0;
- 1276. - if (cur.sPreload.innerHTML) {
- 1277. - while (cur.sPreload.firstChild) {
- 1278. - var el = cur.sPreload.firstChild;
- 1279. - cur.aContent.appendChild(el);
- 1280. - cur.recsCount++;
- 1281. - }
- 1282. - }
- 1283. - if (cur.preloadJSON) {
- 1284. - json = cur.preloadJSON['all'];
- 1285. - var cur_order = cur.recsCount;
- 1286. - for (var i in json) {
- 1287. - var audio = json[i];
- 1288. - audio._order = cur_order++;
- 1289. - if (indexOf(cur.recommendIds, audio[0]+"_"+audio[1]) == -1) {
- 1290. - cur.recommendIds.push(audio[0]+"_"+audio[1]);
- 1291. - cur.recommendAudios.push(audio);
- 1292. - }
- 1293. - }
- 1294. - var aid = currentAudioId(), needs_update = (aid && cur.recommendIds && indexOf(cur.recommendIds, aid) != -1);
- 1295. - audioPlayer.genPlaylist(cur.recommendAudios, needs_update);
- 1296. - }
- 1297. - if (cur.noRecommendations) {
- 1298. - hide(cur.showMore);
- 1299. - delete cur.noRecommendations;
- 1300. - return;
- 1301. - }
- 1302. - if (opts.tt) {
- 1303. - opts.tt.hide();
- 1304. - }
- 1305. - cur.loadingRecs = true;
- 1306. - cur.lastAct = 'recommendations';
- 1307. - var offset = cur.recsOffset, query = {act: 'get_recommendations', id: cur.id, offset: offset},
- 1308. - needsUpdate = window.audioPlayer && audioPlayer.shuffle;
- 1309. - if (update == 'remix' || needsUpdate != cur.recsRemix) {
- 1310. - cur.recsRemix = needsUpdate;
- 1311. - query.remix = needsUpdate ? 1 : 0;
- 1312. - var aid = currentAudioId();
- 1313. - if (aid && window.audioPlaylist && audioPlaylist[aid] && audioPlaylist.address && audioPlaylist.address.indexOf('act=recommendations') > 0) {
- 1314. - var a = audioPlaylist[aid];
- 1315. - if (a[10]) query.current = a[10]+' '+aid;
- 1316. - }
- 1317. - }
- 1318. - if (cur.recsAudioId) {
- 1319. - query.audio_id = cur.recsAudioId;
- 1320. - }
- 1321. - ajax.post(Audio.address, query, {
- 1322. - onDone: function(rows, preload, json, preload_json, options, ownersRows) {
- 1323. - delete cur.loadingRecs;
- 1324. - if (cur.lastAct != 'recommendations') return;
- 1325. - if (!offset) {
- 1326. - if (ownersRows) {
- 1327. - val('audio_popular_owners_rows', ownersRows);
- 1328. - show(cur.popularOwners);
- 1329. - } else {
- 1330. - hide(cur.popularOwners);
- 1331. - }
- 1332. - }
- 1333. - if (options.recsCount === 0 && offset) {
- 1334. - cur.noRecommendations = true;
- 1335. - delete options.recsOffset;
- 1336. - }
- 1337. - if (json) {
- 1338. - json = eval('('+json+')');
- 1339. - json = json['all'];
- 1340. - var cur_order = cur.recsCount;
- 1341. - for (var i in json) {
- 1342. - var audio = json[i];
- 1343. - audio._order = cur_order++;
- 1344. - if (indexOf(cur.recommendIds, audio[0]+"_"+audio[1]) == -1) {
- 1345. - cur.recommendIds.push(audio[0]+"_"+audio[1]);
- 1346. - cur.recommendAudios.push(audio);
- 1347. - }
- 1348. - }
- 1349. - var aid = currentAudioId(), needs_update = (aid && cur.recommendIds && indexOf(cur.recommendIds, aid) != -1);
- 1350. - audioPlayer.genPlaylist(cur.recommendAudios, needs_update);
- 1351. - if (query.audio_id) {
- 1352. - cur.nextPlaylist.rec = 1;
- 1353. - }
- 1354. - }
- 1355. - removeClass(cur.showMore, 'loading');
- 1356. - if (offset) {
- 1357. - delete options.recsCount;
- 1358. - }
- 1359. - if (options) extend(cur, options);
- 1360. - if (!offset) {
- 1361. - cur.aContent.innerHTML = rows;
- 1362. - }
- 1363. -
- 1364. - cur.preloadJSON = preload_json ? eval('('+preload_json+')') : false;
- 1365. - cur.sPreload.innerHTML = '';
- 1366. - var au = ce('div', {innerHTML: preload});
- 1367. - while (au.firstChild) {
- 1368. - if (!ge(au.firstChild.id)) {
- 1369. - var el = au.firstChild;
- 1370. - cur.sPreload.appendChild(el);
- 1371. - } else {
- 1372. - au.removeChild(au.firstChild);
- 1373. - }
- 1374. - }
- 1375. -
- 1376. - if (cur.recsCount && !query.audio_id) {
- 1377. - show(cur.showMore);
- 1378. - } else {
- 1379. - hide(cur.showMore);
- 1380. - }
- 1381. - if (query.remix) {
- 1382. - cur.justShuffled = true;
- 1383. - }
- 1384. - Audio.changeHTitle();
- 1385. - val(cur.aSearch, '');
- 1386. - removeClass(cur.clearSearch, 'shown');
- 1387. - cur.searchStr = '';
- 1388. - cur.album_id = 0;
- 1389. - Audio.hideSearchResults();
- 1390. - hide(cur.sShowMore);
- 1391. - if (!offset) scrollToTop();
- 1392. - delete nav.objLoc.q;
- 1393. - delete nav.objLoc.owner;
- 1394. - delete nav.objLoc.friend;
- 1395. - delete nav.objLoc.album_id;
- 1396. - delete nav.objLoc.club;
- 1397. - delete nav.objLoc.genre;
- 1398. - delete cur._back;
- 1399. - extend(nav.objLoc, {act: 'recommendations'});
- 1400. - if (query.audio_id) {
- 1401. - extend(nav.objLoc, {audio_id: query.audio_id});
- 1402. - } else {
- 1403. - delete nav.objLoc.audio_id;
- 1404. - }
- 1405. - nav.setLoc(nav.objLoc);
- 1406. - var _a = window.audioPlayer;
- 1407. - if (_a && _a.showCurrentTrack) _a.showCurrentTrack();
- 1408. - if (window.Pads && Pads.updateAudioPlaylist) {
- 1409. - Pads.updateAudioPlaylist();
- 1410. - }
- 1411. - },
- 1412. - onFail: function(msg) {
- 1413. - delete cur.loadingRecs;
- 1414. - cur.curSection = cur.lastSection;
- 1415. - removeClass(ge('recommendations'), 'selected');
- 1416. - setTimeout(showFastBox(getLang('global_error'), msg).hide, 3000);
- 1417. - return true;
- 1418. - },
- 1419. - showProgress: function () {
- 1420. - addClass(rec_filter, 'loading');
- 1421. - },
- 1422. - hideProgress: function () {
- 1423. - removeClass(rec_filter, 'loading');
- 1424. - }
- 1425. - });
- 1426. - cur.recsOffset += offset ? 50 : 100;
- 1427. - },
- 1428. -
- 1429. - loadPopular: function(update, genre) {
- 1430. - if (cur.silent) {
- 1431. - cur.onSilentLoad = function() {
- 1432. - Audio.loadPopular(update, genre);
- 1433. - };
- 1434. - return;
- 1435. - }
- 1436. - if (cur.loadingPopular) return;
- 1437. - if (cur.popularAudios === undefined) {
- 1438. - cur.popularAudios = [];
- 1439. - }
- 1440. - if (update) {
- 1441. - delete cur.popularOffset;
- 1442. - delete cur.popularIds;
- 1443. - delete cur.popularAudios[genre];
- 1444. - delete cur.preloadJSON;
- 1445. - if (genre !== undefined) {
- 1446. - cur.genre = genre;
- 1447. - }
- 1448. - }
- 1449. - each(geByClass('audio_filter', cur.albumFilters), function(i, e) {
- 1450. - removeClass(e, 'selected');
- 1451. - });
- 1452. - if (cur.searchStr && isVisible(cur.searchInfoCont)) {
- 1453. - hide(cur.searchInfoCont);
- 1454. - }
- 1455. - var genre_filter = false;
- 1456. - if (cur.genre) {
- 1457. - var prevGenre = geByClass1('selected', ge('audio_genres'));
- 1458. - if (prevGenre) {
- 1459. - removeClass(prevGenre, 'selected');
- 1460. - }
- 1461. -
- 1462. - genre_filter = ge('audio_genre_'+cur.genre);
- 1463. - if (genre_filter) {
- 1464. - addClass(genre_filter, 'selected');
- 1465. - } else {
- 1466. - cur.genre = 0;
- 1467. - }
- 1468. - }
- 1469. - var pop_filter = ge('top_audios');
- 1470. - addClass(pop_filter, 'selected');
- 1471. - removeClass(cur.albumFiltered, 'selected');
- 1472. - toggle(cur.audioFriends, false);
- 1473. - hide(cur.searchInfoCont);
- 1474. - if (cur.popularFilters) {
- 1475. - show(cur.popularFilters);
- 1476. - hide(cur.audioAlbums);
- 1477. - } else {
- 1478. - show(cur.audioAlbums);
- 1479. - Audio.updateAlbums();
- 1480. - }
- 1481. - removeClass(cur.albumFiltered, 'club_shown');
- 1482. - hide(cur.searchFilters, cur.popularOwners);
- 1483. - Audio.handleFilterPos();
- 1484. - cur.curSection = 'popular';
- 1485. - if (cur.popularOffset === undefined) {
- 1486. - cur.popularOffset = 0;
- 1487. - } else {
- 1488. - addClass(cur.showMore, 'loading');
- 1489. - }
- 1490. - if (cur.popularIds === undefined) cur.popularIds = [];
- 1491. - if (cur.popularAudios[genre] === undefined) cur.popularAudios[genre] = [];
- 1492. - if (cur.popularCount === undefined) cur.popularCount = 0;
- 1493. - if (cur.sPreload.innerHTML) {
- 1494. - while (cur.sPreload.firstChild) {
- 1495. - var el = cur.sPreload.firstChild;
- 1496. - cur.aContent.appendChild(el);
- 1497. - cur.popularCount++;
- 1498. - }
- 1499. - }
- 1500. - if (cur.preloadJSON) {
- 1501. - json = cur.preloadJSON['all'];
- 1502. - var cur_order = cur.popularCount;
- 1503. - for (var i in json) {
- 1504. - var audio = json[i];
- 1505. - audio._order = cur_order++;
- 1506. - if (indexOf(cur.popularIds, audio[0]+"_"+audio[1]) == -1) {
- 1507. - cur.popularIds.push(audio[0]+"_"+audio[1]);
- 1508. - cur.popularAudios[genre].push(audio);
- 1509. - }
- 1510. - }
- 1511. - var aid = currentAudioId(), needs_update = (aid && cur.popularIds && indexOf(cur.popularIds, aid) != -1);
- 1512. - audioPlayer.genPlaylist(cur.popularAudios[genre], needs_update);
- 1513. - }
- 1514. - if (cur.noPopular) {
- 1515. - hide(cur.showMore);
- 1516. - delete cur.noPopular;
- 1517. - return;
- 1518. - }
- 1519. - cur.loadingPopular = true;
- 1520. - cur.lastAct = 'popular';
- 1521. - var offset = cur.popularOffset, query = {act: 'get_popular', offset: offset},
- 1522. - needsUpdate = window.audioPlayer && audioPlayer.shuffle;
- 1523. - if (nav.objLoc.update) {
- 1524. - query.update = 1;
- 1525. - }
- 1526. - if (needsUpdate && !offset) query.offset = -1;
- 1527. - if (update == 'remix' || needsUpdate != cur.popRemix) {
- 1528. - cur.popRemix = needsUpdate;
- 1529. - query.remix = needsUpdate ? 1 : 0;
- 1530. - var aid = currentAudioId();
- 1531. - if (aid && window.audioPlaylist && audioPlaylist[aid] && audioPlaylist.address && audioPlaylist.address.indexOf('act=popular') > 0) {
- 1532. - query.current = aid;
- 1533. - }
- 1534. - }
- 1535. - if (cur.topType !== undefined) {
- 1536. - query.type = cur.topType;
- 1537. - delete cur.topType;
- 1538. - }
- 1539. - if (cur.genre) {
- 1540. - query.genre = cur.genre;
- 1541. - }
- 1542. - ajax.post(Audio.address, query, {
- 1543. - onDone: function(rows, preload, json, preload_json, options, genres) {
- 1544. - delete cur.loadingPopular;
- 1545. - if (cur.lastAct != 'popular') return;
- 1546. - if (options.popularCount === 0 && offset) {
- 1547. - cur.noPopular = true;
- 1548. - delete options.popularOffset;
- 1549. - }
- 1550. - if (json) {
- 1551. - json = eval('('+json+')');
- 1552. - json = json['all'];
- 1553. - var cur_order = cur.popularCount;
- 1554. - for (var i in json) {
- 1555. - var audio = json[i];
- 1556. - audio._order = cur_order++;
- 1557. - if (indexOf(cur.popularIds, audio[0]+"_"+audio[1]) == -1) {
- 1558. - cur.popularIds.push(audio[0]+"_"+audio[1]);
- 1559. - cur.popularAudios[genre].push(audio);
- 1560. - }
- 1561. - }
- 1562. - var aid = currentAudioId(), needs_update = (aid && cur.popularIds && indexOf(cur.popularIds, aid) != -1);
- 1563. - audioPlayer.genPlaylist(cur.popularAudios[genre], needs_update);
- 1564. - }
- 1565. - removeClass(cur.showMore, 'loading');
- 1566. - if (offset) {
- 1567. - delete options.popularCount;
- 1568. - }
- 1569. - if (options) extend(cur, options);
- 1570. - if (!offset) {
- 1571. - cur.aContent.innerHTML = rows;
- 1572. - }
- 1573. -
- 1574. - if (preload_json) {
- 1575. - cur.preloadJSON = eval('('+preload_json+')');
- 1576. - } else {
- 1577. - cur.preloadJSON = {};
- 1578. - }
- 1579. - cur.sPreload.innerHTML = '';
- 1580. - var au = ce('div', {innerHTML: preload});
- 1581. - while (au.firstChild) {
- 1582. - if (!ge(au.firstChild.id)) {
- 1583. - var el = au.firstChild;
- 1584. - cur.sPreload.appendChild(el);
- 1585. - } else {
- 1586. - au.removeChild(au.firstChild);
- 1587. - }
- 1588. - }
- 1589. -
- 1590. - if (cur.popularCount) {
- 1591. - show(cur.showMore);
- 1592. - } else {
- 1593. - hide(cur.showMore);
- 1594. - }
- 1595. - if (update == 'remix') {
- 1596. - cur.justShuffled = true;
- 1597. - }
- 1598. - if (genres) {
- 1599. - ge('audio_genres').innerHTML = genres;
- 1600. - }
- 1601. - Audio.changeHTitle();
- 1602. - val(cur.aSearch, '');
- 1603. - removeClass(cur.clearSearch, 'shown');
- 1604. - cur.searchStr = '';
- 1605. - cur.album_id = 0;
- 1606. - Audio.hideSearchResults();
- 1607. - hide(cur.sShowMore);
- 1608. - if (!offset) scrollToTop();
- 1609. - delete nav.objLoc.q;
- 1610. - delete nav.objLoc.owner;
- 1611. - delete nav.objLoc.friend;
- 1612. - delete nav.objLoc.album_id;
- 1613. - delete nav.objLoc.club;
- 1614. - delete nav.objLoc.genre;
- 1615. - delete nav.objLoc.audio_id;
- 1616. - nav.objLoc.act = 'popular';
- 1617. - if (cur.genre) {
- 1618. - nav.objLoc.genre = cur.genre;
- 1619. - } else {
- 1620. - delete nav.objLoc.genre;
- 1621. - }
- 1622. - nav.setLoc(nav.objLoc);
- 1623. - var _a = window.audioPlayer;
- 1624. - if (_a && _a.showCurrentTrack) _a.showCurrentTrack();
- 1625. - if (window.tooltips) {
- 1626. - tooltips.destroyAll();
- 1627. - }
- 1628. - if (window.Pads && Pads.updateAudioPlaylist) {
- 1629. - Pads.updateAudioPlaylist();
- 1630. - }
- 1631. - if (options.infoJS) {
- 1632. - eval('(function(){' + options.infoJS + ';})()');
- 1633. - }
- 1634. - },
- 1635. - showProgress: function () {
- 1636. - addClass(genre_filter || pop_filter, 'loading');
- 1637. - },
- 1638. - hideProgress: function () {
- 1639. - removeClass(genre_filter || pop_filter, 'loading');
- 1640. - }
- 1641. - });
- 1642. - cur.popularOffset += offset ? 50 : 100;
- 1643. - },
- 1644. -
- 1645. - loadFeed: function(update) {
- 1646. - if (cur.silent) {
- 1647. - cur.onSilentLoad = function() {
- 1648. - Audio.loadFeed(update);
- 1649. - };
- 1650. - return;
- 1651. - }
- 1652. - if (cur.isFeedLoading) return;
- 1653. - cur.isFeedLoading = true;
- 1654. - if (cur.audiosList['all'] && cur.allAudiosIndex != 'all') {
- 1655. - cur.allAudiosIndex = 'all';
- 1656. - this.indexAll();
- 1657. - var curEl = geByClass1('current', ge('audio_friends_list'));
- 1658. - if (curEl) removeClass(curEl, 'current');
- 1659. - }
- 1660. - if (update) {
- 1661. - delete cur.feedFrom;
- 1662. - delete cur.feedOffset;
- 1663. - delete cur.feedIds;
- 1664. - delete cur.feedAudios;
- 1665. - if (update === 'reload') {
- 1666. - var params = {act: 'feed', part: 1, update: 1}, q = Audio.address + '#' + ajx2q(params);
- 1667. - delete window.ajaxCache[q];
- 1668. - }
- 1669. - }
- 1670. - each(geByClass('audio_filter', cur.albumFilters), function(i, e) {
- 1671. - removeClass(e, 'selected');
- 1672. - });
- 1673. - if (cur.searchStr && isVisible(cur.searchInfoCont)) {
- 1674. - hide(cur.searchInfoCont);
- 1675. - }
- 1676. - var feed_filter = ge('feed_filter');
- 1677. - addClass(feed_filter, 'selected');
- 1678. - removeClass(cur.albumFiltered, 'selected');
- 1679. - hide(cur.searchFilters, cur.popularFilters, cur.popularOwners);
- 1680. - if (cur.oid == vk.id) {
- 1681. - show(cur.audioFriends);
- 1682. - hide(cur.searchInfoCont);
- 1683. - hide(cur.audioAlbums);
- 1684. - }
- 1685. - removeClass(cur.albumFiltered, 'club_shown');
- 1686. - Audio.handleFilterPos();
- 1687. - cur.lastSection = cur.curSection;
- 1688. - cur.curSection = 'feed';
- 1689. - if (!update) {
- 1690. - addClass(cur.showMore, 'loading');
- 1691. - }
- 1692. - cur.lastAct = 'feed';
- 1693. - ajax.post(Audio.address, {act: 'feed', offset: cur.feedOffset, from: cur.feedFrom, part: 1, update: update ? 1 : ''}, {
- 1694. - onDone: function (rows, script) {
- 1695. - if (cur.lastAct != 'feed') return;
- 1696. - if (rows) {
- 1697. - if (update) {
- 1698. - cur.aContent.innerHTML = rows;
- 1699. - } else {
- 1700. - var au = ce('div'), par = geByClass1('wall_module', cur.aContent), row;
- 1701. - au.innerHTML = rows;
- 1702. - if (par && update) {
- 1703. - par.innerHTML = '';
- 1704. - }
- 1705. - while (row = au.firstChild) {
- 1706. - if (!row.id || ge(row.id)) {
- 1707. - au.removeChild(row);
- 1708. - continue;
- 1709. - }
- 1710. - if (par) {
- 1711. - par.appendChild(row);
- 1712. - }
- 1713. - }
- 1714. - }
- 1715. - } else {
- 1716. - hide(cur.showMore);
- 1717. - }
- 1718. - if (script) {
- 1719. - eval(script);
- 1720. - }
- 1721. - var aid = currentAudioId(), needs_update = (aid && cur.feedIds && indexOf(cur.feedIds, aid) != -1);
- 1722. - audioPlayer.genPlaylist(cur.feedAudios, needs_update);
- 1723. - removeClass(cur.showMore, 'loading');
- 1724. - Audio.changeHTitle();
- 1725. - val(cur.aSearch, '');
- 1726. - removeClass(cur.clearSearch, 'shown');
- 1727. - cur.searchStr = '';
- 1728. - cur.album_id = 0;
- 1729. - Audio.hideSearchResults();
- 1730. - hide(cur.sShowMore);
- 1731. - if (update) scrollToTop();
- 1732. - delete nav.objLoc.q;
- 1733. - delete nav.objLoc.owner;
- 1734. - delete nav.objLoc.friend;
- 1735. - delete nav.objLoc.album_id;
- 1736. - delete nav.objLoc.club;
- 1737. - delete nav.objLoc.genre;
- 1738. - delete nav.objLoc.audio_id;
- 1739. - delete cur._back;
- 1740. - extend(nav.objLoc, {act: 'feed'});
- 1741. - nav.setLoc(nav.objLoc);
- 1742. - var _a = window.audioPlayer;
- 1743. - if (_a && _a.showCurrentTrack) _a.showCurrentTrack();
- 1744. - },
- 1745. - showProgress: function () {
- 1746. - cur.isFeedLoading = true;
- 1747. - addClass(feed_filter, 'loading');
- 1748. - },
- 1749. - hideProgress: function () {
- 1750. - cur.isFeedLoading = false;
- 1751. - removeClass(feed_filter, 'loading');
- 1752. - },
- 1753. - cache: 1
- 1754. - });
- 1755. - },
- 1756. -
- 1757. - reorderPlaylist: function(aid, before_id, after_id) {
- 1758. - each([window.audioPlaylist, cur.nextPlaylist], function(i, e) {
- 1759. - var list = e;
- 1760. - if (before_id && !after_id && list && list[before_id]) {
- 1761. - after_id = list[before_id]._prev;
- 1762. - }
- 1763. - if (list && list[aid] && after_id && list[after_id] && after_id != aid) {
- 1764. - var next_id = list[aid]._next, prev_id = list[aid]._prev;
- 1765. - if (next_id != aid) {
- 1766. - list[next_id]._prev = prev_id;
- 1767. - list[prev_id]._next = next_id;
- 1768. - list[aid]._prev = after_id;
- 1769. - list[aid]._next = list[after_id]._next;
- 1770. - list[after_id]._next = list[list[after_id]._next]._prev = aid;
- 1771. - }
- 1772. - }
- 1773. - });
- 1774. - var plist = ls.get('pad_playlist');
- 1775. - if (plist && plist[aid] && after_id && plist[after_id] && after_id != aid && window.audioPlayer) {
- 1776. - audioPlayer.setPadPlaylist();
- 1777. - }
- 1778. - },
- 1779. -
- 1780. - removeFromPlaylist: function(aid) {
- 1781. - each([window.audioPlaylist, cur.nextPlaylist], function(i, e) {
- 1782. - var list = e;
- 1783. - if (list && list[aid]) {
- 1784. - var next_id = list[aid]._next, prev_id = list[aid]._prev;
- 1785. - if (next_id != aid) {
- 1786. - // delete list[aid];
- 1787. - list[next_id]._prev = prev_id;
- 1788. - list[prev_id]._next = next_id;
- 1789. - }
- 1790. - }
- 1791. - });
- 1792. - var plist = ls.get('pad_playlist');
- 1793. - if (plist && plist[aid] && window.audioPlayer) {
- 1794. - audioPlayer.setPadPlaylist();
- 1795. - }
- 1796. - },
- 1797. -
- 1798. - backToPlaylist: function(aid) {
- 1799. - each([window.audioPlaylist, cur.nextPlaylist], function(i, e) {
- 1800. - var list = e;
- 1801. - if (list && list[aid]) {
- 1802. - var next_id = list[aid]._next, prev_id = list[aid]._prev;
- 1803. - if (next_id != aid) {
- 1804. - list[next_id]._prev = list[prev_id]._next = aid;
- 1805. - }
- 1806. - }
- 1807. - });
- 1808. - var plist = ls.get('pad_playlist');
- 1809. - if (plist && plist[aid] && window.audioPlayer) {
- 1810. - audioPlayer.setPadPlaylist();
- 1811. - }
- 1812. - },
- 1813. -
- 1814. - hideRecommendation: function(aid, q, hash, event) {
- 1815. - if (window.audioPlayer && currentAudioId() == aid) {
- 1816. - audioPlayer.nextTrack(true);
- 1817. - }
- 1818. - var recRow = ge('audio'+aid);
- 1819. - if (recRow) {
- 1820. - if (window.tooltips) {
- 1821. - tooltips.hide(ge('remove'+aid))
- 1822. - }
- 1823. - slideUp(recRow, 200, function() {
- 1824. - recRow.parentNode.removeChild(recRow);
- 1825. - Audio.removeFromPlaylist(aid);
- 1826. - cur.recsCount--;
- 1827. - Audio.changeHTitle();
- 1828. - });
- 1829. - }
- 1830. - ajax.post(Audio.address, {act: 'hide_recommendation', q: q, hash: hash});
- 1831. - if (event) cancelEvent(event);
- 1832. - return false;
- 1833. - },
- 1834. -
- 1835. - _animDelX: function(el, opacity, set_active) {
- 1836. - if (!el) return;
- 1837. - if (set_active !== undefined) {
- 1838. - el.active = set_active;
- 1839. - } else if (el.active) {
- 1840. - return;
- 1841. - }
- 1842. - animate(el, {opacity: opacity}, 200);
- 1843. - },
- 1844. -
- 1845. - rowActive: function(el, tt, sh) {
- 1846. - Audio._animDelX(el, 1, 1);
- 1847. - if (tt) showTooltip(el, {text: tt, showdt: 0, black: 1, shift: (sh ? sh : [12, 4, 0])});
- 1848. - },
- 1849. - rowInactive: function(el, light) {
- 1850. - var opacity = light ? 0.6 : 0.4;
- 1851. - Audio._animDelX(el, opacity, 0);
- 1852. - },
- 1853. -
- 1854. - switchToFriends: function() {
- 1855. - each(geByClass('audio_filter', cur.albumFilters), function(i, e) {
- 1856. - removeClass(e, 'selected');
- 1857. - });
- 1858. - addClass(ge('friends_audios'), 'selected');
- 1859. - removeClass(cur.albumFiltered, 'selected');
- 1860. - var showFriends = function() {
- 1861. - show(cur.audioFriends);
- 1862. - hide(cur.searchInfoCont);
- 1863. - hide(cur.audioAlbums, cur.searchFilters, cur.popularFilters, cur.popularOwners);
- 1864. - }
- 1865. - if (!cur.audioFriendPlaying && cur.shownFriends.length <= 10) {
- 1866. - Audio.cacheFriendsList();
- 1867. - showFriends();
- 1868. - Audio.selectFriend(cur.audioFriend);
- 1869. - } else {
- 1870. - addClass(ge('friends_audios'), 'loading');
- 1871. - var query = {act: 'more_friends'};
- 1872. - if (cur.audioFriendPlaying) query.owner = cur.audioFriendPlaying;
- 1873. - else if (cur.audioFriend) query.owner = cur.audioFriend;
- 1874. - ajax.post(Audio.address, query, {
- 1875. - cache: 1,
- 1876. - onDone: function(cont, friends) {
- 1877. - if (cont) {
- 1878. - ge('audio_friends_list').innerHTML = cont;
- 1879. - }
- 1880. - addClass(ge('audio_friend'+cur.audioFriend), 'current');
- 1881. - removeClass(ge('friends_audios'), 'loading');
- 1882. - showFriends();
- 1883. - cur.shownFriends = friends;
- 1884. - var fid = cur.audioFriendPlaying ? cur.audioFriendPlaying : cur.audioFriend;
- 1885. - Audio.selectFriend(fid);
- 1886. - },
- 1887. - onFail: function() {removeClass(ge('friends_audios'), 'loading');}
- 1888. - });
- 1889. - }
- 1890. - },
- 1891. - selectFriend: function(id, ev) {
- 1892. - if (cur.skipSelectFriend) {
- 1893. - cur.skipSelectFriend = false;
- 1894. - return;
- 1895. - }
- 1896. - each(geByTag('div', cur.audioFriends), function(i, e) {
- 1897. - removeClass(e, 'current');
- 1898. - });
- 1899. - addClass(ge('audio_friend' + id), 'current');
- 1900. - addClass(ge('album0'), 'loading');
- 1901. - each(geByClass('audio_filter', cur.albumFilters), function(i, e) {
- 1902. - removeClass(e, 'selected');
- 1903. - });
- 1904. - Audio.loadFriendsAudios(id, 'friend'+id);
- 1905. - if (id && cur.oid == vk.id) {
- 1906. - ajax.post(Audio.address, {act: 'list_stats', owner: id});
- 1907. - }
- 1908. - return ev ? cancelEvent(ev) : false;
- 1909. - },
- 1910. - skipSelectFriend: function() {
- 1911. - cur.skipSelectFriend = true;
- 1912. - },
- 1913. - selectCommunity: function(id, ev) {
- 1914. - if (cur.skipSelectCommunity) {
- 1915. - cur.skipSelectCommunity = false;
- 1916. - return;
- 1917. - }
- 1918. - each(geByClass('audio_friend', cur.searchInfoCont), function(i, e) {
- 1919. - removeClass(e, 'current');
- 1920. - });
- 1921. - addClass(ge('audio_community' + id), 'current');
- 1922. - mentionOver(ge('audio_community' + id), {shift: [47, 7, 7]});
- 1923. - each(geByClass('audio_filter', cur.albumFilters), function(i, e) {
- 1924. - removeClass(e, 'selected');
- 1925. - });
- 1926. - addClass(cur.albumFiltered, 'club_shown');
- 1927. - cur.searchSortFilter.disable(true);
- 1928. - cur.searchLyricsFilter.disable(true);
- 1929. - removeClass(cur.albumFiltered, 'selected');
- 1930. - cur.club = id;
- 1931. - Audio.loadCommunityAudios(id, 'club'+id);
- 1932. - if (id && cur.oid == vk.id) {
- 1933. - ajax.post(Audio.address, {act: 'list_stats', club: id});
- 1934. - }
- 1935. - return ev ? cancelEvent(ev) : false;
- 1936. - },
- 1937. - skipSelectCommunity: function() {
- 1938. - cur.skipSelectCommunity = true;
- 1939. - },
- 1940. - backToSearch: function() {
- 1941. - if (cur.curSection && cur.curSection.substr(0, 4) == 'club') {
- 1942. - cur.ignoreEqual = true;
- 1943. - each(geByClass('audio_friend', cur.searchInfoCont), function() {
- 1944. - removeClass(this, 'current');
- 1945. - });
- 1946. - this.updateList(null, cur.aSearch);
- 1947. - }
- 1948. - },
- 1949. - playCurrent: function(el, hash, ev) {
- 1950. - var _a = window.audioPlayer, aid = currentAudioId(), audioId = el.getAttribute('data-audio');
- 1951. - if (_a) _a.gpDisabled = false;
- 1952. - if ((window.audioPlaylist || {})[audioId]) {
- 1953. - if (!_a || aid != audioId || _a.player.paused()) playAudioNew(audioId);
- 1954. - return cancelEvent(ev);
- 1955. - }
- 1956. -
- 1957. - var prg = el.nextSibling || el.parentNode.appendChild(ce('span', {className: 'progress_inline current_audio_prg'}));
- 1958. - stManager.add(['audioplayer.css', 'audioplayer.js']);
- 1959. - ajax.post(Audio.address, {act: 'play_audio_status', id: audioId, hash: hash}, {
- 1960. - onDone: function(info, data, uid) {
- 1961. - if (data && uid && window.audioPlayer) {
- 1962. - audioPlayer.statusData = audioPlayer.statusData || {};
- 1963. - audioPlayer.statusData[uid] = data;
- 1964. - }
- 1965. - if (!info) return;
- 1966. -
- 1967. - if (!window.audioPlaylist) {
- 1968. - window.audioPlaylist = {};
- 1969. - }
- 1970. - audioPlaylist[audioId] = info;
- 1971. - audioPlaylist.start = audioId;
- 1972. - if (!audioPlaylist.searchStr) {
- 1973. - window.lastPlaylist = clone(audioPlaylist);
- 1974. - }
- 1975. - if (window.audioPlayer) {
- 1976. - audioPlayer.setPadPlaylist();
- 1977. - }
- 1978. - delete audioPlaylist.searchStr;
- 1979. - playAudioNew(audioId);
- 1980. - },
- 1981. - showProgress: function() {
- 1982. - show(prg);
- 1983. - hide(el);
- 1984. - },
- 1985. - hideProgress: function() {
- 1986. - hide(prg);
- 1987. - show(el);
- 1988. - }
- 1989. - });
- 1990. - return cancelEvent(ev);
- 1991. - },
- 1992. - loadFriendsAudios: function(id, index, album, showAlbums, owner) {
- 1993. - if (cur.silent) {
- 1994. - cur.onSilentLoad = function() {
- 1995. - Audio.loadFriendsAudios(id, index, album, showAlbums);
- 1996. - };
- 1997. - return;
- 1998. - }
- 1999. - if (!cur.audiosList[index]) {
- 2000. - if (index == 'all') {
- 2001. - each(geByClass('audio_filter', cur.albumFilters), function(i, e) {
- 2002. - removeClass(e, 'selected');
- 2003. - });
- 2004. - if (showAlbums) {
- 2005. - addClass(ge('audios_albums'), 'selected loading');
- 2006. - } else {
- 2007. - addClass(ge('album0'), 'selected loading');
- 2008. - }
- 2009. - removeClass(cur.albumFiltered, 'selected');
- 2010. - }
- 2011. - cur.lastAct = index;
- 2012. - var query = {act: 'load_audios_silent', id: id, claim: nav.objLoc.claim, please_dont_ddos: 3};
- 2013. - if (owner) {
- 2014. - query.is_owner = 1;
- 2015. - }
- 2016. - if (index != 'all' && !ge('audio_friend' + id) && !owner) {
- 2017. - cur.shownFriends = [];
- 2018. - var txt = domFC(ge('audio_more_friends')), prg = domLC(ge('audio_more_friends'));
- 2019. - Audio.showMoreFriends(function() {
- 2020. - hide(txt);
- 2021. - show(prg);
- 2022. - }, function() {
- 2023. - hide(prg);
- 2024. - show(txt);
- 2025. - }, id);
- 2026. - }
- 2027. - ajax.post(Audio.address, query, {
- 2028. - cache: 1,
- 2029. - onDone: function(data, opts) {
- 2030. - if (cur.lastAct != index) return;
- 2031. - opts = eval('('+opts+')');
- 2032. - if (id < 0) {
- 2033. - cur.allFriendsHTitles = cur.allFriendsHTitles || {};
- 2034. - cur.allFriendsHTitles[id] = opts.summaryLang.all_club_htitle;
- 2035. - } else {
- 2036. - cur.allFriendsTitles = cur.allFriendsTitles || {};
- 2037. - cur.allFriendsTitles[id] = opts.summaryLang.all_friend_title;
- 2038. - cur.allFriendsHTitles = cur.allFriendsHTitles || {};
- 2039. - cur.allFriendsHTitles[id] = opts.summaryLang.all_friend_htitle;
- 2040. - }
- 2041. - var obj = eval('('+data+')');
- 2042. - if (!obj) return;
- 2043. - cur.audiosList[index] = obj['all'];
- 2044. - if (id == vk.id && index == 'all') {
- 2045. - cur.allAudiosIndex = 'all';
- 2046. - Audio.generateAlbums();
- 2047. - }
- 2048. - if (!cur.performerInfo) {
- 2049. - cur.performerInfo = {};
- 2050. - }
- 2051. - cur.performerInfo[index] = opts.performerInfo;
- 2052. - if (opts.backLink) {
- 2053. - cur.backLink = opts.backLink;
- 2054. - showBackLink('/audio?act=popular'+(cur.genre ? '&genre='+cur.genre : ''), cur.backLink);
- 2055. - }
- 2056. - if (index != 'all') cur.audioFriend = id;
- 2057. - Audio.changeAllIndex(index, album, showAlbums, owner);
- 2058. - Audio.cacheFriendsList();
- 2059. - }
- 2060. - });
- 2061. - } else {
- 2062. - if (index != 'all') cur.audioFriend = id;
- 2063. - if (owner) {
- 2064. - showBackLink('/audio?act=popular'+(cur.genre ? '&genre='+cur.genre : ''), cur.backLink);
- 2065. - }
- 2066. - Audio.changeAllIndex(index, album, showAlbums, owner);
- 2067. - }
- 2068. - },
- 2069. - loadCommunityAudios: function(gid, index) {
- 2070. - if (cur.silent) {
- 2071. - cur.onSilentLoad = function() {
- 2072. - Audio.loadCommunityAudios(gid, index);
- 2073. - };
- 2074. - return;
- 2075. - }
- 2076. - if (!cur.audiosList[index]) {
- 2077. - cur.lastAct = index;
- 2078. - ajax.post(Audio.address, {act: 'load_audios_silent', gid: gid, claim: nav.objLoc.claim, please_dont_ddos: 1}, {
- 2079. - cache: 1,
- 2080. - showProgress: addClass.pbind(ge('album0'), 'loading'),
- 2081. - hideProgress: removeClass.pbind(ge('album0'), 'loading'),
- 2082. - onDone: function(data, opts) {
- 2083. - if (cur.lastAct != index) return;
- 2084. - opts = eval('('+opts+')');
- 2085. - cur.allClubsHTitles = cur.allClubsHTitles || {};
- 2086. - cur.allClubsHTitles[gid] = opts.summaryLang.all_club_htitle;
- 2087. - var obj = eval('('+data+')');
- 2088. - if (!obj) return;
- 2089. - cur.audiosList[index] = obj['all'];
- 2090. - Audio.searchAudios('', index);
- 2091. - scrollToTop();
- 2092. - }
- 2093. - });
- 2094. - } else {
- 2095. - Audio.searchAudios('', index);
- 2096. - scrollToTop();
- 2097. - }
- 2098. - },
- 2099. - showMoreFriends: function(showProgress, hideProgress, friend) {
- 2100. - if (cur.moreFriendsSent) {
- 2101. - return;
- 2102. - }
- 2103. - cur.moreFriendsSent = true;
- 2104. - var query = {act: 'more_friends', ids: cur.shownFriends};
- 2105. - if (friend) {
- 2106. - query.owner = friend;
- 2107. - }
- 2108. - ajax.post(Audio.address, query, {
- 2109. - onDone: function(cont, friends, reset) {
- 2110. - cur.moreFriendsSent = false;
- 2111. - if (cont) {
- 2112. - var list = ge('audio_friends_list');
- 2113. - re('audio_friends_old');
- 2114. - var old = ce('div', {innerHTML: '<div id="audio_friends_old" style="position: absolute;">'+list.innerHTML+'</div>'}).firstChild;
- 2115. - list.parentNode.insertBefore(old, list);
- 2116. - list.innerHTML = '';
- 2117. - setStyle(list, {display: 'none'});
- 2118. - list.innerHTML = cont;
- 2119. - var oldRows = geByClass('audio_friend', old), oldCnt = oldRows.length,
- 2120. - newCnt = geByClass('audio_friend', list).length;
- 2121. - if (oldCnt > newCnt) {
- 2122. - oldRows = oldRows.slice(newCnt);
- 2123. - each(oldRows, function() {
- 2124. - re(this);
- 2125. - });
- 2126. - }
- 2127. - setTimeout(Audio.handleFilterPos, 0);
- 2128. - fadeIn(list, 400, re.pbind(old));
- 2129. - if (friends) {
- 2130. - cur.shownFriends = reset ? friends : cur.shownFriends.concat(friends);
- 2131. - }
- 2132. - } else {
- 2133. - hide(el.parentNode.parentNode);
- 2134. - Audio.handleFilterPos();
- 2135. - }
- 2136. - },
- 2137. - onFail: function() {
- 2138. - cur.moreFriendsSent = false;
- 2139. - },
- 2140. - showProgress: showProgress,
- 2141. - hideProgress: hideProgress
- 2142. - });
- 2143. - },
- 2144. - cacheFriendsList: function() {
- 2145. - var query = {act: 'more_friends'};
- 2146. - if (cur.audioFriendPlaying) query.owner = cur.audioFriendPlaying;
- 2147. - else if (cur.audioFriend) query.owner = cur.audioFriend;
- 2148. - ajax.post(Audio.address, query, {cache: 1});
- 2149. - },
- 2150. -
- 2151. - // Audio Edit functions
- 2152. -
- 2153. - showAudioClaimWarning: function(aid, claim_id, title, reason) {
- 2154. - if (cur.silent) {
- 2155. - cur.onSilentLoad = function() {
- 2156. - Audio.showAudioClaimWarning(aid, claim_id, title, reason);
- 2157. - };
- 2158. - return;
- 2159. - }
- 2160. - var claimText, claimTitle;
- 2161. - if (reason == 'crap') {
- 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'));
- 2163. - claimTitle = getLang('audio_crap_warning_title') || getLang('audio_claim_warning_title');
- 2164. - } else {
- 2165. - claimText = (claim_id > 0) ? getLang('audio_claim_warning_objection') : (claim_id == 0 ? getLang('audio_claim_warning_text') : getLang('audio_claim_warning'));
- 2166. - claimTitle = getLang('audio_claim_warning_title');
- 2167. - }
- 2168. - claimText = claimText.split('{audio}').join('<b>' + title + '</b>');
- 2169. - claimText = claimText.split('{objection_link}').join('<a href="/help?act=cc_objection&claim=' + claim_id + '&content=audio' + aid + '">' + getLang('audio_claim_objection') + '</a>');
- 2170. - claimText = claimText.split('{delete_link}').join('<a href="#" onclick="Audio.deleteAudio(\'' + aid + '\'); return false;">' + getLang('audio_claim_delete') + '</a>');
- 2171. - cur.claimWarning = showFastBox(claimTitle, claimText);
- 2172. - },
- 2173. -
- 2174. - deleteAudio: function(id) {
- 2175. - if (cur.silent) {
- 2176. - cur.onSilentLoad = function() {
- 2177. - Audio.deleteAudio(id);
- 2178. - };
- 2179. - return;
- 2180. - }
- 2181. - if (cur.deleting) {
- 2182. - return false;
- 2183. - }
- 2184. - cur.deleting = true;
- 2185. - var el = ge('audio' + id), aid = id.split('_')[1];
- 2186. - if (!cur.deletedAudios) cur.deletedAudios = [];
- 2187. - cur.deletedAudios[aid] = el.innerHTML;
- 2188. - var acts = geByClass1('actions', el);
- 2189. - each(acts.children, function(){if (this.tt && this.tt.hide) this.tt.hide()});
- 2190. - var a = (cur.audios || {})[aid] || [], lyrics = isVisible(ge('lyrics'+id)),
- 2191. - _tw = el && geByClass1('title_wrap', el),
- 2192. - performer = a[5] || _tw && (geByTag1('a', _tw) || {}).innerHTML || '',
- 2193. - title = a[6] || _tw && (geByClass1('title', _tw) || {}).innerHTML || '';
- 2194. - el.innerHTML = rs(cur.deletedTpl, {
- 2195. - audio_id: id,
- 2196. - performer: performer.split('<span>').join('').split('</span>').join(''),
- 2197. - title: title,
- 2198. - delete_all: ''
- 2199. - });
- 2200. - var _a = window.audioPlayer;
- 2201. - if (currentAudioId() == id) {
- 2202. - _a.showCurrentTrack();
- 2203. - }
- 2204. - if (lyrics) {
- 2205. - Audio.updateSorterRows(ge('audio'+id));
- 2206. - }
- 2207. - var addBtn = ge('audio_add'+id);
- 2208. - if (addBtn) {
- 2209. - addBtn.onmouseover = function() {};
- 2210. - }
- 2211. - ajax.post(Audio.address, {act: 'delete_audio', oid: cur.oid, aid: aid, hash: cur.hashes.delete_hash, restore: 1}, {
- 2212. - onDone: function(action, delete_all) {
- 2213. - cur.deleting = false;
- 2214. - if (cur.claimWarning) {
- 2215. - cur.claimWarning.hide();
- 2216. - }
- 2217. - var acts = geByClass1('actions', el);
- 2218. - each(acts.children, function(){if (this.tt) this.tt.hide()});
- 2219. - el.innerHTML = rs(cur.deletedTpl, {
- 2220. - audio_id: id,
- 2221. - performer: performer.split('<span>').join('').split('</span>').join(''),
- 2222. - title: title,
- 2223. - delete_all: action ? action : ''
- 2224. - });
- 2225. - el.style.cursor = 'auto';
- 2226. - el.setAttribute('nosorthandle', '1');
- 2227. - if (currentAudioId() == id) {
- 2228. - _a.showCurrentTrack();
- 2229. - }
- 2230. - if (delete_all) {
- 2231. - cur.lang = cur.lang || {};
- 2232. - cur.lang.audio_delete_all = delete_all;
- 2233. - }
- 2234. - if (cur.audios[aid]) {
- 2235. - cur.audiosIndex.remove(cur.audios[aid]);
- 2236. - cur.audios[aid].deleted = true;
- 2237. - }
- 2238. - Audio.removeFromPlaylist(id);
- 2239. - cur.sectionCount--;
- 2240. - if (cur.shownAudios) cur.shownAudios--;
- 2241. - Audio.changeSummary();
- 2242. - },
- 2243. - onFail: function() {
- 2244. - cur.deleting = false;
- 2245. - }
- 2246. - });
- 2247. - return false;
- 2248. - },
- 2249. -
- 2250. - restoreAudio: function(id) {
- 2251. - if (cur.restoring) {
- 2252. - return;
- 2253. - }
- 2254. - cur.restoring = true;
- 2255. - var el = ge('audio' + id), aid = id.split('_')[1];
- 2256. - ajax.post(Audio.address, {act: 'restore_audio', oid: cur.oid, aid: aid, hash: cur.hashes.restore_hash}, {
- 2257. - onDone: function() {
- 2258. - cur.restoring = false;
- 2259. - var acts = geByClass1('actions', el);
- 2260. - each(acts.children, function(){if (this.tt) this.tt.hide()});
- 2261. - el.innerHTML = cur.deletedAudios[aid];
- 2262. - var lyrics = isVisible(ge('lyrics'+id));
- 2263. - if (lyrics) {
- 2264. - Audio.updateSorterRows(ge('audio'+id));
- 2265. - }
- 2266. - el.removeAttribute('nosorthandle');
- 2267. - if (cur.audios[aid]) {
- 2268. - cur.audiosIndex.add(cur.audios[aid]);
- 2269. - cur.audios[aid].deleted = false;
- 2270. - }
- 2271. - Audio.backToPlaylist(id);
- 2272. - cur.sectionCount++;
- 2273. - if (cur.shownAudios) cur.shownAudios++;
- 2274. - Audio.changeSummary();
- 2275. - toggleClass(ge('play'+id), 'playing', id == currentAudioId());
- 2276. - },
- 2277. - onFail: function() {
- 2278. - cur.restoring = false;
- 2279. - }
- 2280. - });
- 2281. - },
- 2282. -
- 2283. - deleteAll: function(object_id, from_id, to_id, hash) {
- 2284. - var box = showFastBox(getLang('audio_delete_all_title'), getLang('audio_delete_all') || '', getLang('global_delete'), function(btn){
- 2285. - ajax.post(Audio.address, {act: 'delete_all', object_id: object_id, to_id: to_id, from_id: from_id, hash: hash}, {
- 2286. - showProgress: lockButton.pbind(btn),
- 2287. - onDone: function() {
- 2288. - nav.reload();
- 2289. - },
- 2290. - onFail: box.hide
- 2291. - });
- 2292. - }, getLang('global_cancel'));
- 2293. - },
- 2294. -
- 2295. - editAudio: function(aid, event){
- 2296. - showBox(Audio.address, {act: 'edit_audio_box', aid: aid}, {
- 2297. - params: {width: '430px', bodyStyle: 'padding: 15px;'}
- 2298. - });
- 2299. - if (event) cancelEvent(event);
- 2300. - return false;
- 2301. - },
- 2302. -
- 2303. - editTopAudio: function(full_aid, event) {
- 2304. - showBox('al_search.php', {act: 'audio_top_edit_box', id: full_aid, full_id: full_aid}, {
- 2305. - params: {width: '430px', bodyStyle: 'padding: 15px;'}
- 2306. - });
- 2307. - if (event) cancelEvent(event);
- 2308. - return false;
- 2309. - },
- 2310. -
- 2311. - removeFromTop: function(audio_hash, hash, full_aid, event) {
- 2312. - ajax.post('al_search.php', {act: 'save_top_audio', deleted: 1, audio_hash: audio_hash, hash: hash, id: full_aid}, {
- 2313. - onDone: function() {
- 2314. - var audioRow = ge('audio'+full_aid);
- 2315. - slideUp(audioRow, 100);
- 2316. - }
- 2317. - })
- 2318. - },
- 2319. -
- 2320. - updateAlbums: function() {
- 2321. - if (!cur.canEdit || browser.mobile) return;
- 2322. - each (cur.audioAlbumsWrap.sorter.elems, function() {
- 2323. - setStyle(this, {top: 'auto', left: 'auto', width: 'auto'});
- 2324. - });
- 2325. - cur.audioAlbumsWrap.sorter.destroy();
- 2326. - this.initAlbumsSort();
- 2327. - this.updateAlbumsTitles();
- 2328. - },
- 2329. -
- 2330. - updateAlbumsTitles: function() {
- 2331. - if (!cur.audioAlbumsWrap) return;
- 2332. -
- 2333. - each (geByClass('label', cur.audioAlbumsWrap), function() {
- 2334. - if (this.scrollWidth > this.clientWidth) {
- 2335. - this.setAttribute('title', this.innerText || this.textContent);
- 2336. - } else {
- 2337. - this.removeAttribute('title');
- 2338. - }
- 2339. - });
- 2340. - },
- 2341. -
- 2342. - initAlbumsSort: function() {
- 2343. - if (!cur.canEdit || browser.mobile || !cur.audioAlbumsWrap) return;
- 2344. - sorter.init(cur.audioAlbumsWrap, {onMouseDown: Audio.hideAlbumsTT, onReorder: Audio.onAlbumReorder, noMoveCursor: 1});
- 2345. - },
- 2346. -
- 2347. - hideAlbumsTT: function() {
- 2348. - each(geByClass('icon_wrap', cur.audioAlbumsWrap), function() {
- 2349. - if (this.tt) this.tt.hide();
- 2350. - })
- 2351. - },
- 2352. -
- 2353. - onAlbumReorder: function(album, before, after) {
- 2354. - var aid = album.id.replace('album', '');
- 2355. - var before_id = (before && before.id || '').replace('album', '');
- 2356. - var after_id = (after && after.id || '').replace('album', '');
- 2357. - ajax.post(Audio.address, {act: 'reorder_albums', oid: cur.oid, aid: aid, before: before_id, after: after_id, hash: cur.hashes.reorder_hash});
- 2358. - },
- 2359. -
- 2360. - editAlbum: function(aid){
- 2361. - if (cur.silent) {
- 2362. - cur.onSilentLoad = function() {
- 2363. - Audio.editAlbum(aid);
- 2364. - };
- 2365. - return;
- 2366. - }
- 2367. - if (!cur.audiosList) {
- 2368. - return;
- 2369. - }
- 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']});
- 2371. - cur.onOListSave = Audio.saveAlbum.pbind(box, aid);
- 2372. - return false;
- 2373. - },
- 2374. -
- 2375. - createAlbum: function() {
- 2376. - return this.editAlbum(0);
- 2377. - },
- 2378. -
- 2379. - saveAlbum: function(box, aid, audio_ids) {
- 2380. - var btn = geByClass1('button_blue', box.bodyNode.nextSibling).firstChild,
- 2381. - albumName = val('album_name');
- 2382. - if (!albumName) {
- 2383. - notaBene('album_name');
- 2384. - return false;
- 2385. - }
- 2386. - var query = {act: 'save_album', album_id: aid, name: albumName, gid: cur.gid, Audios: audio_ids.join(','), hash: cur.hashes.save_album_hash};
- 2387. - ajax.post(Audio.address, query, {
- 2388. - showProgress: lockButton.pbind(btn),
- 2389. - hideProgress: unlockButton.pbind(btn),
- 2390. - onFail: box.hide,
- 2391. - onDone: function(album_id, audio_ids, filters) {
- 2392. - try{
- 2393. - cur.audioAlbumsWrap.innerHTML = filters;
- 2394. - var old = cur.audiosList['album'+album_id];
- 2395. - if (old) {
- 2396. - for (var i in old) {
- 2397. - cur.audios[old[i][1]][8] = 0;
- 2398. - }
- 2399. - }
- 2400. - for (var i in audio_ids) {
- 2401. - cur.audios[audio_ids[i]][8] = album_id;
- 2402. - }
- 2403. - cur.albums[album_id] = {id: album_id, title: clean(albumName)};
- 2404. - Audio.generateAlbums();
- 2405. - Audio.loadAlbum(album_id);
- 2406. - Audio.initAlbumsSort();
- 2407. - Audio.updateAlbumsTitles();
- 2408. - box.hide();
- 2409. - }catch(e){}
- 2410. - }
- 2411. - });
- 2412. - return false;
- 2413. - },
- 2414. -
- 2415. - deleteAlbum: function(aid, hash){
- 2416. - var box = showFastBox(getLang('audio_delete_album_title'), getLang('audio_delete_album_are_you_sure'), getLang('audio_delete_album_button'), function(btn){
- 2417. - ajax.post(Audio.address, {act: 'delete_album', album_id: aid, hash: hash, gid: cur.gid}, {
- 2418. - showProgress: lockButton.pbind(btn),
- 2419. - hideProgress: unlockButton.pbind(btn),
- 2420. - onDone: function(audio_ids, filters){
- 2421. - try{
- 2422. - re('album'+aid);
- 2423. - boxQueue.hideAll();
- 2424. - for (var i in audio_ids) {
- 2425. - cur.audios[audio_ids[i]][8] = 0;
- 2426. - }
- 2427. - delete cur.albums[aid];
- 2428. - Audio.generateAlbums();
- 2429. - if (cur.album_id == aid) {
- 2430. - Audio.loadAlbum(0, undefined, true);
- 2431. - }
- 2432. - Audio.updateAlbums();
- 2433. - }catch(e){}
- 2434. - },
- 2435. - onFail: function(){
- 2436. - box.hide(200);
- 2437. - }
- 2438. - });
- 2439. - }, getLang('global_cancel'));
- 2440. - },
- 2441. -
- 2442. - moveAudio: function(full_id, album_id) {
- 2443. - var id = full_id.split('_')[1];
- 2444. - ajax.post(Audio.address, {act:'move_to_album', album_id:album_id, audio_id:id, gid:cur.gid, hash:cur.hashes.move_hash}, {
- 2445. - onDone: function(text) {
- 2446. - if((cur.album_id && cur.album_id != album_id) || cur.filterUnsorted){
- 2447. - var el = ge('audio'+full_id);
- 2448. - fadeOut(el, 300, function(){
- 2449. - el.parentNode.removeChild(el);
- 2450. - each (cur.aContent.sorter.elems, function() {
- 2451. - setStyle(this, {top: 'auto', left: 'auto'});
- 2452. - });
- 2453. - cur.aContent.sorter.destroy();
- 2454. - var opts = {onReorder: Audio.onAudioReorder, onMouseDown: Audio.onDragStart, onMouseUp: Audio.onDragEnd, noMoveCursor: 1};
- 2455. - if (cur.albumFilters) {
- 2456. - extend(opts, {target: cur.albumFilters, onDragOver: Audio.onDragOver, onDragOut: Audio.onDragOut});
- 2457. - }
- 2458. - sorter.init(cur.aContent, opts);
- 2459. - cur.sectionCount--;
- 2460. - Audio.changeSummary();
- 2461. - if (cur.sectionCount == 0) {
- 2462. - cur.aContent.innerHTML = '<div id="not_found" class="info_msg">'+getLang('audio_album_no_recs')+'</div>';
- 2463. - }
- 2464. - hide(cur.showMore);
- 2465. - });
- 2466. - }
- 2467. - cur.audios[id][8] = album_id;
- 2468. - Audio.generateAlbums();
- 2469. - }
- 2470. - });
- 2471. - },
- 2472. -
- 2473. - onAudioReorder: function(audio, before, after) {
- 2474. - var aid = audio.id.replace('audio', '').split('_')[1];
- 2475. - var before_id = (before && before.id || '').replace('audio', '').split('_')[1];
- 2476. - var after_id = (after && after.id || '').replace('audio', '').split('_')[1];
- 2477. - ajax.post(Audio.address, {act: 'reorder_audios', oid: cur.oid, aid: aid, before: before_id, after: after_id, hash: cur.hashes.reorder_hash}, {
- 2478. - onDone: function(data) {
- 2479. - var val;
- 2480. - if (before_id && !after_id) {
- 2481. - val = cur.audios[before_id]._order - 0.01;
- 2482. - } else {
- 2483. - val = cur.audios[after_id]._order + 0.01;
- 2484. - }
- 2485. - cur.audios[aid]._order = val;
- 2486. - Audio.reorderPlaylist(cur.oid + '_' + aid, before_id ? cur.oid + '_' + before_id : '', after_id ? cur.oid + '_' + after_id : '');
- 2487. - }
- 2488. - });
- 2489. - },
- 2490. -
- 2491. - onDragStart: function(el) {
- 2492. - // addClass(ge('page_body'), 'no_overflow');
- 2493. - cur.dragStartTimer = setTimeout(function() {
- 2494. - addClass(cur.audioAlbumsWrap, 'drag');
- 2495. - hide('album_add');
- 2496. - var ids = el.id.substr(5), id = parseInt(ids.split('_')[1]);
- 2497. - var album_id = (cur.audios) ? cur.audios[id][8] : cur.album_id;
- 2498. - each(geByClass('audio_filter', cur.audioAlbumsWrap), function(i,v) {
- 2499. - if ('album'+album_id == v.id || (album_id == 0 && v.id == 'album_unsorted')) {
- 2500. - return;
- 2501. - }
- 2502. - addClass(v, 'drag_on');
- 2503. - });
- 2504. - animate(el, {opacity: .8}, 200);
- 2505. - }, 300);
- 2506. - },
- 2507. -
- 2508. - onDragEnd: function(el, target) {
- 2509. - if (cur.dragStartTimer) clearTimeout(cur.dragStartTimer);
- 2510. - // removeClass(ge('page_body'), 'no_overflow');
- 2511. - each(geByClass('audio_filter', cur.audioAlbumsWrap), function(i,v) {
- 2512. - removeClass(v, 'drag_on');
- 2513. - });
- 2514. - show('album_add');
- 2515. - if (target) {
- 2516. - var new_album, full_id = el.id.substr(5), aid = parseInt(full_id.split('_')[1]);
- 2517. - var album_id = (cur.audios) ? cur.audios[aid][8] : cur.album_id;
- 2518. - if (target.id != 'album_unsorted') {
- 2519. - new_album = parseInt(target.id.substr(5));
- 2520. - } else {
- 2521. - new_album = 0;
- 2522. - }
- 2523. - if (new_album != album_id) {
- 2524. - Audio.moveAudio(full_id, new_album);
- 2525. - }
- 2526. - }
- 2527. - removeClass(cur.audioAlbumsWrap, 'drag');
- 2528. - animate(el, {opacity: 1}, 200);
- 2529. - },
- 2530. -
- 2531. - onDragOver: function(el, target) {
- 2532. - cur.targetId = target.id || '';
- 2533. - var ids = el.id.substr(5), id = parseInt(ids.split('_')[1]);
- 2534. - var album_id = (cur.audios) ? cur.audios[id][8] : cur.album_id;
- 2535. - if ('album'+album_id == target.id || (album_id == 0 && target.id == 'album_unsorted')) {
- 2536. - return;
- 2537. - }
- 2538. - if (cur.dragOutTimer) {
- 2539. - clearTimeout(cur.dragOutTimer);
- 2540. - }
- 2541. - addClass(target, 'drag_over');
- 2542. - setStyle(el, {opacity: .4});
- 2543. - },
- 2544. -
- 2545. - onDragOut: function(el, target) {
- 2546. - removeClass(target, 'drag_over');
- 2547. - if (target.id && cur.targetId != target.id) return;
- 2548. - cur.dragOutTimer = setTimeout(function(){setStyle(el, {opacity: .8});}, 200);
- 2549. - },
- 2550. -
- 2551. - ignoreOwner: function (post_raw, owner_id, hash, btn) {
- 2552. - triggerEvent(ge('delete_post' + post_raw), 'mouseout');
- 2553. - cur.feedEntriesHTML = cur.feedEntriesHTML || {};
- 2554. - if (post_raw) {
- 2555. - cur.feedEntriesHTML[post_raw + '_ignored'] = val('post' + post_raw);
- 2556. - }
- 2557. - ajax.post(Audio.address, {act: 'a_ignore_owner', post_raw: post_raw, owner_id: owner_id, hash: hash}, {
- 2558. - onDone:function(html) {
- 2559. - val('post' + post_raw, html);
- 2560. - each(geByClass('post', cur.aContent), function(i,v) {
- 2561. - var ids = this.id.match(/post((-?\d+)_(-?\d+)(_\d+)?)/);
- 2562. - if (ids[1] != post_raw && (!ids[4] && ids[2] == owner_id || ids[4] && ids[3] == owner_id)) {
- 2563. - hide(this);
- 2564. - }
- 2565. - });
- 2566. - }
- 2567. - });
- 2568. - },
- 2569. -
- 2570. - unignoreOwner: function (post_raw, owner_id, hash) {
- 2571. - ajax.post(Audio.address, {act: 'a_unignore_owner', post_raw: post_raw || '', owner_id: owner_id, hash: hash}, {
- 2572. - onDone:function(html) {
- 2573. - if (post_raw) {
- 2574. - val('post' + post_raw, cur.feedEntriesHTML[post_raw + '_ignored']);
- 2575. - } else {
- 2576. - val('ignore_row' + owner_id, html);
- 2577. - }
- 2578. - each(geByClass('post', cur.aContent), function(i,v) {
- 2579. - var ids = this.id.match(/post((-?\d+)_(-?\d+)(_\d+)?)/);
- 2580. - if (!ids[4] && ids[2] == owner_id || ids[4] && ids[3] == owner_id) {
- 2581. - show(this);
- 2582. - }
- 2583. - });
- 2584. - }
- 2585. - });
- 2586. - },
- 2587. -
- 2588. - editHidden: function () {
- 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']});
- 2590. - cur.onOListSave = Audio.onHiddenSave;
- 2591. - return false;
- 2592. - },
- 2593. -
- 2594. - onHiddenSave: function(white, black, list, options) {
- 2595. - var box = curBox(), params = {act: 'a_ignore_olist', hash: options.hash};
- 2596. - if (white.length < black.length) {
- 2597. - params.White = white.join(',');
- 2598. - } else {
- 2599. - params.Black = black.join(',');
- 2600. - }
- 2601. - ajax.post(Audio.address, params, {
- 2602. - onDone: function(control, rules) {
- 2603. - box.hide();
- 2604. - Audio.loadFeed('reload');
- 2605. - },
- 2606. - showProgress: box.showProgress,
- 2607. - hiderogress: box.hideProgress
- 2608. - });
- 2609. - return false;
- 2610. - },
- 2611. -
- 2612. - loadGenre: function(genre_id, ev) {
- 2613. - if (checkEvent(ev)) {
- 2614. - return true;
- 2615. - }
- 2616. - Audio.loadPopular(true, genre_id);
- 2617. - return cancelEvent(ev);
- 2618. - },
- 2619. -
- 2620. - loadPerformer: function(oid, ev) {
- 2621. - if (checkEvent(ev)) {
- 2622. - return true;
- 2623. - }
- 2624. - var index = 'owner'+oid;
- 2625. - Audio.loadFriendsAudios(oid, index, undefined, undefined, true);
- 2626. - return cancelEvent(ev);
- 2627. - },
- 2628. -
- 2629. - moreCatalog: function(obj) {
- 2630. - if (hasClass(obj, 'audio_performer_shown')) {
- 2631. - var height = getSize(ge('audio_more_performers'))[1];
- 2632. - removeClass(obj, 'audio_performer_shown');
- 2633. - hide('audio_more_performers');
- 2634. - if (height > 300) {
- 2635. - scrollToTop(0);
- 2636. - }
- 2637. - } else {
- 2638. - if (ge('audio_more_performers')) {
- 2639. - show('audio_more_performers')
- 2640. - addClass(obj, 'audio_performer_shown');
- 2641. - return false;
- 2642. - }
- 2643. - var exclude = [];
- 2644. - var nodes = ge('audio_performers').childNodes;
- 2645. - for (var i in nodes) {
- 2646. - if (hasClass(nodes[i], 'audio_owner')) {
- 2647. - exclude.push(intval(nodes[i].getAttribute('ref')));
- 2648. - }
- 2649. - }
- 2650. - ajax.post('al_audio.php', {act: 'get_more_performers', offset: 4, exclude: exclude.join(','), genre: parseInt(cur.genre)}, {
- 2651. - onDone: function(rows) {
- 2652. - ge('audio_performers').appendChild(ce('div', {
- 2653. - id: 'audio_more_performers',
- 2654. - innerHTML: rows
- 2655. - }));
- 2656. - addClass(obj, 'audio_performer_shown');
- 2657. - },
- 2658. - showProgress: addClass.pbind(obj, 'audio_performer_loading'),
- 2659. - hideProgress: removeClass.pbind(obj, 'audio_performer_loading')
- 2660. - });
- 2661. - }
- 2662. - },
- 2663. -
- 2664. - _eof: 1
- 2665. - }
- 2666. - try{stManager.done('audio.js');}catch(e){}
- ------
Advertisement
Add Comment
Please, Sign In to add comment