2
0

main.js 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  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. /* Global collection helpers */
  46. Handlebars.registerHelper("rooms", function(){
  47. return Rooms.find({});
  48. });
  49. Handlebars.registerHelper('active', function(path) {
  50. return curPath() == path ? 'active' : '';
  51. });
  52. UI.registerHelper("formatTime", function(seconds) {
  53. var d = moment.duration(parseInt(seconds), 'seconds');
  54. return d.minutes() + ":" + ("0" + d.seconds()).slice(-2);
  55. });
  56. Template.registerHelper("rtime", function(date) {
  57. Session.get("time");
  58. if (date) {
  59. return moment(date).fromNow();
  60. }
  61. });
  62. var allAlertSub = undefined;
  63. var YTPlayer = undefined;
  64. var previewEndSongTimeout = undefined;
  65. var hpSound = undefined;
  66. var songsArr = [];
  67. var parts = location.href.split('/');
  68. var id = parts.pop();
  69. var type = id.toLowerCase();
  70. 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}}};
  71. function gup( name, url ) {
  72. if (!url) url = location.href;
  73. name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  74. var regexS = "[\\?&]"+name+"=([^&#]*)";
  75. var regex = new RegExp( regexS );
  76. var results = regex.exec( url );
  77. return results == null ? null : results[1];
  78. }
  79. var ban_interval = Meteor.setInterval(function() {
  80. var userId = Meteor.userId();
  81. if (userId !== undefined) {
  82. var userData = Meteor.user();
  83. if (localStorage.getItem("banned") === "true") {
  84. if (userData !== undefined && userData !== null && userData.punishments !== undefined && userData.punishments.ban !== undefined) {
  85. var ban = userData.punishments.ban;
  86. if (new Date(ban.bannedUntil).getTime() <= new Date().getTime()) {
  87. Meteor.call("isBanned", function(err, res) {
  88. if (res === false) {
  89. localStorage.setItem("banned", false);
  90. Meteor._reload.reload();
  91. }
  92. });
  93. }
  94. } else {
  95. localStorage.setItem("banned", false);
  96. Meteor._reload.reload();
  97. }
  98. } else {
  99. if (userData !== undefined && userData !== null && userData.punishments !== undefined && userData.punishments.ban !== undefined) {
  100. localStorage.setItem("banned", true);
  101. Meteor._reload.reload();
  102. }
  103. }
  104. }
  105. }, 1000);