Hormold

VK Change (#1385984711)

Dec 2nd, 2013
350
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 248.09 KB | None | 0 0
  1. Файл - pads.js (Старый размер - 61428 | Новый - 44686):
  2. 9.  -     mus: {w: 629},
  3. 10.  +     mus: {w: 520},
  4. 40.  -   decr: function(id, toZero) {
  5. 41.  +   decr: function(id) {
  6. 44.  -     handlePageCount(id, toZero ? 0 : (vk.counts[id] - 1), mp[id], 1);
  7. 45.  +     handlePageCount(id, (vk.counts[id] - 1), mp[id], 1);
  8. 66.  -     var d = Pads.coords[id], c = _pads.cache[id], el = Pads.getEl(id), xy = getXY(el, true),
  9. 67.  -         barHeight = getXY('page_layout')[1], topOffset = 33 + barHeight;
  10. 68.  +     var d = Pads.coords[id], c = _pads.cache[id], el = Pads.getEl(id), xy = getXY(el, true);
  11. 72.  -           fixed = (posStyle == 'fixed' || posStyle != 'fixed' && y >= topOffset && isVisible(gp) || reverse || !ge('head_play_btn')), l, r, t, b;
  12. 73.  +           fixed = (posStyle == 'fixed' || posStyle != 'fixed' && y >= 33 && isVisible(gp) || reverse || !ge('head_play_btn')), l, r, t, b;
  13. 82.  -       t = reverse ? 'auto' : ((y >= topOffset && isVisible(gp) || !playBtn) ? 12 : 46) + barHeight;
  14. 83.  +       t = reverse ? 'auto' : ((y >= 33 && isVisible(gp) || !playBtn) ? 12 : 46);
  15. 88.  -       if (!fixed && !reverse && browser.mac) { // :(
  16. 89.  -         setTimeout(function() {
  17. 90.  -           var nt = intval(_pads.wrap.style.top);
  18. 91.  -           _pads.wrap.style.top = (nt - scrollGetY()) + 'px';
  19. 92.  -           _pads.wrap.style.position = 'fixed';
  20. 93.  -           setTimeout(function() { _pads.wrap.style.position = ''; _pads.wrap.style.top = nt + 'px'; }, 0);
  21. 94.  -         }, 0);
  22. 95.  -       }
  23. 97.  -       toggleClass(_pads.arrow, 'head', (y < topOffset || !isVisible(gp)) && playBtn && !_pads.gpClicked);
  24. 98.  -       toggleClass(gp, 'head', (y < topOffset || !isVisible(gp)) && playBtn && !_pads.gpClicked);
  25. 99.  -       toggleClass(_pads.arrow, 'right', (y >= topOffset && isVisible(gp) || !playBtn) && !hasClass(gp, 'reverse'));
  26. 100.  -       toggleClass(_pads.arrow, 'left', (y >= topOffset && isVisible(gp) || !playBtn) && hasClass(gp, 'reverse'));
  27. 101.  -       var toup = (y < topOffset || !isVisible(gp)) && playBtn && !_pads.gpClicked;
  28. 102.  +       toggleClass(_pads.arrow, 'head', (y < 33 || !isVisible(gp)) && playBtn && !_pads.gpClicked);
  29. 103.  +       toggleClass(gp, 'head', (y < 33 || !isVisible(gp)) && playBtn && !_pads.gpClicked);
  30. 104.  +       toggleClass(_pads.arrow, 'right', (y >= 33 && isVisible(gp) || !playBtn) && !hasClass(gp, 'reverse'));
  31. 105.  +       toggleClass(_pads.arrow, 'left', (y >= 33 && isVisible(gp) || !playBtn) && hasClass(gp, 'reverse'));
  32. 106.  +       var toup = (y < 33 || !isVisible(gp)) && playBtn && !_pads.gpClicked;
  33. 146.  -         cntr -= 46 + barHeight;
  34. 147.  +         cntr -= 46;
  35. 150.  -         _pads.wrap.style.top = (46 + barHeight) + 'px';
  36. 151.  +         _pads.wrap.style.top = 46 + 'px';
  37. 168.  -     var y = scrollGetY(), barHeight = getXY('page_layout')[1], topOffset = 33 + barHeight;
  38. 169.  +     var y = scrollGetY();
  39. 180.  -         setStyle(_pads.wrap, {bottom: fixed ? '15px' : 'auto', top: fixed ? 'auto' : 46 + barHeight});
  40. 181.  +         setStyle(_pads.wrap, {bottom: fixed ? '15px' : 'auto', top: fixed ? 'auto' : '46px'});
  41. 184.  -       } else if (y >= topOffset && isVisible(gp) && !fixed || !playBtn) {
  42. 185.  +       } else if (y >= 33 && isVisible(gp) && !fixed || !playBtn) {
  43. 205.  -         setStyle(_pads.wrap, {top: 46 + barHeight, bottom: 'auto'});
  44. 206.  +         setStyle(_pads.wrap, {top: '46px', bottom: 'auto'});
  45. 323.  -       var topOffset = 33 + getXY('page_layout')[1];
  46. 324.  -       toggleClass(ge('gp'), 'head', id == 'mus' && scrollGetY() < topOffset && !hasClass(ge('gp'), 'reverse') && !_pads.gpClicked);
  47. 325.  +       toggleClass(ge('gp'), 'head', id == 'mus' && scrollGetY() < 33 && !hasClass(ge('gp'), 'reverse') && !_pads.gpClicked);
  48. 342.  -             loadEl.innerHTML = loadEl.padLoad;
  49. 343.  -             delete loadEl.padLoad;
  50. 344.  +           loadEl.innerHTML = loadEl.padLoad;
  51. 345.  +           delete loadEl.padLoad;
  52. 401.  -       var scrollElements = [];
  53. 402.  -       if (id == 'mus') {
  54. 403.  -         scrollElements.push(ge('pad_side_filters_wrap'));
  55. 404.  -       }
  56. 411.  -         right: vk.rtl ? 'auto' : (id == 'mus' ? 0 : 1),
  57. 412.  -         left: !vk.rtl ? 'auto' : (id == 'mus' ? 0 : 1),
  58. 413.  -         forceCancelEvent: (id == 'mus'),
  59. 414.  -         scrollElements: scrollElements,
  60. 415.  +         right: vk.rtl ? 'auto' : 1,
  61. 416.  +         left: !vk.rtl ? 'auto' : 1,
  62. 465.  -     if (_pads.shown == 'mus') {
  63. 466.  -       if (ge('gp')) {
  64. 467.  -         removeClass(ge('gp').firstChild, 'active');
  65. 468.  -         _pads.gpClicked = false;
  66. 469.  -       }
  67. 470.  -       if (window.audioPlayer && audioPlayer.controls && audioPlayer.controls.pd && audioPlayer.controls.pd.status && audioPlayer.controls.pd.status.tt) {
  68. 471.  -         hide(audioPlayer.controls.pd.status.tt.container);
  69. 472.  -       }
  70. 473.  -       if (window.Audio) {
  71. 474.  -         Audio.stopPadEvents();
  72. 475.  -       }
  73. 476.  +     if (_pads.shown == 'mus' && ge('gp')) {
  74. 477.  +       removeClass(ge('gp').firstChild, 'active');
  75. 478.  +       _pads.gpClicked = false;
  76. 545.  -     ajax.post('pads.php', {act: 'pad', offset: _pads.cur.offset, pad_id: _pads.shown, pad_section: _pads.cur.sect || 0}, {
  77. 546.  +     ajax.post('pads.php', {act: 'pad', offset: _pads.cur.offset, pad_id: _pads.shown}, {
  78. 607.  -   },
  79. 608.  -   handleFilterPos: function() {
  80. 609.  -     var filters = ge('pad_side_filters'), filtersWrap = ge('pad_side_filters_wrap'),
  81. 610.  -         lastPos = _pads.cur.filterLastPos || 0, lastSt = _pads.cur.lastSt || 0, pos,
  82. 611.  -         st = _pads.content.scrollTop, fSz = getSize(filters)[1], fwSz = getSize(filtersWrap)[1];
  83. 612.  -     pos = Math.min(0, Math.max(lastPos + lastSt - st, fwSz - fSz - 10));
  84. 613.  -     setStyle(filters, {top: pos});
  85. 614.  -     _pads.cur.filterLastPos = pos;
  86. 615.  -     _pads.cur.lastSt = st;
  87. 619.  -       var more = ge('pad_more_audio'), searchMore = ge('pad_more_search_link');
  88. 620.  -       Pads.handleFilterPos();
  89. 621.  -       if (!window.Audio || !Audio.showRows) return;
  90. 622.  -
  91. 623.  -       if (more && isVisible(more) && _pads.content.scrollTop + _pads.content.offsetHeight + 400 > more.offsetTop) {
  92. 624.  -         Audio.showRows({from_pad: true});
  93. 625.  -       }
  94. 626.  -
  95. 627.  -       if (searchMore && isVisible(searchMore) && _pads.content.scrollTop + _pads.content.offsetHeight + 400 > searchMore.offsetTop) {
  96. 628.  -         Audio.loadRows(true);
  97. 629.  +       var more = ge('pad_more_audio');
  98. 630.  +       if (!more || !isVisible(more) || !Pads.showAudios) return;
  99. 631.  +       if (_pads.content.scrollTop + _pads.content.offsetHeight > more.offsetTop) {
  100. 632.  +         Pads.showAudios();
  101. 653.  -       });
  102. 654.  -       extend(_pads, {
  103. 655.  -         editing: {}
  104. 767.  -       var barHeight = getXY('page_layout')[1];
  105. 768.  -       if (lh) wh = Math.max(Math.min(wh, lh - 104 - (/*hasClass(_pads.arrow, 'right') ? 12 :*/ 46) + barHeight), 200);
  106. 769.  +       if (lh) wh = Math.max(Math.min(wh, lh - 104 - (hasClass(_pads.arrow, 'right') ? 12 : 46)), 200);
  107. 776.  -         editing: _pads.editing || {}
  108. 777.  +         editing: {}
  109. 792.  -         editing: _pads.editing || {}
  110. 793.  +         editing: {}
  111. 795.  -       handlePageCount('nws', 0, 'feed' + (ge('l_nwsf') ? '?section=notifications' : ''), ge('l_nwsf') ? '' : 'section=notifications');
  112. 796.  +       handlePageCount('nws', 0, 'feed', 'section=notifications');
  113. 1036.  -   grDone: function(gid, fail, res, block, text) {
  114. 1037.  +   grDone: function(gid, fail, text) {
  115. 1042.  -       }
  116. 1043.  -     } else {
  117. 1044.  -       if (_pads.cur.processed[gid] > 0 && vk.counts.gr >= _pads.cur.savedcnts[gid]) {
  118. 1045.  -         Pads.decr('gr');
  119. 1046.  -         for (var i in _pads.cur.savedcnts) {
  120. 1047.  -           --_pads.cur.savedcnts[i];
  121. 1048.  -         }
  122. 1050.  -       if (block > 0) {
  123. 1051.  -         text = '<div class="pads_gr_clubinv_block">' + text.replace('{club}', '<b>' + val(domPS(ge('pads_clubinv' + gid))) + '</b>') + '</div>';
  124. 1052.  -         text += '<div class="pads_gr_clubinv_block"><a onclick="Pads.grProcess(this, ' + gid + ', -2, -1)">' + getLang('global_cancel') + '</a></div>';
  125. 1053.  -       } else if (!block && res < 0 && ge('pads_clubinv' + gid)) {
  126. 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>';
  127. 1055.  +     } else if (_pads.cur.processed[gid] > 0 && vk.counts.gr >= _pads.cur.savedcnts[gid]) {
  128. 1056.  +       Pads.decr('gr');
  129. 1057.  +       for (var i in _pads.cur.savedcnts) {
  130. 1058.  +         --_pads.cur.savedcnts[i];
  131. 1064.  -     if (!fail && block < 0) {
  132. 1065.  -       text = btns.oldtext;
  133. 1066.  -     }
  134. 1069.  -       className: 'pad_gr_result',
  135. 1070.  -       oldtext: val(btns)
  136. 1071.  +       className: 'pad_gr_result'
  137. 1075.  -   grProcess: function(el, gid, res, block) {
  138. 1076.  +   grProcess: function(el, gid, res) {
  139. 1087.  -     ajax.post('al_groups.php', {act: act, gid: gid, from: 'pad', context: context, hash: _pads.hash, block: block}, {
  140. 1088.  -       onDone: Pads.grDone.pbind(gid, false, res, block),
  141. 1089.  -       onFail: Pads.grDone.pbind(gid, true, res, block),
  142. 1090.  +     ajax.post('al_groups.php', {act: act, gid: gid, from: 'pad', context: context, hash: _pads.hash}, {
  143. 1091.  +       onDone: Pads.grDone.pbind(gid, false),
  144. 1092.  +       onFail: Pads.grDone.pbind(gid, true),
  145. 1107.  -       }
  146. 1108.  -       if (trim((
  147. 1109.  -         window.getSelection && window.getSelection() ||
  148. 1110.  -         document.getSelection && document.getSelection() ||
  149. 1111.  -         document.selection && document.selection.createRange().text || ''
  150. 1112.  -       ).toString()).length) {
  151. 1113.  -         return;
  152. 1239.  -     var op = _pads.editing[nws], t = ge('pad_nws_field' + nws), d = val('pad_nwsd' + nws).split('/'), el = ge('pad_nws' + nws);
  153. 1240.  +     var t = ge('pad_nws_field' + nws), d = val('pad_nwsd' + nws).split('/'), el = ge('pad_nws' + nws);
  154. 1242.  -       if (!op) return;
  155. 1243.  +       if (!t) return;
  156. 1248.  -       }
  157. 1249.  -       if (trim((
  158. 1250.  -         window.getSelection && window.getSelection() ||
  159. 1251.  -         document.getSelection && document.getSelection() ||
  160. 1252.  -         document.selection && document.selection.createRange().text || ''
  161. 1253.  -       ).toString()).length) {
  162. 1254.  -         return;
  163. 1257.  -     if (op) {
  164. 1258.  +     if (t) {
  165. 1260.  -         var v = t ? val(t) : '';
  166. 1261.  -         if (trim(v) && op.greet.indexOf(v) !== 0) return (ev === true) ? true : elfocus(t);
  167. 1262.  +         var v = val(t);
  168. 1263.  +         if (trim(v) && _pads.editing[nws].greet.indexOf(v) !== 0) return (ev === true) ? true : elfocus(t);
  169. 1265.  -       if (t) cleanElems(t);
  170. 1266.  +       cleanElems(t);
  171. 1281.  -       addClass(el, 'pad_nws_reply');
  172. 1282.  -       _pads.editing[nws] = opts;
  173. 1283.  -       if (opts.disabled) {
  174. 1284.  -         var c = geByClass1('pad_nws_cont', el).appendChild(ce('div', {
  175. 1285.  -           className: 'pad_nwsa pad_nwsr',
  176. 1286.  -           innerHTML: val('pad_nws_dis_tpl').replace('{text}', opts.disabled)
  177. 1287.  -         }));
  178. 1288.  -       } else {
  179. 1289.  -         var c = geByClass1('pad_nws_cont', el).appendChild(ce('div', {
  180. 1290.  -           className: 'pad_nwsa pad_nwsr',
  181. 1291.  -           innerHTML: val('pad_nws_reply_tpl').replace('{field}', '\
  182. 1292.  +       var c = geByClass1('pad_nws_cont', el).appendChild(ce('div', {
  183. 1293.  +         className: 'pad_nwsa pad_nwsr',
  184. 1294.  +         innerHTML: val('pad_nws_reply_tpl').replace('{field}', '\
  185. 1301.  -         }));
  186. 1302.  -         t = ge('pad_nws_field' + nws);
  187. 1303.  -         placeholderSetup(t, {back: true});
  188. 1304.  -         autosizeSetup(t, {minHeight: 31, onResize: Pads.update});
  189. 1305.  -       }
  190. 1306.  +       }));
  191. 1307.  +       t = ge('pad_nws_field' + nws);
  192. 1308.  +       addClass(el, 'pad_nws_reply');
  193. 1309.  +       placeholderSetup(t, {back: true});
  194. 1310.  +       autosizeSetup(t, {minHeight: 31, onResize: Pads.update});
  195. 1311.  +       _pads.editing[nws] = opts;
  196. 1312.  +
  197. 1328.  -         if (t) elfocus(t);
  198. 1329.  +         elfocus(t);
  199. 1407.  -     if (!post.indexOf('topic_comment')) {
  200. 1408.  +     if (!post.indexOf('topic_post')) {
  201. 1410.  -       post = post.replace('topic_comment', '');
  202. 1411.  +       post = post.replace('topic_post', '');
  203. 1472.  -     });
  204. 1473.  -     Pads.invalidate();
  205. 1474.  -   },
  206. 1475.  -   apRemoveAll: function(hash) {
  207. 1476.  -     ajax.post('apps', {act: 'a_remove_all_notifies', hash: hash, requests: 1}, {
  208. 1477.  -       onDone: function() {
  209. 1478.  -         Pads.decr('ap', true);
  210. 1479.  -       }
  211. 1480.  -     });
  212. 1481.  -   },
  213. 1482.  -   loadAudioRecommendations: function(el, aid) {
  214. 1483.  -     if (el.tt) el.tt.hide();
  215. 1484.  -     stManager.add('audioplayer.js', function() {
  216. 1485.  -       if (!window.audioPlayer) return;
  217. 1486.  -       audioPlayer.showRec(aid, true);
  218. 1487.  -     });
  219. 1488.  -   },
  220. 1489.  -   addAudio: function(el, aid, oid) {
  221. 1490.  -     if (cur.addedIds && cur.addedIds[oid+'_'+aid]) return false;
  222. 1491.  -     if (el.tt) el.tt.hide();
  223. 1492.  -     if (window.Audio) {
  224. 1493.  -       Audio.animateAdded(el, 200);
  225. 1494.  -       var addEl = ge('audio'+oid+'_'+aid) && geByClass1('audio_add_wrap', ge('audio'+oid+'_'+aid));
  226. 1495.  -       if (addEl && !hasClass(addEl, 'anim')) {
  227. 1496.  -         Audio.animateAdded(addEl, 200);
  228. 1497.  -       }
  229. 1498.  -     } else {
  230. 1499.  -       var c = se('<div class="audio_add_wrap added fl_r" onclick="return cancelEvent(event);"><div class="audio_add"></div></div>');
  231. 1500.  -       el.parentNode.replaceChild(c, el);
  232. 1501.  -     }
  233. 1502.  -     var _a = window.audioPlayer;
  234. 1503.  -     var query = {act: 'add', aid: aid, oid: oid, hash: (window._pads && _pads.addHash || _a && _a.addHash)};
  235. 1504.  -     if (_a && (_a.top || _a.playbackParams && (_a.playbackParams.top_audio || _a.playbackParams.top))) {
  236. 1505.  -       query.top = 1;
  237. 1506.  -     }
  238. 1507.  -     ajax.post(Audio.address, query, {
  239. 1508.  -       onDone: function (data, res) {
  240. 1509.  -         if (data && window.Audio) {
  241. 1510.  -           var aobj = eval('('+data+')'), all_list;
  242. 1511.  -           aobj = aobj['all'][0];
  243. 1512.  -           setTimeout(function(){
  244. 1513.  -             if (cur.id == vk.id && cur.audiosIndex && cur.audiosList && cur.audiosList['all'] && cur.aSearch) {
  245. 1514.  -               all_list = cur.audiosList['all'];
  246. 1515.  -               if (all_list && all_list.length) {
  247. 1516.  -                 aobj._order = all_list[0]._order - 1;
  248. 1517.  -                 cur.audiosList['all'].splice(0,0,aobj);
  249. 1518.  -               } else {
  250. 1519.  -                 aobj._order = 0;
  251. 1520.  -                 cur.audiosList['all'] = [aobj];
  252. 1521.  -               }
  253. 1522.  -               cur.audios[aobj[1]] = aobj;
  254. 1523.  -               cur.audiosIndex.add(aobj);
  255. 1524.  -             }
  256. 1525.  -             if (window._pads && _pads.cur && _pads.cur.audiosIndex && _pads.cur.audiosList) {
  257. 1526.  -               all_list = _pads.cur.audiosList['all'];
  258. 1527.  -               if (all_list && all_list.length) {
  259. 1528.  -                 aobj._order = all_list[0]._order - 1;
  260. 1529.  -                 _pads.cur.audiosList['all'].splice(0,0,aobj);
  261. 1530.  -               } else {
  262. 1531.  -                 aobj._order = 0;
  263. 1532.  -                 _pads.cur.audiosList['all'] = [aobj];
  264. 1533.  -               }
  265. 1534.  -               if (_pads.cur.audios) {
  266. 1535.  -                 _pads.cur.audios[aobj[1]] = aobj;
  267. 1536.  -               }
  268. 1537.  -               if (_pads.cur.allAudiosIndex == 'all') {
  269. 1538.  -                 _pads.cur.audiosIndex.add(aobj);
  270. 1539.  -               }
  271. 1540.  -             }
  272. 1541.  -             Pads.clearAudioLoadCache();
  273. 1542.  -           }, 0);
  274. 1543.  -         }
  275. 1544.  -         cur.addedIds = cur.addedIds || {};
  276. 1545.  -         cur.addedIds[oid+'_'+aid] = 1;
  277. 1546.  -         if (window.audioPlayer && currentAudioId()) {
  278. 1547.  -           var cur_aids = currentAudioId().split('_');
  279. 1548.  -           if (cur_aids[0] == oid && cur_aids[1] == aid) {
  280. 1549.  -             audioPlayer.showCurrentAdded();
  281. 1550.  -           }
  282. 1551.  -         }
  283. 1552.  -       }
  284. 1553.  -     });
  285. 1554.  -   },
  286. 1555.  -   onAudioReorder: function(audio, before, after) {
  287. 1556.  -     var aid = audio.id.substr(5);
  288. 1557.  -     var before_id = (before && before.id || '').substr(5);
  289. 1558.  -     var after_id = (after && after.id || '').substr(5);
  290. 1559.  -     var padPlist = padAudioPlaylist();
  291. 1560.  -     if (aid && padPlist && !padPlist[aid]) {
  292. 1561.  -       aid = aid.replace('_pad', '');
  293. 1562.  -       before_id = before_id.replace('_pad', '');
  294. 1563.  -       after_id = after_id.replace('_pad', '');
  295. 1564.  -     }
  296. 1565.  -     if (aid && padPlist && padPlist[aid]) {
  297. 1566.  -       if (!before_id && after_id && padPlist[after_id]) {
  298. 1567.  -         before_id = padPlist[after_id]._next;
  299. 1568.  -       } else if (!after_id && before_id && padPlist[before_id]) {
  300. 1569.  -         after_id = padPlist[before_id]._prev;
  301. 1570.  -       }
  302. 1571.  -       var pl = ge('pad_playlist');
  303. 1572.  -       if (pl && pl.sorter && pl.sorter.elems) {
  304. 1573.  -         var newStart = (pl.sorter.elems[0].id || '').substr(5);
  305. 1574.  -         if (newStart && !padPlist[newStart]) {
  306. 1575.  -           newStart = newStart.replace('_pad', '');
  307. 1576.  -         }
  308. 1577.  -         padPlist.start = newStart;
  309. 1578.  -       }
  310. 1579.  -       var prev_id = padPlist[aid]._prev, next_id = padPlist[aid]._next;
  311. 1580.  -       if (prev_id && padPlist[prev_id] && next_id && padPlist[next_id] &&
  312. 1581.  -         before_id && padPlist[before_id] && after_id && padPlist[after_id] && after_id != aid && before_id != aid) {
  313. 1582.  -         padPlist[prev_id]._next = next_id;
  314. 1583.  -         padPlist[next_id]._prev = prev_id;
  315. 1584.  -         padPlist[aid]._prev = after_id;
  316. 1585.  -         padPlist[after_id]._next = aid;
  317. 1586.  -         padPlist[aid]._next = before_id;
  318. 1587.  -         padPlist[before_id]._prev = aid;
  319. 1588.  -       }
  320. 1589.  -       if (window.audioPlaylist && audioPlaylist[aid]) {
  321. 1590.  -         window.audioPlaylist = padPlist;
  322. 1591.  -       }
  323. 1592.  -       ls.set('pad_playlist', padPlist);
  324. 1593.  -       ls.set('pad_pltime', vkNow());
  325. 1594.  -     }
  326. 1595.  -   },
  327. 1596.  -   setAudioCurPos: function(speed) {
  328. 1597.  -     var _a = window.audioPlayer, audio_id = (_a && _a.isPlaylistGlobal()) ? ls.get('audio_id') || currentAudioId() : currentAudioId();
  329. 1598.  -     if (!audio_id) return;
  330. 1599.  -     if (audio_id.substr(-4) != '_pad') {
  331. 1600.  -       audio_id += '_pad';
  332. 1601.  -     }
  333. 1602.  -     if (ge('audio'+audio_id)) {
  334. 1603.  -       var h = 430;
  335. 1604.  -       if (window.lastWindowHeight) {
  336. 1605.  -         h = Math.min(h, lastWindowHeight - 104 - (hasClass(ge('pad_arrow'), 'right') ? 13 : 46));
  337. 1606.  -         if (h < 200) h = 200;
  338. 1607.  -       }
  339. 1608.  -       var sTop = ge('audio'+audio_id).offsetTop + ge('pad_playlist').offsetTop - Math.min(ge('pad_cont').offsetHeight, h) / 2 + 17;
  340. 1609.  -       if (ge('pad_content') && sTop > 0) {
  341. 1610.  -         if (speed) {
  342. 1611.  -           animate(ge('pad_content'), {scrollTop: sTop}, speed, function() {
  343. 1612.  -             Pads.update();
  344. 1613.  -           })
  345. 1614.  -         } else {
  346. 1615.  -           ge('pad_content').scrollTop = sTop;
  347. 1616.  -           Pads.update();
  348. 1617.  -         }
  349. 1618.  -       }
  350. 1619.  -     }
  351. 1620.  -   },
  352. 1621.  -   playLastStatus: function() {
  353. 1622.  -     var _a = audioPlayer, pl = ge('pad_playlist');
  354. 1623.  -     if (cur.nextPlaylist && cur.nextPlaylist.start) {
  355. 1624.  -       var m = cur.nextPlaylist.start.match(/^-?\d+_\d+_s(-?\d+)(?:_|$)/);
  356. 1625.  -       if (m && m[1] && _a.statusData && _a.statusData[m[1]]) {
  357. 1626.  -         var data = _a.statusData[m[1]];
  358. 1627.  -         window.audioPlaylist = clone(cur.nextPlaylist);
  359. 1628.  -         if (window.audioPlayer) {
  360. 1629.  -           audioPlayer.setPadPlaylist(audioPlaylist);
  361. 1630.  -         }
  362. 1631.  -         playAudioNew(audioPlaylist.start);
  363. 1632.  -         pl.innerHTML = '<div class="pad_audio_status">'+data.audio_litening_to_user+'</div>';
  364. 1633.  -         ge('pad_footer_text').innerHTML = data.audio_goto_user;
  365. 1634.  -         hide('pad_more_audio');
  366. 1635.  -       }
  367. 1636.  -     }
  368. 1637.  -   },
  369. 1638.  -   audioRow: function(audio, opts) {
  370. 1639.  -     opts = opts || {};
  371. 1640.  -     var aid = audio.full_id || audio[0]+'_'+audio[1], actions = '';
  372. 1641.  -     var performer = audio[5].replace(/\\$/g, "\\&#36;");
  373. 1642.  -     var _a = window.audioPlayer, cur_aid = (_a && _a.isPlaylistGlobal()) ? ls.get('audio_id') || currentAudioId() : currentAudioId();
  374. 1643.  -     if (vk.id != audio[0] || audio[9] && intval(audio[9])) {
  375. 1644.  -       if (cur.addedIds && cur.addedIds[audio[0]+'_'+audio[1]]) {
  376. 1645.  -         actions += '<div class="audio_add_wrap added fl_r" onclick="return cancelEvent(event);"><div class="audio_add"></div></div>';
  377. 1646.  -       } else {
  378. 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>';
  379. 1648.  -       }
  380. 1649.  -     }
  381. 1650.  -
  382. 1651.  -     return rs(Pads.audioTpl, {
  383. 1652.  -       audio_id: (aid.substr(-4) == '_pad') ? aid : aid+'_pad',
  384. 1653.  -       performer: performer,
  385. 1654.  -       title: audio[6].replace(/\\$/g, "\\&#36;"),
  386. 1655.  -       url: audio[2],
  387. 1656.  -       playtime: audio[3],
  388. 1657.  -       duration: audio[4],
  389. 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(/&#39;/g, "\\\\\\&#39;")+'\'}); return false"',
  390. 1659.  -       actions: actions,
  391. 1660.  -       author: '',
  392. 1661.  -       onclick: 'window.padPlClicked = true; playAudioNew(\''+aid+'\')',
  393. 1662.  -       rowclass: (actions ? '' : 'no_actions') + (cur_aid == aid ? (opts.thisTab && currentAudioId() == aid ? ' current' : ' tab_current') : '')
  394. 1664.  -   },
  395. 1665.  -   showAudios: function() {
  396. 1666.  -     var self = this, __cur = window._pads && _pads.cur, pl = ge('pad_playlist'),
  397. 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());
  398. 1668.  -     if (__cur.allLoading) return;
  399. 1669.  -     if (pList) {
  400. 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();
  401. 1671.  -
  402. 1672.  -       if (el) {
  403. 1673.  -         first_id = geByClass1('audio', pl).id.substr(5).replace('_pad', '');
  404. 1674.  -         var last_id = el.id.substr(5).replace('_pad', '');
  405. 1675.  -         if (pList[last_id] && pList[last_id]._next) {
  406. 1676.  -           aid = pList[last_id]._next;
  407. 1677.  -         }
  408. 1678.  -       } else if (audio_id && pList[audio_id]) {
  409. 1679.  -         aid = audio_id;
  410. 1680.  -         for (var i = 0; i < 100; i++) {
  411. 1681.  -           if (!aid || aid == pList.start) break;
  412. 1682.  -           aid = pList[aid]._prev;
  413. 1683.  -           showRowsCnt++;
  414. 1684.  -         }
  415. 1685.  -         first_id = aid;
  416. 1686.  -       } else {
  417. 1687.  -         aid = first_id = pList.start;
  418. 1688.  -       }
  419. 1689.  -       if (!first_id) {
  420. 1690.  -         if (audio_id) {
  421. 1691.  -           var m = audio_id.match(/^-?\d+_\d+_s(-?\d+)(?:_|$)/);
  422. 1692.  -           if (m && m[1] && (pList.statusData || _a.statusData && _a.statusData[m[1]])) {
  423. 1693.  -             var data = pList.statusData || _a.statusData[m[1]];
  424. 1694.  -             var el = se('<div class="pad_audio_status">' + (first_id != audio_id ? data.audio_listen_to_user : data.audio_litening_to_user) + '</div>');
  425. 1695.  -             pl.appendChild(el);
  426. 1696.  -             setTimeout(function() {
  427. 1697.  -               setStyle(el, {height: getSize(_pads.content)[1] - 110 - ge('pad_playlist').offsetTop});
  428. 1698.  -             }, 0)
  429. 1699.  -             ge('pad_footer_text').innerHTML = data.audio_goto_user;
  430. 1700.  -           }
  431. 1701.  -         }
  432. 1702.  -         hide('pad_more_audio');
  433. 1703.  -       } else {
  434. 1704.  -         if (first_id) {
  435. 1705.  -           var m = first_id.match(/^-?\d+_\d+_s(-?\d+)(?:_|$)/);
  436. 1706.  -           if (m && m[1] && (pList.statusData || _a.statusData && _a.statusData[m[1]]) && !pList[first_id]._next) {
  437. 1707.  -             var data = pList.statusData || _a.statusData[m[1]];
  438. 1708.  -             var el = se('<div class="pad_audio_status">' + (first_id != audio_id ? data.audio_listen_to_user : data.audio_litening_to_user) + '</div>');
  439. 1709.  -             pl.appendChild(el);
  440. 1710.  -             setTimeout(function() {
  441. 1711.  -               setStyle(el, {height: getSize(_pads.content)[1] - 110 - ge('pad_playlist').offsetTop});
  442. 1712.  -             }, 0)
  443. 1713.  -             ge('pad_footer_text').innerHTML = data.audio_goto_user;
  444. 1714.  -             hide('pad_more_audio');
  445. 1715.  -             return;
  446. 1716.  -           }
  447. 1717.  -         }
  448. 1718.  -         var k = 0;
  449. 1719.  -         if (aid) {
  450. 1720.  -           var thisTab = pList && window.curNotifier && pList.instance == curNotifier.instance_id;
  451. 1721.  -           do {
  452. 1722.  -             var rowEl = se(Pads.audioRow(pList[aid], {thisTab: thisTab}));
  453. 1723.  -             pl.appendChild(rowEl);
  454. 1724.  -             if (pList[aid]._next) aid = pList[aid]._next;
  455. 1725.  -             k++;
  456. 1726.  -           } while (aid && aid !== first_id && k < showRowsCnt);
  457. 1727.  -         }
  458. 1728.  -         if (aid == first_id) {
  459. 1729.  -           var more = ge('pad_more_audio');
  460. 1730.  -           if (pList.has_more) {
  461. 1731.  -             __cur.allLoading = true;
  462. 1732.  -             __cur.allLoadedCallback = function() {
  463. 1733.  -               __cur.allLoading = false;
  464. 1734.  -               Audio.showRows({from_pad: true});
  465. 1735.  -             }
  466. 1736.  -             Audio.loadFriendsAudios({from_pad: true, id: vk.id, index: 'all'});
  467. 1737.  -           } else {
  468. 1738.  -             hide(more);
  469. 1739.  -           }
  470. 1740.  -         }
  471. 1741.  -         if (window._pads && _pads.currentShown && !browser.mobile) {
  472. 1742.  -           if (el && pl.sorter) {
  473. 1743.  -             setTimeout(sorter.added.pbind(pl), 0);
  474. 1744.  -           } else {
  475. 1745.  -             setTimeout(function(){
  476. 1746.  -               sorter.init(pl, {onReorder: Pads.onAudioReorder, noMoveCursor: 1});
  477. 1747.  -               if (!el && !_a.recsLoaded) Pads.setAudioCurPos();
  478. 1748.  -             }, 0);
  479. 1749.  -           }
  480. 1750.  -         }
  481. 1751.  -         if (pList.htitle) {
  482. 1752.  -           ge('pad_footer_text').innerHTML = '<span class="audio_album_length">'+pList.htitle+'</span>';
  483. 1753.  -         }
  484. 1754.  -         if (!el && !_a.recsLoaded) Pads.setAudioCurPos();
  485. 1755.  -       }
  486. 1756.  -       Pads.update();
  487. 1757.  -     }
  488. 1758.  -   },
  489. 1759.  -   clearAudioLoadCache: function() {
  490. 1760.  -     if (!window._pads) {
  491. 1761.  -       return;
  492. 1762.  -     }
  493. 1764.  -     if (!window.ajaxCache) {
  494. 1765.  -       return;
  495. 1766.  -     }
  496. 1767.  -     for (var i in window.ajaxCache) {
  497. 1768.  -       var h = i.split('#'), params = h[1] && q2ajx(h[1]);
  498. 1769.  -       if ((h[0] == '/audio' || h[0] == 'audio') && params.act == 'load_audios_silent' && intval(params.id) == 3520) {
  499. 1770.  -         delete ajaxCache[i];
  500. 1771.  -       }
  501. 1772.  -     }
  502. ------
  503. Файл - audioplayer.js (Старый размер - 69789 | Новый - 0):
  504. 0.  - var oldAudioPlayer = window.audioPlayer || {};
  505. 1.  - var audioPlayer = {
  506. 2.  -   id: oldAudioPlayer.id || null,
  507. 3.  -   controls: oldAudioPlayer.controls || null,
  508. 4.  -   player: oldAudioPlayer.player || null,
  509. 5.  -   lastSong: oldAudioPlayer.lastSong || null,
  510. 6.  -   eventsInited: oldAudioPlayer.eventsInited || null,
  511. 7.  -   statusExport: oldAudioPlayer.statusExport || null,
  512. 8.  -   addHash: oldAudioPlayer.addHash || null,
  513. 9.  -   volW: 33,
  514. 10.  -   prX: 14,
  515. 11.  -   gpSz: 330,
  516. 12.  -   gpMinW: 154,
  517. 13.  -   gpMaxW: 553,
  518. 14.  -   prStep: 10,
  519. 15.  -   images: {
  520. 16.  -     icon: '/images/favicon' + (vk.intnat ? '_vk' : 'new') + '.ico',
  521. 17.  -     playicon: '/images/playiconnew'+(window.devicePixelRatio >= 2 ? '_2x' : '')+'.ico',
  522. 18.  -     pauseicon: '/images/pauseiconnew'+(window.devicePixelRatio >= 2 ? '_2x' : '')+'.ico'
  523. 19.  -   },
  524. 20.  -   songInfos: {},
  525. 21.  -   shareMusic: function() {
  526. 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+)?))?/);
  527. 23.  -     if (!mus) return;
  528. 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']});
  529. 25.  -   },
  530. 26.  -   initPlayer: function(id) {
  531. 27.  -     var _a = audioPlayer;
  532. 28.  -     var html5AudioSupport = false;
  533. 29.  -     try {
  534. 30.  -       var audioObj = ce('audio');
  535. 31.  -       if (('no' != audioObj.canPlayType('audio/mpeg')) && ('' != audioObj.canPlayType('audio/mpeg'))) html5AudioSupport=true;
  536. 32.  -     } catch (e){}
  537. 33.  -     if (browser.mobile || browser.msie6) _a.gpDisabled = true;
  538. 34.  -     if (browser.flash >= 9 && !(browser.mac && (browser.chrome || browser.safari) && html5AudioSupport)) {
  539. 35.  -       var opts = {
  540. 36.  -         url: '/swf/audio_lite.swf',
  541. 37.  -         id: 'player',
  542. 38.  -         height: 2
  543. 39.  -       }
  544. 40.  -       var params = {
  545. 41.  -         swliveconnect: 'true',
  546. 42.  -         allowscriptaccess: 'always',
  547. 43.  -         wmode: 'opaque'
  548. 44.  -       }
  549. 45.  -       var vars = {
  550. 46.  -         onLoadComplete: 'audioPlayer.onLoadComplete',
  551. 47.  -         onError: 'audioPlayer.onError',
  552. 48.  -         onPlayFinish: 'audioPlayer.onPlayFinish',
  553. 49.  -         onLoadProgress: 'audioPlayer.onLoadProgress',
  554. 50.  -         onPlayProgress: 'audioPlayer.onPlayProgress'
  555. 51.  -       }
  556. 52.  -       var t = 'flash_audio';
  557. 53.  -       if (!ge(t)) document.body.appendChild(ce('div',{id: t, className: 'fixed'}));
  558. 54.  -       if (renderFlash(t, opts, params, vars)) {
  559. 55.  -         setTimeout(function(){_a.checkFlashLoaded(id);},50);
  560. 56.  -       }
  561. 57.  -     } else {
  562. 58.  -       if (html5AudioSupport) {
  563. 59.  -         var t = 'html5_audio';
  564. 60.  -         if (!ge(t)) document.body.appendChild(ce('audio',{id: t}));
  565. 61.  -         stManager.add('audio_html5.js',function(){
  566. 62.  -           _a.isHTML5 = true;
  567. 63.  -           _a.setPlayer(audio_html5, id);
  568. 64.  -         });
  569. 65.  -       } else {
  570. 66.  -         _a.setPlayer(null,id);
  571. 67.  -       }
  572. 68.  -     }
  573. 69.  -     if (!_a.eventsInited) _a.initEvents();
  574. 70.  -     if (!ge('gp') && !_a.gpDisabled) {
  575. 71.  -       document.body.appendChild(ce('div', {id: 'gp', className: 'fixed'}));
  576. 72.  -       addEvent(ge('gp'), 'dragstart', function() {return false;});
  577. 73.  -       addEvent(ge('gp'), 'selectstart', function() {return false;});
  578. 74.  -       ge('gp').innerHTML = '<div class="wrap" onmouseover="addClass(this, \'over\');" onmouseout="removeClass(this, \'over\');">\
  579. 75.  -   <div id="gp_back"><div><!-- --></div></div>\
  580. 76.  -   <div id="gp_wrap">\
  581. 77.  -     <div class="audio" id="audio_global">\
  582. 78.  -       <div id="gp_small">\
  583. 79.  -         <div id="gp_play_btn" class="fl_l"></div>\
  584. 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)">\
  585. 81.  -           <div id="gp_performer"></div>\
  586. 82.  -           <div id="gp_title"></div>\
  587. 83.  -         </div>\
  588. 84.  -       </div>\
  589. 85.  -     </div>\
  590. 86.  -   </div>\
  591. 87.  - </div>';
  592. 88.  -       toggle('gp', !_a.gpHidden && !cur.gpHidden);
  593. 89.  -       var barHeight = getXY('page_layout')[1];
  594. 90.  -       var headFixed = ge('head_play_btn') && getStyle(ge('page_header'), 'position') == 'fixed',
  595. 91.  -         gpTop = headFixed || scrollGetY() < 29 + barHeight ? 49 + barHeight : 20;
  596. 92.  -       setStyle(gp, {top: gpTop});
  597. 93.  -       // toggleClass(gp, 'z_index', !browser.mac);
  598. 94.  -     }
  599. 95.  -   },
  600. 96.  -   initEvents: function() {
  601. 97.  -     var _n = window.Notifier, _a = audioPlayer;
  602. 98.  -     if (_a.eventsInited) return;
  603. 99.  -     if (_n) {
  604. 100.  -       _n.addRecvClbk('audio_start', 'audio', function(data) {
  605. 101.  -         var _a = window.audioPlayer;
  606. 102.  -         if (_a) {
  607. 103.  -           if (_a.player && !_a.player.paused()) _a.pauseTrack();
  608. 104.  -           _a.pausedByVideo = null;
  609. 105.  -           if (window.Pads && window._pads && _pads.shown == 'mus') {
  610. 106.  -             Pads.hide();
  611. 107.  -           }
  612. 108.  -         }
  613. 109.  -       });
  614. 110.  -       _n.addRecvClbk('audio_mediakey', 'audio', this.keyPressed.pbind(true));
  615. 111.  -       _n.addRecvClbk('video_start', 'audio', function (data) {
  616. 112.  -         var _a = window.audioPlayer;
  617. 113.  -         if (_a && _a.player && !_a.player.paused()) {
  618. 114.  -           _a.pauseTrack();
  619. 115.  -           _a.pausedByVideo = 1;
  620. 116.  -         }
  621. 117.  -       });
  622. 118.  -       _n.addRecvClbk('video_hide', 'audio', function (data) {
  623. 119.  -         var _a = window.audioPlayer;
  624. 120.  -         if (_a) {
  625. 121.  -           if (_a.player && _a.player.paused() && _a.pausedByVideo) _a.playTrack();
  626. 122.  -           _a.pausedByVideo = null;
  627. 123.  -         }
  628. 124.  -       });
  629. 125.  -       _n.addRecvClbk('videocall_start', 'audio', function (data) {
  630. 126.  -         var _a = window.audioPlayer;
  631. 127.  -         if (_a && _a.player && !_a.player.paused()) {
  632. 128.  -           _a.pauseTrack();
  633. 129.  -           _a.pausedByVideo = 1;
  634. 130.  -         }
  635. 131.  -       });
  636. 132.  -       _n.addRecvClbk('videocall_end', 'audio', function (data) {
  637. 133.  -         var _a = window.audioPlayer;
  638. 134.  -         if (_a) {
  639. 135.  -           if (_a.player && _a.player.paused() && _a.pausedByVideo) _a.playTrack();
  640. 136.  -           _a.pausedByVideo = null;
  641. 137.  -         }
  642. 138.  -       });
  643. 139.  -     }
  644. 140.  -     addEvent(document, 'mouseup', _a.mouseUp);
  645. 141.  -     addEvent(document, 'mousemove', _a.mouseMove);
  646. 142.  -     _a.timeLeft = intval(getCookie('audio_time_left') || 1);
  647. 143.  -     if (cur.hashes && cur.hashes.add_hash && !_a.addHash) {
  648. 144.  -       _a.addHash = cur.hashes.add_hash;
  649. 145.  -     }
  650. 146.  -
  651. 147.  -     _a.eventsInited = true;
  652. 148.  -   },
  653. 149.  -   checkFlashLoaded: function(id) {
  654. 150.  -     var player=ge("player");
  655. 151.  -     var _a=audioPlayer;
  656. 152.  -     if (player && player.paused) _a.setPlayer(player,id);
  657. 153.  -     else setTimeout(function(){_a.checkFlashLoaded(id);},50);
  658. 154.  -   },
  659. 155.  -   hasStatusExport: function() {
  660. 156.  -     var _a = audioPlayer;
  661. 157.  -     _a.statusExport = _a.statusExport || {};
  662. 158.  -     for (var i in _a.statusExport) {
  663. 159.  -       if (_a.statusExport[i]) return true;
  664. 160.  -     }
  665. 161.  -     return false;
  666. 162.  -   },
  667. 163.  -   setPlayer: function(element, id) {
  668. 164.  -     if (element) {
  669. 165.  -       var _a = audioPlayer;
  670. 166.  -       _a.player = element;
  671. 167.  -       var volume = browser.mobile ? 80 : parseInt(getCookie('audio_vol'));
  672. 168.  -       if (!isNaN(volume)) _a.player.setVolume(volume / 100);
  673. 169.  -       _a.operate(id, true);
  674. 170.  -       if (!_a.gotData) {
  675. 171.  -         _a.gotData = -1;
  676. 172.  -         ajax.post('audio', {act: 'get_data'}, {
  677. 173.  -           onDone: function(hash, exp, langs) {
  678. 174.  -             window.lang = extend(window.lang || {}, langs);
  679. 175.  -             _a.addHash = hash;
  680. 176.  -             _a.statusExport = exp && !_a.hasStatusExport() ? exp : _a.statusExport || {};
  681. 177.  -             checkbox('currinfo_audio', _a.hasStatusExport());
  682. 178.  -             if (_a.hasStatusExport()) {
  683. 179.  -               _a.playback(_a.paused);
  684. 180.  -               _a.showCurrentTrack();
  685. 181.  -             }
  686. 182.  -             _a.gotData = 1;
  687. 183.  -           }
  688. 184.  -         })
  689. 185.  -       }
  690. 186.  -     } else {
  691. 187.  -       var message = getLang('audio_you_need_flash') + '<br/><br/>' + getLang('audio_do_you_want_flash');
  692. 188.  -       showFastBox({title: getLang('audio_need_flash_title')}, message, getLang('share_go'), function() {
  693. 189.  -         document.location = 'http://get.adobe.com/flash/';
  694. 190.  -       }, getLang('global_cancel'));
  695. 191.  -       _a.gpHidden = true;
  696. 192.  -     }
  697. 193.  -   },
  698. 194.  -   setIcon: function(icon) {
  699. 195.  -     setFavIcon(audioPlayer.images[icon]);
  700. 196.  -   },
  701. 197.  -   getSongInfoFromDOM: function(aid) {
  702. 198.  -     var art, title, nfo = geByClass1('info', ge('audio' + aid)), full_id = aid, l;
  703. 199.  -     if (full_id.substr(-4) == '_pad') {
  704. 200.  -       full_id = full_id.substr(0, full_id.length - 4);
  705. 201.  -     }
  706. 202.  -     if (!nfo) {
  707. 203.  -       nfo = geByClass1('info', ge('audio' + aid + '_pad'));
  708. 204.  -     }
  709. 205.  -     if (!ge('audio_info' + aid)) return null;
  710. 206.  -     art = geByTag1('b', nfo);
  711. 207.  -     l = geByTag1('a', art);
  712. 208.  -     if (l) art = l;
  713. 209.  -     var reArr = ['<span>', '</span>', '<span class="match">', '<font>', '</font>'], re = new RegExp(reArr.join('|'), "gi");
  714. 210.  -     art = art.innerHTML.replace(re, '');
  715. 211.  -     title = geByClass1('title', nfo);
  716. 212.  -     if (!title) title = ge('title' + aid);
  717. 213.  -     l = geByTag1('a', title);
  718. 214.  -     if (l) title = l.innerHTML;
  719. 215.  -     else title = title.innerHTML;
  720. 216.  -     title = title.replace(re, '');
  721. 217.  -     var data = ge('audio_info' + aid).value.split(','), url = data[0], duration = parseInt(data[1]);
  722. 218.  -     dur = audioPlayer.formatTime(duration);
  723. 219.  -     data = aid.split('_');
  724. 220.  -     var oid = data[0], aid = data[1], canAdd = (oid != vk.id) ? 1 : 0;
  725. 221.  -     if (!canAdd && data[2] && data[3]) {
  726. 222.  -       var wpt = ge('wpt' + data[2] + '_' + data[3]), post = wpt, postFound = false;
  727. 223.  -       if (wpt) {
  728. 224.  -         while (post) {
  729. 225.  -           post = post.parentNode;
  730. 226.  -           each(['reply_table', 'post_table', 'fw_reply_table', 'fw_post_table', 'pad_nwsa', 'pad_nws_data', 'feedback_row_content'], function() {
  731. 227.  -             if (hasClass(post, this)) {
  732. 228.  -               postFound = true;
  733. 229.  -               return false;
  734. 230.  -             }
  735. 231.  -           });
  736. 232.  -           if (postFound) break;
  737. 233.  -         }
  738. 234.  -         if (post) {
  739. 235.  -           var author = false;
  740. 236.  -           each(['author', 'fw_reply_author', 'fw_post_author', 'pad_nws_name'], function() {
  741. 237.  -             author = geByClass1(this, post);
  742. 238.  -             if (author) return false;
  743. 239.  -           });
  744. 240.  -           if (author) {
  745. 241.  -             var author_id = intval(author.getAttribute('data-from-id'));
  746. 242.  -             if (author_id && author_id != vk.id) {
  747. 243.  -               canAdd = 1;
  748. 244.  -             }
  749. 245.  -           }
  750. 246.  -         }
  751. 247.  -       }
  752. 248.  -     }
  753. 249.  -     var res = {
  754. 250.  -       0: oid,
  755. 251.  -       1: aid,
  756. 252.  -       2: url,
  757. 253.  -       3: duration,
  758. 254.  -       4: dur,
  759. 255.  -       5: art,
  760. 256.  -       6: title,
  761. 257.  -       7: 0,
  762. 258.  -       8: 0,
  763. 259.  -       9: canAdd
  764. 260.  -     };
  765. 261.  -     res.full_id = full_id;
  766. 262.  -     return res;
  767. 263.  -   },
  768. 264.  -   setSongInfo: function() {
  769. 265.  -     var _a = audioPlayer, aid = currentAudioId(), pl;
  770. 266.  -
  771. 267.  -     if ((pl = padAudioPlaylist()) && pl[aid]) {
  772. 268.  -       _a.lastSong = pl[aid];
  773. 269.  -     } else if (_a.songInfos[aid]) {
  774. 270.  -       _a.lastSong = _a.songInfos[aid];
  775. 271.  -     } else if (cur.defaultTrack && cur.defaultTrack.id == aid) {
  776. 272.  -       _a.lastSong = cur.defaultTrack;
  777. 273.  -     } else {
  778. 274.  -       _a.lastSong = _a.getSongInfoFromDOM(aid);
  779. 275.  -     }
  780. 276.  -     if (!_a.lastSong) return;
  781. 277.  -     ls.set('pad_lastsong', _a.lastSong);
  782. 278.  -     _a.lastSong.aid = aid;
  783. 279.  -   },
  784. 280.  -   updateURL: function(full_id, audio_id, url, duration) {
  785. 281.  -     if (ge('audio_info'+full_id)) {
  786. 282.  -       ge('audio_info'+full_id).value = url+','+duration;
  787. 283.  -     }
  788. 284.  -     if (window.cur && cur.audios && cur.audios[audio_id]) {
  789. 285.  -       cur.audios[audio_id][2] = url;
  790. 286.  -       cur.audios[audio_id][3] = duration;
  791. 287.  -     }
  792. 288.  -     if (window.audioPlaylist && window.audioPlaylist[full_id]) {
  793. 289.  -       window.audioPlaylist[full_id][2] = url;
  794. 290.  -       window.audioPlaylist[full_id][3] = duration;
  795. 291.  -     }
  796. 292.  -     var pad_plist = ls.get('pad_playlist');
  797. 293.  -     if (pad_plist && pad_plist[full_id]) {
  798. 294.  -       this.setPadPlaylist(window.audioPlaylist);
  799. 295.  -     }
  800. 296.  -     if (window.cur && cur.nextPlaylist && cur.nextPlaylist[full_id]) {
  801. 297.  -       cur.nextPlaylist[full_id][2] = url;
  802. 298.  -       cur.nextPlaylist[full_id][3] = duration;
  803. 299.  -     }
  804. 300.  -   },
  805. 301.  -   reloadPlaylist: function() {
  806. 302.  -     if (window.cur && cur.audiosReloadedAll) return;
  807. 303.  -     if (window.audioPlaylist || window.cur && cur.audiosList && cur.audiosList['all'] && cur.oid) {
  808. 304.  -       var _a = audioPlayer;
  809. 305.  -       var query = {act: 'reload_playlist'};
  810. 306.  -       if (window.audioPlaylist) {
  811. 307.  -         var q = [];
  812. 308.  -         var i = 0, j = 0;
  813. 309.  -         for (var audio in window.audioPlaylist) {
  814. 310.  -           if (j >= 100) { j = 0; i++; }
  815. 311.  -           if (!q[i]) q[i] = [];
  816. 312.  -           q[i].push(audio);
  817. 313.  -           j++;
  818. 314.  -         }
  819. 315.  -         for (var i in q) {
  820. 316.  -           q[i] = q[i].join(',');
  821. 317.  -         }
  822. 318.  -         for (var i in q) {
  823. 319.  -           query['l['+i+']'] = q[i];
  824. 320.  -         }
  825. 321.  -       }
  826. 322.  -       if (window.cur && cur.audiosList && cur.audiosList['all'] && cur.oid) {
  827. 323.  -         query['oid'] = cur.oid;
  828. 324.  -       }
  829. 325.  -       ajax.post('audio', query, {onDone: function(list) {
  830. 326.  -         if (list) for (var i in list) {
  831. 327.  -           var a = list[i];
  832. 328.  -           var audio_id = i.split('_')[1];
  833. 329.  -           _a.updateURL(i, audio_id, a[0], a[1]);
  834. 330.  -         }
  835. 331.  -         if (!window.cur) window.cur = {};
  836. 332.  -         cur.audiosReloadedAll = true;
  837. 333.  -         setTimeout(function(){delete cur.audiosReloadedAll;}, 60000);
  838. 334.  -       }});
  839. 335.  -     }
  840. 336.  -   },
  841. 337.  -   reloadAudio: function(id) {
  842. 338.  -     ids = id.split('_');
  843. 339.  -     if (window.cur && (cur.audiosReloadedAll || cur.audiosReloaded && cur.audiosReloaded[id])) {
  844. 340.  -       setTimeout(showFastBox({title: getLang('global_error')}, getLang('audio_error_loading'), getLang('global_close')).hide, 2000);
  845. 341.  -     } else {
  846. 342.  -       ajax.post('audio', {act: 'reload_audio', owner_id: ids[0], audio_id: ids[1]}, {onDone: function(res) {
  847. 343.  -         if (res) {
  848. 344.  -           var _a = audioPlayer;
  849. 345.  -           _a.updateURL(id, ids[1], res[0], res[1]);
  850. 346.  -           _a.setSongInfo();
  851. 347.  -           _a.duration = res[1];
  852. 348.  -           _a.player.loadAudio(res[0]);
  853. 349.  -           _a.setControlsTitle();
  854. 350.  -           _a.setGraphics('load');
  855. 351.  -           _a.playback();
  856. 352.  -         }
  857. 353.  -         if (!window.cur) window.cur = {};
  858. 354.  -         if (!cur.audiosReloaded) cur.audiosReloaded = {};
  859. 355.  -         cur.audiosReloaded[id] = true;
  860. 356.  -         setTimeout(function(){delete cur.audiosReloaded[id];}, 60000);
  861. 357.  -       }});
  862. 358.  -     }
  863. 359.  -   },
  864. 360.  -   sendNotification: function(data) {
  865. 361.  -     var _n = window.Notifier;
  866. 362.  -     if (_n) _n.lcSend('audio_start', data);
  867. 363.  -     try {
  868. 364.  -       if (ge('video_player') && ge('video_player').playVideo) ge('video_player').playVideo(false);
  869. 365.  -     } catch(e) {}
  870. 366.  -   },
  871. 367.  -   setAid: function(aid) {
  872. 368.  -     audioPlayer.id = aid;
  873. 369.  -     ls.set('audio_id', aid);
  874. 370.  -   },
  875. 371.  -   operate: function(orig_id, nextPlaylist, opts) {
  876. 372.  -     var _a = audioPlayer, aid = currentAudioId(), id = orig_id;
  877. 373.  -     if (id.substr(-4) == '_pad') {
  878. 374.  -       id = id.substr(0, id.length - 4);
  879. 375.  -     }
  880. 376.  -
  881. 377.  -     if (!_a.player || (!ge('flash_audio') && !ge('html5_audio'))) {
  882. 378.  -       _a.initPlayer(orig_id);
  883. 379.  -       return;
  884. 380.  -     }
  885. 381.  -     if (opts && opts.songInfo) {
  886. 382.  -       _a.songInfos[id] = opts.songInfo;
  887. 383.  -     }
  888. 384.  -
  889. 385.  -     if (aid == id) {
  890. 386.  -       if (_a.player.paused()) {
  891. 387.  -         _a.sendNotification({id: id});
  892. 388.  -         if (_a.pausedByVideo) _a.pausedByVideo = null;
  893. 389.  -         if (_a.time != undefined) {
  894. 390.  -           try {_a.player.playAudio(_a.time)}catch(e){};
  895. 391.  -           _a.time = null;
  896. 392.  -         } else _a.player.playAudio();
  897. 393.  -         _a.setGraphics('play');
  898. 394.  -         _a.playback();
  899. 395.  -         if (!nextPlaylist && (cur.module == 'audio' || window._pads && _pads.shown == 'mus')) {
  900. 396.  -           if (ge('audio' + aid)) _a.scrollToTrack(aid);
  901. 397.  -         }
  902. 398.  -       } else {
  903. 399.  -         _a.player.pauseAudio();
  904. 400.  -         _a.setGraphics('pause');
  905. 401.  -         _a.playback(true);
  906. 402.  -       }
  907. 403.  -     } else {
  908. 404.  -       _a.sendNotification({id: id});
  909. 405.  -       if (_a.pausedByVideo) _a.pausedByVideo = null;
  910. 406.  -       if (aid) _a.stop();
  911. 407.  -       _a.setAid(id);
  912. 408.  -       if (window.padPlClicked/* || orig_id.substr(-4) == '_pad'*/) {
  913. 409.  -         var pList = _a.isPlaylistGlobal() ? ls.get('pad_playlist') || window.audioPlaylist : padAudioPlaylist();
  914. 410.  -         if (pList && pList[id]) {
  915. 411.  -           if (window.curNotifier && curNotifier.instance_id) {
  916. 412.  -             pList.instance = curNotifier.instance_id;
  917. 413.  -             _a.setPadPlaylist(pList);
  918. 414.  -           }
  919. 415.  -           nextPlaylist = cur.nextPlaylist && cur.nextPlaylist[id];
  920. 416.  -         }
  921. 417.  -         delete window.padPlClicked;
  922. 418.  -       }
  923. 419.  -       if (nextPlaylist) {
  924. 420.  -         if (cur.curSection == 'popular' || window._pads && _pads.shown == 'mus' && _pads.cur && _pads.cur.curSection == 'popular' || cur.audioTop) {
  925. 421.  -           _a.top = true;
  926. 422.  -         } else {
  927. 423.  -           delete _a.top;
  928. 424.  -         }
  929. 425.  -         _a.setPlaybackParams();
  930. 426.  -         if (cur && cur.nextPlaylist && cur.nextPlaylist[id]) {
  931. 427.  -           delete cur.nextPlaylist.has_more;
  932. 428.  -           window.audioPlaylist = clone(cur.nextPlaylist);
  933. 429.  -           audioPlaylist.address = nav.strLoc;
  934. 430.  -           cur.nextPlaylist = null;
  935. 431.  -         } else if (id.substr(-4) == '_pad' && cur && cur.nextPlaylist && cur.nextPlaylist[id.substr(0, id.length - 4)]) {
  936. 432.  -           _a.operate(id.substr(0, id.length - 4), nextPlaylist, opts);
  937. 433.  -           return;
  938. 434.  -         } else {
  939. 435.  -           if (!window.audioPlaylist || !window.audioPlaylist[id]) {
  940. 436.  -             if (ge('audio' + orig_id)) {
  941. 437.  -               _a.createDynamicPlaylist(orig_id, true);
  942. 438.  -             } else if (window.audioPlaylist) {
  943. 439.  -               window.audioPlaylist = null;
  944. 440.  -             }
  945. 441.  -           }
  946. 442.  -         }
  947. 443.  -         _a.setPadPlaylist(window.audioPlaylist);
  948. 444.  -       }
  949. 445.  -       if (_a.lastSong == undefined || id != _a.lastSong.aid) _a.setSongInfo();
  950. 446.  -       if (!_a.lastSong) return;
  951. 447.  -       if (_a.lastSong[0] && _a.lastSong[1] && parseInt(_a.lastSong[11])) {
  952. 448.  -         showAudioClaimWarning(_a.lastSong[0], _a.lastSong[0], '', -1, _a.lastSong[5] + ' &ndash; ' + _a.lastSong[6]);
  953. 449.  -         _a.setAid(null);
  954. 450.  -         return;
  955. 451.  -       }
  956. 452.  -       var url = _a.lastSong[2];
  957. 453.  -       _a.duration = _a.lastSong[3];
  958. 454.  -       if (url) {
  959. 455.  -         try {
  960. 456.  -           _a.player.loadAudio(url);
  961. 457.  -         } catch(e){}
  962. 458.  -       } else {
  963. 459.  -         _a.reloadAudio(id);
  964. 460.  -       }
  965. 461.  -       _a.setControlsTitle();
  966. 462.  -       var ids = id.split('_');
  967. 463.  -       var uid = (ids && ids.length > 1) ? ids[0] : vk.id;
  968. 464.  -       if (intval(uid) == cur.audioFriend) {
  969. 465.  -         cur.audioFriendPlaying = cur.audioFriend;
  970. 466.  -         if (window.Audio) Audio.cacheFriendsList();
  971. 467.  -       }
  972. 468.  -       _a.setGraphics('load');
  973. 469.  -       updGlobalPlayer();
  974. 470.  -       if (url) _a.playback();
  975. 471.  -     }
  976. 472.  -     if (_a.gpHidden) {
  977. 473.  -       _a.gpHidden = false;
  978. 474.  -       updGlobalPlayer();
  979. 475.  -     }
  980. 476.  -   },
  981. 477.  -   setGraphics: function(act) {
  982. 478.  -     var _a = audioPlayer, head_play = ge('head_play_btn'), aid = currentAudioId(),
  983. 479.  -       _row = ge('audio' +aid), pad_row = ge('audio'+aid+'_pad'), gp_play = ge('gp_play');
  984. 480.  -     if (!aid) return;
  985. 481.  -     switch (act) {
  986. 482.  -       case 'play':
  987. 483.  -         _a.setIcon('playicon');
  988. 484.  -         if (_row) {
  989. 485.  -           addClass(ge('play' + aid), 'playing');
  990. 486.  -           addClass(_row, 'current');
  991. 487.  -         }
  992. 488.  -         if (pad_row) {
  993. 489.  -           addClass(ge('play' + aid + '_pad'), 'playing');
  994. 490.  -           addClass(pad_row, 'current');
  995. 491.  -         }
  996. 492.  -         if (head_play) {
  997. 493.  -           addClass(head_play, 'playing');
  998. 494.  -         }
  999. 495.  -         if (gp_play) {
  1000. 496.  -           addClass(gp_play, 'playing');
  1001. 497.  -         }
  1002. 498.  -         if (_a.controls) {
  1003. 499.  -           for (var i in _a.controls) {
  1004. 500.  -             var obj = _a.controls[i];
  1005. 501.  -             if (obj.play) addClass(obj.play, 'playing');
  1006. 502.  -           }
  1007. 503.  -         }
  1008. 504.  -         break;
  1009. 505.  -       case 'pause':
  1010. 506.  -         _a.setIcon('pauseicon');
  1011. 507.  -         if (_row) {
  1012. 508.  -           removeClass(ge('play' + aid), 'playing');
  1013. 509.  -         }
  1014. 510.  -         if (pad_row) {
  1015. 511.  -           removeClass(ge('play' + aid + '_pad'), 'playing');
  1016. 512.  -         }
  1017. 513.  -         if (head_play) {
  1018. 514.  -           removeClass(head_play, 'playing');
  1019. 515.  -         }
  1020. 516.  -         if (gp_play) {
  1021. 517.  -           removeClass(gp_play, 'playing');
  1022. 518.  -         }
  1023. 519.  -         if (_a.controls) {
  1024. 520.  -           for (var i in _a.controls) {
  1025. 521.  -             var obj = _a.controls[i];
  1026. 522.  -             if (obj.play) removeClass(obj.play, 'playing');
  1027. 523.  -           }
  1028. 524.  -         }
  1029. 525.  -         break;
  1030. 526.  -       case 'stop':
  1031. 527.  -         _a.setIcon('icon');
  1032. 528.  -         if (_row) {
  1033. 529.  -           if (ge('repeat' + aid)) hide('repeat' + aid);
  1034. 530.  -           removeClass(ge('play' + aid), 'playing');
  1035. 531.  -           removeClass(_row, 'current');
  1036. 532.  -
  1037. 533.  -           if (aid) {
  1038. 534.  -             var t = _a.duration || _a.lastSong && _a.lastSong[3] || ge('audio_info' + aid).value.split(',')[1],
  1039. 535.  -                 res = _a.formatTime(t),
  1040. 536.  -                 dur = geByClass1('duration', ge('audio' + aid));
  1041. 537.  -             if (dur && res) dur.innerHTML = res;
  1042. 538.  -           }
  1043. 539.  -
  1044. 540.  -         }
  1045. 541.  -         if (pad_row) {
  1046. 542.  -           removeClass(ge('play' + aid + '_pad'), 'playing');
  1047. 543.  -           removeClass(pad_row, 'current');
  1048. 544.  -         }
  1049. 545.  -         if (head_play) {
  1050. 546.  -           removeClass(head_play, 'playing');
  1051. 547.  -         }
  1052. 548.  -         if (gp_play) {
  1053. 549.  -           removeClass(gp_play, 'playing');
  1054. 550.  -         }
  1055. 551.  -         if (_a.controls) {
  1056. 552.  -           for (var i in _a.controls) {
  1057. 553.  -             var obj = _a.controls[i];
  1058. 554.  -             if (obj.play) removeClass(obj.play, 'playing');
  1059. 555.  -           }
  1060. 556.  -         }
  1061. 557.  -         break;
  1062. 558.  -       case 'load':
  1063. 559.  -         var loaded = 0, playerVol = _a.player.getVolume(),
  1064. 560.  -             vol = Math.round(_a.volW * playerVol);
  1065. 561.  -         if (vk.rtl) vol = -vol;
  1066. 562.  -         _a.setIcon('playicon');
  1067. 563.  -         if (_a.controls) {
  1068. 564.  -           for (var i in _a.controls) {
  1069. 565.  -             var obj = _a.controls[i];
  1070. 566.  -             if (obj.volume) {
  1071. 567.  -               setStyle(obj.volume, {width: (playerVol * 100) + '%'})
  1072. 568.  -             }
  1073. 569.  -           }
  1074. 570.  -         }
  1075. 571.  -         if (_row) {
  1076. 572.  -           addClass(ge('play' + aid), 'playing');
  1077. 573.  -           addClass(_row, 'current');
  1078. 574.  -           if (ge('player' + aid)) {
  1079. 575.  -             if (ge('audio_vol' + aid) && browser.mobile) {
  1080. 576.  -               hide('audio_vol' + aid);
  1081. 577.  -             }
  1082. 578.  -             if (ge('audio_vol_line' + aid)) {
  1083. 579.  -               setStyle(ge('audio_vol_line' + aid), {width: (playerVol * 100) + '%'});
  1084. 580.  -             }
  1085. 581.  -           }
  1086. 582.  -           var r = ge('repeat' + aid);
  1087. 583.  -           if (r) {
  1088. 584.  -             show(r);
  1089. 585.  -             if (_a.repeat) {
  1090. 586.  -               addClass(r, 'on');
  1091. 587.  -             } else {
  1092. 588.  -               removeClass(r, 'on');
  1093. 589.  -             }
  1094. 590.  -           }
  1095. 591.  -         }
  1096. 592.  -         var tabCurRow = geByClass1('tab_current', ge('pad_playlist'));
  1097. 593.  -         if (tabCurRow) {
  1098. 594.  -           removeClass(tabCurRow, 'tab_current');
  1099. 595.  -         }
  1100. 596.  -         if (pad_row) {
  1101. 597.  -           addClass(ge('play' + aid + '_pad'), 'playing');
  1102. 598.  -           addClass(pad_row, 'current');
  1103. 599.  -         }
  1104. 600.  -         if (head_play) {
  1105. 601.  -           addClass(head_play, 'playing');
  1106. 602.  -         }
  1107. 603.  -         if (gp_play) {
  1108. 604.  -           addClass(gp_play, 'playing');
  1109. 605.  -         }
  1110. 606.  -         var a = window.audioPlaylist && audioPlaylist[aid];
  1111. 607.  -         if (_a.controls) {
  1112. 608.  -           for (var i in _a.controls) {
  1113. 609.  -             var obj = _a.controls[i];
  1114. 610.  -             if (obj.play) addClass(obj.play, 'playing');
  1115. 611.  -             if (obj.add && obj.container) {
  1116. 612.  -               var mid = aid.split('_')[0];
  1117. 613.  -               toggleClass(obj.container, 'add', mid != vk.id || a && a[9] && intval(a[9]));
  1118. 614.  -             }
  1119. 615.  -           }
  1120. 616.  -         }
  1121. 617.  -         break;
  1122. 618.  -     }
  1123. 619.  -   },
  1124. 620.  -   stop: function() {
  1125. 621.  -     var _a = audioPlayer, aid = currentAudioId();
  1126. 622.  -     if (aid) {
  1127. 623.  -       if (_a.player && !_a.player.paused()) _a.player.stopAudio();
  1128. 624.  -       _a.setGraphics('stop');
  1129. 625.  -       _a.setAid(null);
  1130. 626.  -     }
  1131. 627.  -   },
  1132. 628.  -   pauseTrack: function() {
  1133. 629.  -     var _a = audioPlayer, aid = currentAudioId();
  1134. 630.  -     if (aid && _a.player && !_a.player.paused()) {
  1135. 631.  -       _a.operate(aid);
  1136. 632.  -     }
  1137. 633.  -   },
  1138. 634.  -   playTrack: function() {
  1139. 635.  -     var _a = audioPlayer, aid = currentAudioId();
  1140. 636.  -     if (aid && _a.player && _a.player.paused()) {
  1141. 637.  -       _a.operate(aid);
  1142. 638.  -     }
  1143. 639.  -   },
  1144. 640.  -   setPlaybackParams: function() {
  1145. 641.  -     var _a = audioPlayer, aid = currentAudioId(), ids = (aid || '').split('_'), __cur = window._pads && _pads.shown == 'mus' && _pads.cur, params = {};
  1146. 642.  -     if (cur.curSection == 'recommendations' || __cur && __cur.curSection == 'recommendations') {
  1147. 643.  -       params.recommendation = 1;
  1148. 644.  -     }
  1149. 645.  -     if (cur.module == 'search' && nav.objLoc['c[section]'] == 'audio' && !nav.objLoc['c[q]']) {
  1150. 646.  -       params.top = 1;
  1151. 647.  -     }
  1152. 648.  -     if (cur.module == 'audio' && cur.curSection == 'popular' && !cur.searchStr || __cur && __cur.curSection == 'popular' && !__cur.searchStr) {
  1153. 649.  -       params.top_audio = 1;
  1154. 650.  -     }
  1155. 651.  -     if (cur.module == 'audio' && cur.curSection == 'feed' && !cur.searchStr || __cur && __cur.curSection == 'feed' && !__cur.searchStr) {
  1156. 652.  -       params.feed_audio = 1;
  1157. 653.  -     }
  1158. 654.  -     if ((aid + '').match(/^-?\d+_\d+_s(-?\d+)(?:_|$)/) && window.audioPlaylist && audioPlaylist[aid]) {
  1159. 655.  -       params.status = 1;
  1160. 656.  -     }
  1161. 657.  -     if (_a.isAudioFriend(ids[0], aid)) {
  1162. 658.  -       params.friend = ids[0];
  1163. 659.  -     }
  1164. 660.  -     if ((cur.module == 'groups' || cur.module == 'public' || cur.module == 'audio') && cur.oid == ids[0] && cur.oid < 0) {
  1165. 661.  -       params.group = 1;
  1166. 662.  -     }
  1167. 663.  -     if ((cur.module == 'audio' || cur.module == 'feed') && nav.objLoc['q'] || cur.module == 'search' && nav.objLoc['c[q]'] || __cur && __cur.searchStr) {
  1168. 664.  -       params.search = 1;
  1169. 665.  -     }
  1170. 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) {
  1171. 667.  -       params.album = 1;
  1172. 668.  -     }
  1173. 669.  -     if (cur.module == 'audio' && cur.curSection && cur.curSection.substr(0, 5) == 'owner' || __cur && __cur.curSection && __cur.curSection.substr(0, 5) == 'owner') {
  1174. 670.  -       params.top_bands = 1;
  1175. 671.  -     }
  1176. 672.  -     if (cur.module == 'audio' && cur.curSection == 'popular' && cur.genre || __cur && __cur.curSection == 'popular' && __cur.genre) {
  1177. 673.  -       params.popular_genre = 1;
  1178. 674.  -     }
  1179. 675.  -     if (cur.module == 'audio' && cur.club || __cur && __cur.club) {
  1180. 676.  -       params.club = cur.club;
  1181. 677.  -     }
  1182. 678.  -     if (!params.search && cur.module == 'feed' && !__cur) {
  1183. 679.  -       params.feed = 1;
  1184. 680.  -     }
  1185. 681.  -     _a.playbackParams = params;
  1186. 682.  -   },
  1187. 683.  -   isAudioFriend: function(oid, full_id) {
  1188. 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');
  1189. 685.  -   },
  1190. 686.  -   playbackSent: 0,
  1191. 687.  -   statusSent: 0,
  1192. 688.  -   playback: function(paused) {
  1193. 689.  -     var _a = audioPlayer, aid = currentAudioId(), ids = (aid || '').split('_');
  1194. 690.  -     if (ids.length < 2 && cur.oid) { // edit mode
  1195. 691.  -       ids = [cur.oid, aid];
  1196. 692.  -       aid = ids.join('_');
  1197. 693.  -     }
  1198. 694.  -     if (_a.hasStatusExport() && ids[1] != _a.statusSent) {
  1199. 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);
  1200. 696.  -       _a.statusSent = ids[1];
  1201. 697.  -     }
  1202. 698.  -     clearTimeout(_a.playbackTimer);
  1203. 699.  -     if (!paused && aid && vk.id) {
  1204. 700.  -       if (ids[1] != _a.playbackSent) {
  1205. 701.  -         var sendPlayback = function() {
  1206. 702.  -           if (!cur.startedAids || !cur.startedAids[aid]) {
  1207. 703.  -             _a.playbackTimer = setTimeout(sendPlayback, 10000);
  1208. 704.  -             return;
  1209. 705.  -           }
  1210. 706.  -           var query = {act: 'playback', full_id: aid, hash: _a.addHash};
  1211. 707.  -           if (ids[0] == vk.id && ids[1]) query.id = ids[1];
  1212. 708.  -           if (_a.playbackParams) extend(query, _a.playbackParams);
  1213. 709.  -           ajax.post('audio', query, {onDone: function() {
  1214. 710.  -             _a.playbackSent = ids[1];
  1215. 711.  -           }});
  1216. 712.  -         };
  1217. 713.  -         _a.playbackTimer = setTimeout(sendPlayback, 10000);
  1218. 714.  -       }
  1219. 715.  -     }
  1220. 716.  -   },
  1221. 717.  -   keyPressed: function(otherTab, e) {
  1222. 718.  -     e = normEvent(e);
  1223. 719.  -     if (!e.keyCode) return;
  1224. 720.  -     var keyCodes = [176, 177, 178, 179, KEY.LEFT, KEY.RIGHT], inArr = false;
  1225. 721.  -     each(keyCodes, function(k, v){
  1226. 722.  -       if (e.keyCode == v) {
  1227. 723.  -         inArr = true;
  1228. 724.  -         return false;
  1229. 725.  -       }
  1230. 726.  -     });
  1231. 727.  -     if ((e.keyCode == KEY.LEFT || e.keyCode == KEY.RIGHT) && otherTab) return;
  1232. 728.  -     if (!inArr) return;
  1233. 729.  -     var cn = window.curNotifier, pData = ls.get('pad_pldata'), anotherTab = cn && pData && cn.instance_id && pData.instance && cn.instance_id !== pData.instance;
  1234. 730.  -     if (!e.noBroadcast) {
  1235. 731.  -       if (anotherTab) {
  1236. 732.  -         var _n = window.Notifier;
  1237. 733.  -         if (_n) _n.lcSend('audio_mediakey', {keyCode: e.keyCode, noBroadcast: 1});
  1238. 734.  -         return;
  1239. 735.  -       }
  1240. 736.  -     } else {
  1241. 737.  -       if (anotherTab) return;
  1242. 738.  -     }
  1243. 739.  -     var _a = audioPlayer, aid = currentAudioId();
  1244. 740.  -     if (!aid) return;
  1245. 741.  -     switch (e.keyCode) {
  1246. 742.  -       case 179:
  1247. 743.  -         playAudioNew(aid);
  1248. 744.  -         break;
  1249. 745.  -       case 178:
  1250. 746.  -         _a.stop();
  1251. 747.  -         audioPlayer.onPlayProgress(0, 1, true);
  1252. 748.  -         break;
  1253. 749.  -       case 177:
  1254. 750.  -         _a.prevTrack();
  1255. 751.  -         break;
  1256. 752.  -       case 176:
  1257. 753.  -         _a.nextTrack();
  1258. 754.  -         break;
  1259. 755.  -       case KEY.LEFT:
  1260. 756.  -         if (_a.canChangePr(e)) {
  1261. 757.  -           _a.changePr(-1);
  1262. 758.  -         }
  1263. 759.  -         break;
  1264. 760.  -       case KEY.RIGHT:
  1265. 761.  -         if (_a.canChangePr(e)) {
  1266. 762.  -           _a.changePr(1);
  1267. 763.  -         }
  1268. 764.  -         break;
  1269. 765.  -     }
  1270. 766.  -   },
  1271. 767.  -   canChangePr: function(e) {
  1272. 768.  -     var chatInput = window.curFastChat && curFastChat.peer && geByClass1('fc_editable', ge('rb_box_fc_peer' + curFastChat.peer)),
  1273. 769.  -         inp = cur.__focused || chatInput || window._pads && _pads.shown && geByTag1('textarea', _pads.content);
  1274. 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>'));
  1275. 771.  -   },
  1276. 772.  -   changePr: function(delta) {
  1277. 773.  -     var _a = audioPlayer, aid = currentAudioId();
  1278. 774.  -     if (!aid) return;
  1279. 775.  -     _a.time = (_a.curTime || 0) + delta * _a.prStep;
  1280. 776.  -     if (_a.time < 0) _a.time = 0;
  1281. 777.  -     if (_a.duration && _a.time > _a.duration) _a.time = _a.duration;
  1282. 778.  -     try{
  1283. 779.  -       if (!_a.player.paused()) {
  1284. 780.  -         _a.player.playAudio(_a.time);
  1285. 781.  -       }
  1286. 782.  -       _a.player.callPlayProgress();
  1287. 783.  -     }catch(e){};
  1288. 784.  -   },
  1289. 785.  -   mouseUp: function(e) {
  1290. 786.  -     var _a = audioPlayer;
  1291. 787.  -     if (_a.player && _a.player.paused) {
  1292. 788.  -       if (_a.prClicked) {
  1293. 789.  -         if (_a.time !== undefined) try{
  1294. 790.  -           if (!_a.player.paused()) {
  1295. 791.  -             _a.player.playAudio(_a.time);
  1296. 792.  -             _a.time = null;
  1297. 793.  -           }
  1298. 794.  -         }catch(e){};
  1299. 795.  -       }
  1300. 796.  -       _a.player.callPlayProgress();
  1301. 797.  -     }
  1302. 798.  -     if (_a.volClicked) {
  1303. 799.  -       if (_a.controls && _a.controls[_a.volClicked]) {
  1304. 800.  -         removeClass(_a.controls[_a.volClicked].volumeArea, 'down');
  1305. 801.  -       }
  1306. 802.  -       hide('audio_tip_wrap');
  1307. 803.  -     }
  1308. 804.  -     if (_a.prClicked && _a.controls && _a.controls[_a.prClicked]) {
  1309. 805.  -       removeClass(_a.controls[_a.prClicked].progressArea, 'down');
  1310. 806.  -     }
  1311. 807.  -     _a.volClicked = null;
  1312. 808.  -     _a.prClicked = null;
  1313. 809.  -   },
  1314. 810.  -   tipOver: function() {
  1315. 811.  -     if (cur.hideTipTO) {
  1316. 812.  -       clearTimeout(cur.hideTipTO);
  1317. 813.  -     }
  1318. 814.  -   },
  1319. 815.  -   tipOut: function() {
  1320. 816.  -     cur.hideTipTO = setTimeout(hide.pbind('audio_tip_wrap'), 100);
  1321. 817.  -   },
  1322. 818.  -   showTip: function(text, x, y, fixed, pad) {
  1323. 819.  -     if (!ge('audio_tip_wrap')) {
  1324. 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>'));
  1325. 821.  -     }
  1326. 822.  -     ge('audio_tip').innerHTML = text;
  1327. 823.  -     var sz = getSize('audio_tip_wrap'), w = sz[0] || 32, h = sz[1] || 18, l = x - (w + 1) / 2, a = w / 2 - 3;
  1328. 824.  -     setStyle(ge('audio_tip_wrap'), {left: l, top: y - h - 7, position: fixed ? 'fixed' : 'absolute', zIndex: curBox() ? 1001 : (pad ? 401 : 101)});
  1329. 825.  -     setStyle(ge('audio_tip_arrow'), {left: a});
  1330. 826.  -     show('audio_tip_wrap');
  1331. 827.  -   },
  1332. 828.  -   mouseMove: function(e) {
  1333. 829.  -     var _a = audioPlayer;
  1334. 830.  -     if (_a.volClicked) _a.volClick(e, _a.volClicked);
  1335. 831.  -     if (_a.prClicked) _a.prClick(e, _a.prClicked);
  1336. 832.  -     if (!audioPlayer.duration) return;
  1337. 833.  -
  1338. 834.  -     var overFound = false, aid = currentAudioId();
  1339. 835.  -     if (_a.controls) {
  1340. 836.  -       for (var i in _a.controls) {
  1341. 837.  -         var obj = _a.controls[i];
  1342. 838.  -         if (obj.progressArea && hasClass(obj.progressArea, 'over')) {
  1343. 839.  -           overFound = true;
  1344. 840.  -           var time = intval(_a.getPrPos(e, i) * _a.duration / 100), fixed = _a.controls[i].fixed,
  1345. 841.  -               timeText = _a.formatTime(time);
  1346. 842.  -           _a.showTip(timeText, _a.defX(e), getXY(obj.progressArea, fixed)[1], fixed, i == 'pd');
  1347. 843.  -           break;
  1348. 844.  -         }
  1349. 845.  -       }
  1350. 846.  -     }
  1351. 847.  -     if (!overFound && aid && hasClass(ge('audio_pr' + aid), 'over')) {
  1352. 848.  -       overFound = true;
  1353. 849.  -       var time = intval(_a.getPrPos(e, null) * _a.duration / 100), timeText = _a.formatTime(time);
  1354. 850.  -       _a.showTip(timeText, _a.defX(e), getXY(ge('audio_pr'+aid))[1]);
  1355. 851.  -     }
  1356. 852.  -   },
  1357. 853.  -   defX: function(e) {
  1358. 854.  -     if (!e) e = window.event;
  1359. 855.  -     var hscroll = !document.body.scrollLeft && (browser.ipad || browser.iphone4 || browser.ipod4) ? 0 : (document.all ? document.body.scrollLeft : window.pageXOffset);
  1360. 856.  -     return intval(e.clientX + hscroll);
  1361. 857.  -   },
  1362. 858.  -   getPrPos: function(e, objName) {
  1363. 859.  -     var _a = audioPlayer, el, pos, prSize, val, defX;
  1364. 860.  -     if (objName && _a.controls && _a.controls[objName]) {
  1365. 861.  -       el = _a.controls[objName].progressArea, pos = getXY(el,_a.controls[objName].fixed)[0],
  1366. 862.  -       val = _a.defX(e) - pos, prSize = getSize(el)[0];
  1367. 863.  -     } else {
  1368. 864.  -       var aid = currentAudioId();
  1369. 865.  -       el = ge('audio_back_line' + aid), pos = getXY(el)[0],
  1370. 866.  -       val = _a.defX(e) - pos, prSize = getSize(el)[0];
  1371. 867.  -     }
  1372. 868.  -     val = Math.min(100, Math.max(0, val / prSize * 100));
  1373. 869.  -     if (vk.rtl) val = 100 - val;
  1374. 870.  -     return val;
  1375. 871.  -   },
  1376. 872.  -   prClick: function(e, objName) {
  1377. 873.  -     if (!e) e = window.event
  1378. 874.  -     if (e.button == 2) return;
  1379. 875.  -     var _a = audioPlayer, aid = currentAudioId();
  1380. 876.  -     if (objName && _a.controls && _a.controls[objName] && _a.controls[objName].progressArea) {
  1381. 877.  -       if (!_a.player) return;
  1382. 878.  -       if (!_a.prClicked) {
  1383. 879.  -         _a.prClicked = objName;
  1384. 880.  -         addClass(_a.controls[objName].progressArea, 'down');
  1385. 881.  -       }
  1386. 882.  -     } else {
  1387. 883.  -       if (!_a.prClicked) {
  1388. 884.  -         _a.prClicked = true;
  1389. 885.  -       }
  1390. 886.  -     }
  1391. 887.  -     var val = _a.getPrPos(e, objName);
  1392. 888.  -     _a.time = val / 100 * _a.duration;
  1393. 889.  -     if (_a.controls) {
  1394. 890.  -       for (var i in _a.controls) {
  1395. 891.  -         var obj = _a.controls[i];
  1396. 892.  -         if (obj.progress) {
  1397. 893.  -           setStyle(obj.progress, {width: val + '%'});
  1398. 894.  -         }
  1399. 895.  -       }
  1400. 896.  -     }
  1401. 897.  -     if (aid && ge('player' + aid)) {
  1402. 898.  -       setStyle(ge('audio_pr_line' + aid), {width: val + '%'});
  1403. 899.  -     }
  1404. 900.  -     cancelEvent(e);
  1405. 901.  -   },
  1406. 902.  -   volClick: function(e, objName) {
  1407. 903.  -     if (!e) e = window.event
  1408. 904.  -     if (e.button == 2) return;
  1409. 905.  -     var _a = audioPlayer, el, xy, val, pos, aid = currentAudioId();
  1410. 906.  -     if (objName && _a.controls && _a.controls[objName] && _a.controls[objName].volumeArea) {
  1411. 907.  -       var obj = _a.controls[objName], fixed = _a.controls[objName].fixed;
  1412. 908.  -       el = obj.volumeArea, pos = getXY(el, fixed), val = _a.defX(e) - pos[0];
  1413. 909.  -       var volSize = getSize(el)[0], val = val / volSize * 100;
  1414. 910.  -       val = Math.min(100, Math.max(0, val));
  1415. 911.  -       if (vk.rtl) val = 100 - val;
  1416. 912.  -       if (!_a.volClicked) {
  1417. 913.  -         _a.volClicked = objName;
  1418. 914.  -         addClass(obj.volumeArea, 'down');
  1419. 915.  -       }
  1420. 916.  -       var tipX = Math.min(pos[0] + volSize, Math.max(pos[0], _a.defX(e)));
  1421. 917.  -       _a.showTip(intval(val) + '%', tipX, pos[1], fixed, objName == 'pd');
  1422. 918.  -     } else {
  1423. 919.  -       el = ge('audio_vol_back_line' + aid), pos = getXY(el), val = _a.defX(e) - pos[0];
  1424. 920.  -       var volSize = getSize(el)[0], val = val / volSize * 100;
  1425. 921.  -       val = Math.min(100, Math.max(0, val));
  1426. 922.  -       if (vk.rtl) val = 100 - val;
  1427. 923.  -       if (!_a.volClicked) {
  1428. 924.  -         _a.volClicked = true;
  1429. 925.  -       }
  1430. 926.  -       var tipX = Math.min(pos[0] + volSize, Math.max(pos[0], _a.defX(e)));
  1431. 927.  -       _a.showTip(intval(val) + '%', tipX, pos[1]);
  1432. 928.  -     }
  1433. 929.  -     if (_a.controls) {
  1434. 930.  -       for (var i in _a.controls) {
  1435. 931.  -         var obj = _a.controls[i];
  1436. 932.  -         if (obj.volume) {
  1437. 933.  -           setStyle(obj.volume, {width: val + '%'});
  1438. 934.  -         }
  1439. 935.  -       }
  1440. 936.  -     }
  1441. 937.  -     if (aid && ge('player' + aid)) {
  1442. 938.  -       setStyle(ge('audio_vol_line' + aid), {width: val + '%'});
  1443. 939.  -     }
  1444. 940.  -     if (_a.player) _a.player.setVolume(val / 100);
  1445. 941.  -     setCookie('audio_vol', Math.round(val), 365);
  1446. 942.  -     cancelEvent(e);
  1447. 943.  -   },
  1448. 944.  -   toggleRepeat: function() {
  1449. 945.  -     var _a = audioPlayer, aid = currentAudioId();
  1450. 946.  -     if (!aid && _a.lastSong) {
  1451. 947.  -       aid = _a.lastSong.aid;
  1452. 948.  -     }
  1453. 949.  -     _a.repeat = !_a.repeat;
  1454. 950.  -     if (_a.controls) {
  1455. 951.  -       for (var i in _a.controls) {
  1456. 952.  -         var obj = _a.controls[i];
  1457. 953.  -         if (obj.repeat) {
  1458. 954.  -           toggleClass(obj.repeat, 'on', _a.repeat);
  1459. 955.  -         }
  1460. 956.  -       }
  1461. 957.  -     }
  1462. 958.  -     if (!aid) return;
  1463. 959.  -     var r = ge('repeat' + aid);
  1464. 960.  -     if (r) {
  1465. 961.  -       toggleClass(r, 'on', _a.repeat);
  1466. 962.  -     }
  1467. 963.  -   },
  1468. 964.  -   showRec: function(aid, fromPad) {
  1469. 965.  -     var _a = audioPlayer;
  1470. 966.  -     aid = aid || currentAudioId() ||  _a.lastSong && _a.lastSong.aid || cur.defaultTrack && cur.defaultTrack.id || window.audioPlaylist && audioPlaylist.start || '';
  1471. 967.  -     if (!aid) return;
  1472. 968.  -     // if (fromPad) {
  1473. 969.  -     //   _a.loadTrackRecommendations(aid);
  1474. 970.  -     // } else if (window.Audio) {
  1475. 971.  -       Audio.loadRecommendations({from_pad: fromPad, update: true, audioId: aid});
  1476. 972.  -     // }
  1477. 973.  -   },
  1478. 974.  -   updateStatusChecks: function(cont) {
  1479. 975.  -     var _a = audioPlayer, chks = geByClass('checkbox', cont);
  1480. 976.  -     each(chks, function() {
  1481. 977.  -       checkbox(this, false);
  1482. 978.  -     });
  1483. 979.  -     if (_a.statusExport) {
  1484. 980.  -       for (var i in _a.statusExport) {
  1485. 981.  -         checkbox(geByClass1('status' + i, cont), true);
  1486. 982.  -       }
  1487. 983.  -     }
  1488. 984.  -   },
  1489. 985.  -   updateAllStatusChecks: function() {
  1490. 986.  -     var _a = audioPlayer;
  1491. 987.  -     for (var i in _a.controls) {
  1492. 988.  -       var obj = _a.controls[i];
  1493. 989.  -       if (obj.status && obj.status.tt) {
  1494. 990.  -         _a.updateStatusChecks(obj.status.tt.container);
  1495. 991.  -       }
  1496. 992.  -     }
  1497. 993.  -   },
  1498. 994.  -   toggleStatus: function(oid) {
  1499. 995.  -     var _a = audioPlayer, aid = currentAudioId(), exp, oid = intval(oid);
  1500. 996.  -     _a.statusExport = _a.statusExport || {};
  1501. 997.  -     if (!oid) {
  1502. 998.  -       if (_a.hasStatusExport()) {
  1503. 999.  -         for (var i in _a.statusExport) {
  1504. 1000.  -           delete _a.statusExport[i];
  1505. 1001.  -           _a.updateAllStatusChecks();
  1506. 1002.  -         }
  1507. 1003.  -         exp = false;
  1508. 1004.  -       } else {
  1509. 1005.  -         oid = vk.id;
  1510. 1006.  -         _a.statusExport[oid] = 1;
  1511. 1007.  -         _a.updateAllStatusChecks();
  1512. 1008.  -         exp = true;
  1513. 1009.  -       }
  1514. 1010.  -     } else {
  1515. 1011.  -       if (_a.statusExport[oid]) {
  1516. 1012.  -         delete _a.statusExport[oid];
  1517. 1013.  -         exp = false
  1518. 1014.  -       } else {
  1519. 1015.  -         _a.statusExport[oid] = 1;
  1520. 1016.  -         exp = true;
  1521. 1017.  -       }
  1522. 1018.  -     }
  1523. 1019.  -     if (!_a.addHash) return;
  1524. 1020.  -     if (oid == vk.id || !oid) checkbox('currinfo_audio', _a.hasStatusExport());
  1525. 1021.  -     if (_a.controls) {
  1526. 1022.  -       for (var i in _a.controls) {
  1527. 1023.  -         var obj = _a.controls[i];
  1528. 1024.  -         if (obj.status) {
  1529. 1025.  -           toggleClass(obj.status, 'on', _a.hasStatusExport());
  1530. 1026.  -         }
  1531. 1027.  -       }
  1532. 1028.  -     }
  1533. 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 : ''});
  1534. 1030.  -     if (window._pads && _pads.cache) {
  1535. 1031.  -       delete _pads.cache.mus;
  1536. 1032.  -     }
  1537. 1033.  -   },
  1538. 1034.  -   setControlsTitle: function() {
  1539. 1035.  -     var _a = audioPlayer;
  1540. 1036.  -     if (_a.controls) {
  1541. 1037.  -       for (var i in _a.controls) {
  1542. 1038.  -         var obj = _a.controls[i], songInfo = obj.padPlaylist && _a.isPlaylistGlobal() ? ls.get('pad_lastsong') || _a.lastSong : _a.lastSong;
  1543. 1039.  -         if (obj.performer) {
  1544. 1040.  -           obj.performer.innerHTML = clean(replaceEntities(songInfo[5]));
  1545. 1041.  -         }
  1546. 1042.  -         if (obj.title) {
  1547. 1043.  -           obj.title.innerHTML = clean(replaceEntities(songInfo[6]));
  1548. 1044.  -         }
  1549. 1045.  -         if (obj.titleWrap) {
  1550. 1046.  -           if (obj.titleWrap.scrollWidth > obj.titleWrap.clientWidth) {
  1551. 1047.  -             var el = ce('div', {innerHTML: clean(replaceEntities(songInfo[5])) + ' &ndash; ' + clean(replaceEntities(songInfo[6])) });
  1552. 1048.  -             obj.titleWrap.title = el.innerText || el.textContent;
  1553. 1049.  -           } else {
  1554. 1050.  -             obj.titleWrap.removeAttribute('title');
  1555. 1051.  -           }
  1556. 1052.  -         }
  1557. 1053.  -         if (obj.duration) {
  1558. 1054.  -           obj.duration.innerHTML = _a.timeLeft ? songInfo[4] : '0:00';
  1559. 1055.  -         }
  1560. 1056.  -         if (obj.add) {
  1561. 1057.  -           var aid = currentAudioId(), cur_aids = aid && aid.split('_') || [], raw_id = aid && cur_aids[0] + '_' + cur_aids[1] || null;
  1562. 1058.  -           toggleClass(obj.add, 'added', !!(raw_id && cur.addedIds && cur.addedIds[raw_id]));
  1563. 1059.  -         }
  1564. 1060.  -       }
  1565. 1061.  -     }
  1566. 1062.  -     if (ge('gp')) _a.loadGlobal();
  1567. 1063.  -   },
  1568. 1064.  -   loadGlobal: function() {
  1569. 1065.  -     var l, _a = audioPlayer, aid = currentAudioId(), cl = aid && _a.player && !_a.player.paused() || !aid && _a.lastSong ? 'playing' : '';
  1570. 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>';
  1571. 1067.  -     var art, title;
  1572. 1068.  -     art = clean(replaceEntities(_a.lastSong[5]));
  1573. 1069.  -     title = clean(replaceEntities(_a.lastSong[6]));
  1574. 1070.  -     ge('gp_performer').innerHTML = art;
  1575. 1071.  -     ge('gp_title').innerHTML = title;
  1576. 1072.  -     updGlobalPlayer();
  1577. 1073.  -   },
  1578. 1074.  -   onError: function(error_msg) {
  1579. 1075.  -     var _a = audioPlayer, aid = currentAudioId();
  1580. 1076.  -     if (aid) _a.reloadAudio(aid);
  1581. 1077.  -     _a.reloadPlaylist();
  1582. 1078.  -   },
  1583. 1079.  -   onLoadComplete: function(len) {
  1584. 1080.  -     if (len) audioPlayer.duration = len;
  1585. 1081.  -   },
  1586. 1082.  -   onPlayFinish: function() {
  1587. 1083.  -     var _a = audioPlayer;
  1588. 1084.  -     _a.playbackSent = _a.statusSent = 0;
  1589. 1085.  -     var next_id, cur_id = currentAudioId(), m = (cur_id + '').match(/^-?\d+_\d+_s(-?\d+)(?:_|$)/);
  1590. 1086.  -     if (cur.startedAids) delete cur.startedAids[cur_id];
  1591. 1087.  -     if (_a.repeat) {
  1592. 1088.  -       next_id = cur_id;
  1593. 1089.  -     } else if (m && window.audioPlaylist && audioPlaylist[cur_id]) {
  1594. 1090.  -       next_id = audioPlaylist[cur_id]['_next'];
  1595. 1091.  -       if (!next_id) {
  1596. 1092.  -         ajax.post('audio', {act: 'get_audio_status', oid: m[1]}, {
  1597. 1093.  -           onDone: function(id, info) {
  1598. 1094.  -             if (!info) return;
  1599. 1095.  -
  1600. 1096.  -             if (cur_id !== id) {
  1601. 1097.  -               info['_prev'] = cur_id;
  1602. 1098.  -               audioPlaylist[cur_id]['_next'] = id;
  1603. 1099.  -               audioPlaylist[id] = info;
  1604. 1100.  -               audioPlaylist.start = id;
  1605. 1101.  -               _a.setPadPlaylist(window.audioPlaylist);
  1606. 1102.  -             }
  1607. 1103.  -             if (!currentAudioId()) {
  1608. 1104.  -               _a.operate(id);
  1609. 1105.  -             }
  1610. 1106.  -           }
  1611. 1107.  -         });
  1612. 1108.  -       }
  1613. 1109.  -     } else {
  1614. 1110.  -       var pList = _a.isPlaylistGlobal() ? ls.get('pad_playlist') || window.audioPlaylist : padAudioPlaylist();
  1615. 1111.  -       next_id = (pList && pList[cur_id] && pList[cur_id]['_next']) ? pList[cur_id]['_next'] : _a.getNextSibling();
  1616. 1112.  -     }
  1617. 1113.  -     _a.stop();
  1618. 1114.  -     if (next_id && (_a.repeat || cur_id != next_id)) {
  1619. 1115.  -       _a.operate(next_id);
  1620. 1116.  -       if (window._pads && _pads.shown == 'mus' && window.Pads && Pads.setAudioCurPos) {
  1621. 1117.  -         Pads.setAudioCurPos(400);
  1622. 1118.  -         return;
  1623. 1119.  -       }
  1624. 1120.  -     }
  1625. 1121.  -   },
  1626. 1122.  -   scrollToTrack: function(nid) {
  1627. 1123.  -     var w = window, de = document.documentElement, play_btn = ge('play'+nid);
  1628. 1124.  -     if (window._pads && _pads.shown == 'mus' && window.Pads && Pads.setAudioCurPos) {
  1629. 1125.  -       Pads.setAudioCurPos(400);
  1630. 1126.  -       return;
  1631. 1127.  -     }
  1632. 1128.  -     if (!w.pageNode || !play_btn || cur.module == 'im') return;
  1633. 1129.  -     var xy = getXY(play_btn);
  1634. 1130.  -     var dheight = Math.max(intval(w.innerHeight), intval(de.clientHeight));
  1635. 1131.  -     var height = Math.max(0, xy[1] - (dheight - 16) / 2);
  1636. 1132.  -     scrollToY(height, 400);
  1637. 1133.  -   },
  1638. 1134.  -   nextTrack: function(no_scroll, fromPad) {
  1639. 1135.  -     var nid, _a = audioPlayer
  1640. 1136.  -     fromPad = fromPad && _a.isPlaylistGlobal();
  1641. 1137.  -     var aid = fromPad ? ls.get('audio_id') || currentAudioId() : currentAudioId(), pList = fromPad ? ls.get('pad_playlist') || window.audioPlaylist : window.audioPlaylist;
  1642. 1138.  -     nid = (pList && pList[aid]) ? pList[aid]['_next'] : _a.getNextSibling();
  1643. 1139.  -     if (nid) {
  1644. 1140.  -       _a.stop();
  1645. 1141.  -       if (fromPad) {
  1646. 1142.  -         window.padPlClicked = true;
  1647. 1143.  -       }
  1648. 1144.  -       _a.operate(nid);
  1649. 1145.  -       if (!no_scroll) _a.scrollToTrack(nid);
  1650. 1146.  -     }
  1651. 1147.  -   },
  1652. 1148.  -   prevTrack: function(no_scroll, fromPad) {
  1653. 1149.  -     var nid, _a = audioPlayer
  1654. 1150.  -     fromPad = fromPad && _a.isPlaylistGlobal();
  1655. 1151.  -     var aid = fromPad ? ls.get('audio_id') || currentAudioId() : currentAudioId(), pList = fromPad ? ls.get('pad_playlist') || window.audioPlaylist : window.audioPlaylist;
  1656. 1152.  -     pid = (pList && pList[aid]) ? pList[aid]['_prev'] : _a.getPrevSibling();
  1657. 1153.  -     if (pid) {
  1658. 1154.  -       _a.stop();
  1659. 1155.  -       if (fromPad) {
  1660. 1156.  -         window.padPlClicked = true;
  1661. 1157.  -       }
  1662. 1158.  -       _a.operate(pid);
  1663. 1159.  -       if (!no_scroll) _a.scrollToTrack(pid);
  1664. 1160.  -     }
  1665. 1161.  -   },
  1666. 1162.  -   getNextSibling: function(aid) {
  1667. 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; }
  1668. 1164.  -     if (!aid) aid = currentAudioId();
  1669. 1165.  -     var cur = ge('audio' + aid);
  1670. 1166.  -     if (!cur) return null;
  1671. 1167.  -     var aid = 0;
  1672. 1168.  -     for (var el = cur.nextSibling; el; el = el.nextSibling) {
  1673. 1169.  -       if (aid = getAId(el)) return aid;
  1674. 1170.  -       if (isVisible(el) && (aid = getAId(el.firstChild))) return aid;
  1675. 1171.  -     }
  1676. 1172.  -     var p = cur.parentNode.nextSibling;
  1677. 1173.  -     while (p && p.nodeType != 1 && p.nextSibling) p = p.nextSibling;
  1678. 1174.  -     if (p && p.nodeType == 1) {
  1679. 1175.  -       var el = geByClass1('audio', p);
  1680. 1176.  -       if (aid = getAId(el)) return aid;
  1681. 1177.  -     }
  1682. 1178.  -     for (p = cur.parentNode.parentNode.firstChild; p; p = p.nextSibling) {
  1683. 1179.  -       if (p && p.nodeType == 1 && p != cur.parentNode) {
  1684. 1180.  -         var el = geByClass1('audio', p);
  1685. 1181.  -         if (aid = getAId(el)) return aid;
  1686. 1182.  -       }
  1687. 1183.  -     }
  1688. 1184.  -     for (var el = cur.parentNode.firstChild; el; el = el.nextSibling) {
  1689. 1185.  -       if (aid = getAId(el)) return aid;
  1690. 1186.  -     }
  1691. 1187.  -   },
  1692. 1188.  -   getPrevSibling: function(aid) {
  1693. 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; }
  1694. 1190.  -     if (!aid) aid = currentAudioId();
  1695. 1191.  -     var cur = ge('audio' + aid);
  1696. 1192.  -     if (!cur) return null;
  1697. 1193.  -     var aid = 0;
  1698. 1194.  -     for (var el = cur.previousSibling; el; el = el.previousSibling) {
  1699. 1195.  -       if (aid = getAId(el)) return aid;
  1700. 1196.  -       if (isVisible(el) && (aid = getAId(el.firstChild))) return aid;
  1701. 1197.  -     }
  1702. 1198.  -     var p = cur.parentNode.previousSibling;
  1703. 1199.  -     while (p && p.nodeType != 1 && p.previousSibling) p = p.previousSibling;
  1704. 1200.  -     if (p && p.nodeType == 1) {
  1705. 1201.  -       var el = geByClass1('audio', p);
  1706. 1202.  -       if (aid = getAId(el)) return aid;
  1707. 1203.  -     }
  1708. 1204.  -     for (p = cur.parentNode.parentNode.lastChild; p; p = p.previousSibling) {
  1709. 1205.  -       if (p && p.nodeType == 1 && p != cur.parentNode) {
  1710. 1206.  -         var el = geByClass1('audio', p);
  1711. 1207.  -         if (aid = getAId(el)) return aid;
  1712. 1208.  -       }
  1713. 1209.  -     }
  1714. 1210.  -     for (var el = cur.parentNode.lastChild; el; el = el.previousSibling) {
  1715. 1211.  -       if (aid = getAId(el)) return aid;
  1716. 1212.  -     }
  1717. 1213.  -   },
  1718. 1214.  -
  1719. 1215.  -   genPlaylist: function(list, copyToMain, opts) {
  1720. 1216.  -     opts = opts || {};
  1721. 1217.  -     var res = [];
  1722. 1218.  -     if (!list || !list.length) return;
  1723. 1219.  -     for (var i in list) {
  1724. 1220.  -       if (list[i][11] && parseInt(list[i][11])) {
  1725. 1221.  -         continue;
  1726. 1222.  -       }
  1727. 1223.  -       res.push(list[i]);
  1728. 1224.  -     }
  1729. 1225.  -     if (!res.length) return;
  1730. 1226.  -     if (res[0]._order !== undefined) {
  1731. 1227.  -       res = res.sort(function(a,b) {return a._order - b._order});
  1732. 1228.  -     }
  1733. 1229.  -     cur.nextPlaylist = {};
  1734. 1230.  -     for (var i in res) {
  1735. 1231.  -       i = parseInt(i);
  1736. 1232.  -       var a = extend({}, res[i]);
  1737. 1233.  -       var aid = a.full_id || a[0]+'_'+a[1];
  1738. 1234.  -       cur.nextPlaylist[aid] = clone(a);
  1739. 1235.  -       if (i > 0) cur.nextPlaylist[aid]['_prev'] = res[i-1].full_id || res[i-1][0]+'_'+res[i-1][1];
  1740. 1236.  -       if (i < res.length - 1) cur.nextPlaylist[aid]['_next'] = res[i+1].full_id || res[i+1][0]+'_'+res[i+1][1];
  1741. 1237.  -     }
  1742. 1238.  -     var firstId = res[0].full_id || res[0][0]+'_'+res[0][1],
  1743. 1239.  -         lastId = res[res.length-1].full_id || res[res.length-1][0]+'_'+res[res.length-1][1];
  1744. 1240.  -     cur.nextPlaylist[firstId]['_prev'] = lastId;
  1745. 1241.  -     cur.nextPlaylist[lastId]['_next'] = firstId;
  1746. 1242.  -     cur.nextPlaylist.start = firstId;
  1747. 1243.  -     cur.nextPlaylist.length = res.length;
  1748. 1244.  -     cur.nextPlaylist.instance = cur.nextPlaylist.source = window.curNotifier && curNotifier.instance_id || '';
  1749. 1245.  -     cur.nextPlaylist.address = nav.strLoc;
  1750. 1246.  -     if (opts.my) {
  1751. 1247.  -       cur.nextPlaylist.my = opts.my;
  1752. 1248.  -     }
  1753. 1249.  -     if (opts.has_more) {
  1754. 1250.  -       cur.nextPlaylist.has_more = opts.has_more;
  1755. 1251.  -     }
  1756. 1252.  -     if (opts.htitle) {
  1757. 1253.  -       cur.nextPlaylist.htitle = opts.htitle;
  1758. 1254.  -     }
  1759. 1255.  -     var aid = currentAudioId();
  1760. 1256.  -     if (copyToMain || cur.justShuffled && aid && cur.nextPlaylist[aid]) {
  1761. 1257.  -       window.audioPlaylist = clone(cur.nextPlaylist);
  1762. 1258.  -       if (window.curNotifier && (padPlData = ls.get('pad_pldata')) && padPlData.instance == curNotifier.instance_id) {
  1763. 1259.  -         this.setPadPlaylist(window.audioPlaylist);
  1764. 1260.  -       }
  1765. 1261.  -     }
  1766. 1262.  -   },
  1767. 1263.  -
  1768. 1264.  -   isPlaylistGlobal: function() {
  1769. 1265.  -     var padPlData;
  1770. 1266.  -     return (!window.audioPlaylist || window.curNotifier && (padPlData = ls.get('pad_pldata')) && padPlData.source == curNotifier.instance_id);
  1771. 1267.  -   },
  1772. 1268.  -
  1773. 1269.  -   setPadPlaylist: function(pList) {
  1774. 1270.  -     if (pList) {
  1775. 1271.  -       if (!pList.htitle) {
  1776. 1272.  -         var htitle =  window._pads && _pads.cur && (_pads.cur.lastHTitle || _pads.cur.htitle) || cur.module == 'audio' && (cur.lastHTitle || cur.htitle) || '';
  1777. 1273.  -         pList.htitle = htitle ? getLang('audio_current_playing_from').replace('{playlist}', htitle) : '';
  1778. 1274.  -         if (cur.nextPlaylist && !cur.nextPlaylist.htitle && cur.nextPlaylist.source == pList.source && cur.nextPlaylist.start == pList.start && cur.nextPlaylist.length == pList.length) {
  1779. 1275.  -           cur.nextPlaylist.htitle = audioPlaylist.htitle;
  1780. 1276.  -         }
  1781. 1277.  -       }
  1782. 1278.  -       ls.set('pad_playlist', pList);
  1783. 1279.  -       ls.set('pad_pltime', vkNow());
  1784. 1280.  -       if (!pList.instance && !pList.source && window.curNotifier && curNotifier.instance_id) {
  1785. 1281.  -         pList.instance = pList.source = curNotifier.instance_id;
  1786. 1282.  -       }
  1787. 1283.  -       if (pList.instance && pList.source) {
  1788. 1284.  -         this.setPadPlData({instance: pList.instance, source: pList.source});
  1789. 1285.  -       } else {
  1790. 1286.  -         this.setPadPlData();
  1791. 1287.  -       }
  1792. 1288.  -     } else {
  1793. 1289.  -       ls.remove('pad_playlist');
  1794. 1290.  -       ls.remove('pad_pltime');
  1795. 1291.  -     }
  1796. 1292.  -   },
  1797. 1293.  -
  1798. 1294.  -   setPadPlData: function(obj) {
  1799. 1295.  -     if (obj) {
  1800. 1296.  -       ls.set('pad_pldata', obj);
  1801. 1297.  -     } else {
  1802. 1298.  -       ls.remove('pad_pldata');
  1803. 1299.  -     }
  1804. 1300.  -   },
  1805. 1301.  -
  1806. 1302.  -   updateCurrentPlaylist: function(obj, aid) {
  1807. 1303.  -     var _a = audioPlayer;
  1808. 1304.  -     if (obj && obj.all && window.audioPlaylist && audioPlaylist[aid]) {
  1809. 1305.  -       var found = false, audio_id = aid.split('_')[1], curId = aid, fullIds = {};
  1810. 1306.  -       do {
  1811. 1307.  -         var curAudioId = curId.split('_')[1];
  1812. 1308.  -         fullIds[curAudioId] = curId;
  1813. 1309.  -         curId = audioPlaylist[curId]._next;
  1814. 1310.  -       } while (curId && curId != aid);
  1815. 1311.  -       for (var i in obj.all) {
  1816. 1312.  -         if (obj.all[i][1] == audio_id) {
  1817. 1313.  -           found = true;
  1818. 1314.  -         }
  1819. 1315.  -         if (fullIds[obj.all[i][1]] && !obj.all[i].full_id) {
  1820. 1316.  -           obj.all[i].full_id = fullIds[obj.all[i][1]];
  1821. 1317.  -         }
  1822. 1318.  -       }
  1823. 1319.  -       if (found) {
  1824. 1320.  -         _a.genPlaylist(obj.all, true);
  1825. 1321.  -       }
  1826. 1322.  -     }
  1827. 1323.  -   },
  1828. 1324.  -
  1829. 1325.  -   createDynamicPlaylist: function(aid, copyToMain, limit) {
  1830. 1326.  -     var _a = audioPlayer;
  1831. 1327.  -     if (!aid) return;
  1832. 1328.  -     var nextId = startId = aid, el = ge('audio' + aid), dynPl = [_a.getSongInfoFromDOM(startId)], k = 1;
  1833. 1329.  -     if (!limit) limit = 200;
  1834. 1330.  -     while (nextId = _a.getNextSibling(nextId)) {
  1835. 1331.  -       if (nextId == startId || k++ >= limit) break;
  1836. 1332.  -       var info = _a.getSongInfoFromDOM(nextId);
  1837. 1333.  -       if (info[2]) {
  1838. 1334.  -         dynPl.push(info);
  1839. 1335.  -       }
  1840. 1336.  -     }
  1841. 1337.  -     _a.genPlaylist(dynPl, copyToMain);
  1842. 1338.  -     if (hasClass(el.parentNode, 'module_body')) {
  1843. 1339.  -       ajax.post('/audio', {act: 'get_playlist', oid: cur.oid}, {
  1844. 1340.  -         onDone: function(res) {
  1845. 1341.  -           var obj = eval('(' + res + ')');
  1846. 1342.  -           _a.updateCurrentPlaylist(obj, aid);
  1847. 1343.  -         }
  1848. 1344.  -       })
  1849. 1345.  -     } else if (dynPl.length < 2 && vk.id && (cur.module == 'groups' || cur.module == 'public' || cur.module == 'profile' || cur.module == 'feed' || cur.module == 'wall')) {
  1850. 1346.  -       var ids = aid.split('_'), local_id = ids && ids[3] || '';
  1851. 1347.  -       if (local_id && ge('post'+ids[2]+'_'+ids[3])) {
  1852. 1348.  -         var wallType = cur.wallType;
  1853. 1349.  -         if (wallType == 'full_own') wallType = 'own';
  1854. 1350.  -         if (wallType == 'full_all') wallType = 'all';
  1855. 1351.  -         if (wallType != 'own' && wallType != 'all') {
  1856. 1352.  -           wallType = 'own';
  1857. 1353.  -         }
  1858. 1354.  -         var params = {act: 'get_wall_playlist', oid: ids[2], wall_type: wallType, local_id: local_id};
  1859. 1355.  -         if (cur.module == 'wall' && ge('wall_search') && ge('wall_search').value) {
  1860. 1356.  -           params.q = ge('wall_search').value;
  1861. 1357.  -         }
  1862. 1358.  -         ajax.post('/audio', params, {
  1863. 1359.  -           onDone: function(obj) {
  1864. 1360.  -             if (obj && obj.all && obj.all.length) {
  1865. 1361.  -               _a.updateCurrentPlaylist(obj, aid);
  1866. 1362.  -             }
  1867. 1363.  -           }
  1868. 1364.  -         });
  1869. 1365.  -       }
  1870. 1366.  -     }
  1871. 1367.  -   },
  1872. 1368.  -   showCurrentTrack: function() {
  1873. 1369.  -     each(geByClass('current'), function() {
  1874. 1370.  -       if (hasClass(this, 'audio')) {
  1875. 1371.  -         removeClass(this, 'current');
  1876. 1372.  -         var btn = geByClass1('play_new', this);
  1877. 1373.  -         if (btn) removeClass(btn, 'playing');
  1878. 1374.  -       }
  1879. 1375.  -     })
  1880. 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;
  1881. 1377.  -     if (aid && _a.player) {
  1882. 1378.  -       _a.setGraphics('load');
  1883. 1379.  -       if (_a.player.paused()) {
  1884. 1380.  -         _a.setGraphics('pause');
  1885. 1381.  -       } else {
  1886. 1382.  -         _a.setGraphics('play');
  1887. 1383.  -       }
  1888. 1384.  -       _a.setControlsTitle();
  1889. 1385.  -       _a.player.callPlayProgress();
  1890. 1386.  -       if (_a.player.callLoadProgress) _a.player.callLoadProgress();
  1891. 1387.  -       if (aid.substr(-4) !== '_pad' && ge('audio' + aid)) {
  1892. 1388.  -         addClass('audio' + aid, 'current');
  1893. 1389.  -       }
  1894. 1390.  -       if (pad_aid.substr(-4) !== '_pad') {
  1895. 1391.  -         pad_aid += '_pad';
  1896. 1392.  -       }
  1897. 1393.  -       if (ge('audio' + pad_aid) && _a.isPlaylistGlobal()) {
  1898. 1394.  -         var padClass = (window.curNotifier && (padPlData = ls.get('pad_pldata')) && padPlData.instance == curNotifier.instance_id) ? 'current' : 'tab_current';
  1899. 1395.  -         addClass('audio' + pad_aid, padClass);
  1900. 1396.  -         if (padClass == 'tab_current') {
  1901. 1397.  -           var curRow = geByClass1('current', ge('pad_playlist'));
  1902. 1398.  -           if (curRow) {
  1903. 1399.  -             removeClass(curRow, 'current');
  1904. 1400.  -           }
  1905. 1401.  -         }
  1906. 1402.  -       }
  1907. 1403.  -     }
  1908. 1404.  -     if (_a.controls) {
  1909. 1405.  -       for (var i in _a.controls) {
  1910. 1406.  -         var obj = _a.controls[i];
  1911. 1407.  -         if (obj.repeat) toggleClass(obj.repeat, 'on', !!_a.repeat);
  1912. 1408.  -         if (obj.status) toggleClass(obj.status, 'on', !!_a.hasStatusExport());
  1913. 1409.  -         if (obj.shuffle) toggleClass(obj.shuffle, 'on', !!_a.shuffle);
  1914. 1410.  -         if (obj.add) toggleClass(obj.add, 'added', !!(raw_id && cur.addedIds && cur.addedIds[raw_id]));
  1915. 1411.  -       }
  1916. 1412.  -     }
  1917. 1413.  -   },
  1918. 1414.  -   hideCurrentTrack: function() {
  1919. 1415.  -     var audios = geByClass('audio'), playBtns = geByClass('play_new');
  1920. 1416.  -     each(audios, function() {
  1921. 1417.  -       if (hasClass(this, 'current')) {
  1922. 1418.  -         removeClass(this, 'current');
  1923. 1419.  -       }
  1924. 1420.  -     });
  1925. 1421.  -     each(playBtns, function() {
  1926. 1422.  -       if (hasClass(this, 'playing')) {
  1927. 1423.  -         removeClass(this, 'playing');
  1928. 1424.  -       }
  1929. 1425.  -     });
  1930. 1426.  -   },
  1931. 1427.  -   formatTime: function(t) {
  1932. 1428.  -     var res, sec, min, hour;
  1933. 1429.  -     t = Math.max(t, 0);
  1934. 1430.  -     sec = t % 60;
  1935. 1431.  -     res = (sec < 10) ? '0'+sec : sec;
  1936. 1432.  -     t = Math.floor(t / 60);
  1937. 1433.  -     min = t % 60;
  1938. 1434.  -     res = min+':'+res;
  1939. 1435.  -     t = Math.floor(t / 60);
  1940. 1436.  -     if (t > 0) {
  1941. 1437.  -       if (min < 10) res = '0' + res;
  1942. 1438.  -       res = t+':'+res;
  1943. 1439.  -     }
  1944. 1440.  -     return res;
  1945. 1441.  -   },
  1946. 1442.  -   setCurTime: function(cur, len) {
  1947. 1443.  -     var _a = audioPlayer, aid = currentAudioId();
  1948. 1444.  -     var t = _a.timeLeft ? len - cur : cur, res = _a.formatTime(t);
  1949. 1445.  -     _a.curTime = cur;
  1950. 1446.  -     if (_a.timeLeft) res = vk.rtl ? res+'-' : '-'+res;
  1951. 1447.  -     if (_a.controls) {
  1952. 1448.  -       for (var i in _a.controls) {
  1953. 1449.  -         var obj = _a.controls[i];
  1954. 1450.  -         if (obj.duration) obj.duration.innerHTML = res;
  1955. 1451.  -       }
  1956. 1452.  -     }
  1957. 1453.  -     var dur = ge('audio' + aid) && geByClass1('duration', ge('audio' + aid));
  1958. 1454.  -     if (dur && res) dur.innerHTML = res;
  1959. 1455.  -   },
  1960. 1456.  -   switchTimeFormat: function(id, event) {
  1961. 1457.  -     var _a = audioPlayer, aid = currentAudioId();
  1962. 1458.  -     if (aid && id) {
  1963. 1459.  -       var aids = aid.split('_'), ids = id.split('_');
  1964. 1460.  -       if (aids[0] != ids[0] || aids[1] != ids[1]) return false;
  1965. 1461.  -     }
  1966. 1462.  -     _a.timeLeft = (_a.timeLeft + 1) % 2;
  1967. 1463.  -     if (_a.player) {
  1968. 1464.  -       _a.player.callPlayProgress();
  1969. 1465.  -     }
  1970. 1466.  -     setCookie('audio_time_left', _a.timeLeft);
  1971. 1467.  -     cancelEvent(event);
  1972. 1468.  -   },
  1973. 1469.  -   onLoadProgress: function(bLoaded, bTotal) {
  1974. 1470.  -     var _a = audioPlayer, aid = currentAudioId();
  1975. 1471.  -     if (isNaN(bTotal) && _a.player.onCanPlay) bTotal = _a.duration;
  1976. 1472.  -     var per = Math.ceil(bLoaded/bTotal*100);
  1977. 1473.  -     per = Math.min(100, Math.max(0, per));
  1978. 1474.  -     if (_a.controls) {
  1979. 1475.  -       for (var i in _a.controls) {
  1980. 1476.  -         var obj = _a.controls[i];
  1981. 1477.  -         if (obj.load) setStyle(obj.load, {width: per + '%'});
  1982. 1478.  -       }
  1983. 1479.  -     }
  1984. 1480.  -     if (ge('player' + aid)) {
  1985. 1481.  -       setStyle(ge('audio_load_line' + aid), {width: per + '%'});
  1986. 1482.  -     }
  1987. 1483.  -   },
  1988. 1484.  -   onPlayProgress: function(pos, len, force) {
  1989. 1485.  -     var barSize, _a = audioPlayer, aid = currentAudioId();
  1990. 1486.  -     if (Math.abs(len - _a.duration) > 1 || isNaN(len)) len = _a.duration;
  1991. 1487.  -     if (pos > 1) {
  1992. 1488.  -       cur.startedAids = cur.startedAids || {};
  1993. 1489.  -       cur.startedAids[aid] = 1;
  1994. 1490.  -     }
  1995. 1491.  -     if (_a.time && _a.player.paused()) pos = _a.time;
  1996. 1492.  -     _a.setCurTime(Math.round(pos), Math.round(len));
  1997. 1493.  -     if (_a.player.paused() && !force) return;
  1998. 1494.  -     var per = pos / len * 100;
  1999. 1495.  -     per = Math.min(100, Math.max(0, per));
  2000. 1496.  -     if (!_a.prClicked) {
  2001. 1497.  -       if (_a.controls) {
  2002. 1498.  -         for (var i in _a.controls) {
  2003. 1499.  -           var obj = _a.controls[i];
  2004. 1500.  -           if (obj.progress) {
  2005. 1501.  -             setStyle(obj.progress, {width: per + '%'});
  2006. 1502.  -           }
  2007. 1503.  -         }
  2008. 1504.  -       }
  2009. 1505.  -       if (ge('player' + aid)) {
  2010. 1506.  -         setStyle(ge('audio_pr_line' + aid), {width: per + '%'});
  2011. 1507.  -       }
  2012. 1508.  -     }
  2013. 1509.  -   },
  2014. 1510.  -   showCurrentAdded: function() {
  2015. 1511.  -     var _a = audioPlayer;
  2016. 1512.  -     if (_a.controls) {
  2017. 1513.  -       for (var i in _a.controls) {
  2018. 1514.  -         var obj = _a.controls[i];
  2019. 1515.  -         if (obj.add) {
  2020. 1516.  -           addClass(obj.add, 'added');
  2021. 1517.  -           if (obj.add.tt) {
  2022. 1518.  -             obj.add.tt.hide();
  2023. 1519.  -           }
  2024. 1520.  -         }
  2025. 1521.  -       }
  2026. 1522.  -     }
  2027. 1523.  -   },
  2028. 1524.  -   addCurrentTrack: function() {
  2029. 1525.  -     if (cur.addingAudio) return false;
  2030. 1526.  -     var _a = audioPlayer, aid = currentAudioId();
  2031. 1527.  -     if (!aid && _a.lastSong) {
  2032. 1528.  -       aid = _a.lastSong.aid;
  2033. 1529.  -     }
  2034. 1530.  -     if (aid && _a.addHash) {
  2035. 1531.  -       var ids = aid.split('_');
  2036. 1532.  -       if (ids.length == 1) {
  2037. 1533.  -         ids[1] = ids[0];
  2038. 1534.  -         ids[0] = vk.id;
  2039. 1535.  -       }
  2040. 1536.  -       var raw_id = ids[0] + '_' + ids[1];
  2041. 1537.  -       if (cur.addedIds && cur.addedIds[raw_id]) return false;
  2042. 1538.  -       if (ids && ids[0] && ids[1]) {
  2043. 1539.  -         var query = {act: 'add', oid: ids[0], aid: ids[1], hash: _a.addHash};
  2044. 1540.  -         if (_a.top) query.top = 1;
  2045. 1541.  -         cur.addingAudio = true;
  2046. 1542.  -         ajax.post('audio', query, {
  2047. 1543.  -           onDone: function (data, res, text) {
  2048. 1544.  -             if (data && window.Audio) {
  2049. 1545.  -               var aobj = eval('('+data+')'), all_list;
  2050. 1546.  -               aobj = aobj['all'][0];
  2051. 1547.  -               setTimeout(function(){
  2052. 1548.  -                 if (cur.id == vk.id && cur.audiosIndex && cur.audiosList && cur.audiosList['all'] && cur.aSearch) {
  2053. 1549.  -                   all_list = cur.audiosList['all'];
  2054. 1550.  -                   if (all_list && all_list.length) {
  2055. 1551.  -                     aobj._order = all_list[0]._order - 1;
  2056. 1552.  -                     cur.audiosList['all'].splice(0,0,aobj);
  2057. 1553.  -                   } else {
  2058. 1554.  -                     aobj._order = 0;
  2059. 1555.  -                     cur.audiosList['all'] = [aobj];
  2060. 1556.  -                   }
  2061. 1557.  -                   cur.audios[aobj[1]] = aobj;
  2062. 1558.  -                   cur.audiosIndex.add(aobj);
  2063. 1559.  -                 }
  2064. 1560.  -                 if (window._pads && _pads.cur && _pads.cur.audiosIndex && _pads.cur.audiosList) {
  2065. 1561.  -                   all_list = _pads.cur.audiosList['all'];
  2066. 1562.  -                   if (all_list && all_list.length) {
  2067. 1563.  -                     aobj._order = all_list[0]._order - 1;
  2068. 1564.  -                     _pads.cur.audiosList['all'].splice(0,0,aobj);
  2069. 1565.  -                   } else {
  2070. 1566.  -                     aobj._order = 0;
  2071. 1567.  -                     _pads.cur.audiosList['all'] = [aobj];
  2072. 1568.  -                   }
  2073. 1569.  -                   if (_pads.cur.audios) {
  2074. 1570.  -                     _pads.cur.audios[aobj[1]] = aobj;
  2075. 1571.  -                   }
  2076. 1572.  -                   if (_pads.cur.allAudiosIndex == 'all') {
  2077. 1573.  -                     _pads.cur.audiosIndex.add(aobj);
  2078. 1574.  -                   }
  2079. 1575.  -                 }
  2080. 1576.  -                 if (window.Pads && Pads.clearAudioLoadCache) {
  2081. 1577.  -                   Pads.clearAudioLoadCache();
  2082. 1578.  -                 }
  2083. 1579.  -               }, 0);
  2084. 1580.  -             }
  2085. 1581.  -             if (!cur.addedIds) cur.addedIds = {};
  2086. 1582.  -             cur.addedIds[raw_id] = 1;
  2087. 1583.  -             showDoneBox(text, {out: 2000});
  2088. 1584.  -             cur.addingAudio = false;
  2089. 1585.  -             _a.showCurrentAdded();
  2090. 1586.  -             each([raw_id, raw_id + '_pad', aid, aid + '_pad'], function() {
  2091. 1587.  -               var Actions = window.Audio || window.searchActions || {},
  2092. 1588.  -                   addEl = ge('audio' + this) && geByClass1('audio_add_wrap', ge('audio' + this));
  2093. 1589.  -               if (Actions && Actions.animateAdded && addEl && !hasClass(addEl, 'anim')) {
  2094. 1590.  -                 Actions.animateAdded(addEl, isVisible(addEl) ? 200 : 0);
  2095. 1591.  -               }
  2096. 1592.  -             });
  2097. 1593.  -           },
  2098. 1594.  -           onFail: function() {
  2099. 1595.  -             cur.addingAudio = false;
  2100. 1596.  -           }
  2101. 1597.  -         });
  2102. 1598.  -       }
  2103. 1599.  -     }
  2104. 1600.  -   },
  2105. 1601.  -   shuffleAudios: function(fromPad) {
  2106. 1602.  -     var _a = audioPlayer, pl, aid;
  2107. 1603.  -     if (fromPad && window.Pads) {
  2108. 1604.  -       pl = ((!window.audioPlaylist || window.curNotifier && (padPlData = ls.get('pad_pldata')) && padPlData.source == curNotifier.instance_id) ? ls.get('pad_playlist') || window.audioPlaylist : padAudioPlaylist());
  2109. 1605.  -       aid = ((_a = window.audioPlayer) && _a.isPlaylistGlobal()) ? ls.get('audio_id') || currentAudioId() : currentAudioId();
  2110. 1606.  -     } else {
  2111. 1607.  -       pl = window.audioPlaylist;
  2112. 1608.  -       aid = currentAudioId();
  2113. 1609.  -     }
  2114. 1610.  -     if (aid) {
  2115. 1611.  -       var m = aid.match(/^-?\d+_\d+_s(-?\d+)(?:_|$)/);
  2116. 1612.  -       if (m && m[1] && (pl.statusData || _a.statusData && _a.statusData[m[1]])) {
  2117. 1613.  -         return false;
  2118. 1614.  -       }
  2119. 1615.  -     }
  2120. 1616.  -     if (!pl && _a.isPlaylistGlobal()) {
  2121. 1617.  -       pl = ls.get('pad_playlist');
  2122. 1618.  -       if (pl) {
  2123. 1619.  -         window.audioPlaylist = pl;
  2124. 1620.  -       }
  2125. 1621.  -     }
  2126. 1622.  -     if (cur.module != 'audio' && !pl) {
  2127. 1623.  -       return false;
  2128. 1624.  -     }
  2129. 1625.  -     _a.shuffle = !_a.shuffle;
  2130. 1626.  -     if (_a.controls) {
  2131. 1627.  -       for (var i in _a.controls) {
  2132. 1628.  -         var obj = _a.controls[i];
  2133. 1629.  -         if (obj.shuffle) {
  2134. 1630.  -           toggleClass(obj.shuffle, 'on', _a.shuffle);
  2135. 1631.  -         }
  2136. 1632.  -       }
  2137. 1633.  -     }
  2138. 1634.  -     if (cur.module == 'audio' && window.Audio) {
  2139. 1635.  -       Audio.mixAudios();
  2140. 1636.  -     } else {
  2141. 1637.  -       var aid = currentAudioId(), startId = pl.start, res = [], other = [];
  2142. 1638.  -       if (_a.shuffle) {
  2143. 1639.  -         for (var i in pl) {
  2144. 1640.  -           each(['_prev', '_next'], function() {
  2145. 1641.  -             if (pl[i][this] !== undefined) {
  2146. 1642.  -               pl[i]['_old'+this] = pl[i][this];
  2147. 1643.  -             }
  2148. 1644.  -           });
  2149. 1645.  -         }
  2150. 1646.  -         pl[startId]._start = true;
  2151. 1647.  -         if (aid && pl[aid]) {
  2152. 1648.  -           res.push(pl[aid]);
  2153. 1649.  -           startId = aid;
  2154. 1650.  -         } else {
  2155. 1651.  -           other.push(pl[startId]);
  2156. 1652.  -         }
  2157. 1653.  -       } else {
  2158. 1654.  -         for (var i in pl) {
  2159. 1655.  -           if (pl[i]._old_prev !== undefined && pl[i]._old_next !== undefined) {
  2160. 1656.  -             pl[i]._prev = pl[i]._old_prev;
  2161. 1657.  -             pl[i]._next = pl[i]._old_next;
  2162. 1658.  -             delete pl[i]._old_prev;
  2163. 1659.  -             delete pl[i]._old_next;
  2164. 1660.  -           }
  2165. 1661.  -           if (pl[i]._start) {
  2166. 1662.  -             startId = i;
  2167. 1663.  -             delete pl[i]._start;
  2168. 1664.  -           }
  2169. 1665.  -         }
  2170. 1666.  -         other.push(pl[startId]);
  2171. 1667.  -       }
  2172. 1668.  -       var curId = pl[startId]._next;
  2173. 1669.  -       while (curId && curId != startId && pl[curId]) {
  2174. 1670.  -         var obj = pl[curId];
  2175. 1671.  -         delete obj._order;
  2176. 1672.  -         other.push(obj);
  2177. 1673.  -         curId = pl[curId]._next;
  2178. 1674.  -       }
  2179. 1675.  -       if (other && _a.shuffle) {
  2180. 1676.  -         var shuffle = function(arr) {
  2181. 1677.  -           for(var j, x, i = arr.length; i; j = parseInt(Math.random() * i), x = arr[--i], arr[i] = arr[j], arr[j] = x);
  2182. 1678.  -           return true;
  2183. 1679.  -         }
  2184. 1680.  -         shuffle(other);
  2185. 1681.  -         other = clone(other);
  2186. 1682.  -       }
  2187. 1683.  -       for (var i in other) {
  2188. 1684.  -         res.push(other[i]);
  2189. 1685.  -       }
  2190. 1686.  -       _a.genPlaylist(res, true, {my: pl && pl.my, has_more: pl && pl.has_more, htitle: pl && pl.htitle});
  2191. 1687.  -       if (window.Audio && Audio.loadCurrentPlaylist) {
  2192. 1688.  -         Audio.loadCurrentPlaylist();
  2193. 1689.  -       }
  2194. 1690.  -     }
  2195. 1691.  -     return false;
  2196. 1692.  -   },
  2197. 1693.  -   showStatusTT: function(obj) {
  2198. 1694.  -     var _a = audioPlayer;
  2199. 1695.  -     if (cur.statusTTPreloading) {
  2200. 1696.  -       return false;
  2201. 1697.  -     }
  2202. 1698.  -     cur.statusTTPreloading = true;
  2203. 1699.  -     ajax.post('audio', {act: 'status_tt'}, {
  2204. 1700.  -       cache: 1,
  2205. 1701.  -       onDone: function(richTT, html) {
  2206. 1702.  -         if (richTT) {
  2207. 1703.  -           showTooltip(obj, {
  2208. 1704.  -             text: html,
  2209. 1705.  -             className: 'audio_status_tt',
  2210. 1706.  -             showdt: 0,
  2211. 1707.  -             slide: 15,
  2212. 1708.  -             hidedt: 400,
  2213. 1709.  -             hasover: 1,
  2214. 1710.  -             asrtl: 1,
  2215. 1711.  -             shift: [30, 0, 5],
  2216. 1712.  -             onShowStart: function() {
  2217. 1713.  -               var clubs_content = geByClass1('audio_status_wrap', obj.tt.container);
  2218. 1714.  -               if (!cur.clubsScroll || !hasClass(clubs_content, 'ready')) {
  2219. 1715.  -                 cur.clubsScroll = new Scrollbar(clubs_content, {
  2220. 1716.  -                   prefix: 'audio_clubs_',
  2221. 1717.  -                   nomargin: true,
  2222. 1718.  -                   global: true,
  2223. 1719.  -                   nokeys: true,
  2224. 1720.  -                   right: vk.rtl ? 'auto' : 0,
  2225. 1721.  -                   left: !vk.rtl ? 'auto' : 0,
  2226. 1722.  -                   wheelObj: clubs_content
  2227. 1723.  -                 });
  2228. 1724.  -                 addClass(clubs_content, 'ready');
  2229. 1725.  -               }
  2230. 1726.  -               _a.updateAllStatusChecks();
  2231. 1727.  -             },
  2232. 1728.  -             onShowEnd: function() {
  2233. 1729.  -               if (!cur.clubsScroll) return;
  2234. 1730.  -               cur.clubsScroll.update(false, true);
  2235. 1731.  -             },
  2236. 1732.  -           });
  2237. 1733.  -         } else {
  2238. 1734.  -           showTooltip(obj, {text: getLang('audio_export_tip'), showdt: 0, black: 1, shift: [11, 0, 0]});
  2239. 1735.  -         }
  2240. 1736.  -         cur.statusTTPreloading = false;
  2241. 1737.  -       }
  2242. 1738.  -     });
  2243. 1739.  -   },
  2244. 1740.  -   updateStatus: function(el, oid) {
  2245. 1741.  -     checkbox(el);
  2246. 1742.  -     audioPlayer.toggleStatus(oid);
  2247. 1743.  -   },
  2248. 1744.  -   registerPlayer: function(name, obj) {
  2249. 1745.  -     var _a = audioPlayer;
  2250. 1746.  -     _a.controls = _a.controls || {};
  2251. 1747.  -     _a.controls[name] = obj;
  2252. 1748.  -     if (obj.duration) {
  2253. 1749.  -       addEvent(obj.duration, 'mousedown', function(){
  2254. 1750.  -         _a.switchTimeFormat();
  2255. 1751.  -       });
  2256. 1752.  -     }
  2257. 1753.  -     if (obj.volume && obj.volumeArea) {
  2258. 1754.  -       addEvent(obj.volumeArea, 'mousedown', function(e){
  2259. 1755.  -         _a.volClick(e, name);
  2260. 1756.  -       });
  2261. 1757.  -       var volume = browser.mobile ? 80 : parseInt(getCookie('audio_vol'));
  2262. 1758.  -       volume = Math.max(0, Math.min(volume, 100));
  2263. 1759.  -       setStyle(obj.volume, {width: volume + '%'});
  2264. 1760.  -     }
  2265. 1761.  -     if (obj.progress && obj.progressArea) {
  2266. 1762.  -       addEvent(obj.progressArea, 'mousedown', function(e){
  2267. 1763.  -         _a.prClick(e, name);
  2268. 1764.  -       });
  2269. 1765.  -       addEvent(obj.progressArea, 'mouseover', function(){
  2270. 1766.  -         if (audioPlayer.player) addClass(obj.progressArea, 'over');
  2271. 1767.  -         if (cur.hideTipTO) {
  2272. 1768.  -           clearTimeout(cur.hideTipTO);
  2273. 1769.  -         }
  2274. 1770.  -       });
  2275. 1771.  -       addEvent(obj.progressArea, 'mouseout', function() {
  2276. 1772.  -         removeClass(obj.progressArea, 'over');
  2277. 1773.  -         cur.hideTipTO = setTimeout(hide.pbind('audio_tip_wrap'), 100);
  2278. 1774.  -       });
  2279. 1775.  -     }
  2280. 1776.  -     if (obj.play) {
  2281. 1777.  -       addEvent(obj.play, 'click', function(e){
  2282. 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 || '';
  2283. 1779.  -         if (obj.padPlaylist) {
  2284. 1780.  -           window.padPlClicked = true;
  2285. 1781.  -         }
  2286. 1782.  -         if (aid) playAudioNew(aid, false);
  2287. 1783.  -       });
  2288. 1784.  -       addEvent(obj.play, 'mousedown', addClass.pbind(obj.play, 'down'));
  2289. 1785.  -       addEvent(obj.play, 'mouseup', removeClass.pbind(obj.play, 'down'));
  2290. 1786.  -     }
  2291. 1787.  -     var clickClbks = {
  2292. 1788.  -       prev: _a.prevTrack.pbind(false, !!obj.padPlaylist),
  2293. 1789.  -       next: _a.nextTrack.pbind(false, !!obj.padPlaylist),
  2294. 1790.  -       add: _a.addCurrentTrack,
  2295. 1791.  -       repeat: _a.toggleRepeat,
  2296. 1792.  -       shuffle: _a.shuffleAudios.pbind(!!obj.padPlaylist),
  2297. 1793.  -       rec: _a.showRec.pbind(false, !!obj.padPlaylist),
  2298. 1794.  -       status: _a.toggleStatus
  2299. 1795.  -     };
  2300. 1796.  -     for (var i in clickClbks) {
  2301. 1797.  -       if (obj[i]) {
  2302. 1798.  -         var callback = clickClbks[i];
  2303. 1799.  -         addEvent(obj[i], 'click', callback.pbind(false));
  2304. 1800.  -       }
  2305. 1801.  -     }
  2306. 1802.  -     var overTTs = {
  2307. 1803.  -       add: 'audio_add_to_audio',
  2308. 1804.  -       repeat: 'audio_repeat_tooltip',
  2309. 1805.  -       shuffle: 'audio_shuffle',
  2310. 1806.  -       rec: 'audio_show_recommendations'
  2311. 1807.  -     };
  2312. 1808.  -     each(['prev', 'next', 'play', 'add', 'repeat', 'rec', 'status', 'shuffle', 'volumeArea'], function(){
  2313. 1809.  -       if (obj[this]) {
  2314. 1810.  -         var self = this;
  2315. 1811.  -         addEvent(obj[this], 'mouseover', function() {
  2316. 1812.  -           addClass(this, 'over');
  2317. 1813.  -           if (self == 'status') _a.showStatusTT(this);
  2318. 1814.  -           if (overTTs[self] && !(self == 'add' && hasClass(this, 'added'))) {
  2319. 1815.  -             showTooltip(this, {text: getLang(overTTs[self]), showdt: 0, black: 1, shift: [11, 0, 0]});
  2320. 1816.  -           }
  2321. 1817.  -         });
  2322. 1818.  -       }
  2323. 1819.  -     });
  2324. 1820.  -     each(['prev', 'next', 'play', 'add', 'repeat', 'rec', 'status', 'shuffle', 'volumeArea'], function(){
  2325. 1821.  -       if (obj[this]) {
  2326. 1822.  -         addEvent(obj[this], 'mouseout', function() {
  2327. 1823.  -           removeClass(this, 'over');
  2328. 1824.  -           removeClass(this, 'down');
  2329. 1825.  -         });
  2330. 1826.  -       }
  2331. 1827.  -     });
  2332. 1828.  -   },
  2333. 1829.  -   deregisterPlayer: function(name) {
  2334. 1830.  -     var _a = audioPlayer, obj = audioPlayer.controls[name];
  2335. 1831.  -     if (!obj) {
  2336. 1832.  -       return;
  2337. 1833.  -     }
  2338. 1834.  -     if (obj.duration) {
  2339. 1835.  -       removeEvent(obj.duration, 'mousedown', function(){
  2340. 1836.  -         _a.switchTimeFormat();
  2341. 1837.  -       });
  2342. 1838.  -     }
  2343. 1839.  -     if (obj.volume && obj.volumeArea) {
  2344. 1840.  -       removeEvent(obj.volumeArea, 'mousedown', function(e){
  2345. 1841.  -         _a.volClick(e, name);
  2346. 1842.  -       });
  2347. 1843.  -     }
  2348. 1844.  -     if (obj.progress && obj.progressArea) {
  2349. 1845.  -       removeEvent(obj.progressArea, 'mousedown', function(e){
  2350. 1846.  -         _a.prClick(e, name);
  2351. 1847.  -       });
  2352. 1848.  -       removeEvent(obj.progressArea, 'mouseover', function(){
  2353. 1849.  -         if (audioPlayer.player) addClass(obj.progressArea, 'over');
  2354. 1850.  -         if (cur.hideTipTO) {
  2355. 1851.  -           clearTimeout(cur.hideTipTO);
  2356. 1852.  -         }
  2357. 1853.  -       });
  2358. 1854.  -       removeEvent(obj.progressArea, 'mouseout', function() {
  2359. 1855.  -         removeClass(obj.progressArea, 'over');
  2360. 1856.  -         cur.hideTipTO = setTimeout(hide.pbind('audio_tip_wrap'), 100);
  2361. 1857.  -       });
  2362. 1858.  -     }
  2363. 1859.  -     if (obj.play) {
  2364. 1860.  -       removeEvent(obj.play, 'click', function(e){
  2365. 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 || '';
  2366. 1862.  -         if (obj.padPlaylist) {
  2367. 1863.  -           window.padPlClicked = true;
  2368. 1864.  -         }
  2369. 1865.  -         if (aid) playAudioNew(aid, false);
  2370. 1866.  -       });
  2371. 1867.  -       removeEvent(obj.play, 'mousedown', addClass.pbind(obj.play, 'down'));
  2372. 1868.  -       removeEvent(obj.play, 'mouseup', removeClass.pbind(obj.play, 'down'));
  2373. 1869.  -     }
  2374. 1870.  -     var clickClbks = {
  2375. 1871.  -       prev: _a.prevTrack.pbind(false, !!obj.padPlaylist),
  2376. 1872.  -       next: _a.nextTrack.pbind(false, !!obj.padPlaylist),
  2377. 1873.  -       add: _a.addCurrentTrack,
  2378. 1874.  -       repeat: _a.toggleRepeat,
  2379. 1875.  -       shuffle: _a.shuffleAudios.pbind(!!obj.padPlaylist),
  2380. 1876.  -       rec: _a.showRec.pbind(false, !!obj.padPlaylist),
  2381. 1877.  -       status: _a.toggleStatus
  2382. 1878.  -     };
  2383. 1879.  -     for (var i in clickClbks) {
  2384. 1880.  -       if (obj[i]) {
  2385. 1881.  -         var callback = clickClbks[i];
  2386. 1882.  -         removeEvent(obj[i], 'click', callback.pbind(false));
  2387. 1883.  -       }
  2388. 1884.  -     }
  2389. 1885.  -     var overTTs = {
  2390. 1886.  -       add: 'audio_add_to_audio',
  2391. 1887.  -       repeat: 'audio_repeat_tooltip',
  2392. 1888.  -       shuffle: 'audio_shuffle',
  2393. 1889.  -       rec: 'audio_show_recommendations'
  2394. 1890.  -     };
  2395. 1891.  -     each(['prev', 'next', 'play', 'add', 'repeat', 'rec', 'status', 'shuffle', 'volumeArea'], function(){
  2396. 1892.  -       if (obj[this]) {
  2397. 1893.  -         var self = this;
  2398. 1894.  -         removeEvent(obj[this], 'mouseover', function() {
  2399. 1895.  -           addClass(this, 'over');
  2400. 1896.  -           if (self == 'status') _a.showStatusTT(this);
  2401. 1897.  -           if (overTTs[self] && !(self == 'add' && hasClass(this, 'added'))) {
  2402. 1898.  -             showTooltip(this, {text: getLang(overTTs[self]), showdt: 0, black: 1, shift: [11, 0, 0]});
  2403. 1899.  -           }
  2404. 1900.  -         });
  2405. 1901.  -       }
  2406. 1902.  -     });
  2407. 1903.  -     each(['prev', 'next', 'play', 'add', 'repeat', 'rec', 'status', 'shuffle', 'volumeArea'], function(){
  2408. 1904.  -       if (obj[this]) {
  2409. 1905.  -         removeEvent(obj[this], 'mouseout', function() {
  2410. 1906.  -           removeClass(this, 'over');
  2411. 1907.  -           removeClass(this, 'down');
  2412. 1908.  -         });
  2413. 1909.  -       }
  2414. 1910.  -     });
  2415. 1911.  -     delete audioPlayer.controls[name];
  2416. 1912.  -   }
  2417. 1913.  - }
  2418. 1914.  -
  2419. 1915.  - try{stManager.done('audioplayer.js');}catch(e){}
  2420. ------
  2421. Файл - audio.js (Старый размер - 112948 | Новый - 0):
  2422. 0.  - var Audio = {
  2423. 1.  -   address: '/audio',
  2424. 2.  -   scrollnode: browser.msie6 ? pageNode : window,
  2425. 3.  -   fixedScroll: !(browser.msie && browser.version < 8 || browser.mobile),
  2426. 4.  -   initPad: function()  {
  2427. 5.  -     if (window._pads && _pads.cur) {
  2428. 6.  -       var __cur = _pads.cur;
  2429. 7.  -       extend(__cur, {
  2430. 8.  -         searchCont: ge('pad_audio_search'),
  2431. 9.  -         aSearch: ge('pad_search'),
  2432. 10.  -         clearSearch: ge('pad_audio_reset'),
  2433. 11.  -         aContent: ge('pad_playlist'),
  2434. 12.  -         sContent: ge('pad_search_list'),
  2435. 13.  -         sPreload: ge('pad_search_preload'),
  2436. 14.  -         showMore: ge('pad_more_audio'),
  2437. 15.  -         sShowMore: ge('pad_more_search_link'),
  2438. 16.  -         sWrap: ge('pad_audio_search_wrap'),
  2439. 17.  -         sSummary: ge('pad_audio_search_summary'),
  2440. 18.  -         albumFilters: ge('pad_album_filters'),
  2441. 19.  -         audioFriends: ge('pad_audio_friends'),
  2442. 20.  -         albumFiltered: ge('pad_album_filtered'),
  2443. 21.  -         popularFilters: ge('pad_audio_popular_filters'),
  2444. 22.  -         audioAlbums: ge('pad_audio_albums'),
  2445. 23.  -         searchFilters: ge('pad_audio_search_filters'),
  2446. 24.  -         popularOwners: ge('pad_audio_popular_owners'),
  2447. 25.  -         popularGenres: ge('pad_audio_genres'),
  2448. 26.  -         audioAlbumsWrap: ge('pad_audio_albums_wrap'),
  2449. 27.  -         searchInfoCont: ge('pad_audio_search_info'),
  2450. 28.  -         feedFilter: ge('pad_feed_filter'),
  2451. 29.  -         topFilter: ge('pad_top_audios'),
  2452. 30.  -         recFilter: ge('pad_recommendations'),
  2453. 31.  -         albumsFilter: ge('pad_audios_albums'),
  2454. 32.  -         friendsList: ge('pad_audio_friends_list'),
  2455. 33.  -         currentFilter: ge('pad_current_filter'),
  2456. 34.  -         friendsSearch: ge('pad_audio_friends_search_input'),
  2457. 35.  -         audioMoreFriensId: 'pad_audio_more_friends',
  2458. 36.  -         popularPerformersId: 'pad_audio_performers',
  2459. 37.  -         searchStr: '',
  2460. 38.  -         htitle: getLang('audio_header')
  2461. 39.  -       });
  2462. 40.  -       __cur.audiosList = __cur.audiosList || {};
  2463. 41.  -       __cur.audios = __cur.audios || {};
  2464. 42.  -       if (cur.module == 'audio' && cur.oid == vk.id && cur.audiosList && cur.audiosList['all']) {
  2465. 43.  -         __cur.audiosList['all'] = clone(cur.audiosList['all']);
  2466. 44.  -         __cur.allAudiosIndex = 'all';
  2467. 45.  -         if (cur.summaryLang) {
  2468. 46.  -           __cur.summaryLang = extend(__cur.summaryLang || {}, cur.summaryLang);
  2469. 47.  -         }
  2470. 48.  -         Audio.generateAlbums(true);
  2471. 49.  -         Audio.changeAllIndex({from_pad: true, index: 'all', clbk: function() {}});
  2472. 50.  -       }
  2473. 51.  -       Audio.startPadEvents();
  2474. 52.  -     }
  2475. 53.  -   },
  2476. 54.  -   init: function(obj, audioTpl) {
  2477. 55.  -     extend(cur, {
  2478. 56.  -       searchCont: ge('audio_search'),
  2479. 57.  -       aSearch: ge('s_search'),
  2480. 58.  -       clearSearch: ge('audio_query_reset'),
  2481. 59.  -       aContent: ge('initial_list'),
  2482. 60.  -       sContent: ge('search_list'),
  2483. 61.  -       sPreload: ge('search_preload'),
  2484. 62.  -       showMore: ge('more_link'),
  2485. 63.  -       sShowMore: ge('s_more_link'),
  2486. 64.  -       sWrap: ge('audio_search_wrap'),
  2487. 65.  -       sSummary: ge('audio_search_summary'),
  2488. 66.  -       albumFilters: ge('album_filters'),
  2489. 67.  -       albumFiltered: ge('album_filtered'),
  2490. 68.  -       searchFilters: ge('audio_search_filters'),
  2491. 69.  -       popularFilters: ge('audio_popular_filters'),
  2492. 70.  -       popularOwners: ge('audio_popular_owners'),
  2493. 71.  -       popularGenres: ge('audio_genres'),
  2494. 72.  -       audioFriends: ge('audio_friends'),
  2495. 73.  -       audioAlbums: ge('audio_albums'),
  2496. 74.  -       audioAlbumsWrap: ge('audio_albums_wrap'),
  2497. 75.  -       audioWrap: ge('audio_wrap'),
  2498. 76.  -       searchInfoCont: ge('audio_search_info'),
  2499. 77.  -       feedFilter: ge('feed_filter'),
  2500. 78.  -       topFilter: ge('top_audios'),
  2501. 79.  -       recFilter: ge('recommendations'),
  2502. 80.  -       albumsFilter: ge('audios_albums'),
  2503. 81.  -       friendsList: ge('audio_friends_list'),
  2504. 82.  -       friendsSearch: ge('audio_friends_search_input'),
  2505. 83.  -       audioMoreFriensId: 'audio_more_friends',
  2506. 84.  -       popularPerformersId: 'audio_performers',
  2507. 85.  -       searchStr: "",
  2508. 86.  -       autoComplete: 1,
  2509. 87.  -       audioTpl: audioTpl,
  2510. 88.  -       audioEl: {
  2511. 89.  -         head: ge('page_header'),
  2512. 90.  -         bar: ge('ac'),
  2513. 91.  -         cont: ge('audio'),
  2514. 92.  -         filters: ge('side_filters')
  2515. 93.  -       }
  2516. 94.  -     });
  2517. 95.  -
  2518. 96.  -     if (ge('ac') && window.audioPlayer) {
  2519. 97.  -       audioPlayer.initEvents();
  2520. 98.  -       audioPlayer.registerPlayer('ac', {
  2521. 99.  -         container: ge('ac'),
  2522. 100.  -         performer: ge('ac_performer'),
  2523. 101.  -         title: ge('ac_title'),
  2524. 102.  -         titleWrap: ge('ac_name'),
  2525. 103.  -         duration: ge('ac_duration'),
  2526. 104.  -         load: ge('ac_load_line'),
  2527. 105.  -         progress: ge('ac_pr_line'),
  2528. 106.  -         progressArea: ge('ac_pr'),
  2529. 107.  -         volume: ge('ac_vol_line'),
  2530. 108.  -         volumeArea: ge('ac_vol'),
  2531. 109.  -         play: ge('ac_play'),
  2532. 110.  -         prev: ge('ac_prev'),
  2533. 111.  -         next: ge('ac_next'),
  2534. 112.  -         add: ge('ac_add'),
  2535. 113.  -         repeat: ge('ac_repeat'),
  2536. 114.  -         shuffle: ge('ac_shuffle'),
  2537. 115.  -         rec: ge('ac_rec'),
  2538. 116.  -         status: ge('ac_status'),
  2539. 117.  -         fixed: !(browser.msie && browser.version < 8 || browser.mobile)
  2540. 118.  -       });
  2541. 119.  -     }
  2542. 120.  -     if (browser.mobile) {
  2543. 121.  -       hide('ac_vol');
  2544. 122.  -       setStyle('ac_duration', {margin: 0});
  2545. 123.  -     }
  2546. 124.  -
  2547. 125.  -     if (!cur.allAudiosIndex) cur.allAudiosIndex = 'all';
  2548. 126.  -
  2549. 127.  -     extend(cur, obj);
  2550. 128.  -     cur.module = 'audio';
  2551. 129.  -     //cur.disableAutoMore = true;
  2552. 130.  -     if (cur.aSearch) {
  2553. 131.  -       cur.aSearch.value = cur.q;
  2554. 132.  -       toggleClass(cur.clearSearch, 'shown', !!cur.q);
  2555. 133.  -       placeholderSetup(cur.aSearch, {back: true});
  2556. 134.  -       setTimeout(function() {
  2557. 135.  -         cur.aSearch.focus();
  2558. 136.  -       }, 0);
  2559. 137.  -     }
  2560. 138.  -     if (ge('audio_friends_search_input')) {
  2561. 139.  -       placeholderSetup(ge('audio_friends_search_input'));
  2562. 140.  -     }
  2563. 141.  -
  2564. 142.  -     Audio.scrollnode = browser.msie6 ? pageNode : window;
  2565. 143.  -     Audio.fixedScroll = !(browser.msie && browser.version < 8 || browser.mobile);
  2566. 144.  -     window.scrollTop = bodyNode.scrollTop = pageNode.scrollTop = htmlNode.scrollTop = 0;
  2567. 145.  -     Audio.startEvents();
  2568. 146.  -     cur.destroy.push(function() {
  2569. 147.  -       Audio.stopEvents();
  2570. 148.  -     });
  2571. 149.  -
  2572. 150.  -     cur.nav.push(function(changed, old, n) {
  2573. 151.  -       if (changed.act == 'popular') {
  2574. 152.  -         Audio.loadPopular({update: true, genre: intval(n.genre)});
  2575. 153.  -         return false;
  2576. 154.  -       }
  2577. 155.  -     });
  2578. 156.  -
  2579. 157.  -
  2580. 158.  -     var _a = window.audioPlayer;
  2581. 159.  -     if (_a && _a.showCurrentTrack) {
  2582. 160.  -       _a.shuffle = false;
  2583. 161.  -       _a.showCurrentTrack();
  2584. 162.  -     }
  2585. 163.  -
  2586. 164.  -     cur.audios = {};
  2587. 165.  -     hide(cur.sContent);
  2588. 166.  -
  2589. 167.  -     cur.silent = true;
  2590. 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};
  2591. 169.  -     if (cur.allAudiosIndex != 'all') {
  2592. 170.  -       Audio.cacheFriendsList();
  2593. 171.  -     }
  2594. 172.  -     if (cur.club) {
  2595. 173.  -       cur.curSection = 'club' + cur.club;
  2596. 174.  -       query.club = cur.club;
  2597. 175.  -       cur.searchStr = cur.q;
  2598. 176.  -     }
  2599. 177.  -     ajax.post(Audio.address, query, {onDone: (function(data, opts) {
  2600. 178.  -       opts = eval('('+opts+')');
  2601. 179.  -       if (opts.exp) {
  2602. 180.  -         _a.statusExport = opts.exp;
  2603. 181.  -         checkbox('currinfo_audio', (_a.hasStatusExport()));
  2604. 182.  -         if (_a && _a.showCurrentTrack) _a.showCurrentTrack();
  2605. 183.  -         delete opts.exp;
  2606. 184.  -       }
  2607. 185.  -       extend(cur, opts);
  2608. 186.  -       if (cur.hashes && cur.hashes.add_hash && !_a.addHash) {
  2609. 187.  -         _a.addHash = cur.hashes.add_hash;
  2610. 188.  -       }
  2611. 189.  -       if (query.id > 0) {
  2612. 190.  -         cur.allFriendsTitles = cur.allFriendsTitles || {};
  2613. 191.  -         cur.allFriendsTitles[query.id] = opts.summaryLang.all_friend_title;
  2614. 192.  -         cur.allFriendsHTitles = cur.allFriendsHTitles || {};
  2615. 193.  -         cur.allFriendsHTitles[query.id] = opts.summaryLang.all_friend_htitle;
  2616. 194.  -       }
  2617. 195.  -       var obj = eval('('+data+')');
  2618. 196.  -       if (!obj) {
  2619. 197.  -         return;
  2620. 198.  -       }
  2621. 199.  -       cur.audiosList = cur.audiosList || {};
  2622. 200.  -       if ((query.club || query.id < 0) && obj.club) {
  2623. 201.  -         var club = query.club || -query.id;
  2624. 202.  -         cur.allClubsHTitles = cur.allClubsHTitles || {};
  2625. 203.  -         cur.allClubsHTitles[club] = opts.summaryLang.all_club_htitle || cur.htitle;
  2626. 204.  -         cur.allFriendsHTitles = cur.allFriendsHTitles || {};
  2627. 205.  -         cur.allFriendsHTitles[-club] = opts.summaryLang.all_club_htitle || cur.htitle;
  2628. 206.  -         cur.curList = 'club' + club;
  2629. 207.  -         cur.audiosList[cur.curList] = obj.club;
  2630. 208.  -       } else {
  2631. 209.  -         cur.curList = (cur.album_id) ? 'album'+cur.album_id : cur.allAudiosIndex;
  2632. 210.  -       }
  2633. 211.  -       cur.searchOffset = 0;
  2634. 212.  -       cur.audiosList[cur.allAudiosIndex] = obj.all ? obj.all : [];
  2635. 213.  -       if (cur.allAudiosIndex == 'all') Audio.generateAlbums();
  2636. 214.  -       cur.sectionCount = (cur.audiosList[cur.curList] || []).length;
  2637. 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) {
  2638. 216.  -         if (cur.sectionCount) {
  2639. 217.  -           var opts = {onReorder: Audio.onAudioReorder, onMouseDown: Audio.onDragStart, onMouseUp: Audio.onDragEnd, noMoveCursor: 1};
  2640. 218.  -           if (cur.audioAlbumsWrap) {
  2641. 219.  -             extend(opts, {target: cur.audioAlbumsWrap, onDragOver: Audio.onDragOver, onDragOut: Audio.onDragOut});
  2642. 220.  -           }
  2643. 221.  -           sorter.init(cur.aContent, opts);
  2644. 222.  -         }
  2645. 223.  -       }
  2646. 224.  -       if (cur.albums) {
  2647. 225.  -         Audio.initAlbumsSort();
  2648. 226.  -       }
  2649. 227.  -       this.indexAll({callback: function() {
  2650. 228.  -         cur.silent = false;
  2651. 229.  -         if (cur.onSilentLoad) {
  2652. 230.  -           cur.onSilentLoad();
  2653. 231.  -         }
  2654. 232.  -         if (!cur.q || cur.club) {
  2655. 233.  -           if (cur.curSection == 'recommendations' || cur.curSection == 'popular' || cur.curSection == 'feed') {
  2656. 234.  -             if (cur[cur.curSection+'Audios']) {
  2657. 235.  -               var k = 0;
  2658. 236.  -               for (var i in cur[cur.curSection+'Audios']) {
  2659. 237.  -                 cur[cur.curSection+'Audios'][i]._order = k++;
  2660. 238.  -               }
  2661. 239.  -               audioPlayer.genPlaylist(cur[cur.curSection+'Audios'], false);
  2662. 240.  -             }
  2663. 241.  -           } else {
  2664. 242.  -             audioPlayer.genPlaylist(cur.audiosList[cur.curList], false, {my: (cur.curList == 'all' && cur.oid == vk.id ? 'my' : false)});
  2665. 243.  -           }
  2666. 244.  -         } else if (!query.club) {
  2667. 245.  -           Audio.selectPerformer({name: cur.q});
  2668. 246.  -         }
  2669. 247.  -         if (cur.audio_id) {
  2670. 248.  -           var audio = cur.audios[cur.audio_id];
  2671. 249.  -           if (audio) {
  2672. 250.  -             var audio_id = audio[0] + '_' + audio[1];
  2673. 251.  -             if (audio[11] && parseInt(audio[11])) {
  2674. 252.  -               var claim = parseInt(audio[11]) || 0;
  2675. 253.  -               if (claim == -2) claim = 0;
  2676. 254.  -               Audio.showAudioClaimWarning(audio_id, claim, audio[5] + ' &ndash; ' + audio[6]);
  2677. 255.  -             } else {
  2678. 256.  -               try{
  2679. 257.  -                 playAudioNew(audio_id);
  2680. 258.  -               }catch(e){};
  2681. 259.  -             }
  2682. 260.  -           }
  2683. 261.  -         }
  2684. 262.  -       }});
  2685. 263.  -     }).bind(this), local: 1});
  2686. 264.  -   },
  2687. 265.  -
  2688. 266.  -   startEvents: function() {
  2689. 267.  -     addEvent(Audio.scrollnode, 'scroll', Audio.scrollCheck);
  2690. 268.  -     addEvent(window, 'resize', Audio.scrollCheck);
  2691. 269.  -     addEvent(cur.aSearch, 'blur', Audio.searchBlur.pbind(false));
  2692. 270.  -     addEvent(cur.aSearch, 'focus', Audio.searchFocus.pbind(false));
  2693. 271.  -     cur.gpHidden = true;
  2694. 272.  -     toggleGlobalPlayer(false);
  2695. 273.  -     if (Audio.fixedScroll) {
  2696. 274.  -       var els = geByClass('top_info_wrap', ge('page_wrap'));
  2697. 275.  -       each(els, function() { hide(this); });
  2698. 276.  -       hide(_stlSide);
  2699. 277.  -       setTimeout(function() {
  2700. 278.  -         each(els, function() { hide(this); });
  2701. 279.  -         hide(_stlSide);
  2702. 280.  -       }, 110);
  2703. 281.  -       var headH = cur.audioEl.head.clientHeight,
  2704. 282.  -           headT = getXY(cur.audioEl.head)[1],
  2705. 283.  -           audioNavH = cur.audioEl.bar.offsetHeight,
  2706. 284.  -           headW = cur.audioEl.head.clientWidth,
  2707. 285.  -           contentY = headH + audioNavH;
  2708. 286.  -       setStyle(cur.audioEl.head, {width: headW, top: headT});
  2709. 287.  -       setStyle('side_bar', {top: headH + headT});
  2710. 288.  -       setStyle(cur.audioEl.bar, {top: headH + headT});
  2711. 289.  -       setStyle(cur.audioEl.cont, {paddingTop: contentY});
  2712. 290.  -       setStyle(cur.audioEl.filters, {top: contentY});
  2713. 291.  -
  2714. 292.  -       addClass(bodyNode, 'audio_fixed_nav');
  2715. 293.  -       _fixedNav = true;
  2716. 294.  -     }
  2717. 295.  -     Audio.updateAlbumsTitles();
  2718. 296.  -     Audio.handleFilterPos();
  2719. 297.  -   },
  2720. 298.  -
  2721. 299.  -   stopEvents: function() {
  2722. 300.  -     removeEvent(Audio.scrollnode, 'scroll', Audio.scrollCheck);
  2723. 301.  -     removeEvent(window, 'resize', Audio.scrollCheck);
  2724. 302.  -     removeEvent(cur.aSearch, 'blur', Audio.searchBlur.pbind(false));
  2725. 303.  -     removeEvent(cur.aSearch, 'focus', Audio.searchFocus.pbind(false));
  2726. 304.  -     if (Audio.fixedScroll) {
  2727. 305.  -       var els = geByClass('top_info_wrap', ge('page_wrap'));
  2728. 306.  -       each(els, function() { show(this); });
  2729. 307.  -       setStyle(cur.audioEl.head, {width: '', top: ''});
  2730. 308.  -       setStyle('side_bar', {top: ''});
  2731. 309.  -
  2732. 310.  -       removeClass(bodyNode, 'audio_fixed_nav');
  2733. 311.  -       _fixedNav = false;
  2734. 312.  -
  2735. 313.  -       show(_stlSide);
  2736. 314.  -     }
  2737. 315.  -     audioPlayer.deregisterPlayer('ac');
  2738. 316.  -     setTimeout(function() {
  2739. 317.  -       toggleGlobalPlayer(true);
  2740. 318.  -       updGlobalPlayer();
  2741. 319.  -     }, 100);
  2742. 320.  -   },
  2743. 321.  -
  2744. 322.  -   startPadEvents: function() {
  2745. 323.  -     var __cur = window._pads && _pads.cur;
  2746. 324.  -     addEvent(__cur.aSearch, 'blur', Audio.searchBlur.pbind(true));
  2747. 325.  -     addEvent(__cur.aSearch, 'focus', Audio.searchFocus.pbind(true));
  2748. 326.  -     Audio.updateAlbumsTitles({from_pad: true});
  2749. 327.  -   },
  2750. 328.  -
  2751. 329.  -   stopPadEvents: function() {
  2752. 330.  -     var __cur = window._pads && _pads.cur;
  2753. 331.  -     removeEvent(__cur.aSearch, 'blur', Audio.searchBlur.pbind(true));
  2754. 332.  -     removeEvent(__cur.aSearch, 'focus', Audio.searchFocus.pbind(true));
  2755. 333.  -     audioPlayer.deregisterPlayer('pd');
  2756. 334.  -   },
  2757. 335.  -
  2758. 336.  -   searchFocus: function(from_pad) {
  2759. 337.  -     var alist = from_pad ? ge('pad_playlist_panel') : ge('audios_list');
  2760. 338.  -     if (!hasClass(alist, 'light')) addClass(alist, 'light');
  2761. 339.  -   },
  2762. 340.  -
  2763. 341.  -   searchBlur: function(from_pad) {
  2764. 342.  -     var alist = from_pad ? ge('pad_playlist_panel') : ge('audios_list');
  2765. 343.  -     if (hasClass(alist, 'light')) removeClass(alist, 'light');
  2766. 344.  -   },
  2767. 345.  -
  2768. 346.  -   scrollToTop: function(from_pad) {
  2769. 347.  -     if (from_pad && window._pads) {
  2770. 348.  -       animate(_pads.content, {scrollTop: 0}, 200);
  2771. 349.  -     } else {
  2772. 350.  -       scrollToTop();
  2773. 351.  -     }
  2774. 352.  -   },
  2775. 353.  -
  2776. 354.  -   clearSearch: function(opts) {
  2777. 355.  -     opts = opts || {};
  2778. 356.  -     var __cur = opts.from_pad ? window._pads && _pads.cur : window.cur,
  2779. 357.  -         from_pad = !!opts.from_pad, event = opts.event, el = opts.el;
  2780. 358.  -     setStyle(el, {opacity: .6});
  2781. 359.  -     __cur.aSearch.focus();
  2782. 360.  -     if (__cur.allAudiosIndex == 'all') {
  2783. 361.  -       Audio.loadAlbum({from_pad: from_pad, album: 0});
  2784. 362.  -     } else {
  2785. 363.  -       this.filterTimeout = setTimeout((function() {
  2786. 364.  -         val(__cur.aSearch, '');
  2787. 365.  -         removeClass(__cur.clearSearch, 'shown');
  2788. 366.  -         this.updateList({from_pad: from_pad});
  2789. 367.  -         this.hideSearchResults(from_pad);
  2790. 368.  -         this.scrollToTop(from_pad);
  2791. 369.  -       }).bind(this), 10);
  2792. 370.  -     }
  2793. 371.  -     if (isVisible(__cur.searchInfoCont)) {
  2794. 372.  -       hide(__cur.searchInfoCont);
  2795. 373.  -       if (from_pad) {
  2796. 374.  -         Audio.updatePadFiltersHeight();
  2797. 375.  -       }
  2798. 376.  -     }
  2799. 377.  -   },
  2800. 378.  -
  2801. 379.  -   updateSorterRows: function(fromEl) {
  2802. 380.  -     if (fromEl && fromEl.parentNode.sorter){
  2803. 381.  -       sorter.update(fromEl);
  2804. 382.  -     }
  2805. 383.  -   },
  2806. 384.  -
  2807. 385.  -   showLyrics: function(id, lid, top) {
  2808. 386.  -     var lyrics_div = ge('lyrics'+id);
  2809. 387.  -     if (!isVisible(lyrics_div)) {
  2810. 388.  -       show(lyrics_div);
  2811. 389.  -       lyrics_div.innerHTML = "<div style='text-align: center; height: 50px; padding: 30px 10px 10px 10px'><img valign='middle' src='/images/progress7.gif'></div>";
  2812. 390.  -       Audio.updateSorterRows(ge('audio'+id));
  2813. 391.  -       ajax.post(Audio.address, {act: 'get_lyrics', lid: lid, aid: id, top: top ? 1 : 0}, {cache: 1, onDone: (function(responseText) {
  2814. 392.  -           lyrics_div.innerHTML = responseText;
  2815. 393.  -           Audio.updateSorterRows(ge('audio'+id));
  2816. 394.  -         }).bind(this)});
  2817. 395.  -     } else {
  2818. 396.  -       lyrics_div.innerHTML = "";
  2819. 397.  -       hide(lyrics_div);
  2820. 398.  -       Audio.updateSorterRows(ge('audio'+id));
  2821. 399.  -       Audio.handleFilterPos();
  2822. 400.  -     }
  2823. 401.  -   },
  2824. 402.  -
  2825. 403.  -   allAudios: function(from_pad) {
  2826. 404.  -     var __cur = from_pad ? window._pads && _pads.cur : window.cur;
  2827. 405.  -     return __cur.audiosList ? __cur.audiosList[__cur.allAudiosIndex] || [] : [];
  2828. 406.  -   },
  2829. 407.  -
  2830. 408.  -   showRows: function(opts) {
  2831. 409.  -     opts = opts || {};
  2832. 410.  -     var __cur = opts.from_pad ? window._pads && _pads.cur : window.cur,
  2833. 411.  -         from_pad = !!opts.from_pad, force = opts.force, start = opts.start, end = opts.end;
  2834. 412.  -
  2835. 413.  -     if (from_pad && !__cur.curSection) {
  2836. 414.  -       Pads.showAudios();
  2837. 415.  -       return;
  2838. 416.  -     } else if (__cur.curSection == 'recommendations') {
  2839. 417.  -       Audio.loadRecommendations({from_pad: from_pad});
  2840. 418.  -       return;
  2841. 419.  -     } else if (__cur.curSection == 'popular') {
  2842. 420.  -       Audio.loadPopular({from_pad: from_pad});
  2843. 421.  -       return;
  2844. 422.  -     } else if (__cur.curSection == 'feed') {
  2845. 423.  -       Audio.loadFeed({from_pad: from_pad});
  2846. 424.  -       return;
  2847. 425.  -     }
  2848. 426.  -     if (__cur.silent) {
  2849. 427.  -       __cur.onSilentLoad = function() {
  2850. 428.  -         Audio.showRows(opts);
  2851. 429.  -       };
  2852. 430.  -       return;
  2853. 431.  -     }
  2854. 432.  -     var list = __cur.audiosList[__cur.curList] || [];
  2855. 433.  -     if (list[0] && list[0]._order !== undefined) {
  2856. 434.  -       list = list.sort(function(a,b) {return a._order - b._order});
  2857. 435.  -     }
  2858. 436.  -     list = Audio.filterClaimed(list);
  2859. 437.  -     __cur.sectionCount = list.length;
  2860. 438.  -     if (!__cur.searchStr) {
  2861. 439.  -       list = Audio.filterDeleted(list, from_pad);
  2862. 440.  -       if (__cur.filterUnsorted) {
  2863. 441.  -         list = Audio.filterByAlbum(list, 0);
  2864. 442.  -       }
  2865. 443.  -       __cur.sectionCount = list.length;
  2866. 444.  -     }
  2867. 445.  -     if (start == undefined) {
  2868. 446.  -       start = __cur.shownAudios;
  2869. 447.  -     }
  2870. 448.  -     if (end == undefined) {
  2871. 449.  -       end = __cur.shownAudios + __cur.audiosPerPage;
  2872. 450.  -     }
  2873. 451.  -     if (window.tooltips && cur.tooltips) {
  2874. 452.  -       for (var i = 0; i < cur.tooltips.length; ++i) {
  2875. 453.  -         if (cur.tooltips[i].el) {
  2876. 454.  -           if (hasClass(cur.tooltips[i].el, 'audio_friend')) continue;
  2877. 455.  -           if (cur.tooltips[i].el.ttimer) {
  2878. 456.  -             clearTimeout(cur.tooltips[i].el.ttimer);
  2879. 457.  -           }
  2880. 458.  -         }
  2881. 459.  -         cur.tooltips[i].hide({fasthide: true});
  2882. 460.  -       }
  2883. 461.  -     }
  2884. 462.  -     if (from_pad && ge('pad_footer_text')) {
  2885. 463.  -       ge('pad_footer_text').innerHTML = '';
  2886. 464.  -     }
  2887. 465.  -     var _a = window.audioPlayer;
  2888. 466.  -     if (!list || !list.length) {
  2889. 467.  -       if (__cur.shownAudios == 0 && (__cur.album_id || (!Audio.allAudios(from_pad).length && !__cur.searchStr))) {
  2890. 468.  -         var msg;
  2891. 469.  -         if (Audio.allAudios(from_pad).length) {
  2892. 470.  -           msg = (__cur.album_id) ? getLang('audio_album_no_recs') : getLang('audio_no_audios_found').split('{query}').join('<b>'+cur.searchStr.replace(/([<>&#]*)/g, '')+'</b>');
  2893. 471.  -         } else {
  2894. 472.  -           if (__cur.oid > 0 && !__cur.audioFriend) {
  2895. 473.  -             if ((__cur.id == vk.id || from_pad) && __cur.allAudiosIndex == 'all') {
  2896. 474.  -               msg = getLang('audio_no_rec_load_msg').split('{link}').join('<a href="#" onclick="Audio.addAudio(); return false">').split('{/link}').join('</a>');
  2897. 475.  -             } else {
  2898. 476.  -               msg = getLang('audio_user_no_recs');
  2899. 477.  -             }
  2900. 478.  -           } else {
  2901. 479.  -             msg = __cur.audioFriend > 0 ? getLang('audio_user_no_recs') : getLang('audio_group_no_recs');
  2902. 480.  -           }
  2903. 481.  -         }
  2904. 482.  -         var style = from_pad && window._pads && _pads.content ? ' style="height: ' + (getSize(_pads.content)[1] - 110 - ge('pad_playlist').offsetTop) + 'px;"' : '';
  2905. 483.  -         __cur.aContent.innerHTML = '<div id="not_found" class="info_msg" ' + style + '>'+msg+'</div>';
  2906. 484.  -       }
  2907. 485.  -       hide(__cur.showMore);
  2908. 486.  -     } else {
  2909. 487.  -       if (!__cur.shownAudios) {
  2910. 488.  -         __cur.aContent.innerHTML = '';
  2911. 489.  -       }
  2912. 490.  -       var audios = list.slice(start, end);
  2913. 491.  -       if (!audios.length) {
  2914. 492.  -         if (__cur.shownAudios >= __cur.sectionCount) {
  2915. 493.  -           hide(__cur.showMore);
  2916. 494.  -           if (__cur.searchStr) {
  2917. 495.  -             this.loadRows(from_pad);
  2918. 496.  -           }
  2919. 497.  -         }
  2920. 498.  -         return;
  2921. 499.  -       }
  2922. 500.  -       var html = [];
  2923. 501.  -       for (i in audios) {
  2924. 502.  -         var audio = audios[i].slice();
  2925. 503.  -         if (__cur.selection) {
  2926. 504.  -           audio[5] = audio[5].replace(__cur.selection.re, __cur.selection.val);
  2927. 505.  -           audio[6] = audio[6].replace(__cur.selection.re, __cur.selection.val);
  2928. 506.  -         }
  2929. 507.  -         html.push(this.drawAudio(audio, from_pad));
  2930. 508.  -         __cur.shownAudios += 1;
  2931. 509.  -       }
  2932. 510.  -       var au = ce('div', {innerHTML: html.join('')});
  2933. 511.  -       while (au.firstChild) {
  2934. 512.  -         var el = au.firstChild;
  2935. 513.  -         __cur.aContent.appendChild(el);
  2936. 514.  -       }
  2937. 515.  -       if (from_pad && window.Pads && Pads.updateHeight) {
  2938. 516.  -         Pads.updateHeight();
  2939. 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) {
  2940. 518.  -         if (start > 0) {
  2941. 519.  -           setTimeout(sorter.added.pbind(__cur.aContent), 0);
  2942. 520.  -         } else {
  2943. 521.  -           setTimeout(function(){
  2944. 522.  -             var opts = {onReorder: Audio.onAudioReorder, onMouseDown: Audio.onDragStart, onMouseUp: Audio.onDragEnd, noMoveCursor: 1};
  2945. 523.  -             if (__cur.audioAlbumsWrap) {
  2946. 524.  -               extend(opts, {target: __cur.audioAlbumsWrap, onDragOver: Audio.onDragOver, onDragOut: Audio.onDragOut});
  2947. 525.  -             }
  2948. 526.  -             sorter.init(__cur.aContent, opts);
  2949. 527.  -           }, 0);
  2950. 528.  -         }
  2951. 529.  -       }
  2952. 530.  -       if (__cur.searchCount && isVisible(__cur.sContent)) {
  2953. 531.  -         show(__cur.sWrap);
  2954. 532.  -         __cur.sContent.style.paddingTop = '12px';
  2955. 533.  -         __cur.sSummary.innerHTML = langNumeric(__cur.searchCount, __cur.summaryLang['list_found'], true);
  2956. 534.  -       }
  2957. 535.  -       if (_a && _a.showCurrentTrack) _a.showCurrentTrack();
  2958. 536.  -     }
  2959. 537.  -     setTimeout(Audio.handleFilterPos, 0);
  2960. 538.  -     var aid = currentAudioId(), clubList = (__cur.curSection && __cur.curSection.substr(0, 4) == 'club');
  2961. 539.  -     if (_a && _a.gpDisabled && aid) {
  2962. 540.  -       var track_id = aid.split('_')[1];
  2963. 541.  -       if (!__cur.audios[track_id]) _a.stop();
  2964. 542.  -     }
  2965. 543.  -     if (__cur.justShuffled) {
  2966. 544.  -       toggle(__cur.showMore, __cur.shownAudios < __cur.sectionCount);
  2967. 545.  -       return;
  2968. 546.  -     }
  2969. 547.  -     if (clubList) {
  2970. 548.  -       Audio.hideSearchResults(from_pad);
  2971. 549.  -     }
  2972. 550.  -     if (force) return;
  2973. 551.  -     if (__cur.shownAudios >= __cur.sectionCount) {
  2974. 552.  -       hide(__cur.showMore);
  2975. 553.  -       if (__cur.searchStr && !clubList) {
  2976. 554.  -         this.loadRows(from_pad);
  2977. 555.  -       } else if (!from_pad) {
  2978. 556.  -         Audio.setQLoc(__cur.searchStr);
  2979. 557.  -       }
  2980. 558.  -     } else {
  2981. 559.  -       show(__cur.showMore);
  2982. 560.  -       if (!from_pad) {
  2983. 561.  -         Audio.setQLoc(__cur.searchStr);
  2984. 562.  -       }
  2985. 563.  -     }
  2986. 564.  -   },
  2987. 565.  -
  2988. 566.  -   toggleSearchFriends: function(show, el) {
  2989. 567.  -     var inpWrap = el.nextSibling, inp = geByTag1('input', inpWrap);
  2990. 568.  -     if (val(inp) && !show) return;
  2991. 569.  -     toggle(el, !show);
  2992. 570.  -     toggle(inpWrap, show);
  2993. 571.  -     if (show) {
  2994. 572.  -       setTimeout(function() {inp.select();}, 0);
  2995. 573.  -     }
  2996. 574.  -   },
  2997. 575.  -
  2998. 576.  -   clearFriendsSearch: function(opts) {
  2999. 577.  -     opts = opts || {};
  3000. 578.  -     var __cur = opts.from_pad ? window._pads && _pads.cur : window.cur,
  3001. 579.  -         from_pad = !!opts.from_pad, inp = opts.el;
  3002. 580.  -     val(inp, '');
  3003. 581.  -     this.searchFriends({from_pad: from_pad, str: '', el: inp});
  3004. 582.  -     this.toggleSearchFriends(false, domPS(inp.parentNode));
  3005. 583.  -   },
  3006. 584.  -
  3007. 585.  -   searchFriends: function(opts) {
  3008. 586.  -     opts = opts || {};
  3009. 587.  -     var __cur = opts.from_pad ? window._pads && _pads.cur : window.cur,
  3010. 588.  -         from_pad = !!opts.from_pad, str = trim(val(__cur.friendsSearch)),
  3011. 589.  -         inp = opts.el, event = opts.event;
  3012. 590.  -     if (event && event.keyCode == KEY.ESC) {
  3013. 591.  -       inp.blur();
  3014. 592.  -       return;
  3015. 593.  -     }
  3016. 594.  -     if (str == __cur.searchFriendsStr) return;
  3017. 595.  -     __cur.searchFriendsStr = str;
  3018. 596.  -     toggleClass(inp.parentNode, 'str', !!str);
  3019. 597.  -
  3020. 598.  -     clearTimeout(this.searchFTimeout);
  3021. 599.  -     this.searchFTimeout = setTimeout((function() {
  3022. 600.  -       Audio.searchFriendsRequest({from_pad: from_pad, str: __cur.searchFriendsStr});
  3023. 601.  -     }).bind(this), 150);
  3024. 602.  -   },
  3025. 603.  -
  3026. 604.  -   searchFriendsRequest: function(opts) {
  3027. 605.  -     opts = opts || {};
  3028. 606.  -     var __cur = opts.from_pad ? window._pads && _pads.cur : window.cur,
  3029. 607.  -         from_pad = !!opts.from_pad, str = opts.str;
  3030. 608.  -     if (__cur.searchFriendsSent) {
  3031. 609.  -       return;
  3032. 610.  -     }
  3033. 611.  -     __cur.searchFriendsSent = true;
  3034. 612.  -
  3035. 613.  -     var query = {act: 'search_friends', str: str};
  3036. 614.  -     if (__cur.audioFriend && __cur.allAudiosIndex && !__cur.allAudiosIndex.indexOf('friend')) {
  3037. 615.  -       query.owner = __cur.audioFriend;
  3038. 616.  -     }
  3039. 617.  -     if (from_pad) {
  3040. 618.  -       query.from_pad = 1;
  3041. 619.  -     }
  3042. 620.  -     ajax.post(Audio.address, query, {onDone: function(cont, friends) {
  3043. 621.  -       __cur.searchFriendsSent = false;
  3044. 622.  -       if (cont) {
  3045. 623.  -         __cur.friendsList.innerHTML = cont;
  3046. 624.  -         setTimeout(Audio.handleFilterPos, 0);
  3047. 625.  -         if (friends) {
  3048. 626.  -           __cur.shownFriends = friends;
  3049. 627.  -         }
  3050. 628.  -       }
  3051. 629.  -       if (ge(__cur.audioMoreFriensId)) {
  3052. 630.  -         toggle(ge(__cur.audioMoreFriensId).parentNode, !str);
  3053. 631.  -       }
  3054. 632.  -       if (from_pad) {
  3055. 633.  -         Audio.updatePadFiltersHeight();
  3056. 634.  -       }
  3057. 635.  -     }});
  3058. 636.  -   },
  3059. 637.  -
  3060. 638.  -   loadRows: function(from_pad) {
  3061. 639.  -     var __cur = from_pad ? window._pads && _pads.cur : window.cur;
  3062. 640.  -     if (__cur.sPreload.innerHTML) {
  3063. 641.  -       while (__cur.sPreload.firstChild) {
  3064. 642.  -         var el = __cur.sPreload.firstChild
  3065. 643.  -         __cur.sContent.appendChild(el);
  3066. 644.  -       }
  3067. 645.  -       if (from_pad && window.Pads && Pads.updateHeight) {
  3068. 646.  -         Pads.updateHeight();
  3069. 647.  -       }
  3070. 648.  -     }
  3071. 649.  -     clearTimeout(this.searchTimeout);
  3072. 650.  -     this.searchTimeout = setTimeout((function() {
  3073. 651.  -       Audio.searchRequest({from_pad: from_pad, str: __cur.searchStr, offset: __cur.searchOffset});
  3074. 652.  -     }).bind(this), 300);
  3075. 653.  -   },
  3076. 654.  -
  3077. 655.  -   searchRequest: function(opts) {
  3078. 656.  -     opts = opts || {};
  3079. 657.  -     var __cur = opts.from_pad ? window._pads && _pads.cur : window.cur,
  3080. 658.  -         from_pad = !!opts.from_pad, val = opts.str, offset = opts.offset;
  3081. 659.  -     if (!val) return;
  3082. 660.  -     if (val[val.length - 1] == ' ') {
  3083. 661.  -       val[val.length - 1] = '_';
  3084. 662.  -     }
  3085. 663.  -     addClass(__cur.searchCont, 'loading');
  3086. 664.  -     setStyle(__cur.clearSearch, {opacity: .6});
  3087. 665.  -     var query = {act: 'search', q: val, offset: offset, id: __cur.id, gid: __cur.gid, performer: __cur.searchTypeMenu ? __cur.searchTypeMenu.val() : 0};
  3088. 666.  -     if (!from_pad) {
  3089. 667.  -       var l = ge('audio_lyrics_filter');
  3090. 668.  -       if (l && parseInt(l.value)) query.lyrics = 1;
  3091. 669.  -     }
  3092. 670.  -     if (__cur.searchSortFilter) query.sort = parseInt(__cur.searchSortFilter.val());
  3093. 671.  -     if (__cur.autoComplete) query.autocomplete = __cur.autoComplete;
  3094. 672.  -     if (nav.objLoc.claim && !from_pad) query.claim = nav.objLoc.claim;
  3095. 673.  -     if (from_pad) {
  3096. 674.  -       query.from_pad = 1;
  3097. 675.  -     }
  3098. 676.  -     ajax.post(Audio.address, query, {onDone: function(res, preload, options) {
  3099. 677.  -         removeClass(__cur.searchCont, 'loading');
  3100. 678.  -         var newVal = __cur.searchStr;
  3101. 679.  -         if (newVal[newVal.length - 1] == ' ') {
  3102. 680.  -           newVal[newVal.length - 1] = '_';
  3103. 681.  -         }
  3104. 682.  -         if (val != newVal) {
  3105. 683.  -           return;
  3106. 684.  -         }
  3107. 685.  -         if (res) {
  3108. 686.  -           __cur.sContent.innerHTML = res;
  3109. 687.  -           if (from_pad && window.Pads && Pads.updateHeight) {
  3110. 688.  -             Pads.updateHeight();
  3111. 689.  -           }
  3112. 690.  -         }
  3113. 691.  -         if (preload) {
  3114. 692.  -           __cur.sPreload.innerHTML = preload;
  3115. 693.  -         }
  3116. 694.  -         Audio.applyOptions(__cur, options, offset);
  3117. 695.  -         if (from_pad) {
  3118. 696.  -           Audio.updatePadFiltersHeight();
  3119. 697.  -         }
  3120. 698.  -         show(__cur.sContent);
  3121. 699.  -         if (!__cur.sectionCount) {
  3122. 700.  -           hide(__cur.sWrap);
  3123. 701.  -           __cur.sContent.style.paddingTop = '0px';
  3124. 702.  -           __cur.aContent.innerHTML = '';
  3125. 703.  -           if (!__cur.searchCount && !res && !preload) {
  3126. 704.  -             msg = getLang('audio_no_audios_found').split('{query}').join('<b>'+__cur.searchStr.replace(/([<>&#]*)/g, '')+'</b>');
  3127. 705.  -             var style = from_pad && window._pads && _pads.content ? ' style="height: ' + (getSize(_pads.content)[1] - 110 - ge('pad_playlist').offsetTop) + 'px;"' : '';
  3128. 706.  -             __cur.aContent.innerHTML = '<div id="not_found" class="info_msg"' + style + '>'+msg+'</div>';
  3129. 707.  -             hide(__cur.showMore);
  3130. 708.  -             hide(__cur.sContent);
  3131. 709.  -           }
  3132. 710.  -         } else {
  3133. 711.  -           __cur.sContent.style.paddingTop = '12px';
  3134. 712.  -           if (__cur.searchCount) {
  3135. 713.  -             __cur.sSummary.innerHTML = langNumeric(__cur.searchCount, __cur.summaryLang['list_found'], true);
  3136. 714.  -             show(__cur.sWrap);
  3137. 715.  -           } else {
  3138. 716.  -             Audio.hideSearchResults(from_pad);
  3139. 717.  -             hide(__cur.sWrap);
  3140. 718.  -           }
  3141. 719.  -         }
  3142. 720.  -         Audio.changeSummary({from_pad: from_pad, from_search: true});
  3143. 721.  -         Audio.scrollCheck();
  3144. 722.  -         if (!offset && !from_pad) {
  3145. 723.  -           Audio.setQLoc(__cur.searchStr);
  3146. 724.  -         }
  3147. 725.  -         var _a = window.audioPlayer;
  3148. 726.  -         if (_a && _a.showCurrentTrack) _a.showCurrentTrack();
  3149. 727.  -       },
  3150. 728.  -       onFail: function() {
  3151. 729.  -         removeClass(__cur.searchCont, 'loading');
  3152. 730.  -       },
  3153. 731.  -       showProgress: function () {
  3154. 732.  -         __cur.isAudioLoading = true;
  3155. 733.  -       },
  3156. 734.  -       hideProgress: function () {
  3157. 735.  -         __cur.isAudioLoading = false;
  3158. 736.  -       }
  3159. 737.  -     });
  3160. 738.  -   },
  3161. 739.  -
  3162. 740.  -   changeSearchFilters: function(from_pad) {
  3163. 741.  -     var __cur = from_pad ? window._pads && _pads.cur : window.cur;
  3164. 742.  -     __cur.searchOffset = 0;
  3165. 743.  -     Audio.searchRequest({from_pad: from_pad, str: __cur.searchStr, offset: 0});
  3166. 744.  -   },
  3167. 745.  -
  3168. 746.  -   hideSearchResults: function(from_pad) {
  3169. 747.  -     setTimeout(function(){
  3170. 748.  -       var __cur = from_pad ? window._pads && _pads.cur : window.cur;
  3171. 749.  -       __cur.sContent.innerHTML = '';
  3172. 750.  -       if (__cur.curSection != 'recommendations' && __cur.curSection != 'popular' && __cur.curSection != 'feed') __cur.sPreload.innerHTML = '';
  3173. 751.  -       hide(__cur.sContent);
  3174. 752.  -       hide(__cur.sWrap);
  3175. 753.  -       hide(__cur.sShowMore);
  3176. 754.  -       Audio.scrollCheck();
  3177. 755.  -     }, 0);
  3178. 756.  -   },
  3179. 757.  -
  3180. 758.  -   drawAudio: function(audio, from_pad) {
  3181. 759.  -     return from_pad ? Pads.audioRow(audio, {}) : cur.audioTpl(audio, cur.curSection);
  3182. 760.  -   },
  3183. 761.  -
  3184. 762.  -   applyOptions: function(__cur, options, offset) {
  3185. 763.  -     extend(__cur, options);
  3186. 764.  -     if (!__cur.has_more) {
  3187. 765.  -       hide(__cur.sShowMore);
  3188. 766.  -     } else {
  3189. 767.  -       show(__cur.sShowMore);
  3190. 768.  -     }
  3191. 769.  -     if (!offset) {
  3192. 770.  -       if (options.searchInfo) {
  3193. 771.  -         __cur.searchInfoCont.innerHTML = options.searchInfo;
  3194. 772.  -         if (!isVisible(__cur.searchInfoCont)) {
  3195. 773.  -           show(__cur.searchInfoCont);
  3196. 774.  -         }
  3197. 775.  -         each(geByClass('audio_friend_name_now', __cur.searchInfoCont), function() {
  3198. 776.  -           if (this.scrollWidth > this.clientWidth) {
  3199. 777.  -             this.setAttribute('title', this.innerText || this.textContent);
  3200. 778.  -           } else {
  3201. 779.  -             this.removeAttribute('title');
  3202. 780.  -           }
  3203. 781.  -         })
  3204. 782.  -       } else if (isVisible(__cur.searchInfoCont)) {
  3205. 783.  -         hide(__cur.searchInfoCont);
  3206. 784.  -       }
  3207. 785.  -     }
  3208. 786.  -   },
  3209. 787.  -
  3210. 788.  -   handleFilterPos: function() {
  3211. 789.  -     if (!Audio.fixedScroll || !cur.audioEl) return false;
  3212. 790.  -     var headH = cur.audioEl.head.clientHeight, audioNavH = cur.audioEl.bar.offsetHeight,
  3213. 791.  -         contentY = headH + audioNavH,
  3214. 792.  -         st = Math.max(0, scrollGetY()), wh = window.lastWindowHeight || 0, pos = 0,
  3215. 793.  -         filt = ge('side_panel'), filtPos = getXY(filt)[1], filtY = getSize(filt)[1],
  3216. 794.  -         sf = ge('side_filters'), sfPos = (getStyle(sf, 'position') == 'fixed') ? parseInt(getStyle(sf, 'top')) : getXY(sf)[1], sfY = getSize(sf)[1],
  3217. 795.  -         bottomPad = Math.max(0, st + wh - filtY - contentY),
  3218. 796.  -         tooBig = (filtPos + filtY - sfPos - sfY < 20),
  3219. 797.  -         lastPos = cur.filterLastPos || 100, lastSt = cur.lastSt || 0;
  3220. 798.  -
  3221. 799.  -     if  (!tooBig) {
  3222. 800.  -       addClass(sf, 'fixed');
  3223. 801.  -       pos = (wh > sfY + contentY) ? Math.min(contentY, wh - sfY - bottomPad) : Math.max(Math.min(contentY, lastPos + lastSt - st), wh - sfY - bottomPad);
  3224. 802.  -     } else {
  3225. 803.  -       removeClass(sf, 'fixed');
  3226. 804.  -       pos = 0;
  3227. 805.  -     }
  3228. 806.  -     cur.filterLastPos = pos;
  3229. 807.  -     cur.lastSt = st;
  3230. 808.  -     setStyle(sf, {top: pos + 'px'});
  3231. 809.  -
  3232. 810.  -     if (!browser.mozilla && !browser.msie && cur.lastWW !== lastWindowWidth) {
  3233. 811.  -       cur.lastWW = lastWindowWidth;
  3234. 812.  -       var goodLeft1 = ge('page_layout').offsetLeft,
  3235. 813.  -           goodLeft2 = goodLeft1 + cur.audioEl.cont.offsetLeft,
  3236. 814.  -           goodLeft3 = goodLeft2 + getSize(cur.audioEl.cont)[0] - getSize(cur.audioEl.filters)[0] - 10;
  3237. 815.  -       cur.audioEl.head.style.left = ge('side_bar').style.left = goodLeft1 + 'px';
  3238. 816.  -       cur.audioEl.bar.style.left = goodLeft2 + 'px';
  3239. 817.  -       cur.audioEl.filters.style.left = goodLeft3 + 'px';
  3240. 818.  -       setTimeout(Audio.resetStyles, 0);
  3241. 819.  -     }
  3242. 820.  -   },
  3243. 821.  -
  3244. 822.  -   resetStyles: function() {
  3245. 823.  -     cur.audioEl.head.style.left = ge('side_bar').style.left =
  3246. 824.  -     cur.audioEl.bar.style.left = cur.audioEl.filters.style.left = '';
  3247. 825.  -   },
  3248. 826.  -
  3249. 827.  -   scrollCheck: function () {
  3250. 828.  -     Audio.handleFilterPos();
  3251. 829.  -     if (browser.mobile || cur.isAudioLoading  || cur.disableAutoMore) return;
  3252. 830.  -
  3253. 831.  -     if (!isVisible(cur.showMore) && !isVisible(cur.sShowMore)) return;
  3254. 832.  -     if (!cur.curList) {
  3255. 833.  -       setTimeout(Audio.scrollCheck, 50);
  3256. 834.  -       return;
  3257. 835.  -     }
  3258. 836.  -
  3259. 837.  -     var docEl = document.documentElement;
  3260. 838.  -     var ch = window.innerHeight || docEl.clientHeight || bodyNode.clientHeight;
  3261. 839.  -     var st = scrollGetY();
  3262. 840.  -
  3263. 841.  -     if (isVisible(cur.showMore) && st + ch + 400 > cur.showMore.offsetTop) {
  3264. 842.  -       Audio.showRows();
  3265. 843.  -     }
  3266. 844.  -     if (isVisible(cur.sShowMore) && st + ch + 400 > cur.sShowMore.offsetTop) {
  3267. 845.  -       Audio.loadRows();
  3268. 846.  -     }
  3269. 847.  -   },
  3270. 848.  -
  3271. 849.  -   updateList: function(opts) {
  3272. 850.  -     opts = opts || {};
  3273. 851.  -     var __cur = opts.from_pad ? window._pads && _pads.cur : window.cur,
  3274. 852.  -         from_pad = !!opts.from_pad, e = opts.event, force = opts.force,
  3275. 853.  -         showAlbums = opts.showAlbums, fromIndex = opts.fromIndex, obj = __cur.aSearch;
  3276. 854.  -     if (__cur.silent) {
  3277. 855.  -       __cur.onSilentLoad = function() {
  3278. 856.  -         Audio.updateList(opts);
  3279. 857.  -       };
  3280. 858.  -       return;
  3281. 859.  -     }
  3282. 860.  -     if (e && (e.keyCode == 10 || e.keyCode == 13) || __cur.forceNoAutoComplete) {
  3283. 861.  -       delete __cur.forceNoAutoComplete
  3284. 862.  -       delete __cur.autoComplete;
  3285. 863.  -     } else {
  3286. 864.  -       __cur.autoComplete = 1;
  3287. 865.  -     }
  3288. 866.  -     clearTimeout(this.filterTimeout);
  3289. 867.  -     this.filterTimeout = setTimeout((function() {
  3290. 868.  -       var str = trim(obj.value), el;
  3291. 869.  -       if (str == __cur.searchStr && __cur.autoComplete && !__cur.ignoreEqual) {
  3292. 870.  -         return;
  3293. 871.  -       }
  3294. 872.  -       delete __cur.ignoreEqual;
  3295. 873.  -       if (!from_pad) {
  3296. 874.  -         delete nav.objLoc.audio_id;
  3297. 875.  -         if (nav.objLoc.act == 'recommendations' || nav.objLoc.act == 'popular' || nav.objLoc.act == 'feed' || nav.objLoc.act == 'albums') {
  3298. 876.  -           delete nav.objLoc.act;
  3299. 877.  -         }
  3300. 878.  -       }
  3301. 879.  -
  3302. 880.  -       if (__cur.allAudiosIndex == 'all') {
  3303. 881.  -         __cur.album_id = 0;
  3304. 882.  -       }
  3305. 883.  -       each(geByClass('audio_filter', __cur.albumFilters), function(i, e) {
  3306. 884.  -         removeClass(e, 'selected');
  3307. 885.  -       });
  3308. 886.  -       var c = Audio.allAudios(from_pad).length;
  3309. 887.  -       if (str) {
  3310. 888.  -         el = __cur.albumFiltered;
  3311. 889.  -         hide(__cur.audioFriends);
  3312. 890.  -         Audio.hideAlbums({from_pad: from_pad});
  3313. 891.  -         addClass(__cur.clearSearch, 'shown');
  3314. 892.  -         show(__cur.searchFilters);
  3315. 893.  -         hide(__cur.searchInfoCont);
  3316. 894.  -         if (__cur.audioWrap && !c && __cur.allAudiosIndex == 'all') {
  3317. 895.  -           removeClass(__cur.audioWrap, 'audio_no_recs');
  3318. 896.  -         }
  3319. 897.  -       } else {
  3320. 898.  -         if (showAlbums || __cur.oid != vk.id && !from_pad) {
  3321. 899.  -           if (__cur.allAudiosIndex == 'all') {
  3322. 900.  -             el = __cur.albumsFilter || ge((from_pad ? 'pad_' : '') + 'album0');
  3323. 901.  -           }
  3324. 902.  -           hide(__cur.audioFriends);
  3325. 903.  -           Audio.showAlbums({from_pad: from_pad});
  3326. 904.  -         } else if (fromIndex == 2) {
  3327. 905.  -           Audio.hideAlbums({from_pad: from_pad});
  3328. 906.  -           hide(__cur.audioFriends);
  3329. 907.  -           __cur.searchInfoCont.innerHTML = __cur.performerInfo[__cur.allAudiosIndex];
  3330. 908.  -           show(__cur.searchInfoCont);
  3331. 909.  -         } else {
  3332. 910.  -           Audio.hideAlbums({from_pad: from_pad});
  3333. 911.  -           show(__cur.audioFriends);
  3334. 912.  -           hide(__cur.searchInfoCont);
  3335. 913.  -           if (__cur.allAudiosIndex == 'all') {
  3336. 914.  -             el = ge((from_pad ? 'pad_' : '') + 'album0');
  3337. 915.  -             var curEl = geByClass1('current', __cur.friendsList);
  3338. 916.  -             if (curEl) removeClass(curEl, 'current');
  3339. 917.  -           }
  3340. 918.  -         }
  3341. 919.  -         removeClass(__cur.clearSearch, 'shown');
  3342. 920.  -         removeClass(__cur.albumFiltered, 'selected');
  3343. 921.  -         hide(__cur.searchFilters);
  3344. 922.  -         if (__cur.audioWrap && !c && __cur.allAudiosIndex == 'all' && __cur.oid <= 0) {
  3345. 923.  -           addClass(__cur.audioWrap, 'audio_no_recs');
  3346. 924.  -         }
  3347. 925.  -       }
  3348. 926.  -       if (el) addClass(el, 'selected');
  3349. 927.  -       hide(__cur.popularFilters, __cur.popularOwners);
  3350. 928.  -       if (from_pad) {
  3351. 929.  -         Audio.updatePadFiltersHeight();
  3352. 930.  -       }
  3353. 931.  -       __cur.searchStr = str;
  3354. 932.  -       this.searchAudios({from_pad: from_pad, str: str, type: __cur.allAudiosIndex, force: force});
  3355. 933.  -       this.scrollToTop(from_pad);
  3356. 934.  -     }).bind(this), fromIndex ? 0 : 10);
  3357. 935.  -   },
  3358. 936.  -
  3359. 937.  -   selectPerformer: function(opts) {
  3360. 938.  -     opts = opts || {};
  3361. 939.  -     var __cur = opts.from_pad ? window._pads && _pads.cur : window.cur,
  3362. 940.  -         from_pad = !!opts.from_pad, event = opts.event, name = opts.name;
  3363. 941.  -     __cur.aSearch.setValue(name);
  3364. 942.  -     __cur.forceNoAutoComplete = true;
  3365. 943.  -     if (event) {
  3366. 944.  -       __cur.searchTypeMenu.value = 1;
  3367. 945.  -       __cur.searchTypeChanged({target: {index: 1}}, true);
  3368. 946.  -     }
  3369. 947.  -     Audio.updateList({from_pad: from_pad});
  3370. 948.  -     if (event) cancelEvent(event);
  3371. 949.  -   },
  3372. 950.  -
  3373. 951.  -   searchAudios: function(opts) {
  3374. 952.  -     opts = opts || {};
  3375. 953.  -     var __cur = opts.from_pad ? window._pads && _pads.cur : window.cur,
  3376. 954.  -         from_pad = !!opts.from_pad, str = opts.str, type = opts.type, force = opts.force;
  3377. 955.  -     __cur.shownAudios = 0;
  3378. 956.  -     __cur.curSection = type;
  3379. 957.  -     if (from_pad && !__cur.audiosIndex) {
  3380. 958.  -       Audio.loadFriendsAudios({from_pad: from_pad, id: vk.id, index: 'all', str: str});
  3381. 959.  -       return;
  3382. 960.  -     }
  3383. 961.  -     var clubList = (type && type.substr(0, 4) == 'club');
  3384. 962.  -     if (!clubList && __cur.searchSortFilter) {
  3385. 963.  -       __cur.searchSortFilter.disable(false);
  3386. 964.  -       __cur.searchLyricsFilter.disable(false);
  3387. 965.  -       removeClass(__cur.albumFiltered, 'club_shown');
  3388. 966.  -       delete __cur.club;
  3389. 967.  -     }
  3390. 968.  -     if (str) {
  3391. 969.  -       var htmlentities = function(s){
  3392. 970.  -         var el = document.createElement('div');
  3393. 971.  -         el.innerText = el.textContent = s;
  3394. 972.  -         s = el.innerHTML;
  3395. 973.  -         delete el;
  3396. 974.  -         return s.split('"').join('&quot;');
  3397. 975.  -       }
  3398. 976.  -       var htmlencode = function(str){
  3399. 977.  -         return str.toLowerCase().replace(/\u2013|\u2014/g, '-');
  3400. 978.  -         var aStr = str.toLowerCase().replace(/\u2013|\u2014/g, '-').split(''), i = aStr.length, aRet = [];
  3401. 979.  -         while (i--) {
  3402. 980.  -           var iC = aStr[i].charCodeAt();
  3403. 981.  -           if ((iC > 127 && iC < 994)) {
  3404. 982.  -             aRet.push('&#'+iC+';');
  3405. 983.  -           } else if (iC == 36) {
  3406. 984.  -             aRet.push('&#0'+iC+';');
  3407. 985.  -           } else {
  3408. 986.  -             aRet.push(htmlentities(aStr[i]));
  3409. 987.  -           }
  3410. 988.  -         }
  3411. 989.  -         return aRet.reverse().join('');
  3412. 990.  -       }
  3413. 991.  -       var res = __cur.audiosIndex.search(htmlencode(str));
  3414. 992.  -       var newList = __cur.curSection;
  3415. 993.  -       newList += '_search_'+str;
  3416. 994.  -
  3417. 995.  -       __cur.curList = newList;
  3418. 996.  -       __cur.audiosList[__cur.curList] = res.sort(function(a,b) {return a._order - b._order});
  3419. 997.  -       audioPlayer.genPlaylist(res, false);
  3420. 998.  -
  3421. 999.  -       if (str) {
  3422. 1000.  -         str += ' '+(parseLatin(str) || '');
  3423. 1001.  -         str = trim(escapeRE(str.replace(/\)/g, '')).split('&').join('&amp;'));
  3424. 1002.  -         __cur.selection = {
  3425. 1003.  -           re: new RegExp('(\\s|^)('+str.replace(__cur.audiosIndex.delimiter, '|').replace(/(^\||\|$|\?)/g, '')+')', 'gi'),
  3426. 1004.  -           val: '$1<span>$2</span>'
  3427. 1005.  -         };
  3428. 1006.  -       }
  3429. 1007.  -     } else {
  3430. 1008.  -       if (!clubList) Audio.hideSearchResults(from_pad);
  3431. 1009.  -       __cur.curList = __cur.curSection;
  3432. 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});
  3433. 1011.  -       __cur.selection = false;
  3434. 1012.  -     }
  3435. 1013.  -
  3436. 1014.  -     __cur.sectionCount = (__cur.audiosList[__cur.curList]) ? __cur.audiosList[__cur.curList].length : 0;
  3437. 1015.  -     this.filterTimeout = setTimeout((function() {
  3438. 1016.  -       if (!force) {
  3439. 1017.  -         hide(__cur.sShowMore);
  3440. 1018.  -         __cur.searchOffset = 0;
  3441. 1019.  -       }
  3442. 1020.  -       this.showRows({from_pad: from_pad, force: force});
  3443. 1021.  -       if (__cur.sectionCount || !__cur.searchStr) {
  3444. 1022.  -         this.changeSummary({from_pad: from_pad});
  3445. 1023.  -       }
  3446. 1024.  -       if (__cur.justShuffled) {
  3447. 1025.  -         delete __cur.justShuffled;
  3448. 1026.  -         var aid = currentAudioId();
  3449. 1027.  -         if (cur.nextPlaylist && (!aid || window.audioPlaylist && !window.audioPlaylist[aid])) {
  3450. 1028.  -           window.audioPlaylist = clone(cur.nextPlaylist);
  3451. 1029.  -         }
  3452. 1030.  -         if (!from_pad) {
  3453. 1031.  -           Audio.loadCurrentPlaylist();
  3454. 1032.  -         }
  3455. 1033.  -       }
  3456. 1034.  -     }).bind(this), 10);
  3457. 1035.  -   },
  3458. 1036.  -
  3459. 1037.  -   indexAll: function(opts) {
  3460. 1038.  -     opts = opts || {};
  3461. 1039.  -     var __cur = opts.from_pad ? window._pads && _pads.cur : window.cur,
  3462. 1040.  -         from_pad = !!opts.from_pad, callback = opts.callback;
  3463. 1041.  -     var all = Audio.allAudios(from_pad),
  3464. 1042.  -     replacer = function(str, p) {
  3465. 1043.  -       var c = intval(p);
  3466. 1044.  -       return (c >= 33 && c < 48) ? String.fromCharCode(c) : str;
  3467. 1045.  -     };
  3468. 1046.  -
  3469. 1047.  -     __cur.audiosIndex = new vkIndexer(all, function(obj) {
  3470. 1048.  -       __cur.audios[parseInt(obj[1])] = obj;
  3471. 1049.  -       return (obj[5]+' '+obj[6]).replace(/\&\#(\d+);?/gi, replacer);
  3472. 1050.  -     }, function() {
  3473. 1051.  -       if (callback) {
  3474. 1052.  -         callback();
  3475. 1053.  -       }
  3476. 1054.  -     });
  3477. 1055.  -   },
  3478. 1056.  -
  3479. 1057.  -   changeAllIndex: function(opts) {
  3480. 1058.  -     opts = opts || {};
  3481. 1059.  -     var __cur = opts.from_pad ? window._pads && _pads.cur : window.cur,
  3482. 1060.  -         from_pad = !!opts.from_pad, index = opts.index, albumSelected = opts.album,
  3483. 1061.  -         showAlbums = opts.showAlbums, owner = opts.owner, str = opts.str || '';
  3484. 1062.  -
  3485. 1063.  -     if (!__cur.audiosList[index]) return;
  3486. 1064.  -     __cur.allAudiosIndex = __cur.curList = index;
  3487. 1065.  -     this.indexAll({from_pad: from_pad, callback: opts.clbk || function() {
  3488. 1066.  -       var _a = window.audioPlayer;
  3489. 1067.  -       Audio.mixAllAudios({from_pad: from_pad, mix: (_a && _a.shuffle), noShuffle: true});
  3490. 1068.  -       audioPlayer.genPlaylist(__cur.audiosList[__cur.curList], from_pad && index == 'all' && !currentAudioId(), {my: (index == 'all' && (__cur.oid == vk.id || from_pad) ? 'my' : false)});
  3491. 1069.  -       each(geByTag('div', __cur.albumFilters), function(i, e) {
  3492. 1070.  -         removeClass(e, 'loading');
  3493. 1071.  -       });
  3494. 1072.  -       if (__cur.allLoadedCallback) {
  3495. 1073.  -         __cur.allLoadedCallback();
  3496. 1074.  -         delete __cur.allLoadedCallback;
  3497. 1075.  -         return;
  3498. 1076.  -       }
  3499. 1077.  -
  3500. 1078.  -       __cur.ignoreEqual = true;
  3501. 1079.  -
  3502. 1080.  -       setStyle(__cur.clearSearch, {opacity: .6});
  3503. 1081.  -       val(__cur.aSearch, str);
  3504. 1082.  -       toggleClass(__cur.clearSearch, 'shown', !!str);
  3505. 1083.  -       __cur.searchStr = str;
  3506. 1084.  -       if (str) {
  3507. 1085.  -         __cur.forceNoAutoComplete = true;
  3508. 1086.  -       } else {
  3509. 1087.  -         Audio.hideSearchResults(from_pad);
  3510. 1088.  -       }
  3511. 1089.  -       if (albumSelected) {
  3512. 1090.  -         Audio.loadAlbum({from_pad: from_pad, album: albumSelected});
  3513. 1091.  -       } else {
  3514. 1092.  -         Audio.updateList({from_pad: from_pad, showAlbums: showAlbums, fromIndex: (owner ? 2 : 1)});
  3515. 1093.  -       }
  3516. 1094.  -     }});
  3517. 1095.  -   },
  3518. 1096.  -
  3519. 1097.  -   generateAlbums: function(from_pad) {
  3520. 1098.  -     var __cur = from_pad ? window._pads && _pads.cur : window.cur;
  3521. 1099.  -     for (var i in __cur.audiosList) {
  3522. 1100.  -       if (i.substr(0, 5) == 'album') __cur.audiosList[i] = [];
  3523. 1101.  -     }
  3524. 1102.  -     var all = Audio.allAudios(from_pad);
  3525. 1103.  -     for (var i in all) {
  3526. 1104.  -       var el = all[i];
  3527. 1105.  -       if (el[8] && parseInt(el[8])) {
  3528. 1106.  -         if (!__cur.audiosList['album'+el[8]]) {
  3529. 1107.  -           __cur.audiosList['album'+el[8]] = [];
  3530. 1108.  -         }
  3531. 1109.  -         __cur.audiosList['album'+el[8]].push(el);
  3532. 1110.  -       }
  3533. 1111.  -     }
  3534. 1112.  -   },
  3535. 1113.  -
  3536. 1114.  -   changeHTitle: function(opts) {
  3537. 1115.  -     opts = opts || {};
  3538. 1116.  -     var __cur = opts.from_pad ? window._pads && _pads.cur : window.cur,
  3539. 1117.  -         from_pad = !!opts.from_pad, from_search = opts.from_search;
  3540. 1118.  -     var htitle = __cur.htitle, pad_htitle = '';
  3541. 1119.  -     if (__cur.curSection && !__cur.curSection.indexOf('album')) {
  3542. 1120.  -       var album = ge((from_pad ? 'pad_' : '') + __cur.curSection);
  3543. 1121.  -       if (album) {
  3544. 1122.  -         htitle = album.innerText || album.textContent;
  3545. 1123.  -       }
  3546. 1124.  -     } else if (__cur.curSection && __cur.curSection == 'recommendations') {
  3547. 1125.  -       htitle = __cur.recommendTitle ? __cur.recommendTitle : getLang('audio_recommended_audios');
  3548. 1126.  -     } else if (__cur.curSection && __cur.curSection == 'feed') {
  3549. 1127.  -       htitle = __cur.feedTitle ? __cur.feedTitle : getLang('audio_friends_feed');
  3550. 1128.  -     } else if (__cur.curSection && __cur.curSection == 'popular') {
  3551. 1129.  -       htitle = __cur.popularTitle ? __cur.popularTitle : getLang('audio_popular_audios');
  3552. 1130.  -     } else if (__cur.curSection && __cur.curSection.indexOf('owner') === 0) {
  3553. 1131.  -       htitle = __cur.allFriendsHTitles[__cur.audioFriend];
  3554. 1132.  -     } else if (from_search) {
  3555. 1133.  -       htitle = getLang('audio_title_search').replace('{q}', val(__cur.aSearch));
  3556. 1134.  -       pad_htitle = getLang('audio_title_search').replace('{q}', '<b>' + val(__cur.aSearch) + '</b>');
  3557. 1135.  -     } else if (__cur.curSection && !__cur.curSection.indexOf('club')) {
  3558. 1136.  -       htitle = __cur.allClubsHTitles[__cur.club] || htitle;
  3559. 1137.  -     } else if (__cur.audioFriend && __cur.allAudiosIndex && !__cur.allAudiosIndex.indexOf('friend')) {
  3560. 1138.  -       htitle = __cur.allFriendsHTitles[__cur.audioFriend];
  3561. 1139.  -     }
  3562. 1140.  -     __cur.lastHTitle = pad_htitle || htitle;
  3563. 1141.  -     if (from_pad) {
  3564. 1142.  -       return;
  3565. 1143.  -     }
  3566. 1144.  -     if (opts.count && cur.lang.audio_N_recs) {
  3567. 1145.  -       htitle += ' | ' + getLang('audio_N_recs', opts.count);
  3568. 1146.  -     }
  3569. 1147.  -     // Updating document title
  3570. 1148.  -     document.title = replaceEntities(stripHTML(htitle));
  3571. 1149.  -   },
  3572. 1150.  -
  3573. 1151.  -   changeSummary: function(opts) {
  3574. 1152.  -     opts = opts || {};
  3575. 1153.  -     var from_pad = opts.from_pad, from_search = opts.from_search;
  3576. 1154.  -     var count = (from_search) ? cur.searchCount : cur.sectionCount;
  3577. 1155.  -     Audio.changeHTitle({from_pad: from_pad, count: count, from_search: from_search});
  3578. 1156.  -   },
  3579. 1157.  -
  3580. 1158.  -   setQLoc: function(query) {
  3581. 1159.  -     clearTimeout(this.qTimeout);
  3582. 1160.  -     this.qTimeout = setTimeout(function() {
  3583. 1161.  -       if (cur.allAudiosIndex != 'all') {
  3584. 1162.  -         if (cur.allAudiosIndex && cur.allAudiosIndex.substr(0, 5) == 'owner') {
  3585. 1163.  -           extend(nav.objLoc, {owner: cur.audioFriend});
  3586. 1164.  -         } else {
  3587. 1165.  -           extend(nav.objLoc, {friend: cur.audioFriend});
  3588. 1166.  -         }
  3589. 1167.  -       } else {
  3590. 1168.  -         delete nav.objLoc.owner;
  3591. 1169.  -         delete nav.objLoc.friend;
  3592. 1170.  -       }
  3593. 1171.  -       if (cur.curSection && cur.curSection.substr(0, 4) == 'club') {
  3594. 1172.  -         extend(nav.objLoc, {club: cur.club});
  3595. 1173.  -       } else {
  3596. 1174.  -         delete nav.objLoc.club;
  3597. 1175.  -         delete nav.objLoc.genre;
  3598. 1176.  -       }
  3599. 1177.  -       if (query) {
  3600. 1178.  -         extend(nav.objLoc, {q: query});
  3601. 1179.  -         var performer = cur.searchTypeMenu ? parseInt(cur.searchTypeMenu.val()) : 0;
  3602. 1180.  -         if (performer) {
  3603. 1181.  -           extend(nav.objLoc, {performer: performer});
  3604. 1182.  -         } else {
  3605. 1183.  -           delete nav.objLoc.performer;
  3606. 1184.  -         }
  3607. 1185.  -       } else {
  3608. 1186.  -         delete nav.objLoc.q;
  3609. 1187.  -       }
  3610. 1188.  -       nav.setLoc(nav.objLoc);
  3611. 1189.  -     }, 500);
  3612. 1190.  -   },
  3613. 1191.  -
  3614. 1192.  -   filterClaimed: function(arr) {
  3615. 1193.  -     var len = arr.length;
  3616. 1194.  -     var res = [];
  3617. 1195.  -     for (var i = 0; i < len; i++) {
  3618. 1196.  -       var t = arr[i];
  3619. 1197.  -       if (t && (!(t[11] && parseInt(t[11])) || t[12] && parseInt(t[12])) || nav.objLoc.claim) {
  3620. 1198.  -         res.push(t);
  3621. 1199.  -       }
  3622. 1200.  -     }
  3623. 1201.  -     return res;
  3624. 1202.  -   },
  3625. 1203.  -
  3626. 1204.  -   filterDeleted: function(arr, from_pad) {
  3627. 1205.  -     var __cur = from_pad ? window._pads && _pads.cur : window.cur;
  3628. 1206.  -     var len = arr.length;
  3629. 1207.  -     var res = [];
  3630. 1208.  -     for (var i = 0; i < len; i++) {
  3631. 1209.  -       var t = arr[i];
  3632. 1210.  -       if (__cur && __cur.audios && __cur.audios[t[1]] && !__cur.audios[t[1]].deleted) {
  3633. 1211.  -         res.push(t);
  3634. 1212.  -       }
  3635. 1213.  -     }
  3636. 1214.  -     return res;
  3637. 1215.  -   },
  3638. 1216.  -
  3639. 1217.  -   filterByAlbum: function(arr, album) {
  3640. 1218.  -     var len = arr.length;
  3641. 1219.  -     var res = [];
  3642. 1220.  -     for (var i = 0; i < len; i++) {
  3643. 1221.  -       var t = arr[i];
  3644. 1222.  -       if (album == t[8]) {
  3645. 1223.  -         res.push(t);
  3646. 1224.  -       }
  3647. 1225.  -     }
  3648. 1226.  -     return res;
  3649. 1227.  -   },
  3650. 1228.  -
  3651. 1229.  -   animateAdded: function(el, speed) {
  3652. 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>');
  3653. 1231.  -     el.parentNode.replaceChild(c, el);
  3654. 1232.  -     el = c;
  3655. 1233.  -     setTimeout(function() {
  3656. 1234.  -       var anim = geByClass1('audio_add_anim', el), add = anim.firstChild, added = add.nextSibling;
  3657. 1235.  -       cssAnim(anim, {left: '-15px'}, {duration: speed}, function() {
  3658. 1236.  -         setStyle(anim.parentNode, {width: '15px'});
  3659. 1237.  -         setStyle(anim.parentNode.parentNode, {paddingLeft: '2px'});
  3660. 1238.  -         setStyle(anim, {left: '-13px'});
  3661. 1239.  -       });
  3662. 1240.  -       cssAnim(add, {opacity: 0}, {duration: speed});
  3663. 1241.  -       cssAnim(added, {opacity: 1}, {duration: speed});
  3664. 1242.  -     }, 0);
  3665. 1243.  -     return el;
  3666. 1244.  -   },
  3667. 1245.  -
  3668. 1246.  -   addShareAudio: function(opts) {
  3669. 1247.  -     opts = opts || {};
  3670. 1248.  -     var __cur = opts.from_pad ? window._pads && _pads.cur : window.cur,
  3671. 1249.  -         from_pad = !!opts.from_pad, el = opts.el, aid = opts.aid, oid = opts.oid,
  3672. 1250.  -         hash = opts.hash, gid = opts.gid, top = opts.top;
  3673. 1251.  -
  3674. 1252.  -     if (el.tt) el.tt.hide();
  3675. 1253.  -     el = Audio.animateAdded(el, 200);
  3676. 1254.  -     var query = {act:'add', aid:aid, oid:oid, hash:hash, top:top};
  3677. 1255.  -     if (gid) query.gid = cur.gid;
  3678. 1256.  -     if (__cur.curSection == 'recommendations') query.recommendation = 1;
  3679. 1257.  -     if ((cur.module == 'audio' || cur.module == 'feed') && nav.objLoc['q'] || cur.module == 'search' && nav.objLoc['c[q]']) query.search = 1;
  3680. 1258.  -     ajax.post(Audio.address, query, {
  3681. 1259.  -       onDone: function (data, res) {
  3682. 1260.  -         var obj = eval('('+data+')'), all_list;
  3683. 1261.  -         if (((!cur.gid && (cur.id == vk.id || from_pad)) || (cur.gid && gid)) && obj) {
  3684. 1262.  -           setTimeout(function(){
  3685. 1263.  -             obj = obj['all'][0];
  3686. 1264.  -             if (cur.audiosIndex) {
  3687. 1265.  -               all_list = cur.audiosList['all'];
  3688. 1266.  -               if (all_list && all_list.length) {
  3689. 1267.  -                 obj._order = all_list[0]._order - 1;
  3690. 1268.  -                 cur.audiosList['all'].splice(0,0,obj);
  3691. 1269.  -               } else {
  3692. 1270.  -                 obj._order = 0;
  3693. 1271.  -                 cur.audiosList['all'] = [obj];
  3694. 1272.  -               }
  3695. 1273.  -               cur.audios[obj[1]] = obj;
  3696. 1274.  -               if (cur.allAudiosIndex == 'all') {
  3697. 1275.  -                 cur.audiosIndex.add(obj);
  3698. 1276.  -               }
  3699. 1277.  -             }
  3700. 1278.  -             if (window._pads && _pads.cur && _pads.cur.audiosIndex && _pads.cur.audiosList) {
  3701. 1279.  -               all_list = _pads.cur.audiosList['all'];
  3702. 1280.  -               if (all_list && all_list.length) {
  3703. 1281.  -                 obj._order = all_list[0]._order - 1;
  3704. 1282.  -                 _pads.cur.audiosList['all'].splice(0,0,obj);
  3705. 1283.  -               } else {
  3706. 1284.  -                 obj._order = 0;
  3707. 1285.  -                 _pads.cur.audiosList['all'] = [obj];
  3708. 1286.  -               }
  3709. 1287.  -               if (_pads.cur.audios) {
  3710. 1288.  -                 _pads.cur.audios[obj[1]] = obj;
  3711. 1289.  -               }
  3712. 1290.  -               if (_pads.cur.allAudiosIndex == 'all') {
  3713. 1291.  -                 _pads.cur.audiosIndex.add(obj);
  3714. 1292.  -               }
  3715. 1293.  -             }
  3716. 1294.  -             if (window.Pads && Pads.clearAudioLoadCache) {
  3717. 1295.  -               Pads.clearAudioLoadCache();
  3718. 1296.  -             }
  3719. 1297.  -           }, 0);
  3720. 1298.  -         }
  3721. 1299.  -         var showShare = function() {
  3722. 1300.  -           addClass(ge('audio'+oid+'_'+aid), 'tt_shown');
  3723. 1301.  -           showTooltip(el, {
  3724. 1302.  -             content: res.content,
  3725. 1303.  -             slide: 15,
  3726. 1304.  -             shift: [59, 5, 0],
  3727. 1305.  -             black: 1,
  3728. 1306.  -             hidedt: 200,
  3729. 1307.  -             className: 'audio_add_tt wall_tt rich',
  3730. 1308.  -             onHide: function() {
  3731. 1309.  -               removeClass(ge('audio'+oid+'_'+aid), 'tt_shown');
  3732. 1310.  -             }
  3733. 1311.  -           });
  3734. 1312.  -           var tip = el.tt;
  3735. 1313.  -           if (tip && !tip.inited) {
  3736. 1314.  -             var a = geByClass('add_cont', tip.container)[0];
  3737. 1315.  -             tip.onClean = function() {
  3738. 1316.  -               tip.inited = false;
  3739. 1317.  -               removeEvent(tip.container, 'mouseover', tip.show);
  3740. 1318.  -               removeEvent(tip.container, 'mouseout', tip.hide);
  3741. 1319.  -             }
  3742. 1320.  -             addEvent(tip.container, 'mouseover', tip.show);
  3743. 1321.  -             addEvent(tip.container, 'mouseout', tip.hide);
  3744. 1322.  -             addEvent(a, 'click', function(){
  3745. 1323.  -               toggleClass(this, 'on');
  3746. 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};
  3747. 1325.  -               if (gid) share_q.gid = cur.gid;
  3748. 1326.  -               ajax.post(Audio.address, share_q, {
  3749. 1327.  -                 onDone: function(data) {
  3750. 1328.  -                   if (data) tip.status = data;
  3751. 1329.  -                 }
  3752. 1330.  -               });
  3753. 1331.  -             });
  3754. 1332.  -             tip.inited = true;
  3755. 1333.  -           }
  3756. 1334.  -         }
  3757. 1335.  -         addEvent(el, 'mouseover', showShare);
  3758. 1336.  -         if (!cur.addedIds) cur.addedIds = {};
  3759. 1337.  -         cur.addedIds[oid+'_'+aid] = 1;
  3760. 1338.  -         if (window.audioPlayer && currentAudioId()) {
  3761. 1339.  -           var cur_aids = currentAudioId().split('_');
  3762. 1340.  -           if (cur_aids[0] == oid && cur_aids[1] == aid) {
  3763. 1341.  -             audioPlayer.showCurrentAdded();
  3764. 1342.  -           }
  3765. 1343.  -         }
  3766. 1344.  -       }
  3767. 1345.  -     });
  3768. 1346.  -   },
  3769. 1347.  -
  3770. 1348.  -   alistOver: function(obj){
  3771. 1349.  -     if (!hasClass(obj, 'audio_list_cell_on')) {
  3772. 1350.  -       obj.className = 'audio_list_cell_over';
  3773. 1351.  -     }
  3774. 1352.  -   },
  3775. 1353.  -
  3776. 1354.  -   alistOff: function(obj) {
  3777. 1355.  -     if (!hasClass(obj, 'audio_list_cell_on')){
  3778. 1356.  -       obj.className = 'audio_list_cell';
  3779. 1357.  -     }
  3780. 1358.  -   },
  3781. 1359.  -
  3782. 1360.  -   listOut: function(obj) {
  3783. 1361.  -     removeClass(obj, 'over');
  3784. 1362.  -   },
  3785. 1363.  -
  3786. 1364.  -   listOver: function(obj) {
  3787. 1365.  -     addClass(obj, 'over');
  3788. 1366.  -   },
  3789. 1367.  -
  3790. 1368.  -   loadAlbum: function(opts) {
  3791. 1369.  -     opts = opts || {};
  3792. 1370.  -     var __cur = opts.from_pad ? window._pads && _pads.cur : window.cur,
  3793. 1371.  -         from_pad = !!opts.from_pad,
  3794. 1372.  -         album_id = opts.album, filter = opts.filter, showAlbums = opts.showAlbums;
  3795. 1373.  -     if (__cur.silent) {
  3796. 1374.  -       __cur.onSilentLoad = function() {
  3797. 1375.  -         Audio.loadAlbum(opts);
  3798. 1376.  -       };
  3799. 1377.  -       return;
  3800. 1378.  -     }
  3801. 1379.  -     if (!album_id && !showAlbums && (__cur.oid == vk.id) && isVisible(__cur.audioMoreFriensId) && !__cur.searchFriendsStr) {
  3802. 1380.  -       __cur.shownFriends = [];
  3803. 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')});
  3804. 1382.  -     }
  3805. 1383.  -     hide(__cur.searchInfoCont);
  3806. 1384.  -     if (__cur.allAudiosIndex != 'all') {
  3807. 1385.  -       Audio.loadFriendsAudios({from_pad: from_pad, id: vk.id, index: 'all', album: album_id, showAlbums: showAlbums});
  3808. 1386.  -       return;
  3809. 1387.  -     }
  3810. 1388.  -     if (__cur.audioWrap && !Audio.allAudios(from_pad).length && __cur.allAudiosIndex == 'all' && __cur.oid <= 0) {
  3811. 1389.  -       addClass(__cur.audioWrap, 'audio_no_recs');
  3812. 1390.  -     }
  3813. 1391.  -     if (filter) {
  3814. 1392.  -       __cur.filterUnsorted = 1;
  3815. 1393.  -     } else {
  3816. 1394.  -       delete __cur.filterUnsorted;
  3817. 1395.  -     }
  3818. 1396.  -     var curSel = __cur.filterUnsorted ? ge('album_unsorted') : (showAlbums ? __cur.albumsFilter : ge((from_pad ? 'pad_' : '') + 'album' + album_id));
  3819. 1397.  -     __cur.lastAct = 'album' + album_id;
  3820. 1398.  -     album_id = album_id || 0;
  3821. 1399.  -     each(geByClass('audio_filter', __cur.albumFilters), function(i, e) {
  3822. 1400.  -       removeClass(e, 'selected');
  3823. 1401.  -     });
  3824. 1402.  -     if (curSel) addClass(curSel, 'selected');
  3825. 1403.  -     removeClass(__cur.albumFiltered, 'selected');
  3826. 1404.  -     hide(__cur.popularFilters, __cur.popularOwners, __cur.searchFilters);
  3827. 1405.  -     if (album_id == 0 && !showAlbums && (__cur.oid == vk.id || from_pad)) {
  3828. 1406.  -       Audio.hideAlbums({from_pad: from_pad});
  3829. 1407.  -       show(__cur.audioFriends);
  3830. 1408.  -       var curEl = geByClass1('current', __cur.friendsList);
  3831. 1409.  -       if (curEl) removeClass(curEl, 'current');
  3832. 1410.  -     } else {
  3833. 1411.  -       hide(__cur.audioFriends);
  3834. 1412.  -       Audio.showAlbums({from_pad: from_pad});
  3835. 1413.  -     }
  3836. 1414.  -     if (from_pad) {
  3837. 1415.  -       Audio.updatePadFiltersHeight();
  3838. 1416.  -     } else {
  3839. 1417.  -       if (showAlbums && !filter && !album_id) {
  3840. 1418.  -         Audio.updateAlbums();
  3841. 1419.  -       }
  3842. 1420.  -       delete nav.objLoc.q;
  3843. 1421.  -       delete nav.objLoc.owner;
  3844. 1422.  -       delete nav.objLoc.friend;
  3845. 1423.  -       delete __cur.recsOffset;
  3846. 1424.  -       delete __cur.popularOffset;
  3847. 1425.  -       delete nav.objLoc.club;
  3848. 1426.  -       delete nav.objLoc.genre;
  3849. 1427.  -       delete nav.objLoc.audio_id;
  3850. 1428.  -       delete __cur._back;
  3851. 1429.  -       if (nav.objLoc.act == 'recommendations' || nav.objLoc.act == 'popular' || nav.objLoc.act == 'feed' || nav.objLoc.act == 'albums') delete nav.objLoc.act;
  3852. 1430.  -       if (album_id) {
  3853. 1431.  -         extend(nav.objLoc, {album_id: album_id});
  3854. 1432.  -       } else {
  3855. 1433.  -         delete nav.objLoc.album_id;
  3856. 1434.  -       }
  3857. 1435.  -       nav.setLoc(nav.objLoc);
  3858. 1436.  -     }
  3859. 1437.  -     clearTimeout(this.filterTimeout);
  3860. 1438.  -     this.filterTimeout = setTimeout((function() {
  3861. 1439.  -       val(__cur.aSearch, '');
  3862. 1440.  -       removeClass(__cur.clearSearch, 'shown');
  3863. 1441.  -       __cur.searchStr = '';
  3864. 1442.  -       __cur.album_id = album_id;
  3865. 1443.  -       var type = (album_id) ? 'album'+album_id : __cur.allAudiosIndex;
  3866. 1444.  -       this.searchAudios({from_pad: from_pad, type: type, str: ''});
  3867. 1445.  -       this.hideSearchResults(from_pad);
  3868. 1446.  -       this.scrollToTop(from_pad);
  3869. 1447.  -     }).bind(this), 10);
  3870. 1448.  -     if (__cur.oid == vk.id || from_pad) {
  3871. 1449.  -       ajax.post(Audio.address, {act: 'list_stats', albums: (album_id || showAlbums) ? 1 : 0});
  3872. 1450.  -     }
  3873. 1451.  -   },
  3874. 1452.  -
  3875. 1453.  -   hideAlbums: function(opts) {
  3876. 1454.  -     opts = opts || {};
  3877. 1455.  -     var __cur = opts.from_pad ? window._pads && _pads.cur : window.cur,
  3878. 1456.  -         from_pad = !!opts.from_pad, icon = geByClass1('icon', __cur.albumsFilter);
  3879. 1457.  -     if (isVisible(__cur.audioAlbums)) {
  3880. 1458.  -       slideUp(__cur.audioAlbums, 200, function() {
  3881. 1459.  -         if (from_pad) {
  3882. 1460.  -           Audio.updatePadFiltersHeight();
  3883. 1461.  -         }
  3884. 1462.  -         removeClass(icon, 'up');
  3885. 1463.  -       });
  3886. 1464.  -     }
  3887. 1465.  -   },
  3888. 1466.  -
  3889. 1467.  -   showAlbums: function(opts) {
  3890. 1468.  -     opts = opts || {};
  3891. 1469.  -     var __cur = opts.from_pad ? window._pads && _pads.cur : window.cur,
  3892. 1470.  -         from_pad = !!opts.from_pad, icon = geByClass1('icon', __cur.albumsFilter);
  3893. 1471.  -     if (!isVisible(__cur.audioAlbums)) {
  3894. 1472.  -       if (!from_pad) {
  3895. 1473.  -         Audio.updateAlbumsStart();
  3896. 1474.  -       }
  3897. 1475.  -       slideUp(__cur.audioAlbums, 200, function() {
  3898. 1476.  -         addClass(icon, 'up');
  3899. 1477.  -         if (from_pad) {
  3900. 1478.  -           Audio.updatePadFiltersHeight();
  3901. 1479.  -         } else {
  3902. 1480.  -           Audio.updateAlbumsFinish();
  3903. 1481.  -         }
  3904. 1482.  -       });
  3905. 1483.  -     }
  3906. 1484.  -   },
  3907. 1485.  -
  3908. 1486.  -   toggleAlbums: function(opts) {
  3909. 1487.  -     opts = opts || {};
  3910. 1488.  -     var __cur = opts.from_pad ? window._pads && _pads.cur : window.cur,
  3911. 1489.  -         from_pad = !!opts.from_pad, down = isVisible(__cur.audioAlbums),
  3912. 1490.  -         icon = geByClass1('icon', __cur.albumsFilter);
  3913. 1491.  -     if (!from_pad) {
  3914. 1492.  -       Audio.updateAlbumsStart();
  3915. 1493.  -     }
  3916. 1494.  -     slideToggle(__cur.audioAlbums, 200, function() {
  3917. 1495.  -       if (from_pad) {
  3918. 1496.  -         Audio.updatePadFiltersHeight();
  3919. 1497.  -       } else {
  3920. 1498.  -         Audio.updateAlbumsFinish();
  3921. 1499.  -       }
  3922. 1500.  -     });
  3923. 1501.  -     toggleClass(icon, 'up', !down);
  3924. 1502.  -   },
  3925. 1503.  -
  3926. 1504.  -   addAudio: function(params, event) {
  3927. 1505.  -     if (cur.uploadBanned) {
  3928. 1506.  -       setTimeout(showFastBox({title: getLang('audio_no_upload_title'), bodyStyle: 'line-height: 160%;'}, getLang('audio_claims_no_upload')).hide, 5000);
  3929. 1507.  -       if (event) cancelEvent(event);
  3930. 1508.  -       return false;
  3931. 1509.  -     }
  3932. 1510.  -     showBox(Audio.address, extend(params || {}, {act: 'new_audio', gid: cur.gid}), {
  3933. 1511.  -       params: {width: '440px', bodyStyle: 'padding: 0px; position: relative;'}
  3934. 1512.  -     });
  3935. 1513.  -     if (event) cancelEvent(event);
  3936. 1514.  -     return false;
  3937. 1515.  -   },
  3938. 1516.  -
  3939. 1517.  -   mixAllAudios: function(opts) {
  3940. 1518.  -     opts = opts || {};
  3941. 1519.  -     var __cur = opts.from_pad ? window._pads && _pads.cur : window.cur,
  3942. 1520.  -         from_pad = !!opts.from_pad, mix = opts.mix, noShuffle = opts.noShuffle;
  3943. 1521.  -     var all_list = Audio.allAudios(from_pad), _a = window.audioPlayer, current = 0;
  3944. 1522.  -     if (!all_list) return;
  3945. 1523.  -     if (mix) {
  3946. 1524.  -       if (all_list[0] && all_list[0]._old_order !== undefined) return;
  3947. 1525.  -       for (var i = all_list.length; i; ) {
  3948. 1526.  -         var j = parseInt(Math.random() * i)
  3949. 1527.  -         var x = all_list[--i];
  3950. 1528.  -         all_list[i] = all_list[j];
  3951. 1529.  -         all_list[i]._old_order = all_list[i]._order;
  3952. 1530.  -         all_list[i]._order = i;
  3953. 1531.  -         if (currentAudioId() == all_list[i][0]+'_'+all_list[i][1]) {
  3954. 1532.  -           current = i;
  3955. 1533.  -         }
  3956. 1534.  -         all_list[j] = x;
  3957. 1535.  -       };
  3958. 1536.  -       if (current) {
  3959. 1537.  -         var x = all_list[current];
  3960. 1538.  -         all_list[current] = all_list[0];
  3961. 1539.  -         all_list[current]._order = current;
  3962. 1540.  -         all_list[0] = x;
  3963. 1541.  -         all_list[0]._order = 0;
  3964. 1542.  -       }
  3965. 1543.  -     } else {
  3966. 1544.  -       for (var i in all_list) {
  3967. 1545.  -         if (all_list[i]._old_order !== undefined) {
  3968. 1546.  -           all_list[i]._order = all_list[i]._old_order;
  3969. 1547.  -           delete all_list[i]._old_order;
  3970. 1548.  -         }
  3971. 1549.  -       };
  3972. 1550.  -     }
  3973. 1551.  -     if (!noShuffle) __cur.justShuffled = true;
  3974. 1552.  -   },
  3975. 1553.  -   mixAudios: function() {
  3976. 1554.  -     if (cur.curSection == 'recommendations') {
  3977. 1555.  -       Audio.loadRecommendations({update: 'remix'});
  3978. 1556.  -       return;
  3979. 1557.  -     }
  3980. 1558.  -     if (cur.curSection == 'popular') {
  3981. 1559.  -       Audio.loadPopular({update: 'remix'});
  3982. 1560.  -       return;
  3983. 1561.  -     }
  3984. 1562.  -     if (cur.silent) {
  3985. 1563.  -       cur.onSilentLoad = function() {
  3986. 1564.  -         Audio.mixAudios();
  3987. 1565.  -       };
  3988. 1566.  -       return;
  3989. 1567.  -     }
  3990. 1568.  -     var _a = window.audioPlayer;
  3991. 1569.  -     Audio.mixAllAudios({mix: _a && _a.shuffle});
  3992. 1570.  -     cur.ignoreEqual = true;
  3993. 1571.  -     if (cur.album_id) {
  3994. 1572.  -       this.loadAlbum({album: cur.album_id});
  3995. 1573.  -     } else {
  3996. 1574.  -       this.updateList();
  3997. 1575.  -     }
  3998. 1576.  -     cur.shuffled = _a && _a.shuffle;
  3999. 1577.  -   },
  4000. 1578.  -
  4001. 1579.  -   loadRecommendations: function(opts) {
  4002. 1580.  -     opts = opts || {};
  4003. 1581.  -     var __cur = opts.from_pad ? window._pads && _pads.cur : window.cur,
  4004. 1582.  -         from_pad = !!opts.from_pad, update = opts.update, audioId = opts.audioId;
  4005. 1583.  -     if (__cur.loadingRecs) return;
  4006. 1584.  -     if (update) {
  4007. 1585.  -       delete __cur.recsOffset;
  4008. 1586.  -       delete __cur.recommendIds;
  4009. 1587.  -       delete __cur.recommendAudios;
  4010. 1588.  -       delete __cur.preloadJSON;
  4011. 1589.  -     }
  4012. 1590.  -     if (audioId) {
  4013. 1591.  -       __cur.recsAudioId = audioId;
  4014. 1592.  -     } else if (update === true) {
  4015. 1593.  -       delete __cur.recsAudioId;
  4016. 1594.  -     }
  4017. 1595.  -     each(geByClass('audio_filter', __cur.albumFilters), function(i, e) {
  4018. 1596.  -       removeClass(e, 'selected');
  4019. 1597.  -     });
  4020. 1598.  -     if (__cur.searchStr && isVisible(__cur.searchInfoCont)) {
  4021. 1599.  -       hide(__cur.searchInfoCont);
  4022. 1600.  -     }
  4023. 1601.  -     if (from_pad && ge('pad_footer_text')) {
  4024. 1602.  -       ge('pad_footer_text').innerHTML = '';
  4025. 1603.  -     }
  4026. 1604.  -     var rec_filter = __cur.recFilter;
  4027. 1605.  -     addClass(rec_filter, 'selected');
  4028. 1606.  -     removeClass(__cur.albumFiltered, 'selected');
  4029. 1607.  -     hide(__cur.searchFilters, __cur.popularFilters);
  4030. 1608.  -     if (from_pad || __cur.oid == vk.id) {
  4031. 1609.  -       hide(__cur.audioFriends, __cur.searchInfoCont);
  4032. 1610.  -       Audio.hideAlbums({from_pad: from_pad});
  4033. 1611.  -     }
  4034. 1612.  -     if (from_pad && ge('pad_footer_text')) {
  4035. 1613.  -       ge('pad_footer_text').innerHTML = '';
  4036. 1614.  -     }
  4037. 1615.  -     removeClass(__cur.albumFiltered, 'club_shown');
  4038. 1616.  -     Audio.handleFilterPos();
  4039. 1617.  -     __cur.lastSection = __cur.curSection;
  4040. 1618.  -     __cur.curSection = 'recommendations';
  4041. 1619.  -     if (__cur.recsOffset === undefined) {
  4042. 1620.  -       __cur.recsOffset = 0;
  4043. 1621.  -     } else {
  4044. 1622.  -       addClass(__cur.showMore, 'loading');
  4045. 1623.  -     }
  4046. 1624.  -     if (__cur.recommendIds === undefined) __cur.recommendIds = [];
  4047. 1625.  -     if (__cur.recommendAudios === undefined) __cur.recommendAudios = [];
  4048. 1626.  -     if (__cur.recsCount === undefined) __cur.recsCount = 0;
  4049. 1627.  -     if (__cur.sPreload.innerHTML) {
  4050. 1628.  -       while (__cur.sPreload.firstChild) {
  4051. 1629.  -         var el = __cur.sPreload.firstChild;
  4052. 1630.  -         __cur.aContent.appendChild(el);
  4053. 1631.  -         __cur.recsCount++;
  4054. 1632.  -       }
  4055. 1633.  -       if (from_pad && window.Pads && Pads.updateHeight) {
  4056. 1634.  -         Pads.updateHeight();
  4057. 1635.  -       }
  4058. 1636.  -     }
  4059. 1637.  -     if (__cur.preloadJSON) {
  4060. 1638.  -       json = __cur.preloadJSON['all'];
  4061. 1639.  -       var cur_order = __cur.recsCount;
  4062. 1640.  -       for (var i in json) {
  4063. 1641.  -         var audio = json[i];
  4064. 1642.  -         audio._order = cur_order++;
  4065. 1643.  -         if (indexOf(__cur.recommendIds, audio[0]+"_"+audio[1]) == -1) {
  4066. 1644.  -           __cur.recommendIds.push(audio[0]+"_"+audio[1]);
  4067. 1645.  -           __cur.recommendAudios.push(audio);
  4068. 1646.  -         }
  4069. 1647.  -       }
  4070. 1648.  -       var aid = currentAudioId(), needs_update = __cur.recsOffset && (aid && __cur.recommendIds && indexOf(__cur.recommendIds, aid) != -1);
  4071. 1649.  -       audioPlayer.genPlaylist(__cur.recommendAudios, needs_update);
  4072. 1650.  -     }
  4073. 1651.  -     if (__cur.noRecommendations) {
  4074. 1652.  -       hide(__cur.showMore);
  4075. 1653.  -       delete __cur.noRecommendations;
  4076. 1654.  -       return;
  4077. 1655.  -     }
  4078. 1656.  -     if (opts.tt) {
  4079. 1657.  -       opts.tt.hide();
  4080. 1658.  -     }
  4081. 1659.  -     __cur.loadingRecs = true;
  4082. 1660.  -     __cur.lastAct = 'recommendations';
  4083. 1661.  -     var offset = __cur.recsOffset, query = {act: 'get_recommendations', id: __cur.id, offset: offset},
  4084. 1662.  -         needsUpdate = window.audioPlayer && audioPlayer.shuffle;
  4085. 1663.  -     if (from_pad) {
  4086. 1664.  -       query.from_pad = 1;
  4087. 1665.  -     }
  4088. 1666.  -     if (update == 'remix' || needsUpdate != __cur.recsRemix) {
  4089. 1667.  -       __cur.recsRemix = needsUpdate;
  4090. 1668.  -       query.remix = needsUpdate ? 1 : 0;
  4091. 1669.  -       var aid = currentAudioId();
  4092. 1670.  -       if (aid && window.audioPlaylist && audioPlaylist[aid] && audioPlaylist.address && audioPlaylist.address.indexOf('act=recommendations') > 0) {
  4093. 1671.  -         var a = audioPlaylist[aid];
  4094. 1672.  -         if (a[10]) query.current = a[10]+' '+aid;
  4095. 1673.  -       }
  4096. 1674.  -     }
  4097. 1675.  -     if (__cur.recsAudioId) {
  4098. 1676.  -       query.audio_id = __cur.recsAudioId;
  4099. 1677.  -     }
  4100. 1678.  -     ajax.post(Audio.address, query, {
  4101. 1679.  -       onDone: function(rows, preload, json, preload_json, options, ownersRows) {
  4102. 1680.  -         delete __cur.loadingRecs;
  4103. 1681.  -         if (__cur.lastAct != 'recommendations') return;
  4104. 1682.  -         if (!offset) {
  4105. 1683.  -           if (ownersRows) {
  4106. 1684.  -             val((from_pad ? 'pad_' : '') + 'audio_popular_owners_rows', ownersRows);
  4107. 1685.  -             show(__cur.popularOwners);
  4108. 1686.  -           } else {
  4109. 1687.  -             hide(__cur.popularOwners);
  4110. 1688.  -           }
  4111. 1689.  -         }
  4112. 1690.  -         if (from_pad) {
  4113. 1691.  -           Audio.updatePadFiltersHeight();
  4114. 1692.  -         }
  4115. 1693.  -         if (options.recsCount === 0 && offset) {
  4116. 1694.  -           __cur.noRecommendations = true;
  4117. 1695.  -           delete options.recsOffset;
  4118. 1696.  -         }
  4119. 1697.  -         if (json) {
  4120. 1698.  -           json = eval('('+json+')');
  4121. 1699.  -           json = json['all'];
  4122. 1700.  -           var cur_order = __cur.recsCount;
  4123. 1701.  -           for (var i in json) {
  4124. 1702.  -             var audio = json[i];
  4125. 1703.  -             audio._order = cur_order++;
  4126. 1704.  -             if (indexOf(__cur.recommendIds, audio[0]+"_"+audio[1]) == -1) {
  4127. 1705.  -               __cur.recommendIds.push(audio[0]+"_"+audio[1]);
  4128. 1706.  -               __cur.recommendAudios.push(audio);
  4129. 1707.  -             }
  4130. 1708.  -           }
  4131. 1709.  -           var aid = currentAudioId(), needs_update = query.offset && (aid && __cur.recommendIds && indexOf(__cur.recommendIds, aid) != -1);
  4132. 1710.  -           audioPlayer.genPlaylist(__cur.recommendAudios, needs_update);
  4133. 1711.  -           if (query.audio_id) {
  4134. 1712.  -             cur.nextPlaylist.rec = 1;
  4135. 1713.  -           }
  4136. 1714.  -         }
  4137. 1715.  -         removeClass(__cur.showMore, 'loading');
  4138. 1716.  -         if (offset) {
  4139. 1717.  -           delete options.recsCount;
  4140. 1718.  -         }
  4141. 1719.  -         if (options) extend(__cur, options);
  4142. 1720.  -         if (!offset) {
  4143. 1721.  -           __cur.aContent.innerHTML = rows;
  4144. 1722.  -           if (from_pad && window.Pads && Pads.updateHeight) {
  4145. 1723.  -             Pads.updateHeight();
  4146. 1724.  -           }
  4147. 1725.  -         }
  4148. 1726.  -
  4149. 1727.  -         __cur.preloadJSON = preload_json ? eval('('+preload_json+')') : false;
  4150. 1728.  -         __cur.sPreload.innerHTML = '';
  4151. 1729.  -         var au = ce('div', {innerHTML: preload});
  4152. 1730.  -         while (au.firstChild) {
  4153. 1731.  -           if (!ge(au.firstChild.id)) {
  4154. 1732.  -             var el = au.firstChild;
  4155. 1733.  -             __cur.sPreload.appendChild(el);
  4156. 1734.  -           } else {
  4157. 1735.  -             au.removeChild(au.firstChild);
  4158. 1736.  -           }
  4159. 1737.  -         }
  4160. 1738.  -
  4161. 1739.  -         if (__cur.recsCount && !query.audio_id) {
  4162. 1740.  -           show(__cur.showMore);
  4163. 1741.  -         } else {
  4164. 1742.  -           hide(__cur.showMore);
  4165. 1743.  -         }
  4166. 1744.  -         if (query.remix) {
  4167. 1745.  -           __cur.justShuffled = true;
  4168. 1746.  -         }
  4169. 1747.  -         Audio.changeHTitle({from_pad: from_pad});
  4170. 1748.  -         val(__cur.aSearch, '');
  4171. 1749.  -         removeClass(__cur.clearSearch, 'shown');
  4172. 1750.  -         __cur.searchStr = '';
  4173. 1751.  -         __cur.album_id = 0;
  4174. 1752.  -         Audio.hideSearchResults(from_pad);
  4175. 1753.  -         hide(__cur.sShowMore);
  4176. 1754.  -         if (!offset) {
  4177. 1755.  -           Audio.scrollToTop(from_pad);
  4178. 1756.  -         }
  4179. 1757.  -         if (!from_pad) {
  4180. 1758.  -           delete nav.objLoc.q;
  4181. 1759.  -           delete nav.objLoc.owner;
  4182. 1760.  -           delete nav.objLoc.friend;
  4183. 1761.  -           delete nav.objLoc.album_id;
  4184. 1762.  -           delete nav.objLoc.club;
  4185. 1763.  -           delete nav.objLoc.genre;
  4186. 1764.  -           delete __cur._back;
  4187. 1765.  -           extend(nav.objLoc, {act: 'recommendations'});
  4188. 1766.  -           if (query.audio_id) {
  4189. 1767.  -             extend(nav.objLoc, {audio_id: query.audio_id});
  4190. 1768.  -           } else {
  4191. 1769.  -             delete nav.objLoc.audio_id;
  4192. 1770.  -           }
  4193. 1771.  -           nav.setLoc(nav.objLoc);
  4194. 1772.  -         }
  4195. 1773.  -         var _a = window.audioPlayer;
  4196. 1774.  -         if (_a && _a.showCurrentTrack) _a.showCurrentTrack();
  4197. 1775.  -         if (!from_pad) {
  4198. 1776.  -           Audio.loadCurrentPlaylist();
  4199. 1777.  -         }
  4200. 1778.  -       },
  4201. 1779.  -       onFail: function(msg) {
  4202. 1780.  -         delete __cur.loadingRecs;
  4203. 1781.  -         __cur.curSection = __cur.lastSection;
  4204. 1782.  -         removeClass(__cur.recFilter, 'selected');
  4205. 1783.  -         setTimeout(showFastBox(getLang('global_error'), msg).hide, 3000);
  4206. 1784.  -         return true;
  4207. 1785.  -       },
  4208. 1786.  -       showProgress: function () {
  4209. 1787.  -         addClass(rec_filter, 'loading');
  4210. 1788.  -       },
  4211. 1789.  -       hideProgress: function () {
  4212. 1790.  -         removeClass(rec_filter, 'loading');
  4213. 1791.  -       }
  4214. 1792.  -     });
  4215. 1793.  -     __cur.recsOffset += offset ? 50 : 100;
  4216. 1794.  -   },
  4217. 1795.  -
  4218. 1796.  -   loadPopular: function(opts) {
  4219. 1797.  -     opts = opts || {};
  4220. 1798.  -     var __cur = opts.from_pad ? window._pads && _pads.cur : window.cur,
  4221. 1799.  -         from_pad = !!opts.from_pad, update = opts.update, genre = opts.genre;
  4222. 1800.  -     if (__cur.silent) {
  4223. 1801.  -       __cur.onSilentLoad = function() {
  4224. 1802.  -         Audio.loadPopular(opts);
  4225. 1803.  -       };
  4226. 1804.  -       return;
  4227. 1805.  -     }
  4228. 1806.  -     if (__cur.loadingPopular) return;
  4229. 1807.  -     if (__cur.popularAudios === undefined) {
  4230. 1808.  -       __cur.popularAudios = [];
  4231. 1809.  -     }
  4232. 1810.  -     if (update) {
  4233. 1811.  -       delete __cur.popularOffset;
  4234. 1812.  -       delete __cur.popularIds;
  4235. 1813.  -       delete __cur.popularAudios[genre];
  4236. 1814.  -       delete __cur.preloadJSON;
  4237. 1815.  -       if (genre !== undefined) {
  4238. 1816.  -         __cur.genre = genre;
  4239. 1817.  -       }
  4240. 1818.  -     }
  4241. 1819.  -     each(geByClass('audio_filter', __cur.albumFilters), function(i, e) {
  4242. 1820.  -       removeClass(e, 'selected');
  4243. 1821.  -     });
  4244. 1822.  -     if (__cur.searchStr && isVisible(__cur.searchInfoCont)) {
  4245. 1823.  -       hide(__cur.searchInfoCont);
  4246. 1824.  -     }
  4247. 1825.  -     if (from_pad && ge('pad_footer_text')) {
  4248. 1826.  -       ge('pad_footer_text').innerHTML = '';
  4249. 1827.  -     }
  4250. 1828.  -     var genre_filter = false;
  4251. 1829.  -     if (__cur.genre) {
  4252. 1830.  -       var prevGenre = geByClass1('selected', __cur.popularGenres);
  4253. 1831.  -       if (prevGenre) {
  4254. 1832.  -         removeClass(prevGenre, 'selected');
  4255. 1833.  -       }
  4256. 1834.  -
  4257. 1835.  -       genre_filter = ge((from_pad ? 'pad_' : '') + 'audio_genre_'+__cur.genre);
  4258. 1836.  -       if (genre_filter) {
  4259. 1837.  -         addClass(genre_filter, 'selected');
  4260. 1838.  -       } else {
  4261. 1839.  -         __cur.genre = 0;
  4262. 1840.  -       }
  4263. 1841.  -     }
  4264. 1842.  -     var pop_filter = __cur.topFilter;
  4265. 1843.  -     addClass(pop_filter, 'selected');
  4266. 1844.  -     removeClass(__cur.albumFiltered, 'selected');
  4267. 1845.  -     toggle(__cur.audioFriends, false);
  4268. 1846.  -     hide(__cur.searchInfoCont);
  4269. 1847.  -     if (__cur.popularFilters) {
  4270. 1848.  -       show(__cur.popularFilters);
  4271. 1849.  -       Audio.hideAlbums({from_pad: from_pad});
  4272. 1850.  -     } else {
  4273. 1851.  -       Audio.showAlbums({from_pad: from_pad});
  4274. 1852.  -     }
  4275. 1853.  -     removeClass(__cur.albumFiltered, 'club_shown');
  4276. 1854.  -     hide(__cur.searchFilters, __cur.popularOwners);
  4277. 1855.  -     Audio.handleFilterPos();
  4278. 1856.  -     __cur.curSection = 'popular';
  4279. 1857.  -     if (__cur.popularOffset === undefined) {
  4280. 1858.  -       __cur.popularOffset = 0;
  4281. 1859.  -     } else {
  4282. 1860.  -       addClass(__cur.showMore, 'loading');
  4283. 1861.  -     }
  4284. 1862.  -     if (__cur.popularIds === undefined) __cur.popularIds = [];
  4285. 1863.  -     if (__cur.popularAudios[genre] === undefined) __cur.popularAudios[genre] = [];
  4286. 1864.  -     if (__cur.popularCount === undefined) __cur.popularCount = 0;
  4287. 1865.  -     if (__cur.sPreload.innerHTML) {
  4288. 1866.  -       while (__cur.sPreload.firstChild) {
  4289. 1867.  -         var el = __cur.sPreload.firstChild;
  4290. 1868.  -         __cur.aContent.appendChild(el);
  4291. 1869.  -         __cur.popularCount++;
  4292. 1870.  -       }
  4293. 1871.  -       if (from_pad && window.Pads && Pads.updateHeight) {
  4294. 1872.  -         Pads.updateHeight();
  4295. 1873.  -       }
  4296. 1874.  -     }
  4297. 1875.  -     if (__cur.preloadJSON) {
  4298. 1876.  -       json = __cur.preloadJSON['all'];
  4299. 1877.  -       var cur_order = __cur.popularCount;
  4300. 1878.  -       for (var i in json) {
  4301. 1879.  -         var audio = json[i];
  4302. 1880.  -         audio._order = cur_order++;
  4303. 1881.  -         if (indexOf(__cur.popularIds, audio[0]+"_"+audio[1]) == -1) {
  4304. 1882.  -           __cur.popularIds.push(audio[0]+"_"+audio[1]);
  4305. 1883.  -           __cur.popularAudios[genre].push(audio);
  4306. 1884.  -         }
  4307. 1885.  -       }
  4308. 1886.  -       var aid = currentAudioId(), needs_update = __cur.popularOffset && (aid && __cur.popularIds && indexOf(__cur.popularIds, aid) != -1);
  4309. 1887.  -       audioPlayer.genPlaylist(__cur.popularAudios[genre], needs_update);
  4310. 1888.  -     }
  4311. 1889.  -     if (__cur.noPopular) {
  4312. 1890.  -       hide(__cur.showMore);
  4313. 1891.  -       delete __cur.noPopular;
  4314. 1892.  -       return;
  4315. 1893.  -     }
  4316. 1894.  -     __cur.loadingPopular = true;
  4317. 1895.  -     __cur.lastAct = 'popular';
  4318. 1896.  -     var offset = __cur.popularOffset, query = {act: 'get_popular', offset: offset},
  4319. 1897.  -         needsUpdate = window.audioPlayer && audioPlayer.shuffle;
  4320. 1898.  -     if (from_pad) {
  4321. 1899.  -       query.from_pad = 1;
  4322. 1900.  -     }
  4323. 1901.  -     if (nav.objLoc.update)  {
  4324. 1902.  -       query.update = 1;
  4325. 1903.  -     }
  4326. 1904.  -     if (needsUpdate && !offset) query.offset = -1;
  4327. 1905.  -     if (update == 'remix' || needsUpdate != __cur.popRemix) {
  4328. 1906.  -       __cur.popRemix = needsUpdate;
  4329. 1907.  -       query.remix = needsUpdate ? 1 : 0;
  4330. 1908.  -       var aid = currentAudioId();
  4331. 1909.  -       if (aid && window.audioPlaylist && audioPlaylist[aid] && audioPlaylist.address && audioPlaylist.address.indexOf('act=popular') > 0) {
  4332. 1910.  -         query.current = aid;
  4333. 1911.  -       }
  4334. 1912.  -     }
  4335. 1913.  -     if (__cur.topType !== undefined) {
  4336. 1914.  -       query.type = __cur.topType;
  4337. 1915.  -       delete __cur.topType;
  4338. 1916.  -     }
  4339. 1917.  -     if (__cur.genre) {
  4340. 1918.  -       query.genre = __cur.genre;
  4341. 1919.  -     }
  4342. 1920.  -     ajax.post(Audio.address, query, {
  4343. 1921.  -       onDone: function(rows, preload, json, preload_json, options, genres) {
  4344. 1922.  -         delete __cur.loadingPopular;
  4345. 1923.  -         if (__cur.lastAct != 'popular') return;
  4346. 1924.  -         if (options.popularCount === 0 && offset) {
  4347. 1925.  -           __cur.noPopular = true;
  4348. 1926.  -           delete options.popularOffset;
  4349. 1927.  -         }
  4350. 1928.  -         if (json) {
  4351. 1929.  -           json = eval('('+json+')');
  4352. 1930.  -           json = json['all'];
  4353. 1931.  -           var cur_order = __cur.popularCount;
  4354. 1932.  -           for (var i in json) {
  4355. 1933.  -             var audio = json[i];
  4356. 1934.  -             audio._order = cur_order++;
  4357. 1935.  -             if (indexOf(__cur.popularIds, audio[0]+"_"+audio[1]) == -1) {
  4358. 1936.  -               __cur.popularIds.push(audio[0]+"_"+audio[1]);
  4359. 1937.  -               __cur.popularAudios[genre].push(audio);
  4360. 1938.  -             }
  4361. 1939.  -           }
  4362. 1940.  -           var aid = currentAudioId(), needs_update = query.offset && (aid && __cur.popularIds && indexOf(__cur.popularIds, aid) != -1);
  4363. 1941.  -           audioPlayer.genPlaylist(__cur.popularAudios[genre], needs_update);
  4364. 1942.  -         }
  4365. 1943.  -         removeClass(__cur.showMore, 'loading');
  4366. 1944.  -         if (offset) {
  4367. 1945.  -           delete options.popularCount;
  4368. 1946.  -         }
  4369. 1947.  -         if (options) extend(__cur, options);
  4370. 1948.  -         if (!offset) {
  4371. 1949.  -           __cur.aContent.innerHTML = rows;
  4372. 1950.  -           if (from_pad && window.Pads && Pads.updateHeight) {
  4373. 1951.  -             Pads.updateHeight();
  4374. 1952.  -           }
  4375. 1953.  -           Audio.scrollToTop(from_pad);
  4376. 1954.  -         }
  4377. 1955.  -
  4378. 1956.  -         if (preload_json) {
  4379. 1957.  -           __cur.preloadJSON = eval('('+preload_json+')');
  4380. 1958.  -         } else {
  4381. 1959.  -           __cur.preloadJSON = {};
  4382. 1960.  -         }
  4383. 1961.  -         __cur.sPreload.innerHTML = '';
  4384. 1962.  -         var au = ce('div', {innerHTML: preload});
  4385. 1963.  -         while (au.firstChild) {
  4386. 1964.  -           if (!ge(au.firstChild.id)) {
  4387. 1965.  -             var el = au.firstChild;
  4388. 1966.  -             __cur.sPreload.appendChild(el);
  4389. 1967.  -           } else {
  4390. 1968.  -             au.removeChild(au.firstChild);
  4391. 1969.  -           }
  4392. 1970.  -         }
  4393. 1971.  -
  4394. 1972.  -         if (__cur.popularCount) {
  4395. 1973.  -           show(__cur.showMore);
  4396. 1974.  -         } else {
  4397. 1975.  -           hide(__cur.showMore);
  4398. 1976.  -         }
  4399. 1977.  -         if (update == 'remix') {
  4400. 1978.  -           __cur.justShuffled = true;
  4401. 1979.  -         }
  4402. 1980.  -         if (genres) {
  4403. 1981.  -           __cur.popularGenres.innerHTML = genres;
  4404. 1982.  -         }
  4405. 1983.  -         Audio.changeHTitle({from_pad: from_pad});
  4406. 1984.  -         val(__cur.aSearch, '');
  4407. 1985.  -         removeClass(__cur.clearSearch, 'shown');
  4408. 1986.  -         __cur.searchStr = '';
  4409. 1987.  -         __cur.album_id = 0;
  4410. 1988.  -         Audio.hideSearchResults(from_pad);
  4411. 1989.  -         hide(__cur.sShowMore);
  4412. 1990.  -         if (!from_pad) {
  4413. 1991.  -           delete nav.objLoc.q;
  4414. 1992.  -           delete nav.objLoc.owner;
  4415. 1993.  -           delete nav.objLoc.friend;
  4416. 1994.  -           delete nav.objLoc.album_id;
  4417. 1995.  -           delete nav.objLoc.club;
  4418. 1996.  -           delete nav.objLoc.genre;
  4419. 1997.  -           delete nav.objLoc.audio_id;
  4420. 1998.  -           nav.objLoc.act = 'popular';
  4421. 1999.  -           if (__cur.genre) {
  4422. 2000.  -             nav.objLoc.genre = __cur.genre;
  4423. 2001.  -           } else {
  4424. 2002.  -             delete nav.objLoc.genre;
  4425. 2003.  -           }
  4426. 2004.  -           nav.setLoc(nav.objLoc);
  4427. 2005.  -         }
  4428. 2006.  -         var _a = window.audioPlayer;
  4429. 2007.  -         if (_a && _a.showCurrentTrack) _a.showCurrentTrack();
  4430. 2008.  -         if (window.tooltips) {
  4431. 2009.  -           tooltips.destroyAll();
  4432. 2010.  -         }
  4433. 2011.  -         if (!from_pad) {
  4434. 2012.  -           Audio.loadCurrentPlaylist();
  4435. 2013.  -         }
  4436. 2014.  -         if (options.infoJS) {
  4437. 2015.  -           eval('(function(){' + options.infoJS + ';})()');
  4438. 2016.  -         }
  4439. 2017.  -       },
  4440. 2018.  -       showProgress: function () {
  4441. 2019.  -         addClass(genre_filter || pop_filter, 'loading');
  4442. 2020.  -       },
  4443. 2021.  -       hideProgress: function () {
  4444. 2022.  -         removeClass(genre_filter || pop_filter, 'loading');
  4445. 2023.  -       }
  4446. 2024.  -     });
  4447. 2025.  -     __cur.popularOffset += offset ? 50 : 100;
  4448. 2026.  -   },
  4449. 2027.  -
  4450. 2028.  -   loadFeed: function(opts) {
  4451. 2029.  -     opts = opts || {};
  4452. 2030.  -     var __cur = opts.from_pad ? window._pads && _pads.cur : window.cur,
  4453. 2031.  -         from_pad = !!opts.from_pad, update = opts.update;
  4454. 2032.  -     if (__cur.silent) {
  4455. 2033.  -       __cur.onSilentLoad = function() {
  4456. 2034.  -         Audio.loadFeed(opts);
  4457. 2035.  -       };
  4458. 2036.  -       return;
  4459. 2037.  -     }
  4460. 2038.  -     if (__cur.isFeedLoading) return;
  4461. 2039.  -     __cur.isFeedLoading = true;
  4462. 2040.  -     if (__cur.audiosList && __cur.audiosList['all'] && __cur.allAudiosIndex != 'all') {
  4463. 2041.  -       __cur.allAudiosIndex = 'all';
  4464. 2042.  -       this.indexAll({from_pad: from_pad});
  4465. 2043.  -       var curEl = geByClass1('current', __cur.friendsList);
  4466. 2044.  -       if (curEl) removeClass(curEl, 'current');
  4467. 2045.  -     }
  4468. 2046.  -     if (update) {
  4469. 2047.  -       delete __cur.feedFrom;
  4470. 2048.  -       delete __cur.feedOffset;
  4471. 2049.  -       delete __cur.feedIds;
  4472. 2050.  -       delete __cur.feedAudios;
  4473. 2051.  -       if (update === 'reload') {
  4474. 2052.  -         var params = {act: 'feed', part: 1, update: 1}, q = Audio.address + '#' + ajx2q(params);
  4475. 2053.  -         delete window.ajaxCache[q];
  4476. 2054.  -       }
  4477. 2055.  -     }
  4478. 2056.  -     each(geByClass('audio_filter', __cur.albumFilters), function(i, e) {
  4479. 2057.  -       removeClass(e, 'selected');
  4480. 2058.  -     });
  4481. 2059.  -     if (__cur.searchStr && isVisible(__cur.searchInfoCont)) {
  4482. 2060.  -       hide(__cur.searchInfoCont);
  4483. 2061.  -     }
  4484. 2062.  -     if (from_pad && ge('pad_footer_text')) {
  4485. 2063.  -       ge('pad_footer_text').innerHTML = '';
  4486. 2064.  -     }
  4487. 2065.  -     addClass(__cur.feedFilter, 'selected');
  4488. 2066.  -     removeClass(__cur.albumFiltered, 'selected');
  4489. 2067.  -     hide(__cur.searchFilters, __cur.popularFilters, __cur.popularOwners);
  4490. 2068.  -     if (from_pad || __cur.oid == vk.id) {
  4491. 2069.  -       show(__cur.audioFriends);
  4492. 2070.  -       hide(__cur.searchInfoCont);
  4493. 2071.  -       Audio.hideAlbums({from_pad: from_pad});
  4494. 2072.  -     }
  4495. 2073.  -     removeClass(__cur.albumFiltered, 'club_shown');
  4496. 2074.  -     Audio.handleFilterPos();
  4497. 2075.  -     __cur.lastSection = __cur.curSection;
  4498. 2076.  -     __cur.curSection = 'feed';
  4499. 2077.  -     if (!update) {
  4500. 2078.  -       addClass(__cur.showMore, 'loading');
  4501. 2079.  -     }
  4502. 2080.  -     __cur.lastAct = 'feed';
  4503. 2081.  -     var query = {act: 'feed', offset: __cur.feedOffset, from: __cur.feedFrom, part: 1, update: update ? 1 : ''};
  4504. 2082.  -     if (from_pad) {
  4505. 2083.  -       query.from_pad = 1;
  4506. 2084.  -     }
  4507. 2085.  -     ajax.post(Audio.address, query, {
  4508. 2086.  -       onDone: function (rows, script) {
  4509. 2087.  -         if (__cur.lastAct != 'feed') return;
  4510. 2088.  -         if (rows) {
  4511. 2089.  -           if (update) {
  4512. 2090.  -             __cur.aContent.innerHTML = rows;
  4513. 2091.  -           } else {
  4514. 2092.  -             var au = ce('div'), par = geByClass1('wall_module', __cur.aContent), row;
  4515. 2093.  -             au.innerHTML = rows;
  4516. 2094.  -             if (par && update) {
  4517. 2095.  -               par.innerHTML = '';
  4518. 2096.  -             }
  4519. 2097.  -             while (row = au.firstChild) {
  4520. 2098.  -               if (!row.id || ge(row.id)) {
  4521. 2099.  -                 au.removeChild(row);
  4522. 2100.  -                 continue;
  4523. 2101.  -               }
  4524. 2102.  -               if (par) {
  4525. 2103.  -                 par.appendChild(row);
  4526. 2104.  -               }
  4527. 2105.  -             }
  4528. 2106.  -           }
  4529. 2107.  -         } else {
  4530. 2108.  -           hide(__cur.showMore);
  4531. 2109.  -         }
  4532. 2110.  -         if (from_pad && window.Pads && Pads.updateHeight) {
  4533. 2111.  -           Pads.updateHeight();
  4534. 2112.  -         }
  4535. 2113.  -         if (script) {
  4536. 2114.  -           eval(script);
  4537. 2115.  -         }
  4538. 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);
  4539. 2117.  -         audioPlayer.genPlaylist(__cur.feedAudios, needs_update);
  4540. 2118.  -         removeClass(__cur.showMore, 'loading');
  4541. 2119.  -         Audio.changeHTitle({from_pad: from_pad});
  4542. 2120.  -         val(__cur.aSearch, '');
  4543. 2121.  -         removeClass(__cur.clearSearch, 'shown');
  4544. 2122.  -         __cur.searchStr = '';
  4545. 2123.  -         __cur.album_id = 0;
  4546. 2124.  -         Audio.hideSearchResults(from_pad);
  4547. 2125.  -         hide(__cur.sShowMore);
  4548. 2126.  -         if (update) {
  4549. 2127.  -           Audio.scrollToTop(from_pad);
  4550. 2128.  -         }
  4551. 2129.  -         if (!from_pad) {
  4552. 2130.  -           delete nav.objLoc.q;
  4553. 2131.  -           delete nav.objLoc.owner;
  4554. 2132.  -           delete nav.objLoc.friend;
  4555. 2133.  -           delete nav.objLoc.album_id;
  4556. 2134.  -           delete nav.objLoc.club;
  4557. 2135.  -           delete nav.objLoc.genre;
  4558. 2136.  -           delete nav.objLoc.audio_id;
  4559. 2137.  -           delete __cur._back;
  4560. 2138.  -           extend(nav.objLoc, {act: 'feed'});
  4561. 2139.  -           nav.setLoc(nav.objLoc);
  4562. 2140.  -         }
  4563. 2141.  -         var _a = window.audioPlayer;
  4564. 2142.  -         if (_a && _a.showCurrentTrack) _a.showCurrentTrack();
  4565. 2143.  -       },
  4566. 2144.  -       showProgress: function () {
  4567. 2145.  -         __cur.isFeedLoading = true;
  4568. 2146.  -         addClass(__cur.feedFilter, 'loading');
  4569. 2147.  -       },
  4570. 2148.  -       hideProgress: function () {
  4571. 2149.  -         __cur.isFeedLoading = false;
  4572. 2150.  -         removeClass(__cur.feedFilter, 'loading');
  4573. 2151.  -       },
  4574. 2152.  -       cache: 1
  4575. 2153.  -     });
  4576. 2154.  -   },
  4577. 2155.  -
  4578. 2156.  -   loadCurrentPlaylist: function() {
  4579. 2157.  -     if (!window.Pads || !Pads.showAudios || !window._pads || _pads.shown != 'mus') {
  4580. 2158.  -       return;
  4581. 2159.  -     }
  4582. 2160.  -     var __cur = _pads.cur;
  4583. 2161.  -     __cur.aContent.innerHTML = '';
  4584. 2162.  -
  4585. 2163.  -     each(geByClass('audio_filter', __cur.albumFilters), function(i, e) {
  4586. 2164.  -       removeClass(e, 'selected');
  4587. 2165.  -     });
  4588. 2166.  -     removeClass(__cur.albumFiltered, 'selected');
  4589. 2167.  -     addClass(__cur.currentFilter, 'selected');
  4590. 2168.  -     hide(__cur.popularFilters, __cur.popularOwners, __cur.searchFilters, __cur.searchInfoCont);
  4591. 2169.  -     show(__cur.audioFriends, __cur.showMore, __cur.currentFilter);
  4592. 2170.  -     Audio.hideAlbums({from_pad: true});
  4593. 2171.  -
  4594. 2172.  -     val(__cur.aSearch, '');
  4595. 2173.  -     removeClass(__cur.clearSearch, 'shown');
  4596. 2174.  -     __cur.lastSection = __cur.curSection;
  4597. 2175.  -     __cur.lastAct = __cur.searchStr = __cur.curSection = '';
  4598. 2176.  -     __cur.album_id = 0;
  4599. 2177.  -     Audio.hideSearchResults(true);
  4600. 2178.  -
  4601. 2179.  -     Pads.showAudios();
  4602. 2180.  -   },
  4603. 2181.  -
  4604. 2182.  -   reorderPlaylist: function(aid, before_id, after_id) {
  4605. 2183.  -     each([window.audioPlaylist, cur.nextPlaylist], function(i, e) {
  4606. 2184.  -       var list = e;
  4607. 2185.  -       if (before_id && !after_id && list && list[before_id]) {
  4608. 2186.  -         after_id = list[before_id]._prev;
  4609. 2187.  -       }
  4610. 2188.  -       if (list && list[aid] && after_id && list[after_id] && after_id != aid) {
  4611. 2189.  -         var next_id = list[aid]._next, prev_id = list[aid]._prev;
  4612. 2190.  -         if (next_id != aid) {
  4613. 2191.  -           list[next_id]._prev = prev_id;
  4614. 2192.  -           list[prev_id]._next = next_id;
  4615. 2193.  -           list[aid]._prev = after_id;
  4616. 2194.  -           list[aid]._next = list[after_id]._next;
  4617. 2195.  -           list[after_id]._next = list[list[after_id]._next]._prev = aid;
  4618. 2196.  -         }
  4619. 2197.  -       }
  4620. 2198.  -     });
  4621. 2199.  -     var plist = ls.get('pad_playlist');
  4622. 2200.  -     if (plist && plist[aid] && after_id && plist[after_id] && after_id != aid && window.audioPlayer) {
  4623. 2201.  -       audioPlayer.setPadPlaylist();
  4624. 2202.  -     }
  4625. 2203.  -   },
  4626. 2204.  -
  4627. 2205.  -   removeFromPlaylist: function(aid) {
  4628. 2206.  -     each([window.audioPlaylist, cur.nextPlaylist], function(i, e) {
  4629. 2207.  -       var list = e;
  4630. 2208.  -       if (list && list[aid]) {
  4631. 2209.  -         var next_id = list[aid]._next, prev_id = list[aid]._prev;
  4632. 2210.  -         if (next_id != aid) {
  4633. 2211.  -           // delete list[aid];
  4634. 2212.  -           list[next_id]._prev = prev_id;
  4635. 2213.  -           list[prev_id]._next = next_id;
  4636. 2214.  -         }
  4637. 2215.  -       }
  4638. 2216.  -     });
  4639. 2217.  -     var plist = ls.get('pad_playlist');
  4640. 2218.  -     if (plist && plist[aid] && window.audioPlayer) {
  4641. 2219.  -       audioPlayer.setPadPlaylist();
  4642. 2220.  -     }
  4643. 2221.  -   },
  4644. 2222.  -
  4645. 2223.  -   backToPlaylist: function(aid) {
  4646. 2224.  -     each([window.audioPlaylist, cur.nextPlaylist], function(i, e) {
  4647. 2225.  -       var list = e;
  4648. 2226.  -       if (list && list[aid]) {
  4649. 2227.  -         var next_id = list[aid]._next, prev_id = list[aid]._prev;
  4650. 2228.  -         if (next_id != aid) {
  4651. 2229.  -           list[next_id]._prev = list[prev_id]._next = aid;
  4652. 2230.  -         }
  4653. 2231.  -       }
  4654. 2232.  -     });
  4655. 2233.  -     var plist = ls.get('pad_playlist');
  4656. 2234.  -     if (plist && plist[aid] && window.audioPlayer) {
  4657. 2235.  -       audioPlayer.setPadPlaylist();
  4658. 2236.  -     }
  4659. 2237.  -   },
  4660. 2238.  -
  4661. 2239.  -   hideRecommendation: function(aid, q, hash, event) {
  4662. 2240.  -     if (window.audioPlayer && currentAudioId() == aid) {
  4663. 2241.  -       audioPlayer.nextTrack(true);
  4664. 2242.  -     }
  4665. 2243.  -     var recRow = ge('audio'+aid);
  4666. 2244.  -     if (recRow) {
  4667. 2245.  -       if (window.tooltips) {
  4668. 2246.  -         tooltips.hide(ge('remove'+aid))
  4669. 2247.  -       }
  4670. 2248.  -       slideUp(recRow, 200, function() {
  4671. 2249.  -         recRow.parentNode.removeChild(recRow);
  4672. 2250.  -         Audio.removeFromPlaylist(aid);
  4673. 2251.  -         cur.recsCount--;
  4674. 2252.  -         Audio.changeHTitle();
  4675. 2253.  -       });
  4676. 2254.  -     }
  4677. 2255.  -     ajax.post(Audio.address, {act: 'hide_recommendation', q: q, hash: hash});
  4678. 2256.  -     if (event) cancelEvent(event);
  4679. 2257.  -     return false;
  4680. 2258.  -   },
  4681. 2259.  -
  4682. 2260.  -   _animDelX: function(el, opacity, set_active) {
  4683. 2261.  -     if (!el) return;
  4684. 2262.  -     if (set_active !== undefined) {
  4685. 2263.  -       el.active = set_active;
  4686. 2264.  -     } else if (el.active) {
  4687. 2265.  -       return;
  4688. 2266.  -     }
  4689. 2267.  -     animate(el, {opacity: opacity}, 200);
  4690. 2268.  -   },
  4691. 2269.  -
  4692. 2270.  -   rowActive: function(el, tt, sh) {
  4693. 2271.  -     Audio._animDelX(el, 1, 1);
  4694. 2272.  -     if (tt) showTooltip(el, {text: tt, showdt: 0, black: 1, shift: (sh ? sh : [12, 4, 0])});
  4695. 2273.  -   },
  4696. 2274.  -   rowInactive: function(el, light) {
  4697. 2275.  -     var opacity = light ? 0.6 : 0.4;
  4698. 2276.  -     Audio._animDelX(el, opacity, 0);
  4699. 2277.  -   },
  4700. 2278.  -
  4701. 2279.  -   selectFriend: function(opts, ev) {
  4702. 2280.  -     opts = opts || {};
  4703. 2281.  -     var __cur = opts.from_pad ? window._pads && _pads.cur : window.cur,
  4704. 2282.  -         from_pad = !!opts.from_pad, id = opts.id;
  4705. 2283.  -     if (__cur.skipSelectFriend) {
  4706. 2284.  -       __cur.skipSelectFriend = false;
  4707. 2285.  -       return;
  4708. 2286.  -     }
  4709. 2287.  -     each(geByTag('div', __cur.audioFriends), function(i, e) {
  4710. 2288.  -       removeClass(e, 'current');
  4711. 2289.  -     });
  4712. 2290.  -     addClass(ge((from_pad ? 'pad_' : '') + 'audio_friend' + id), 'current');
  4713. 2291.  -     addClass(ge((from_pad ? 'pad_' : '') + 'album0'), 'loading');
  4714. 2292.  -     each(geByClass('audio_filter', __cur.albumFilters), function(i, e) {
  4715. 2293.  -       removeClass(e, 'selected');
  4716. 2294.  -     });
  4717. 2295.  -     Audio.loadFriendsAudios({id: id, index: 'friend' + id, from_pad: from_pad});
  4718. 2296.  -     if (id && (__cur.oid == vk.id || from_pad)) {
  4719. 2297.  -       ajax.post(Audio.address, {act: 'list_stats', owner: id});
  4720. 2298.  -     }
  4721. 2299.  -     return ev ? cancelEvent(ev) : false;
  4722. 2300.  -   },
  4723. 2301.  -   skipSelectFriend: function(opts) {
  4724. 2302.  -     opts = opts || {};
  4725. 2303.  -     var __cur = opts.from_pad ? window._pads && _pads.cur : window.cur;
  4726. 2304.  -     __cur.skipSelectFriend = true;
  4727. 2305.  -   },
  4728. 2306.  -   selectCommunity: function(opts, ev) {
  4729. 2307.  -     opts = opts || {};
  4730. 2308.  -     var __cur = opts.from_pad ? window._pads && _pads.cur : window.cur,
  4731. 2309.  -         from_pad = !!opts.from_pad, id = opts.id;
  4732. 2310.  -     if (__cur.skipSelectCommunity) {
  4733. 2311.  -       __cur.skipSelectCommunity = false;
  4734. 2312.  -       return;
  4735. 2313.  -     }
  4736. 2314.  -     each(geByClass('audio_friend', __cur.searchInfoCont), function(i, e) {
  4737. 2315.  -       removeClass(e, 'current');
  4738. 2316.  -     });
  4739. 2317.  -     addClass(ge((from_pad ? 'pad_' : '') + 'audio_community' + id), 'current');
  4740. 2318.  -     mentionOver(ge((from_pad ? 'pad_' : '') + 'audio_community' + id), {shift: [47, 7, 7]});
  4741. 2319.  -     each(geByClass('audio_filter', __cur.albumFilters), function(i, e) {
  4742. 2320.  -       removeClass(e, 'selected');
  4743. 2321.  -     });
  4744. 2322.  -     addClass(__cur.albumFiltered, 'club_shown');
  4745. 2323.  -     __cur.searchSortFilter.disable(true);
  4746. 2324.  -     __cur.searchLyricsFilter.disable(true);
  4747. 2325.  -     removeClass(__cur.albumFiltered, 'selected');
  4748. 2326.  -     __cur.club = id;
  4749. 2327.  -     Audio.loadCommunityAudios({from_pad: from_pad, gid: id, index: 'club' + id});
  4750. 2328.  -     if (id && (__cur.oid == vk.id || from_pad)) {
  4751. 2329.  -       ajax.post(Audio.address, {act: 'list_stats', club: id});
  4752. 2330.  -     }
  4753. 2331.  -     return ev ? cancelEvent(ev) : false;
  4754. 2332.  -   },
  4755. 2333.  -   skipSelectCommunity: function(opts) {
  4756. 2334.  -     opts = opts || {};
  4757. 2335.  -     var __cur = opts.from_pad ? window._pads && _pads.cur : window.cur;
  4758. 2336.  -     __cur.skipSelectCommunity = true;
  4759. 2337.  -   },
  4760. 2338.  -   backToSearch: function(from_pad) {
  4761. 2339.  -     var __cur = from_pad ? window._pads && _pads.cur : window.cur;
  4762. 2340.  -     if (__cur.curSection && __cur.curSection.substr(0, 4) == 'club') {
  4763. 2341.  -       __cur.ignoreEqual = true;
  4764. 2342.  -       each(geByClass('audio_friend', __cur.searchInfoCont), function() {
  4765. 2343.  -         removeClass(this, 'current');
  4766. 2344.  -       });
  4767. 2345.  -       this.updateList({from_pad: from_pad});
  4768. 2346.  -     }
  4769. 2347.  -   },
  4770. 2348.  -   playCurrent: function(el, hash, ev) {
  4771. 2349.  -     var _a = window.audioPlayer, aid = currentAudioId(), audioId = el.getAttribute('data-audio');
  4772. 2350.  -     if (_a) _a.gpDisabled = false;
  4773. 2351.  -     if ((window.audioPlaylist || {})[audioId]) {
  4774. 2352.  -       if (!_a || aid != audioId || _a.player.paused()) playAudioNew(audioId);
  4775. 2353.  -       return cancelEvent(ev);
  4776. 2354.  -     }
  4777. 2355.  -
  4778. 2356.  -     var prg = el.nextSibling || el.parentNode.appendChild(ce('span', {className: 'progress_inline current_audio_prg'}));
  4779. 2357.  -     stManager.add(['audioplayer.css', 'audioplayer.js'], ajax.post.pbind(Audio.address, {act: 'play_audio_status', id: audioId, hash: hash}, {
  4780. 2358.  -       onDone: function(info, data, uid) {
  4781. 2359.  -         if (data && uid) {
  4782. 2360.  -           audioPlayer.statusData = audioPlayer.statusData || {};
  4783. 2361.  -           audioPlayer.statusData[uid] = data;
  4784. 2362.  -         }
  4785. 2363.  -         if (!info) return;
  4786. 2364.  -
  4787. 2365.  -         if (!window.audioPlaylist) {
  4788. 2366.  -           window.audioPlaylist = {};
  4789. 2367.  -         }
  4790. 2368.  -         audioPlaylist[audioId] = info;
  4791. 2369.  -         audioPlaylist.start = audioId;
  4792. 2370.  -         if (data && uid) {
  4793. 2371.  -           audioPlaylist.statusData = data;
  4794. 2372.  -         } else {
  4795. 2373.  -           delete audioPlaylist.statusData;
  4796. 2374.  -         }
  4797. 2375.  -         audioPlayer.setPadPlaylist(audioPlaylist);
  4798. 2376.  -         playAudioNew(audioId);
  4799. 2377.  -       },
  4800. 2378.  -       showProgress: function() {
  4801. 2379.  -         show(prg);
  4802. 2380.  -         hide(el);
  4803. 2381.  -       },
  4804. 2382.  -       hideProgress: function() {
  4805. 2383.  -         hide(prg);
  4806. 2384.  -         show(el);
  4807. 2385.  -       }
  4808. 2386.  -     }));
  4809. 2387.  -     return cancelEvent(ev);
  4810. 2388.  -   },
  4811. 2389.  -   loadFriendsAudios: function(opts) {
  4812. 2390.  -     opts = opts || {};
  4813. 2391.  -     var __cur = opts.from_pad ? window._pads && _pads.cur : window.cur,
  4814. 2392.  -         from_pad = !!opts.from_pad, id = opts.id, index = opts.index, str = opts.str,
  4815. 2393.  -         album = opts.album, showAlbums = opts.showAlbums, owner = opts.owner;
  4816. 2394.  -     if (__cur.silent) {
  4817. 2395.  -       __cur.onSilentLoad = function() {
  4818. 2396.  -         Audio.loadFriendsAudios(opts);
  4819. 2397.  -       };
  4820. 2398.  -       return;
  4821. 2399.  -     }
  4822. 2400.  -     if (!__cur.audiosList[index]) {
  4823. 2401.  -       if (index == 'all') {
  4824. 2402.  -         each(geByClass('audio_filter', __cur.albumFilters), function(i, e) {
  4825. 2403.  -           removeClass(e, 'selected');
  4826. 2404.  -         });
  4827. 2405.  -         if (showAlbums) {
  4828. 2406.  -           addClass(__cur.albumsFilter, 'loading');
  4829. 2407.  -         } else if (album) {
  4830. 2408.  -           addClass(ge((from_pad ? 'pad_' : '') + 'album' + album), 'selected loading');
  4831. 2409.  -         } else {
  4832. 2410.  -           addClass(ge((from_pad ? 'pad_' : '') + 'album0'), 'selected loading');
  4833. 2411.  -         }
  4834. 2412.  -         removeClass(__cur.albumFiltered, 'selected');
  4835. 2413.  -       }
  4836. 2414.  -       __cur.lastAct = index;
  4837. 2415.  -       var query = {act: 'load_audios_silent', id: id, claim: nav.objLoc.claim, please_dont_ddos: 3};
  4838. 2416.  -       if (owner) {
  4839. 2417.  -         query.is_owner = 1;
  4840. 2418.  -       }
  4841. 2419.  -       if (index != 'all' && !ge((from_pad ? 'pad_' : '') + 'audio_friend' + id) && !owner) {
  4842. 2420.  -         __cur.shownFriends = [];
  4843. 2421.  -         var txt = domFC(ge(__cur.audioMoreFriensId)), prg = domLC(ge(__cur.audioMoreFriensId));
  4844. 2422.  -         Audio.showMoreFriends({from_pad: from_pad, onShow: function() {
  4845. 2423.  -           hide(txt);
  4846. 2424.  -           show(prg);
  4847. 2425.  -         }, onHide: function() {
  4848. 2426.  -           hide(prg);
  4849. 2427.  -           show(txt);
  4850. 2428.  -         }, friend: id});
  4851. 2429.  -       }
  4852. 2430.  -       ajax.post(Audio.address, query, {
  4853. 2431.  -         cache: 1,
  4854. 2432.  -         onDone: function(data, options) {
  4855. 2433.  -           if (__cur.lastAct != index) return;
  4856. 2434.  -           options = eval('('+options+')');
  4857. 2435.  -           if (options.summaryLang) {
  4858. 2436.  -             __cur.summaryLang = extend(__cur.summaryLang || {}, options.summaryLang);
  4859. 2437.  -           }
  4860. 2438.  -           if (id < 0) {
  4861. 2439.  -             __cur.allFriendsHTitles = __cur.allFriendsHTitles || {};
  4862. 2440.  -             __cur.allFriendsHTitles[id] = options.summaryLang.all_club_htitle;
  4863. 2441.  -           } else {
  4864. 2442.  -             __cur.allFriendsTitles = __cur.allFriendsTitles || {};
  4865. 2443.  -             __cur.allFriendsTitles[id] = options.summaryLang.all_friend_title;
  4866. 2444.  -             __cur.allFriendsHTitles = __cur.allFriendsHTitles || {};
  4867. 2445.  -             __cur.allFriendsHTitles[id] = options.summaryLang.all_friend_htitle;
  4868. 2446.  -           }
  4869. 2447.  -           var obj = eval('('+data+')');
  4870. 2448.  -           if (!obj) return;
  4871. 2449.  -           __cur.audiosList[index] = obj['all'];
  4872. 2450.  -           if (id == vk.id && index == 'all') {
  4873. 2451.  -             __cur.allAudiosIndex = 'all';
  4874. 2452.  -             Audio.generateAlbums(from_pad);
  4875. 2453.  -           }
  4876. 2454.  -           if (!__cur.performerInfo) {
  4877. 2455.  -             __cur.performerInfo = {};
  4878. 2456.  -           }
  4879. 2457.  -           __cur.performerInfo[index] = options.performerInfo;
  4880. 2458.  -           if (options.backLink && !from_pad) {
  4881. 2459.  -             __cur.backLink = options.backLink;
  4882. 2460.  -             showBackLink('/audio?act=popular'+(__cur.genre ? '&genre='+__cur.genre : ''), __cur.backLink);
  4883. 2461.  -           }
  4884. 2462.  -           if (index != 'all') __cur.audioFriend = id;
  4885. 2463.  -           Audio.changeAllIndex({from_pad: from_pad, index: index, album: album, showAlbums: showAlbums, owner: owner, str: str});
  4886. 2464.  -           Audio.cacheFriendsList(from_pad);
  4887. 2465.  -         }
  4888. 2466.  -       });
  4889. 2467.  -     } else {
  4890. 2468.  -       if (index != 'all') __cur.audioFriend = id;
  4891. 2469.  -       if (owner && !from_pad) {
  4892. 2470.  -         showBackLink('/audio?act=popular'+(__cur.genre ? '&genre='+__cur.genre : ''), __cur.backLink);
  4893. 2471.  -       }
  4894. 2472.  -       Audio.changeAllIndex({from_pad: from_pad, index: index, album: album, showAlbums: showAlbums, owner: owner, str: str});
  4895. 2473.  -     }
  4896. 2474.  -   },
  4897. 2475.  -   loadCommunityAudios: function(opts) {
  4898. 2476.  -     opts = opts || {};
  4899. 2477.  -     var __cur = opts.from_pad ? window._pads && _pads.cur : window.cur,
  4900. 2478.  -         from_pad = !!opts.from_pad, gid = opts.gid, index = opts.index;
  4901. 2479.  -     if (__cur.silent) {
  4902. 2480.  -       __cur.onSilentLoad = function() {
  4903. 2481.  -         Audio.loadCommunityAudios(opts);
  4904. 2482.  -       };
  4905. 2483.  -       return;
  4906. 2484.  -     }
  4907. 2485.  -     if (!__cur.audiosList[index]) {
  4908. 2486.  -       __cur.lastAct = index;
  4909. 2487.  -       ajax.post(Audio.address, {act: 'load_audios_silent', gid: gid, claim: nav.objLoc.claim, please_dont_ddos: 1}, {
  4910. 2488.  -         cache: 1,
  4911. 2489.  -         showProgress: addClass.pbind(ge((from_pad ? 'pad_' : '') + 'album0'), 'loading'),
  4912. 2490.  -         hideProgress: removeClass.pbind(ge((from_pad ? 'pad_' : '') + 'album0'), 'loading'),
  4913. 2491.  -         onDone: function(data, options) {
  4914. 2492.  -           if (__cur.lastAct != index) return;
  4915. 2493.  -           options = eval('('+options+')');
  4916. 2494.  -           __cur.allClubsHTitles = __cur.allClubsHTitles || {};
  4917. 2495.  -           __cur.allClubsHTitles[gid] = options.summaryLang.all_club_htitle;
  4918. 2496.  -           var obj = eval('('+data+')');
  4919. 2497.  -           if (!obj) return;
  4920. 2498.  -           __cur.audiosList[index] = obj['all'];
  4921. 2499.  -           Audio.searchAudios({from_pad: from_pad, type: index, str: ''});
  4922. 2500.  -           Audio.scrollToTop(from_pad);
  4923. 2501.  -         }
  4924. 2502.  -       });
  4925. 2503.  -     } else {
  4926. 2504.  -       Audio.searchAudios({from_pad: from_pad, type: index, str: ''});
  4927. 2505.  -       Audio.scrollToTop(from_pad);
  4928. 2506.  -     }
  4929. 2507.  -   },
  4930. 2508.  -   showMoreFriends: function(opts) {
  4931. 2509.  -     opts = opts || {};
  4932. 2510.  -     var __cur = opts.from_pad ? window._pads && _pads.cur : window.cur,
  4933. 2511.  -         from_pad = !!opts.from_pad, friend = opts.friend,
  4934. 2512.  -         onShow = opts.onShow || function() {}, onHide = opts.onHide || function() {};
  4935. 2513.  -     if (__cur.moreFriendsSent) {
  4936. 2514.  -       return;
  4937. 2515.  -     }
  4938. 2516.  -     __cur.moreFriendsSent = true;
  4939. 2517.  -     var query = {act: 'more_friends', ids: __cur.shownFriends};
  4940. 2518.  -     if (friend) {
  4941. 2519.  -       query.owner = friend;
  4942. 2520.  -     }
  4943. 2521.  -     if (from_pad) {
  4944. 2522.  -       query.from_pad = 1;
  4945. 2523.  -     }
  4946. 2524.  -     ajax.post(Audio.address, query, {
  4947. 2525.  -       onDone: function(cont, friends, reset) {
  4948. 2526.  -         __cur.moreFriendsSent = false;
  4949. 2527.  -         if (cont) {
  4950. 2528.  -           var list = __cur.friendsList;
  4951. 2529.  -           re('audio_friends_old');
  4952. 2530.  -           var old = ce('div', {innerHTML: '<div id="audio_friends_old" style="position: absolute; top: ' + list.offsetTop + 'px">'+list.innerHTML+'</div>'}).firstChild;
  4953. 2531.  -           list.parentNode.insertBefore(old, list);
  4954. 2532.  -           list.innerHTML = '';
  4955. 2533.  -           setStyle(list, {display: 'none'});
  4956. 2534.  -           list.innerHTML = cont;
  4957. 2535.  -           var oldRows = geByClass('audio_friend', old), oldCnt = oldRows.length,
  4958. 2536.  -               newCnt = geByClass('audio_friend', list).length;
  4959. 2537.  -           if (oldCnt > newCnt) {
  4960. 2538.  -             oldRows = oldRows.slice(newCnt);
  4961. 2539.  -             each(oldRows, function() {
  4962. 2540.  -               re(this);
  4963. 2541.  -             });
  4964. 2542.  -           }
  4965. 2543.  -           setTimeout(Audio.handleFilterPos, 0);
  4966. 2544.  -           fadeIn(list, 400, re.pbind(old));
  4967. 2545.  -           if (friends) {
  4968. 2546.  -             __cur.shownFriends = reset ? friends : __cur.shownFriends.concat(friends);
  4969. 2547.  -           }
  4970. 2548.  -         } else {
  4971. 2549.  -           Audio.handleFilterPos();
  4972. 2550.  -         }
  4973. 2551.  -       },
  4974. 2552.  -       onFail: function() {
  4975. 2553.  -         __cur.moreFriendsSent = false;
  4976. 2554.  -       },
  4977. 2555.  -       showProgress: onShow,
  4978. 2556.  -       hideProgress: onHide
  4979. 2557.  -     });
  4980. 2558.  -   },
  4981. 2559.  -   cacheFriendsList: function(from_pad) {
  4982. 2560.  -     var __cur = from_pad ? window._pads && _pads.cur : window.cur,
  4983. 2561.  -         query = {act: 'more_friends'};
  4984. 2562.  -     if (__cur.audioFriendPlaying) query.owner = __cur.audioFriendPlaying;
  4985. 2563.  -     else if (__cur.audioFriend) query.owner = __cur.audioFriend;
  4986. 2564.  -     ajax.post(Audio.address, query, {cache: 1});
  4987. 2565.  -   },
  4988. 2566.  -
  4989. 2567.  -   // Audio Edit functions
  4990. 2568.  -
  4991. 2569.  -   showAudioClaimWarning: function(aid, claim_id, title, reason) {
  4992. 2570.  -     if (cur.silent) {
  4993. 2571.  -       cur.onSilentLoad = function() {
  4994. 2572.  -         Audio.showAudioClaimWarning(aid, claim_id, title, reason);
  4995. 2573.  -       };
  4996. 2574.  -       return;
  4997. 2575.  -     }
  4998. 2576.  -     var claimText, claimTitle;
  4999. 2577.  -     if (reason == 'crap') {
  5000. 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'));
  5001. 2579.  -       claimTitle = getLang('audio_crap_warning_title') || getLang('audio_claim_warning_title');
  5002. 2580.  -     } else {
  5003. 2581.  -       claimText = (claim_id > 0) ? getLang('audio_claim_warning_objection') : (claim_id == 0 ? getLang('audio_claim_warning_text') : getLang('audio_claim_warning'));
  5004. 2582.  -       claimTitle = getLang('audio_claim_warning_title');
  5005. 2583.  -     }
  5006. 2584.  -     claimText = claimText.split('{audio}').join('<b>' + title + '</b>');
  5007. 2585.  -     claimText = claimText.split('{objection_link}').join('<a href="/help?act=cc_objection&claim=' + claim_id + '&content=audio' + aid + '">' + getLang('audio_claim_objection') + '</a>');
  5008. 2586.  -     claimText = claimText.split('{delete_link}').join('<a href="#" onclick="Audio.deleteAudio(\'' + aid + '\'); return false;">' + getLang('audio_claim_delete') + '</a>');
  5009. 2587.  -     cur.claimWarning = showFastBox(claimTitle, claimText);
  5010. 2588.  -   },
  5011. 2589.  -
  5012. 2590.  -   deleteAudio: function(id) {
  5013. 2591.  -     if (cur.silent) {
  5014. 2592.  -       cur.onSilentLoad = function() {
  5015. 2593.  -         Audio.deleteAudio(id);
  5016. 2594.  -       };
  5017. 2595.  -       return;
  5018. 2596.  -     }
  5019. 2597.  -     if (cur.deleting) {
  5020. 2598.  -       return false;
  5021. 2599.  -     }
  5022. 2600.  -     cur.deleting = true;
  5023. 2601.  -     var el = ge('audio' + id), aid = id.split('_')[1];
  5024. 2602.  -     if (!cur.deletedAudios) cur.deletedAudios = [];
  5025. 2603.  -     cur.deletedAudios[aid] = el.innerHTML;
  5026. 2604.  -     var acts = geByClass1('actions', el);
  5027. 2605.  -     each(acts.children, function(){if (this.tt && this.tt.hide) this.tt.hide()});
  5028. 2606.  -     var a = (cur.audios || {})[aid] || [], lyrics = isVisible(ge('lyrics'+id)),
  5029. 2607.  -         _tw = el && geByClass1('title_wrap', el),
  5030. 2608.  -         performer = a[5] || _tw && (geByTag1('a', _tw) || {}).innerHTML || '',
  5031. 2609.  -         title = a[6] || _tw && (geByClass1('title', _tw) || {}).innerHTML || '';
  5032. 2610.  -     el.innerHTML = rs(cur.deletedTpl, {
  5033. 2611.  -       audio_id: id,
  5034. 2612.  -       performer: performer.split('<span>').join('').split('</span>').join(''),
  5035. 2613.  -       title: title,
  5036. 2614.  -       delete_all: ''
  5037. 2615.  -     });
  5038. 2616.  -     var _a = window.audioPlayer;
  5039. 2617.  -     if (currentAudioId() == id) {
  5040. 2618.  -       _a.showCurrentTrack();
  5041. 2619.  -     }
  5042. 2620.  -     if (lyrics) {
  5043. 2621.  -       Audio.updateSorterRows(ge('audio'+id));
  5044. 2622.  -     }
  5045. 2623.  -     var addBtn = ge('audio_add'+id);
  5046. 2624.  -     if (addBtn) {
  5047. 2625.  -       addBtn.onmouseover = function() {};
  5048. 2626.  -     }
  5049. 2627.  -     ajax.post(Audio.address, {act: 'delete_audio', oid: cur.oid, aid: aid, hash: cur.hashes.delete_hash, restore: 1}, {
  5050. 2628.  -       onDone: function(action, delete_all) {
  5051. 2629.  -         cur.deleting = false;
  5052. 2630.  -         if (cur.claimWarning) {
  5053. 2631.  -           cur.claimWarning.hide();
  5054. 2632.  -         }
  5055. 2633.  -         var acts = geByClass1('actions', el);
  5056. 2634.  -         each(acts.children, function(){if (this.tt) this.tt.hide()});
  5057. 2635.  -         el.innerHTML = rs(cur.deletedTpl, {
  5058. 2636.  -           audio_id: id,
  5059. 2637.  -           performer: performer.split('<span>').join('').split('</span>').join(''),
  5060. 2638.  -           title: title,
  5061. 2639.  -           delete_all: action ? action : ''
  5062. 2640.  -         });
  5063. 2641.  -         el.style.cursor = 'auto';
  5064. 2642.  -         el.setAttribute('nosorthandle', '1');
  5065. 2643.  -         if (currentAudioId() == id) {
  5066. 2644.  -           _a.showCurrentTrack();
  5067. 2645.  -         }
  5068. 2646.  -         if (delete_all) {
  5069. 2647.  -           cur.lang = cur.lang || {};
  5070. 2648.  -           cur.lang.audio_delete_all = delete_all;
  5071. 2649.  -         }
  5072. 2650.  -         if (cur.audios[aid]) {
  5073. 2651.  -           cur.audiosIndex.remove(cur.audios[aid]);
  5074. 2652.  -           cur.audios[aid].deleted = true;
  5075. 2653.  -           if (window.Pads && Pads.clearAudioLoadCache) {
  5076. 2654.  -             Pads.clearAudioLoadCache();
  5077. 2655.  -           }
  5078. 2656.  -         }
  5079. 2657.  -         Audio.removeFromPlaylist(id);
  5080. 2658.  -         cur.sectionCount--;
  5081. 2659.  -         if (cur.shownAudios) cur.shownAudios--;
  5082. 2660.  -         Audio.changeSummary();
  5083. 2661.  -       },
  5084. 2662.  -       onFail: function() {
  5085. 2663.  -         cur.deleting = false;
  5086. 2664.  -       }
  5087. 2665.  -     });
  5088. 2666.  -     return false;
  5089. 2667.  -   },
  5090. 2668.  -
  5091. 2669.  -   restoreAudio: function(id) {
  5092. 2670.  -     if (cur.restoring) {
  5093. 2671.  -       return;
  5094. 2672.  -     }
  5095. 2673.  -     cur.restoring = true;
  5096. 2674.  -     var el = ge('audio' + id), aid = id.split('_')[1];
  5097. 2675.  -     ajax.post(Audio.address, {act: 'restore_audio', oid: cur.oid, aid: aid, hash: cur.hashes.restore_hash}, {
  5098. 2676.  -       onDone: function() {
  5099. 2677.  -         cur.restoring = false;
  5100. 2678.  -         var acts = geByClass1('actions', el);
  5101. 2679.  -         each(acts.children, function(){if (this.tt) this.tt.hide()});
  5102. 2680.  -         el.innerHTML = cur.deletedAudios[aid];
  5103. 2681.  -         var lyrics = isVisible(ge('lyrics'+id));
  5104. 2682.  -         if (lyrics) {
  5105. 2683.  -           Audio.updateSorterRows(ge('audio'+id));
  5106. 2684.  -         }
  5107. 2685.  -         el.removeAttribute('nosorthandle');
  5108. 2686.  -         if (cur.audios[aid]) {
  5109. 2687.  -           cur.audiosIndex.add(cur.audios[aid]);
  5110. 2688.  -           cur.audios[aid].deleted = false;
  5111. 2689.  -           if (window.Pads && Pads.clearAudioLoadCache) {
  5112. 2690.  -             Pads.clearAudioLoadCache();
  5113. 2691.  -           }
  5114. 2692.  -         }
  5115. 2693.  -         Audio.backToPlaylist(id);
  5116. 2694.  -         cur.sectionCount++;
  5117. 2695.  -         if (cur.shownAudios) cur.shownAudios++;
  5118. 2696.  -         Audio.changeSummary();
  5119. 2697.  -         toggleClass(ge('play'+id), 'playing', id == currentAudioId());
  5120. 2698.  -       },
  5121. 2699.  -       onFail: function() {
  5122. 2700.  -         cur.restoring = false;
  5123. 2701.  -       }
  5124. 2702.  -     });
  5125. 2703.  -   },
  5126. 2704.  -
  5127. 2705.  -   deleteAll: function(object_id, from_id, to_id, hash) {
  5128. 2706.  -     var box = showFastBox(getLang('audio_delete_all_title'), getLang('audio_delete_all') || '', getLang('global_delete'), function(btn){
  5129. 2707.  -       ajax.post(Audio.address, {act: 'delete_all', object_id: object_id, to_id: to_id, from_id: from_id, hash: hash}, {
  5130. 2708.  -         showProgress: lockButton.pbind(btn),
  5131. 2709.  -         onDone: function() {
  5132. 2710.  -           nav.reload();
  5133. 2711.  -         },
  5134. 2712.  -         onFail: box.hide
  5135. 2713.  -       });
  5136. 2714.  -     }, getLang('global_cancel'));
  5137. 2715.  -   },
  5138. 2716.  -
  5139. 2717.  -   editAudio: function(aid, event){
  5140. 2718.  -     showBox(Audio.address, {act: 'edit_audio_box', aid: aid}, {
  5141. 2719.  -       params: {width: '430px', bodyStyle: 'padding: 15px;'}
  5142. 2720.  -     });
  5143. 2721.  -     if (event) cancelEvent(event);
  5144. 2722.  -     return false;
  5145. 2723.  -   },
  5146. 2724.  -
  5147. 2725.  -   editTopAudio: function(full_aid, event) {
  5148. 2726.  -     showBox('al_search.php', {act: 'audio_top_edit_box', id: full_aid, full_id: full_aid}, {
  5149. 2727.  -       params: {width: '430px', bodyStyle: 'padding: 15px;'}
  5150. 2728.  -     });
  5151. 2729.  -     if (event) cancelEvent(event);
  5152. 2730.  -     return false;
  5153. 2731.  -   },
  5154. 2732.  -
  5155. 2733.  -   removeFromTop: function(audio_hash, hash, full_aid, event) {
  5156. 2734.  -     ajax.post('al_search.php', {act: 'save_top_audio', deleted: 1, audio_hash: audio_hash, hash: hash, id: full_aid}, {
  5157. 2735.  -       onDone: function() {
  5158. 2736.  -         var audioRow = ge('audio'+full_aid);
  5159. 2737.  -         slideUp(audioRow, 100);
  5160. 2738.  -       }
  5161. 2739.  -     })
  5162. 2740.  -   },
  5163. 2741.  -
  5164. 2742.  -   updateAlbumsStart: function() {
  5165. 2743.  -     if (!cur.canEdit || browser.mobile || !cur.audioAlbumsWrap ||  !cur.audioAlbumsWrap.sorter) return;
  5166. 2744.  -     each (cur.audioAlbumsWrap.sorter.elems, function() {
  5167. 2745.  -       setStyle(this, {top: 'auto', left: 'auto', width: 'auto'});
  5168. 2746.  -     });
  5169. 2747.  -     cur.audioAlbumsWrap.sorter.destroy();
  5170. 2748.  -   },
  5171. 2749.  -
  5172. 2750.  -   updateAlbumsFinish: function() {
  5173. 2751.  -     if (!cur.canEdit || browser.mobile) return;
  5174. 2752.  -     this.initAlbumsSort();
  5175. 2753.  -     this.updateAlbumsTitles();
  5176. 2754.  -   },
  5177. 2755.  -
  5178. 2756.  -   updateAlbums: function() {
  5179. 2757.  -     this.updateAlbumsStart();
  5180. 2758.  -     this.updateAlbumsFinish();
  5181. 2759.  -   },
  5182. 2760.  -
  5183. 2761.  -   updateAlbumsTitles: function(opts) {
  5184. 2762.  -     opts = opts || {};
  5185. 2763.  -     var __cur = opts.from_pad ? window._pads && _pads.cur : window.cur,
  5186. 2764.  -         from_pad = !!opts.from_pad;
  5187. 2765.  -
  5188. 2766.  -     if (!__cur.audioAlbumsWrap) return;
  5189. 2767.  -
  5190. 2768.  -     each (geByClass('label', __cur.audioAlbumsWrap), function() {
  5191. 2769.  -       if (this.scrollWidth > this.clientWidth) {
  5192. 2770.  -         this.setAttribute('title', this.innerText || this.textContent);
  5193. 2771.  -       } else {
  5194. 2772.  -         this.removeAttribute('title');
  5195. 2773.  -       }
  5196. 2774.  -     });
  5197. 2775.  -   },
  5198. 2776.  -
  5199. 2777.  -   updatePadFiltersHeight: function() {
  5200. 2778.  -     var filters = ge('pad_side_filters'), td = ge('pad_filters_panel'),
  5201. 2779.  -         curSz = getSize(td)[1], minSz = getSize(_pads.content)[1],
  5202. 2780.  -         newSz = Math.max(minSz, getSize(filters)[1] + 10);
  5203. 2781.  -     if (newSz != curSz) {
  5204. 2782.  -       setStyle(td, {height: newSz});
  5205. 2783.  -       if (window.Pads) {
  5206. 2784.  -         Pads.updateHeight();
  5207. 2785.  -       }
  5208. 2786.  -     }
  5209. 2787.  -   },
  5210. 2788.  -
  5211. 2789.  -   initAlbumsSort: function() {
  5212. 2790.  -     if (!cur.canEdit || browser.mobile || !cur.audioAlbumsWrap || cur.audioAlbumsWrap.sorter) return;
  5213. 2791.  -     sorter.init(cur.audioAlbumsWrap, {onMouseDown: Audio.hideAlbumsTT, onReorder: Audio.onAlbumReorder, noMoveCursor: 1});
  5214. 2792.  -   },
  5215. 2793.  -
  5216. 2794.  -   hideAlbumsTT: function() {
  5217. 2795.  -     each(geByClass('icon_wrap', cur.audioAlbumsWrap), function() {
  5218. 2796.  -       if (this.tt) this.tt.hide();
  5219. 2797.  -     })
  5220. 2798.  -   },
  5221. 2799.  -
  5222. 2800.  -   onAlbumReorder: function(album, before, after) {
  5223. 2801.  -     var aid = album.id.replace('album', '');
  5224. 2802.  -     var before_id = (before && before.id || '').replace('album', '');
  5225. 2803.  -     var after_id = (after && after.id || '').replace('album', '');
  5226. 2804.  -     ajax.post(Audio.address, {act: 'reorder_albums', oid: cur.oid, aid: aid, before: before_id, after: after_id, hash: cur.hashes.reorder_hash});
  5227. 2805.  -   },
  5228. 2806.  -
  5229. 2807.  -   editAlbum: function(aid){
  5230. 2808.  -     if (cur.silent) {
  5231. 2809.  -       cur.onSilentLoad = function() {
  5232. 2810.  -         Audio.editAlbum(aid);
  5233. 2811.  -       };
  5234. 2812.  -       return;
  5235. 2813.  -     }
  5236. 2814.  -     if (!cur.audiosList) {
  5237. 2815.  -       return;
  5238. 2816.  -     }
  5239. 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']});
  5240. 2818.  -     cur.onOListSave = Audio.saveAlbum.pbind(box, aid);
  5241. 2819.  -     return false;
  5242. 2820.  -   },
  5243. 2821.  -
  5244. 2822.  -   createAlbum: function() {
  5245. 2823.  -     return this.editAlbum(0);
  5246. 2824.  -   },
  5247. 2825.  -
  5248. 2826.  -   saveAlbum: function(box, aid, audio_ids) {
  5249. 2827.  -     var btn = geByClass1('button_blue', box.bodyNode.nextSibling).firstChild,
  5250. 2828.  -         albumName = val('album_name');
  5251. 2829.  -     if (!albumName) {
  5252. 2830.  -       notaBene('album_name');
  5253. 2831.  -       return false;
  5254. 2832.  -     }
  5255. 2833.  -     var query = {act: 'save_album', album_id: aid, name: albumName, gid: cur.gid, Audios: audio_ids.join(','), hash: cur.hashes.save_album_hash};
  5256. 2834.  -     ajax.post(Audio.address, query, {
  5257. 2835.  -       showProgress: lockButton.pbind(btn),
  5258. 2836.  -       hideProgress: unlockButton.pbind(btn),
  5259. 2837.  -       onFail: box.hide,
  5260. 2838.  -       onDone: function(album_id, audio_ids, filters) {
  5261. 2839.  -         try{
  5262. 2840.  -           cur.audioAlbumsWrap.innerHTML = filters;
  5263. 2841.  -           var old = cur.audiosList['album'+album_id];
  5264. 2842.  -           if (old) {
  5265. 2843.  -             for (var i in old) {
  5266. 2844.  -               cur.audios[old[i][1]][8] = 0;
  5267. 2845.  -             }
  5268. 2846.  -           }
  5269. 2847.  -           for (var i in audio_ids) {
  5270. 2848.  -             cur.audios[audio_ids[i]][8] = album_id;
  5271. 2849.  -           }
  5272. 2850.  -           cur.albums[album_id] = {id: album_id, title: clean(albumName)};
  5273. 2851.  -           Audio.generateAlbums();
  5274. 2852.  -           Audio.loadAlbum({album: album_id});
  5275. 2853.  -           Audio.initAlbumsSort();
  5276. 2854.  -           Audio.updateAlbumsTitles();
  5277. 2855.  -           box.hide();
  5278. 2856.  -         }catch(e){}
  5279. 2857.  -       }
  5280. 2858.  -     });
  5281. 2859.  -     return false;
  5282. 2860.  -   },
  5283. 2861.  -
  5284. 2862.  -   deleteAlbum: function(aid, hash){
  5285. 2863.  -     var box = showFastBox(getLang('audio_delete_album_title'), getLang('audio_delete_album_are_you_sure'), getLang('audio_delete_album_button'), function(btn){
  5286. 2864.  -       ajax.post(Audio.address, {act: 'delete_album', album_id: aid, hash: hash, gid: cur.gid}, {
  5287. 2865.  -         showProgress: lockButton.pbind(btn),
  5288. 2866.  -         hideProgress: unlockButton.pbind(btn),
  5289. 2867.  -         onDone: function(audio_ids, filters){
  5290. 2868.  -           try{
  5291. 2869.  -             re('album'+aid);
  5292. 2870.  -             boxQueue.hideAll();
  5293. 2871.  -             for (var i in audio_ids) {
  5294. 2872.  -               cur.audios[audio_ids[i]][8] = 0;
  5295. 2873.  -             }
  5296. 2874.  -             delete cur.albums[aid];
  5297. 2875.  -             Audio.generateAlbums();
  5298. 2876.  -             if (cur.album_id == aid) {
  5299. 2877.  -               Audio.loadAlbum({album: 0, showAlbums: true});
  5300. 2878.  -             }
  5301. 2879.  -             Audio.updateAlbums();
  5302. 2880.  -           }catch(e){}
  5303. 2881.  -         },
  5304. 2882.  -         onFail: function(){
  5305. 2883.  -           box.hide(200);
  5306. 2884.  -         }
  5307. 2885.  -       });
  5308. 2886.  -     }, getLang('global_cancel'));
  5309. 2887.  -   },
  5310. 2888.  -
  5311. 2889.  -   moveAudio: function(full_id, album_id) {
  5312. 2890.  -     var id = full_id.split('_')[1];
  5313. 2891.  -     ajax.post(Audio.address, {act:'move_to_album', album_id:album_id, audio_id:id, gid:cur.gid, hash:cur.hashes.move_hash}, {
  5314. 2892.  -       onDone: function(text) {
  5315. 2893.  -         if((cur.album_id && cur.album_id != album_id) || cur.filterUnsorted){
  5316. 2894.  -           var el = ge('audio'+full_id);
  5317. 2895.  -           fadeOut(el, 300, function(){
  5318. 2896.  -             el.parentNode.removeChild(el);
  5319. 2897.  -             each (cur.aContent.sorter.elems, function() {
  5320. 2898.  -               setStyle(this, {top: 'auto', left: 'auto'});
  5321. 2899.  -             });
  5322. 2900.  -             cur.aContent.sorter.destroy();
  5323. 2901.  -             var opts = {onReorder: Audio.onAudioReorder, onMouseDown: Audio.onDragStart, onMouseUp: Audio.onDragEnd, noMoveCursor: 1};
  5324. 2902.  -             if (cur.albumFilters) {
  5325. 2903.  -               extend(opts, {target: cur.albumFilters, onDragOver: Audio.onDragOver, onDragOut: Audio.onDragOut});
  5326. 2904.  -             }
  5327. 2905.  -             sorter.init(cur.aContent, opts);
  5328. 2906.  -             cur.sectionCount--;
  5329. 2907.  -             Audio.changeSummary();
  5330. 2908.  -             if (cur.sectionCount == 0) {
  5331. 2909.  -               cur.aContent.innerHTML = '<div id="not_found" class="info_msg">'+getLang('audio_album_no_recs')+'</div>';
  5332. 2910.  -             }
  5333. 2911.  -             hide(cur.showMore);
  5334. 2912.  -           });
  5335. 2913.  -         }
  5336. 2914.  -         cur.audios[id][8] = album_id;
  5337. 2915.  -         Audio.generateAlbums();
  5338. 2916.  -       }
  5339. 2917.  -     });
  5340. 2918.  -   },
  5341. 2919.  -
  5342. 2920.  -   onAudioReorder: function(audio, before, after) {
  5343. 2921.  -     var aid = audio.id.replace('audio', '').split('_')[1];
  5344. 2922.  -     var before_id = (before && before.id || '').replace('audio', '').split('_')[1];
  5345. 2923.  -     var after_id = (after && after.id || '').replace('audio', '').split('_')[1];
  5346. 2924.  -     ajax.post(Audio.address, {act: 'reorder_audios', oid: cur.oid, aid: aid, before: before_id, after: after_id, hash: cur.hashes.reorder_hash}, {
  5347. 2925.  -       onDone: function(data) {
  5348. 2926.  -         var val;
  5349. 2927.  -         if (before_id && !after_id) {
  5350. 2928.  -           val = cur.audios[before_id]._order - 0.01;
  5351. 2929.  -         } else {
  5352. 2930.  -           val = cur.audios[after_id]._order + 0.01;
  5353. 2931.  -         }
  5354. 2932.  -         cur.audios[aid]._order = val;
  5355. 2933.  -         Audio.reorderPlaylist(cur.oid + '_' + aid, before_id ? cur.oid + '_' + before_id : '', after_id ? cur.oid + '_' + after_id : '');
  5356. 2934.  -       }
  5357. 2935.  -     });
  5358. 2936.  -   },
  5359. 2937.  -
  5360. 2938.  -   onDragStart: function(el) {
  5361. 2939.  -     // addClass(ge('page_body'), 'no_overflow');
  5362. 2940.  -     cur.dragStartTimer = setTimeout(function() {
  5363. 2941.  -       addClass(cur.audioAlbumsWrap, 'drag');
  5364. 2942.  -       hide('album_add');
  5365. 2943.  -       var ids = el.id.substr(5), id = parseInt(ids.split('_')[1]);
  5366. 2944.  -       var album_id = (cur.audios) ? cur.audios[id][8] : cur.album_id;
  5367. 2945.  -       each(geByClass('audio_filter', cur.audioAlbumsWrap), function(i,v) {
  5368. 2946.  -         if ('album'+album_id == v.id || (album_id == 0 && v.id == 'album_unsorted')) {
  5369. 2947.  -           return;
  5370. 2948.  -         }
  5371. 2949.  -         addClass(v, 'drag_on');
  5372. 2950.  -       });
  5373. 2951.  -       animate(el, {opacity: .8}, 200);
  5374. 2952.  -     }, 300);
  5375. 2953.  -   },
  5376. 2954.  -
  5377. 2955.  -   onDragEnd: function(el, target) {
  5378. 2956.  -     if (cur.dragStartTimer) clearTimeout(cur.dragStartTimer);
  5379. 2957.  -     // removeClass(ge('page_body'), 'no_overflow');
  5380. 2958.  -     each(geByClass('audio_filter', cur.audioAlbumsWrap), function(i,v) {
  5381. 2959.  -       removeClass(v, 'drag_on');
  5382. 2960.  -     });
  5383. 2961.  -     show('album_add');
  5384. 2962.  -     if (target) {
  5385. 2963.  -       var new_album, full_id = el.id.substr(5), aid = parseInt(full_id.split('_')[1]);
  5386. 2964.  -       var album_id = (cur.audios) ? cur.audios[aid][8] : cur.album_id;
  5387. 2965.  -       if (target.id != 'album_unsorted') {
  5388. 2966.  -         new_album = parseInt(target.id.substr(5));
  5389. 2967.  -       } else {
  5390. 2968.  -         new_album = 0;
  5391. 2969.  -       }
  5392. 2970.  -       if (new_album != album_id) {
  5393. 2971.  -         Audio.moveAudio(full_id, new_album);
  5394. 2972.  -       }
  5395. 2973.  -     }
  5396. 2974.  -     removeClass(cur.audioAlbumsWrap, 'drag');
  5397. 2975.  -     animate(el, {opacity: 1}, 200);
  5398. 2976.  -   },
  5399. 2977.  -
  5400. 2978.  -   onDragOver: function(el, target) {
  5401. 2979.  -     cur.targetId = target.id || '';
  5402. 2980.  -     var ids = el.id.substr(5), id = parseInt(ids.split('_')[1]);
  5403. 2981.  -     var album_id = (cur.audios) ? cur.audios[id][8] : cur.album_id;
  5404. 2982.  -     if ('album'+album_id == target.id || (album_id == 0 && target.id == 'album_unsorted')) {
  5405. 2983.  -       return;
  5406. 2984.  -     }
  5407. 2985.  -     if (cur.dragOutTimer) {
  5408. 2986.  -       clearTimeout(cur.dragOutTimer);
  5409. 2987.  -     }
  5410. 2988.  -     addClass(target, 'drag_over');
  5411. 2989.  -     setStyle(el, {opacity: .4});
  5412. 2990.  -   },
  5413. 2991.  -
  5414. 2992.  -   onDragOut: function(el, target) {
  5415. 2993.  -     removeClass(target, 'drag_over');
  5416. 2994.  -     if (target.id && cur.targetId != target.id) return;
  5417. 2995.  -     cur.dragOutTimer = setTimeout(function(){setStyle(el, {opacity: .8});}, 200);
  5418. 2996.  -   },
  5419. 2997.  -
  5420. 2998.  -   ignoreOwner: function (post_raw, owner_id, hash, btn) {
  5421. 2999.  -     triggerEvent(ge('delete_post' + post_raw), 'mouseout');
  5422. 3000.  -     cur.feedEntriesHTML = cur.feedEntriesHTML || {};
  5423. 3001.  -     if (post_raw) {
  5424. 3002.  -       cur.feedEntriesHTML[post_raw + '_ignored'] = val('post' + post_raw);
  5425. 3003.  -     }
  5426. 3004.  -     ajax.post(Audio.address, {act: 'a_ignore_owner', post_raw: post_raw, owner_id: owner_id, hash: hash}, {
  5427. 3005.  -       onDone:function(html) {
  5428. 3006.  -         val('post' + post_raw, html);
  5429. 3007.  -         each(geByClass('post', cur.aContent), function(i,v) {
  5430. 3008.  -           var ids = this.id.match(/post((-?\d+)_(-?\d+)(_\d+)?)/);
  5431. 3009.  -           if (ids[1] != post_raw && (!ids[4] && ids[2] == owner_id || ids[4] && ids[3] == owner_id)) {
  5432. 3010.  -             hide(this);
  5433. 3011.  -           }
  5434. 3012.  -         });
  5435. 3013.  -       }
  5436. 3014.  -     });
  5437. 3015.  -   },
  5438. 3016.  -
  5439. 3017.  -   unignoreOwner: function (post_raw, owner_id, hash) {
  5440. 3018.  -     ajax.post(Audio.address, {act: 'a_unignore_owner', post_raw: post_raw || '', owner_id: owner_id, hash: hash}, {
  5441. 3019.  -       onDone:function(html) {
  5442. 3020.  -         if (post_raw) {
  5443. 3021.  -           val('post' + post_raw, cur.feedEntriesHTML[post_raw + '_ignored']);
  5444. 3022.  -         } else {
  5445. 3023.  -           val('ignore_row' + owner_id, html);
  5446. 3024.  -         }
  5447. 3025.  -         each(geByClass('post', cur.aContent), function(i,v) {
  5448. 3026.  -           var ids = this.id.match(/post((-?\d+)_(-?\d+)(_\d+)?)/);
  5449. 3027.  -           if (!ids[4] && ids[2] == owner_id || ids[4] && ids[3] == owner_id) {
  5450. 3028.  -             show(this);
  5451. 3029.  -           }
  5452. 3030.  -         });
  5453. 3031.  -       }
  5454. 3032.  -     });
  5455. 3033.  -   },
  5456. 3034.  -
  5457. 3035.  -   editHidden: function () {
  5458. 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']});
  5459. 3037.  -     cur.onOListSave = Audio.onHiddenSave;
  5460. 3038.  -     return false;
  5461. 3039.  -   },
  5462. 3040.  -
  5463. 3041.  -   onHiddenSave: function(white, black, list, options) {
  5464. 3042.  -     var box = curBox(), params = {act: 'a_ignore_olist', hash: options.hash};
  5465. 3043.  -     if (white.length < black.length) {
  5466. 3044.  -       params.White = white.join(',');
  5467. 3045.  -     } else {
  5468. 3046.  -       params.Black = black.join(',');
  5469. 3047.  -     }
  5470. 3048.  -     ajax.post(Audio.address, params, {
  5471. 3049.  -       onDone: function(control, rules) {
  5472. 3050.  -         box.hide();
  5473. 3051.  -         Audio.loadFeed({update: 'reload'});
  5474. 3052.  -       },
  5475. 3053.  -       showProgress: box.showProgress,
  5476. 3054.  -       hiderogress: box.hideProgress
  5477. 3055.  -     });
  5478. 3056.  -     return false;
  5479. 3057.  -   },
  5480. 3058.  -
  5481. 3059.  -   loadGenre: function(opts, ev) {
  5482. 3060.  -     if (checkEvent(ev)) {
  5483. 3061.  -       return true;
  5484. 3062.  -     }
  5485. 3063.  -     opts = opts || {};
  5486. 3064.  -     var from_pad = !!opts.from_pad, genre_id = opts.genre;
  5487. 3065.  -     Audio.loadPopular({update: true, genre: genre_id, from_pad: from_pad});
  5488. 3066.  -     return cancelEvent(ev);
  5489. 3067.  -   },
  5490. 3068.  -
  5491. 3069.  -   loadPerformer: function(opts, ev) {
  5492. 3070.  -     if (checkEvent(ev)) {
  5493. 3071.  -       return true;
  5494. 3072.  -     }
  5495. 3073.  -     opts = opts || {};
  5496. 3074.  -     var from_pad = !!opts.from_pad, oid = opts.oid, index = 'owner' + oid;
  5497. 3075.  -     Audio.loadFriendsAudios({id: oid, index: index, owner: true, from_pad: from_pad});
  5498. 3076.  -     return cancelEvent(ev);
  5499. 3077.  -   },
  5500. 3078.  -
  5501. 3079.  -   moreCatalog: function(opts) {
  5502. 3080.  -     opts = opts || {};
  5503. 3081.  -     var __cur = opts.from_pad ? window._pads && _pads.cur : window.cur,
  5504. 3082.  -         from_pad = !!opts.from_pad, obj = opts.el;
  5505. 3083.  -     if (hasClass(obj, 'audio_performer_shown')) {
  5506. 3084.  -       var height = getSize(ge('audio_more_performers'))[1];
  5507. 3085.  -       removeClass(obj, 'audio_performer_shown');
  5508. 3086.  -       hide('audio_more_performers');
  5509. 3087.  -       if (height > 300) {
  5510. 3088.  -         scrollToTop(0);
  5511. 3089.  -       }
  5512. 3090.  -     } else {
  5513. 3091.  -       if (ge('audio_more_performers')) {
  5514. 3092.  -         show('audio_more_performers')
  5515. 3093.  -         addClass(obj, 'audio_performer_shown');
  5516. 3094.  -         return false;
  5517. 3095.  -       }
  5518. 3096.  -       var exclude = [];
  5519. 3097.  -       var nodes = ge(__cur.popularPerformersId).childNodes;
  5520. 3098.  -       for (var i in nodes) {
  5521. 3099.  -         if (hasClass(nodes[i], 'audio_owner')) {
  5522. 3100.  -           exclude.push(intval(nodes[i].getAttribute('ref')));
  5523. 3101.  -         }
  5524. 3102.  -       }
  5525. 3103.  -       var query = {act: 'get_more_performers', offset: 4, exclude: exclude.join(','), genre: parseInt(__cur.genre)};
  5526. 3104.  -       if (from_pad) {
  5527. 3105.  -         query.from_pad = 1;
  5528. 3106.  -       }
  5529. 3107.  -       ajax.post('al_audio.php', query, {
  5530. 3108.  -         onDone: function(rows) {
  5531. 3109.  -           ge(__cur.popularPerformersId).appendChild(ce('div', {
  5532. 3110.  -             id: 'audio_more_performers',
  5533. 3111.  -             innerHTML: rows
  5534. 3112.  -           }));
  5535. 3113.  -           addClass(obj, 'audio_performer_shown');
  5536. 3114.  -         },
  5537. 3115.  -         showProgress: addClass.pbind(obj, 'audio_performer_loading'),
  5538. 3116.  -         hideProgress: removeClass.pbind(obj, 'audio_performer_loading')
  5539. 3117.  -       });
  5540. 3118.  -     }
  5541. 3119.  -   },
  5542. 3120.  -
  5543. 3121.  -   _eof: 1
  5544. 3122.  - }
  5545. 3123.  - try{stManager.done('audio.js');}catch(e){}
  5546. ------
Advertisement
Add Comment
Please, Sign In to add comment