Guest User

Untitled

a guest
Mar 19th, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.22 KB | None | 0 0
  1. function player(track, track_name) {
  2. var src = track.getAttribute('about');
  3. $('#player-main').attr('src', src);
  4. document.getElementById('player-main').play();
  5. toastr.success(track_name, 'Сейчас играет', {timeOut: 1000})
  6. }
  7.  
  8. function remove_playlist(obj, playlist_name) {
  9. if ($('#playlist_ajax_button').attr('value') == 'remove'){
  10. $.ajax({
  11. url: '/playlist_remove',
  12. method: 'GET',
  13. data: {'type': 'playlist_remove', 'name': playlist_name},
  14. success: function(data){
  15. if (data == 'remove ok'){
  16. var button_playlist = $('#playlist_ajax_button');
  17. toastr.warning(playlist_name, 'Удалено');
  18. button_playlist.removeClass( );
  19. button_playlist.addClass('btn');
  20. button_playlist.addClass('btn-primary');
  21. button_playlist.text('Добавить');
  22. button_playlist.attr('value', 'add');
  23. }
  24. }
  25. });
  26. }else if($('#playlist_ajax_button').attr('value') == 'add'){
  27. $.ajax({
  28. url: '/playlist_remove',
  29. method: 'GET',
  30. data: {'type': 'playlist_add', 'name': playlist_name},
  31. success: function(data){
  32. if (data == 'add ok'){
  33. var button_playlist = $('#playlist_ajax_button');
  34. toastr.success(playlist_name, 'Добавлено');
  35. button_playlist.removeClass( );
  36. button_playlist.addClass('btn');
  37. button_playlist.addClass('btn-danger');
  38. button_playlist.text('Удалить');
  39. button_playlist.attr('value', 'remove');
  40. }
  41. }
  42. });
  43. }
  44. }
  45. function setLocation(curLoc){
  46. try {
  47. history.pushState(null, null, curLoc);
  48. return;
  49. } catch(e) {}
  50. location.hash = '#' + curLoc;
  51. }
  52. function ajax_url(url_obj) {
  53. event.preventDefault();
  54. var href = url_obj.getAttribute('href');
  55. console.log(href);
  56. setLocation(href);
  57. $(".base-main-content").load(href + ' .for-ajax-load');
  58. $.ajax({
  59. url: href,
  60. success: function(data){
  61. var newTitle = $(data).filter('title').text();
  62. document.title = newTitle;
  63. }
  64. });
  65.  
  66. }
Add Comment
Please, Sign In to add comment