123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702 |
- var StationSubscription = undefined;
- var resizeSeekerbarInterval;
- Template.banned.onCreated(function() {
- if (Session.get("rTimeInterval") !== undefined) {
- Meteor.clearInterval(Session.get("rTimeInterval"))
- }
- Session.set("rTimeInterval", Meteor.setInterval(function() {
- Session.set("time", new Date().getTime());
- }, 10000));
- Session.set("ban", Meteor.user().punishments.ban);
- });
- Template.home.onCreated(function() {
- if (Session.get("minterval") !== undefined) {
- Meteor.clearInterval(Session.get("minterval"));
- }
- if (resizeSeekerbarInterval !== undefined) {
- Meteor.clearInterval(resizeSeekerbarInterval);
- resizeSeekerbarInterval = undefined;
- }
- if (StationSubscription !== undefined) {
- StationSubscription.stop();
- }
- Session.set("type", undefined);
- });
- Template.loginRegister.onCreated(function() {
- Session.set("github", true);
- Accounts.onLoginFailure(function() {
- if (Session.get("github") === true) {
- var $toastContent = $('<span><strong>Oh Snap!</strong> Something went wrong when trying to log in/register with GitHub. Maybe an account with that username is already registered?</span>');
- Materialize.toast($toastContent, 8000);
- }
- });
- });
- Template.admin.onCreated(function() {
- Meteor.subscribe("allAlerts");
- });
- Template.feedback.onCreated(function(){
- Meteor.subscribe("feedback");
- })
- Template.profile.onCreated(function() {
- var parts = Router.current().url.split('/');
- var username = parts.pop();
- Session.set("loaded", false);
- Meteor.subscribe("userProfiles", username.toLowerCase(), function() {
- if (Meteor.users.find({"profile.usernameL": username.toLowerCase()}).count() === 0) {
- window.location = "/";
- } else {
- var data = Meteor.users.findOne({"profile.usernameL": username.toLowerCase()});
- Session.set("real_name", data.profile.realname);
- Session.set("username", data.profile.username);
- Session.set("first_joined", data.createdAt);
- Session.set("rank", data.profile.rank);
- Session.set("songs_requested", data.profile.statistics.songsRequested);
- Session.set("liked", data.profile.liked);
- Session.set("disliked", data.profile.disliked);
- Session.set("loaded", true);
- }
- });
- });
- Template.queues.onCreated(function() {
- var tag = document.createElement("script");
- tag.src = "https://www.youtube.com/iframe_api";
- var firstScriptTag = document.getElementsByTagName('script')[0];
- firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
- YTPlayer = undefined;
- $(document).keydown(function(evt){
- if (evt.keyCode==83 && (evt.ctrlKey)){
- evt.preventDefault();
- if (Session.get("editing") === true) {
- $("#save-song-button").click();
- }
- }
- });
- });
- Template.manageStation.onCreated(function() {
- var tag = document.createElement("script");
- tag.src = "https://www.youtube.com/iframe_api";
- var firstScriptTag = document.getElementsByTagName('script')[0];
- firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
- YTPlayer = undefined;
- $(document).keydown(function(evt){
- if (evt.keyCode==83 && (evt.ctrlKey)){
- evt.preventDefault();
- if (Session.get("editing") === true) {
- $("#save-song-button").click();
- }
- }
- });
- });
- Template.manageSongs.onCreated(function() {
- Session.set("showNoGenres", false);
- Session.set("showGenres", true);
- var tag = document.createElement("script");
- tag.src = "https://www.youtube.com/iframe_api";
- var firstScriptTag = document.getElementsByTagName('script')[0];
- firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
- YTPlayer = undefined;
- $(document).keydown(function(evt){
- if (evt.keyCode==83 && (evt.ctrlKey)){
- evt.preventDefault();
- if (Session.get("editing") === true) {
- $("#save-song-button").click();
- }
- }
- });
- });
- Template.room.onCreated(function () {
- Chat.after.find(function(userId, selector) {
- if (selector.type === "global") {
- if (!$("#global-chat-tab").hasClass("active")) {
- $("#global-chat-tab").addClass("unread-messages");
- }
- } else if(selector.type === Session.get("type")) {
- if (!$("#chat-tab").hasClass("active")) {
- $("#chat-tab").addClass("unread-messages");
- }
- }
- });
- Session.set("reportSong", false);
- Session.set("reportTitle", false);
- Session.set("reportAuthor", false);
- Session.set("reportDuration", false);
- Session.set("reportAudio", false);
- Session.set("reportAlbumart", false);
- Session.set("reportOther", false);
- Session.set("si_or_pl", "singleVideo");
- Session.set("editingSong", false);
- var parts = location.href.split('/');
- var id = parts.pop();
- var type = id.toLowerCase();
- if (resizeSeekerbarInterval !== undefined) {
- Meteor.clearInterval(resizeSeekerbarInterval);
- resizeSeekerbarInterval = undefined;
- }
- YTPlayer = undefined;
- Session.set("videoHidden", false);
- var tag = document.createElement("script");
- tag.src = "https://www.youtube.com/iframe_api";
- var firstScriptTag = document.getElementsByTagName('script')[0];
- firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
- Session.set("singleVideo", true);
- var currentSong = undefined;
- var currentSongR = undefined;
- function getTimeElapsed() {
- var type = Session.get("type");
- if (currentSong !== undefined) {
- var room = Rooms.findOne({type: type});
- if (room !== undefined) {
- return Date.now() - currentSong.started - room.timePaused;
- }
- }
- return 0;
- }
- function getSongInfo(songData){
- Session.set("title", songData.title);
- Session.set("artist", songData.artist);
- Session.set("id", songData.id);
- $("#song-img").attr("src", songData.img);
- Session.set("duration", parseInt(songData.duration));
- var d = moment.duration(parseInt(songData.duration), 'seconds');
- $("#time-total").text(d.minutes() + ":" + ("0" + d.seconds()).slice(-2));
- Session.set("timeFormat", d.minutes() + ":" + ("0" + d.seconds()).slice(-2));
- document.title = Session.get("title") + " - " + Session.get("artist") + " - Musare";
- }
- function resizeSeekerbar() {
- if (Session.get("state") === "playing") {
- $(".seeker-bar").width(((getTimeElapsed() / 1000) / Session.get("duration") * 100) + "%");
- }
- }
- function startSong() {
- $("#time-elapsed").text("0:00");
- $("#vote-skip").attr("disabled", false);
- if (currentSong !== undefined) {
- if (YTPlayer !== undefined && YTPlayer.stopVideo !== undefined) YTPlayer.stopVideo();
- var volume = localStorage.getItem("volume") || 20;
- $("#volume_slider").val(volume);
- $("#player").show();
- function loadVideo() {
- if (!Session.get("YTLoaded")) {
- Session.set("loadVideoTimeout", Meteor.setTimeout(function () {
- loadVideo();
- }, 500));
- } else {
- if (YTPlayer === undefined) {
- if (YT !== undefined && YT !== null && YT.Player !== undefined) {
- YTPlayer = new YT.Player("player", {
- height: 270,
- width: 480,
- videoId: currentSong.id,
- playerVars: {controls: 0, iv_load_policy: 3, rel: 0, showinfo: 0},
- events: {
- 'onReady': function (event) {
- if (currentSong.skipDuration === undefined) {
- currentSong.skipDuration = 0;
- }
- event.target.seekTo(Number(currentSong.skipDuration) + getTimeElapsed() / 1000);
- event.target.playVideo();
- event.target.setVolume(volume);
- function recursion() {
- Meteor.setTimeout(function() {
- if (event.target.getPlayerState() === 1 && Session.get("state") === "playing") {
- event.target.seekTo(Number(currentSong.skipDuration) + getTimeElapsed() / 1000);
- } else {
- recursion();
- }
- }, 200);
- }
- recursion();
- resizeSeekerbar();
- },
- 'onStateChange': function (event) {
- if (Session.get("YTLoaded")) {
- if (event.data == YT.PlayerState.PAUSED && Session.get("state") === "playing") {
- event.target.seekTo(Number(currentSong.skipDuration) + getTimeElapsed() / 1000);
- event.target.playVideo();
- }
- if (event.data == YT.PlayerState.PLAYING && Session.get("state") === "paused") {
- event.target.seekTo(Number(currentSong.skipDuration) + getTimeElapsed() / 1000);
- event.target.pauseVideo();
- }
- }
- }
- }
- });
- } else {
- setTimeout(function() {
- startSong();
- }, 500);
- }
- } else {
- YTPlayer.loadVideoById(currentSong.id);
- if (currentSong.skipDuration === undefined) {
- currentSong.skipDuration = 0;
- }
- YTPlayer.seekTo(Number(currentSong.skipDuration) + getTimeElapsed() / 1000);
- $("#vote-skip").removeClass("disabled");
- }
- Session.set("pauseVideo", false);
- getSongInfo(currentSong);
- }
- }
- loadVideo();
- }
- }
- Session.set("loaded", false);
- Meteor.subscribe("rooms", function() {
- var parts = location.href.split('/');
- var id = parts.pop();
- var type = id.toLowerCase();
- Session.set("type", type);
- if (Rooms.find({type: type}).count() !== 1) {
- window.location = "/";
- } else {
- StationSubscription = Meteor.subscribe(type);
- Session.set("loaded", true);
- Session.set("minterval", Meteor.setInterval(function () {
- var room = Rooms.findOne({type: type});
- if (room !== undefined) {
- if (room.state === "paused" || Session.get("pauseVideo")) {
- Session.set("state", "paused");
- // TODO Fix issue where sometimes nothing loads with the YT is not defined error. The error points to around this.
- if (YTPlayer !== undefined && YTPlayer.getPlayerState !== undefined && YTPlayer.getPlayerState() === 1) {
- YTPlayer.pauseVideo();
- }
- } else {
- Session.set("state", "playing");
- if (YTPlayer !== undefined && YTPlayer.getPlayerState !== undefined && YTPlayer.getPlayerState() !== 1) {
- YTPlayer.playVideo();
- }
- }
- }
- if (currentSongR === undefined || room.currentSong.started !== currentSongR.started) {
- Session.set("previousSong", currentSong);
- currentSongR = room.currentSong;
- currentSong = room.currentSong.song;
- currentSong.started = room.currentSong.started;
- Session.set("currentSong", currentSong);
- Meteor.clearTimeout(Session.get("loadVideoTimeout"));
- startSong();
- }
- if (currentSong !== undefined) {
- if (room !== undefined) {
- var duration = (Date.now() - currentSong.started - room.timePaused) / 1000;
- var song_duration = currentSong.duration;
- if (song_duration <= duration) {
- Session.set("pauseVideo", true);
- } else if (Session.get("pauseVideo") === true) {
- Session.set("pauseVideo", false);
- }
- var d = moment.duration(duration, 'seconds');
- if (Session.get("state") === "playing") {
- $("#time-elapsed").text(d.minutes() + ":" + ("0" + d.seconds()).slice(-2));
- }
- }
- }
- }, 100));
- resizeSeekerbarInterval = Meteor.setInterval(function () {
- resizeSeekerbar();
- }, 500)
- }
- });
- Meteor.setTimeout(function(){
- $("#playlist-slideout").on("click", function(){
- if($("#chat-slide-out").css("right") === "0px"){
- $("#chat-slideout").sideNav("hide");
- }
- else if($("#users-slide-out").css("right") === "0px"){
- $("#users-slideout").sideNav("hide");
- }
- var marginRightWidth = ($(document).width() - $(".container").width()) / 2 + "px";
- $(".room-container").css("margin-right", "370px")
- if($("#playlist-slide-out").css("right") === "0px"){
- $(".room-container").css("margin-right", marginRightWidth);
- }
- });
- $("#chat-slideout").on("click", function(){
- if($("#playlist-slide-out").css("right") === "0px"){
- $("#playlist-slideout").sideNav("hide");
- }
- else if($("#users-slide-out").css("right") === "0px"){
- $("#users-slideout").sideNav("hide");
- }
- var marginRightWidth = ($(document).width() - $(".container").width()) / 2 + "px";
- $(".chat-ul").scrollTop(1000000);
- $(".room-container").css("margin-right", "370px")
- if($("#chat-slide-out").css("right") === "0px"){
- $(".room-container").css("margin-right", marginRightWidth);
- }
- });
- $("#users-slideout").on("click", function(){
- if($("#playlist-slide-out").css("right") === "0px"){
- $("#playlist-slideout").sideNav("hide");
- }
- else if($("#chat-slide-out").css("right") === "0px"){
- $("#chat-slideout").sideNav("hide");
- }
- var marginRightWidth = ($(document).width() - $(".container").width()) / 2 + "px";
- $(".room-container").css("margin-right", "370px")
- if($("#users-slide-out").css("right") === "0px"){
- $(".room-container").css("margin-right", marginRightWidth);
- }
- });
- $("body").on("click", function(e){
- });
- $(window).on("resize", function(){
- var marginRightWidth = ($(document).width() - $(".container").width()) / 2 + "px";
- $(".container").css("margin-right", marginRightWidth);
- })
- }, 1000);
- });
- Template.communityStation.onCreated(function () {
- Chat.after.find(function(userId, selector) {
- if (selector.type === "global") {
- if (!$("#global-chat-tab").hasClass("active")) {
- $("#global-chat-tab").addClass("unread-messages");
- }
- }
- });
- var parts = location.href.split('/');
- var id = parts.pop();
- var name = id.toLowerCase();
- if (resizeSeekerbarInterval !== undefined) {
- Meteor.clearInterval(resizeSeekerbarInterval);
- resizeSeekerbarInterval = undefined;
- }
- YTPlayer = undefined;
- Session.set("videoHidden", false);
- var tag = document.createElement("script");
- tag.src = "https://www.youtube.com/iframe_api";
- var firstScriptTag = document.getElementsByTagName('script')[0];
- firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
- Session.set("singleVideo", true);
- var currentSong = undefined;
- var currentSongR = undefined;
- function getTimeElapsed() {
- var name = Session.get("CommunityStationName");
- if (currentSong !== undefined) {
- var room = CommunityStations.findOne({name: name});
- if (room !== undefined) {
- return Date.now() - currentSong.started - room.timePaused;
- }
- }
- return 0;
- }
- function getSongInfo(songData){
- Session.set("title", songData.title);
- Session.set("id", songData.id);
- Session.set("duration", parseInt(songData.duration));
- var d = moment.duration(parseInt(songData.duration), 'seconds');
- $("#time-total").text(d.minutes() + ":" + ("0" + d.seconds()).slice(-2));
- Session.set("timeFormat", d.minutes() + ":" + ("0" + d.seconds()).slice(-2));
- document.title = Session.get("title") + " - Musare";
- }
- function resizeSeekerbar() {
- if (Session.get("state") === "playing") {
- $(".seeker-bar").width(((getTimeElapsed() / 1000) / Session.get("duration") * 100) + "%");
- }
- }
- function startSong() {
- $("#time-elapsed").text("0:00");
- $("#vote-skip").attr("disabled", false);
- if (currentSong !== undefined) {
- if (YTPlayer !== undefined && YTPlayer.stopVideo !== undefined && YTPlayer.getPlayerState() === YT.PlayerState.PLAYING) YTPlayer.stopVideo();
- var volume = localStorage.getItem("volume") || 20;
- $("#volume_slider").val(volume);
- $("#player").show();
- function loadVideo() {
- if (!Session.get("YTLoaded")) {
- Session.set("loadVideoTimeout", Meteor.setTimeout(function () {
- loadVideo();
- }, 500));
- } else {
- if (YTPlayer === undefined) {
- if (YT !== undefined && YT !== null && YT.Player !== undefined) {
- YTPlayer = new YT.Player("player", {
- height: 270,
- width: 480,
- videoId: currentSong.id,
- playerVars: {controls: 0, iv_load_policy: 3, rel: 0, showinfo: 0},
- events: {
- 'onReady': function (event) {
- event.target.seekTo(getTimeElapsed() / 1000);
- event.target.playVideo();
- event.target.setVolume(volume);
- function recursion() {
- Meteor.setTimeout(function() {
- if (event.target.getPlayerState() === 1 && Session.get("state") === "playing") {
- event.target.seekTo(getTimeElapsed() / 1000);
- } else {
- recursion();
- }
- }, 200);
- }
- recursion();
- resizeSeekerbar();
- },
- 'onStateChange': function (event) {
- if (Session.get("YTLoaded")) {
- if (event.data == YT.PlayerState.PAUSED && Session.get("state") === "playing" && !Session.get("noCurrentSong")) {
- event.target.seekTo(getTimeElapsed() / 1000);
- event.target.playVideo();
- }
- if (event.data == YT.PlayerState.PLAYING && Session.get("state") === "paused") {
- event.target.seekTo(getTimeElapsed() / 1000);
- event.target.pauseVideo();
- }
- }
- }
- }
- });
- } else {
- setTimeout(function() {
- startSong();
- }, 500);
- }
- } else {
- YTPlayer.loadVideoById(currentSong.id);
- YTPlayer.seekTo(getTimeElapsed() / 1000);
- $("#vote-skip").removeClass("disabled");
- }
- Session.set("pauseVideo", false);
- getSongInfo(currentSong);
- }
- }
- loadVideo();
- }
- }
- Session.set("loaded", false);
- Meteor.subscribe("community_stations", function() {
- var parts = location.href.split('/');
- var id = parts.pop();
- var name = id.toLowerCase();
- Session.set("CommunityStationName", name);
- if (CommunityStations.find({name: name}).count() !== 1) {
- window.location = "/";
- } else {
- StationSubscription = Meteor.subscribe("pr_" + name);
- Session.set("loaded", true);
- Session.set("minterval", Meteor.setInterval(function () {
- var room = CommunityStations.findOne({name: name});
- if (room !== undefined) {
- if (room.state === "paused" || Session.get("pauseVideo")) {
- Session.set("state", "paused");
- // TODO Fix issue where sometimes nothing loads with the YT is not defined error. The error points to around this.
- if (YTPlayer !== undefined && YTPlayer.getPlayerState !== undefined && YTPlayer.getPlayerState() === 1) {
- YTPlayer.pauseVideo();
- }
- } else {
- Session.set("state", "playing");
- if (YTPlayer !== undefined && YTPlayer.getPlayerState !== undefined && YTPlayer.getPlayerState() !== 1 && !Session.get("noCurrentSong")) {
- YTPlayer.playVideo();
- }
- }
- }
- if (currentSongR === undefined || room.currentSong.started !== currentSongR.started) {
- Session.set("previousSong", currentSong);
- currentSongR = room.currentSong;
- if (!_.isEqual(currentSongR, {})) {
- Session.set("noCurrentSong", false);
- currentSong = room.currentSong.song;
- currentSong.started = room.currentSong.started;
- Session.set("currentSong", currentSong);
- Meteor.clearTimeout(Session.get("loadVideoTimeout"));
- startSong();
- } else {
- if (YTPlayer !== undefined && YTPlayer.stopVideo !== undefined && YTPlayer.getPlayerState() === YT.PlayerState.PLAYING) YTPlayer.stopVideo();
- document.title = "Musare";
- Session.set("noCurrentSong", true);
- }
- }
- if (currentSong !== undefined && !Session.get("noCurrentSong")) {
- if (room !== undefined) {
- var duration = (Date.now() - currentSong.started - room.timePaused) / 1000;
- var song_duration = currentSong.duration;
- if (song_duration <= duration) {
- Session.set("pauseVideo", true);
- } else if (Session.get("pauseVideo") === true) {
- Session.set("pauseVideo", false);
- }
- var d = moment.duration(duration, 'seconds');
- if (Session.get("state") === "playing") {
- $("#time-elapsed").text(d.minutes() + ":" + ("0" + d.seconds()).slice(-2));
- }
- }
- }
- }, 100));
- resizeSeekerbarInterval = Meteor.setInterval(function () {
- resizeSeekerbar();
- }, 500)
- }
- });
- Meteor.setTimeout(function(){
- $("#playlist-slideout").on("click", function(){
- if($("#chat-slide-out").css("right") === "0px"){
- $("#chat-slideout").sideNav("hide");
- }
- else if($("#users-slide-out").css("right") === "0px"){
- $("#users-slideout").sideNav("hide");
- }
- else if($("#allowed-slide-out").css("right") === "0px"){
- $("#allowed-slideout").sideNav("hide");
- }
- else if($("#playlists-slide-out").css("right") === "0px"){
- $("#playlists-slideout").sideNav("hide");
- }
- var marginRightWidth = ($(document).width() - $(".container").width()) / 2 + "px";
- $(".room-container").css("margin-right", "370px")
- if($("#playlist-slide-out").css("right") === "0px"){
- $(".room-container").css("margin-right", marginRightWidth);
- }
- });
- $("#chat-slideout").on("click", function(){
- if($("#playlist-slide-out").css("right") === "0px"){
- $("#playlist-slideout").sideNav("hide");
- }
- else if($("#users-slide-out").css("right") === "0px"){
- $("#users-slideout").sideNav("hide");
- }
- else if($("#allowed-slide-out").css("right") === "0px"){
- $("#allowed-slideout").sideNav("hide");
- }
- else if($("#playlists-slide-out").css("right") === "0px"){
- $("#playlists-slideout").sideNav("hide");
- }
- var marginRightWidth = ($(document).width() - $(".container").width()) / 2 + "px";
- $(".chat-ul").scrollTop(1000000);
- $(".room-container").css("margin-right", "370px")
- if($("#chat-slide-out").css("right") === "0px"){
- $(".room-container").css("margin-right", marginRightWidth);
- }
- });
- $("#users-slideout").on("click", function(){
- if($("#playlist-slide-out").css("right") === "0px"){
- $("#playlist-slideout").sideNav("hide");
- }
- else if($("#chat-slide-out").css("right") === "0px"){
- $("#chat-slideout").sideNav("hide");
- }
- else if($("#allowed-slide-out").css("right") === "0px"){
- $("#allowed-slideout").sideNav("hide");
- }
- else if($("#playlists-slide-out").css("right") === "0px"){
- $("#playlists-slideout").sideNav("hide");
- }
- var marginRightWidth = ($(document).width() - $(".container").width()) / 2 + "px";
- $(".room-container").css("margin-right", "370px")
- if($("#users-slide-out").css("right") === "0px"){
- $(".room-container").css("margin-right", marginRightWidth);
- }
- });
- $("#allowed-slideout").on("click", function(){
- if($("#playlist-slide-out").css("right") === "0px"){
- $("#playlist-slideout").sideNav("hide");
- }
- else if($("#chat-slide-out").css("right") === "0px"){
- $("#chat-slideout").sideNav("hide");
- }
- else if($("#users-slide-out").css("right") === "0px"){
- $("#users-slideout").sideNav("hide");
- }
- else if($("#playlists-slide-out").css("right") === "0px"){
- $("#playlists-slideout").sideNav("hide");
- }
- var marginRightWidth = ($(document).width() - $(".container").width()) / 2 + "px";
- $(".room-container").css("margin-right", "370px")
- if($("#allowed-slide-out").css("right") === "0px"){
- $(".room-container").css("margin-right", marginRightWidth);
- }
- });
- $("#playlists-slideout").on("click", function(){
- if($("#playlist-slide-out").css("right") === "0px"){
- $("#playlist-slideout").sideNav("hide");
- }
- else if($("#chat-slide-out").css("right") === "0px"){
- $("#chat-slideout").sideNav("hide");
- }
- else if($("#users-slide-out").css("right") === "0px"){
- $("#users-slideout").sideNav("hide");
- }
- else if($("#allowed-slide-out").css("right") === "0px"){
- $("#allowed-slideout").sideNav("hide");
- }
- var marginRightWidth = ($(document).width() - $(".container").width()) / 2 + "px";
- $(".room-container").css("margin-right", "370px")
- if($("#playlists-slide-out").css("right") === "0px"){
- $(".room-container").css("margin-right", marginRightWidth);
- }
- });
- $("body").on("click", function(e){
- });
- $(window).on("resize", function(){
- var marginRightWidth = ($(document).width() - $(".container").width()) / 2 + "px";
- $(".container").css("margin-right", marginRightWidth);
- })
- }, 1000);
- });
- Template.settings.onCreated(function() {
- $(document).ready(function() {
- var user = Meteor.user();
- function initSettings() {
- if (user !== undefined) {
- if (user.profile.settings && user.profile.settings.showRating === true) {
- function setChecked() {
- $("#showRating").prop("checked", true);
- if (!$("#showRating").prop("checked")) {
- Meteor.setTimeout(function() {
- setChecked();
- }, 100);
- }
- }
- setChecked();
- }
- } else {
- Meteor.setTimeout(function() {
- initSettings();
- }, 500);
- }
- }
- initSettings();
- });
- });
|