Oppaitime's version of Gazelle
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

user_notifications.js 2.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. $(document).ready(function() {
  2. var skip = getSkippedPage();
  3. $('.noty-notification').each(function() {
  4. var $this = $(this);
  5. var type = $this.data('noty-type'),
  6. importance = $this.data('noty-importance'),
  7. id = $this.data('noty-id'),
  8. url = $this.data('noty-url');
  9. if (type != skip) {
  10. createNoty(type, id, $this.text(), url, importance);
  11. }
  12. $this.remove();
  13. });
  14. });
  15. function getSkippedPage() {
  16. var skip
  17. var url = {
  18. path: window.location.pathname.split('/').reverse()[0].split('.')[0],
  19. query: window.location.search.slice(1).split('&').reduce((a,b)=>Object.assign(a,{[b.split('=')[0]]:b.split('=')[1]}),{})
  20. };
  21. switch(url.path) {
  22. case "inbox":
  23. if (url.query.length == 0 || (url.query.length == 1 && url.query.hasOwnProperty('sort'))) {
  24. skip = "Inbox";
  25. }
  26. break;
  27. case "userhistory":
  28. if (url.query['action'] == "subscriptions") {
  29. skip = "Subscriptions";
  30. }
  31. if (url.query['action'] == "quote_notifications") {
  32. skip = "Quotes";
  33. }
  34. if (url.query['action'] == "subscribed_collages") {
  35. skip = "Collages";
  36. }
  37. break;
  38. case "user":
  39. if (url.query['action'] == "notify") {
  40. skip = "Torrents";
  41. }
  42. break;
  43. case "blog":
  44. if (url.query.length == 0) {
  45. skip = "Blog";
  46. }
  47. break;
  48. case "index":
  49. if (url.query.length == 0) {
  50. skip = "News";
  51. }
  52. break;
  53. case "staffpm":
  54. if (url.query.length == 0) {
  55. skip = "StaffPM";
  56. }
  57. break;
  58. default:
  59. break;
  60. }
  61. return skip;
  62. }
  63. function createNoty(type, id, message, url, importance) {
  64. var hideButtons = !url;
  65. noty({
  66. text: message,
  67. type: importance,
  68. layout: 'bottomRight',
  69. closeWith: ['click'],
  70. animation: {
  71. open: {height: 'toggle'},
  72. close: {height: 'toggle'},
  73. easing: 'swing',
  74. speed: 250
  75. },
  76. buttonElement : 'a',
  77. buttons: [
  78. {
  79. addClass: 'brackets noty_button_view' + (hideButtons ? ' hidden' : ''), text: 'View', href: url
  80. },
  81. {
  82. addClass: 'brackets noty_button_clear', text: 'Clear', onClick: function($noty) {
  83. $noty.close();
  84. clear(type, id);
  85. }
  86. },
  87. {
  88. addClass: 'brackets noty_button_close ', text: 'Hide', onClick: function($noty) {
  89. $noty.close();
  90. }
  91. },
  92. ]
  93. });
  94. }
  95. function clear(type, id) {
  96. $.ajax({
  97. type : "POST",
  98. url: "ajax.php?action=clear_user_notification",
  99. dataType: "json",
  100. data : {
  101. "type" : type,
  102. "id" : id
  103. }
  104. });
  105. }