2
0

main.js 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. Meteor.startup(function() {
  2. reCAPTCHA.config({
  3. publickey: '6LcVxg0TAAAAAE18vBiH00UAyaJggsmLm890SjZl'
  4. });
  5. Avatar.setOptions({
  6. fallbackType: "initials",
  7. defaultImageUrl: "http://static.boredpanda.com/blog/wp-content/uploads/2014/04/amazing-fox-photos-182.jpg",
  8. generateCSS: true,
  9. imageSizes: {
  10. 'header': 40
  11. }
  12. });
  13. });
  14. Deps.autorun(function() {
  15. Meteor.subscribe("queues");
  16. Meteor.subscribe("reports");
  17. Meteor.subscribe("chat");
  18. Meteor.subscribe("playlists");
  19. Meteor.subscribe("alerts");
  20. Meteor.subscribe("rooms");
  21. Meteor.subscribe("userData", Meteor.userId());
  22. });
  23. Handlebars.registerHelper("isAdmin", function(argument){
  24. if (Meteor.user() && Meteor.user().profile) {
  25. return Meteor.user().profile.rank === "admin";
  26. } else {
  27. return false;
  28. }
  29. });
  30. Handlebars.registerHelper("isModerator", function(argument){
  31. if (Meteor.user() && Meteor.user().profile && (Meteor.user().profile.rank === "admin" || Meteor.user().profile.rank === "moderator")) {
  32. return true;
  33. } else {
  34. return false;
  35. }
  36. });
  37. Handlebars.registerHelper("initials", function(argument){
  38. var user = Meteor.user();
  39. if (user !== undefined) {
  40. return user.profile.username[0].toUpperCase();
  41. } else {
  42. return "";
  43. }
  44. });
  45. Handlebars.registerHelper('active', function(path) {
  46. return curPath() == path ? 'active' : '';
  47. });
  48. UI.registerHelper("formatTime", function(seconds) {
  49. var d = moment.duration(parseInt(seconds), 'seconds');
  50. return d.minutes() + ":" + ("0" + d.seconds()).slice(-2);
  51. });
  52. Template.registerHelper("rtime", function(date) {
  53. Session.get("time");
  54. if (date) {
  55. return moment(date).fromNow();
  56. }
  57. });
  58. var allAlertSub = undefined;
  59. var YTPlayer = undefined;
  60. var SCPlayer = undefined;
  61. var previewEndSongTimeout = undefined;
  62. var hpSound = undefined;
  63. var songsArr = [];
  64. var parts = location.href.split('/');
  65. var id = parts.pop();
  66. var type = id.toLowerCase();
  67. curPath=function(){var c=window.location.pathname;var b=c.slice(0,-1);var a=c.slice(-1);if(b==""){return"/"}else{if(a=="/"){return b}else{return c}}};
  68. function gup( name, url ) {
  69. if (!url) url = location.href;
  70. name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  71. var regexS = "[\\?&]"+name+"=([^&#]*)";
  72. var regex = new RegExp( regexS );
  73. var results = regex.exec( url );
  74. return results == null ? null : results[1];
  75. }
  76. var ban_interval = Meteor.setInterval(function() {
  77. var userId = Meteor.userId();
  78. if (userId !== undefined) {
  79. var userData = Meteor.user();
  80. if (localStorage.getItem("banned") === "true") {
  81. if (userData !== undefined && userData !== null && userData.punishments !== undefined && userData.punishments.ban !== undefined) {
  82. var ban = userData.punishments.ban;
  83. if (new Date(ban.bannedUntil).getTime() <= new Date().getTime()) {
  84. Meteor.call("isBanned", function(err, res) {
  85. if (res === false) {
  86. localStorage.setItem("banned", false);
  87. Meteor._reload.reload();
  88. }
  89. });
  90. }
  91. } else {
  92. localStorage.setItem("banned", false);
  93. Meteor._reload.reload();
  94. }
  95. } else {
  96. if (userData !== undefined && userData !== null && userData.punishments !== undefined && userData.punishments.ban !== undefined) {
  97. localStorage.setItem("banned", true);
  98. Meteor._reload.reload();
  99. }
  100. }
  101. }
  102. }, 1000);