Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Файл - pads.js (Старый размер - 61428 | Новый - 44686):
- 9. - mus: {w: 629},
- 10. + mus: {w: 520},
- 40. - decr: function(id, toZero) {
- 41. + decr: function(id) {
- 44. - handlePageCount(id, toZero ? 0 : (vk.counts[id] - 1), mp[id], 1);
- 45. + handlePageCount(id, (vk.counts[id] - 1), mp[id], 1);
- 66. - var d = Pads.coords[id], c = _pads.cache[id], el = Pads.getEl(id), xy = getXY(el, true),
- 67. - barHeight = getXY('page_layout')[1], topOffset = 33 + barHeight;
- 68. + var d = Pads.coords[id], c = _pads.cache[id], el = Pads.getEl(id), xy = getXY(el, true);
- 72. - fixed = (posStyle == 'fixed' || posStyle != 'fixed' && y >= topOffset && isVisible(gp) || reverse || !ge('head_play_btn')), l, r, t, b;
- 73. + fixed = (posStyle == 'fixed' || posStyle != 'fixed' && y >= 33 && isVisible(gp) || reverse || !ge('head_play_btn')), l, r, t, b;
- 82. - t = reverse ? 'auto' : ((y >= topOffset && isVisible(gp) || !playBtn) ? 12 : 46) + barHeight;
- 83. + t = reverse ? 'auto' : ((y >= 33 && isVisible(gp) || !playBtn) ? 12 : 46);
- 88. - if (!fixed && !reverse && browser.mac) { // :(
- 89. - setTimeout(function() {
- 90. - var nt = intval(_pads.wrap.style.top);
- 91. - _pads.wrap.style.top = (nt - scrollGetY()) + 'px';
- 92. - _pads.wrap.style.position = 'fixed';
- 93. - setTimeout(function() { _pads.wrap.style.position = ''; _pads.wrap.style.top = nt + 'px'; }, 0);
- 94. - }, 0);
- 95. - }
- 97. - toggleClass(_pads.arrow, 'head', (y < topOffset || !isVisible(gp)) && playBtn && !_pads.gpClicked);
- 98. - toggleClass(gp, 'head', (y < topOffset || !isVisible(gp)) && playBtn && !_pads.gpClicked);
- 99. - toggleClass(_pads.arrow, 'right', (y >= topOffset && isVisible(gp) || !playBtn) && !hasClass(gp, 'reverse'));
- 100. - toggleClass(_pads.arrow, 'left', (y >= topOffset && isVisible(gp) || !playBtn) && hasClass(gp, 'reverse'));
- 101. - var toup = (y < topOffset || !isVisible(gp)) && playBtn && !_pads.gpClicked;
- 102. + toggleClass(_pads.arrow, 'head', (y < 33 || !isVisible(gp)) && playBtn && !_pads.gpClicked);
- 103. + toggleClass(gp, 'head', (y < 33 || !isVisible(gp)) && playBtn && !_pads.gpClicked);
- 104. + toggleClass(_pads.arrow, 'right', (y >= 33 && isVisible(gp) || !playBtn) && !hasClass(gp, 'reverse'));
- 105. + toggleClass(_pads.arrow, 'left', (y >= 33 && isVisible(gp) || !playBtn) && hasClass(gp, 'reverse'));
- 106. + var toup = (y < 33 || !isVisible(gp)) && playBtn && !_pads.gpClicked;
- 146. - cntr -= 46 + barHeight;
- 147. + cntr -= 46;
- 150. - _pads.wrap.style.top = (46 + barHeight) + 'px';
- 151. + _pads.wrap.style.top = 46 + 'px';
- 168. - var y = scrollGetY(), barHeight = getXY('page_layout')[1], topOffset = 33 + barHeight;
- 169. + var y = scrollGetY();
- 180. - setStyle(_pads.wrap, {bottom: fixed ? '15px' : 'auto', top: fixed ? 'auto' : 46 + barHeight});
- 181. + setStyle(_pads.wrap, {bottom: fixed ? '15px' : 'auto', top: fixed ? 'auto' : '46px'});
- 184. - } else if (y >= topOffset && isVisible(gp) && !fixed || !playBtn) {
- 185. + } else if (y >= 33 && isVisible(gp) && !fixed || !playBtn) {
- 205. - setStyle(_pads.wrap, {top: 46 + barHeight, bottom: 'auto'});
- 206. + setStyle(_pads.wrap, {top: '46px', bottom: 'auto'});
- 323. - var topOffset = 33 + getXY('page_layout')[1];
- 324. - toggleClass(ge('gp'), 'head', id == 'mus' && scrollGetY() < topOffset && !hasClass(ge('gp'), 'reverse') && !_pads.gpClicked);
- 325. + toggleClass(ge('gp'), 'head', id == 'mus' && scrollGetY() < 33 && !hasClass(ge('gp'), 'reverse') && !_pads.gpClicked);
- 342. - loadEl.innerHTML = loadEl.padLoad;
- 343. - delete loadEl.padLoad;
- 344. + loadEl.innerHTML = loadEl.padLoad;
- 345. + delete loadEl.padLoad;
- 401. - var scrollElements = [];
- 402. - if (id == 'mus') {
- 403. - scrollElements.push(ge('pad_side_filters_wrap'));
- 404. - }
- 411. - right: vk.rtl ? 'auto' : (id == 'mus' ? 0 : 1),
- 412. - left: !vk.rtl ? 'auto' : (id == 'mus' ? 0 : 1),
- 413. - forceCancelEvent: (id == 'mus'),
- 414. - scrollElements: scrollElements,
- 415. + right: vk.rtl ? 'auto' : 1,
- 416. + left: !vk.rtl ? 'auto' : 1,
- 465. - if (_pads.shown == 'mus') {
- 466. - if (ge('gp')) {
- 467. - removeClass(ge('gp').firstChild, 'active');
- 468. - _pads.gpClicked = false;
- 469. - }
- 470. - if (window.audioPlayer && audioPlayer.controls && audioPlayer.controls.pd && audioPlayer.controls.pd.status && audioPlayer.controls.pd.status.tt) {
- 471. - hide(audioPlayer.controls.pd.status.tt.container);
- 472. - }
- 473. - if (window.Audio) {
- 474. - Audio.stopPadEvents();
- 475. - }
- 476. + if (_pads.shown == 'mus' && ge('gp')) {
- 477. + removeClass(ge('gp').firstChild, 'active');
- 478. + _pads.gpClicked = false;
- 545. - ajax.post('pads.php', {act: 'pad', offset: _pads.cur.offset, pad_id: _pads.shown, pad_section: _pads.cur.sect || 0}, {
- 546. + ajax.post('pads.php', {act: 'pad', offset: _pads.cur.offset, pad_id: _pads.shown}, {
- 607. - },
- 608. - handleFilterPos: function() {
- 609. - var filters = ge('pad_side_filters'), filtersWrap = ge('pad_side_filters_wrap'),
- 610. - lastPos = _pads.cur.filterLastPos || 0, lastSt = _pads.cur.lastSt || 0, pos,
- 611. - st = _pads.content.scrollTop, fSz = getSize(filters)[1], fwSz = getSize(filtersWrap)[1];
- 612. - pos = Math.min(0, Math.max(lastPos + lastSt - st, fwSz - fSz - 10));
- 613. - setStyle(filters, {top: pos});
- 614. - _pads.cur.filterLastPos = pos;
- 615. - _pads.cur.lastSt = st;
- 619. - var more = ge('pad_more_audio'), searchMore = ge('pad_more_search_link');
- 620. - Pads.handleFilterPos();
- 621. - if (!window.Audio || !Audio.showRows) return;
- 622. -
- 623. - if (more && isVisible(more) && _pads.content.scrollTop + _pads.content.offsetHeight + 400 > more.offsetTop) {
- 624. - Audio.showRows({from_pad: true});
- 625. - }
- 626. -
- 627. - if (searchMore && isVisible(searchMore) && _pads.content.scrollTop + _pads.content.offsetHeight + 400 > searchMore.offsetTop) {
- 628. - Audio.loadRows(true);
- 629. + var more = ge('pad_more_audio');
- 630. + if (!more || !isVisible(more) || !Pads.showAudios) return;
- 631. + if (_pads.content.scrollTop + _pads.content.offsetHeight > more.offsetTop) {
- 632. + Pads.showAudios();
- 653. - });
- 654. - extend(_pads, {
- 655. - editing: {}
- 767. - var barHeight = getXY('page_layout')[1];
- 768. - if (lh) wh = Math.max(Math.min(wh, lh - 104 - (/*hasClass(_pads.arrow, 'right') ? 12 :*/ 46) + barHeight), 200);
- 769. + if (lh) wh = Math.max(Math.min(wh, lh - 104 - (hasClass(_pads.arrow, 'right') ? 12 : 46)), 200);
- 776. - editing: _pads.editing || {}
- 777. + editing: {}
- 792. - editing: _pads.editing || {}
- 793. + editing: {}
- 795. - handlePageCount('nws', 0, 'feed' + (ge('l_nwsf') ? '?section=notifications' : ''), ge('l_nwsf') ? '' : 'section=notifications');
- 796. + handlePageCount('nws', 0, 'feed', 'section=notifications');
- 1036. - grDone: function(gid, fail, res, block, text) {
- 1037. + grDone: function(gid, fail, text) {
- 1042. - }
- 1043. - } else {
- 1044. - if (_pads.cur.processed[gid] > 0 && vk.counts.gr >= _pads.cur.savedcnts[gid]) {
- 1045. - Pads.decr('gr');
- 1046. - for (var i in _pads.cur.savedcnts) {
- 1047. - --_pads.cur.savedcnts[i];
- 1048. - }
- 1050. - if (block > 0) {
- 1051. - text = '<div class="pads_gr_clubinv_block">' + text.replace('{club}', '<b>' + val(domPS(ge('pads_clubinv' + gid))) + '</b>') + '</div>';
- 1052. - text += '<div class="pads_gr_clubinv_block"><a onclick="Pads.grProcess(this, ' + gid + ', -2, -1)">' + getLang('global_cancel') + '</a></div>';
- 1053. - } else if (!block && res < 0 && ge('pads_clubinv' + gid)) {
- 1054. - text += '<div class="pads_gr_clubinv_block"><a onclick="Pads.grProcess(this, ' + gid + ', -2, 1)">' + val('groups_block_clubinv').replace('{club}', '<b>' + val(domPS(ge('pads_clubinv' + gid))) + '</b>') + '</a></div>';
- 1055. + } else if (_pads.cur.processed[gid] > 0 && vk.counts.gr >= _pads.cur.savedcnts[gid]) {
- 1056. + Pads.decr('gr');
- 1057. + for (var i in _pads.cur.savedcnts) {
- 1058. + --_pads.cur.savedcnts[i];
- 1064. - if (!fail && block < 0) {
- 1065. - text = btns.oldtext;
- 1066. - }
- 1069. - className: 'pad_gr_result',
- 1070. - oldtext: val(btns)
- 1071. + className: 'pad_gr_result'
- 1075. - grProcess: function(el, gid, res, block) {
- 1076. + grProcess: function(el, gid, res) {
- 1087. - ajax.post('al_groups.php', {act: act, gid: gid, from: 'pad', context: context, hash: _pads.hash, block: block}, {
- 1088. - onDone: Pads.grDone.pbind(gid, false, res, block),
- 1089. - onFail: Pads.grDone.pbind(gid, true, res, block),
- 1090. + ajax.post('al_groups.php', {act: act, gid: gid, from: 'pad', context: context, hash: _pads.hash}, {
- 1091. + onDone: Pads.grDone.pbind(gid, false),
- 1092. + onFail: Pads.grDone.pbind(gid, true),
- 1107. - }
- 1108. - if (trim((
- 1109. - window.getSelection && window.getSelection() ||
- 1110. - document.getSelection && document.getSelection() ||
- 1111. - document.selection && document.selection.createRange().text || ''
- 1112. - ).toString()).length) {
- 1113. - return;
- 1239. - var op = _pads.editing[nws], t = ge('pad_nws_field' + nws), d = val('pad_nwsd' + nws).split('/'), el = ge('pad_nws' + nws);
- 1240. + var t = ge('pad_nws_field' + nws), d = val('pad_nwsd' + nws).split('/'), el = ge('pad_nws' + nws);
- 1242. - if (!op) return;
- 1243. + if (!t) return;
- 1248. - }
- 1249. - if (trim((
- 1250. - window.getSelection && window.getSelection() ||
- 1251. - document.getSelection && document.getSelection() ||
- 1252. - document.selection && document.selection.createRange().text || ''
- 1253. - ).toString()).length) {
- 1254. - return;
- 1257. - if (op) {
- 1258. + if (t) {
- 1260. - var v = t ? val(t) : '';
- 1261. - if (trim(v) && op.greet.indexOf(v) !== 0) return (ev === true) ? true : elfocus(t);
- 1262. + var v = val(t);
- 1263. + if (trim(v) && _pads.editing[nws].greet.indexOf(v) !== 0) return (ev === true) ? true : elfocus(t);
- 1265. - if (t) cleanElems(t);
- 1266. + cleanElems(t);
- 1281. - addClass(el, 'pad_nws_reply');
- 1282. - _pads.editing[nws] = opts;
- 1283. - if (opts.disabled) {
- 1284. - var c = geByClass1('pad_nws_cont', el).appendChild(ce('div', {
- 1285. - className: 'pad_nwsa pad_nwsr',
- 1286. - innerHTML: val('pad_nws_dis_tpl').replace('{text}', opts.disabled)
- 1287. - }));
- 1288. - } else {
- 1289. - var c = geByClass1('pad_nws_cont', el).appendChild(ce('div', {
- 1290. - className: 'pad_nwsa pad_nwsr',
- 1291. - innerHTML: val('pad_nws_reply_tpl').replace('{field}', '\
- 1292. + var c = geByClass1('pad_nws_cont', el).appendChild(ce('div', {
- 1293. + className: 'pad_nwsa pad_nwsr',
- 1294. + innerHTML: val('pad_nws_reply_tpl').replace('{field}', '\
- 1301. - }));
- 1302. - t = ge('pad_nws_field' + nws);
- 1303. - placeholderSetup(t, {back: true});
- 1304. - autosizeSetup(t, {minHeight: 31, onResize: Pads.update});
- 1305. - }
- 1306. + }));
- 1307. + t = ge('pad_nws_field' + nws);
- 1308. + addClass(el, 'pad_nws_reply');
- 1309. + placeholderSetup(t, {back: true});
- 1310. + autosizeSetup(t, {minHeight: 31, onResize: Pads.update});
- 1311. + _pads.editing[nws] = opts;
- 1312. +
- 1328. - if (t) elfocus(t);
- 1329. + elfocus(t);
- 1407. - if (!post.indexOf('topic_comment')) {
- 1408. + if (!post.indexOf('topic_post')) {
- 1410. - post = post.replace('topic_comment', '');
- 1411. + post = post.replace('topic_post', '');
- 1472. - });
- 1473. - Pads.invalidate();
- 1474. - },
- 1475. - apRemoveAll: function(hash) {
- 1476. - ajax.post('apps', {act: 'a_remove_all_notifies', hash: hash, requests: 1}, {
- 1477. - onDone: function() {
- 1478. - Pads.decr('ap', true);
- 1479. - }
- 1480. - });
- 1481. - },
- 1482. - loadAudioRecommendations: function(el, aid) {
- 1483. - if (el.tt) el.tt.hide();
- 1484. - stManager.add('audioplayer.js', function() {
- 1485. - if (!window.audioPlayer) return;
- 1486. - audioPlayer.showRec(aid, true);
- 1487. - });
- 1488. - },
- 1489. - addAudio: function(el, aid, oid) {
- 1490. - if (cur.addedIds && cur.addedIds[oid+'_'+aid]) return false;
- 1491. - if (el.tt) el.tt.hide();
- 1492. - if (window.Audio) {
- 1493. - Audio.animateAdded(el, 200);
- 1494. - var addEl = ge('audio'+oid+'_'+aid) && geByClass1('audio_add_wrap', ge('audio'+oid+'_'+aid));
- 1495. - if (addEl && !hasClass(addEl, 'anim')) {
- 1496. - Audio.animateAdded(addEl, 200);
- 1497. - }
- 1498. - } else {
- 1499. - var c = se('<div class="audio_add_wrap added fl_r" onclick="return cancelEvent(event);"><div class="audio_add"></div></div>');
- 1500. - el.parentNode.replaceChild(c, el);
- 1501. - }
- 1502. - var _a = window.audioPlayer;
- 1503. - var query = {act: 'add', aid: aid, oid: oid, hash: (window._pads && _pads.addHash || _a && _a.addHash)};
- 1504. - if (_a && (_a.top || _a.playbackParams && (_a.playbackParams.top_audio || _a.playbackParams.top))) {
- 1505. - query.top = 1;
- 1506. - }
- 1507. - ajax.post(Audio.address, query, {
- 1508. - onDone: function (data, res) {
- 1509. - if (data && window.Audio) {
- 1510. - var aobj = eval('('+data+')'), all_list;
- 1511. - aobj = aobj['all'][0];
- 1512. - setTimeout(function(){
- 1513. - if (cur.id == vk.id && cur.audiosIndex && cur.audiosList && cur.audiosList['all'] && cur.aSearch) {
- 1514. - all_list = cur.audiosList['all'];
- 1515. - if (all_list && all_list.length) {
- 1516. - aobj._order = all_list[0]._order - 1;
- 1517. - cur.audiosList['all'].splice(0,0,aobj);
- 1518. - } else {
- 1519. - aobj._order = 0;
- 1520. - cur.audiosList['all'] = [aobj];
- 1521. - }
- 1522. - cur.audios[aobj[1]] = aobj;
- 1523. - cur.audiosIndex.add(aobj);
- 1524. - }
- 1525. - if (window._pads && _pads.cur && _pads.cur.audiosIndex && _pads.cur.audiosList) {
- 1526. - all_list = _pads.cur.audiosList['all'];
- 1527. - if (all_list && all_list.length) {
- 1528. - aobj._order = all_list[0]._order - 1;
- 1529. - _pads.cur.audiosList['all'].splice(0,0,aobj);
- 1530. - } else {
- 1531. - aobj._order = 0;
- 1532. - _pads.cur.audiosList['all'] = [aobj];
- 1533. - }
- 1534. - if (_pads.cur.audios) {
- 1535. - _pads.cur.audios[aobj[1]] = aobj;
- 1536. - }
- 1537. - if (_pads.cur.allAudiosIndex == 'all') {
- 1538. - _pads.cur.audiosIndex.add(aobj);
- 1539. - }
- 1540. - }
- 1541. - Pads.clearAudioLoadCache();
- 1542. - }, 0);
- 1543. - }
- 1544. - cur.addedIds = cur.addedIds || {};
- 1545. - cur.addedIds[oid+'_'+aid] = 1;
- 1546. - if (window.audioPlayer && currentAudioId()) {
- 1547. - var cur_aids = currentAudioId().split('_');
- 1548. - if (cur_aids[0] == oid && cur_aids[1] == aid) {
- 1549. - audioPlayer.showCurrentAdded();
- 1550. - }
- 1551. - }
- 1552. - }
- 1553. - });
- 1554. - },
- 1555. - onAudioReorder: function(audio, before, after) {
- 1556. - var aid = audio.id.substr(5);
- 1557. - var before_id = (before && before.id || '').substr(5);
- 1558. - var after_id = (after && after.id || '').substr(5);
- 1559. - var padPlist = padAudioPlaylist();
- 1560. - if (aid && padPlist && !padPlist[aid]) {
- 1561. - aid = aid.replace('_pad', '');
- 1562. - before_id = before_id.replace('_pad', '');
- 1563. - after_id = after_id.replace('_pad', '');
- 1564. - }
- 1565. - if (aid && padPlist && padPlist[aid]) {
- 1566. - if (!before_id && after_id && padPlist[after_id]) {
- 1567. - before_id = padPlist[after_id]._next;
- 1568. - } else if (!after_id && before_id && padPlist[before_id]) {
- 1569. - after_id = padPlist[before_id]._prev;
- 1570. - }
- 1571. - var pl = ge('pad_playlist');
- 1572. - if (pl && pl.sorter && pl.sorter.elems) {
- 1573. - var newStart = (pl.sorter.elems[0].id || '').substr(5);
- 1574. - if (newStart && !padPlist[newStart]) {
- 1575. - newStart = newStart.replace('_pad', '');
- 1576. - }
- 1577. - padPlist.start = newStart;
- 1578. - }
- 1579. - var prev_id = padPlist[aid]._prev, next_id = padPlist[aid]._next;
- 1580. - if (prev_id && padPlist[prev_id] && next_id && padPlist[next_id] &&
- 1581. - before_id && padPlist[before_id] && after_id && padPlist[after_id] && after_id != aid && before_id != aid) {
- 1582. - padPlist[prev_id]._next = next_id;
- 1583. - padPlist[next_id]._prev = prev_id;
- 1584. - padPlist[aid]._prev = after_id;
- 1585. - padPlist[after_id]._next = aid;
- 1586. - padPlist[aid]._next = before_id;
- 1587. - padPlist[before_id]._prev = aid;
- 1588. - }
- 1589. - if (window.audioPlaylist && audioPlaylist[aid]) {
- 1590. - window.audioPlaylist = padPlist;
- 1591. - }
- 1592. - ls.set('pad_playlist', padPlist);
- 1593. - ls.set('pad_pltime', vkNow());
- 1594. - }
- 1595. - },
- 1596. - setAudioCurPos: function(speed) {
- 1597. - var _a = window.audioPlayer, audio_id = (_a && _a.isPlaylistGlobal()) ? ls.get('audio_id') || currentAudioId() : currentAudioId();
- 1598. - if (!audio_id) return;
- 1599. - if (audio_id.substr(-4) != '_pad') {
- 1600. - audio_id += '_pad';
- 1601. - }
- 1602. - if (ge('audio'+audio_id)) {
- 1603. - var h = 430;
- 1604. - if (window.lastWindowHeight) {
- 1605. - h = Math.min(h, lastWindowHeight - 104 - (hasClass(ge('pad_arrow'), 'right') ? 13 : 46));
- 1606. - if (h < 200) h = 200;
- 1607. - }
- 1608. - var sTop = ge('audio'+audio_id).offsetTop + ge('pad_playlist').offsetTop - Math.min(ge('pad_cont').offsetHeight, h) / 2 + 17;
- 1609. - if (ge('pad_content') && sTop > 0) {
- 1610. - if (speed) {
- 1611. - animate(ge('pad_content'), {scrollTop: sTop}, speed, function() {
- 1612. - Pads.update();
- 1613. - })
- 1614. - } else {
- 1615. - ge('pad_content').scrollTop = sTop;
- 1616. - Pads.update();
- 1617. - }
- 1618. - }
- 1619. - }
- 1620. - },
- 1621. - playLastStatus: function() {
- 1622. - var _a = audioPlayer, pl = ge('pad_playlist');
- 1623. - if (cur.nextPlaylist && cur.nextPlaylist.start) {
- 1624. - var m = cur.nextPlaylist.start.match(/^-?\d+_\d+_s(-?\d+)(?:_|$)/);
- 1625. - if (m && m[1] && _a.statusData && _a.statusData[m[1]]) {
- 1626. - var data = _a.statusData[m[1]];
- 1627. - window.audioPlaylist = clone(cur.nextPlaylist);
- 1628. - if (window.audioPlayer) {
- 1629. - audioPlayer.setPadPlaylist(audioPlaylist);
- 1630. - }
- 1631. - playAudioNew(audioPlaylist.start);
- 1632. - pl.innerHTML = '<div class="pad_audio_status">'+data.audio_litening_to_user+'</div>';
- 1633. - ge('pad_footer_text').innerHTML = data.audio_goto_user;
- 1634. - hide('pad_more_audio');
- 1635. - }
- 1636. - }
- 1637. - },
- 1638. - audioRow: function(audio, opts) {
- 1639. - opts = opts || {};
- 1640. - var aid = audio.full_id || audio[0]+'_'+audio[1], actions = '';
- 1641. - var performer = audio[5].replace(/\\$/g, "\\$");
- 1642. - var _a = window.audioPlayer, cur_aid = (_a && _a.isPlaylistGlobal()) ? ls.get('audio_id') || currentAudioId() : currentAudioId();
- 1643. - if (vk.id != audio[0] || audio[9] && intval(audio[9])) {
- 1644. - if (cur.addedIds && cur.addedIds[audio[0]+'_'+audio[1]]) {
- 1645. - actions += '<div class="audio_add_wrap added fl_r" onclick="return cancelEvent(event);"><div class="audio_add"></div></div>';
- 1646. - } else {
- 1647. - actions += '<div class="audio_add_wrap fl_r" onmouseover="Audio.rowActive(this, \'' + getLang('audio_add_to_audio') + '\', [9, 5, 0]);" onmouseout="Audio.rowInactive(this);" onclick="Pads.addAudio(this, '+audio[1]+', '+audio[0]+'); return cancelEvent(event);"><div class="audio_add"></div></div>';
- 1648. - }
- 1649. - }
- 1650. -
- 1651. - return rs(Pads.audioTpl, {
- 1652. - audio_id: (aid.substr(-4) == '_pad') ? aid : aid+'_pad',
- 1653. - performer: performer,
- 1654. - title: audio[6].replace(/\\$/g, "\\$"),
- 1655. - url: audio[2],
- 1656. - playtime: audio[3],
- 1657. - duration: audio[4],
- 1658. - attr: 'href="/search?c[q]='+performer.replace(/(<span>|<\/span>)/g, '')+'&c[section]=audio&c[performer]=1" onclick="if (checkEvent(event)) return; Audio.selectPerformer({from_pad: true, event: event, name: \''+performer.replace(/(<span>|<\/span>)/g, '').replace(/'/g, "\\\\\\'")+'\'}); return false"',
- 1659. - actions: actions,
- 1660. - author: '',
- 1661. - onclick: 'window.padPlClicked = true; playAudioNew(\''+aid+'\')',
- 1662. - rowclass: (actions ? '' : 'no_actions') + (cur_aid == aid ? (opts.thisTab && currentAudioId() == aid ? ' current' : ' tab_current') : '')
- 1664. - },
- 1665. - showAudios: function() {
- 1666. - var self = this, __cur = window._pads && _pads.cur, pl = ge('pad_playlist'),
- 1667. - _a = window.audioPlayer, pList = _a.recsLoaded && cur.nextPlaylist ? cur.nextPlaylist || {} : ((!window.audioPlaylist || window.curNotifier && (padPlData = ls.get('pad_pldata')) && padPlData.source == curNotifier.instance_id) ? ls.get('pad_playlist') || window.audioPlaylist : padAudioPlaylist());
- 1668. - if (__cur.allLoading) return;
- 1669. - if (pList) {
- 1670. - var el = domLC(pl), aid = '', first_id = '', showRowsCnt = 25, rowsCnt = geByClass('audio', pl).length, _a, audio_id = ((_a = window.audioPlayer) && _a.isPlaylistGlobal()) ? ls.get('audio_id') || currentAudioId() : currentAudioId();
- 1671. -
- 1672. - if (el) {
- 1673. - first_id = geByClass1('audio', pl).id.substr(5).replace('_pad', '');
- 1674. - var last_id = el.id.substr(5).replace('_pad', '');
- 1675. - if (pList[last_id] && pList[last_id]._next) {
- 1676. - aid = pList[last_id]._next;
- 1677. - }
- 1678. - } else if (audio_id && pList[audio_id]) {
- 1679. - aid = audio_id;
- 1680. - for (var i = 0; i < 100; i++) {
- 1681. - if (!aid || aid == pList.start) break;
- 1682. - aid = pList[aid]._prev;
- 1683. - showRowsCnt++;
- 1684. - }
- 1685. - first_id = aid;
- 1686. - } else {
- 1687. - aid = first_id = pList.start;
- 1688. - }
- 1689. - if (!first_id) {
- 1690. - if (audio_id) {
- 1691. - var m = audio_id.match(/^-?\d+_\d+_s(-?\d+)(?:_|$)/);
- 1692. - if (m && m[1] && (pList.statusData || _a.statusData && _a.statusData[m[1]])) {
- 1693. - var data = pList.statusData || _a.statusData[m[1]];
- 1694. - var el = se('<div class="pad_audio_status">' + (first_id != audio_id ? data.audio_listen_to_user : data.audio_litening_to_user) + '</div>');
- 1695. - pl.appendChild(el);
- 1696. - setTimeout(function() {
- 1697. - setStyle(el, {height: getSize(_pads.content)[1] - 110 - ge('pad_playlist').offsetTop});
- 1698. - }, 0)
- 1699. - ge('pad_footer_text').innerHTML = data.audio_goto_user;
- 1700. - }
- 1701. - }
- 1702. - hide('pad_more_audio');
- 1703. - } else {
- 1704. - if (first_id) {
- 1705. - var m = first_id.match(/^-?\d+_\d+_s(-?\d+)(?:_|$)/);
- 1706. - if (m && m[1] && (pList.statusData || _a.statusData && _a.statusData[m[1]]) && !pList[first_id]._next) {
- 1707. - var data = pList.statusData || _a.statusData[m[1]];
- 1708. - var el = se('<div class="pad_audio_status">' + (first_id != audio_id ? data.audio_listen_to_user : data.audio_litening_to_user) + '</div>');
- 1709. - pl.appendChild(el);
- 1710. - setTimeout(function() {
- 1711. - setStyle(el, {height: getSize(_pads.content)[1] - 110 - ge('pad_playlist').offsetTop});
- 1712. - }, 0)
- 1713. - ge('pad_footer_text').innerHTML = data.audio_goto_user;
- 1714. - hide('pad_more_audio');
- 1715. - return;
- 1716. - }
- 1717. - }
- 1718. - var k = 0;
- 1719. - if (aid) {
- 1720. - var thisTab = pList && window.curNotifier && pList.instance == curNotifier.instance_id;
- 1721. - do {
- 1722. - var rowEl = se(Pads.audioRow(pList[aid], {thisTab: thisTab}));
- 1723. - pl.appendChild(rowEl);
- 1724. - if (pList[aid]._next) aid = pList[aid]._next;
- 1725. - k++;
- 1726. - } while (aid && aid !== first_id && k < showRowsCnt);
- 1727. - }
- 1728. - if (aid == first_id) {
- 1729. - var more = ge('pad_more_audio');
- 1730. - if (pList.has_more) {
- 1731. - __cur.allLoading = true;
- 1732. - __cur.allLoadedCallback = function() {
- 1733. - __cur.allLoading = false;
- 1734. - Audio.showRows({from_pad: true});
- 1735. - }
- 1736. - Audio.loadFriendsAudios({from_pad: true, id: vk.id, index: 'all'});
- 1737. - } else {
- 1738. - hide(more);
- 1739. - }
- 1740. - }
- 1741. - if (window._pads && _pads.currentShown && !browser.mobile) {
- 1742. - if (el && pl.sorter) {
- 1743. - setTimeout(sorter.added.pbind(pl), 0);
- 1744. - } else {
- 1745. - setTimeout(function(){
- 1746. - sorter.init(pl, {onReorder: Pads.onAudioReorder, noMoveCursor: 1});
- 1747. - if (!el && !_a.recsLoaded) Pads.setAudioCurPos();
- 1748. - }, 0);
- 1749. - }
- 1750. - }
- 1751. - if (pList.htitle) {
- 1752. - ge('pad_footer_text').innerHTML = '<span class="audio_album_length">'+pList.htitle+'</span>';
- 1753. - }
- 1754. - if (!el && !_a.recsLoaded) Pads.setAudioCurPos();
- 1755. - }
- 1756. - Pads.update();
- 1757. - }
- 1758. - },
- 1759. - clearAudioLoadCache: function() {
- 1760. - if (!window._pads) {
- 1761. - return;
- 1762. - }
- 1764. - if (!window.ajaxCache) {
- 1765. - return;
- 1766. - }
- 1767. - for (var i in window.ajaxCache) {
- 1768. - var h = i.split('#'), params = h[1] && q2ajx(h[1]);
- 1769. - if ((h[0] == '/audio' || h[0] == 'audio') && params.act == 'load_audios_silent' && intval(params.id) == 3520) {
- 1770. - delete ajaxCache[i];
- 1771. - }
- 1772. - }
- ------
- Файл - audioplayer.js (Старый размер - 69789 | Новый - 0):
- 0. - var oldAudioPlayer = window.audioPlayer || {};
- 1. - var audioPlayer = {
- 2. - id: oldAudioPlayer.id || null,
- 3. - controls: oldAudioPlayer.controls || null,
- 4. - player: oldAudioPlayer.player || null,
- 5. - lastSong: oldAudioPlayer.lastSong || null,
- 6. - eventsInited: oldAudioPlayer.eventsInited || null,
- 7. - statusExport: oldAudioPlayer.statusExport || null,
- 8. - addHash: oldAudioPlayer.addHash || null,
- 9. - volW: 33,
- 10. - prX: 14,
- 11. - gpSz: 330,
- 12. - gpMinW: 154,
- 13. - gpMaxW: 553,
- 14. - prStep: 10,
- 15. - images: {
- 16. - icon: '/images/favicon' + (vk.intnat ? '_vk' : 'new') + '.ico',
- 17. - playicon: '/images/playiconnew'+(window.devicePixelRatio >= 2 ? '_2x' : '')+'.ico',
- 18. - pauseicon: '/images/pauseiconnew'+(window.devicePixelRatio >= 2 ? '_2x' : '')+'.ico'
- 19. - },
- 20. - songInfos: {},
- 21. - shareMusic: function() {
- 22. - var mus = ((window._pads && _pads.shown == 'mus' && audioPlayer.isPlaylistGlobal() ? ls.get('audio_id') : null) || currentAudioId() || (audioPlayer.lastSong && audioPlayer.lastSong.aid) || (cur.defaultTrack && cur.defaultTrack.id) || window.audioPlaylist && audioPlaylist.start || '').match(/^(-?\d+_\d+)(?:_(s-?\d+(?:_h-?\d+)?))?/);
- 23. - if (!mus) return;
- 24. - return !showBox('like.php', {act: 'publish_box', object: 'audio' + mus[1], list: mus[2] || ('s' + vk.id), to: 'mail'}, {stat: ['page.js', 'page.css', 'wide_dd.js', 'wide_dd.css', 'sharebox.js']});
- 25. - },
- 26. - initPlayer: function(id) {
- 27. - var _a = audioPlayer;
- 28. - var html5AudioSupport = false;
- 29. - try {
- 30. - var audioObj = ce('audio');
- 31. - if (('no' != audioObj.canPlayType('audio/mpeg')) && ('' != audioObj.canPlayType('audio/mpeg'))) html5AudioSupport=true;
- 32. - } catch (e){}
- 33. - if (browser.mobile || browser.msie6) _a.gpDisabled = true;
- 34. - if (browser.flash >= 9 && !(browser.mac && (browser.chrome || browser.safari) && html5AudioSupport)) {
- 35. - var opts = {
- 36. - url: '/swf/audio_lite.swf',
- 37. - id: 'player',
- 38. - height: 2
- 39. - }
- 40. - var params = {
- 41. - swliveconnect: 'true',
- 42. - allowscriptaccess: 'always',
- 43. - wmode: 'opaque'
- 44. - }
- 45. - var vars = {
- 46. - onLoadComplete: 'audioPlayer.onLoadComplete',
- 47. - onError: 'audioPlayer.onError',
- 48. - onPlayFinish: 'audioPlayer.onPlayFinish',
- 49. - onLoadProgress: 'audioPlayer.onLoadProgress',
- 50. - onPlayProgress: 'audioPlayer.onPlayProgress'
- 51. - }
- 52. - var t = 'flash_audio';
- 53. - if (!ge(t)) document.body.appendChild(ce('div',{id: t, className: 'fixed'}));
- 54. - if (renderFlash(t, opts, params, vars)) {
- 55. - setTimeout(function(){_a.checkFlashLoaded(id);},50);
- 56. - }
- 57. - } else {
- 58. - if (html5AudioSupport) {
- 59. - var t = 'html5_audio';
- 60. - if (!ge(t)) document.body.appendChild(ce('audio',{id: t}));
- 61. - stManager.add('audio_html5.js',function(){
- 62. - _a.isHTML5 = true;
- 63. - _a.setPlayer(audio_html5, id);
- 64. - });
- 65. - } else {
- 66. - _a.setPlayer(null,id);
- 67. - }
- 68. - }
- 69. - if (!_a.eventsInited) _a.initEvents();
- 70. - if (!ge('gp') && !_a.gpDisabled) {
- 71. - document.body.appendChild(ce('div', {id: 'gp', className: 'fixed'}));
- 72. - addEvent(ge('gp'), 'dragstart', function() {return false;});
- 73. - addEvent(ge('gp'), 'selectstart', function() {return false;});
- 74. - ge('gp').innerHTML = '<div class="wrap" onmouseover="addClass(this, \'over\');" onmouseout="removeClass(this, \'over\');">\
- 75. - <div id="gp_back"><div><!-- --></div></div>\
- 76. - <div id="gp_wrap">\
- 77. - <div class="audio" id="audio_global">\
- 78. - <div id="gp_small">\
- 79. - <div id="gp_play_btn" class="fl_l"></div>\
- 80. - <div id="gp_info" class="fl_l" onmouseover="if (!vk.id) return; Pads.preload(\'mus\')" onclick="if (!vk.id) return; window._pads.gpClicked = true; Pads.show(\'mus\', event)">\
- 81. - <div id="gp_performer"></div>\
- 82. - <div id="gp_title"></div>\
- 83. - </div>\
- 84. - </div>\
- 85. - </div>\
- 86. - </div>\
- 87. - </div>';
- 88. - toggle('gp', !_a.gpHidden && !cur.gpHidden);
- 89. - var barHeight = getXY('page_layout')[1];
- 90. - var headFixed = ge('head_play_btn') && getStyle(ge('page_header'), 'position') == 'fixed',
- 91. - gpTop = headFixed || scrollGetY() < 29 + barHeight ? 49 + barHeight : 20;
- 92. - setStyle(gp, {top: gpTop});
- 93. - // toggleClass(gp, 'z_index', !browser.mac);
- 94. - }
- 95. - },
- 96. - initEvents: function() {
- 97. - var _n = window.Notifier, _a = audioPlayer;
- 98. - if (_a.eventsInited) return;
- 99. - if (_n) {
- 100. - _n.addRecvClbk('audio_start', 'audio', function(data) {
- 101. - var _a = window.audioPlayer;
- 102. - if (_a) {
- 103. - if (_a.player && !_a.player.paused()) _a.pauseTrack();
- 104. - _a.pausedByVideo = null;
- 105. - if (window.Pads && window._pads && _pads.shown == 'mus') {
- 106. - Pads.hide();
- 107. - }
- 108. - }
- 109. - });
- 110. - _n.addRecvClbk('audio_mediakey', 'audio', this.keyPressed.pbind(true));
- 111. - _n.addRecvClbk('video_start', 'audio', function (data) {
- 112. - var _a = window.audioPlayer;
- 113. - if (_a && _a.player && !_a.player.paused()) {
- 114. - _a.pauseTrack();
- 115. - _a.pausedByVideo = 1;
- 116. - }
- 117. - });
- 118. - _n.addRecvClbk('video_hide', 'audio', function (data) {
- 119. - var _a = window.audioPlayer;
- 120. - if (_a) {
- 121. - if (_a.player && _a.player.paused() && _a.pausedByVideo) _a.playTrack();
- 122. - _a.pausedByVideo = null;
- 123. - }
- 124. - });
- 125. - _n.addRecvClbk('videocall_start', 'audio', function (data) {
- 126. - var _a = window.audioPlayer;
- 127. - if (_a && _a.player && !_a.player.paused()) {
- 128. - _a.pauseTrack();
- 129. - _a.pausedByVideo = 1;
- 130. - }
- 131. - });
- 132. - _n.addRecvClbk('videocall_end', 'audio', function (data) {
- 133. - var _a = window.audioPlayer;
- 134. - if (_a) {
- 135. - if (_a.player && _a.player.paused() && _a.pausedByVideo) _a.playTrack();
- 136. - _a.pausedByVideo = null;
- 137. - }
- 138. - });
- 139. - }
- 140. - addEvent(document, 'mouseup', _a.mouseUp);
- 141. - addEvent(document, 'mousemove', _a.mouseMove);
- 142. - _a.timeLeft = intval(getCookie('audio_time_left') || 1);
- 143. - if (cur.hashes && cur.hashes.add_hash && !_a.addHash) {
- 144. - _a.addHash = cur.hashes.add_hash;
- 145. - }
- 146. -
- 147. - _a.eventsInited = true;
- 148. - },
- 149. - checkFlashLoaded: function(id) {
- 150. - var player=ge("player");
- 151. - var _a=audioPlayer;
- 152. - if (player && player.paused) _a.setPlayer(player,id);
- 153. - else setTimeout(function(){_a.checkFlashLoaded(id);},50);
- 154. - },
- 155. - hasStatusExport: function() {
- 156. - var _a = audioPlayer;
- 157. - _a.statusExport = _a.statusExport || {};
- 158. - for (var i in _a.statusExport) {
- 159. - if (_a.statusExport[i]) return true;
- 160. - }
- 161. - return false;
- 162. - },
- 163. - setPlayer: function(element, id) {
- 164. - if (element) {
- 165. - var _a = audioPlayer;
- 166. - _a.player = element;
- 167. - var volume = browser.mobile ? 80 : parseInt(getCookie('audio_vol'));
- 168. - if (!isNaN(volume)) _a.player.setVolume(volume / 100);
- 169. - _a.operate(id, true);
- 170. - if (!_a.gotData) {
- 171. - _a.gotData = -1;
- 172. - ajax.post('audio', {act: 'get_data'}, {
- 173. - onDone: function(hash, exp, langs) {
- 174. - window.lang = extend(window.lang || {}, langs);
- 175. - _a.addHash = hash;
- 176. - _a.statusExport = exp && !_a.hasStatusExport() ? exp : _a.statusExport || {};
- 177. - checkbox('currinfo_audio', _a.hasStatusExport());
- 178. - if (_a.hasStatusExport()) {
- 179. - _a.playback(_a.paused);
- 180. - _a.showCurrentTrack();
- 181. - }
- 182. - _a.gotData = 1;
- 183. - }
- 184. - })
- 185. - }
- 186. - } else {
- 187. - var message = getLang('audio_you_need_flash') + '<br/><br/>' + getLang('audio_do_you_want_flash');
- 188. - showFastBox({title: getLang('audio_need_flash_title')}, message, getLang('share_go'), function() {
- 189. - document.location = 'http://get.adobe.com/flash/';
- 190. - }, getLang('global_cancel'));
- 191. - _a.gpHidden = true;
- 192. - }
- 193. - },
- 194. - setIcon: function(icon) {
- 195. - setFavIcon(audioPlayer.images[icon]);
- 196. - },
- 197. - getSongInfoFromDOM: function(aid) {
- 198. - var art, title, nfo = geByClass1('info', ge('audio' + aid)), full_id = aid, l;
- 199. - if (full_id.substr(-4) == '_pad') {
- 200. - full_id = full_id.substr(0, full_id.length - 4);
- 201. - }
- 202. - if (!nfo) {
- 203. - nfo = geByClass1('info', ge('audio' + aid + '_pad'));
- 204. - }
- 205. - if (!ge('audio_info' + aid)) return null;
- 206. - art = geByTag1('b', nfo);
- 207. - l = geByTag1('a', art);
- 208. - if (l) art = l;
- 209. - var reArr = ['<span>', '</span>', '<span class="match">', '<font>', '</font>'], re = new RegExp(reArr.join('|'), "gi");
- 210. - art = art.innerHTML.replace(re, '');
- 211. - title = geByClass1('title', nfo);
- 212. - if (!title) title = ge('title' + aid);
- 213. - l = geByTag1('a', title);
- 214. - if (l) title = l.innerHTML;
- 215. - else title = title.innerHTML;
- 216. - title = title.replace(re, '');
- 217. - var data = ge('audio_info' + aid).value.split(','), url = data[0], duration = parseInt(data[1]);
- 218. - dur = audioPlayer.formatTime(duration);
- 219. - data = aid.split('_');
- 220. - var oid = data[0], aid = data[1], canAdd = (oid != vk.id) ? 1 : 0;
- 221. - if (!canAdd && data[2] && data[3]) {
- 222. - var wpt = ge('wpt' + data[2] + '_' + data[3]), post = wpt, postFound = false;
- 223. - if (wpt) {
- 224. - while (post) {
- 225. - post = post.parentNode;
- 226. - each(['reply_table', 'post_table', 'fw_reply_table', 'fw_post_table', 'pad_nwsa', 'pad_nws_data', 'feedback_row_content'], function() {
- 227. - if (hasClass(post, this)) {
- 228. - postFound = true;
- 229. - return false;
- 230. - }
- 231. - });
- 232. - if (postFound) break;
- 233. - }
- 234. - if (post) {
- 235. - var author = false;
- 236. - each(['author', 'fw_reply_author', 'fw_post_author', 'pad_nws_name'], function() {
- 237. - author = geByClass1(this, post);
- 238. - if (author) return false;
- 239. - });
- 240. - if (author) {
- 241. - var author_id = intval(author.getAttribute('data-from-id'));
- 242. - if (author_id && author_id != vk.id) {
- 243. - canAdd = 1;
- 244. - }
- 245. - }
- 246. - }
- 247. - }
- 248. - }
- 249. - var res = {
- 250. - 0: oid,
- 251. - 1: aid,
- 252. - 2: url,
- 253. - 3: duration,
- 254. - 4: dur,
- 255. - 5: art,
- 256. - 6: title,
- 257. - 7: 0,
- 258. - 8: 0,
- 259. - 9: canAdd
- 260. - };
- 261. - res.full_id = full_id;
- 262. - return res;
- 263. - },
- 264. - setSongInfo: function() {
- 265. - var _a = audioPlayer, aid = currentAudioId(), pl;
- 266. -
- 267. - if ((pl = padAudioPlaylist()) && pl[aid]) {
- 268. - _a.lastSong = pl[aid];
- 269. - } else if (_a.songInfos[aid]) {
- 270. - _a.lastSong = _a.songInfos[aid];
- 271. - } else if (cur.defaultTrack && cur.defaultTrack.id == aid) {
- 272. - _a.lastSong = cur.defaultTrack;
- 273. - } else {
- 274. - _a.lastSong = _a.getSongInfoFromDOM(aid);
- 275. - }
- 276. - if (!_a.lastSong) return;
- 277. - ls.set('pad_lastsong', _a.lastSong);
- 278. - _a.lastSong.aid = aid;
- 279. - },
- 280. - updateURL: function(full_id, audio_id, url, duration) {
- 281. - if (ge('audio_info'+full_id)) {
- 282. - ge('audio_info'+full_id).value = url+','+duration;
- 283. - }
- 284. - if (window.cur && cur.audios && cur.audios[audio_id]) {
- 285. - cur.audios[audio_id][2] = url;
- 286. - cur.audios[audio_id][3] = duration;
- 287. - }
- 288. - if (window.audioPlaylist && window.audioPlaylist[full_id]) {
- 289. - window.audioPlaylist[full_id][2] = url;
- 290. - window.audioPlaylist[full_id][3] = duration;
- 291. - }
- 292. - var pad_plist = ls.get('pad_playlist');
- 293. - if (pad_plist && pad_plist[full_id]) {
- 294. - this.setPadPlaylist(window.audioPlaylist);
- 295. - }
- 296. - if (window.cur && cur.nextPlaylist && cur.nextPlaylist[full_id]) {
- 297. - cur.nextPlaylist[full_id][2] = url;
- 298. - cur.nextPlaylist[full_id][3] = duration;
- 299. - }
- 300. - },
- 301. - reloadPlaylist: function() {
- 302. - if (window.cur && cur.audiosReloadedAll) return;
- 303. - if (window.audioPlaylist || window.cur && cur.audiosList && cur.audiosList['all'] && cur.oid) {
- 304. - var _a = audioPlayer;
- 305. - var query = {act: 'reload_playlist'};
- 306. - if (window.audioPlaylist) {
- 307. - var q = [];
- 308. - var i = 0, j = 0;
- 309. - for (var audio in window.audioPlaylist) {
- 310. - if (j >= 100) { j = 0; i++; }
- 311. - if (!q[i]) q[i] = [];
- 312. - q[i].push(audio);
- 313. - j++;
- 314. - }
- 315. - for (var i in q) {
- 316. - q[i] = q[i].join(',');
- 317. - }
- 318. - for (var i in q) {
- 319. - query['l['+i+']'] = q[i];
- 320. - }
- 321. - }
- 322. - if (window.cur && cur.audiosList && cur.audiosList['all'] && cur.oid) {
- 323. - query['oid'] = cur.oid;
- 324. - }
- 325. - ajax.post('audio', query, {onDone: function(list) {
- 326. - if (list) for (var i in list) {
- 327. - var a = list[i];
- 328. - var audio_id = i.split('_')[1];
- 329. - _a.updateURL(i, audio_id, a[0], a[1]);
- 330. - }
- 331. - if (!window.cur) window.cur = {};
- 332. - cur.audiosReloadedAll = true;
- 333. - setTimeout(function(){delete cur.audiosReloadedAll;}, 60000);
- 334. - }});
- 335. - }
- 336. - },
- 337. - reloadAudio: function(id) {
- 338. - ids = id.split('_');
- 339. - if (window.cur && (cur.audiosReloadedAll || cur.audiosReloaded && cur.audiosReloaded[id])) {
- 340. - setTimeout(showFastBox({title: getLang('global_error')}, getLang('audio_error_loading'), getLang('global_close')).hide, 2000);
- 341. - } else {
- 342. - ajax.post('audio', {act: 'reload_audio', owner_id: ids[0], audio_id: ids[1]}, {onDone: function(res) {
- 343. - if (res) {
- 344. - var _a = audioPlayer;
- 345. - _a.updateURL(id, ids[1], res[0], res[1]);
- 346. - _a.setSongInfo();
- 347. - _a.duration = res[1];
- 348. - _a.player.loadAudio(res[0]);
- 349. - _a.setControlsTitle();
- 350. - _a.setGraphics('load');
- 351. - _a.playback();
- 352. - }
- 353. - if (!window.cur) window.cur = {};
- 354. - if (!cur.audiosReloaded) cur.audiosReloaded = {};
- 355. - cur.audiosReloaded[id] = true;
- 356. - setTimeout(function(){delete cur.audiosReloaded[id];}, 60000);
- 357. - }});
- 358. - }
- 359. - },
- 360. - sendNotification: function(data) {
- 361. - var _n = window.Notifier;
- 362. - if (_n) _n.lcSend('audio_start', data);
- 363. - try {
- 364. - if (ge('video_player') && ge('video_player').playVideo) ge('video_player').playVideo(false);
- 365. - } catch(e) {}
- 366. - },
- 367. - setAid: function(aid) {
- 368. - audioPlayer.id = aid;
- 369. - ls.set('audio_id', aid);
- 370. - },
- 371. - operate: function(orig_id, nextPlaylist, opts) {
- 372. - var _a = audioPlayer, aid = currentAudioId(), id = orig_id;
- 373. - if (id.substr(-4) == '_pad') {
- 374. - id = id.substr(0, id.length - 4);
- 375. - }
- 376. -
- 377. - if (!_a.player || (!ge('flash_audio') && !ge('html5_audio'))) {
- 378. - _a.initPlayer(orig_id);
- 379. - return;
- 380. - }
- 381. - if (opts && opts.songInfo) {
- 382. - _a.songInfos[id] = opts.songInfo;
- 383. - }
- 384. -
- 385. - if (aid == id) {
- 386. - if (_a.player.paused()) {
- 387. - _a.sendNotification({id: id});
- 388. - if (_a.pausedByVideo) _a.pausedByVideo = null;
- 389. - if (_a.time != undefined) {
- 390. - try {_a.player.playAudio(_a.time)}catch(e){};
- 391. - _a.time = null;
- 392. - } else _a.player.playAudio();
- 393. - _a.setGraphics('play');
- 394. - _a.playback();
- 395. - if (!nextPlaylist && (cur.module == 'audio' || window._pads && _pads.shown == 'mus')) {
- 396. - if (ge('audio' + aid)) _a.scrollToTrack(aid);
- 397. - }
- 398. - } else {
- 399. - _a.player.pauseAudio();
- 400. - _a.setGraphics('pause');
- 401. - _a.playback(true);
- 402. - }
- 403. - } else {
- 404. - _a.sendNotification({id: id});
- 405. - if (_a.pausedByVideo) _a.pausedByVideo = null;
- 406. - if (aid) _a.stop();
- 407. - _a.setAid(id);
- 408. - if (window.padPlClicked/* || orig_id.substr(-4) == '_pad'*/) {
- 409. - var pList = _a.isPlaylistGlobal() ? ls.get('pad_playlist') || window.audioPlaylist : padAudioPlaylist();
- 410. - if (pList && pList[id]) {
- 411. - if (window.curNotifier && curNotifier.instance_id) {
- 412. - pList.instance = curNotifier.instance_id;
- 413. - _a.setPadPlaylist(pList);
- 414. - }
- 415. - nextPlaylist = cur.nextPlaylist && cur.nextPlaylist[id];
- 416. - }
- 417. - delete window.padPlClicked;
- 418. - }
- 419. - if (nextPlaylist) {
- 420. - if (cur.curSection == 'popular' || window._pads && _pads.shown == 'mus' && _pads.cur && _pads.cur.curSection == 'popular' || cur.audioTop) {
- 421. - _a.top = true;
- 422. - } else {
- 423. - delete _a.top;
- 424. - }
- 425. - _a.setPlaybackParams();
- 426. - if (cur && cur.nextPlaylist && cur.nextPlaylist[id]) {
- 427. - delete cur.nextPlaylist.has_more;
- 428. - window.audioPlaylist = clone(cur.nextPlaylist);
- 429. - audioPlaylist.address = nav.strLoc;
- 430. - cur.nextPlaylist = null;
- 431. - } else if (id.substr(-4) == '_pad' && cur && cur.nextPlaylist && cur.nextPlaylist[id.substr(0, id.length - 4)]) {
- 432. - _a.operate(id.substr(0, id.length - 4), nextPlaylist, opts);
- 433. - return;
- 434. - } else {
- 435. - if (!window.audioPlaylist || !window.audioPlaylist[id]) {
- 436. - if (ge('audio' + orig_id)) {
- 437. - _a.createDynamicPlaylist(orig_id, true);
- 438. - } else if (window.audioPlaylist) {
- 439. - window.audioPlaylist = null;
- 440. - }
- 441. - }
- 442. - }
- 443. - _a.setPadPlaylist(window.audioPlaylist);
- 444. - }
- 445. - if (_a.lastSong == undefined || id != _a.lastSong.aid) _a.setSongInfo();
- 446. - if (!_a.lastSong) return;
- 447. - if (_a.lastSong[0] && _a.lastSong[1] && parseInt(_a.lastSong[11])) {
- 448. - showAudioClaimWarning(_a.lastSong[0], _a.lastSong[0], '', -1, _a.lastSong[5] + ' – ' + _a.lastSong[6]);
- 449. - _a.setAid(null);
- 450. - return;
- 451. - }
- 452. - var url = _a.lastSong[2];
- 453. - _a.duration = _a.lastSong[3];
- 454. - if (url) {
- 455. - try {
- 456. - _a.player.loadAudio(url);
- 457. - } catch(e){}
- 458. - } else {
- 459. - _a.reloadAudio(id);
- 460. - }
- 461. - _a.setControlsTitle();
- 462. - var ids = id.split('_');
- 463. - var uid = (ids && ids.length > 1) ? ids[0] : vk.id;
- 464. - if (intval(uid) == cur.audioFriend) {
- 465. - cur.audioFriendPlaying = cur.audioFriend;
- 466. - if (window.Audio) Audio.cacheFriendsList();
- 467. - }
- 468. - _a.setGraphics('load');
- 469. - updGlobalPlayer();
- 470. - if (url) _a.playback();
- 471. - }
- 472. - if (_a.gpHidden) {
- 473. - _a.gpHidden = false;
- 474. - updGlobalPlayer();
- 475. - }
- 476. - },
- 477. - setGraphics: function(act) {
- 478. - var _a = audioPlayer, head_play = ge('head_play_btn'), aid = currentAudioId(),
- 479. - _row = ge('audio' +aid), pad_row = ge('audio'+aid+'_pad'), gp_play = ge('gp_play');
- 480. - if (!aid) return;
- 481. - switch (act) {
- 482. - case 'play':
- 483. - _a.setIcon('playicon');
- 484. - if (_row) {
- 485. - addClass(ge('play' + aid), 'playing');
- 486. - addClass(_row, 'current');
- 487. - }
- 488. - if (pad_row) {
- 489. - addClass(ge('play' + aid + '_pad'), 'playing');
- 490. - addClass(pad_row, 'current');
- 491. - }
- 492. - if (head_play) {
- 493. - addClass(head_play, 'playing');
- 494. - }
- 495. - if (gp_play) {
- 496. - addClass(gp_play, 'playing');
- 497. - }
- 498. - if (_a.controls) {
- 499. - for (var i in _a.controls) {
- 500. - var obj = _a.controls[i];
- 501. - if (obj.play) addClass(obj.play, 'playing');
- 502. - }
- 503. - }
- 504. - break;
- 505. - case 'pause':
- 506. - _a.setIcon('pauseicon');
- 507. - if (_row) {
- 508. - removeClass(ge('play' + aid), 'playing');
- 509. - }
- 510. - if (pad_row) {
- 511. - removeClass(ge('play' + aid + '_pad'), 'playing');
- 512. - }
- 513. - if (head_play) {
- 514. - removeClass(head_play, 'playing');
- 515. - }
- 516. - if (gp_play) {
- 517. - removeClass(gp_play, 'playing');
- 518. - }
- 519. - if (_a.controls) {
- 520. - for (var i in _a.controls) {
- 521. - var obj = _a.controls[i];
- 522. - if (obj.play) removeClass(obj.play, 'playing');
- 523. - }
- 524. - }
- 525. - break;
- 526. - case 'stop':
- 527. - _a.setIcon('icon');
- 528. - if (_row) {
- 529. - if (ge('repeat' + aid)) hide('repeat' + aid);
- 530. - removeClass(ge('play' + aid), 'playing');
- 531. - removeClass(_row, 'current');
- 532. -
- 533. - if (aid) {
- 534. - var t = _a.duration || _a.lastSong && _a.lastSong[3] || ge('audio_info' + aid).value.split(',')[1],
- 535. - res = _a.formatTime(t),
- 536. - dur = geByClass1('duration', ge('audio' + aid));
- 537. - if (dur && res) dur.innerHTML = res;
- 538. - }
- 539. -
- 540. - }
- 541. - if (pad_row) {
- 542. - removeClass(ge('play' + aid + '_pad'), 'playing');
- 543. - removeClass(pad_row, 'current');
- 544. - }
- 545. - if (head_play) {
- 546. - removeClass(head_play, 'playing');
- 547. - }
- 548. - if (gp_play) {
- 549. - removeClass(gp_play, 'playing');
- 550. - }
- 551. - if (_a.controls) {
- 552. - for (var i in _a.controls) {
- 553. - var obj = _a.controls[i];
- 554. - if (obj.play) removeClass(obj.play, 'playing');
- 555. - }
- 556. - }
- 557. - break;
- 558. - case 'load':
- 559. - var loaded = 0, playerVol = _a.player.getVolume(),
- 560. - vol = Math.round(_a.volW * playerVol);
- 561. - if (vk.rtl) vol = -vol;
- 562. - _a.setIcon('playicon');
- 563. - if (_a.controls) {
- 564. - for (var i in _a.controls) {
- 565. - var obj = _a.controls[i];
- 566. - if (obj.volume) {
- 567. - setStyle(obj.volume, {width: (playerVol * 100) + '%'})
- 568. - }
- 569. - }
- 570. - }
- 571. - if (_row) {
- 572. - addClass(ge('play' + aid), 'playing');
- 573. - addClass(_row, 'current');
- 574. - if (ge('player' + aid)) {
- 575. - if (ge('audio_vol' + aid) && browser.mobile) {
- 576. - hide('audio_vol' + aid);
- 577. - }
- 578. - if (ge('audio_vol_line' + aid)) {
- 579. - setStyle(ge('audio_vol_line' + aid), {width: (playerVol * 100) + '%'});
- 580. - }
- 581. - }
- 582. - var r = ge('repeat' + aid);
- 583. - if (r) {
- 584. - show(r);
- 585. - if (_a.repeat) {
- 586. - addClass(r, 'on');
- 587. - } else {
- 588. - removeClass(r, 'on');
- 589. - }
- 590. - }
- 591. - }
- 592. - var tabCurRow = geByClass1('tab_current', ge('pad_playlist'));
- 593. - if (tabCurRow) {
- 594. - removeClass(tabCurRow, 'tab_current');
- 595. - }
- 596. - if (pad_row) {
- 597. - addClass(ge('play' + aid + '_pad'), 'playing');
- 598. - addClass(pad_row, 'current');
- 599. - }
- 600. - if (head_play) {
- 601. - addClass(head_play, 'playing');
- 602. - }
- 603. - if (gp_play) {
- 604. - addClass(gp_play, 'playing');
- 605. - }
- 606. - var a = window.audioPlaylist && audioPlaylist[aid];
- 607. - if (_a.controls) {
- 608. - for (var i in _a.controls) {
- 609. - var obj = _a.controls[i];
- 610. - if (obj.play) addClass(obj.play, 'playing');
- 611. - if (obj.add && obj.container) {
- 612. - var mid = aid.split('_')[0];
- 613. - toggleClass(obj.container, 'add', mid != vk.id || a && a[9] && intval(a[9]));
- 614. - }
- 615. - }
- 616. - }
- 617. - break;
- 618. - }
- 619. - },
- 620. - stop: function() {
- 621. - var _a = audioPlayer, aid = currentAudioId();
- 622. - if (aid) {
- 623. - if (_a.player && !_a.player.paused()) _a.player.stopAudio();
- 624. - _a.setGraphics('stop');
- 625. - _a.setAid(null);
- 626. - }
- 627. - },
- 628. - pauseTrack: function() {
- 629. - var _a = audioPlayer, aid = currentAudioId();
- 630. - if (aid && _a.player && !_a.player.paused()) {
- 631. - _a.operate(aid);
- 632. - }
- 633. - },
- 634. - playTrack: function() {
- 635. - var _a = audioPlayer, aid = currentAudioId();
- 636. - if (aid && _a.player && _a.player.paused()) {
- 637. - _a.operate(aid);
- 638. - }
- 639. - },
- 640. - setPlaybackParams: function() {
- 641. - var _a = audioPlayer, aid = currentAudioId(), ids = (aid || '').split('_'), __cur = window._pads && _pads.shown == 'mus' && _pads.cur, params = {};
- 642. - if (cur.curSection == 'recommendations' || __cur && __cur.curSection == 'recommendations') {
- 643. - params.recommendation = 1;
- 644. - }
- 645. - if (cur.module == 'search' && nav.objLoc['c[section]'] == 'audio' && !nav.objLoc['c[q]']) {
- 646. - params.top = 1;
- 647. - }
- 648. - if (cur.module == 'audio' && cur.curSection == 'popular' && !cur.searchStr || __cur && __cur.curSection == 'popular' && !__cur.searchStr) {
- 649. - params.top_audio = 1;
- 650. - }
- 651. - if (cur.module == 'audio' && cur.curSection == 'feed' && !cur.searchStr || __cur && __cur.curSection == 'feed' && !__cur.searchStr) {
- 652. - params.feed_audio = 1;
- 653. - }
- 654. - if ((aid + '').match(/^-?\d+_\d+_s(-?\d+)(?:_|$)/) && window.audioPlaylist && audioPlaylist[aid]) {
- 655. - params.status = 1;
- 656. - }
- 657. - if (_a.isAudioFriend(ids[0], aid)) {
- 658. - params.friend = ids[0];
- 659. - }
- 660. - if ((cur.module == 'groups' || cur.module == 'public' || cur.module == 'audio') && cur.oid == ids[0] && cur.oid < 0) {
- 661. - params.group = 1;
- 662. - }
- 663. - if ((cur.module == 'audio' || cur.module == 'feed') && nav.objLoc['q'] || cur.module == 'search' && nav.objLoc['c[q]'] || __cur && __cur.searchStr) {
- 664. - params.search = 1;
- 665. - }
- 666. - if (cur.module == 'audio' && cur.curSection && cur.curSection.substr(0, 5) == 'album' && cur.album_id || __cur && __cur.curSection && __cur.curSection.substr(0, 5) == 'album' && __cur.album_id) {
- 667. - params.album = 1;
- 668. - }
- 669. - if (cur.module == 'audio' && cur.curSection && cur.curSection.substr(0, 5) == 'owner' || __cur && __cur.curSection && __cur.curSection.substr(0, 5) == 'owner') {
- 670. - params.top_bands = 1;
- 671. - }
- 672. - if (cur.module == 'audio' && cur.curSection == 'popular' && cur.genre || __cur && __cur.curSection == 'popular' && __cur.genre) {
- 673. - params.popular_genre = 1;
- 674. - }
- 675. - if (cur.module == 'audio' && cur.club || __cur && __cur.club) {
- 676. - params.club = cur.club;
- 677. - }
- 678. - if (!params.search && cur.module == 'feed' && !__cur) {
- 679. - params.feed = 1;
- 680. - }
- 681. - _a.playbackParams = params;
- 682. - },
- 683. - isAudioFriend: function(oid, full_id) {
- 684. - return (oid != vk.id && cur.allAudiosIndex && cur.allAudiosIndex != 'all' && cur.audioFriend && cur.curSection != 'recommendations' && cur.curSection != 'popular') || ge('audio_playback'+full_id) || (cur.isAudioFriend && cur.curSection != 'recommendations' && cur.allAudiosIndex && cur.allAudiosIndex == 'all');
- 685. - },
- 686. - playbackSent: 0,
- 687. - statusSent: 0,
- 688. - playback: function(paused) {
- 689. - var _a = audioPlayer, aid = currentAudioId(), ids = (aid || '').split('_');
- 690. - if (ids.length < 2 && cur.oid) { // edit mode
- 691. - ids = [cur.oid, aid];
- 692. - aid = ids.join('_');
- 693. - }
- 694. - if (_a.hasStatusExport() && ids[1] != _a.statusSent) {
- 695. - setTimeout(ajax.post.pbind('audio', {act: 'audio_status', full_id: aid, hash: _a.addHash, top: _a.playbackParams && (_a.playbackParams.top_audio || _a.playbackParams.top) ? 1 : ''}), 0);
- 696. - _a.statusSent = ids[1];
- 697. - }
- 698. - clearTimeout(_a.playbackTimer);
- 699. - if (!paused && aid && vk.id) {
- 700. - if (ids[1] != _a.playbackSent) {
- 701. - var sendPlayback = function() {
- 702. - if (!cur.startedAids || !cur.startedAids[aid]) {
- 703. - _a.playbackTimer = setTimeout(sendPlayback, 10000);
- 704. - return;
- 705. - }
- 706. - var query = {act: 'playback', full_id: aid, hash: _a.addHash};
- 707. - if (ids[0] == vk.id && ids[1]) query.id = ids[1];
- 708. - if (_a.playbackParams) extend(query, _a.playbackParams);
- 709. - ajax.post('audio', query, {onDone: function() {
- 710. - _a.playbackSent = ids[1];
- 711. - }});
- 712. - };
- 713. - _a.playbackTimer = setTimeout(sendPlayback, 10000);
- 714. - }
- 715. - }
- 716. - },
- 717. - keyPressed: function(otherTab, e) {
- 718. - e = normEvent(e);
- 719. - if (!e.keyCode) return;
- 720. - var keyCodes = [176, 177, 178, 179, KEY.LEFT, KEY.RIGHT], inArr = false;
- 721. - each(keyCodes, function(k, v){
- 722. - if (e.keyCode == v) {
- 723. - inArr = true;
- 724. - return false;
- 725. - }
- 726. - });
- 727. - if ((e.keyCode == KEY.LEFT || e.keyCode == KEY.RIGHT) && otherTab) return;
- 728. - if (!inArr) return;
- 729. - var cn = window.curNotifier, pData = ls.get('pad_pldata'), anotherTab = cn && pData && cn.instance_id && pData.instance && cn.instance_id !== pData.instance;
- 730. - if (!e.noBroadcast) {
- 731. - if (anotherTab) {
- 732. - var _n = window.Notifier;
- 733. - if (_n) _n.lcSend('audio_mediakey', {keyCode: e.keyCode, noBroadcast: 1});
- 734. - return;
- 735. - }
- 736. - } else {
- 737. - if (anotherTab) return;
- 738. - }
- 739. - var _a = audioPlayer, aid = currentAudioId();
- 740. - if (!aid) return;
- 741. - switch (e.keyCode) {
- 742. - case 179:
- 743. - playAudioNew(aid);
- 744. - break;
- 745. - case 178:
- 746. - _a.stop();
- 747. - audioPlayer.onPlayProgress(0, 1, true);
- 748. - break;
- 749. - case 177:
- 750. - _a.prevTrack();
- 751. - break;
- 752. - case 176:
- 753. - _a.nextTrack();
- 754. - break;
- 755. - case KEY.LEFT:
- 756. - if (_a.canChangePr(e)) {
- 757. - _a.changePr(-1);
- 758. - }
- 759. - break;
- 760. - case KEY.RIGHT:
- 761. - if (_a.canChangePr(e)) {
- 762. - _a.changePr(1);
- 763. - }
- 764. - break;
- 765. - }
- 766. - },
- 767. - canChangePr: function(e) {
- 768. - var chatInput = window.curFastChat && curFastChat.peer && geByClass1('fc_editable', ge('rb_box_fc_peer' + curFastChat.peer)),
- 769. - inp = cur.__focused || chatInput || window._pads && _pads.shown && geByTag1('textarea', _pads.content);
- 770. - return !e.shiftKey && !e.ctrlKey && !e.metaKey && (cur.module == 'audio' || window._pads && _pads.shown == 'mus') && !cur.pvShown && !(window.wkcur || {}).shown && !(window.mvcur || {}).mvShown && !curBox() && !(inp && trim(val(inp)) && !(chatInput && trim(val(inp)) == '<br>'));
- 771. - },
- 772. - changePr: function(delta) {
- 773. - var _a = audioPlayer, aid = currentAudioId();
- 774. - if (!aid) return;
- 775. - _a.time = (_a.curTime || 0) + delta * _a.prStep;
- 776. - if (_a.time < 0) _a.time = 0;
- 777. - if (_a.duration && _a.time > _a.duration) _a.time = _a.duration;
- 778. - try{
- 779. - if (!_a.player.paused()) {
- 780. - _a.player.playAudio(_a.time);
- 781. - }
- 782. - _a.player.callPlayProgress();
- 783. - }catch(e){};
- 784. - },
- 785. - mouseUp: function(e) {
- 786. - var _a = audioPlayer;
- 787. - if (_a.player && _a.player.paused) {
- 788. - if (_a.prClicked) {
- 789. - if (_a.time !== undefined) try{
- 790. - if (!_a.player.paused()) {
- 791. - _a.player.playAudio(_a.time);
- 792. - _a.time = null;
- 793. - }
- 794. - }catch(e){};
- 795. - }
- 796. - _a.player.callPlayProgress();
- 797. - }
- 798. - if (_a.volClicked) {
- 799. - if (_a.controls && _a.controls[_a.volClicked]) {
- 800. - removeClass(_a.controls[_a.volClicked].volumeArea, 'down');
- 801. - }
- 802. - hide('audio_tip_wrap');
- 803. - }
- 804. - if (_a.prClicked && _a.controls && _a.controls[_a.prClicked]) {
- 805. - removeClass(_a.controls[_a.prClicked].progressArea, 'down');
- 806. - }
- 807. - _a.volClicked = null;
- 808. - _a.prClicked = null;
- 809. - },
- 810. - tipOver: function() {
- 811. - if (cur.hideTipTO) {
- 812. - clearTimeout(cur.hideTipTO);
- 813. - }
- 814. - },
- 815. - tipOut: function() {
- 816. - cur.hideTipTO = setTimeout(hide.pbind('audio_tip_wrap'), 100);
- 817. - },
- 818. - showTip: function(text, x, y, fixed, pad) {
- 819. - if (!ge('audio_tip_wrap')) {
- 820. - bodyNode.appendChild(se('<div id="audio_tip_wrap" onmouseover="audioPlayer.tipOver();" onmouseout="audioPlayer.tipOut();"><div id="audio_tip"></div><div id="audio_tip_arrow"></div></div>'));
- 821. - }
- 822. - ge('audio_tip').innerHTML = text;
- 823. - var sz = getSize('audio_tip_wrap'), w = sz[0] || 32, h = sz[1] || 18, l = x - (w + 1) / 2, a = w / 2 - 3;
- 824. - setStyle(ge('audio_tip_wrap'), {left: l, top: y - h - 7, position: fixed ? 'fixed' : 'absolute', zIndex: curBox() ? 1001 : (pad ? 401 : 101)});
- 825. - setStyle(ge('audio_tip_arrow'), {left: a});
- 826. - show('audio_tip_wrap');
- 827. - },
- 828. - mouseMove: function(e) {
- 829. - var _a = audioPlayer;
- 830. - if (_a.volClicked) _a.volClick(e, _a.volClicked);
- 831. - if (_a.prClicked) _a.prClick(e, _a.prClicked);
- 832. - if (!audioPlayer.duration) return;
- 833. -
- 834. - var overFound = false, aid = currentAudioId();
- 835. - if (_a.controls) {
- 836. - for (var i in _a.controls) {
- 837. - var obj = _a.controls[i];
- 838. - if (obj.progressArea && hasClass(obj.progressArea, 'over')) {
- 839. - overFound = true;
- 840. - var time = intval(_a.getPrPos(e, i) * _a.duration / 100), fixed = _a.controls[i].fixed,
- 841. - timeText = _a.formatTime(time);
- 842. - _a.showTip(timeText, _a.defX(e), getXY(obj.progressArea, fixed)[1], fixed, i == 'pd');
- 843. - break;
- 844. - }
- 845. - }
- 846. - }
- 847. - if (!overFound && aid && hasClass(ge('audio_pr' + aid), 'over')) {
- 848. - overFound = true;
- 849. - var time = intval(_a.getPrPos(e, null) * _a.duration / 100), timeText = _a.formatTime(time);
- 850. - _a.showTip(timeText, _a.defX(e), getXY(ge('audio_pr'+aid))[1]);
- 851. - }
- 852. - },
- 853. - defX: function(e) {
- 854. - if (!e) e = window.event;
- 855. - var hscroll = !document.body.scrollLeft && (browser.ipad || browser.iphone4 || browser.ipod4) ? 0 : (document.all ? document.body.scrollLeft : window.pageXOffset);
- 856. - return intval(e.clientX + hscroll);
- 857. - },
- 858. - getPrPos: function(e, objName) {
- 859. - var _a = audioPlayer, el, pos, prSize, val, defX;
- 860. - if (objName && _a.controls && _a.controls[objName]) {
- 861. - el = _a.controls[objName].progressArea, pos = getXY(el,_a.controls[objName].fixed)[0],
- 862. - val = _a.defX(e) - pos, prSize = getSize(el)[0];
- 863. - } else {
- 864. - var aid = currentAudioId();
- 865. - el = ge('audio_back_line' + aid), pos = getXY(el)[0],
- 866. - val = _a.defX(e) - pos, prSize = getSize(el)[0];
- 867. - }
- 868. - val = Math.min(100, Math.max(0, val / prSize * 100));
- 869. - if (vk.rtl) val = 100 - val;
- 870. - return val;
- 871. - },
- 872. - prClick: function(e, objName) {
- 873. - if (!e) e = window.event
- 874. - if (e.button == 2) return;
- 875. - var _a = audioPlayer, aid = currentAudioId();
- 876. - if (objName && _a.controls && _a.controls[objName] && _a.controls[objName].progressArea) {
- 877. - if (!_a.player) return;
- 878. - if (!_a.prClicked) {
- 879. - _a.prClicked = objName;
- 880. - addClass(_a.controls[objName].progressArea, 'down');
- 881. - }
- 882. - } else {
- 883. - if (!_a.prClicked) {
- 884. - _a.prClicked = true;
- 885. - }
- 886. - }
- 887. - var val = _a.getPrPos(e, objName);
- 888. - _a.time = val / 100 * _a.duration;
- 889. - if (_a.controls) {
- 890. - for (var i in _a.controls) {
- 891. - var obj = _a.controls[i];
- 892. - if (obj.progress) {
- 893. - setStyle(obj.progress, {width: val + '%'});
- 894. - }
- 895. - }
- 896. - }
- 897. - if (aid && ge('player' + aid)) {
- 898. - setStyle(ge('audio_pr_line' + aid), {width: val + '%'});
- 899. - }
- 900. - cancelEvent(e);
- 901. - },
- 902. - volClick: function(e, objName) {
- 903. - if (!e) e = window.event
- 904. - if (e.button == 2) return;
- 905. - var _a = audioPlayer, el, xy, val, pos, aid = currentAudioId();
- 906. - if (objName && _a.controls && _a.controls[objName] && _a.controls[objName].volumeArea) {
- 907. - var obj = _a.controls[objName], fixed = _a.controls[objName].fixed;
- 908. - el = obj.volumeArea, pos = getXY(el, fixed), val = _a.defX(e) - pos[0];
- 909. - var volSize = getSize(el)[0], val = val / volSize * 100;
- 910. - val = Math.min(100, Math.max(0, val));
- 911. - if (vk.rtl) val = 100 - val;
- 912. - if (!_a.volClicked) {
- 913. - _a.volClicked = objName;
- 914. - addClass(obj.volumeArea, 'down');
- 915. - }
- 916. - var tipX = Math.min(pos[0] + volSize, Math.max(pos[0], _a.defX(e)));
- 917. - _a.showTip(intval(val) + '%', tipX, pos[1], fixed, objName == 'pd');
- 918. - } else {
- 919. - el = ge('audio_vol_back_line' + aid), pos = getXY(el), val = _a.defX(e) - pos[0];
- 920. - var volSize = getSize(el)[0], val = val / volSize * 100;
- 921. - val = Math.min(100, Math.max(0, val));
- 922. - if (vk.rtl) val = 100 - val;
- 923. - if (!_a.volClicked) {
- 924. - _a.volClicked = true;
- 925. - }
- 926. - var tipX = Math.min(pos[0] + volSize, Math.max(pos[0], _a.defX(e)));
- 927. - _a.showTip(intval(val) + '%', tipX, pos[1]);
- 928. - }
- 929. - if (_a.controls) {
- 930. - for (var i in _a.controls) {
- 931. - var obj = _a.controls[i];
- 932. - if (obj.volume) {
- 933. - setStyle(obj.volume, {width: val + '%'});
- 934. - }
- 935. - }
- 936. - }
- 937. - if (aid && ge('player' + aid)) {
- 938. - setStyle(ge('audio_vol_line' + aid), {width: val + '%'});
- 939. - }
- 940. - if (_a.player) _a.player.setVolume(val / 100);
- 941. - setCookie('audio_vol', Math.round(val), 365);
- 942. - cancelEvent(e);
- 943. - },
- 944. - toggleRepeat: function() {
- 945. - var _a = audioPlayer, aid = currentAudioId();
- 946. - if (!aid && _a.lastSong) {
- 947. - aid = _a.lastSong.aid;
- 948. - }
- 949. - _a.repeat = !_a.repeat;
- 950. - if (_a.controls) {
- 951. - for (var i in _a.controls) {
- 952. - var obj = _a.controls[i];
- 953. - if (obj.repeat) {
- 954. - toggleClass(obj.repeat, 'on', _a.repeat);
- 955. - }
- 956. - }
- 957. - }
- 958. - if (!aid) return;
- 959. - var r = ge('repeat' + aid);
- 960. - if (r) {
- 961. - toggleClass(r, 'on', _a.repeat);
- 962. - }
- 963. - },
- 964. - showRec: function(aid, fromPad) {
- 965. - var _a = audioPlayer;
- 966. - aid = aid || currentAudioId() || _a.lastSong && _a.lastSong.aid || cur.defaultTrack && cur.defaultTrack.id || window.audioPlaylist && audioPlaylist.start || '';
- 967. - if (!aid) return;
- 968. - // if (fromPad) {
- 969. - // _a.loadTrackRecommendations(aid);
- 970. - // } else if (window.Audio) {
- 971. - Audio.loadRecommendations({from_pad: fromPad, update: true, audioId: aid});
- 972. - // }
- 973. - },
- 974. - updateStatusChecks: function(cont) {
- 975. - var _a = audioPlayer, chks = geByClass('checkbox', cont);
- 976. - each(chks, function() {
- 977. - checkbox(this, false);
- 978. - });
- 979. - if (_a.statusExport) {
- 980. - for (var i in _a.statusExport) {
- 981. - checkbox(geByClass1('status' + i, cont), true);
- 982. - }
- 983. - }
- 984. - },
- 985. - updateAllStatusChecks: function() {
- 986. - var _a = audioPlayer;
- 987. - for (var i in _a.controls) {
- 988. - var obj = _a.controls[i];
- 989. - if (obj.status && obj.status.tt) {
- 990. - _a.updateStatusChecks(obj.status.tt.container);
- 991. - }
- 992. - }
- 993. - },
- 994. - toggleStatus: function(oid) {
- 995. - var _a = audioPlayer, aid = currentAudioId(), exp, oid = intval(oid);
- 996. - _a.statusExport = _a.statusExport || {};
- 997. - if (!oid) {
- 998. - if (_a.hasStatusExport()) {
- 999. - for (var i in _a.statusExport) {
- 1000. - delete _a.statusExport[i];
- 1001. - _a.updateAllStatusChecks();
- 1002. - }
- 1003. - exp = false;
- 1004. - } else {
- 1005. - oid = vk.id;
- 1006. - _a.statusExport[oid] = 1;
- 1007. - _a.updateAllStatusChecks();
- 1008. - exp = true;
- 1009. - }
- 1010. - } else {
- 1011. - if (_a.statusExport[oid]) {
- 1012. - delete _a.statusExport[oid];
- 1013. - exp = false
- 1014. - } else {
- 1015. - _a.statusExport[oid] = 1;
- 1016. - exp = true;
- 1017. - }
- 1018. - }
- 1019. - if (!_a.addHash) return;
- 1020. - if (oid == vk.id || !oid) checkbox('currinfo_audio', _a.hasStatusExport());
- 1021. - if (_a.controls) {
- 1022. - for (var i in _a.controls) {
- 1023. - var obj = _a.controls[i];
- 1024. - if (obj.status) {
- 1025. - toggleClass(obj.status, 'on', _a.hasStatusExport());
- 1026. - }
- 1027. - }
- 1028. - }
- 1029. - ajax.post('audio', {act: 'toggle_status', exp: (exp ? 1 : ''), oid: oid, hash: _a.addHash, id: aid, top: _a.playbackParams && (_a.playbackParams.top_audio || _a.playbackParams.top) ? 1 : ''});
- 1030. - if (window._pads && _pads.cache) {
- 1031. - delete _pads.cache.mus;
- 1032. - }
- 1033. - },
- 1034. - setControlsTitle: function() {
- 1035. - var _a = audioPlayer;
- 1036. - if (_a.controls) {
- 1037. - for (var i in _a.controls) {
- 1038. - var obj = _a.controls[i], songInfo = obj.padPlaylist && _a.isPlaylistGlobal() ? ls.get('pad_lastsong') || _a.lastSong : _a.lastSong;
- 1039. - if (obj.performer) {
- 1040. - obj.performer.innerHTML = clean(replaceEntities(songInfo[5]));
- 1041. - }
- 1042. - if (obj.title) {
- 1043. - obj.title.innerHTML = clean(replaceEntities(songInfo[6]));
- 1044. - }
- 1045. - if (obj.titleWrap) {
- 1046. - if (obj.titleWrap.scrollWidth > obj.titleWrap.clientWidth) {
- 1047. - var el = ce('div', {innerHTML: clean(replaceEntities(songInfo[5])) + ' – ' + clean(replaceEntities(songInfo[6])) });
- 1048. - obj.titleWrap.title = el.innerText || el.textContent;
- 1049. - } else {
- 1050. - obj.titleWrap.removeAttribute('title');
- 1051. - }
- 1052. - }
- 1053. - if (obj.duration) {
- 1054. - obj.duration.innerHTML = _a.timeLeft ? songInfo[4] : '0:00';
- 1055. - }
- 1056. - if (obj.add) {
- 1057. - var aid = currentAudioId(), cur_aids = aid && aid.split('_') || [], raw_id = aid && cur_aids[0] + '_' + cur_aids[1] || null;
- 1058. - toggleClass(obj.add, 'added', !!(raw_id && cur.addedIds && cur.addedIds[raw_id]));
- 1059. - }
- 1060. - }
- 1061. - }
- 1062. - if (ge('gp')) _a.loadGlobal();
- 1063. - },
- 1064. - loadGlobal: function() {
- 1065. - var l, _a = audioPlayer, aid = currentAudioId(), cl = aid && _a.player && !_a.player.paused() || !aid && _a.lastSong ? 'playing' : '';
- 1066. - ge('gp_play_btn').innerHTML = '<a onmousedown="cancelEvent(event)" onclick="playAudioNew(\'' + aid + '\', false)"><div class="gp_play_wrap"><div id="gp_play" class="' + cl + '"></div></div></a>';
- 1067. - var art, title;
- 1068. - art = clean(replaceEntities(_a.lastSong[5]));
- 1069. - title = clean(replaceEntities(_a.lastSong[6]));
- 1070. - ge('gp_performer').innerHTML = art;
- 1071. - ge('gp_title').innerHTML = title;
- 1072. - updGlobalPlayer();
- 1073. - },
- 1074. - onError: function(error_msg) {
- 1075. - var _a = audioPlayer, aid = currentAudioId();
- 1076. - if (aid) _a.reloadAudio(aid);
- 1077. - _a.reloadPlaylist();
- 1078. - },
- 1079. - onLoadComplete: function(len) {
- 1080. - if (len) audioPlayer.duration = len;
- 1081. - },
- 1082. - onPlayFinish: function() {
- 1083. - var _a = audioPlayer;
- 1084. - _a.playbackSent = _a.statusSent = 0;
- 1085. - var next_id, cur_id = currentAudioId(), m = (cur_id + '').match(/^-?\d+_\d+_s(-?\d+)(?:_|$)/);
- 1086. - if (cur.startedAids) delete cur.startedAids[cur_id];
- 1087. - if (_a.repeat) {
- 1088. - next_id = cur_id;
- 1089. - } else if (m && window.audioPlaylist && audioPlaylist[cur_id]) {
- 1090. - next_id = audioPlaylist[cur_id]['_next'];
- 1091. - if (!next_id) {
- 1092. - ajax.post('audio', {act: 'get_audio_status', oid: m[1]}, {
- 1093. - onDone: function(id, info) {
- 1094. - if (!info) return;
- 1095. -
- 1096. - if (cur_id !== id) {
- 1097. - info['_prev'] = cur_id;
- 1098. - audioPlaylist[cur_id]['_next'] = id;
- 1099. - audioPlaylist[id] = info;
- 1100. - audioPlaylist.start = id;
- 1101. - _a.setPadPlaylist(window.audioPlaylist);
- 1102. - }
- 1103. - if (!currentAudioId()) {
- 1104. - _a.operate(id);
- 1105. - }
- 1106. - }
- 1107. - });
- 1108. - }
- 1109. - } else {
- 1110. - var pList = _a.isPlaylistGlobal() ? ls.get('pad_playlist') || window.audioPlaylist : padAudioPlaylist();
- 1111. - next_id = (pList && pList[cur_id] && pList[cur_id]['_next']) ? pList[cur_id]['_next'] : _a.getNextSibling();
- 1112. - }
- 1113. - _a.stop();
- 1114. - if (next_id && (_a.repeat || cur_id != next_id)) {
- 1115. - _a.operate(next_id);
- 1116. - if (window._pads && _pads.shown == 'mus' && window.Pads && Pads.setAudioCurPos) {
- 1117. - Pads.setAudioCurPos(400);
- 1118. - return;
- 1119. - }
- 1120. - }
- 1121. - },
- 1122. - scrollToTrack: function(nid) {
- 1123. - var w = window, de = document.documentElement, play_btn = ge('play'+nid);
- 1124. - if (window._pads && _pads.shown == 'mus' && window.Pads && Pads.setAudioCurPos) {
- 1125. - Pads.setAudioCurPos(400);
- 1126. - return;
- 1127. - }
- 1128. - if (!w.pageNode || !play_btn || cur.module == 'im') return;
- 1129. - var xy = getXY(play_btn);
- 1130. - var dheight = Math.max(intval(w.innerHeight), intval(de.clientHeight));
- 1131. - var height = Math.max(0, xy[1] - (dheight - 16) / 2);
- 1132. - scrollToY(height, 400);
- 1133. - },
- 1134. - nextTrack: function(no_scroll, fromPad) {
- 1135. - var nid, _a = audioPlayer
- 1136. - fromPad = fromPad && _a.isPlaylistGlobal();
- 1137. - var aid = fromPad ? ls.get('audio_id') || currentAudioId() : currentAudioId(), pList = fromPad ? ls.get('pad_playlist') || window.audioPlaylist : window.audioPlaylist;
- 1138. - nid = (pList && pList[aid]) ? pList[aid]['_next'] : _a.getNextSibling();
- 1139. - if (nid) {
- 1140. - _a.stop();
- 1141. - if (fromPad) {
- 1142. - window.padPlClicked = true;
- 1143. - }
- 1144. - _a.operate(nid);
- 1145. - if (!no_scroll) _a.scrollToTrack(nid);
- 1146. - }
- 1147. - },
- 1148. - prevTrack: function(no_scroll, fromPad) {
- 1149. - var nid, _a = audioPlayer
- 1150. - fromPad = fromPad && _a.isPlaylistGlobal();
- 1151. - var aid = fromPad ? ls.get('audio_id') || currentAudioId() : currentAudioId(), pList = fromPad ? ls.get('pad_playlist') || window.audioPlaylist : window.audioPlaylist;
- 1152. - pid = (pList && pList[aid]) ? pList[aid]['_prev'] : _a.getPrevSibling();
- 1153. - if (pid) {
- 1154. - _a.stop();
- 1155. - if (fromPad) {
- 1156. - window.padPlClicked = true;
- 1157. - }
- 1158. - _a.operate(pid);
- 1159. - if (!no_scroll) _a.scrollToTrack(pid);
- 1160. - }
- 1161. - },
- 1162. - getNextSibling: function(aid) {
- 1163. - var getAId = function(el){return el && el.id && el.id.substr(0, 5) == 'audio' && parseInt(el.id.substr(5)) ? el.id.substr(5) : 0; }
- 1164. - if (!aid) aid = currentAudioId();
- 1165. - var cur = ge('audio' + aid);
- 1166. - if (!cur) return null;
- 1167. - var aid = 0;
- 1168. - for (var el = cur.nextSibling; el; el = el.nextSibling) {
- 1169. - if (aid = getAId(el)) return aid;
- 1170. - if (isVisible(el) && (aid = getAId(el.firstChild))) return aid;
- 1171. - }
- 1172. - var p = cur.parentNode.nextSibling;
- 1173. - while (p && p.nodeType != 1 && p.nextSibling) p = p.nextSibling;
- 1174. - if (p && p.nodeType == 1) {
- 1175. - var el = geByClass1('audio', p);
- 1176. - if (aid = getAId(el)) return aid;
- 1177. - }
- 1178. - for (p = cur.parentNode.parentNode.firstChild; p; p = p.nextSibling) {
- 1179. - if (p && p.nodeType == 1 && p != cur.parentNode) {
- 1180. - var el = geByClass1('audio', p);
- 1181. - if (aid = getAId(el)) return aid;
- 1182. - }
- 1183. - }
- 1184. - for (var el = cur.parentNode.firstChild; el; el = el.nextSibling) {
- 1185. - if (aid = getAId(el)) return aid;
- 1186. - }
- 1187. - },
- 1188. - getPrevSibling: function(aid) {
- 1189. - var getAId = function(el){return el && el.id && el.id.substr(0, 5) == 'audio' && parseInt(el.id.substr(5)) ? el.id.substr(5) : 0; }
- 1190. - if (!aid) aid = currentAudioId();
- 1191. - var cur = ge('audio' + aid);
- 1192. - if (!cur) return null;
- 1193. - var aid = 0;
- 1194. - for (var el = cur.previousSibling; el; el = el.previousSibling) {
- 1195. - if (aid = getAId(el)) return aid;
- 1196. - if (isVisible(el) && (aid = getAId(el.firstChild))) return aid;
- 1197. - }
- 1198. - var p = cur.parentNode.previousSibling;
- 1199. - while (p && p.nodeType != 1 && p.previousSibling) p = p.previousSibling;
- 1200. - if (p && p.nodeType == 1) {
- 1201. - var el = geByClass1('audio', p);
- 1202. - if (aid = getAId(el)) return aid;
- 1203. - }
- 1204. - for (p = cur.parentNode.parentNode.lastChild; p; p = p.previousSibling) {
- 1205. - if (p && p.nodeType == 1 && p != cur.parentNode) {
- 1206. - var el = geByClass1('audio', p);
- 1207. - if (aid = getAId(el)) return aid;
- 1208. - }
- 1209. - }
- 1210. - for (var el = cur.parentNode.lastChild; el; el = el.previousSibling) {
- 1211. - if (aid = getAId(el)) return aid;
- 1212. - }
- 1213. - },
- 1214. -
- 1215. - genPlaylist: function(list, copyToMain, opts) {
- 1216. - opts = opts || {};
- 1217. - var res = [];
- 1218. - if (!list || !list.length) return;
- 1219. - for (var i in list) {
- 1220. - if (list[i][11] && parseInt(list[i][11])) {
- 1221. - continue;
- 1222. - }
- 1223. - res.push(list[i]);
- 1224. - }
- 1225. - if (!res.length) return;
- 1226. - if (res[0]._order !== undefined) {
- 1227. - res = res.sort(function(a,b) {return a._order - b._order});
- 1228. - }
- 1229. - cur.nextPlaylist = {};
- 1230. - for (var i in res) {
- 1231. - i = parseInt(i);
- 1232. - var a = extend({}, res[i]);
- 1233. - var aid = a.full_id || a[0]+'_'+a[1];
- 1234. - cur.nextPlaylist[aid] = clone(a);
- 1235. - if (i > 0) cur.nextPlaylist[aid]['_prev'] = res[i-1].full_id || res[i-1][0]+'_'+res[i-1][1];
- 1236. - if (i < res.length - 1) cur.nextPlaylist[aid]['_next'] = res[i+1].full_id || res[i+1][0]+'_'+res[i+1][1];
- 1237. - }
- 1238. - var firstId = res[0].full_id || res[0][0]+'_'+res[0][1],
- 1239. - lastId = res[res.length-1].full_id || res[res.length-1][0]+'_'+res[res.length-1][1];
- 1240. - cur.nextPlaylist[firstId]['_prev'] = lastId;
- 1241. - cur.nextPlaylist[lastId]['_next'] = firstId;
- 1242. - cur.nextPlaylist.start = firstId;
- 1243. - cur.nextPlaylist.length = res.length;
- 1244. - cur.nextPlaylist.instance = cur.nextPlaylist.source = window.curNotifier && curNotifier.instance_id || '';
- 1245. - cur.nextPlaylist.address = nav.strLoc;
- 1246. - if (opts.my) {
- 1247. - cur.nextPlaylist.my = opts.my;
- 1248. - }
- 1249. - if (opts.has_more) {
- 1250. - cur.nextPlaylist.has_more = opts.has_more;
- 1251. - }
- 1252. - if (opts.htitle) {
- 1253. - cur.nextPlaylist.htitle = opts.htitle;
- 1254. - }
- 1255. - var aid = currentAudioId();
- 1256. - if (copyToMain || cur.justShuffled && aid && cur.nextPlaylist[aid]) {
- 1257. - window.audioPlaylist = clone(cur.nextPlaylist);
- 1258. - if (window.curNotifier && (padPlData = ls.get('pad_pldata')) && padPlData.instance == curNotifier.instance_id) {
- 1259. - this.setPadPlaylist(window.audioPlaylist);
- 1260. - }
- 1261. - }
- 1262. - },
- 1263. -
- 1264. - isPlaylistGlobal: function() {
- 1265. - var padPlData;
- 1266. - return (!window.audioPlaylist || window.curNotifier && (padPlData = ls.get('pad_pldata')) && padPlData.source == curNotifier.instance_id);
- 1267. - },
- 1268. -
- 1269. - setPadPlaylist: function(pList) {
- 1270. - if (pList) {
- 1271. - if (!pList.htitle) {
- 1272. - var htitle = window._pads && _pads.cur && (_pads.cur.lastHTitle || _pads.cur.htitle) || cur.module == 'audio' && (cur.lastHTitle || cur.htitle) || '';
- 1273. - pList.htitle = htitle ? getLang('audio_current_playing_from').replace('{playlist}', htitle) : '';
- 1274. - if (cur.nextPlaylist && !cur.nextPlaylist.htitle && cur.nextPlaylist.source == pList.source && cur.nextPlaylist.start == pList.start && cur.nextPlaylist.length == pList.length) {
- 1275. - cur.nextPlaylist.htitle = audioPlaylist.htitle;
- 1276. - }
- 1277. - }
- 1278. - ls.set('pad_playlist', pList);
- 1279. - ls.set('pad_pltime', vkNow());
- 1280. - if (!pList.instance && !pList.source && window.curNotifier && curNotifier.instance_id) {
- 1281. - pList.instance = pList.source = curNotifier.instance_id;
- 1282. - }
- 1283. - if (pList.instance && pList.source) {
- 1284. - this.setPadPlData({instance: pList.instance, source: pList.source});
- 1285. - } else {
- 1286. - this.setPadPlData();
- 1287. - }
- 1288. - } else {
- 1289. - ls.remove('pad_playlist');
- 1290. - ls.remove('pad_pltime');
- 1291. - }
- 1292. - },
- 1293. -
- 1294. - setPadPlData: function(obj) {
- 1295. - if (obj) {
- 1296. - ls.set('pad_pldata', obj);
- 1297. - } else {
- 1298. - ls.remove('pad_pldata');
- 1299. - }
- 1300. - },
- 1301. -
- 1302. - updateCurrentPlaylist: function(obj, aid) {
- 1303. - var _a = audioPlayer;
- 1304. - if (obj && obj.all && window.audioPlaylist && audioPlaylist[aid]) {
- 1305. - var found = false, audio_id = aid.split('_')[1], curId = aid, fullIds = {};
- 1306. - do {
- 1307. - var curAudioId = curId.split('_')[1];
- 1308. - fullIds[curAudioId] = curId;
- 1309. - curId = audioPlaylist[curId]._next;
- 1310. - } while (curId && curId != aid);
- 1311. - for (var i in obj.all) {
- 1312. - if (obj.all[i][1] == audio_id) {
- 1313. - found = true;
- 1314. - }
- 1315. - if (fullIds[obj.all[i][1]] && !obj.all[i].full_id) {
- 1316. - obj.all[i].full_id = fullIds[obj.all[i][1]];
- 1317. - }
- 1318. - }
- 1319. - if (found) {
- 1320. - _a.genPlaylist(obj.all, true);
- 1321. - }
- 1322. - }
- 1323. - },
- 1324. -
- 1325. - createDynamicPlaylist: function(aid, copyToMain, limit) {
- 1326. - var _a = audioPlayer;
- 1327. - if (!aid) return;
- 1328. - var nextId = startId = aid, el = ge('audio' + aid), dynPl = [_a.getSongInfoFromDOM(startId)], k = 1;
- 1329. - if (!limit) limit = 200;
- 1330. - while (nextId = _a.getNextSibling(nextId)) {
- 1331. - if (nextId == startId || k++ >= limit) break;
- 1332. - var info = _a.getSongInfoFromDOM(nextId);
- 1333. - if (info[2]) {
- 1334. - dynPl.push(info);
- 1335. - }
- 1336. - }
- 1337. - _a.genPlaylist(dynPl, copyToMain);
- 1338. - if (hasClass(el.parentNode, 'module_body')) {
- 1339. - ajax.post('/audio', {act: 'get_playlist', oid: cur.oid}, {
- 1340. - onDone: function(res) {
- 1341. - var obj = eval('(' + res + ')');
- 1342. - _a.updateCurrentPlaylist(obj, aid);
- 1343. - }
- 1344. - })
- 1345. - } else if (dynPl.length < 2 && vk.id && (cur.module == 'groups' || cur.module == 'public' || cur.module == 'profile' || cur.module == 'feed' || cur.module == 'wall')) {
- 1346. - var ids = aid.split('_'), local_id = ids && ids[3] || '';
- 1347. - if (local_id && ge('post'+ids[2]+'_'+ids[3])) {
- 1348. - var wallType = cur.wallType;
- 1349. - if (wallType == 'full_own') wallType = 'own';
- 1350. - if (wallType == 'full_all') wallType = 'all';
- 1351. - if (wallType != 'own' && wallType != 'all') {
- 1352. - wallType = 'own';
- 1353. - }
- 1354. - var params = {act: 'get_wall_playlist', oid: ids[2], wall_type: wallType, local_id: local_id};
- 1355. - if (cur.module == 'wall' && ge('wall_search') && ge('wall_search').value) {
- 1356. - params.q = ge('wall_search').value;
- 1357. - }
- 1358. - ajax.post('/audio', params, {
- 1359. - onDone: function(obj) {
- 1360. - if (obj && obj.all && obj.all.length) {
- 1361. - _a.updateCurrentPlaylist(obj, aid);
- 1362. - }
- 1363. - }
- 1364. - });
- 1365. - }
- 1366. - }
- 1367. - },
- 1368. - showCurrentTrack: function() {
- 1369. - each(geByClass('current'), function() {
- 1370. - if (hasClass(this, 'audio')) {
- 1371. - removeClass(this, 'current');
- 1372. - var btn = geByClass1('play_new', this);
- 1373. - if (btn) removeClass(btn, 'playing');
- 1374. - }
- 1375. - })
- 1376. - var _a = audioPlayer, aid = currentAudioId(), pad_aid = pad_aid_raw = ls.get('audio_id') || aid, cur_aids = aid && aid.split('_') || [], raw_id = aid && cur_aids[0] + '_' + cur_aids[1] || null;
- 1377. - if (aid && _a.player) {
- 1378. - _a.setGraphics('load');
- 1379. - if (_a.player.paused()) {
- 1380. - _a.setGraphics('pause');
- 1381. - } else {
- 1382. - _a.setGraphics('play');
- 1383. - }
- 1384. - _a.setControlsTitle();
- 1385. - _a.player.callPlayProgress();
- 1386. - if (_a.player.callLoadProgress) _a.player.callLoadProgress();
- 1387. - if (aid.substr(-4) !== '_pad' && ge('audio' + aid)) {
- 1388. - addClass('audio' + aid, 'current');
- 1389. - }
- 1390. - if (pad_aid.substr(-4) !== '_pad') {
- 1391. - pad_aid += '_pad';
- 1392. - }
- 1393. - if (ge('audio' + pad_aid) && _a.isPlaylistGlobal()) {
- 1394. - var padClass = (window.curNotifier && (padPlData = ls.get('pad_pldata')) && padPlData.instance == curNotifier.instance_id) ? 'current' : 'tab_current';
- 1395. - addClass('audio' + pad_aid, padClass);
- 1396. - if (padClass == 'tab_current') {
- 1397. - var curRow = geByClass1('current', ge('pad_playlist'));
- 1398. - if (curRow) {
- 1399. - removeClass(curRow, 'current');
- 1400. - }
- 1401. - }
- 1402. - }
- 1403. - }
- 1404. - if (_a.controls) {
- 1405. - for (var i in _a.controls) {
- 1406. - var obj = _a.controls[i];
- 1407. - if (obj.repeat) toggleClass(obj.repeat, 'on', !!_a.repeat);
- 1408. - if (obj.status) toggleClass(obj.status, 'on', !!_a.hasStatusExport());
- 1409. - if (obj.shuffle) toggleClass(obj.shuffle, 'on', !!_a.shuffle);
- 1410. - if (obj.add) toggleClass(obj.add, 'added', !!(raw_id && cur.addedIds && cur.addedIds[raw_id]));
- 1411. - }
- 1412. - }
- 1413. - },
- 1414. - hideCurrentTrack: function() {
- 1415. - var audios = geByClass('audio'), playBtns = geByClass('play_new');
- 1416. - each(audios, function() {
- 1417. - if (hasClass(this, 'current')) {
- 1418. - removeClass(this, 'current');
- 1419. - }
- 1420. - });
- 1421. - each(playBtns, function() {
- 1422. - if (hasClass(this, 'playing')) {
- 1423. - removeClass(this, 'playing');
- 1424. - }
- 1425. - });
- 1426. - },
- 1427. - formatTime: function(t) {
- 1428. - var res, sec, min, hour;
- 1429. - t = Math.max(t, 0);
- 1430. - sec = t % 60;
- 1431. - res = (sec < 10) ? '0'+sec : sec;
- 1432. - t = Math.floor(t / 60);
- 1433. - min = t % 60;
- 1434. - res = min+':'+res;
- 1435. - t = Math.floor(t / 60);
- 1436. - if (t > 0) {
- 1437. - if (min < 10) res = '0' + res;
- 1438. - res = t+':'+res;
- 1439. - }
- 1440. - return res;
- 1441. - },
- 1442. - setCurTime: function(cur, len) {
- 1443. - var _a = audioPlayer, aid = currentAudioId();
- 1444. - var t = _a.timeLeft ? len - cur : cur, res = _a.formatTime(t);
- 1445. - _a.curTime = cur;
- 1446. - if (_a.timeLeft) res = vk.rtl ? res+'-' : '-'+res;
- 1447. - if (_a.controls) {
- 1448. - for (var i in _a.controls) {
- 1449. - var obj = _a.controls[i];
- 1450. - if (obj.duration) obj.duration.innerHTML = res;
- 1451. - }
- 1452. - }
- 1453. - var dur = ge('audio' + aid) && geByClass1('duration', ge('audio' + aid));
- 1454. - if (dur && res) dur.innerHTML = res;
- 1455. - },
- 1456. - switchTimeFormat: function(id, event) {
- 1457. - var _a = audioPlayer, aid = currentAudioId();
- 1458. - if (aid && id) {
- 1459. - var aids = aid.split('_'), ids = id.split('_');
- 1460. - if (aids[0] != ids[0] || aids[1] != ids[1]) return false;
- 1461. - }
- 1462. - _a.timeLeft = (_a.timeLeft + 1) % 2;
- 1463. - if (_a.player) {
- 1464. - _a.player.callPlayProgress();
- 1465. - }
- 1466. - setCookie('audio_time_left', _a.timeLeft);
- 1467. - cancelEvent(event);
- 1468. - },
- 1469. - onLoadProgress: function(bLoaded, bTotal) {
- 1470. - var _a = audioPlayer, aid = currentAudioId();
- 1471. - if (isNaN(bTotal) && _a.player.onCanPlay) bTotal = _a.duration;
- 1472. - var per = Math.ceil(bLoaded/bTotal*100);
- 1473. - per = Math.min(100, Math.max(0, per));
- 1474. - if (_a.controls) {
- 1475. - for (var i in _a.controls) {
- 1476. - var obj = _a.controls[i];
- 1477. - if (obj.load) setStyle(obj.load, {width: per + '%'});
- 1478. - }
- 1479. - }
- 1480. - if (ge('player' + aid)) {
- 1481. - setStyle(ge('audio_load_line' + aid), {width: per + '%'});
- 1482. - }
- 1483. - },
- 1484. - onPlayProgress: function(pos, len, force) {
- 1485. - var barSize, _a = audioPlayer, aid = currentAudioId();
- 1486. - if (Math.abs(len - _a.duration) > 1 || isNaN(len)) len = _a.duration;
- 1487. - if (pos > 1) {
- 1488. - cur.startedAids = cur.startedAids || {};
- 1489. - cur.startedAids[aid] = 1;
- 1490. - }
- 1491. - if (_a.time && _a.player.paused()) pos = _a.time;
- 1492. - _a.setCurTime(Math.round(pos), Math.round(len));
- 1493. - if (_a.player.paused() && !force) return;
- 1494. - var per = pos / len * 100;
- 1495. - per = Math.min(100, Math.max(0, per));
- 1496. - if (!_a.prClicked) {
- 1497. - if (_a.controls) {
- 1498. - for (var i in _a.controls) {
- 1499. - var obj = _a.controls[i];
- 1500. - if (obj.progress) {
- 1501. - setStyle(obj.progress, {width: per + '%'});
- 1502. - }
- 1503. - }
- 1504. - }
- 1505. - if (ge('player' + aid)) {
- 1506. - setStyle(ge('audio_pr_line' + aid), {width: per + '%'});
- 1507. - }
- 1508. - }
- 1509. - },
- 1510. - showCurrentAdded: function() {
- 1511. - var _a = audioPlayer;
- 1512. - if (_a.controls) {
- 1513. - for (var i in _a.controls) {
- 1514. - var obj = _a.controls[i];
- 1515. - if (obj.add) {
- 1516. - addClass(obj.add, 'added');
- 1517. - if (obj.add.tt) {
- 1518. - obj.add.tt.hide();
- 1519. - }
- 1520. - }
- 1521. - }
- 1522. - }
- 1523. - },
- 1524. - addCurrentTrack: function() {
- 1525. - if (cur.addingAudio) return false;
- 1526. - var _a = audioPlayer, aid = currentAudioId();
- 1527. - if (!aid && _a.lastSong) {
- 1528. - aid = _a.lastSong.aid;
- 1529. - }
- 1530. - if (aid && _a.addHash) {
- 1531. - var ids = aid.split('_');
- 1532. - if (ids.length == 1) {
- 1533. - ids[1] = ids[0];
- 1534. - ids[0] = vk.id;
- 1535. - }
- 1536. - var raw_id = ids[0] + '_' + ids[1];
- 1537. - if (cur.addedIds && cur.addedIds[raw_id]) return false;
- 1538. - if (ids && ids[0] && ids[1]) {
- 1539. - var query = {act: 'add', oid: ids[0], aid: ids[1], hash: _a.addHash};
- 1540. - if (_a.top) query.top = 1;
- 1541. - cur.addingAudio = true;
- 1542. - ajax.post('audio', query, {
- 1543. - onDone: function (data, res, text) {
- 1544. - if (data && window.Audio) {
- 1545. - var aobj = eval('('+data+')'), all_list;
- 1546. - aobj = aobj['all'][0];
- 1547. - setTimeout(function(){
- 1548. - if (cur.id == vk.id && cur.audiosIndex && cur.audiosList && cur.audiosList['all'] && cur.aSearch) {
- 1549. - all_list = cur.audiosList['all'];
- 1550. - if (all_list && all_list.length) {
- 1551. - aobj._order = all_list[0]._order - 1;
- 1552. - cur.audiosList['all'].splice(0,0,aobj);
- 1553. - } else {
- 1554. - aobj._order = 0;
- 1555. - cur.audiosList['all'] = [aobj];
- 1556. - }
- 1557. - cur.audios[aobj[1]] = aobj;
- 1558. - cur.audiosIndex.add(aobj);
- 1559. - }
- 1560. - if (window._pads && _pads.cur && _pads.cur.audiosIndex && _pads.cur.audiosList) {
- 1561. - all_list = _pads.cur.audiosList['all'];
- 1562. - if (all_list && all_list.length) {
- 1563. - aobj._order = all_list[0]._order - 1;
- 1564. - _pads.cur.audiosList['all'].splice(0,0,aobj);
- 1565. - } else {
- 1566. - aobj._order = 0;
- 1567. - _pads.cur.audiosList['all'] = [aobj];
- 1568. - }
- 1569. - if (_pads.cur.audios) {
- 1570. - _pads.cur.audios[aobj[1]] = aobj;
- 1571. - }
- 1572. - if (_pads.cur.allAudiosIndex == 'all') {
- 1573. - _pads.cur.audiosIndex.add(aobj);
- 1574. - }
- 1575. - }
- 1576. - if (window.Pads && Pads.clearAudioLoadCache) {
- 1577. - Pads.clearAudioLoadCache();
- 1578. - }
- 1579. - }, 0);
- 1580. - }
- 1581. - if (!cur.addedIds) cur.addedIds = {};
- 1582. - cur.addedIds[raw_id] = 1;
- 1583. - showDoneBox(text, {out: 2000});
- 1584. - cur.addingAudio = false;
- 1585. - _a.showCurrentAdded();
- 1586. - each([raw_id, raw_id + '_pad', aid, aid + '_pad'], function() {
- 1587. - var Actions = window.Audio || window.searchActions || {},
- 1588. - addEl = ge('audio' + this) && geByClass1('audio_add_wrap', ge('audio' + this));
- 1589. - if (Actions && Actions.animateAdded && addEl && !hasClass(addEl, 'anim')) {
- 1590. - Actions.animateAdded(addEl, isVisible(addEl) ? 200 : 0);
- 1591. - }
- 1592. - });
- 1593. - },
- 1594. - onFail: function() {
- 1595. - cur.addingAudio = false;
- 1596. - }
- 1597. - });
- 1598. - }
- 1599. - }
- 1600. - },
- 1601. - shuffleAudios: function(fromPad) {
- 1602. - var _a = audioPlayer, pl, aid;
- 1603. - if (fromPad && window.Pads) {
- 1604. - pl = ((!window.audioPlaylist || window.curNotifier && (padPlData = ls.get('pad_pldata')) && padPlData.source == curNotifier.instance_id) ? ls.get('pad_playlist') || window.audioPlaylist : padAudioPlaylist());
- 1605. - aid = ((_a = window.audioPlayer) && _a.isPlaylistGlobal()) ? ls.get('audio_id') || currentAudioId() : currentAudioId();
- 1606. - } else {
- 1607. - pl = window.audioPlaylist;
- 1608. - aid = currentAudioId();
- 1609. - }
- 1610. - if (aid) {
- 1611. - var m = aid.match(/^-?\d+_\d+_s(-?\d+)(?:_|$)/);
- 1612. - if (m && m[1] && (pl.statusData || _a.statusData && _a.statusData[m[1]])) {
- 1613. - return false;
- 1614. - }
- 1615. - }
- 1616. - if (!pl && _a.isPlaylistGlobal()) {
- 1617. - pl = ls.get('pad_playlist');
- 1618. - if (pl) {
- 1619. - window.audioPlaylist = pl;
- 1620. - }
- 1621. - }
- 1622. - if (cur.module != 'audio' && !pl) {
- 1623. - return false;
- 1624. - }
- 1625. - _a.shuffle = !_a.shuffle;
- 1626. - if (_a.controls) {
- 1627. - for (var i in _a.controls) {
- 1628. - var obj = _a.controls[i];
- 1629. - if (obj.shuffle) {
- 1630. - toggleClass(obj.shuffle, 'on', _a.shuffle);
- 1631. - }
- 1632. - }
- 1633. - }
- 1634. - if (cur.module == 'audio' && window.Audio) {
- 1635. - Audio.mixAudios();
- 1636. - } else {
- 1637. - var aid = currentAudioId(), startId = pl.start, res = [], other = [];
- 1638. - if (_a.shuffle) {
- 1639. - for (var i in pl) {
- 1640. - each(['_prev', '_next'], function() {
- 1641. - if (pl[i][this] !== undefined) {
- 1642. - pl[i]['_old'+this] = pl[i][this];
- 1643. - }
- 1644. - });
- 1645. - }
- 1646. - pl[startId]._start = true;
- 1647. - if (aid && pl[aid]) {
- 1648. - res.push(pl[aid]);
- 1649. - startId = aid;
- 1650. - } else {
- 1651. - other.push(pl[startId]);
- 1652. - }
- 1653. - } else {
- 1654. - for (var i in pl) {
- 1655. - if (pl[i]._old_prev !== undefined && pl[i]._old_next !== undefined) {
- 1656. - pl[i]._prev = pl[i]._old_prev;
- 1657. - pl[i]._next = pl[i]._old_next;
- 1658. - delete pl[i]._old_prev;
- 1659. - delete pl[i]._old_next;
- 1660. - }
- 1661. - if (pl[i]._start) {
- 1662. - startId = i;
- 1663. - delete pl[i]._start;
- 1664. - }
- 1665. - }
- 1666. - other.push(pl[startId]);
- 1667. - }
- 1668. - var curId = pl[startId]._next;
- 1669. - while (curId && curId != startId && pl[curId]) {
- 1670. - var obj = pl[curId];
- 1671. - delete obj._order;
- 1672. - other.push(obj);
- 1673. - curId = pl[curId]._next;
- 1674. - }
- 1675. - if (other && _a.shuffle) {
- 1676. - var shuffle = function(arr) {
- 1677. - for(var j, x, i = arr.length; i; j = parseInt(Math.random() * i), x = arr[--i], arr[i] = arr[j], arr[j] = x);
- 1678. - return true;
- 1679. - }
- 1680. - shuffle(other);
- 1681. - other = clone(other);
- 1682. - }
- 1683. - for (var i in other) {
- 1684. - res.push(other[i]);
- 1685. - }
- 1686. - _a.genPlaylist(res, true, {my: pl && pl.my, has_more: pl && pl.has_more, htitle: pl && pl.htitle});
- 1687. - if (window.Audio && Audio.loadCurrentPlaylist) {
- 1688. - Audio.loadCurrentPlaylist();
- 1689. - }
- 1690. - }
- 1691. - return false;
- 1692. - },
- 1693. - showStatusTT: function(obj) {
- 1694. - var _a = audioPlayer;
- 1695. - if (cur.statusTTPreloading) {
- 1696. - return false;
- 1697. - }
- 1698. - cur.statusTTPreloading = true;
- 1699. - ajax.post('audio', {act: 'status_tt'}, {
- 1700. - cache: 1,
- 1701. - onDone: function(richTT, html) {
- 1702. - if (richTT) {
- 1703. - showTooltip(obj, {
- 1704. - text: html,
- 1705. - className: 'audio_status_tt',
- 1706. - showdt: 0,
- 1707. - slide: 15,
- 1708. - hidedt: 400,
- 1709. - hasover: 1,
- 1710. - asrtl: 1,
- 1711. - shift: [30, 0, 5],
- 1712. - onShowStart: function() {
- 1713. - var clubs_content = geByClass1('audio_status_wrap', obj.tt.container);
- 1714. - if (!cur.clubsScroll || !hasClass(clubs_content, 'ready')) {
- 1715. - cur.clubsScroll = new Scrollbar(clubs_content, {
- 1716. - prefix: 'audio_clubs_',
- 1717. - nomargin: true,
- 1718. - global: true,
- 1719. - nokeys: true,
- 1720. - right: vk.rtl ? 'auto' : 0,
- 1721. - left: !vk.rtl ? 'auto' : 0,
- 1722. - wheelObj: clubs_content
- 1723. - });
- 1724. - addClass(clubs_content, 'ready');
- 1725. - }
- 1726. - _a.updateAllStatusChecks();
- 1727. - },
- 1728. - onShowEnd: function() {
- 1729. - if (!cur.clubsScroll) return;
- 1730. - cur.clubsScroll.update(false, true);
- 1731. - },
- 1732. - });
- 1733. - } else {
- 1734. - showTooltip(obj, {text: getLang('audio_export_tip'), showdt: 0, black: 1, shift: [11, 0, 0]});
- 1735. - }
- 1736. - cur.statusTTPreloading = false;
- 1737. - }
- 1738. - });
- 1739. - },
- 1740. - updateStatus: function(el, oid) {
- 1741. - checkbox(el);
- 1742. - audioPlayer.toggleStatus(oid);
- 1743. - },
- 1744. - registerPlayer: function(name, obj) {
- 1745. - var _a = audioPlayer;
- 1746. - _a.controls = _a.controls || {};
- 1747. - _a.controls[name] = obj;
- 1748. - if (obj.duration) {
- 1749. - addEvent(obj.duration, 'mousedown', function(){
- 1750. - _a.switchTimeFormat();
- 1751. - });
- 1752. - }
- 1753. - if (obj.volume && obj.volumeArea) {
- 1754. - addEvent(obj.volumeArea, 'mousedown', function(e){
- 1755. - _a.volClick(e, name);
- 1756. - });
- 1757. - var volume = browser.mobile ? 80 : parseInt(getCookie('audio_vol'));
- 1758. - volume = Math.max(0, Math.min(volume, 100));
- 1759. - setStyle(obj.volume, {width: volume + '%'});
- 1760. - }
- 1761. - if (obj.progress && obj.progressArea) {
- 1762. - addEvent(obj.progressArea, 'mousedown', function(e){
- 1763. - _a.prClick(e, name);
- 1764. - });
- 1765. - addEvent(obj.progressArea, 'mouseover', function(){
- 1766. - if (audioPlayer.player) addClass(obj.progressArea, 'over');
- 1767. - if (cur.hideTipTO) {
- 1768. - clearTimeout(cur.hideTipTO);
- 1769. - }
- 1770. - });
- 1771. - addEvent(obj.progressArea, 'mouseout', function() {
- 1772. - removeClass(obj.progressArea, 'over');
- 1773. - cur.hideTipTO = setTimeout(hide.pbind('audio_tip_wrap'), 100);
- 1774. - });
- 1775. - }
- 1776. - if (obj.play) {
- 1777. - addEvent(obj.play, 'click', function(e){
- 1778. - var aid = (obj.padPlaylist && audioPlayer.isPlaylistGlobal() ? ls.get('audio_id') : null) || currentAudioId() || (audioPlayer.lastSong && audioPlayer.lastSong.aid) || (cur.defaultTrack && cur.defaultTrack.id) || window.audioPlaylist && audioPlaylist.start || '';
- 1779. - if (obj.padPlaylist) {
- 1780. - window.padPlClicked = true;
- 1781. - }
- 1782. - if (aid) playAudioNew(aid, false);
- 1783. - });
- 1784. - addEvent(obj.play, 'mousedown', addClass.pbind(obj.play, 'down'));
- 1785. - addEvent(obj.play, 'mouseup', removeClass.pbind(obj.play, 'down'));
- 1786. - }
- 1787. - var clickClbks = {
- 1788. - prev: _a.prevTrack.pbind(false, !!obj.padPlaylist),
- 1789. - next: _a.nextTrack.pbind(false, !!obj.padPlaylist),
- 1790. - add: _a.addCurrentTrack,
- 1791. - repeat: _a.toggleRepeat,
- 1792. - shuffle: _a.shuffleAudios.pbind(!!obj.padPlaylist),
- 1793. - rec: _a.showRec.pbind(false, !!obj.padPlaylist),
- 1794. - status: _a.toggleStatus
- 1795. - };
- 1796. - for (var i in clickClbks) {
- 1797. - if (obj[i]) {
- 1798. - var callback = clickClbks[i];
- 1799. - addEvent(obj[i], 'click', callback.pbind(false));
- 1800. - }
- 1801. - }
- 1802. - var overTTs = {
- 1803. - add: 'audio_add_to_audio',
- 1804. - repeat: 'audio_repeat_tooltip',
- 1805. - shuffle: 'audio_shuffle',
- 1806. - rec: 'audio_show_recommendations'
- 1807. - };
- 1808. - each(['prev', 'next', 'play', 'add', 'repeat', 'rec', 'status', 'shuffle', 'volumeArea'], function(){
- 1809. - if (obj[this]) {
- 1810. - var self = this;
- 1811. - addEvent(obj[this], 'mouseover', function() {
- 1812. - addClass(this, 'over');
- 1813. - if (self == 'status') _a.showStatusTT(this);
- 1814. - if (overTTs[self] && !(self == 'add' && hasClass(this, 'added'))) {
- 1815. - showTooltip(this, {text: getLang(overTTs[self]), showdt: 0, black: 1, shift: [11, 0, 0]});
- 1816. - }
- 1817. - });
- 1818. - }
- 1819. - });
- 1820. - each(['prev', 'next', 'play', 'add', 'repeat', 'rec', 'status', 'shuffle', 'volumeArea'], function(){
- 1821. - if (obj[this]) {
- 1822. - addEvent(obj[this], 'mouseout', function() {
- 1823. - removeClass(this, 'over');
- 1824. - removeClass(this, 'down');
- 1825. - });
- 1826. - }
- 1827. - });
- 1828. - },
- 1829. - deregisterPlayer: function(name) {
- 1830. - var _a = audioPlayer, obj = audioPlayer.controls[name];
- 1831. - if (!obj) {
- 1832. - return;
- 1833. - }
- 1834. - if (obj.duration) {
- 1835. - removeEvent(obj.duration, 'mousedown', function(){
- 1836. - _a.switchTimeFormat();
- 1837. - });
- 1838. - }
- 1839. - if (obj.volume && obj.volumeArea) {
- 1840. - removeEvent(obj.volumeArea, 'mousedown', function(e){
- 1841. - _a.volClick(e, name);
- 1842. - });
- 1843. - }
- 1844. - if (obj.progress && obj.progressArea) {
- 1845. - removeEvent(obj.progressArea, 'mousedown', function(e){
- 1846. - _a.prClick(e, name);
- 1847. - });
- 1848. - removeEvent(obj.progressArea, 'mouseover', function(){
- 1849. - if (audioPlayer.player) addClass(obj.progressArea, 'over');
- 1850. - if (cur.hideTipTO) {
- 1851. - clearTimeout(cur.hideTipTO);
- 1852. - }
- 1853. - });
- 1854. - removeEvent(obj.progressArea, 'mouseout', function() {
- 1855. - removeClass(obj.progressArea, 'over');
- 1856. - cur.hideTipTO = setTimeout(hide.pbind('audio_tip_wrap'), 100);
- 1857. - });
- 1858. - }
- 1859. - if (obj.play) {
- 1860. - removeEvent(obj.play, 'click', function(e){
- 1861. - var aid = (obj.padPlaylist && audioPlayer.isPlaylistGlobal() ? ls.get('audio_id') : null) || currentAudioId() || (audioPlayer.lastSong && audioPlayer.lastSong.aid) || (cur.defaultTrack && cur.defaultTrack.id) || window.audioPlaylist && audioPlaylist.start || '';
- 1862. - if (obj.padPlaylist) {
- 1863. - window.padPlClicked = true;
- 1864. - }
- 1865. - if (aid) playAudioNew(aid, false);
- 1866. - });
- 1867. - removeEvent(obj.play, 'mousedown', addClass.pbind(obj.play, 'down'));
- 1868. - removeEvent(obj.play, 'mouseup', removeClass.pbind(obj.play, 'down'));
- 1869. - }
- 1870. - var clickClbks = {
- 1871. - prev: _a.prevTrack.pbind(false, !!obj.padPlaylist),
- 1872. - next: _a.nextTrack.pbind(false, !!obj.padPlaylist),
- 1873. - add: _a.addCurrentTrack,
- 1874. - repeat: _a.toggleRepeat,
- 1875. - shuffle: _a.shuffleAudios.pbind(!!obj.padPlaylist),
- 1876. - rec: _a.showRec.pbind(false, !!obj.padPlaylist),
- 1877. - status: _a.toggleStatus
- 1878. - };
- 1879. - for (var i in clickClbks) {
- 1880. - if (obj[i]) {
- 1881. - var callback = clickClbks[i];
- 1882. - removeEvent(obj[i], 'click', callback.pbind(false));
- 1883. - }
- 1884. - }
- 1885. - var overTTs = {
- 1886. - add: 'audio_add_to_audio',
- 1887. - repeat: 'audio_repeat_tooltip',
- 1888. - shuffle: 'audio_shuffle',
- 1889. - rec: 'audio_show_recommendations'
- 1890. - };
- 1891. - each(['prev', 'next', 'play', 'add', 'repeat', 'rec', 'status', 'shuffle', 'volumeArea'], function(){
- 1892. - if (obj[this]) {
- 1893. - var self = this;
- 1894. - removeEvent(obj[this], 'mouseover', function() {
- 1895. - addClass(this, 'over');
- 1896. - if (self == 'status') _a.showStatusTT(this);
- 1897. - if (overTTs[self] && !(self == 'add' && hasClass(this, 'added'))) {
- 1898. - showTooltip(this, {text: getLang(overTTs[self]), showdt: 0, black: 1, shift: [11, 0, 0]});
- 1899. - }
- 1900. - });
- 1901. - }
- 1902. - });
- 1903. - each(['prev', 'next', 'play', 'add', 'repeat', 'rec', 'status', 'shuffle', 'volumeArea'], function(){
- 1904. - if (obj[this]) {
- 1905. - removeEvent(obj[this], 'mouseout', function() {
- 1906. - removeClass(this, 'over');
- 1907. - removeClass(this, 'down');
- 1908. - });
- 1909. - }
- 1910. - });
- 1911. - delete audioPlayer.controls[name];
- 1912. - }
- 1913. - }
- 1914. -
- 1915. - try{stManager.done('audioplayer.js');}catch(e){}
- ------
- Файл - audio.js (Старый размер - 112948 | Новый - 0):
- 0. - var Audio = {
- 1. - address: '/audio',
- 2. - scrollnode: browser.msie6 ? pageNode : window,
- 3. - fixedScroll: !(browser.msie && browser.version < 8 || browser.mobile),
- 4. - initPad: function() {
- 5. - if (window._pads && _pads.cur) {
- 6. - var __cur = _pads.cur;
- 7. - extend(__cur, {
- 8. - searchCont: ge('pad_audio_search'),
- 9. - aSearch: ge('pad_search'),
- 10. - clearSearch: ge('pad_audio_reset'),
- 11. - aContent: ge('pad_playlist'),
- 12. - sContent: ge('pad_search_list'),
- 13. - sPreload: ge('pad_search_preload'),
- 14. - showMore: ge('pad_more_audio'),
- 15. - sShowMore: ge('pad_more_search_link'),
- 16. - sWrap: ge('pad_audio_search_wrap'),
- 17. - sSummary: ge('pad_audio_search_summary'),
- 18. - albumFilters: ge('pad_album_filters'),
- 19. - audioFriends: ge('pad_audio_friends'),
- 20. - albumFiltered: ge('pad_album_filtered'),
- 21. - popularFilters: ge('pad_audio_popular_filters'),
- 22. - audioAlbums: ge('pad_audio_albums'),
- 23. - searchFilters: ge('pad_audio_search_filters'),
- 24. - popularOwners: ge('pad_audio_popular_owners'),
- 25. - popularGenres: ge('pad_audio_genres'),
- 26. - audioAlbumsWrap: ge('pad_audio_albums_wrap'),
- 27. - searchInfoCont: ge('pad_audio_search_info'),
- 28. - feedFilter: ge('pad_feed_filter'),
- 29. - topFilter: ge('pad_top_audios'),
- 30. - recFilter: ge('pad_recommendations'),
- 31. - albumsFilter: ge('pad_audios_albums'),
- 32. - friendsList: ge('pad_audio_friends_list'),
- 33. - currentFilter: ge('pad_current_filter'),
- 34. - friendsSearch: ge('pad_audio_friends_search_input'),
- 35. - audioMoreFriensId: 'pad_audio_more_friends',
- 36. - popularPerformersId: 'pad_audio_performers',
- 37. - searchStr: '',
- 38. - htitle: getLang('audio_header')
- 39. - });
- 40. - __cur.audiosList = __cur.audiosList || {};
- 41. - __cur.audios = __cur.audios || {};
- 42. - if (cur.module == 'audio' && cur.oid == vk.id && cur.audiosList && cur.audiosList['all']) {
- 43. - __cur.audiosList['all'] = clone(cur.audiosList['all']);
- 44. - __cur.allAudiosIndex = 'all';
- 45. - if (cur.summaryLang) {
- 46. - __cur.summaryLang = extend(__cur.summaryLang || {}, cur.summaryLang);
- 47. - }
- 48. - Audio.generateAlbums(true);
- 49. - Audio.changeAllIndex({from_pad: true, index: 'all', clbk: function() {}});
- 50. - }
- 51. - Audio.startPadEvents();
- 52. - }
- 53. - },
- 54. - init: function(obj, audioTpl) {
- 55. - extend(cur, {
- 56. - searchCont: ge('audio_search'),
- 57. - aSearch: ge('s_search'),
- 58. - clearSearch: ge('audio_query_reset'),
- 59. - aContent: ge('initial_list'),
- 60. - sContent: ge('search_list'),
- 61. - sPreload: ge('search_preload'),
- 62. - showMore: ge('more_link'),
- 63. - sShowMore: ge('s_more_link'),
- 64. - sWrap: ge('audio_search_wrap'),
- 65. - sSummary: ge('audio_search_summary'),
- 66. - albumFilters: ge('album_filters'),
- 67. - albumFiltered: ge('album_filtered'),
- 68. - searchFilters: ge('audio_search_filters'),
- 69. - popularFilters: ge('audio_popular_filters'),
- 70. - popularOwners: ge('audio_popular_owners'),
- 71. - popularGenres: ge('audio_genres'),
- 72. - audioFriends: ge('audio_friends'),
- 73. - audioAlbums: ge('audio_albums'),
- 74. - audioAlbumsWrap: ge('audio_albums_wrap'),
- 75. - audioWrap: ge('audio_wrap'),
- 76. - searchInfoCont: ge('audio_search_info'),
- 77. - feedFilter: ge('feed_filter'),
- 78. - topFilter: ge('top_audios'),
- 79. - recFilter: ge('recommendations'),
- 80. - albumsFilter: ge('audios_albums'),
- 81. - friendsList: ge('audio_friends_list'),
- 82. - friendsSearch: ge('audio_friends_search_input'),
- 83. - audioMoreFriensId: 'audio_more_friends',
- 84. - popularPerformersId: 'audio_performers',
- 85. - searchStr: "",
- 86. - autoComplete: 1,
- 87. - audioTpl: audioTpl,
- 88. - audioEl: {
- 89. - head: ge('page_header'),
- 90. - bar: ge('ac'),
- 91. - cont: ge('audio'),
- 92. - filters: ge('side_filters')
- 93. - }
- 94. - });
- 95. -
- 96. - if (ge('ac') && window.audioPlayer) {
- 97. - audioPlayer.initEvents();
- 98. - audioPlayer.registerPlayer('ac', {
- 99. - container: ge('ac'),
- 100. - performer: ge('ac_performer'),
- 101. - title: ge('ac_title'),
- 102. - titleWrap: ge('ac_name'),
- 103. - duration: ge('ac_duration'),
- 104. - load: ge('ac_load_line'),
- 105. - progress: ge('ac_pr_line'),
- 106. - progressArea: ge('ac_pr'),
- 107. - volume: ge('ac_vol_line'),
- 108. - volumeArea: ge('ac_vol'),
- 109. - play: ge('ac_play'),
- 110. - prev: ge('ac_prev'),
- 111. - next: ge('ac_next'),
- 112. - add: ge('ac_add'),
- 113. - repeat: ge('ac_repeat'),
- 114. - shuffle: ge('ac_shuffle'),
- 115. - rec: ge('ac_rec'),
- 116. - status: ge('ac_status'),
- 117. - fixed: !(browser.msie && browser.version < 8 || browser.mobile)
- 118. - });
- 119. - }
- 120. - if (browser.mobile) {
- 121. - hide('ac_vol');
- 122. - setStyle('ac_duration', {margin: 0});
- 123. - }
- 124. -
- 125. - if (!cur.allAudiosIndex) cur.allAudiosIndex = 'all';
- 126. -
- 127. - extend(cur, obj);
- 128. - cur.module = 'audio';
- 129. - //cur.disableAutoMore = true;
- 130. - if (cur.aSearch) {
- 131. - cur.aSearch.value = cur.q;
- 132. - toggleClass(cur.clearSearch, 'shown', !!cur.q);
- 133. - placeholderSetup(cur.aSearch, {back: true});
- 134. - setTimeout(function() {
- 135. - cur.aSearch.focus();
- 136. - }, 0);
- 137. - }
- 138. - if (ge('audio_friends_search_input')) {
- 139. - placeholderSetup(ge('audio_friends_search_input'));
- 140. - }
- 141. -
- 142. - Audio.scrollnode = browser.msie6 ? pageNode : window;
- 143. - Audio.fixedScroll = !(browser.msie && browser.version < 8 || browser.mobile);
- 144. - window.scrollTop = bodyNode.scrollTop = pageNode.scrollTop = htmlNode.scrollTop = 0;
- 145. - Audio.startEvents();
- 146. - cur.destroy.push(function() {
- 147. - Audio.stopEvents();
- 148. - });
- 149. -
- 150. - cur.nav.push(function(changed, old, n) {
- 151. - if (changed.act == 'popular') {
- 152. - Audio.loadPopular({update: true, genre: intval(n.genre)});
- 153. - return false;
- 154. - }
- 155. - });
- 156. -
- 157. -
- 158. - var _a = window.audioPlayer;
- 159. - if (_a && _a.showCurrentTrack) {
- 160. - _a.shuffle = false;
- 161. - _a.showCurrentTrack();
- 162. - }
- 163. -
- 164. - cur.audios = {};
- 165. - hide(cur.sContent);
- 166. -
- 167. - cur.silent = true;
- 168. - 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};
- 169. - if (cur.allAudiosIndex != 'all') {
- 170. - Audio.cacheFriendsList();
- 171. - }
- 172. - if (cur.club) {
- 173. - cur.curSection = 'club' + cur.club;
- 174. - query.club = cur.club;
- 175. - cur.searchStr = cur.q;
- 176. - }
- 177. - ajax.post(Audio.address, query, {onDone: (function(data, opts) {
- 178. - opts = eval('('+opts+')');
- 179. - if (opts.exp) {
- 180. - _a.statusExport = opts.exp;
- 181. - checkbox('currinfo_audio', (_a.hasStatusExport()));
- 182. - if (_a && _a.showCurrentTrack) _a.showCurrentTrack();
- 183. - delete opts.exp;
- 184. - }
- 185. - extend(cur, opts);
- 186. - if (cur.hashes && cur.hashes.add_hash && !_a.addHash) {
- 187. - _a.addHash = cur.hashes.add_hash;
- 188. - }
- 189. - if (query.id > 0) {
- 190. - cur.allFriendsTitles = cur.allFriendsTitles || {};
- 191. - cur.allFriendsTitles[query.id] = opts.summaryLang.all_friend_title;
- 192. - cur.allFriendsHTitles = cur.allFriendsHTitles || {};
- 193. - cur.allFriendsHTitles[query.id] = opts.summaryLang.all_friend_htitle;
- 194. - }
- 195. - var obj = eval('('+data+')');
- 196. - if (!obj) {
- 197. - return;
- 198. - }
- 199. - cur.audiosList = cur.audiosList || {};
- 200. - if ((query.club || query.id < 0) && obj.club) {
- 201. - var club = query.club || -query.id;
- 202. - cur.allClubsHTitles = cur.allClubsHTitles || {};
- 203. - cur.allClubsHTitles[club] = opts.summaryLang.all_club_htitle || cur.htitle;
- 204. - cur.allFriendsHTitles = cur.allFriendsHTitles || {};
- 205. - cur.allFriendsHTitles[-club] = opts.summaryLang.all_club_htitle || cur.htitle;
- 206. - cur.curList = 'club' + club;
- 207. - cur.audiosList[cur.curList] = obj.club;
- 208. - } else {
- 209. - cur.curList = (cur.album_id) ? 'album'+cur.album_id : cur.allAudiosIndex;
- 210. - }
- 211. - cur.searchOffset = 0;
- 212. - cur.audiosList[cur.allAudiosIndex] = obj.all ? obj.all : [];
- 213. - if (cur.allAudiosIndex == 'all') Audio.generateAlbums();
- 214. - cur.sectionCount = (cur.audiosList[cur.curList] || []).length;
- 215. - if (cur.canEdit && nav.objLoc.act != 'popular' && nav.objLoc.act != 'recommendations' && nav.objLoc.act != 'feed' && !browser.mobile && cur.allAudiosIndex == 'all' && !cur.shuffled && !cur.club) {
- 216. - if (cur.sectionCount) {
- 217. - var opts = {onReorder: Audio.onAudioReorder, onMouseDown: Audio.onDragStart, onMouseUp: Audio.onDragEnd, noMoveCursor: 1};
- 218. - if (cur.audioAlbumsWrap) {
- 219. - extend(opts, {target: cur.audioAlbumsWrap, onDragOver: Audio.onDragOver, onDragOut: Audio.onDragOut});
- 220. - }
- 221. - sorter.init(cur.aContent, opts);
- 222. - }
- 223. - }
- 224. - if (cur.albums) {
- 225. - Audio.initAlbumsSort();
- 226. - }
- 227. - this.indexAll({callback: function() {
- 228. - cur.silent = false;
- 229. - if (cur.onSilentLoad) {
- 230. - cur.onSilentLoad();
- 231. - }
- 232. - if (!cur.q || cur.club) {
- 233. - if (cur.curSection == 'recommendations' || cur.curSection == 'popular' || cur.curSection == 'feed') {
- 234. - if (cur[cur.curSection+'Audios']) {
- 235. - var k = 0;
- 236. - for (var i in cur[cur.curSection+'Audios']) {
- 237. - cur[cur.curSection+'Audios'][i]._order = k++;
- 238. - }
- 239. - audioPlayer.genPlaylist(cur[cur.curSection+'Audios'], false);
- 240. - }
- 241. - } else {
- 242. - audioPlayer.genPlaylist(cur.audiosList[cur.curList], false, {my: (cur.curList == 'all' && cur.oid == vk.id ? 'my' : false)});
- 243. - }
- 244. - } else if (!query.club) {
- 245. - Audio.selectPerformer({name: cur.q});
- 246. - }
- 247. - if (cur.audio_id) {
- 248. - var audio = cur.audios[cur.audio_id];
- 249. - if (audio) {
- 250. - var audio_id = audio[0] + '_' + audio[1];
- 251. - if (audio[11] && parseInt(audio[11])) {
- 252. - var claim = parseInt(audio[11]) || 0;
- 253. - if (claim == -2) claim = 0;
- 254. - Audio.showAudioClaimWarning(audio_id, claim, audio[5] + ' – ' + audio[6]);
- 255. - } else {
- 256. - try{
- 257. - playAudioNew(audio_id);
- 258. - }catch(e){};
- 259. - }
- 260. - }
- 261. - }
- 262. - }});
- 263. - }).bind(this), local: 1});
- 264. - },
- 265. -
- 266. - startEvents: function() {
- 267. - addEvent(Audio.scrollnode, 'scroll', Audio.scrollCheck);
- 268. - addEvent(window, 'resize', Audio.scrollCheck);
- 269. - addEvent(cur.aSearch, 'blur', Audio.searchBlur.pbind(false));
- 270. - addEvent(cur.aSearch, 'focus', Audio.searchFocus.pbind(false));
- 271. - cur.gpHidden = true;
- 272. - toggleGlobalPlayer(false);
- 273. - if (Audio.fixedScroll) {
- 274. - var els = geByClass('top_info_wrap', ge('page_wrap'));
- 275. - each(els, function() { hide(this); });
- 276. - hide(_stlSide);
- 277. - setTimeout(function() {
- 278. - each(els, function() { hide(this); });
- 279. - hide(_stlSide);
- 280. - }, 110);
- 281. - var headH = cur.audioEl.head.clientHeight,
- 282. - headT = getXY(cur.audioEl.head)[1],
- 283. - audioNavH = cur.audioEl.bar.offsetHeight,
- 284. - headW = cur.audioEl.head.clientWidth,
- 285. - contentY = headH + audioNavH;
- 286. - setStyle(cur.audioEl.head, {width: headW, top: headT});
- 287. - setStyle('side_bar', {top: headH + headT});
- 288. - setStyle(cur.audioEl.bar, {top: headH + headT});
- 289. - setStyle(cur.audioEl.cont, {paddingTop: contentY});
- 290. - setStyle(cur.audioEl.filters, {top: contentY});
- 291. -
- 292. - addClass(bodyNode, 'audio_fixed_nav');
- 293. - _fixedNav = true;
- 294. - }
- 295. - Audio.updateAlbumsTitles();
- 296. - Audio.handleFilterPos();
- 297. - },
- 298. -
- 299. - stopEvents: function() {
- 300. - removeEvent(Audio.scrollnode, 'scroll', Audio.scrollCheck);
- 301. - removeEvent(window, 'resize', Audio.scrollCheck);
- 302. - removeEvent(cur.aSearch, 'blur', Audio.searchBlur.pbind(false));
- 303. - removeEvent(cur.aSearch, 'focus', Audio.searchFocus.pbind(false));
- 304. - if (Audio.fixedScroll) {
- 305. - var els = geByClass('top_info_wrap', ge('page_wrap'));
- 306. - each(els, function() { show(this); });
- 307. - setStyle(cur.audioEl.head, {width: '', top: ''});
- 308. - setStyle('side_bar', {top: ''});
- 309. -
- 310. - removeClass(bodyNode, 'audio_fixed_nav');
- 311. - _fixedNav = false;
- 312. -
- 313. - show(_stlSide);
- 314. - }
- 315. - audioPlayer.deregisterPlayer('ac');
- 316. - setTimeout(function() {
- 317. - toggleGlobalPlayer(true);
- 318. - updGlobalPlayer();
- 319. - }, 100);
- 320. - },
- 321. -
- 322. - startPadEvents: function() {
- 323. - var __cur = window._pads && _pads.cur;
- 324. - addEvent(__cur.aSearch, 'blur', Audio.searchBlur.pbind(true));
- 325. - addEvent(__cur.aSearch, 'focus', Audio.searchFocus.pbind(true));
- 326. - Audio.updateAlbumsTitles({from_pad: true});
- 327. - },
- 328. -
- 329. - stopPadEvents: function() {
- 330. - var __cur = window._pads && _pads.cur;
- 331. - removeEvent(__cur.aSearch, 'blur', Audio.searchBlur.pbind(true));
- 332. - removeEvent(__cur.aSearch, 'focus', Audio.searchFocus.pbind(true));
- 333. - audioPlayer.deregisterPlayer('pd');
- 334. - },
- 335. -
- 336. - searchFocus: function(from_pad) {
- 337. - var alist = from_pad ? ge('pad_playlist_panel') : ge('audios_list');
- 338. - if (!hasClass(alist, 'light')) addClass(alist, 'light');
- 339. - },
- 340. -
- 341. - searchBlur: function(from_pad) {
- 342. - var alist = from_pad ? ge('pad_playlist_panel') : ge('audios_list');
- 343. - if (hasClass(alist, 'light')) removeClass(alist, 'light');
- 344. - },
- 345. -
- 346. - scrollToTop: function(from_pad) {
- 347. - if (from_pad && window._pads) {
- 348. - animate(_pads.content, {scrollTop: 0}, 200);
- 349. - } else {
- 350. - scrollToTop();
- 351. - }
- 352. - },
- 353. -
- 354. - clearSearch: function(opts) {
- 355. - opts = opts || {};
- 356. - var __cur = opts.from_pad ? window._pads && _pads.cur : window.cur,
- 357. - from_pad = !!opts.from_pad, event = opts.event, el = opts.el;
- 358. - setStyle(el, {opacity: .6});
- 359. - __cur.aSearch.focus();
- 360. - if (__cur.allAudiosIndex == 'all') {
- 361. - Audio.loadAlbum({from_pad: from_pad, album: 0});
- 362. - } else {
- 363. - this.filterTimeout = setTimeout((function() {
- 364. - val(__cur.aSearch, '');
- 365. - removeClass(__cur.clearSearch, 'shown');
- 366. - this.updateList({from_pad: from_pad});
- 367. - this.hideSearchResults(from_pad);
- 368. - this.scrollToTop(from_pad);
- 369. - }).bind(this), 10);
- 370. - }
- 371. - if (isVisible(__cur.searchInfoCont)) {
- 372. - hide(__cur.searchInfoCont);
- 373. - if (from_pad) {
- 374. - Audio.updatePadFiltersHeight();
- 375. - }
- 376. - }
- 377. - },
- 378. -
- 379. - updateSorterRows: function(fromEl) {
- 380. - if (fromEl && fromEl.parentNode.sorter){
- 381. - sorter.update(fromEl);
- 382. - }
- 383. - },
- 384. -
- 385. - showLyrics: function(id, lid, top) {
- 386. - var lyrics_div = ge('lyrics'+id);
- 387. - if (!isVisible(lyrics_div)) {
- 388. - show(lyrics_div);
- 389. - lyrics_div.innerHTML = "<div style='text-align: center; height: 50px; padding: 30px 10px 10px 10px'><img valign='middle' src='/images/progress7.gif'></div>";
- 390. - Audio.updateSorterRows(ge('audio'+id));
- 391. - ajax.post(Audio.address, {act: 'get_lyrics', lid: lid, aid: id, top: top ? 1 : 0}, {cache: 1, onDone: (function(responseText) {
- 392. - lyrics_div.innerHTML = responseText;
- 393. - Audio.updateSorterRows(ge('audio'+id));
- 394. - }).bind(this)});
- 395. - } else {
- 396. - lyrics_div.innerHTML = "";
- 397. - hide(lyrics_div);
- 398. - Audio.updateSorterRows(ge('audio'+id));
- 399. - Audio.handleFilterPos();
- 400. - }
- 401. - },
- 402. -
- 403. - allAudios: function(from_pad) {
- 404. - var __cur = from_pad ? window._pads && _pads.cur : window.cur;
- 405. - return __cur.audiosList ? __cur.audiosList[__cur.allAudiosIndex] || [] : [];
- 406. - },
- 407. -
- 408. - showRows: function(opts) {
- 409. - opts = opts || {};
- 410. - var __cur = opts.from_pad ? window._pads && _pads.cur : window.cur,
- 411. - from_pad = !!opts.from_pad, force = opts.force, start = opts.start, end = opts.end;
- 412. -
- 413. - if (from_pad && !__cur.curSection) {
- 414. - Pads.showAudios();
- 415. - return;
- 416. - } else if (__cur.curSection == 'recommendations') {
- 417. - Audio.loadRecommendations({from_pad: from_pad});
- 418. - return;
- 419. - } else if (__cur.curSection == 'popular') {
- 420. - Audio.loadPopular({from_pad: from_pad});
- 421. - return;
- 422. - } else if (__cur.curSection == 'feed') {
- 423. - Audio.loadFeed({from_pad: from_pad});
- 424. - return;
- 425. - }
- 426. - if (__cur.silent) {
- 427. - __cur.onSilentLoad = function() {
- 428. - Audio.showRows(opts);
- 429. - };
- 430. - return;
- 431. - }
- 432. - var list = __cur.audiosList[__cur.curList] || [];
- 433. - if (list[0] && list[0]._order !== undefined) {
- 434. - list = list.sort(function(a,b) {return a._order - b._order});
- 435. - }
- 436. - list = Audio.filterClaimed(list);
- 437. - __cur.sectionCount = list.length;
- 438. - if (!__cur.searchStr) {
- 439. - list = Audio.filterDeleted(list, from_pad);
- 440. - if (__cur.filterUnsorted) {
- 441. - list = Audio.filterByAlbum(list, 0);
- 442. - }
- 443. - __cur.sectionCount = list.length;
- 444. - }
- 445. - if (start == undefined) {
- 446. - start = __cur.shownAudios;
- 447. - }
- 448. - if (end == undefined) {
- 449. - end = __cur.shownAudios + __cur.audiosPerPage;
- 450. - }
- 451. - if (window.tooltips && cur.tooltips) {
- 452. - for (var i = 0; i < cur.tooltips.length; ++i) {
- 453. - if (cur.tooltips[i].el) {
- 454. - if (hasClass(cur.tooltips[i].el, 'audio_friend')) continue;
- 455. - if (cur.tooltips[i].el.ttimer) {
- 456. - clearTimeout(cur.tooltips[i].el.ttimer);
- 457. - }
- 458. - }
- 459. - cur.tooltips[i].hide({fasthide: true});
- 460. - }
- 461. - }
- 462. - if (from_pad && ge('pad_footer_text')) {
- 463. - ge('pad_footer_text').innerHTML = '';
- 464. - }
- 465. - var _a = window.audioPlayer;
- 466. - if (!list || !list.length) {
- 467. - if (__cur.shownAudios == 0 && (__cur.album_id || (!Audio.allAudios(from_pad).length && !__cur.searchStr))) {
- 468. - var msg;
- 469. - if (Audio.allAudios(from_pad).length) {
- 470. - msg = (__cur.album_id) ? getLang('audio_album_no_recs') : getLang('audio_no_audios_found').split('{query}').join('<b>'+cur.searchStr.replace(/([<>&#]*)/g, '')+'</b>');
- 471. - } else {
- 472. - if (__cur.oid > 0 && !__cur.audioFriend) {
- 473. - if ((__cur.id == vk.id || from_pad) && __cur.allAudiosIndex == 'all') {
- 474. - msg = getLang('audio_no_rec_load_msg').split('{link}').join('<a href="#" onclick="Audio.addAudio(); return false">').split('{/link}').join('</a>');
- 475. - } else {
- 476. - msg = getLang('audio_user_no_recs');
- 477. - }
- 478. - } else {
- 479. - msg = __cur.audioFriend > 0 ? getLang('audio_user_no_recs') : getLang('audio_group_no_recs');
- 480. - }
- 481. - }
- 482. - var style = from_pad && window._pads && _pads.content ? ' style="height: ' + (getSize(_pads.content)[1] - 110 - ge('pad_playlist').offsetTop) + 'px;"' : '';
- 483. - __cur.aContent.innerHTML = '<div id="not_found" class="info_msg" ' + style + '>'+msg+'</div>';
- 484. - }
- 485. - hide(__cur.showMore);
- 486. - } else {
- 487. - if (!__cur.shownAudios) {
- 488. - __cur.aContent.innerHTML = '';
- 489. - }
- 490. - var audios = list.slice(start, end);
- 491. - if (!audios.length) {
- 492. - if (__cur.shownAudios >= __cur.sectionCount) {
- 493. - hide(__cur.showMore);
- 494. - if (__cur.searchStr) {
- 495. - this.loadRows(from_pad);
- 496. - }
- 497. - }
- 498. - return;
- 499. - }
- 500. - var html = [];
- 501. - for (i in audios) {
- 502. - var audio = audios[i].slice();
- 503. - if (__cur.selection) {
- 504. - audio[5] = audio[5].replace(__cur.selection.re, __cur.selection.val);
- 505. - audio[6] = audio[6].replace(__cur.selection.re, __cur.selection.val);
- 506. - }
- 507. - html.push(this.drawAudio(audio, from_pad));
- 508. - __cur.shownAudios += 1;
- 509. - }
- 510. - var au = ce('div', {innerHTML: html.join('')});
- 511. - while (au.firstChild) {
- 512. - var el = au.firstChild;
- 513. - __cur.aContent.appendChild(el);
- 514. - }
- 515. - if (from_pad && window.Pads && Pads.updateHeight) {
- 516. - Pads.updateHeight();
- 517. - } else 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) {
- 518. - if (start > 0) {
- 519. - setTimeout(sorter.added.pbind(__cur.aContent), 0);
- 520. - } else {
- 521. - setTimeout(function(){
- 522. - var opts = {onReorder: Audio.onAudioReorder, onMouseDown: Audio.onDragStart, onMouseUp: Audio.onDragEnd, noMoveCursor: 1};
- 523. - if (__cur.audioAlbumsWrap) {
- 524. - extend(opts, {target: __cur.audioAlbumsWrap, onDragOver: Audio.onDragOver, onDragOut: Audio.onDragOut});
- 525. - }
- 526. - sorter.init(__cur.aContent, opts);
- 527. - }, 0);
- 528. - }
- 529. - }
- 530. - if (__cur.searchCount && isVisible(__cur.sContent)) {
- 531. - show(__cur.sWrap);
- 532. - __cur.sContent.style.paddingTop = '12px';
- 533. - __cur.sSummary.innerHTML = langNumeric(__cur.searchCount, __cur.summaryLang['list_found'], true);
- 534. - }
- 535. - if (_a && _a.showCurrentTrack) _a.showCurrentTrack();
- 536. - }
- 537. - setTimeout(Audio.handleFilterPos, 0);
- 538. - var aid = currentAudioId(), clubList = (__cur.curSection && __cur.curSection.substr(0, 4) == 'club');
- 539. - if (_a && _a.gpDisabled && aid) {
- 540. - var track_id = aid.split('_')[1];
- 541. - if (!__cur.audios[track_id]) _a.stop();
- 542. - }
- 543. - if (__cur.justShuffled) {
- 544. - toggle(__cur.showMore, __cur.shownAudios < __cur.sectionCount);
- 545. - return;
- 546. - }
- 547. - if (clubList) {
- 548. - Audio.hideSearchResults(from_pad);
- 549. - }
- 550. - if (force) return;
- 551. - if (__cur.shownAudios >= __cur.sectionCount) {
- 552. - hide(__cur.showMore);
- 553. - if (__cur.searchStr && !clubList) {
- 554. - this.loadRows(from_pad);
- 555. - } else if (!from_pad) {
- 556. - Audio.setQLoc(__cur.searchStr);
- 557. - }
- 558. - } else {
- 559. - show(__cur.showMore);
- 560. - if (!from_pad) {
- 561. - Audio.setQLoc(__cur.searchStr);
- 562. - }
- 563. - }
- 564. - },
- 565. -
- 566. - toggleSearchFriends: function(show, el) {
- 567. - var inpWrap = el.nextSibling, inp = geByTag1('input', inpWrap);
- 568. - if (val(inp) && !show) return;
- 569. - toggle(el, !show);
- 570. - toggle(inpWrap, show);
- 571. - if (show) {
- 572. - setTimeout(function() {inp.select();}, 0);
- 573. - }
- 574. - },
- 575. -
- 576. - clearFriendsSearch: function(opts) {
- 577. - opts = opts || {};
- 578. - var __cur = opts.from_pad ? window._pads && _pads.cur : window.cur,
- 579. - from_pad = !!opts.from_pad, inp = opts.el;
- 580. - val(inp, '');
- 581. - this.searchFriends({from_pad: from_pad, str: '', el: inp});
- 582. - this.toggleSearchFriends(false, domPS(inp.parentNode));
- 583. - },
- 584. -
- 585. - searchFriends: function(opts) {
- 586. - opts = opts || {};
- 587. - var __cur = opts.from_pad ? window._pads && _pads.cur : window.cur,
- 588. - from_pad = !!opts.from_pad, str = trim(val(__cur.friendsSearch)),
- 589. - inp = opts.el, event = opts.event;
- 590. - if (event && event.keyCode == KEY.ESC) {
- 591. - inp.blur();
- 592. - return;
- 593. - }
- 594. - if (str == __cur.searchFriendsStr) return;
- 595. - __cur.searchFriendsStr = str;
- 596. - toggleClass(inp.parentNode, 'str', !!str);
- 597. -
- 598. - clearTimeout(this.searchFTimeout);
- 599. - this.searchFTimeout = setTimeout((function() {
- 600. - Audio.searchFriendsRequest({from_pad: from_pad, str: __cur.searchFriendsStr});
- 601. - }).bind(this), 150);
- 602. - },
- 603. -
- 604. - searchFriendsRequest: function(opts) {
- 605. - opts = opts || {};
- 606. - var __cur = opts.from_pad ? window._pads && _pads.cur : window.cur,
- 607. - from_pad = !!opts.from_pad, str = opts.str;
- 608. - if (__cur.searchFriendsSent) {
- 609. - return;
- 610. - }
- 611. - __cur.searchFriendsSent = true;
- 612. -
- 613. - var query = {act: 'search_friends', str: str};
- 614. - if (__cur.audioFriend && __cur.allAudiosIndex && !__cur.allAudiosIndex.indexOf('friend')) {
- 615. - query.owner = __cur.audioFriend;
- 616. - }
- 617. - if (from_pad) {
- 618. - query.from_pad = 1;
- 619. - }
- 620. - ajax.post(Audio.address, query, {onDone: function(cont, friends) {
- 621. - __cur.searchFriendsSent = false;
- 622. - if (cont) {
- 623. - __cur.friendsList.innerHTML = cont;
- 624. - setTimeout(Audio.handleFilterPos, 0);
- 625. - if (friends) {
- 626. - __cur.shownFriends = friends;
- 627. - }
- 628. - }
- 629. - if (ge(__cur.audioMoreFriensId)) {
- 630. - toggle(ge(__cur.audioMoreFriensId).parentNode, !str);
- 631. - }
- 632. - if (from_pad) {
- 633. - Audio.updatePadFiltersHeight();
- 634. - }
- 635. - }});
- 636. - },
- 637. -
- 638. - loadRows: function(from_pad) {
- 639. - var __cur = from_pad ? window._pads && _pads.cur : window.cur;
- 640. - if (__cur.sPreload.innerHTML) {
- 641. - while (__cur.sPreload.firstChild) {
- 642. - var el = __cur.sPreload.firstChild
- 643. - __cur.sContent.appendChild(el);
- 644. - }
- 645. - if (from_pad && window.Pads && Pads.updateHeight) {
- 646. - Pads.updateHeight();
- 647. - }
- 648. - }
- 649. - clearTimeout(this.searchTimeout);
- 650. - this.searchTimeout = setTimeout((function() {
- 651. - Audio.searchRequest({from_pad: from_pad, str: __cur.searchStr, offset: __cur.searchOffset});
- 652. - }).bind(this), 300);
- 653. - },
- 654. -
- 655. - searchRequest: function(opts) {
- 656. - opts = opts || {};
- 657. - var __cur = opts.from_pad ? window._pads && _pads.cur : window.cur,
- 658. - from_pad = !!opts.from_pad, val = opts.str, offset = opts.offset;
- 659. - if (!val) return;
- 660. - if (val[val.length - 1] == ' ') {
- 661. - val[val.length - 1] = '_';
- 662. - }
- 663. - addClass(__cur.searchCont, 'loading');
- 664. - setStyle(__cur.clearSearch, {opacity: .6});
- 665. - var query = {act: 'search', q: val, offset: offset, id: __cur.id, gid: __cur.gid, performer: __cur.searchTypeMenu ? __cur.searchTypeMenu.val() : 0};
- 666. - if (!from_pad) {
- 667. - var l = ge('audio_lyrics_filter');
- 668. - if (l && parseInt(l.value)) query.lyrics = 1;
- 669. - }
- 670. - if (__cur.searchSortFilter) query.sort = parseInt(__cur.searchSortFilter.val());
- 671. - if (__cur.autoComplete) query.autocomplete = __cur.autoComplete;
- 672. - if (nav.objLoc.claim && !from_pad) query.claim = nav.objLoc.claim;
- 673. - if (from_pad) {
- 674. - query.from_pad = 1;
- 675. - }
- 676. - ajax.post(Audio.address, query, {onDone: function(res, preload, options) {
- 677. - removeClass(__cur.searchCont, 'loading');
- 678. - var newVal = __cur.searchStr;
- 679. - if (newVal[newVal.length - 1] == ' ') {
- 680. - newVal[newVal.length - 1] = '_';
- 681. - }
- 682. - if (val != newVal) {
- 683. - return;
- 684. - }
- 685. - if (res) {
- 686. - __cur.sContent.innerHTML = res;
- 687. - if (from_pad && window.Pads && Pads.updateHeight) {
- 688. - Pads.updateHeight();
- 689. - }
- 690. - }
- 691. - if (preload) {
- 692. - __cur.sPreload.innerHTML = preload;
- 693. - }
- 694. - Audio.applyOptions(__cur, options, offset);
- 695. - if (from_pad) {
- 696. - Audio.updatePadFiltersHeight();
- 697. - }
- 698. - show(__cur.sContent);
- 699. - if (!__cur.sectionCount) {
- 700. - hide(__cur.sWrap);
- 701. - __cur.sContent.style.paddingTop = '0px';
- 702. - __cur.aContent.innerHTML = '';
- 703. - if (!__cur.searchCount && !res && !preload) {
- 704. - msg = getLang('audio_no_audios_found').split('{query}').join('<b>'+__cur.searchStr.replace(/([<>&#]*)/g, '')+'</b>');
- 705. - var style = from_pad && window._pads && _pads.content ? ' style="height: ' + (getSize(_pads.content)[1] - 110 - ge('pad_playlist').offsetTop) + 'px;"' : '';
- 706. - __cur.aContent.innerHTML = '<div id="not_found" class="info_msg"' + style + '>'+msg+'</div>';
- 707. - hide(__cur.showMore);
- 708. - hide(__cur.sContent);
- 709. - }
- 710. - } else {
- 711. - __cur.sContent.style.paddingTop = '12px';
- 712. - if (__cur.searchCount) {
- 713. - __cur.sSummary.innerHTML = langNumeric(__cur.searchCount, __cur.summaryLang['list_found'], true);
- 714. - show(__cur.sWrap);
- 715. - } else {
- 716. - Audio.hideSearchResults(from_pad);
- 717. - hide(__cur.sWrap);
- 718. - }
- 719. - }
- 720. - Audio.changeSummary({from_pad: from_pad, from_search: true});
- 721. - Audio.scrollCheck();
- 722. - if (!offset && !from_pad) {
- 723. - Audio.setQLoc(__cur.searchStr);
- 724. - }
- 725. - var _a = window.audioPlayer;
- 726. - if (_a && _a.showCurrentTrack) _a.showCurrentTrack();
- 727. - },
- 728. - onFail: function() {
- 729. - removeClass(__cur.searchCont, 'loading');
- 730. - },
- 731. - showProgress: function () {
- 732. - __cur.isAudioLoading = true;
- 733. - },
- 734. - hideProgress: function () {
- 735. - __cur.isAudioLoading = false;
- 736. - }
- 737. - });
- 738. - },
- 739. -
- 740. - changeSearchFilters: function(from_pad) {
- 741. - var __cur = from_pad ? window._pads && _pads.cur : window.cur;
- 742. - __cur.searchOffset = 0;
- 743. - Audio.searchRequest({from_pad: from_pad, str: __cur.searchStr, offset: 0});
- 744. - },
- 745. -
- 746. - hideSearchResults: function(from_pad) {
- 747. - setTimeout(function(){
- 748. - var __cur = from_pad ? window._pads && _pads.cur : window.cur;
- 749. - __cur.sContent.innerHTML = '';
- 750. - if (__cur.curSection != 'recommendations' && __cur.curSection != 'popular' && __cur.curSection != 'feed') __cur.sPreload.innerHTML = '';
- 751. - hide(__cur.sContent);
- 752. - hide(__cur.sWrap);
- 753. - hide(__cur.sShowMore);
- 754. - Audio.scrollCheck();
- 755. - }, 0);
- 756. - },
- 757. -
- 758. - drawAudio: function(audio, from_pad) {
- 759. - return from_pad ? Pads.audioRow(audio, {}) : cur.audioTpl(audio, cur.curSection);
- 760. - },
- 761. -
- 762. - applyOptions: function(__cur, options, offset) {
- 763. - extend(__cur, options);
- 764. - if (!__cur.has_more) {
- 765. - hide(__cur.sShowMore);
- 766. - } else {
- 767. - show(__cur.sShowMore);
- 768. - }
- 769. - if (!offset) {
- 770. - if (options.searchInfo) {
- 771. - __cur.searchInfoCont.innerHTML = options.searchInfo;
- 772. - if (!isVisible(__cur.searchInfoCont)) {
- 773. - show(__cur.searchInfoCont);
- 774. - }
- 775. - each(geByClass('audio_friend_name_now', __cur.searchInfoCont), function() {
- 776. - if (this.scrollWidth > this.clientWidth) {
- 777. - this.setAttribute('title', this.innerText || this.textContent);
- 778. - } else {
- 779. - this.removeAttribute('title');
- 780. - }
- 781. - })
- 782. - } else if (isVisible(__cur.searchInfoCont)) {
- 783. - hide(__cur.searchInfoCont);
- 784. - }
- 785. - }
- 786. - },
- 787. -
- 788. - handleFilterPos: function() {
- 789. - if (!Audio.fixedScroll || !cur.audioEl) return false;
- 790. - var headH = cur.audioEl.head.clientHeight, audioNavH = cur.audioEl.bar.offsetHeight,
- 791. - contentY = headH + audioNavH,
- 792. - st = Math.max(0, scrollGetY()), wh = window.lastWindowHeight || 0, pos = 0,
- 793. - filt = ge('side_panel'), filtPos = getXY(filt)[1], filtY = getSize(filt)[1],
- 794. - sf = ge('side_filters'), sfPos = (getStyle(sf, 'position') == 'fixed') ? parseInt(getStyle(sf, 'top')) : getXY(sf)[1], sfY = getSize(sf)[1],
- 795. - bottomPad = Math.max(0, st + wh - filtY - contentY),
- 796. - tooBig = (filtPos + filtY - sfPos - sfY < 20),
- 797. - lastPos = cur.filterLastPos || 100, lastSt = cur.lastSt || 0;
- 798. -
- 799. - if (!tooBig) {
- 800. - addClass(sf, 'fixed');
- 801. - pos = (wh > sfY + contentY) ? Math.min(contentY, wh - sfY - bottomPad) : Math.max(Math.min(contentY, lastPos + lastSt - st), wh - sfY - bottomPad);
- 802. - } else {
- 803. - removeClass(sf, 'fixed');
- 804. - pos = 0;
- 805. - }
- 806. - cur.filterLastPos = pos;
- 807. - cur.lastSt = st;
- 808. - setStyle(sf, {top: pos + 'px'});
- 809. -
- 810. - if (!browser.mozilla && !browser.msie && cur.lastWW !== lastWindowWidth) {
- 811. - cur.lastWW = lastWindowWidth;
- 812. - var goodLeft1 = ge('page_layout').offsetLeft,
- 813. - goodLeft2 = goodLeft1 + cur.audioEl.cont.offsetLeft,
- 814. - goodLeft3 = goodLeft2 + getSize(cur.audioEl.cont)[0] - getSize(cur.audioEl.filters)[0] - 10;
- 815. - cur.audioEl.head.style.left = ge('side_bar').style.left = goodLeft1 + 'px';
- 816. - cur.audioEl.bar.style.left = goodLeft2 + 'px';
- 817. - cur.audioEl.filters.style.left = goodLeft3 + 'px';
- 818. - setTimeout(Audio.resetStyles, 0);
- 819. - }
- 820. - },
- 821. -
- 822. - resetStyles: function() {
- 823. - cur.audioEl.head.style.left = ge('side_bar').style.left =
- 824. - cur.audioEl.bar.style.left = cur.audioEl.filters.style.left = '';
- 825. - },
- 826. -
- 827. - scrollCheck: function () {
- 828. - Audio.handleFilterPos();
- 829. - if (browser.mobile || cur.isAudioLoading || cur.disableAutoMore) return;
- 830. -
- 831. - if (!isVisible(cur.showMore) && !isVisible(cur.sShowMore)) return;
- 832. - if (!cur.curList) {
- 833. - setTimeout(Audio.scrollCheck, 50);
- 834. - return;
- 835. - }
- 836. -
- 837. - var docEl = document.documentElement;
- 838. - var ch = window.innerHeight || docEl.clientHeight || bodyNode.clientHeight;
- 839. - var st = scrollGetY();
- 840. -
- 841. - if (isVisible(cur.showMore) && st + ch + 400 > cur.showMore.offsetTop) {
- 842. - Audio.showRows();
- 843. - }
- 844. - if (isVisible(cur.sShowMore) && st + ch + 400 > cur.sShowMore.offsetTop) {
- 845. - Audio.loadRows();
- 846. - }
- 847. - },
- 848. -
- 849. - updateList: function(opts) {
- 850. - opts = opts || {};
- 851. - var __cur = opts.from_pad ? window._pads && _pads.cur : window.cur,
- 852. - from_pad = !!opts.from_pad, e = opts.event, force = opts.force,
- 853. - showAlbums = opts.showAlbums, fromIndex = opts.fromIndex, obj = __cur.aSearch;
- 854. - if (__cur.silent) {
- 855. - __cur.onSilentLoad = function() {
- 856. - Audio.updateList(opts);
- 857. - };
- 858. - return;
- 859. - }
- 860. - if (e && (e.keyCode == 10 || e.keyCode == 13) || __cur.forceNoAutoComplete) {
- 861. - delete __cur.forceNoAutoComplete
- 862. - delete __cur.autoComplete;
- 863. - } else {
- 864. - __cur.autoComplete = 1;
- 865. - }
- 866. - clearTimeout(this.filterTimeout);
- 867. - this.filterTimeout = setTimeout((function() {
- 868. - var str = trim(obj.value), el;
- 869. - if (str == __cur.searchStr && __cur.autoComplete && !__cur.ignoreEqual) {
- 870. - return;
- 871. - }
- 872. - delete __cur.ignoreEqual;
- 873. - if (!from_pad) {
- 874. - delete nav.objLoc.audio_id;
- 875. - if (nav.objLoc.act == 'recommendations' || nav.objLoc.act == 'popular' || nav.objLoc.act == 'feed' || nav.objLoc.act == 'albums') {
- 876. - delete nav.objLoc.act;
- 877. - }
- 878. - }
- 879. -
- 880. - if (__cur.allAudiosIndex == 'all') {
- 881. - __cur.album_id = 0;
- 882. - }
- 883. - each(geByClass('audio_filter', __cur.albumFilters), function(i, e) {
- 884. - removeClass(e, 'selected');
- 885. - });
- 886. - var c = Audio.allAudios(from_pad).length;
- 887. - if (str) {
- 888. - el = __cur.albumFiltered;
- 889. - hide(__cur.audioFriends);
- 890. - Audio.hideAlbums({from_pad: from_pad});
- 891. - addClass(__cur.clearSearch, 'shown');
- 892. - show(__cur.searchFilters);
- 893. - hide(__cur.searchInfoCont);
- 894. - if (__cur.audioWrap && !c && __cur.allAudiosIndex == 'all') {
- 895. - removeClass(__cur.audioWrap, 'audio_no_recs');
- 896. - }
- 897. - } else {
- 898. - if (showAlbums || __cur.oid != vk.id && !from_pad) {
- 899. - if (__cur.allAudiosIndex == 'all') {
- 900. - el = __cur.albumsFilter || ge((from_pad ? 'pad_' : '') + 'album0');
- 901. - }
- 902. - hide(__cur.audioFriends);
- 903. - Audio.showAlbums({from_pad: from_pad});
- 904. - } else if (fromIndex == 2) {
- 905. - Audio.hideAlbums({from_pad: from_pad});
- 906. - hide(__cur.audioFriends);
- 907. - __cur.searchInfoCont.innerHTML = __cur.performerInfo[__cur.allAudiosIndex];
- 908. - show(__cur.searchInfoCont);
- 909. - } else {
- 910. - Audio.hideAlbums({from_pad: from_pad});
- 911. - show(__cur.audioFriends);
- 912. - hide(__cur.searchInfoCont);
- 913. - if (__cur.allAudiosIndex == 'all') {
- 914. - el = ge((from_pad ? 'pad_' : '') + 'album0');
- 915. - var curEl = geByClass1('current', __cur.friendsList);
- 916. - if (curEl) removeClass(curEl, 'current');
- 917. - }
- 918. - }
- 919. - removeClass(__cur.clearSearch, 'shown');
- 920. - removeClass(__cur.albumFiltered, 'selected');
- 921. - hide(__cur.searchFilters);
- 922. - if (__cur.audioWrap && !c && __cur.allAudiosIndex == 'all' && __cur.oid <= 0) {
- 923. - addClass(__cur.audioWrap, 'audio_no_recs');
- 924. - }
- 925. - }
- 926. - if (el) addClass(el, 'selected');
- 927. - hide(__cur.popularFilters, __cur.popularOwners);
- 928. - if (from_pad) {
- 929. - Audio.updatePadFiltersHeight();
- 930. - }
- 931. - __cur.searchStr = str;
- 932. - this.searchAudios({from_pad: from_pad, str: str, type: __cur.allAudiosIndex, force: force});
- 933. - this.scrollToTop(from_pad);
- 934. - }).bind(this), fromIndex ? 0 : 10);
- 935. - },
- 936. -
- 937. - selectPerformer: function(opts) {
- 938. - opts = opts || {};
- 939. - var __cur = opts.from_pad ? window._pads && _pads.cur : window.cur,
- 940. - from_pad = !!opts.from_pad, event = opts.event, name = opts.name;
- 941. - __cur.aSearch.setValue(name);
- 942. - __cur.forceNoAutoComplete = true;
- 943. - if (event) {
- 944. - __cur.searchTypeMenu.value = 1;
- 945. - __cur.searchTypeChanged({target: {index: 1}}, true);
- 946. - }
- 947. - Audio.updateList({from_pad: from_pad});
- 948. - if (event) cancelEvent(event);
- 949. - },
- 950. -
- 951. - searchAudios: function(opts) {
- 952. - opts = opts || {};
- 953. - var __cur = opts.from_pad ? window._pads && _pads.cur : window.cur,
- 954. - from_pad = !!opts.from_pad, str = opts.str, type = opts.type, force = opts.force;
- 955. - __cur.shownAudios = 0;
- 956. - __cur.curSection = type;
- 957. - if (from_pad && !__cur.audiosIndex) {
- 958. - Audio.loadFriendsAudios({from_pad: from_pad, id: vk.id, index: 'all', str: str});
- 959. - return;
- 960. - }
- 961. - var clubList = (type && type.substr(0, 4) == 'club');
- 962. - if (!clubList && __cur.searchSortFilter) {
- 963. - __cur.searchSortFilter.disable(false);
- 964. - __cur.searchLyricsFilter.disable(false);
- 965. - removeClass(__cur.albumFiltered, 'club_shown');
- 966. - delete __cur.club;
- 967. - }
- 968. - if (str) {
- 969. - var htmlentities = function(s){
- 970. - var el = document.createElement('div');
- 971. - el.innerText = el.textContent = s;
- 972. - s = el.innerHTML;
- 973. - delete el;
- 974. - return s.split('"').join('"');
- 975. - }
- 976. - var htmlencode = function(str){
- 977. - return str.toLowerCase().replace(/\u2013|\u2014/g, '-');
- 978. - var aStr = str.toLowerCase().replace(/\u2013|\u2014/g, '-').split(''), i = aStr.length, aRet = [];
- 979. - while (i--) {
- 980. - var iC = aStr[i].charCodeAt();
- 981. - if ((iC > 127 && iC < 994)) {
- 982. - aRet.push('&#'+iC+';');
- 983. - } else if (iC == 36) {
- 984. - aRet.push('�'+iC+';');
- 985. - } else {
- 986. - aRet.push(htmlentities(aStr[i]));
- 987. - }
- 988. - }
- 989. - return aRet.reverse().join('');
- 990. - }
- 991. - var res = __cur.audiosIndex.search(htmlencode(str));
- 992. - var newList = __cur.curSection;
- 993. - newList += '_search_'+str;
- 994. -
- 995. - __cur.curList = newList;
- 996. - __cur.audiosList[__cur.curList] = res.sort(function(a,b) {return a._order - b._order});
- 997. - audioPlayer.genPlaylist(res, false);
- 998. -
- 999. - if (str) {
- 1000. - str += ' '+(parseLatin(str) || '');
- 1001. - str = trim(escapeRE(str.replace(/\)/g, '')).split('&').join('&'));
- 1002. - __cur.selection = {
- 1003. - re: new RegExp('(\\s|^)('+str.replace(__cur.audiosIndex.delimiter, '|').replace(/(^\||\|$|\?)/g, '')+')', 'gi'),
- 1004. - val: '$1<span>$2</span>'
- 1005. - };
- 1006. - }
- 1007. - } else {
- 1008. - if (!clubList) Audio.hideSearchResults(from_pad);
- 1009. - __cur.curList = __cur.curSection;
- 1010. - audioPlayer.genPlaylist(__cur.audiosList[__cur.curList], false, {my: (__cur.curList == 'all' && (__cur.oid == vk.id || from_pad) ? 'my' : false), htitle: __cur.justShuffled && window.audioPlaylist && audioPlaylist.htitle});
- 1011. - __cur.selection = false;
- 1012. - }
- 1013. -
- 1014. - __cur.sectionCount = (__cur.audiosList[__cur.curList]) ? __cur.audiosList[__cur.curList].length : 0;
- 1015. - this.filterTimeout = setTimeout((function() {
- 1016. - if (!force) {
- 1017. - hide(__cur.sShowMore);
- 1018. - __cur.searchOffset = 0;
- 1019. - }
- 1020. - this.showRows({from_pad: from_pad, force: force});
- 1021. - if (__cur.sectionCount || !__cur.searchStr) {
- 1022. - this.changeSummary({from_pad: from_pad});
- 1023. - }
- 1024. - if (__cur.justShuffled) {
- 1025. - delete __cur.justShuffled;
- 1026. - var aid = currentAudioId();
- 1027. - if (cur.nextPlaylist && (!aid || window.audioPlaylist && !window.audioPlaylist[aid])) {
- 1028. - window.audioPlaylist = clone(cur.nextPlaylist);
- 1029. - }
- 1030. - if (!from_pad) {
- 1031. - Audio.loadCurrentPlaylist();
- 1032. - }
- 1033. - }
- 1034. - }).bind(this), 10);
- 1035. - },
- 1036. -
- 1037. - indexAll: function(opts) {
- 1038. - opts = opts || {};
- 1039. - var __cur = opts.from_pad ? window._pads && _pads.cur : window.cur,
- 1040. - from_pad = !!opts.from_pad, callback = opts.callback;
- 1041. - var all = Audio.allAudios(from_pad),
- 1042. - replacer = function(str, p) {
- 1043. - var c = intval(p);
- 1044. - return (c >= 33 && c < 48) ? String.fromCharCode(c) : str;
- 1045. - };
- 1046. -
- 1047. - __cur.audiosIndex = new vkIndexer(all, function(obj) {
- 1048. - __cur.audios[parseInt(obj[1])] = obj;
- 1049. - return (obj[5]+' '+obj[6]).replace(/\&\#(\d+);?/gi, replacer);
- 1050. - }, function() {
- 1051. - if (callback) {
- 1052. - callback();
- 1053. - }
- 1054. - });
- 1055. - },
- 1056. -
- 1057. - changeAllIndex: function(opts) {
- 1058. - opts = opts || {};
- 1059. - var __cur = opts.from_pad ? window._pads && _pads.cur : window.cur,
- 1060. - from_pad = !!opts.from_pad, index = opts.index, albumSelected = opts.album,
- 1061. - showAlbums = opts.showAlbums, owner = opts.owner, str = opts.str || '';
- 1062. -
- 1063. - if (!__cur.audiosList[index]) return;
- 1064. - __cur.allAudiosIndex = __cur.curList = index;
- 1065. - this.indexAll({from_pad: from_pad, callback: opts.clbk || function() {
- 1066. - var _a = window.audioPlayer;
- 1067. - Audio.mixAllAudios({from_pad: from_pad, mix: (_a && _a.shuffle), noShuffle: true});
- 1068. - audioPlayer.genPlaylist(__cur.audiosList[__cur.curList], from_pad && index == 'all' && !currentAudioId(), {my: (index == 'all' && (__cur.oid == vk.id || from_pad) ? 'my' : false)});
- 1069. - each(geByTag('div', __cur.albumFilters), function(i, e) {
- 1070. - removeClass(e, 'loading');
- 1071. - });
- 1072. - if (__cur.allLoadedCallback) {
- 1073. - __cur.allLoadedCallback();
- 1074. - delete __cur.allLoadedCallback;
- 1075. - return;
- 1076. - }
- 1077. -
- 1078. - __cur.ignoreEqual = true;
- 1079. -
- 1080. - setStyle(__cur.clearSearch, {opacity: .6});
- 1081. - val(__cur.aSearch, str);
- 1082. - toggleClass(__cur.clearSearch, 'shown', !!str);
- 1083. - __cur.searchStr = str;
- 1084. - if (str) {
- 1085. - __cur.forceNoAutoComplete = true;
- 1086. - } else {
- 1087. - Audio.hideSearchResults(from_pad);
- 1088. - }
- 1089. - if (albumSelected) {
- 1090. - Audio.loadAlbum({from_pad: from_pad, album: albumSelected});
- 1091. - } else {
- 1092. - Audio.updateList({from_pad: from_pad, showAlbums: showAlbums, fromIndex: (owner ? 2 : 1)});
- 1093. - }
- 1094. - }});
- 1095. - },
- 1096. -
- 1097. - generateAlbums: function(from_pad) {
- 1098. - var __cur = from_pad ? window._pads && _pads.cur : window.cur;
- 1099. - for (var i in __cur.audiosList) {
- 1100. - if (i.substr(0, 5) == 'album') __cur.audiosList[i] = [];
- 1101. - }
- 1102. - var all = Audio.allAudios(from_pad);
- 1103. - for (var i in all) {
- 1104. - var el = all[i];
- 1105. - if (el[8] && parseInt(el[8])) {
- 1106. - if (!__cur.audiosList['album'+el[8]]) {
- 1107. - __cur.audiosList['album'+el[8]] = [];
- 1108. - }
- 1109. - __cur.audiosList['album'+el[8]].push(el);
- 1110. - }
- 1111. - }
- 1112. - },
- 1113. -
- 1114. - changeHTitle: function(opts) {
- 1115. - opts = opts || {};
- 1116. - var __cur = opts.from_pad ? window._pads && _pads.cur : window.cur,
- 1117. - from_pad = !!opts.from_pad, from_search = opts.from_search;
- 1118. - var htitle = __cur.htitle, pad_htitle = '';
- 1119. - if (__cur.curSection && !__cur.curSection.indexOf('album')) {
- 1120. - var album = ge((from_pad ? 'pad_' : '') + __cur.curSection);
- 1121. - if (album) {
- 1122. - htitle = album.innerText || album.textContent;
- 1123. - }
- 1124. - } else if (__cur.curSection && __cur.curSection == 'recommendations') {
- 1125. - htitle = __cur.recommendTitle ? __cur.recommendTitle : getLang('audio_recommended_audios');
- 1126. - } else if (__cur.curSection && __cur.curSection == 'feed') {
- 1127. - htitle = __cur.feedTitle ? __cur.feedTitle : getLang('audio_friends_feed');
- 1128. - } else if (__cur.curSection && __cur.curSection == 'popular') {
- 1129. - htitle = __cur.popularTitle ? __cur.popularTitle : getLang('audio_popular_audios');
- 1130. - } else if (__cur.curSection && __cur.curSection.indexOf('owner') === 0) {
- 1131. - htitle = __cur.allFriendsHTitles[__cur.audioFriend];
- 1132. - } else if (from_search) {
- 1133. - htitle = getLang('audio_title_search').replace('{q}', val(__cur.aSearch));
- 1134. - pad_htitle = getLang('audio_title_search').replace('{q}', '<b>' + val(__cur.aSearch) + '</b>');
- 1135. - } else if (__cur.curSection && !__cur.curSection.indexOf('club')) {
- 1136. - htitle = __cur.allClubsHTitles[__cur.club] || htitle;
- 1137. - } else if (__cur.audioFriend && __cur.allAudiosIndex && !__cur.allAudiosIndex.indexOf('friend')) {
- 1138. - htitle = __cur.allFriendsHTitles[__cur.audioFriend];
- 1139. - }
- 1140. - __cur.lastHTitle = pad_htitle || htitle;
- 1141. - if (from_pad) {
- 1142. - return;
- 1143. - }
- 1144. - if (opts.count && cur.lang.audio_N_recs) {
- 1145. - htitle += ' | ' + getLang('audio_N_recs', opts.count);
- 1146. - }
- 1147. - // Updating document title
- 1148. - document.title = replaceEntities(stripHTML(htitle));
- 1149. - },
- 1150. -
- 1151. - changeSummary: function(opts) {
- 1152. - opts = opts || {};
- 1153. - var from_pad = opts.from_pad, from_search = opts.from_search;
- 1154. - var count = (from_search) ? cur.searchCount : cur.sectionCount;
- 1155. - Audio.changeHTitle({from_pad: from_pad, count: count, from_search: from_search});
- 1156. - },
- 1157. -
- 1158. - setQLoc: function(query) {
- 1159. - clearTimeout(this.qTimeout);
- 1160. - this.qTimeout = setTimeout(function() {
- 1161. - if (cur.allAudiosIndex != 'all') {
- 1162. - if (cur.allAudiosIndex && cur.allAudiosIndex.substr(0, 5) == 'owner') {
- 1163. - extend(nav.objLoc, {owner: cur.audioFriend});
- 1164. - } else {
- 1165. - extend(nav.objLoc, {friend: cur.audioFriend});
- 1166. - }
- 1167. - } else {
- 1168. - delete nav.objLoc.owner;
- 1169. - delete nav.objLoc.friend;
- 1170. - }
- 1171. - if (cur.curSection && cur.curSection.substr(0, 4) == 'club') {
- 1172. - extend(nav.objLoc, {club: cur.club});
- 1173. - } else {
- 1174. - delete nav.objLoc.club;
- 1175. - delete nav.objLoc.genre;
- 1176. - }
- 1177. - if (query) {
- 1178. - extend(nav.objLoc, {q: query});
- 1179. - var performer = cur.searchTypeMenu ? parseInt(cur.searchTypeMenu.val()) : 0;
- 1180. - if (performer) {
- 1181. - extend(nav.objLoc, {performer: performer});
- 1182. - } else {
- 1183. - delete nav.objLoc.performer;
- 1184. - }
- 1185. - } else {
- 1186. - delete nav.objLoc.q;
- 1187. - }
- 1188. - nav.setLoc(nav.objLoc);
- 1189. - }, 500);
- 1190. - },
- 1191. -
- 1192. - filterClaimed: function(arr) {
- 1193. - var len = arr.length;
- 1194. - var res = [];
- 1195. - for (var i = 0; i < len; i++) {
- 1196. - var t = arr[i];
- 1197. - if (t && (!(t[11] && parseInt(t[11])) || t[12] && parseInt(t[12])) || nav.objLoc.claim) {
- 1198. - res.push(t);
- 1199. - }
- 1200. - }
- 1201. - return res;
- 1202. - },
- 1203. -
- 1204. - filterDeleted: function(arr, from_pad) {
- 1205. - var __cur = from_pad ? window._pads && _pads.cur : window.cur;
- 1206. - var len = arr.length;
- 1207. - var res = [];
- 1208. - for (var i = 0; i < len; i++) {
- 1209. - var t = arr[i];
- 1210. - if (__cur && __cur.audios && __cur.audios[t[1]] && !__cur.audios[t[1]].deleted) {
- 1211. - res.push(t);
- 1212. - }
- 1213. - }
- 1214. - return res;
- 1215. - },
- 1216. -
- 1217. - filterByAlbum: function(arr, album) {
- 1218. - var len = arr.length;
- 1219. - var res = [];
- 1220. - for (var i = 0; i < len; i++) {
- 1221. - var t = arr[i];
- 1222. - if (album == t[8]) {
- 1223. - res.push(t);
- 1224. - }
- 1225. - }
- 1226. - return res;
- 1227. - },
- 1228. -
- 1229. - animateAdded: function(el, speed) {
- 1230. - 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>');
- 1231. - el.parentNode.replaceChild(c, el);
- 1232. - el = c;
- 1233. - setTimeout(function() {
- 1234. - var anim = geByClass1('audio_add_anim', el), add = anim.firstChild, added = add.nextSibling;
- 1235. - cssAnim(anim, {left: '-15px'}, {duration: speed}, function() {
- 1236. - setStyle(anim.parentNode, {width: '15px'});
- 1237. - setStyle(anim.parentNode.parentNode, {paddingLeft: '2px'});
- 1238. - setStyle(anim, {left: '-13px'});
- 1239. - });
- 1240. - cssAnim(add, {opacity: 0}, {duration: speed});
- 1241. - cssAnim(added, {opacity: 1}, {duration: speed});
- 1242. - }, 0);
- 1243. - return el;
- 1244. - },
- 1245. -
- 1246. - addShareAudio: function(opts) {
- 1247. - opts = opts || {};
- 1248. - var __cur = opts.from_pad ? window._pads && _pads.cur : window.cur,
- 1249. - from_pad = !!opts.from_pad, el = opts.el, aid = opts.aid, oid = opts.oid,
- 1250. - hash = opts.hash, gid = opts.gid, top = opts.top;
- 1251. -
- 1252. - if (el.tt) el.tt.hide();
- 1253. - el = Audio.animateAdded(el, 200);
- 1254. - var query = {act:'add', aid:aid, oid:oid, hash:hash, top:top};
- 1255. - if (gid) query.gid = cur.gid;
- 1256. - if (__cur.curSection == 'recommendations') query.recommendation = 1;
- 1257. - if ((cur.module == 'audio' || cur.module == 'feed') && nav.objLoc['q'] || cur.module == 'search' && nav.objLoc['c[q]']) query.search = 1;
- 1258. - ajax.post(Audio.address, query, {
- 1259. - onDone: function (data, res) {
- 1260. - var obj = eval('('+data+')'), all_list;
- 1261. - if (((!cur.gid && (cur.id == vk.id || from_pad)) || (cur.gid && gid)) && obj) {
- 1262. - setTimeout(function(){
- 1263. - obj = obj['all'][0];
- 1264. - if (cur.audiosIndex) {
- 1265. - all_list = cur.audiosList['all'];
- 1266. - if (all_list && all_list.length) {
- 1267. - obj._order = all_list[0]._order - 1;
- 1268. - cur.audiosList['all'].splice(0,0,obj);
- 1269. - } else {
- 1270. - obj._order = 0;
- 1271. - cur.audiosList['all'] = [obj];
- 1272. - }
- 1273. - cur.audios[obj[1]] = obj;
- 1274. - if (cur.allAudiosIndex == 'all') {
- 1275. - cur.audiosIndex.add(obj);
- 1276. - }
- 1277. - }
- 1278. - if (window._pads && _pads.cur && _pads.cur.audiosIndex && _pads.cur.audiosList) {
- 1279. - all_list = _pads.cur.audiosList['all'];
- 1280. - if (all_list && all_list.length) {
- 1281. - obj._order = all_list[0]._order - 1;
- 1282. - _pads.cur.audiosList['all'].splice(0,0,obj);
- 1283. - } else {
- 1284. - obj._order = 0;
- 1285. - _pads.cur.audiosList['all'] = [obj];
- 1286. - }
- 1287. - if (_pads.cur.audios) {
- 1288. - _pads.cur.audios[obj[1]] = obj;
- 1289. - }
- 1290. - if (_pads.cur.allAudiosIndex == 'all') {
- 1291. - _pads.cur.audiosIndex.add(obj);
- 1292. - }
- 1293. - }
- 1294. - if (window.Pads && Pads.clearAudioLoadCache) {
- 1295. - Pads.clearAudioLoadCache();
- 1296. - }
- 1297. - }, 0);
- 1298. - }
- 1299. - var showShare = function() {
- 1300. - addClass(ge('audio'+oid+'_'+aid), 'tt_shown');
- 1301. - showTooltip(el, {
- 1302. - content: res.content,
- 1303. - slide: 15,
- 1304. - shift: [59, 5, 0],
- 1305. - black: 1,
- 1306. - hidedt: 200,
- 1307. - className: 'audio_add_tt wall_tt rich',
- 1308. - onHide: function() {
- 1309. - removeClass(ge('audio'+oid+'_'+aid), 'tt_shown');
- 1310. - }
- 1311. - });
- 1312. - var tip = el.tt;
- 1313. - if (tip && !tip.inited) {
- 1314. - var a = geByClass('add_cont', tip.container)[0];
- 1315. - tip.onClean = function() {
- 1316. - tip.inited = false;
- 1317. - removeEvent(tip.container, 'mouseover', tip.show);
- 1318. - removeEvent(tip.container, 'mouseout', tip.hide);
- 1319. - }
- 1320. - addEvent(tip.container, 'mouseover', tip.show);
- 1321. - addEvent(tip.container, 'mouseout', tip.hide);
- 1322. - addEvent(a, 'click', function(){
- 1323. - toggleClass(this, 'on');
- 1324. - var share_q = {act: 'share_audio', audio:res.audio, status: tip.status? tip.status : 0, check: hasClass(a, 'on')?1:0, hash: res.hash};
- 1325. - if (gid) share_q.gid = cur.gid;
- 1326. - ajax.post(Audio.address, share_q, {
- 1327. - onDone: function(data) {
- 1328. - if (data) tip.status = data;
- 1329. - }
- 1330. - });
- 1331. - });
- 1332. - tip.inited = true;
- 1333. - }
- 1334. - }
- 1335. - addEvent(el, 'mouseover', showShare);
- 1336. - if (!cur.addedIds) cur.addedIds = {};
- 1337. - cur.addedIds[oid+'_'+aid] = 1;
- 1338. - if (window.audioPlayer && currentAudioId()) {
- 1339. - var cur_aids = currentAudioId().split('_');
- 1340. - if (cur_aids[0] == oid && cur_aids[1] == aid) {
- 1341. - audioPlayer.showCurrentAdded();
- 1342. - }
- 1343. - }
- 1344. - }
- 1345. - });
- 1346. - },
- 1347. -
- 1348. - alistOver: function(obj){
- 1349. - if (!hasClass(obj, 'audio_list_cell_on')) {
- 1350. - obj.className = 'audio_list_cell_over';
- 1351. - }
- 1352. - },
- 1353. -
- 1354. - alistOff: function(obj) {
- 1355. - if (!hasClass(obj, 'audio_list_cell_on')){
- 1356. - obj.className = 'audio_list_cell';
- 1357. - }
- 1358. - },
- 1359. -
- 1360. - listOut: function(obj) {
- 1361. - removeClass(obj, 'over');
- 1362. - },
- 1363. -
- 1364. - listOver: function(obj) {
- 1365. - addClass(obj, 'over');
- 1366. - },
- 1367. -
- 1368. - loadAlbum: function(opts) {
- 1369. - opts = opts || {};
- 1370. - var __cur = opts.from_pad ? window._pads && _pads.cur : window.cur,
- 1371. - from_pad = !!opts.from_pad,
- 1372. - album_id = opts.album, filter = opts.filter, showAlbums = opts.showAlbums;
- 1373. - if (__cur.silent) {
- 1374. - __cur.onSilentLoad = function() {
- 1375. - Audio.loadAlbum(opts);
- 1376. - };
- 1377. - return;
- 1378. - }
- 1379. - if (!album_id && !showAlbums && (__cur.oid == vk.id) && isVisible(__cur.audioMoreFriensId) && !__cur.searchFriendsStr) {
- 1380. - __cur.shownFriends = [];
- 1381. - Audio.showMoreFriends({from_pad: from_pad, onShow: addClass.pbind(ge((from_pad ? 'pad_' : '') + 'album0'), 'loading'), onHide: removeClass.pbind(ge((from_pad ? 'pad_' : '') + 'album0'), 'loading')});
- 1382. - }
- 1383. - hide(__cur.searchInfoCont);
- 1384. - if (__cur.allAudiosIndex != 'all') {
- 1385. - Audio.loadFriendsAudios({from_pad: from_pad, id: vk.id, index: 'all', album: album_id, showAlbums: showAlbums});
- 1386. - return;
- 1387. - }
- 1388. - if (__cur.audioWrap && !Audio.allAudios(from_pad).length && __cur.allAudiosIndex == 'all' && __cur.oid <= 0) {
- 1389. - addClass(__cur.audioWrap, 'audio_no_recs');
- 1390. - }
- 1391. - if (filter) {
- 1392. - __cur.filterUnsorted = 1;
- 1393. - } else {
- 1394. - delete __cur.filterUnsorted;
- 1395. - }
- 1396. - var curSel = __cur.filterUnsorted ? ge('album_unsorted') : (showAlbums ? __cur.albumsFilter : ge((from_pad ? 'pad_' : '') + 'album' + album_id));
- 1397. - __cur.lastAct = 'album' + album_id;
- 1398. - album_id = album_id || 0;
- 1399. - each(geByClass('audio_filter', __cur.albumFilters), function(i, e) {
- 1400. - removeClass(e, 'selected');
- 1401. - });
- 1402. - if (curSel) addClass(curSel, 'selected');
- 1403. - removeClass(__cur.albumFiltered, 'selected');
- 1404. - hide(__cur.popularFilters, __cur.popularOwners, __cur.searchFilters);
- 1405. - if (album_id == 0 && !showAlbums && (__cur.oid == vk.id || from_pad)) {
- 1406. - Audio.hideAlbums({from_pad: from_pad});
- 1407. - show(__cur.audioFriends);
- 1408. - var curEl = geByClass1('current', __cur.friendsList);
- 1409. - if (curEl) removeClass(curEl, 'current');
- 1410. - } else {
- 1411. - hide(__cur.audioFriends);
- 1412. - Audio.showAlbums({from_pad: from_pad});
- 1413. - }
- 1414. - if (from_pad) {
- 1415. - Audio.updatePadFiltersHeight();
- 1416. - } else {
- 1417. - if (showAlbums && !filter && !album_id) {
- 1418. - Audio.updateAlbums();
- 1419. - }
- 1420. - delete nav.objLoc.q;
- 1421. - delete nav.objLoc.owner;
- 1422. - delete nav.objLoc.friend;
- 1423. - delete __cur.recsOffset;
- 1424. - delete __cur.popularOffset;
- 1425. - delete nav.objLoc.club;
- 1426. - delete nav.objLoc.genre;
- 1427. - delete nav.objLoc.audio_id;
- 1428. - delete __cur._back;
- 1429. - if (nav.objLoc.act == 'recommendations' || nav.objLoc.act == 'popular' || nav.objLoc.act == 'feed' || nav.objLoc.act == 'albums') delete nav.objLoc.act;
- 1430. - if (album_id) {
- 1431. - extend(nav.objLoc, {album_id: album_id});
- 1432. - } else {
- 1433. - delete nav.objLoc.album_id;
- 1434. - }
- 1435. - nav.setLoc(nav.objLoc);
- 1436. - }
- 1437. - clearTimeout(this.filterTimeout);
- 1438. - this.filterTimeout = setTimeout((function() {
- 1439. - val(__cur.aSearch, '');
- 1440. - removeClass(__cur.clearSearch, 'shown');
- 1441. - __cur.searchStr = '';
- 1442. - __cur.album_id = album_id;
- 1443. - var type = (album_id) ? 'album'+album_id : __cur.allAudiosIndex;
- 1444. - this.searchAudios({from_pad: from_pad, type: type, str: ''});
- 1445. - this.hideSearchResults(from_pad);
- 1446. - this.scrollToTop(from_pad);
- 1447. - }).bind(this), 10);
- 1448. - if (__cur.oid == vk.id || from_pad) {
- 1449. - ajax.post(Audio.address, {act: 'list_stats', albums: (album_id || showAlbums) ? 1 : 0});
- 1450. - }
- 1451. - },
- 1452. -
- 1453. - hideAlbums: function(opts) {
- 1454. - opts = opts || {};
- 1455. - var __cur = opts.from_pad ? window._pads && _pads.cur : window.cur,
- 1456. - from_pad = !!opts.from_pad, icon = geByClass1('icon', __cur.albumsFilter);
- 1457. - if (isVisible(__cur.audioAlbums)) {
- 1458. - slideUp(__cur.audioAlbums, 200, function() {
- 1459. - if (from_pad) {
- 1460. - Audio.updatePadFiltersHeight();
- 1461. - }
- 1462. - removeClass(icon, 'up');
- 1463. - });
- 1464. - }
- 1465. - },
- 1466. -
- 1467. - showAlbums: function(opts) {
- 1468. - opts = opts || {};
- 1469. - var __cur = opts.from_pad ? window._pads && _pads.cur : window.cur,
- 1470. - from_pad = !!opts.from_pad, icon = geByClass1('icon', __cur.albumsFilter);
- 1471. - if (!isVisible(__cur.audioAlbums)) {
- 1472. - if (!from_pad) {
- 1473. - Audio.updateAlbumsStart();
- 1474. - }
- 1475. - slideUp(__cur.audioAlbums, 200, function() {
- 1476. - addClass(icon, 'up');
- 1477. - if (from_pad) {
- 1478. - Audio.updatePadFiltersHeight();
- 1479. - } else {
- 1480. - Audio.updateAlbumsFinish();
- 1481. - }
- 1482. - });
- 1483. - }
- 1484. - },
- 1485. -
- 1486. - toggleAlbums: function(opts) {
- 1487. - opts = opts || {};
- 1488. - var __cur = opts.from_pad ? window._pads && _pads.cur : window.cur,
- 1489. - from_pad = !!opts.from_pad, down = isVisible(__cur.audioAlbums),
- 1490. - icon = geByClass1('icon', __cur.albumsFilter);
- 1491. - if (!from_pad) {
- 1492. - Audio.updateAlbumsStart();
- 1493. - }
- 1494. - slideToggle(__cur.audioAlbums, 200, function() {
- 1495. - if (from_pad) {
- 1496. - Audio.updatePadFiltersHeight();
- 1497. - } else {
- 1498. - Audio.updateAlbumsFinish();
- 1499. - }
- 1500. - });
- 1501. - toggleClass(icon, 'up', !down);
- 1502. - },
- 1503. -
- 1504. - addAudio: function(params, event) {
- 1505. - if (cur.uploadBanned) {
- 1506. - setTimeout(showFastBox({title: getLang('audio_no_upload_title'), bodyStyle: 'line-height: 160%;'}, getLang('audio_claims_no_upload')).hide, 5000);
- 1507. - if (event) cancelEvent(event);
- 1508. - return false;
- 1509. - }
- 1510. - showBox(Audio.address, extend(params || {}, {act: 'new_audio', gid: cur.gid}), {
- 1511. - params: {width: '440px', bodyStyle: 'padding: 0px; position: relative;'}
- 1512. - });
- 1513. - if (event) cancelEvent(event);
- 1514. - return false;
- 1515. - },
- 1516. -
- 1517. - mixAllAudios: function(opts) {
- 1518. - opts = opts || {};
- 1519. - var __cur = opts.from_pad ? window._pads && _pads.cur : window.cur,
- 1520. - from_pad = !!opts.from_pad, mix = opts.mix, noShuffle = opts.noShuffle;
- 1521. - var all_list = Audio.allAudios(from_pad), _a = window.audioPlayer, current = 0;
- 1522. - if (!all_list) return;
- 1523. - if (mix) {
- 1524. - if (all_list[0] && all_list[0]._old_order !== undefined) return;
- 1525. - for (var i = all_list.length; i; ) {
- 1526. - var j = parseInt(Math.random() * i)
- 1527. - var x = all_list[--i];
- 1528. - all_list[i] = all_list[j];
- 1529. - all_list[i]._old_order = all_list[i]._order;
- 1530. - all_list[i]._order = i;
- 1531. - if (currentAudioId() == all_list[i][0]+'_'+all_list[i][1]) {
- 1532. - current = i;
- 1533. - }
- 1534. - all_list[j] = x;
- 1535. - };
- 1536. - if (current) {
- 1537. - var x = all_list[current];
- 1538. - all_list[current] = all_list[0];
- 1539. - all_list[current]._order = current;
- 1540. - all_list[0] = x;
- 1541. - all_list[0]._order = 0;
- 1542. - }
- 1543. - } else {
- 1544. - for (var i in all_list) {
- 1545. - if (all_list[i]._old_order !== undefined) {
- 1546. - all_list[i]._order = all_list[i]._old_order;
- 1547. - delete all_list[i]._old_order;
- 1548. - }
- 1549. - };
- 1550. - }
- 1551. - if (!noShuffle) __cur.justShuffled = true;
- 1552. - },
- 1553. - mixAudios: function() {
- 1554. - if (cur.curSection == 'recommendations') {
- 1555. - Audio.loadRecommendations({update: 'remix'});
- 1556. - return;
- 1557. - }
- 1558. - if (cur.curSection == 'popular') {
- 1559. - Audio.loadPopular({update: 'remix'});
- 1560. - return;
- 1561. - }
- 1562. - if (cur.silent) {
- 1563. - cur.onSilentLoad = function() {
- 1564. - Audio.mixAudios();
- 1565. - };
- 1566. - return;
- 1567. - }
- 1568. - var _a = window.audioPlayer;
- 1569. - Audio.mixAllAudios({mix: _a && _a.shuffle});
- 1570. - cur.ignoreEqual = true;
- 1571. - if (cur.album_id) {
- 1572. - this.loadAlbum({album: cur.album_id});
- 1573. - } else {
- 1574. - this.updateList();
- 1575. - }
- 1576. - cur.shuffled = _a && _a.shuffle;
- 1577. - },
- 1578. -
- 1579. - loadRecommendations: function(opts) {
- 1580. - opts = opts || {};
- 1581. - var __cur = opts.from_pad ? window._pads && _pads.cur : window.cur,
- 1582. - from_pad = !!opts.from_pad, update = opts.update, audioId = opts.audioId;
- 1583. - if (__cur.loadingRecs) return;
- 1584. - if (update) {
- 1585. - delete __cur.recsOffset;
- 1586. - delete __cur.recommendIds;
- 1587. - delete __cur.recommendAudios;
- 1588. - delete __cur.preloadJSON;
- 1589. - }
- 1590. - if (audioId) {
- 1591. - __cur.recsAudioId = audioId;
- 1592. - } else if (update === true) {
- 1593. - delete __cur.recsAudioId;
- 1594. - }
- 1595. - each(geByClass('audio_filter', __cur.albumFilters), function(i, e) {
- 1596. - removeClass(e, 'selected');
- 1597. - });
- 1598. - if (__cur.searchStr && isVisible(__cur.searchInfoCont)) {
- 1599. - hide(__cur.searchInfoCont);
- 1600. - }
- 1601. - if (from_pad && ge('pad_footer_text')) {
- 1602. - ge('pad_footer_text').innerHTML = '';
- 1603. - }
- 1604. - var rec_filter = __cur.recFilter;
- 1605. - addClass(rec_filter, 'selected');
- 1606. - removeClass(__cur.albumFiltered, 'selected');
- 1607. - hide(__cur.searchFilters, __cur.popularFilters);
- 1608. - if (from_pad || __cur.oid == vk.id) {
- 1609. - hide(__cur.audioFriends, __cur.searchInfoCont);
- 1610. - Audio.hideAlbums({from_pad: from_pad});
- 1611. - }
- 1612. - if (from_pad && ge('pad_footer_text')) {
- 1613. - ge('pad_footer_text').innerHTML = '';
- 1614. - }
- 1615. - removeClass(__cur.albumFiltered, 'club_shown');
- 1616. - Audio.handleFilterPos();
- 1617. - __cur.lastSection = __cur.curSection;
- 1618. - __cur.curSection = 'recommendations';
- 1619. - if (__cur.recsOffset === undefined) {
- 1620. - __cur.recsOffset = 0;
- 1621. - } else {
- 1622. - addClass(__cur.showMore, 'loading');
- 1623. - }
- 1624. - if (__cur.recommendIds === undefined) __cur.recommendIds = [];
- 1625. - if (__cur.recommendAudios === undefined) __cur.recommendAudios = [];
- 1626. - if (__cur.recsCount === undefined) __cur.recsCount = 0;
- 1627. - if (__cur.sPreload.innerHTML) {
- 1628. - while (__cur.sPreload.firstChild) {
- 1629. - var el = __cur.sPreload.firstChild;
- 1630. - __cur.aContent.appendChild(el);
- 1631. - __cur.recsCount++;
- 1632. - }
- 1633. - if (from_pad && window.Pads && Pads.updateHeight) {
- 1634. - Pads.updateHeight();
- 1635. - }
- 1636. - }
- 1637. - if (__cur.preloadJSON) {
- 1638. - json = __cur.preloadJSON['all'];
- 1639. - var cur_order = __cur.recsCount;
- 1640. - for (var i in json) {
- 1641. - var audio = json[i];
- 1642. - audio._order = cur_order++;
- 1643. - if (indexOf(__cur.recommendIds, audio[0]+"_"+audio[1]) == -1) {
- 1644. - __cur.recommendIds.push(audio[0]+"_"+audio[1]);
- 1645. - __cur.recommendAudios.push(audio);
- 1646. - }
- 1647. - }
- 1648. - var aid = currentAudioId(), needs_update = __cur.recsOffset && (aid && __cur.recommendIds && indexOf(__cur.recommendIds, aid) != -1);
- 1649. - audioPlayer.genPlaylist(__cur.recommendAudios, needs_update);
- 1650. - }
- 1651. - if (__cur.noRecommendations) {
- 1652. - hide(__cur.showMore);
- 1653. - delete __cur.noRecommendations;
- 1654. - return;
- 1655. - }
- 1656. - if (opts.tt) {
- 1657. - opts.tt.hide();
- 1658. - }
- 1659. - __cur.loadingRecs = true;
- 1660. - __cur.lastAct = 'recommendations';
- 1661. - var offset = __cur.recsOffset, query = {act: 'get_recommendations', id: __cur.id, offset: offset},
- 1662. - needsUpdate = window.audioPlayer && audioPlayer.shuffle;
- 1663. - if (from_pad) {
- 1664. - query.from_pad = 1;
- 1665. - }
- 1666. - if (update == 'remix' || needsUpdate != __cur.recsRemix) {
- 1667. - __cur.recsRemix = needsUpdate;
- 1668. - query.remix = needsUpdate ? 1 : 0;
- 1669. - var aid = currentAudioId();
- 1670. - if (aid && window.audioPlaylist && audioPlaylist[aid] && audioPlaylist.address && audioPlaylist.address.indexOf('act=recommendations') > 0) {
- 1671. - var a = audioPlaylist[aid];
- 1672. - if (a[10]) query.current = a[10]+' '+aid;
- 1673. - }
- 1674. - }
- 1675. - if (__cur.recsAudioId) {
- 1676. - query.audio_id = __cur.recsAudioId;
- 1677. - }
- 1678. - ajax.post(Audio.address, query, {
- 1679. - onDone: function(rows, preload, json, preload_json, options, ownersRows) {
- 1680. - delete __cur.loadingRecs;
- 1681. - if (__cur.lastAct != 'recommendations') return;
- 1682. - if (!offset) {
- 1683. - if (ownersRows) {
- 1684. - val((from_pad ? 'pad_' : '') + 'audio_popular_owners_rows', ownersRows);
- 1685. - show(__cur.popularOwners);
- 1686. - } else {
- 1687. - hide(__cur.popularOwners);
- 1688. - }
- 1689. - }
- 1690. - if (from_pad) {
- 1691. - Audio.updatePadFiltersHeight();
- 1692. - }
- 1693. - if (options.recsCount === 0 && offset) {
- 1694. - __cur.noRecommendations = true;
- 1695. - delete options.recsOffset;
- 1696. - }
- 1697. - if (json) {
- 1698. - json = eval('('+json+')');
- 1699. - json = json['all'];
- 1700. - var cur_order = __cur.recsCount;
- 1701. - for (var i in json) {
- 1702. - var audio = json[i];
- 1703. - audio._order = cur_order++;
- 1704. - if (indexOf(__cur.recommendIds, audio[0]+"_"+audio[1]) == -1) {
- 1705. - __cur.recommendIds.push(audio[0]+"_"+audio[1]);
- 1706. - __cur.recommendAudios.push(audio);
- 1707. - }
- 1708. - }
- 1709. - var aid = currentAudioId(), needs_update = query.offset && (aid && __cur.recommendIds && indexOf(__cur.recommendIds, aid) != -1);
- 1710. - audioPlayer.genPlaylist(__cur.recommendAudios, needs_update);
- 1711. - if (query.audio_id) {
- 1712. - cur.nextPlaylist.rec = 1;
- 1713. - }
- 1714. - }
- 1715. - removeClass(__cur.showMore, 'loading');
- 1716. - if (offset) {
- 1717. - delete options.recsCount;
- 1718. - }
- 1719. - if (options) extend(__cur, options);
- 1720. - if (!offset) {
- 1721. - __cur.aContent.innerHTML = rows;
- 1722. - if (from_pad && window.Pads && Pads.updateHeight) {
- 1723. - Pads.updateHeight();
- 1724. - }
- 1725. - }
- 1726. -
- 1727. - __cur.preloadJSON = preload_json ? eval('('+preload_json+')') : false;
- 1728. - __cur.sPreload.innerHTML = '';
- 1729. - var au = ce('div', {innerHTML: preload});
- 1730. - while (au.firstChild) {
- 1731. - if (!ge(au.firstChild.id)) {
- 1732. - var el = au.firstChild;
- 1733. - __cur.sPreload.appendChild(el);
- 1734. - } else {
- 1735. - au.removeChild(au.firstChild);
- 1736. - }
- 1737. - }
- 1738. -
- 1739. - if (__cur.recsCount && !query.audio_id) {
- 1740. - show(__cur.showMore);
- 1741. - } else {
- 1742. - hide(__cur.showMore);
- 1743. - }
- 1744. - if (query.remix) {
- 1745. - __cur.justShuffled = true;
- 1746. - }
- 1747. - Audio.changeHTitle({from_pad: from_pad});
- 1748. - val(__cur.aSearch, '');
- 1749. - removeClass(__cur.clearSearch, 'shown');
- 1750. - __cur.searchStr = '';
- 1751. - __cur.album_id = 0;
- 1752. - Audio.hideSearchResults(from_pad);
- 1753. - hide(__cur.sShowMore);
- 1754. - if (!offset) {
- 1755. - Audio.scrollToTop(from_pad);
- 1756. - }
- 1757. - if (!from_pad) {
- 1758. - delete nav.objLoc.q;
- 1759. - delete nav.objLoc.owner;
- 1760. - delete nav.objLoc.friend;
- 1761. - delete nav.objLoc.album_id;
- 1762. - delete nav.objLoc.club;
- 1763. - delete nav.objLoc.genre;
- 1764. - delete __cur._back;
- 1765. - extend(nav.objLoc, {act: 'recommendations'});
- 1766. - if (query.audio_id) {
- 1767. - extend(nav.objLoc, {audio_id: query.audio_id});
- 1768. - } else {
- 1769. - delete nav.objLoc.audio_id;
- 1770. - }
- 1771. - nav.setLoc(nav.objLoc);
- 1772. - }
- 1773. - var _a = window.audioPlayer;
- 1774. - if (_a && _a.showCurrentTrack) _a.showCurrentTrack();
- 1775. - if (!from_pad) {
- 1776. - Audio.loadCurrentPlaylist();
- 1777. - }
- 1778. - },
- 1779. - onFail: function(msg) {
- 1780. - delete __cur.loadingRecs;
- 1781. - __cur.curSection = __cur.lastSection;
- 1782. - removeClass(__cur.recFilter, 'selected');
- 1783. - setTimeout(showFastBox(getLang('global_error'), msg).hide, 3000);
- 1784. - return true;
- 1785. - },
- 1786. - showProgress: function () {
- 1787. - addClass(rec_filter, 'loading');
- 1788. - },
- 1789. - hideProgress: function () {
- 1790. - removeClass(rec_filter, 'loading');
- 1791. - }
- 1792. - });
- 1793. - __cur.recsOffset += offset ? 50 : 100;
- 1794. - },
- 1795. -
- 1796. - loadPopular: function(opts) {
- 1797. - opts = opts || {};
- 1798. - var __cur = opts.from_pad ? window._pads && _pads.cur : window.cur,
- 1799. - from_pad = !!opts.from_pad, update = opts.update, genre = opts.genre;
- 1800. - if (__cur.silent) {
- 1801. - __cur.onSilentLoad = function() {
- 1802. - Audio.loadPopular(opts);
- 1803. - };
- 1804. - return;
- 1805. - }
- 1806. - if (__cur.loadingPopular) return;
- 1807. - if (__cur.popularAudios === undefined) {
- 1808. - __cur.popularAudios = [];
- 1809. - }
- 1810. - if (update) {
- 1811. - delete __cur.popularOffset;
- 1812. - delete __cur.popularIds;
- 1813. - delete __cur.popularAudios[genre];
- 1814. - delete __cur.preloadJSON;
- 1815. - if (genre !== undefined) {
- 1816. - __cur.genre = genre;
- 1817. - }
- 1818. - }
- 1819. - each(geByClass('audio_filter', __cur.albumFilters), function(i, e) {
- 1820. - removeClass(e, 'selected');
- 1821. - });
- 1822. - if (__cur.searchStr && isVisible(__cur.searchInfoCont)) {
- 1823. - hide(__cur.searchInfoCont);
- 1824. - }
- 1825. - if (from_pad && ge('pad_footer_text')) {
- 1826. - ge('pad_footer_text').innerHTML = '';
- 1827. - }
- 1828. - var genre_filter = false;
- 1829. - if (__cur.genre) {
- 1830. - var prevGenre = geByClass1('selected', __cur.popularGenres);
- 1831. - if (prevGenre) {
- 1832. - removeClass(prevGenre, 'selected');
- 1833. - }
- 1834. -
- 1835. - genre_filter = ge((from_pad ? 'pad_' : '') + 'audio_genre_'+__cur.genre);
- 1836. - if (genre_filter) {
- 1837. - addClass(genre_filter, 'selected');
- 1838. - } else {
- 1839. - __cur.genre = 0;
- 1840. - }
- 1841. - }
- 1842. - var pop_filter = __cur.topFilter;
- 1843. - addClass(pop_filter, 'selected');
- 1844. - removeClass(__cur.albumFiltered, 'selected');
- 1845. - toggle(__cur.audioFriends, false);
- 1846. - hide(__cur.searchInfoCont);
- 1847. - if (__cur.popularFilters) {
- 1848. - show(__cur.popularFilters);
- 1849. - Audio.hideAlbums({from_pad: from_pad});
- 1850. - } else {
- 1851. - Audio.showAlbums({from_pad: from_pad});
- 1852. - }
- 1853. - removeClass(__cur.albumFiltered, 'club_shown');
- 1854. - hide(__cur.searchFilters, __cur.popularOwners);
- 1855. - Audio.handleFilterPos();
- 1856. - __cur.curSection = 'popular';
- 1857. - if (__cur.popularOffset === undefined) {
- 1858. - __cur.popularOffset = 0;
- 1859. - } else {
- 1860. - addClass(__cur.showMore, 'loading');
- 1861. - }
- 1862. - if (__cur.popularIds === undefined) __cur.popularIds = [];
- 1863. - if (__cur.popularAudios[genre] === undefined) __cur.popularAudios[genre] = [];
- 1864. - if (__cur.popularCount === undefined) __cur.popularCount = 0;
- 1865. - if (__cur.sPreload.innerHTML) {
- 1866. - while (__cur.sPreload.firstChild) {
- 1867. - var el = __cur.sPreload.firstChild;
- 1868. - __cur.aContent.appendChild(el);
- 1869. - __cur.popularCount++;
- 1870. - }
- 1871. - if (from_pad && window.Pads && Pads.updateHeight) {
- 1872. - Pads.updateHeight();
- 1873. - }
- 1874. - }
- 1875. - if (__cur.preloadJSON) {
- 1876. - json = __cur.preloadJSON['all'];
- 1877. - var cur_order = __cur.popularCount;
- 1878. - for (var i in json) {
- 1879. - var audio = json[i];
- 1880. - audio._order = cur_order++;
- 1881. - if (indexOf(__cur.popularIds, audio[0]+"_"+audio[1]) == -1) {
- 1882. - __cur.popularIds.push(audio[0]+"_"+audio[1]);
- 1883. - __cur.popularAudios[genre].push(audio);
- 1884. - }
- 1885. - }
- 1886. - var aid = currentAudioId(), needs_update = __cur.popularOffset && (aid && __cur.popularIds && indexOf(__cur.popularIds, aid) != -1);
- 1887. - audioPlayer.genPlaylist(__cur.popularAudios[genre], needs_update);
- 1888. - }
- 1889. - if (__cur.noPopular) {
- 1890. - hide(__cur.showMore);
- 1891. - delete __cur.noPopular;
- 1892. - return;
- 1893. - }
- 1894. - __cur.loadingPopular = true;
- 1895. - __cur.lastAct = 'popular';
- 1896. - var offset = __cur.popularOffset, query = {act: 'get_popular', offset: offset},
- 1897. - needsUpdate = window.audioPlayer && audioPlayer.shuffle;
- 1898. - if (from_pad) {
- 1899. - query.from_pad = 1;
- 1900. - }
- 1901. - if (nav.objLoc.update) {
- 1902. - query.update = 1;
- 1903. - }
- 1904. - if (needsUpdate && !offset) query.offset = -1;
- 1905. - if (update == 'remix' || needsUpdate != __cur.popRemix) {
- 1906. - __cur.popRemix = needsUpdate;
- 1907. - query.remix = needsUpdate ? 1 : 0;
- 1908. - var aid = currentAudioId();
- 1909. - if (aid && window.audioPlaylist && audioPlaylist[aid] && audioPlaylist.address && audioPlaylist.address.indexOf('act=popular') > 0) {
- 1910. - query.current = aid;
- 1911. - }
- 1912. - }
- 1913. - if (__cur.topType !== undefined) {
- 1914. - query.type = __cur.topType;
- 1915. - delete __cur.topType;
- 1916. - }
- 1917. - if (__cur.genre) {
- 1918. - query.genre = __cur.genre;
- 1919. - }
- 1920. - ajax.post(Audio.address, query, {
- 1921. - onDone: function(rows, preload, json, preload_json, options, genres) {
- 1922. - delete __cur.loadingPopular;
- 1923. - if (__cur.lastAct != 'popular') return;
- 1924. - if (options.popularCount === 0 && offset) {
- 1925. - __cur.noPopular = true;
- 1926. - delete options.popularOffset;
- 1927. - }
- 1928. - if (json) {
- 1929. - json = eval('('+json+')');
- 1930. - json = json['all'];
- 1931. - var cur_order = __cur.popularCount;
- 1932. - for (var i in json) {
- 1933. - var audio = json[i];
- 1934. - audio._order = cur_order++;
- 1935. - if (indexOf(__cur.popularIds, audio[0]+"_"+audio[1]) == -1) {
- 1936. - __cur.popularIds.push(audio[0]+"_"+audio[1]);
- 1937. - __cur.popularAudios[genre].push(audio);
- 1938. - }
- 1939. - }
- 1940. - var aid = currentAudioId(), needs_update = query.offset && (aid && __cur.popularIds && indexOf(__cur.popularIds, aid) != -1);
- 1941. - audioPlayer.genPlaylist(__cur.popularAudios[genre], needs_update);
- 1942. - }
- 1943. - removeClass(__cur.showMore, 'loading');
- 1944. - if (offset) {
- 1945. - delete options.popularCount;
- 1946. - }
- 1947. - if (options) extend(__cur, options);
- 1948. - if (!offset) {
- 1949. - __cur.aContent.innerHTML = rows;
- 1950. - if (from_pad && window.Pads && Pads.updateHeight) {
- 1951. - Pads.updateHeight();
- 1952. - }
- 1953. - Audio.scrollToTop(from_pad);
- 1954. - }
- 1955. -
- 1956. - if (preload_json) {
- 1957. - __cur.preloadJSON = eval('('+preload_json+')');
- 1958. - } else {
- 1959. - __cur.preloadJSON = {};
- 1960. - }
- 1961. - __cur.sPreload.innerHTML = '';
- 1962. - var au = ce('div', {innerHTML: preload});
- 1963. - while (au.firstChild) {
- 1964. - if (!ge(au.firstChild.id)) {
- 1965. - var el = au.firstChild;
- 1966. - __cur.sPreload.appendChild(el);
- 1967. - } else {
- 1968. - au.removeChild(au.firstChild);
- 1969. - }
- 1970. - }
- 1971. -
- 1972. - if (__cur.popularCount) {
- 1973. - show(__cur.showMore);
- 1974. - } else {
- 1975. - hide(__cur.showMore);
- 1976. - }
- 1977. - if (update == 'remix') {
- 1978. - __cur.justShuffled = true;
- 1979. - }
- 1980. - if (genres) {
- 1981. - __cur.popularGenres.innerHTML = genres;
- 1982. - }
- 1983. - Audio.changeHTitle({from_pad: from_pad});
- 1984. - val(__cur.aSearch, '');
- 1985. - removeClass(__cur.clearSearch, 'shown');
- 1986. - __cur.searchStr = '';
- 1987. - __cur.album_id = 0;
- 1988. - Audio.hideSearchResults(from_pad);
- 1989. - hide(__cur.sShowMore);
- 1990. - if (!from_pad) {
- 1991. - delete nav.objLoc.q;
- 1992. - delete nav.objLoc.owner;
- 1993. - delete nav.objLoc.friend;
- 1994. - delete nav.objLoc.album_id;
- 1995. - delete nav.objLoc.club;
- 1996. - delete nav.objLoc.genre;
- 1997. - delete nav.objLoc.audio_id;
- 1998. - nav.objLoc.act = 'popular';
- 1999. - if (__cur.genre) {
- 2000. - nav.objLoc.genre = __cur.genre;
- 2001. - } else {
- 2002. - delete nav.objLoc.genre;
- 2003. - }
- 2004. - nav.setLoc(nav.objLoc);
- 2005. - }
- 2006. - var _a = window.audioPlayer;
- 2007. - if (_a && _a.showCurrentTrack) _a.showCurrentTrack();
- 2008. - if (window.tooltips) {
- 2009. - tooltips.destroyAll();
- 2010. - }
- 2011. - if (!from_pad) {
- 2012. - Audio.loadCurrentPlaylist();
- 2013. - }
- 2014. - if (options.infoJS) {
- 2015. - eval('(function(){' + options.infoJS + ';})()');
- 2016. - }
- 2017. - },
- 2018. - showProgress: function () {
- 2019. - addClass(genre_filter || pop_filter, 'loading');
- 2020. - },
- 2021. - hideProgress: function () {
- 2022. - removeClass(genre_filter || pop_filter, 'loading');
- 2023. - }
- 2024. - });
- 2025. - __cur.popularOffset += offset ? 50 : 100;
- 2026. - },
- 2027. -
- 2028. - loadFeed: function(opts) {
- 2029. - opts = opts || {};
- 2030. - var __cur = opts.from_pad ? window._pads && _pads.cur : window.cur,
- 2031. - from_pad = !!opts.from_pad, update = opts.update;
- 2032. - if (__cur.silent) {
- 2033. - __cur.onSilentLoad = function() {
- 2034. - Audio.loadFeed(opts);
- 2035. - };
- 2036. - return;
- 2037. - }
- 2038. - if (__cur.isFeedLoading) return;
- 2039. - __cur.isFeedLoading = true;
- 2040. - if (__cur.audiosList && __cur.audiosList['all'] && __cur.allAudiosIndex != 'all') {
- 2041. - __cur.allAudiosIndex = 'all';
- 2042. - this.indexAll({from_pad: from_pad});
- 2043. - var curEl = geByClass1('current', __cur.friendsList);
- 2044. - if (curEl) removeClass(curEl, 'current');
- 2045. - }
- 2046. - if (update) {
- 2047. - delete __cur.feedFrom;
- 2048. - delete __cur.feedOffset;
- 2049. - delete __cur.feedIds;
- 2050. - delete __cur.feedAudios;
- 2051. - if (update === 'reload') {
- 2052. - var params = {act: 'feed', part: 1, update: 1}, q = Audio.address + '#' + ajx2q(params);
- 2053. - delete window.ajaxCache[q];
- 2054. - }
- 2055. - }
- 2056. - each(geByClass('audio_filter', __cur.albumFilters), function(i, e) {
- 2057. - removeClass(e, 'selected');
- 2058. - });
- 2059. - if (__cur.searchStr && isVisible(__cur.searchInfoCont)) {
- 2060. - hide(__cur.searchInfoCont);
- 2061. - }
- 2062. - if (from_pad && ge('pad_footer_text')) {
- 2063. - ge('pad_footer_text').innerHTML = '';
- 2064. - }
- 2065. - addClass(__cur.feedFilter, 'selected');
- 2066. - removeClass(__cur.albumFiltered, 'selected');
- 2067. - hide(__cur.searchFilters, __cur.popularFilters, __cur.popularOwners);
- 2068. - if (from_pad || __cur.oid == vk.id) {
- 2069. - show(__cur.audioFriends);
- 2070. - hide(__cur.searchInfoCont);
- 2071. - Audio.hideAlbums({from_pad: from_pad});
- 2072. - }
- 2073. - removeClass(__cur.albumFiltered, 'club_shown');
- 2074. - Audio.handleFilterPos();
- 2075. - __cur.lastSection = __cur.curSection;
- 2076. - __cur.curSection = 'feed';
- 2077. - if (!update) {
- 2078. - addClass(__cur.showMore, 'loading');
- 2079. - }
- 2080. - __cur.lastAct = 'feed';
- 2081. - var query = {act: 'feed', offset: __cur.feedOffset, from: __cur.feedFrom, part: 1, update: update ? 1 : ''};
- 2082. - if (from_pad) {
- 2083. - query.from_pad = 1;
- 2084. - }
- 2085. - ajax.post(Audio.address, query, {
- 2086. - onDone: function (rows, script) {
- 2087. - if (__cur.lastAct != 'feed') return;
- 2088. - if (rows) {
- 2089. - if (update) {
- 2090. - __cur.aContent.innerHTML = rows;
- 2091. - } else {
- 2092. - var au = ce('div'), par = geByClass1('wall_module', __cur.aContent), row;
- 2093. - au.innerHTML = rows;
- 2094. - if (par && update) {
- 2095. - par.innerHTML = '';
- 2096. - }
- 2097. - while (row = au.firstChild) {
- 2098. - if (!row.id || ge(row.id)) {
- 2099. - au.removeChild(row);
- 2100. - continue;
- 2101. - }
- 2102. - if (par) {
- 2103. - par.appendChild(row);
- 2104. - }
- 2105. - }
- 2106. - }
- 2107. - } else {
- 2108. - hide(__cur.showMore);
- 2109. - }
- 2110. - if (from_pad && window.Pads && Pads.updateHeight) {
- 2111. - Pads.updateHeight();
- 2112. - }
- 2113. - if (script) {
- 2114. - eval(script);
- 2115. - }
- 2116. - var aid = currentAudioId(), needs_update = query.offset && (aid && __cur.feedIds && indexOf(__cur.feedIds, aid) != -1 && window.audioPlaylist && audioPlaylist.address && audioPlaylist.address.indexOf('act=feed') != -1);
- 2117. - audioPlayer.genPlaylist(__cur.feedAudios, needs_update);
- 2118. - removeClass(__cur.showMore, 'loading');
- 2119. - Audio.changeHTitle({from_pad: from_pad});
- 2120. - val(__cur.aSearch, '');
- 2121. - removeClass(__cur.clearSearch, 'shown');
- 2122. - __cur.searchStr = '';
- 2123. - __cur.album_id = 0;
- 2124. - Audio.hideSearchResults(from_pad);
- 2125. - hide(__cur.sShowMore);
- 2126. - if (update) {
- 2127. - Audio.scrollToTop(from_pad);
- 2128. - }
- 2129. - if (!from_pad) {
- 2130. - delete nav.objLoc.q;
- 2131. - delete nav.objLoc.owner;
- 2132. - delete nav.objLoc.friend;
- 2133. - delete nav.objLoc.album_id;
- 2134. - delete nav.objLoc.club;
- 2135. - delete nav.objLoc.genre;
- 2136. - delete nav.objLoc.audio_id;
- 2137. - delete __cur._back;
- 2138. - extend(nav.objLoc, {act: 'feed'});
- 2139. - nav.setLoc(nav.objLoc);
- 2140. - }
- 2141. - var _a = window.audioPlayer;
- 2142. - if (_a && _a.showCurrentTrack) _a.showCurrentTrack();
- 2143. - },
- 2144. - showProgress: function () {
- 2145. - __cur.isFeedLoading = true;
- 2146. - addClass(__cur.feedFilter, 'loading');
- 2147. - },
- 2148. - hideProgress: function () {
- 2149. - __cur.isFeedLoading = false;
- 2150. - removeClass(__cur.feedFilter, 'loading');
- 2151. - },
- 2152. - cache: 1
- 2153. - });
- 2154. - },
- 2155. -
- 2156. - loadCurrentPlaylist: function() {
- 2157. - if (!window.Pads || !Pads.showAudios || !window._pads || _pads.shown != 'mus') {
- 2158. - return;
- 2159. - }
- 2160. - var __cur = _pads.cur;
- 2161. - __cur.aContent.innerHTML = '';
- 2162. -
- 2163. - each(geByClass('audio_filter', __cur.albumFilters), function(i, e) {
- 2164. - removeClass(e, 'selected');
- 2165. - });
- 2166. - removeClass(__cur.albumFiltered, 'selected');
- 2167. - addClass(__cur.currentFilter, 'selected');
- 2168. - hide(__cur.popularFilters, __cur.popularOwners, __cur.searchFilters, __cur.searchInfoCont);
- 2169. - show(__cur.audioFriends, __cur.showMore, __cur.currentFilter);
- 2170. - Audio.hideAlbums({from_pad: true});
- 2171. -
- 2172. - val(__cur.aSearch, '');
- 2173. - removeClass(__cur.clearSearch, 'shown');
- 2174. - __cur.lastSection = __cur.curSection;
- 2175. - __cur.lastAct = __cur.searchStr = __cur.curSection = '';
- 2176. - __cur.album_id = 0;
- 2177. - Audio.hideSearchResults(true);
- 2178. -
- 2179. - Pads.showAudios();
- 2180. - },
- 2181. -
- 2182. - reorderPlaylist: function(aid, before_id, after_id) {
- 2183. - each([window.audioPlaylist, cur.nextPlaylist], function(i, e) {
- 2184. - var list = e;
- 2185. - if (before_id && !after_id && list && list[before_id]) {
- 2186. - after_id = list[before_id]._prev;
- 2187. - }
- 2188. - if (list && list[aid] && after_id && list[after_id] && after_id != aid) {
- 2189. - var next_id = list[aid]._next, prev_id = list[aid]._prev;
- 2190. - if (next_id != aid) {
- 2191. - list[next_id]._prev = prev_id;
- 2192. - list[prev_id]._next = next_id;
- 2193. - list[aid]._prev = after_id;
- 2194. - list[aid]._next = list[after_id]._next;
- 2195. - list[after_id]._next = list[list[after_id]._next]._prev = aid;
- 2196. - }
- 2197. - }
- 2198. - });
- 2199. - var plist = ls.get('pad_playlist');
- 2200. - if (plist && plist[aid] && after_id && plist[after_id] && after_id != aid && window.audioPlayer) {
- 2201. - audioPlayer.setPadPlaylist();
- 2202. - }
- 2203. - },
- 2204. -
- 2205. - removeFromPlaylist: function(aid) {
- 2206. - each([window.audioPlaylist, cur.nextPlaylist], function(i, e) {
- 2207. - var list = e;
- 2208. - if (list && list[aid]) {
- 2209. - var next_id = list[aid]._next, prev_id = list[aid]._prev;
- 2210. - if (next_id != aid) {
- 2211. - // delete list[aid];
- 2212. - list[next_id]._prev = prev_id;
- 2213. - list[prev_id]._next = next_id;
- 2214. - }
- 2215. - }
- 2216. - });
- 2217. - var plist = ls.get('pad_playlist');
- 2218. - if (plist && plist[aid] && window.audioPlayer) {
- 2219. - audioPlayer.setPadPlaylist();
- 2220. - }
- 2221. - },
- 2222. -
- 2223. - backToPlaylist: function(aid) {
- 2224. - each([window.audioPlaylist, cur.nextPlaylist], function(i, e) {
- 2225. - var list = e;
- 2226. - if (list && list[aid]) {
- 2227. - var next_id = list[aid]._next, prev_id = list[aid]._prev;
- 2228. - if (next_id != aid) {
- 2229. - list[next_id]._prev = list[prev_id]._next = aid;
- 2230. - }
- 2231. - }
- 2232. - });
- 2233. - var plist = ls.get('pad_playlist');
- 2234. - if (plist && plist[aid] && window.audioPlayer) {
- 2235. - audioPlayer.setPadPlaylist();
- 2236. - }
- 2237. - },
- 2238. -
- 2239. - hideRecommendation: function(aid, q, hash, event) {
- 2240. - if (window.audioPlayer && currentAudioId() == aid) {
- 2241. - audioPlayer.nextTrack(true);
- 2242. - }
- 2243. - var recRow = ge('audio'+aid);
- 2244. - if (recRow) {
- 2245. - if (window.tooltips) {
- 2246. - tooltips.hide(ge('remove'+aid))
- 2247. - }
- 2248. - slideUp(recRow, 200, function() {
- 2249. - recRow.parentNode.removeChild(recRow);
- 2250. - Audio.removeFromPlaylist(aid);
- 2251. - cur.recsCount--;
- 2252. - Audio.changeHTitle();
- 2253. - });
- 2254. - }
- 2255. - ajax.post(Audio.address, {act: 'hide_recommendation', q: q, hash: hash});
- 2256. - if (event) cancelEvent(event);
- 2257. - return false;
- 2258. - },
- 2259. -
- 2260. - _animDelX: function(el, opacity, set_active) {
- 2261. - if (!el) return;
- 2262. - if (set_active !== undefined) {
- 2263. - el.active = set_active;
- 2264. - } else if (el.active) {
- 2265. - return;
- 2266. - }
- 2267. - animate(el, {opacity: opacity}, 200);
- 2268. - },
- 2269. -
- 2270. - rowActive: function(el, tt, sh) {
- 2271. - Audio._animDelX(el, 1, 1);
- 2272. - if (tt) showTooltip(el, {text: tt, showdt: 0, black: 1, shift: (sh ? sh : [12, 4, 0])});
- 2273. - },
- 2274. - rowInactive: function(el, light) {
- 2275. - var opacity = light ? 0.6 : 0.4;
- 2276. - Audio._animDelX(el, opacity, 0);
- 2277. - },
- 2278. -
- 2279. - selectFriend: function(opts, ev) {
- 2280. - opts = opts || {};
- 2281. - var __cur = opts.from_pad ? window._pads && _pads.cur : window.cur,
- 2282. - from_pad = !!opts.from_pad, id = opts.id;
- 2283. - if (__cur.skipSelectFriend) {
- 2284. - __cur.skipSelectFriend = false;
- 2285. - return;
- 2286. - }
- 2287. - each(geByTag('div', __cur.audioFriends), function(i, e) {
- 2288. - removeClass(e, 'current');
- 2289. - });
- 2290. - addClass(ge((from_pad ? 'pad_' : '') + 'audio_friend' + id), 'current');
- 2291. - addClass(ge((from_pad ? 'pad_' : '') + 'album0'), 'loading');
- 2292. - each(geByClass('audio_filter', __cur.albumFilters), function(i, e) {
- 2293. - removeClass(e, 'selected');
- 2294. - });
- 2295. - Audio.loadFriendsAudios({id: id, index: 'friend' + id, from_pad: from_pad});
- 2296. - if (id && (__cur.oid == vk.id || from_pad)) {
- 2297. - ajax.post(Audio.address, {act: 'list_stats', owner: id});
- 2298. - }
- 2299. - return ev ? cancelEvent(ev) : false;
- 2300. - },
- 2301. - skipSelectFriend: function(opts) {
- 2302. - opts = opts || {};
- 2303. - var __cur = opts.from_pad ? window._pads && _pads.cur : window.cur;
- 2304. - __cur.skipSelectFriend = true;
- 2305. - },
- 2306. - selectCommunity: function(opts, ev) {
- 2307. - opts = opts || {};
- 2308. - var __cur = opts.from_pad ? window._pads && _pads.cur : window.cur,
- 2309. - from_pad = !!opts.from_pad, id = opts.id;
- 2310. - if (__cur.skipSelectCommunity) {
- 2311. - __cur.skipSelectCommunity = false;
- 2312. - return;
- 2313. - }
- 2314. - each(geByClass('audio_friend', __cur.searchInfoCont), function(i, e) {
- 2315. - removeClass(e, 'current');
- 2316. - });
- 2317. - addClass(ge((from_pad ? 'pad_' : '') + 'audio_community' + id), 'current');
- 2318. - mentionOver(ge((from_pad ? 'pad_' : '') + 'audio_community' + id), {shift: [47, 7, 7]});
- 2319. - each(geByClass('audio_filter', __cur.albumFilters), function(i, e) {
- 2320. - removeClass(e, 'selected');
- 2321. - });
- 2322. - addClass(__cur.albumFiltered, 'club_shown');
- 2323. - __cur.searchSortFilter.disable(true);
- 2324. - __cur.searchLyricsFilter.disable(true);
- 2325. - removeClass(__cur.albumFiltered, 'selected');
- 2326. - __cur.club = id;
- 2327. - Audio.loadCommunityAudios({from_pad: from_pad, gid: id, index: 'club' + id});
- 2328. - if (id && (__cur.oid == vk.id || from_pad)) {
- 2329. - ajax.post(Audio.address, {act: 'list_stats', club: id});
- 2330. - }
- 2331. - return ev ? cancelEvent(ev) : false;
- 2332. - },
- 2333. - skipSelectCommunity: function(opts) {
- 2334. - opts = opts || {};
- 2335. - var __cur = opts.from_pad ? window._pads && _pads.cur : window.cur;
- 2336. - __cur.skipSelectCommunity = true;
- 2337. - },
- 2338. - backToSearch: function(from_pad) {
- 2339. - var __cur = from_pad ? window._pads && _pads.cur : window.cur;
- 2340. - if (__cur.curSection && __cur.curSection.substr(0, 4) == 'club') {
- 2341. - __cur.ignoreEqual = true;
- 2342. - each(geByClass('audio_friend', __cur.searchInfoCont), function() {
- 2343. - removeClass(this, 'current');
- 2344. - });
- 2345. - this.updateList({from_pad: from_pad});
- 2346. - }
- 2347. - },
- 2348. - playCurrent: function(el, hash, ev) {
- 2349. - var _a = window.audioPlayer, aid = currentAudioId(), audioId = el.getAttribute('data-audio');
- 2350. - if (_a) _a.gpDisabled = false;
- 2351. - if ((window.audioPlaylist || {})[audioId]) {
- 2352. - if (!_a || aid != audioId || _a.player.paused()) playAudioNew(audioId);
- 2353. - return cancelEvent(ev);
- 2354. - }
- 2355. -
- 2356. - var prg = el.nextSibling || el.parentNode.appendChild(ce('span', {className: 'progress_inline current_audio_prg'}));
- 2357. - stManager.add(['audioplayer.css', 'audioplayer.js'], ajax.post.pbind(Audio.address, {act: 'play_audio_status', id: audioId, hash: hash}, {
- 2358. - onDone: function(info, data, uid) {
- 2359. - if (data && uid) {
- 2360. - audioPlayer.statusData = audioPlayer.statusData || {};
- 2361. - audioPlayer.statusData[uid] = data;
- 2362. - }
- 2363. - if (!info) return;
- 2364. -
- 2365. - if (!window.audioPlaylist) {
- 2366. - window.audioPlaylist = {};
- 2367. - }
- 2368. - audioPlaylist[audioId] = info;
- 2369. - audioPlaylist.start = audioId;
- 2370. - if (data && uid) {
- 2371. - audioPlaylist.statusData = data;
- 2372. - } else {
- 2373. - delete audioPlaylist.statusData;
- 2374. - }
- 2375. - audioPlayer.setPadPlaylist(audioPlaylist);
- 2376. - playAudioNew(audioId);
- 2377. - },
- 2378. - showProgress: function() {
- 2379. - show(prg);
- 2380. - hide(el);
- 2381. - },
- 2382. - hideProgress: function() {
- 2383. - hide(prg);
- 2384. - show(el);
- 2385. - }
- 2386. - }));
- 2387. - return cancelEvent(ev);
- 2388. - },
- 2389. - loadFriendsAudios: function(opts) {
- 2390. - opts = opts || {};
- 2391. - var __cur = opts.from_pad ? window._pads && _pads.cur : window.cur,
- 2392. - from_pad = !!opts.from_pad, id = opts.id, index = opts.index, str = opts.str,
- 2393. - album = opts.album, showAlbums = opts.showAlbums, owner = opts.owner;
- 2394. - if (__cur.silent) {
- 2395. - __cur.onSilentLoad = function() {
- 2396. - Audio.loadFriendsAudios(opts);
- 2397. - };
- 2398. - return;
- 2399. - }
- 2400. - if (!__cur.audiosList[index]) {
- 2401. - if (index == 'all') {
- 2402. - each(geByClass('audio_filter', __cur.albumFilters), function(i, e) {
- 2403. - removeClass(e, 'selected');
- 2404. - });
- 2405. - if (showAlbums) {
- 2406. - addClass(__cur.albumsFilter, 'loading');
- 2407. - } else if (album) {
- 2408. - addClass(ge((from_pad ? 'pad_' : '') + 'album' + album), 'selected loading');
- 2409. - } else {
- 2410. - addClass(ge((from_pad ? 'pad_' : '') + 'album0'), 'selected loading');
- 2411. - }
- 2412. - removeClass(__cur.albumFiltered, 'selected');
- 2413. - }
- 2414. - __cur.lastAct = index;
- 2415. - var query = {act: 'load_audios_silent', id: id, claim: nav.objLoc.claim, please_dont_ddos: 3};
- 2416. - if (owner) {
- 2417. - query.is_owner = 1;
- 2418. - }
- 2419. - if (index != 'all' && !ge((from_pad ? 'pad_' : '') + 'audio_friend' + id) && !owner) {
- 2420. - __cur.shownFriends = [];
- 2421. - var txt = domFC(ge(__cur.audioMoreFriensId)), prg = domLC(ge(__cur.audioMoreFriensId));
- 2422. - Audio.showMoreFriends({from_pad: from_pad, onShow: function() {
- 2423. - hide(txt);
- 2424. - show(prg);
- 2425. - }, onHide: function() {
- 2426. - hide(prg);
- 2427. - show(txt);
- 2428. - }, friend: id});
- 2429. - }
- 2430. - ajax.post(Audio.address, query, {
- 2431. - cache: 1,
- 2432. - onDone: function(data, options) {
- 2433. - if (__cur.lastAct != index) return;
- 2434. - options = eval('('+options+')');
- 2435. - if (options.summaryLang) {
- 2436. - __cur.summaryLang = extend(__cur.summaryLang || {}, options.summaryLang);
- 2437. - }
- 2438. - if (id < 0) {
- 2439. - __cur.allFriendsHTitles = __cur.allFriendsHTitles || {};
- 2440. - __cur.allFriendsHTitles[id] = options.summaryLang.all_club_htitle;
- 2441. - } else {
- 2442. - __cur.allFriendsTitles = __cur.allFriendsTitles || {};
- 2443. - __cur.allFriendsTitles[id] = options.summaryLang.all_friend_title;
- 2444. - __cur.allFriendsHTitles = __cur.allFriendsHTitles || {};
- 2445. - __cur.allFriendsHTitles[id] = options.summaryLang.all_friend_htitle;
- 2446. - }
- 2447. - var obj = eval('('+data+')');
- 2448. - if (!obj) return;
- 2449. - __cur.audiosList[index] = obj['all'];
- 2450. - if (id == vk.id && index == 'all') {
- 2451. - __cur.allAudiosIndex = 'all';
- 2452. - Audio.generateAlbums(from_pad);
- 2453. - }
- 2454. - if (!__cur.performerInfo) {
- 2455. - __cur.performerInfo = {};
- 2456. - }
- 2457. - __cur.performerInfo[index] = options.performerInfo;
- 2458. - if (options.backLink && !from_pad) {
- 2459. - __cur.backLink = options.backLink;
- 2460. - showBackLink('/audio?act=popular'+(__cur.genre ? '&genre='+__cur.genre : ''), __cur.backLink);
- 2461. - }
- 2462. - if (index != 'all') __cur.audioFriend = id;
- 2463. - Audio.changeAllIndex({from_pad: from_pad, index: index, album: album, showAlbums: showAlbums, owner: owner, str: str});
- 2464. - Audio.cacheFriendsList(from_pad);
- 2465. - }
- 2466. - });
- 2467. - } else {
- 2468. - if (index != 'all') __cur.audioFriend = id;
- 2469. - if (owner && !from_pad) {
- 2470. - showBackLink('/audio?act=popular'+(__cur.genre ? '&genre='+__cur.genre : ''), __cur.backLink);
- 2471. - }
- 2472. - Audio.changeAllIndex({from_pad: from_pad, index: index, album: album, showAlbums: showAlbums, owner: owner, str: str});
- 2473. - }
- 2474. - },
- 2475. - loadCommunityAudios: function(opts) {
- 2476. - opts = opts || {};
- 2477. - var __cur = opts.from_pad ? window._pads && _pads.cur : window.cur,
- 2478. - from_pad = !!opts.from_pad, gid = opts.gid, index = opts.index;
- 2479. - if (__cur.silent) {
- 2480. - __cur.onSilentLoad = function() {
- 2481. - Audio.loadCommunityAudios(opts);
- 2482. - };
- 2483. - return;
- 2484. - }
- 2485. - if (!__cur.audiosList[index]) {
- 2486. - __cur.lastAct = index;
- 2487. - ajax.post(Audio.address, {act: 'load_audios_silent', gid: gid, claim: nav.objLoc.claim, please_dont_ddos: 1}, {
- 2488. - cache: 1,
- 2489. - showProgress: addClass.pbind(ge((from_pad ? 'pad_' : '') + 'album0'), 'loading'),
- 2490. - hideProgress: removeClass.pbind(ge((from_pad ? 'pad_' : '') + 'album0'), 'loading'),
- 2491. - onDone: function(data, options) {
- 2492. - if (__cur.lastAct != index) return;
- 2493. - options = eval('('+options+')');
- 2494. - __cur.allClubsHTitles = __cur.allClubsHTitles || {};
- 2495. - __cur.allClubsHTitles[gid] = options.summaryLang.all_club_htitle;
- 2496. - var obj = eval('('+data+')');
- 2497. - if (!obj) return;
- 2498. - __cur.audiosList[index] = obj['all'];
- 2499. - Audio.searchAudios({from_pad: from_pad, type: index, str: ''});
- 2500. - Audio.scrollToTop(from_pad);
- 2501. - }
- 2502. - });
- 2503. - } else {
- 2504. - Audio.searchAudios({from_pad: from_pad, type: index, str: ''});
- 2505. - Audio.scrollToTop(from_pad);
- 2506. - }
- 2507. - },
- 2508. - showMoreFriends: function(opts) {
- 2509. - opts = opts || {};
- 2510. - var __cur = opts.from_pad ? window._pads && _pads.cur : window.cur,
- 2511. - from_pad = !!opts.from_pad, friend = opts.friend,
- 2512. - onShow = opts.onShow || function() {}, onHide = opts.onHide || function() {};
- 2513. - if (__cur.moreFriendsSent) {
- 2514. - return;
- 2515. - }
- 2516. - __cur.moreFriendsSent = true;
- 2517. - var query = {act: 'more_friends', ids: __cur.shownFriends};
- 2518. - if (friend) {
- 2519. - query.owner = friend;
- 2520. - }
- 2521. - if (from_pad) {
- 2522. - query.from_pad = 1;
- 2523. - }
- 2524. - ajax.post(Audio.address, query, {
- 2525. - onDone: function(cont, friends, reset) {
- 2526. - __cur.moreFriendsSent = false;
- 2527. - if (cont) {
- 2528. - var list = __cur.friendsList;
- 2529. - re('audio_friends_old');
- 2530. - var old = ce('div', {innerHTML: '<div id="audio_friends_old" style="position: absolute; top: ' + list.offsetTop + 'px">'+list.innerHTML+'</div>'}).firstChild;
- 2531. - list.parentNode.insertBefore(old, list);
- 2532. - list.innerHTML = '';
- 2533. - setStyle(list, {display: 'none'});
- 2534. - list.innerHTML = cont;
- 2535. - var oldRows = geByClass('audio_friend', old), oldCnt = oldRows.length,
- 2536. - newCnt = geByClass('audio_friend', list).length;
- 2537. - if (oldCnt > newCnt) {
- 2538. - oldRows = oldRows.slice(newCnt);
- 2539. - each(oldRows, function() {
- 2540. - re(this);
- 2541. - });
- 2542. - }
- 2543. - setTimeout(Audio.handleFilterPos, 0);
- 2544. - fadeIn(list, 400, re.pbind(old));
- 2545. - if (friends) {
- 2546. - __cur.shownFriends = reset ? friends : __cur.shownFriends.concat(friends);
- 2547. - }
- 2548. - } else {
- 2549. - Audio.handleFilterPos();
- 2550. - }
- 2551. - },
- 2552. - onFail: function() {
- 2553. - __cur.moreFriendsSent = false;
- 2554. - },
- 2555. - showProgress: onShow,
- 2556. - hideProgress: onHide
- 2557. - });
- 2558. - },
- 2559. - cacheFriendsList: function(from_pad) {
- 2560. - var __cur = from_pad ? window._pads && _pads.cur : window.cur,
- 2561. - query = {act: 'more_friends'};
- 2562. - if (__cur.audioFriendPlaying) query.owner = __cur.audioFriendPlaying;
- 2563. - else if (__cur.audioFriend) query.owner = __cur.audioFriend;
- 2564. - ajax.post(Audio.address, query, {cache: 1});
- 2565. - },
- 2566. -
- 2567. - // Audio Edit functions
- 2568. -
- 2569. - showAudioClaimWarning: function(aid, claim_id, title, reason) {
- 2570. - if (cur.silent) {
- 2571. - cur.onSilentLoad = function() {
- 2572. - Audio.showAudioClaimWarning(aid, claim_id, title, reason);
- 2573. - };
- 2574. - return;
- 2575. - }
- 2576. - var claimText, claimTitle;
- 2577. - if (reason == 'crap') {
- 2578. - 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'));
- 2579. - claimTitle = getLang('audio_crap_warning_title') || getLang('audio_claim_warning_title');
- 2580. - } else {
- 2581. - claimText = (claim_id > 0) ? getLang('audio_claim_warning_objection') : (claim_id == 0 ? getLang('audio_claim_warning_text') : getLang('audio_claim_warning'));
- 2582. - claimTitle = getLang('audio_claim_warning_title');
- 2583. - }
- 2584. - claimText = claimText.split('{audio}').join('<b>' + title + '</b>');
- 2585. - claimText = claimText.split('{objection_link}').join('<a href="/help?act=cc_objection&claim=' + claim_id + '&content=audio' + aid + '">' + getLang('audio_claim_objection') + '</a>');
- 2586. - claimText = claimText.split('{delete_link}').join('<a href="#" onclick="Audio.deleteAudio(\'' + aid + '\'); return false;">' + getLang('audio_claim_delete') + '</a>');
- 2587. - cur.claimWarning = showFastBox(claimTitle, claimText);
- 2588. - },
- 2589. -
- 2590. - deleteAudio: function(id) {
- 2591. - if (cur.silent) {
- 2592. - cur.onSilentLoad = function() {
- 2593. - Audio.deleteAudio(id);
- 2594. - };
- 2595. - return;
- 2596. - }
- 2597. - if (cur.deleting) {
- 2598. - return false;
- 2599. - }
- 2600. - cur.deleting = true;
- 2601. - var el = ge('audio' + id), aid = id.split('_')[1];
- 2602. - if (!cur.deletedAudios) cur.deletedAudios = [];
- 2603. - cur.deletedAudios[aid] = el.innerHTML;
- 2604. - var acts = geByClass1('actions', el);
- 2605. - each(acts.children, function(){if (this.tt && this.tt.hide) this.tt.hide()});
- 2606. - var a = (cur.audios || {})[aid] || [], lyrics = isVisible(ge('lyrics'+id)),
- 2607. - _tw = el && geByClass1('title_wrap', el),
- 2608. - performer = a[5] || _tw && (geByTag1('a', _tw) || {}).innerHTML || '',
- 2609. - title = a[6] || _tw && (geByClass1('title', _tw) || {}).innerHTML || '';
- 2610. - el.innerHTML = rs(cur.deletedTpl, {
- 2611. - audio_id: id,
- 2612. - performer: performer.split('<span>').join('').split('</span>').join(''),
- 2613. - title: title,
- 2614. - delete_all: ''
- 2615. - });
- 2616. - var _a = window.audioPlayer;
- 2617. - if (currentAudioId() == id) {
- 2618. - _a.showCurrentTrack();
- 2619. - }
- 2620. - if (lyrics) {
- 2621. - Audio.updateSorterRows(ge('audio'+id));
- 2622. - }
- 2623. - var addBtn = ge('audio_add'+id);
- 2624. - if (addBtn) {
- 2625. - addBtn.onmouseover = function() {};
- 2626. - }
- 2627. - ajax.post(Audio.address, {act: 'delete_audio', oid: cur.oid, aid: aid, hash: cur.hashes.delete_hash, restore: 1}, {
- 2628. - onDone: function(action, delete_all) {
- 2629. - cur.deleting = false;
- 2630. - if (cur.claimWarning) {
- 2631. - cur.claimWarning.hide();
- 2632. - }
- 2633. - var acts = geByClass1('actions', el);
- 2634. - each(acts.children, function(){if (this.tt) this.tt.hide()});
- 2635. - el.innerHTML = rs(cur.deletedTpl, {
- 2636. - audio_id: id,
- 2637. - performer: performer.split('<span>').join('').split('</span>').join(''),
- 2638. - title: title,
- 2639. - delete_all: action ? action : ''
- 2640. - });
- 2641. - el.style.cursor = 'auto';
- 2642. - el.setAttribute('nosorthandle', '1');
- 2643. - if (currentAudioId() == id) {
- 2644. - _a.showCurrentTrack();
- 2645. - }
- 2646. - if (delete_all) {
- 2647. - cur.lang = cur.lang || {};
- 2648. - cur.lang.audio_delete_all = delete_all;
- 2649. - }
- 2650. - if (cur.audios[aid]) {
- 2651. - cur.audiosIndex.remove(cur.audios[aid]);
- 2652. - cur.audios[aid].deleted = true;
- 2653. - if (window.Pads && Pads.clearAudioLoadCache) {
- 2654. - Pads.clearAudioLoadCache();
- 2655. - }
- 2656. - }
- 2657. - Audio.removeFromPlaylist(id);
- 2658. - cur.sectionCount--;
- 2659. - if (cur.shownAudios) cur.shownAudios--;
- 2660. - Audio.changeSummary();
- 2661. - },
- 2662. - onFail: function() {
- 2663. - cur.deleting = false;
- 2664. - }
- 2665. - });
- 2666. - return false;
- 2667. - },
- 2668. -
- 2669. - restoreAudio: function(id) {
- 2670. - if (cur.restoring) {
- 2671. - return;
- 2672. - }
- 2673. - cur.restoring = true;
- 2674. - var el = ge('audio' + id), aid = id.split('_')[1];
- 2675. - ajax.post(Audio.address, {act: 'restore_audio', oid: cur.oid, aid: aid, hash: cur.hashes.restore_hash}, {
- 2676. - onDone: function() {
- 2677. - cur.restoring = false;
- 2678. - var acts = geByClass1('actions', el);
- 2679. - each(acts.children, function(){if (this.tt) this.tt.hide()});
- 2680. - el.innerHTML = cur.deletedAudios[aid];
- 2681. - var lyrics = isVisible(ge('lyrics'+id));
- 2682. - if (lyrics) {
- 2683. - Audio.updateSorterRows(ge('audio'+id));
- 2684. - }
- 2685. - el.removeAttribute('nosorthandle');
- 2686. - if (cur.audios[aid]) {
- 2687. - cur.audiosIndex.add(cur.audios[aid]);
- 2688. - cur.audios[aid].deleted = false;
- 2689. - if (window.Pads && Pads.clearAudioLoadCache) {
- 2690. - Pads.clearAudioLoadCache();
- 2691. - }
- 2692. - }
- 2693. - Audio.backToPlaylist(id);
- 2694. - cur.sectionCount++;
- 2695. - if (cur.shownAudios) cur.shownAudios++;
- 2696. - Audio.changeSummary();
- 2697. - toggleClass(ge('play'+id), 'playing', id == currentAudioId());
- 2698. - },
- 2699. - onFail: function() {
- 2700. - cur.restoring = false;
- 2701. - }
- 2702. - });
- 2703. - },
- 2704. -
- 2705. - deleteAll: function(object_id, from_id, to_id, hash) {
- 2706. - var box = showFastBox(getLang('audio_delete_all_title'), getLang('audio_delete_all') || '', getLang('global_delete'), function(btn){
- 2707. - ajax.post(Audio.address, {act: 'delete_all', object_id: object_id, to_id: to_id, from_id: from_id, hash: hash}, {
- 2708. - showProgress: lockButton.pbind(btn),
- 2709. - onDone: function() {
- 2710. - nav.reload();
- 2711. - },
- 2712. - onFail: box.hide
- 2713. - });
- 2714. - }, getLang('global_cancel'));
- 2715. - },
- 2716. -
- 2717. - editAudio: function(aid, event){
- 2718. - showBox(Audio.address, {act: 'edit_audio_box', aid: aid}, {
- 2719. - params: {width: '430px', bodyStyle: 'padding: 15px;'}
- 2720. - });
- 2721. - if (event) cancelEvent(event);
- 2722. - return false;
- 2723. - },
- 2724. -
- 2725. - editTopAudio: function(full_aid, event) {
- 2726. - showBox('al_search.php', {act: 'audio_top_edit_box', id: full_aid, full_id: full_aid}, {
- 2727. - params: {width: '430px', bodyStyle: 'padding: 15px;'}
- 2728. - });
- 2729. - if (event) cancelEvent(event);
- 2730. - return false;
- 2731. - },
- 2732. -
- 2733. - removeFromTop: function(audio_hash, hash, full_aid, event) {
- 2734. - ajax.post('al_search.php', {act: 'save_top_audio', deleted: 1, audio_hash: audio_hash, hash: hash, id: full_aid}, {
- 2735. - onDone: function() {
- 2736. - var audioRow = ge('audio'+full_aid);
- 2737. - slideUp(audioRow, 100);
- 2738. - }
- 2739. - })
- 2740. - },
- 2741. -
- 2742. - updateAlbumsStart: function() {
- 2743. - if (!cur.canEdit || browser.mobile || !cur.audioAlbumsWrap || !cur.audioAlbumsWrap.sorter) return;
- 2744. - each (cur.audioAlbumsWrap.sorter.elems, function() {
- 2745. - setStyle(this, {top: 'auto', left: 'auto', width: 'auto'});
- 2746. - });
- 2747. - cur.audioAlbumsWrap.sorter.destroy();
- 2748. - },
- 2749. -
- 2750. - updateAlbumsFinish: function() {
- 2751. - if (!cur.canEdit || browser.mobile) return;
- 2752. - this.initAlbumsSort();
- 2753. - this.updateAlbumsTitles();
- 2754. - },
- 2755. -
- 2756. - updateAlbums: function() {
- 2757. - this.updateAlbumsStart();
- 2758. - this.updateAlbumsFinish();
- 2759. - },
- 2760. -
- 2761. - updateAlbumsTitles: function(opts) {
- 2762. - opts = opts || {};
- 2763. - var __cur = opts.from_pad ? window._pads && _pads.cur : window.cur,
- 2764. - from_pad = !!opts.from_pad;
- 2765. -
- 2766. - if (!__cur.audioAlbumsWrap) return;
- 2767. -
- 2768. - each (geByClass('label', __cur.audioAlbumsWrap), function() {
- 2769. - if (this.scrollWidth > this.clientWidth) {
- 2770. - this.setAttribute('title', this.innerText || this.textContent);
- 2771. - } else {
- 2772. - this.removeAttribute('title');
- 2773. - }
- 2774. - });
- 2775. - },
- 2776. -
- 2777. - updatePadFiltersHeight: function() {
- 2778. - var filters = ge('pad_side_filters'), td = ge('pad_filters_panel'),
- 2779. - curSz = getSize(td)[1], minSz = getSize(_pads.content)[1],
- 2780. - newSz = Math.max(minSz, getSize(filters)[1] + 10);
- 2781. - if (newSz != curSz) {
- 2782. - setStyle(td, {height: newSz});
- 2783. - if (window.Pads) {
- 2784. - Pads.updateHeight();
- 2785. - }
- 2786. - }
- 2787. - },
- 2788. -
- 2789. - initAlbumsSort: function() {
- 2790. - if (!cur.canEdit || browser.mobile || !cur.audioAlbumsWrap || cur.audioAlbumsWrap.sorter) return;
- 2791. - sorter.init(cur.audioAlbumsWrap, {onMouseDown: Audio.hideAlbumsTT, onReorder: Audio.onAlbumReorder, noMoveCursor: 1});
- 2792. - },
- 2793. -
- 2794. - hideAlbumsTT: function() {
- 2795. - each(geByClass('icon_wrap', cur.audioAlbumsWrap), function() {
- 2796. - if (this.tt) this.tt.hide();
- 2797. - })
- 2798. - },
- 2799. -
- 2800. - onAlbumReorder: function(album, before, after) {
- 2801. - var aid = album.id.replace('album', '');
- 2802. - var before_id = (before && before.id || '').replace('album', '');
- 2803. - var after_id = (after && after.id || '').replace('album', '');
- 2804. - ajax.post(Audio.address, {act: 'reorder_albums', oid: cur.oid, aid: aid, before: before_id, after: after_id, hash: cur.hashes.reorder_hash});
- 2805. - },
- 2806. -
- 2807. - editAlbum: function(aid){
- 2808. - if (cur.silent) {
- 2809. - cur.onSilentLoad = function() {
- 2810. - Audio.editAlbum(aid);
- 2811. - };
- 2812. - return;
- 2813. - }
- 2814. - if (!cur.audiosList) {
- 2815. - return;
- 2816. - }
- 2817. - 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']});
- 2818. - cur.onOListSave = Audio.saveAlbum.pbind(box, aid);
- 2819. - return false;
- 2820. - },
- 2821. -
- 2822. - createAlbum: function() {
- 2823. - return this.editAlbum(0);
- 2824. - },
- 2825. -
- 2826. - saveAlbum: function(box, aid, audio_ids) {
- 2827. - var btn = geByClass1('button_blue', box.bodyNode.nextSibling).firstChild,
- 2828. - albumName = val('album_name');
- 2829. - if (!albumName) {
- 2830. - notaBene('album_name');
- 2831. - return false;
- 2832. - }
- 2833. - var query = {act: 'save_album', album_id: aid, name: albumName, gid: cur.gid, Audios: audio_ids.join(','), hash: cur.hashes.save_album_hash};
- 2834. - ajax.post(Audio.address, query, {
- 2835. - showProgress: lockButton.pbind(btn),
- 2836. - hideProgress: unlockButton.pbind(btn),
- 2837. - onFail: box.hide,
- 2838. - onDone: function(album_id, audio_ids, filters) {
- 2839. - try{
- 2840. - cur.audioAlbumsWrap.innerHTML = filters;
- 2841. - var old = cur.audiosList['album'+album_id];
- 2842. - if (old) {
- 2843. - for (var i in old) {
- 2844. - cur.audios[old[i][1]][8] = 0;
- 2845. - }
- 2846. - }
- 2847. - for (var i in audio_ids) {
- 2848. - cur.audios[audio_ids[i]][8] = album_id;
- 2849. - }
- 2850. - cur.albums[album_id] = {id: album_id, title: clean(albumName)};
- 2851. - Audio.generateAlbums();
- 2852. - Audio.loadAlbum({album: album_id});
- 2853. - Audio.initAlbumsSort();
- 2854. - Audio.updateAlbumsTitles();
- 2855. - box.hide();
- 2856. - }catch(e){}
- 2857. - }
- 2858. - });
- 2859. - return false;
- 2860. - },
- 2861. -
- 2862. - deleteAlbum: function(aid, hash){
- 2863. - var box = showFastBox(getLang('audio_delete_album_title'), getLang('audio_delete_album_are_you_sure'), getLang('audio_delete_album_button'), function(btn){
- 2864. - ajax.post(Audio.address, {act: 'delete_album', album_id: aid, hash: hash, gid: cur.gid}, {
- 2865. - showProgress: lockButton.pbind(btn),
- 2866. - hideProgress: unlockButton.pbind(btn),
- 2867. - onDone: function(audio_ids, filters){
- 2868. - try{
- 2869. - re('album'+aid);
- 2870. - boxQueue.hideAll();
- 2871. - for (var i in audio_ids) {
- 2872. - cur.audios[audio_ids[i]][8] = 0;
- 2873. - }
- 2874. - delete cur.albums[aid];
- 2875. - Audio.generateAlbums();
- 2876. - if (cur.album_id == aid) {
- 2877. - Audio.loadAlbum({album: 0, showAlbums: true});
- 2878. - }
- 2879. - Audio.updateAlbums();
- 2880. - }catch(e){}
- 2881. - },
- 2882. - onFail: function(){
- 2883. - box.hide(200);
- 2884. - }
- 2885. - });
- 2886. - }, getLang('global_cancel'));
- 2887. - },
- 2888. -
- 2889. - moveAudio: function(full_id, album_id) {
- 2890. - var id = full_id.split('_')[1];
- 2891. - ajax.post(Audio.address, {act:'move_to_album', album_id:album_id, audio_id:id, gid:cur.gid, hash:cur.hashes.move_hash}, {
- 2892. - onDone: function(text) {
- 2893. - if((cur.album_id && cur.album_id != album_id) || cur.filterUnsorted){
- 2894. - var el = ge('audio'+full_id);
- 2895. - fadeOut(el, 300, function(){
- 2896. - el.parentNode.removeChild(el);
- 2897. - each (cur.aContent.sorter.elems, function() {
- 2898. - setStyle(this, {top: 'auto', left: 'auto'});
- 2899. - });
- 2900. - cur.aContent.sorter.destroy();
- 2901. - var opts = {onReorder: Audio.onAudioReorder, onMouseDown: Audio.onDragStart, onMouseUp: Audio.onDragEnd, noMoveCursor: 1};
- 2902. - if (cur.albumFilters) {
- 2903. - extend(opts, {target: cur.albumFilters, onDragOver: Audio.onDragOver, onDragOut: Audio.onDragOut});
- 2904. - }
- 2905. - sorter.init(cur.aContent, opts);
- 2906. - cur.sectionCount--;
- 2907. - Audio.changeSummary();
- 2908. - if (cur.sectionCount == 0) {
- 2909. - cur.aContent.innerHTML = '<div id="not_found" class="info_msg">'+getLang('audio_album_no_recs')+'</div>';
- 2910. - }
- 2911. - hide(cur.showMore);
- 2912. - });
- 2913. - }
- 2914. - cur.audios[id][8] = album_id;
- 2915. - Audio.generateAlbums();
- 2916. - }
- 2917. - });
- 2918. - },
- 2919. -
- 2920. - onAudioReorder: function(audio, before, after) {
- 2921. - var aid = audio.id.replace('audio', '').split('_')[1];
- 2922. - var before_id = (before && before.id || '').replace('audio', '').split('_')[1];
- 2923. - var after_id = (after && after.id || '').replace('audio', '').split('_')[1];
- 2924. - ajax.post(Audio.address, {act: 'reorder_audios', oid: cur.oid, aid: aid, before: before_id, after: after_id, hash: cur.hashes.reorder_hash}, {
- 2925. - onDone: function(data) {
- 2926. - var val;
- 2927. - if (before_id && !after_id) {
- 2928. - val = cur.audios[before_id]._order - 0.01;
- 2929. - } else {
- 2930. - val = cur.audios[after_id]._order + 0.01;
- 2931. - }
- 2932. - cur.audios[aid]._order = val;
- 2933. - Audio.reorderPlaylist(cur.oid + '_' + aid, before_id ? cur.oid + '_' + before_id : '', after_id ? cur.oid + '_' + after_id : '');
- 2934. - }
- 2935. - });
- 2936. - },
- 2937. -
- 2938. - onDragStart: function(el) {
- 2939. - // addClass(ge('page_body'), 'no_overflow');
- 2940. - cur.dragStartTimer = setTimeout(function() {
- 2941. - addClass(cur.audioAlbumsWrap, 'drag');
- 2942. - hide('album_add');
- 2943. - var ids = el.id.substr(5), id = parseInt(ids.split('_')[1]);
- 2944. - var album_id = (cur.audios) ? cur.audios[id][8] : cur.album_id;
- 2945. - each(geByClass('audio_filter', cur.audioAlbumsWrap), function(i,v) {
- 2946. - if ('album'+album_id == v.id || (album_id == 0 && v.id == 'album_unsorted')) {
- 2947. - return;
- 2948. - }
- 2949. - addClass(v, 'drag_on');
- 2950. - });
- 2951. - animate(el, {opacity: .8}, 200);
- 2952. - }, 300);
- 2953. - },
- 2954. -
- 2955. - onDragEnd: function(el, target) {
- 2956. - if (cur.dragStartTimer) clearTimeout(cur.dragStartTimer);
- 2957. - // removeClass(ge('page_body'), 'no_overflow');
- 2958. - each(geByClass('audio_filter', cur.audioAlbumsWrap), function(i,v) {
- 2959. - removeClass(v, 'drag_on');
- 2960. - });
- 2961. - show('album_add');
- 2962. - if (target) {
- 2963. - var new_album, full_id = el.id.substr(5), aid = parseInt(full_id.split('_')[1]);
- 2964. - var album_id = (cur.audios) ? cur.audios[aid][8] : cur.album_id;
- 2965. - if (target.id != 'album_unsorted') {
- 2966. - new_album = parseInt(target.id.substr(5));
- 2967. - } else {
- 2968. - new_album = 0;
- 2969. - }
- 2970. - if (new_album != album_id) {
- 2971. - Audio.moveAudio(full_id, new_album);
- 2972. - }
- 2973. - }
- 2974. - removeClass(cur.audioAlbumsWrap, 'drag');
- 2975. - animate(el, {opacity: 1}, 200);
- 2976. - },
- 2977. -
- 2978. - onDragOver: function(el, target) {
- 2979. - cur.targetId = target.id || '';
- 2980. - var ids = el.id.substr(5), id = parseInt(ids.split('_')[1]);
- 2981. - var album_id = (cur.audios) ? cur.audios[id][8] : cur.album_id;
- 2982. - if ('album'+album_id == target.id || (album_id == 0 && target.id == 'album_unsorted')) {
- 2983. - return;
- 2984. - }
- 2985. - if (cur.dragOutTimer) {
- 2986. - clearTimeout(cur.dragOutTimer);
- 2987. - }
- 2988. - addClass(target, 'drag_over');
- 2989. - setStyle(el, {opacity: .4});
- 2990. - },
- 2991. -
- 2992. - onDragOut: function(el, target) {
- 2993. - removeClass(target, 'drag_over');
- 2994. - if (target.id && cur.targetId != target.id) return;
- 2995. - cur.dragOutTimer = setTimeout(function(){setStyle(el, {opacity: .8});}, 200);
- 2996. - },
- 2997. -
- 2998. - ignoreOwner: function (post_raw, owner_id, hash, btn) {
- 2999. - triggerEvent(ge('delete_post' + post_raw), 'mouseout');
- 3000. - cur.feedEntriesHTML = cur.feedEntriesHTML || {};
- 3001. - if (post_raw) {
- 3002. - cur.feedEntriesHTML[post_raw + '_ignored'] = val('post' + post_raw);
- 3003. - }
- 3004. - ajax.post(Audio.address, {act: 'a_ignore_owner', post_raw: post_raw, owner_id: owner_id, hash: hash}, {
- 3005. - onDone:function(html) {
- 3006. - val('post' + post_raw, html);
- 3007. - each(geByClass('post', cur.aContent), function(i,v) {
- 3008. - var ids = this.id.match(/post((-?\d+)_(-?\d+)(_\d+)?)/);
- 3009. - if (ids[1] != post_raw && (!ids[4] && ids[2] == owner_id || ids[4] && ids[3] == owner_id)) {
- 3010. - hide(this);
- 3011. - }
- 3012. - });
- 3013. - }
- 3014. - });
- 3015. - },
- 3016. -
- 3017. - unignoreOwner: function (post_raw, owner_id, hash) {
- 3018. - ajax.post(Audio.address, {act: 'a_unignore_owner', post_raw: post_raw || '', owner_id: owner_id, hash: hash}, {
- 3019. - onDone:function(html) {
- 3020. - if (post_raw) {
- 3021. - val('post' + post_raw, cur.feedEntriesHTML[post_raw + '_ignored']);
- 3022. - } else {
- 3023. - val('ignore_row' + owner_id, html);
- 3024. - }
- 3025. - each(geByClass('post', cur.aContent), function(i,v) {
- 3026. - var ids = this.id.match(/post((-?\d+)_(-?\d+)(_\d+)?)/);
- 3027. - if (!ids[4] && ids[2] == owner_id || ids[4] && ids[3] == owner_id) {
- 3028. - show(this);
- 3029. - }
- 3030. - });
- 3031. - }
- 3032. - });
- 3033. - },
- 3034. -
- 3035. - editHidden: function () {
- 3036. - 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']});
- 3037. - cur.onOListSave = Audio.onHiddenSave;
- 3038. - return false;
- 3039. - },
- 3040. -
- 3041. - onHiddenSave: function(white, black, list, options) {
- 3042. - var box = curBox(), params = {act: 'a_ignore_olist', hash: options.hash};
- 3043. - if (white.length < black.length) {
- 3044. - params.White = white.join(',');
- 3045. - } else {
- 3046. - params.Black = black.join(',');
- 3047. - }
- 3048. - ajax.post(Audio.address, params, {
- 3049. - onDone: function(control, rules) {
- 3050. - box.hide();
- 3051. - Audio.loadFeed({update: 'reload'});
- 3052. - },
- 3053. - showProgress: box.showProgress,
- 3054. - hiderogress: box.hideProgress
- 3055. - });
- 3056. - return false;
- 3057. - },
- 3058. -
- 3059. - loadGenre: function(opts, ev) {
- 3060. - if (checkEvent(ev)) {
- 3061. - return true;
- 3062. - }
- 3063. - opts = opts || {};
- 3064. - var from_pad = !!opts.from_pad, genre_id = opts.genre;
- 3065. - Audio.loadPopular({update: true, genre: genre_id, from_pad: from_pad});
- 3066. - return cancelEvent(ev);
- 3067. - },
- 3068. -
- 3069. - loadPerformer: function(opts, ev) {
- 3070. - if (checkEvent(ev)) {
- 3071. - return true;
- 3072. - }
- 3073. - opts = opts || {};
- 3074. - var from_pad = !!opts.from_pad, oid = opts.oid, index = 'owner' + oid;
- 3075. - Audio.loadFriendsAudios({id: oid, index: index, owner: true, from_pad: from_pad});
- 3076. - return cancelEvent(ev);
- 3077. - },
- 3078. -
- 3079. - moreCatalog: function(opts) {
- 3080. - opts = opts || {};
- 3081. - var __cur = opts.from_pad ? window._pads && _pads.cur : window.cur,
- 3082. - from_pad = !!opts.from_pad, obj = opts.el;
- 3083. - if (hasClass(obj, 'audio_performer_shown')) {
- 3084. - var height = getSize(ge('audio_more_performers'))[1];
- 3085. - removeClass(obj, 'audio_performer_shown');
- 3086. - hide('audio_more_performers');
- 3087. - if (height > 300) {
- 3088. - scrollToTop(0);
- 3089. - }
- 3090. - } else {
- 3091. - if (ge('audio_more_performers')) {
- 3092. - show('audio_more_performers')
- 3093. - addClass(obj, 'audio_performer_shown');
- 3094. - return false;
- 3095. - }
- 3096. - var exclude = [];
- 3097. - var nodes = ge(__cur.popularPerformersId).childNodes;
- 3098. - for (var i in nodes) {
- 3099. - if (hasClass(nodes[i], 'audio_owner')) {
- 3100. - exclude.push(intval(nodes[i].getAttribute('ref')));
- 3101. - }
- 3102. - }
- 3103. - var query = {act: 'get_more_performers', offset: 4, exclude: exclude.join(','), genre: parseInt(__cur.genre)};
- 3104. - if (from_pad) {
- 3105. - query.from_pad = 1;
- 3106. - }
- 3107. - ajax.post('al_audio.php', query, {
- 3108. - onDone: function(rows) {
- 3109. - ge(__cur.popularPerformersId).appendChild(ce('div', {
- 3110. - id: 'audio_more_performers',
- 3111. - innerHTML: rows
- 3112. - }));
- 3113. - addClass(obj, 'audio_performer_shown');
- 3114. - },
- 3115. - showProgress: addClass.pbind(obj, 'audio_performer_loading'),
- 3116. - hideProgress: removeClass.pbind(obj, 'audio_performer_loading')
- 3117. - });
- 3118. - }
- 3119. - },
- 3120. -
- 3121. - _eof: 1
- 3122. - }
- 3123. - try{stManager.done('audio.js');}catch(e){}
- ------
Advertisement
Add Comment
Please, Sign In to add comment