Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ! function(a, b) {
- function d() {
- return b.browser.mobile
- }
- function e() {
- return b.browser.mobile
- }
- var f = {};
- f.chat = {}, f.player = {}, f.room = {}, f.profile = {}, f.playlist = {}, f.global = {}, f.help = {}, f.helpers = {}, f.playlist.containerElCreateApp = !1, f.bindedDocument = !1, f.users = {}, f.user = {};
- var g = {
- config: {}
- };
- a.DUBTRACK_API_URL || (a.DUBTRACK_API_URL = "https://api.dubtrack.fm"), a.Dubtrack = {
- init: function() {
- if (!Dubtrack.initialized) {
- Dubtrack.initialized = !0;
- var a = Dubtrack.helpers.cookie.get("dubtrack-hide-images");
- a && "hide" == a && (Dubtrack.HideImages = !0), soundManager.waitForWindowLoad = !0, Dubtrack.helpers.loadDependencies(function() {
- Dubtrack.app = new DubtrackRoute, Backbone.history.start({
- pushState: !0
- })
- })
- }
- },
- player_initialized: !1,
- initialized: !1,
- chat: {},
- player: {},
- room: {},
- roomList: {},
- layout: {},
- users: {},
- user: {},
- session: {},
- views: {},
- Model: {},
- Collection: {},
- View: {},
- HideImages: !1,
- $: {
- body: b("body"),
- mainSectionEl: b("section#main-section")
- },
- config: {
- apiUrl: a.DUBTRACK_API_URL,
- urls: {
- mediaBaseUrl: "https://dubtrack-fm.s3.amazonaws.com",
- commentsDubs: "/comments/:id/dubs",
- commentsFlag: "/comments/:id/flag",
- room: "/room",
- roomSearch: "/room/term/:term",
- roomImage: "/room/:id/image",
- roomUsers: "/room/{id}/users",
- roomBanUsers: "/room/:id/users/ban",
- roomMuteUsers: "/room/:id/users/mute",
- roomStaffUsers: "/room/:id/users/staff",
- roomBeacon: "/room/beacon/:id/:userid",
- roomQueue: "/room/{id}/playlist",
- roomQueueDetails: "/room/:id/playlist/details",
- roomHistory: "/room/:id/playlist/history",
- roomLockQueue: "/room/:id/lockQueue",
- userQueuePause: "/room/:id/queue/pause",
- dubs: "/dubs",
- user: "/user",
- updateUsername: "/user/updateUsername",
- queryUsernameAvailability: "/user/query/availabilty",
- session: "/auth/session",
- playlist: "/playlist",
- playlistUpdate: "/playlist/:id",
- playlistOrder: "/playlist/:id/order",
- playlistSong: "/playlist/:id/songs",
- getSoundCloudPlaylists: "/playlist/soundcloud",
- importYoutubePlaylist: "/playlist/import/youtube",
- importSoundcloudPlaylist: "/playlist/import/soundcloud",
- song: "/song",
- songComments: "/song/:id/comments",
- chat: "/chat/:id",
- deleteChat: "/chat/:id/:chatid",
- roomPlaylist: "/room/:id/playlist",
- roomQueuePlaylist: "/room/:id/queueplaylist/:playlistid",
- roomPlaylistActive: "/room/:id/playlist/active",
- dubsPlaylistActive: "/room/:id/playlist/:playlistid/dubs",
- kickUser: "/chat/kick/:roomid/user/:id",
- banUser: "/chat/ban/:roomid/user/:id",
- muteUser: "/chat/mute/:roomid/user/:id",
- setModUser: "/chat/52d1ce33c38a06510c000001/:roomid/user/:id",
- setDJUser: "/chat/5615feb8e596154fc2000002/:roomid/user/:id",
- setManagerUser: "/chat/5615fd84e596150061000003/:roomid/user/:id",
- setVIPUser: "/chat/5615fe1ee596154fc2000001/:roomid/user/:id",
- setOwnerUser: "/chat/5615fa9ae596154a5c000000/:roomid/user/:id",
- setRoomDJUser: "/chat/564435423f6ba174d2000001/:roomid/user/:id",
- skipSong: "/chat/skip/:id/:songid",
- userQueue: "/user/session/room/:id/queue",
- userQueueOrder: "/user/session/room/:id/queue/order",
- roomUserQueueOrder: "/room/:id/queue/order",
- userFollow: "/user/:id/follows",
- userFollowing: "/user/:id/following",
- userImage: "/user/:id/image",
- search: "/search",
- messages: "/message",
- messages_items: "/message/:id",
- messages_news: "/message/new",
- messages_read: "/message/:id/read"
- },
- keys: {
- pubunub: "sub-c-2b40f72a-6b59-11e3-ab46-02ee2ddab7fe",
- soundcloud: "a7d642eb62cd95e8619987508f634859"
- },
- player: {
- youtube: {
- youtubeVars: {
- controls: 0,
- rel: 0,
- showinfo: 0,
- autoplay: 1,
- output: "embed",
- wmode: "transparent",
- playsinline: 1,
- iv_load_policy: 3,
- html5: 1,
- is_html5_mobile_device: 1,
- disablekb: 1,
- frameborder: 0
- },
- playerParams: {
- controls: 0,
- rel: 0,
- showinfo: 0,
- autoplay: 0,
- modestbranding: 1,
- output: "embed",
- wmode: "transparent",
- playsinline: 1,
- iv_load_policy: 3,
- html5: 1,
- is_html5_mobile_device: 1,
- disablekb: 1,
- frameborder: 0
- }
- },
- playerWidth: "100%",
- playerHeight: "100%",
- playerEmbedWidth: "100%",
- playerEmbedHeight: 360
- },
- loadingEls: '<div class="spinner"><div class="bounce1"></div><div class="bounce2"></div><div class="bounce3"></div></div>',
- urlPLayerPlaylist: "/room/playlist/get/idroom/",
- urlRoomInfo: "/api/rooms/load_room_info/idroom/",
- chatEndPointUrl: "/room/chat/send/idroom/",
- playerVoteUrl: "/room/main/vote/idroom/",
- browserPlaylistDeatilsUrl: "/api/playlist/getPlaylist/id/",
- roomJoin: "/room/main/join/idroom/",
- roomJoinInco: "/api/rooms/joinIncognito/idroom/",
- roomLeave: "/room/main/removeUser",
- roomListUrl: "/api/rooms/get_rooms/iduser/0",
- browserSearchUrl: "/api/youtube/",
- dubsUrl: "/api/dubs/api",
- dubsGetSong: "/api/dubs/viewapi/url_sh/",
- searchDubsUrl: "/api/dubs/apiSearch",
- userProfileUrl: "/api/users/get_user_info",
- saveDubComment: "/api/dubs/save_comment/",
- reportSpamComment: "/api/dubs/spam_comment/",
- deleteComment: "/api/dubs/delete_comment/id/",
- getAvatarsRoom: "/api/rooms/loadUsers/idroom/",
- getRolesRoom: "/api/rooms/get_room_roles/idroom/",
- getAvatarUrl: "/api/users/get/details/1/id/",
- getWallPost: "/api/users/get_wall_post/id/",
- dubWallPost: "/api/dubs/dub_wall_comment/",
- saveWall: "/user/save_wall/",
- deleteWall: "/user/delete",
- getPlaylistPublic: "/api/playlist/getListPublic",
- getFollowing: "/api/users/follows/",
- fetchNotification: "/api/users/notification_feed/page/",
- addQueue: "/room/playlist/add/idroom/",
- saveUserId: "/api/users/updatedt",
- checkusername: "/api/users/check_usernamedt",
- roomUpdate: "/room/main/update",
- roomCreate: "/room/main/create",
- followUrl: "/api/users/follow/",
- unfollowUrl: "/api/users/unfollow/",
- getWallPostsUrl: "/api/users/get_wall_posts/id/",
- addToPlaylist: "/api/playlist/addMedia",
- removeFromPlaylist: "/api/playlist/deleteMedia",
- changePlaylistType: "/api/playlist/change_playlist_type",
- queuePlaylist: "/room/playlist/addPlaylist",
- removeFromQueue: "/room/playlist/deleteMedia/",
- addPlaylist: "/api/playlist/add",
- removePlaylist: "/api/playlist/delete",
- getQueueUrl: "/room/playlist/getListUser/",
- mytracksUrl: "/dubtrack/music/get",
- updateMytracksUrl: "/dubtrack/music/update",
- deleteMytracksUrl: "/dubtrack/music/delete",
- getMusicTracks: "/dubtrack/music/getMusic/userid/",
- roomHistory: "/room/playlist/getHistory/",
- getQueuePlace: "/room/playlist/shownext/",
- notificationsCountUrl: "/api/users/get_notification_feed_count",
- getFriendsRoomUrl: "/api/rooms/getRoomFriends/idroom/",
- getModsRoomUrl: "/api/rooms/getRoomMods/idroom/",
- getFriendsGlobalUrl: "/api/users/get_friends",
- getChatHistory: "/api/rooms/get_history/idroom/",
- sendMessageUrl: "/user/sendmessage",
- getMessagesUrl: "",
- globalBaseUrl: "http://dubtrack.fm/",
- mainRoomContainer: b("#main_room"),
- playerMainContainer: b("#main_player"),
- playerContainer: b("#main_player").find("div.player_container"),
- playerConrols: b("#room_info"),
- gaId: "UA-31613628-1",
- chatContainer: b("div#chat"),
- roomListContainer: "roomListContainer",
- dubsListContainer: "dubsListContainer",
- mainSectionEl: b("section#main-section"),
- avatarContEl: b("div#avatarCont")
- },
- els: {
- mainLoading: null,
- init: function() {
- this.mainLoading = b("#main-loading").show(), this.mainLoadingText = this.mainLoading.find(".loading-text"), this.mainLoadingText.html(dubtrack_lang.global.loading)
- },
- displayloading: function(a) {
- a || (a = dubtrack_lang.global.loading), this.mainLoadingText.html(a), this.mainLoading.show()
- },
- hideMainLoading: function() {
- this.mainLoading.hide()
- },
- controls: function(a, c) {
- c.loadingEl = b("<div/>", {
- "class": "loading"
- }).html("Loading...").appendTo(a), c.bufferingEl = b("<div/>", {
- "class": "buffering"
- }).html("Buffering...").css({
- display: "none"
- }).appendTo(a), c.replayEl = b("<div/>", {
- "class": "replay"
- }).html("replay").appendTo(a), c.errorEl = b("<div/>", {
- "class": "error"
- }).html("An unexpected error occurred, please try again later").appendTo(a), c.errorEl.hide(), c.controlsContainer = b("<div/>", {
- "class": "controlContainer"
- }).appendTo(a), c.buttonsEl = b("<div/>", {
- "class": "buttons"
- }).appendTo(c.controlsContainer), c.playEl = b("<a/>", {
- "class": "play noaction",
- href: "#"
- }).html('<span class="icon-play"></span>').appendTo(c.buttonsEl), c.pauseEl = b("<a/>", {
- "class": "pause noaction",
- href: "#"
- }).hide().html('<span class="icon-pause"></span>').appendTo(c.buttonsEl), c.progressOuterEl = b("<div/>", {
- "class": "progressContainer"
- }).appendTo(c.controlsContainer), c.progressEl = b("<div/>", {
- "class": "progress"
- }).appendTo(c.progressOuterEl), c.loadedEl = b("<div/>", {
- "class": "loaded"
- }).appendTo(c.progressOuterEl), c.volumeContainer = b('<div class="volume-container"><span class="tooltip"></span><div class="volume-control"></div><span class="volume"></span></div>').prependTo(c.controlsContainer)
- }
- },
- helpers: {
- getParameterByName: function(a) {
- a = a.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
- var b = new RegExp("[\\?&]" + a + "=([^&#]*)"),
- c = b.exec(location.search);
- return null === c ? "" : decodeURIComponent(c[1].replace(/\+/g, " "))
- },
- isDubtrackAdmin: function(a) {
- return "52c821781e2b1fd945000001" == a || "52c8ef6037e22b0200000005" == a || "52d24bff4cf9670200000515" == a || "52c8efcf37e22b0200000008" == a || "551d295433cd73030089d184" == a || "53f7c199892b010200a98809" == a || "560892bf8e9cb60300550aa2" == a || "52c8254ca7b7260200000001" == a ? !0 : !1
- },
- cookie: {
- set: function(a, b, c, d) {
- var e = "";
- if (c && d !== !0) {
- var f = new Date;
- f.setTime(f.getTime() + 24 * c * 60 * 60 * 1e3), e = "; expires=" + f.toGMTString()
- }
- document.cookie = a + "=" + encodeURIComponent(b) + e + "; path=/"
- },
- get: function(a) {
- for (var b = a + "=", c = document.cookie.split(";"), d = 0; d < c.length; d++) {
- for (var e = c[d];
- " " == e.charAt(0);) e = e.substring(1, e.length);
- if (0 === e.indexOf(b)) return decodeURIComponent(e.substring(b.length, e.length))
- }
- return null
- },
- "delete": function(a) {
- Dubtrack.helpers.cookie.set(a, "", -1, !1)
- }
- },
- parse: function(a, b) {
- return a.data
- },
- image: {
- imageError: function(a, b) {
- return a.onerror = "", b ? a.src = Dubtrack.config.urls.mediaBaseUrl + b : a.src = Dubtrack.config.urls.mediaBaseUrl + "/assets/images/media/pic_notfound.jpg", !0
- },
- getImage: function(a, b, c, d) {
- var e = "Dubtrack.helpers.displayUser('" + a + "', this);",
- f = Dubtrack.config.apiUrl + Dubtrack.config.urls.userImage.replace(":id", a);
- c && (f += "/large");
- var g;
- return d || (e = b && null !== b ? "Dubtrack.app.navigate('/" + b + "', {trigger: true});" : ""), g = '<img src="' + f + '" alt="' + b + '" onclick="' + e + '" class="cursor-pointer" onerror="Dubtrack.helpers.image.imageError(this);" />'
- },
- getProfileImg: function(a, b, c, d) {
- var e = "",
- f = "Dubtrack.helpers.displayUser('" + a + "', this);";
- "facebook" == c ? (d ? "large" === d && (d = "large") : d = "square", e = "https://graph.facebook.com/" + a + "/picture?type=" + d) : "google" == c ? (d = d ? "?sz=200" : "", e = "https://plus.google.com/s2/photos/profile/" + a + d) : "soundcloud" == c ? e = "http://media.dubtrack.fm/media/soundCloud.png" : (d ? ("large" == d && (d = "original"), "square" == d && (d = "normal")) : d = "bigger", e = "https://api.twitter.com/1/users/profile_image?id=" + a + "&size=" + d);
- var g = '<img src="' + e + '" alt="' + b + '" onclick="' + f + '" class="cursor-pointer" onerror="Dubtrack.helpers.image.imageError(this);" />';
- return g
- }
- },
- displayUser: function(a, c) {
- Dubtrack.views.user_popover || (Dubtrack.views.user_popover = new f.global.userPopover, Dubtrack.views.user_popover.$el.appendTo("body")), Dubtrack.views.user_popover.displayUser(a);
- var d = b(c).offset(),
- e = d.left - 200,
- g = d.top;
- 0 > e && (e = 0), 0 > g && (g = 0), Dubtrack.views.user_popover.$el.css({
- left: e,
- top: g
- }).show(), Dubtrack.views.user_popover.offset_top = d.top, b(window).height() < d.top + Dubtrack.views.user_popover.$el.height() && (g = d.top - Dubtrack.views.user_popover.$el.height(), 0 > g && (g = 0), Dubtrack.views.user_popover.$el.css({
- top: g
- }))
- },
- flashLogin: function() {
- b("#header_login").stop(!0).fadeIn(300).fadeOut(300).fadeIn(300).fadeOut(300).fadeIn(300)
- },
- navigateHistoryTags: function(a) {
- var c = a.find("a.navigate");
- c.unbind("click"), c.bind("click", function() {
- return $href = b(this).attr("href"), $href && Dubtrack.app.navigate($href, {
- trigger: !0
- }), !1
- })
- },
- playlist: {
- addQueue: function(a, b, c) {
- if (Dubtrack.room) {
- var d = Dubtrack.config.apiUrl + Dubtrack.config.urls.roomQueue.replace("{id}", Dubtrack.room.model.id);
- Dubtrack.helpers.sendRequest(d, {
- songId: a,
- songType: b
- }, "post", c)
- } else c && c.call(this, null)
- },
- removeQueue: function(a, b) {
- if (Dubtrack.room) {
- var c = Dubtrack.config.apiUrl + Dubtrack.config.urls.roomQueue.replace("{id}", Dubtrack.room.model.id) + "/" + a;
- Dubtrack.helpers.sendRequest(c, {}, "delete", b)
- } else b && b.call(this, null)
- }
- },
- genPlaylistContainer: function(a, c, d, e, g) {
- Dubtrack.createPlaylist && Dubtrack.createPlaylist.close(), Dubtrack.app.loadUserPlaylists(function() {
- Dubtrack.createPlaylist = new Dubtrack.View.containerElCreate({
- model: Dubtrack.user.playlist
- }).render(a, c, d, e), g && Dubtrack.createPlaylist.$el.addClass(g), f.bindedDocument || (b(window).on("click", function(a) {
- $parents = b(a.target).parents(".playlist-options"), 0 === $parents.length && Dubtrack.createPlaylist && Dubtrack.createPlaylist.close()
- }), f.bindedDocument = !0)
- })
- },
- sendRequest: function(a, c, d, e, f) {
- f || (f = this);
- try {
- b.ajax({
- url: a,
- data: c,
- type: d,
- xhrFields: {
- withCredentials: !0
- },
- success: function(a) {
- try {
- e && e.call(f, null, a)
- } catch (b) {}
- },
- error: function(a, c, d) {
- var g = d;
- try {
- g = b.parseJSON(a.responseText)
- } catch (h) {}
- e && e.call(f, g, null)
- }
- }, "json")
- } catch (g) {
- e.call(f, g, null)
- }
- },
- displayDubs: function(a, c, d) {
- d || (d = "");
- var e = dubtrack.app.roomAvatarList.collection.get(a);
- if (e) {
- var f = e.get("dubs");
- dubs = parseInt(f) + c, e.set({
- dubs: dubs
- });
- var g = b("<div/>", {
- "class": "dubDisplay"
- }).html("<b>" + d + " +" + c + " dub</b><span>" + dubs + "</span>").appendTo(e.viewEl.$el);
- setTimeout(function() {
- g.remove()
- }, 1500)
- }
- return !1
- },
- loadDependenciesEl: function(a) {
- Dubtrack.layout = new Dubtrack.View.LayoutView, Dubtrack.playerController = new Dubtrack.View.PlayerController, a && a.call()
- },
- loadDependencies: function(a) {
- Dubtrack.user = {}, Dubtrack.user.loggedIn = !1, Dubtrack.els.init(), Dubtrack.session = new Dubtrack.Model.User, Dubtrack.loggedIn = !1, Dubtrack.session.urlRoot = Dubtrack.config.apiUrl + Dubtrack.config.urls.session, Dubtrack.session.parse = Dubtrack.helpers.parse, Dubtrack.session.fetch({
- success: function(b, c) {
- Dubtrack.loggedIn = !0, Dubtrack.helpers.loadDependenciesEl(a), Dubtrack.cache.users.add(c.data)
- },
- error: function() {
- Dubtrack.helpers.loadDependenciesEl(a)
- }
- })
- },
- displayError: function(a, c, d, e) {
- b("#warning").remove();
- var f = b("<div/>", {
- id: "warning"
- }).html("<h3>" + a + "</h3><p>" + c + "</p>").appendTo("body");
- d ? b("<button onclick='location.reload();return false;'>" + dubtrack_lang.global.refresh + "</button>").appendTo(f) : (e || (e = '$("#warning").remove();return false;'), b("<button onclick=" + e + ">Ok</button>").appendTo(f))
- },
- text: {
- shortenLink: function(a, b) {
- return a.length > b && (a = a.substring(0, b) + "..."), a
- },
- shortenMessage: function(a, b) {
- return a.substring(0, b)
- },
- convertHtmltoTags: function(a, b) {
- var c = /^(http|https)(.*)\.(png|jpg|jpeg|gif)$/;
- return a = a.replace(/(\b(?:https?|ftp):\/\/[a-z0-9-+&@#\/%()[\]?=~_|!:,.;]*[a-z0-9-+&@#\/%=~_|])/gim, function(a) {
- if (!Dubtrack.HideImages && a.match(c)) {
- return a = '<a href="' + a + '" class="autolink" target="_blank"><img src="https://dbu1ls7999okz.cloudfront.net/chat?url=' + a + '" /></a>'
- }
- return a = '<a href="' + a + '" class="autolink" target="_blank">' + Dubtrack.helpers.text.shortenLink(a, 60) + "</a>"
- })
- },
- shrinkImg: function(a) {
- var c = b(a);
- 20 === c.width() ? c.animate({
- width: "100%",
- height: "100%"
- }, 500) : c.animate({
- width: "20px",
- height: "20px"
- }, 500)
- },
- convertAttoLink: function(a) {
- return a.replace(/(@[A-Za-z0-9_.]+)/g, '<span class="username-handle">$&</span>')
- }
- }
- },
- app: null,
- dubtrackPlayer: null
- },
- function(a) {
- b.browser = {}, b.browser.mobile = /(ipad|android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i.test(a) || /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(a.substr(0, 4))
- }(navigator.userAgent || navigator.vendor || window.opera), b.fn.serializeObject = function() {
- var a = {},
- c = this.serializeArray();
- return b.each(c, function() {
- void 0 !== a[this.name] ? (a[this.name].push || (a[this.name] = [a[this.name]]), a[this.name].push(this.value || "")) : a[this.name] = this.value || ""
- }), a
- }, b.fn.hasValue = function() {
- var a = this.val();
- return !(_.isNull(a) || _.isUndefined(a) || _.isString(a) && "" === h(a))
- }, b.fn.randomize = function(a) {
- var c = a ? b(this).find(a) : b(this).children(),
- d = c.parent();
- return d.each(function() {
- b(this).children(a).sort(function() {
- return Math.round(Math.random()) - .5
- }).detach().appendTo(this)
- }), this
- };
- var h = String.prototype.trim ? function(a) {
- return null === a ? "" : String.prototype.trim.call(a)
- } : function(a) {
- var b = /^\s+/,
- c = /\s+$/;
- return null === a ? "" : a.toString().replace(b, "").replace(c, "")
- };
- jQuery.expr[":"].regex = function(a, b, c) {
- var d = c[3].split(","),
- e = /^(data|css):/,
- f = {
- method: d[0].match(e) ? d[0].split(":")[0] : "attr",
- property: d.shift().replace(e, "")
- },
- g = "ig",
- h = new RegExp(d.join("").replace(/^\s+|\s+$/g, ""), g);
- return h.test(jQuery(a)[f.method](f.property))
- },
- function(a, b, c) {
- "use strict";
- a.fn.backstretch = function(d, f) {
- return (d === c || 0 === d.length) && a.error("No images were supplied for Backstretch"), 0 === a(b).scrollTop() && b.scrollTo(0, 0), this.each(function() {
- var b = a(this),
- c = b.data("backstretch");
- if (c) {
- if ("string" == typeof d && "function" == typeof c[d]) return void c[d](f);
- f = a.extend(c.options, f), c.destroy(!0)
- }
- c = new e(this, d, f), b.data("backstretch", c)
- })
- }, a.backstretch = function(b, c) {
- return a("body").backstretch(b, c).data("backstretch")
- }, a.expr[":"].backstretch = function(b) {
- return a(b).data("backstretch") !== c
- }, a.fn.backstretch.defaults = {
- centeredX: !0,
- centeredY: !0,
- duration: 5e3,
- fade: 0
- };
- var d = {
- wrap: {
- left: 0,
- top: 0,
- overflow: "hidden",
- margin: 0,
- padding: 0,
- height: "100%",
- width: "100%",
- zIndex: -999999
- },
- img: {
- position: "absolute",
- display: "none",
- margin: 0,
- padding: 0,
- border: "none",
- width: "auto",
- height: "auto",
- maxHeight: "none",
- maxWidth: "none",
- zIndex: -999999
- }
- },
- e = function(c, e, g) {
- this.options = a.extend({}, a.fn.backstretch.defaults, g || {}), this.images = a.isArray(e) ? e : [e], a.each(this.images, function() {
- a("<img />")[0].src = this
- }), this.isBody = c === document.body, this.$container = a(c), this.$root = this.isBody ? a(f ? b : document) : this.$container;
- var h = this.$container.children(".backstretch").first();
- if (this.$wrap = h.length ? h : a('<div class="backstretch"></div>').css(d.wrap).appendTo(this.$container), !this.isBody) {
- var i = this.$container.css("position"),
- j = this.$container.css("zIndex");
- this.$container.css({
- position: "static" === i ? "relative" : i,
- zIndex: "auto" === j ? 0 : j,
- background: "none"
- }), this.$wrap.css({
- zIndex: -999998
- })
- }
- this.$wrap.css({
- position: this.isBody && f ? "fixed" : "absolute"
- }), this.index = 0, this.show(this.index), a(b).on("resize.backstretch", a.proxy(this.resize, this)).on("orientationchange.backstretch", a.proxy(function() {
- this.isBody && 0 === b.pageYOffset && (b.scrollTo(0, 1), this.resize())
- }, this))
- };
- e.prototype = {
- resize: function() {
- try {
- var a, c = {
- left: 0,
- top: 0
- },
- d = this.isBody ? this.$root.width() : this.$root.innerWidth(),
- e = d,
- f = this.isBody ? b.innerHeight ? b.innerHeight : this.$root.height() : this.$root.innerHeight(),
- g = e / this.$img.data("ratio");
- g >= f ? (a = (g - f) / 2, this.options.centeredY && (c.top = "-" + a + "px")) : (g = f, e = g * this.$img.data("ratio"), a = (e - d) / 2, this.options.centeredX && (c.left = "-" + a + "px")), this.$wrap.css({
- width: d,
- height: f
- }).find("img:not(.deleteable)").css({
- width: e,
- height: g
- }).css(c)
- } catch (h) {}
- return this
- },
- show: function(b) {
- if (!(Math.abs(b) > this.images.length - 1)) {
- var c = this,
- e = c.$wrap.find("img").addClass("deleteable"),
- f = {
- relatedTarget: c.$container[0]
- };
- return c.$container.trigger(a.Event("backstretch.before", f), [c, b]), this.index = b, clearInterval(c.interval), c.$img = a("<img />").css(d.img).bind("load", function(d) {
- var g = this.width || a(d.target).width(),
- h = this.height || a(d.target).height();
- a(this).data("ratio", g / h), a(this).fadeIn(c.options.speed || c.options.fade, function() {
- e.remove(), c.paused || c.cycle(), a(["after", "show"]).each(function() {
- c.$container.trigger(a.Event("backstretch." + this, f), [c, b])
- })
- }), c.resize()
- }).appendTo(c.$wrap), c.$img.attr("src", c.images[b]), c
- }
- },
- next: function() {
- return this.show(this.index < this.images.length - 1 ? this.index + 1 : 0)
- },
- prev: function() {
- return this.show(0 === this.index ? this.images.length - 1 : this.index - 1)
- },
- pause: function() {
- return this.paused = !0, this
- },
- resume: function() {
- return this.paused = !1, this.next(), this
- },
- cycle: function() {
- return this.images.length > 1 && (clearInterval(this.interval), this.interval = setInterval(a.proxy(function() {
- this.paused || this.next()
- }, this), this.options.duration)), this
- },
- destroy: function(c) {
- a(b).off("resize.backstretch orientationchange.backstretch"), clearInterval(this.interval), c || this.$wrap.remove(), this.$container.removeData("backstretch")
- }
- };
- var f = function() {
- var a = navigator.userAgent,
- c = navigator.platform,
- d = a.match(/AppleWebKit\/([0-9]+)/),
- e = !!d && d[1],
- f = a.match(/Fennec\/([0-9]+)/),
- g = !!f && f[1],
- h = a.match(/Opera Mobi\/([0-9]+)/),
- i = !!h && h[1],
- j = a.match(/MSIE ([0-9]+)/),
- k = !!j && j[1];
- return !((c.indexOf("iPhone") > -1 || c.indexOf("iPad") > -1 || c.indexOf("iPod") > -1) && e && 534 > e || b.operamini && "[object OperaMini]" === {}.toString.call(b.operamini) || h && 7458 > i || a.indexOf("Android") > -1 && e && 533 > e || g && 6 > g || "palmGetResource" in b && e && 534 > e || a.indexOf("MeeGo") > -1 && a.indexOf("NokiaBrowser/8.5.0") > -1 || k && 6 >= k)
- }()
- }(jQuery, window),
- function(a) {
- "use strict";
- "function" == typeof define && define.amd ? define(["jquery", "jquery.ui.widget"], a) : a(window.jQuery)
- }(function(a) {
- "use strict";
- a.support.fileInput = !(new RegExp("(Android (1\\.[0156]|2\\.[01]))|(Windows Phone (OS 7|8\\.0))|(XBLWP)|(ZuneWP)|(WPDesktop)|(w(eb)?OSBrowser)|(webOS)|(Kindle/(1\\.0|2\\.[05]|3\\.0))").test(window.navigator.userAgent) || a('<input type="file">').prop("disabled")), a.support.xhrFileUpload = !(!window.ProgressEvent || !window.FileReader), a.support.xhrFormDataFileUpload = !!window.FormData, a.support.blobSlice = window.Blob && (Blob.prototype.slice || Blob.prototype.webkitSlice || Blob.prototype.mozSlice), a.widget("blueimp.fileupload", {
- options: {
- dropZone: a(document),
- pasteZone: a(document),
- fileInput: void 0,
- replaceFileInput: !0,
- paramName: void 0,
- singleFileUploads: !0,
- limitMultiFileUploads: void 0,
- limitMultiFileUploadSize: void 0,
- limitMultiFileUploadSizeOverhead: 512,
- sequentialUploads: !1,
- limitConcurrentUploads: void 0,
- forceIframeTransport: !1,
- redirect: void 0,
- redirectParamName: void 0,
- postMessage: void 0,
- multipart: !0,
- maxChunkSize: void 0,
- uploadedBytes: void 0,
- recalculateProgress: !0,
- progressInterval: 100,
- bitrateInterval: 500,
- autoUpload: !0,
- messages: {
- uploadedBytes: "Uploaded bytes exceed file size"
- },
- i18n: function(b, c) {
- return b = this.messages[b] || b.toString(), c && a.each(c, function(a, c) {
- b = b.replace("{" + a + "}", c)
- }), b
- },
- formData: function(a) {
- return a.serializeArray()
- },
- add: function(b, c) {
- return b.isDefaultPrevented() ? !1 : void((c.autoUpload || c.autoUpload !== !1 && a(this).fileupload("option", "autoUpload")) && c.process().done(function() {
- c.submit()
- }))
- },
- processData: !1,
- contentType: !1,
- cache: !1
- },
- _specialOptions: ["fileInput", "dropZone", "pasteZone", "multipart", "forceIframeTransport"],
- _blobSlice: a.support.blobSlice && function() {
- var a = this.slice || this.webkitSlice || this.mozSlice;
- return a.apply(this, arguments)
- },
- _BitrateTimer: function() {
- this.timestamp = Date.now ? Date.now() : (new Date).getTime(), this.loaded = 0, this.bitrate = 0, this.getBitrate = function(a, b, c) {
- var d = a - this.timestamp;
- return (!this.bitrate || !c || d > c) && (this.bitrate = (b - this.loaded) * (1e3 / d) * 8, this.loaded = b, this.timestamp = a), this.bitrate
- }
- },
- _isXHRUpload: function(b) {
- return !b.forceIframeTransport && (!b.multipart && a.support.xhrFileUpload || a.support.xhrFormDataFileUpload)
- },
- _getFormData: function(b) {
- var c;
- return "function" === a.type(b.formData) ? b.formData(b.form) : a.isArray(b.formData) ? b.formData : "object" === a.type(b.formData) ? (c = [], a.each(b.formData, function(a, b) {
- c.push({
- name: a,
- value: b
- })
- }), c) : []
- },
- _getTotal: function(b) {
- var c = 0;
- return a.each(b, function(a, b) {
- c += b.size || 1
- }), c
- },
- _initProgressObject: function(b) {
- var c = {
- loaded: 0,
- total: 0,
- bitrate: 0
- };
- b._progress ? a.extend(b._progress, c) : b._progress = c
- },
- _initResponseObject: function(a) {
- var b;
- if (a._response)
- for (b in a._response) a._response.hasOwnProperty(b) && delete a._response[b];
- else a._response = {}
- },
- _onProgress: function(b, c) {
- if (b.lengthComputable) {
- var d, e = Date.now ? Date.now() : (new Date).getTime();
- if (c._time && c.progressInterval && e - c._time < c.progressInterval && b.loaded !== b.total) return;
- c._time = e, d = Math.floor(b.loaded / b.total * (c.chunkSize || c._progress.total)) + (c.uploadedBytes || 0), this._progress.loaded += d - c._progress.loaded, this._progress.bitrate = this._bitrateTimer.getBitrate(e, this._progress.loaded, c.bitrateInterval), c._progress.loaded = c.loaded = d, c._progress.bitrate = c.bitrate = c._bitrateTimer.getBitrate(e, d, c.bitrateInterval), this._trigger("progress", a.Event("progress", {
- delegatedEvent: b
- }), c), this._trigger("progressall", a.Event("progressall", {
- delegatedEvent: b
- }), this._progress)
- }
- },
- _initProgressListener: function(b) {
- var c = this,
- d = b.xhr ? b.xhr() : a.ajaxSettings.xhr();
- d.upload && (a(d.upload).bind("progress", function(a) {
- var d = a.originalEvent;
- a.lengthComputable = d.lengthComputable, a.loaded = d.loaded, a.total = d.total, c._onProgress(a, b)
- }), b.xhr = function() {
- return d
- })
- },
- _isInstanceOf: function(a, b) {
- return Object.prototype.toString.call(b) === "[object " + a + "]"
- },
- _initXHRData: function(b) {
- var c, d = this,
- e = b.files[0],
- f = b.multipart || !a.support.xhrFileUpload,
- g = "array" === a.type(b.paramName) ? b.paramName[0] : b.paramName;
- b.headers = a.extend({}, b.headers), b.contentRange && (b.headers["Content-Range"] = b.contentRange), f && !b.blob && this._isInstanceOf("File", e) || (b.headers["Content-Disposition"] = 'attachment; filename="' + encodeURI(e.name) + '"'), f ? a.support.xhrFormDataFileUpload && (b.postMessage ? (c = this._getFormData(b), b.blob ? c.push({
- name: g,
- value: b.blob
- }) : a.each(b.files, function(d, e) {
- c.push({
- name: "array" === a.type(b.paramName) && b.paramName[d] || g,
- value: e
- })
- })) : (d._isInstanceOf("FormData", b.formData) ? c = b.formData : (c = new FormData, a.each(this._getFormData(b), function(a, b) {
- c.append(b.name, b.value)
- })), b.blob ? c.append(g, b.blob, e.name) : a.each(b.files, function(e, f) {
- (d._isInstanceOf("File", f) || d._isInstanceOf("Blob", f)) && c.append("array" === a.type(b.paramName) && b.paramName[e] || g, f, f.uploadName || f.name)
- })), b.data = c) : (b.contentType = e.type || "application/octet-stream", b.data = b.blob || e), b.blob = null
- },
- _initIframeSettings: function(b) {
- var c = a("<a></a>").prop("href", b.url).prop("host");
- b.dataType = "iframe " + (b.dataType || ""), b.formData = this._getFormData(b), b.redirect && c && c !== location.host && b.formData.push({
- name: b.redirectParamName || "redirect",
- value: b.redirect
- })
- },
- _initDataSettings: function(a) {
- this._isXHRUpload(a) ? (this._chunkedUpload(a, !0) || (a.data || this._initXHRData(a), this._initProgressListener(a)), a.postMessage && (a.dataType = "postmessage " + (a.dataType || ""))) : this._initIframeSettings(a)
- },
- _getParamName: function(b) {
- var c = a(b.fileInput),
- d = b.paramName;
- return d ? a.isArray(d) || (d = [d]) : (d = [], c.each(function() {
- for (var b = a(this), c = b.prop("name") || "files[]", e = (b.prop("files") || [1]).length; e;) d.push(c), e -= 1
- }), d.length || (d = [c.prop("name") || "files[]"])), d
- },
- _initFormSettings: function(b) {
- b.form && b.form.length || (b.form = a(b.fileInput.prop("form")), b.form.length || (b.form = a(this.options.fileInput.prop("form")))), b.paramName = this._getParamName(b), b.url || (b.url = b.form.prop("action") || location.href), b.type = (b.type || "string" === a.type(b.form.prop("method")) && b.form.prop("method") || "").toUpperCase(), "POST" !== b.type && "PUT" !== b.type && "PATCH" !== b.type && (b.type = "POST"), b.formAcceptCharset || (b.formAcceptCharset = b.form.attr("accept-charset"))
- },
- _getAJAXSettings: function(b) {
- var c = a.extend({}, this.options, b);
- return this._initFormSettings(c), this._initDataSettings(c), c
- },
- _getDeferredState: function(a) {
- return a.state ? a.state() : a.isResolved() ? "resolved" : a.isRejected() ? "rejected" : "pending"
- },
- _enhancePromise: function(a) {
- return a.success = a.done, a.error = a.fail, a.complete = a.always, a
- },
- _getXHRPromise: function(b, c, d) {
- var e = a.Deferred(),
- f = e.promise();
- return c = c || this.options.context || f, b === !0 ? e.resolveWith(c, d) : b === !1 && e.rejectWith(c, d), f.abort = e.promise, this._enhancePromise(f)
- },
- _addConvenienceMethods: function(b, c) {
- var d = this,
- e = function(b) {
- return a.Deferred().resolveWith(d, b).promise()
- };
- c.process = function(b, f) {
- return (b || f) && (c._processQueue = this._processQueue = (this._processQueue || e([this])).pipe(function() {
- return c.errorThrown ? a.Deferred().rejectWith(d, [c]).promise() : e(arguments)
- }).pipe(b, f)), this._processQueue || e([this])
- }, c.submit = function() {
- return "pending" !== this.state() && (c.jqXHR = this.jqXHR = d._trigger("submit", a.Event("submit", {
- delegatedEvent: b
- }), this) !== !1 && d._onSend(b, this)), this.jqXHR || d._getXHRPromise()
- }, c.abort = function() {
- return this.jqXHR ? this.jqXHR.abort() : (this.errorThrown = "abort", d._trigger("fail", null, this), d._getXHRPromise(!1))
- }, c.state = function() {
- return this.jqXHR ? d._getDeferredState(this.jqXHR) : this._processQueue ? d._getDeferredState(this._processQueue) : void 0
- }, c.processing = function() {
- return !this.jqXHR && this._processQueue && "pending" === d._getDeferredState(this._processQueue)
- }, c.progress = function() {
- return this._progress
- }, c.response = function() {
- return this._response
- }
- },
- _getUploadedBytes: function(a) {
- var b = a.getResponseHeader("Range"),
- c = b && b.split("-"),
- d = c && c.length > 1 && parseInt(c[1], 10);
- return d && d + 1
- },
- _chunkedUpload: function(b, c) {
- b.uploadedBytes = b.uploadedBytes || 0;
- var d, e, f = this,
- g = b.files[0],
- h = g.size,
- i = b.uploadedBytes,
- j = b.maxChunkSize || h,
- k = this._blobSlice,
- l = a.Deferred(),
- m = l.promise();
- return this._isXHRUpload(b) && k && (i || h > j) && !b.data ? c ? !0 : i >= h ? (g.error = b.i18n("uploadedBytes"), this._getXHRPromise(!1, b.context, [null, "error", g.error])) : (e = function() {
- var c = a.extend({}, b),
- m = c._progress.loaded;
- c.blob = k.call(g, i, i + j, g.type), c.chunkSize = c.blob.size, c.contentRange = "bytes " + i + "-" + (i + c.chunkSize - 1) + "/" + h, f._initXHRData(c), f._initProgressListener(c), d = (f._trigger("chunksend", null, c) !== !1 && a.ajax(c) || f._getXHRPromise(!1, c.context)).done(function(d, g, j) {
- i = f._getUploadedBytes(j) || i + c.chunkSize, m + c.chunkSize - c._progress.loaded && f._onProgress(a.Event("progress", {
- lengthComputable: !0,
- loaded: i - c.uploadedBytes,
- total: i - c.uploadedBytes
- }), c), b.uploadedBytes = c.uploadedBytes = i, c.result = d, c.textStatus = g, c.jqXHR = j, f._trigger("chunkdone", null, c), f._trigger("chunkalways", null, c), h > i ? e() : l.resolveWith(c.context, [d, g, j])
- }).fail(function(a, b, d) {
- c.jqXHR = a, c.textStatus = b, c.errorThrown = d, f._trigger("chunkfail", null, c), f._trigger("chunkalways", null, c), l.rejectWith(c.context, [a, b, d])
- })
- }, this._enhancePromise(m), m.abort = function() {
- return d.abort()
- }, e(), m) : !1
- },
- _beforeSend: function(a, b) {
- 0 === this._active && (this._trigger("start"), this._bitrateTimer = new this._BitrateTimer, this._progress.loaded = this._progress.total = 0, this._progress.bitrate = 0), this._initResponseObject(b), this._initProgressObject(b), b._progress.loaded = b.loaded = b.uploadedBytes || 0, b._progress.total = b.total = this._getTotal(b.files) || 1, b._progress.bitrate = b.bitrate = 0, this._active += 1, this._progress.loaded += b.loaded, this._progress.total += b.total
- },
- _onDone: function(b, c, d, e) {
- var f = e._progress.total,
- g = e._response;
- e._progress.loaded < f && this._onProgress(a.Event("progress", {
- lengthComputable: !0,
- loaded: f,
- total: f
- }), e), g.result = e.result = b, g.textStatus = e.textStatus = c, g.jqXHR = e.jqXHR = d, this._trigger("done", null, e)
- },
- _onFail: function(a, b, c, d) {
- var e = d._response;
- d.recalculateProgress && (this._progress.loaded -= d._progress.loaded, this._progress.total -= d._progress.total), e.jqXHR = d.jqXHR = a, e.textStatus = d.textStatus = b, e.errorThrown = d.errorThrown = c, this._trigger("fail", null, d)
- },
- _onAlways: function(a, b, c, d) {
- this._trigger("always", null, d)
- },
- _onSend: function(b, c) {
- c.submit || this._addConvenienceMethods(b, c);
- var d, e, f, g, h = this,
- i = h._getAJAXSettings(c),
- j = function() {
- return h._sending += 1, i._bitrateTimer = new h._BitrateTimer,
- d = d || ((e || h._trigger("send", a.Event("send", {
- delegatedEvent: b
- }), i) === !1) && h._getXHRPromise(!1, i.context, e) || h._chunkedUpload(i) || a.ajax(i)).done(function(a, b, c) {
- h._onDone(a, b, c, i)
- }).fail(function(a, b, c) {
- h._onFail(a, b, c, i)
- }).always(function(a, b, c) {
- if (h._onAlways(a, b, c, i), h._sending -= 1, h._active -= 1, i.limitConcurrentUploads && i.limitConcurrentUploads > h._sending)
- for (var d = h._slots.shift(); d;) {
- if ("pending" === h._getDeferredState(d)) {
- d.resolve();
- break
- }
- d = h._slots.shift()
- }
- 0 === h._active && h._trigger("stop")
- })
- };
- return this._beforeSend(b, i), this.options.sequentialUploads || this.options.limitConcurrentUploads && this.options.limitConcurrentUploads <= this._sending ? (this.options.limitConcurrentUploads > 1 ? (f = a.Deferred(), this._slots.push(f), g = f.pipe(j)) : (this._sequence = this._sequence.pipe(j, j), g = this._sequence), g.abort = function() {
- return e = [void 0, "abort", "abort"], d ? d.abort() : (f && f.rejectWith(i.context, e), j())
- }, this._enhancePromise(g)) : j()
- },
- _onAdd: function(b, c) {
- var d, e, f, g, h = this,
- i = !0,
- j = a.extend({}, this.options, c),
- k = c.files,
- l = k.length,
- m = j.limitMultiFileUploads,
- n = j.limitMultiFileUploadSize,
- o = j.limitMultiFileUploadSizeOverhead,
- p = 0,
- q = this._getParamName(j),
- r = 0;
- if (!n || l && void 0 !== k[0].size || (n = void 0), (j.singleFileUploads || m || n) && this._isXHRUpload(j))
- if (j.singleFileUploads || n || !m)
- if (!j.singleFileUploads && n)
- for (f = [], d = [], g = 0; l > g; g += 1) p += k[g].size + o, (g + 1 === l || p + k[g + 1].size + o > n || m && g + 1 - r >= m) && (f.push(k.slice(r, g + 1)), e = q.slice(r, g + 1), e.length || (e = q), d.push(e), r = g + 1, p = 0);
- else d = q;
- else
- for (f = [], d = [], g = 0; l > g; g += m) f.push(k.slice(g, g + m)), e = q.slice(g, g + m), e.length || (e = q), d.push(e);
- else f = [k], d = [q];
- return c.originalFiles = k, a.each(f || k, function(e, g) {
- var j = a.extend({}, c);
- return j.files = f ? g : [g], j.paramName = d[e], h._initResponseObject(j), h._initProgressObject(j), h._addConvenienceMethods(b, j), i = h._trigger("add", a.Event("add", {
- delegatedEvent: b
- }), j)
- }), i
- },
- _replaceFileInput: function(b) {
- var c = b.clone(!0);
- a("<form></form>").append(c)[0].reset(), b.after(c).detach(), a.cleanData(b.unbind("remove")), this.options.fileInput = this.options.fileInput.map(function(a, d) {
- return d === b[0] ? c[0] : d
- }), b[0] === this.element[0] && (this.element = c)
- },
- _handleFileTreeEntry: function(b, c) {
- var d, e = this,
- f = a.Deferred(),
- g = function(a) {
- a && !a.entry && (a.entry = b), f.resolve([a])
- };
- return c = c || "", b.isFile ? b._file ? (b._file.relativePath = c, f.resolve(b._file)) : b.file(function(a) {
- a.relativePath = c, f.resolve(a)
- }, g) : b.isDirectory ? (d = b.createReader(), d.readEntries(function(a) {
- e._handleFileTreeEntries(a, c + b.name + "/").done(function(a) {
- f.resolve(a)
- }).fail(g)
- }, g)) : f.resolve([]), f.promise()
- },
- _handleFileTreeEntries: function(b, c) {
- var d = this;
- return a.when.apply(a, a.map(b, function(a) {
- return d._handleFileTreeEntry(a, c)
- })).pipe(function() {
- return Array.prototype.concat.apply([], arguments)
- })
- },
- _getDroppedFiles: function(b) {
- b = b || {};
- var c = b.items;
- return c && c.length && (c[0].webkitGetAsEntry || c[0].getAsEntry) ? this._handleFileTreeEntries(a.map(c, function(a) {
- var b;
- return a.webkitGetAsEntry ? (b = a.webkitGetAsEntry(), b && (b._file = a.getAsFile()), b) : a.getAsEntry()
- })) : a.Deferred().resolve(a.makeArray(b.files)).promise()
- },
- _getSingleFileInputFiles: function(b) {
- b = a(b);
- var c, d, e = b.prop("webkitEntries") || b.prop("entries");
- if (e && e.length) return this._handleFileTreeEntries(e);
- if (c = a.makeArray(b.prop("files")), c.length) void 0 === c[0].name && c[0].fileName && a.each(c, function(a, b) {
- b.name = b.fileName, b.size = b.fileSize
- });
- else {
- if (d = b.prop("value"), !d) return a.Deferred().resolve([]).promise();
- c = [{
- name: d.replace(/^.*\\/, "")
- }]
- }
- return a.Deferred().resolve(c).promise()
- },
- _getFileInputFiles: function(b) {
- return b instanceof a && 1 !== b.length ? a.when.apply(a, a.map(b, this._getSingleFileInputFiles)).pipe(function() {
- return Array.prototype.concat.apply([], arguments)
- }) : this._getSingleFileInputFiles(b)
- },
- _onChange: function(b) {
- var c = this,
- d = {
- fileInput: a(b.target),
- form: a(b.target.form)
- };
- this._getFileInputFiles(d.fileInput).always(function(e) {
- d.files = e, c.options.replaceFileInput && c._replaceFileInput(d.fileInput), c._trigger("change", a.Event("change", {
- delegatedEvent: b
- }), d) !== !1 && c._onAdd(b, d)
- })
- },
- _onPaste: function(b) {
- var c = b.originalEvent && b.originalEvent.clipboardData && b.originalEvent.clipboardData.items,
- d = {
- files: []
- };
- c && c.length && (a.each(c, function(a, b) {
- var c = b.getAsFile && b.getAsFile();
- c && d.files.push(c)
- }), this._trigger("paste", a.Event("paste", {
- delegatedEvent: b
- }), d) !== !1 && this._onAdd(b, d))
- },
- _onDrop: function(b) {
- b.dataTransfer = b.originalEvent && b.originalEvent.dataTransfer;
- var c = this,
- d = b.dataTransfer,
- e = {};
- d && d.files && d.files.length && (b.preventDefault(), this._getDroppedFiles(d).always(function(d) {
- e.files = d, c._trigger("drop", a.Event("drop", {
- delegatedEvent: b
- }), e) !== !1 && c._onAdd(b, e)
- }))
- },
- _onDragOver: function(b) {
- b.dataTransfer = b.originalEvent && b.originalEvent.dataTransfer;
- var c = b.dataTransfer;
- c && -1 !== a.inArray("Files", c.types) && this._trigger("dragover", a.Event("dragover", {
- delegatedEvent: b
- })) !== !1 && (b.preventDefault(), c.dropEffect = "copy")
- },
- _initEventHandlers: function() {
- this._isXHRUpload(this.options) && (this._on(this.options.dropZone, {
- dragover: this._onDragOver,
- drop: this._onDrop
- }), this._on(this.options.pasteZone, {
- paste: this._onPaste
- })), a.support.fileInput && this._on(this.options.fileInput, {
- change: this._onChange
- })
- },
- _destroyEventHandlers: function() {
- this._off(this.options.dropZone, "dragover drop"), this._off(this.options.pasteZone, "paste"), this._off(this.options.fileInput, "change")
- },
- _setOption: function(b, c) {
- var d = -1 !== a.inArray(b, this._specialOptions);
- d && this._destroyEventHandlers(), this._super(b, c), d && (this._initSpecialOptions(), this._initEventHandlers())
- },
- _initSpecialOptions: function() {
- var b = this.options;
- void 0 === b.fileInput ? b.fileInput = this.element.is('input[type="file"]') ? this.element : this.element.find('input[type="file"]') : b.fileInput instanceof a || (b.fileInput = a(b.fileInput)), b.dropZone instanceof a || (b.dropZone = a(b.dropZone)), b.pasteZone instanceof a || (b.pasteZone = a(b.pasteZone))
- },
- _getRegExp: function(a) {
- var b = a.split("/"),
- c = b.pop();
- return b.shift(), new RegExp(b.join("/"), c)
- },
- _isRegExpOption: function(b, c) {
- return "url" !== b && "string" === a.type(c) && /^\/.*\/[igm]{0,3}$/.test(c)
- },
- _initDataAttributes: function() {
- var b = this,
- c = this.options,
- d = a(this.element[0].cloneNode(!1));
- a.each(d.data(), function(a, e) {
- var f = "data-" + a.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase();
- d.attr(f) && (b._isRegExpOption(a, e) && (e = b._getRegExp(e)), c[a] = e)
- })
- },
- _create: function() {
- this._initDataAttributes(), this._initSpecialOptions(), this._slots = [], this._sequence = this._getXHRPromise(!0), this._sending = this._active = 0, this._initProgressObject(this), this._initEventHandlers()
- },
- active: function() {
- return this._active
- },
- progress: function() {
- return this._progress
- },
- add: function(b) {
- var c = this;
- b && !this.options.disabled && (b.fileInput && !b.files ? this._getFileInputFiles(b.fileInput).always(function(a) {
- b.files = a, c._onAdd(null, b)
- }) : (b.files = a.makeArray(b.files), this._onAdd(null, b)))
- },
- send: function(b) {
- if (b && !this.options.disabled) {
- if (b.fileInput && !b.files) {
- var c, d, e = this,
- f = a.Deferred(),
- g = f.promise();
- return g.abort = function() {
- return d = !0, c ? c.abort() : (f.reject(null, "abort", "abort"), g)
- }, this._getFileInputFiles(b.fileInput).always(function(a) {
- if (!d) {
- if (!a.length) return void f.reject();
- b.files = a, c = e._onSend(null, b).then(function(a, b, c) {
- f.resolve(a, b, c)
- }, function(a, b, c) {
- f.reject(a, b, c)
- })
- }
- }), this._enhancePromise(g)
- }
- if (b.files = a.makeArray(b.files), b.files.length) return this._onSend(null, b)
- }
- return this._getXHRPromise(!1, b && b.context)
- }
- })
- }),
- function(a) {
- "use strict";
- "function" == typeof define && define.amd ? define(["jquery"], a) : a(window.jQuery)
- }(function(a) {
- "use strict";
- var b = 0;
- a.ajaxTransport("iframe", function(c) {
- if (c.async) {
- var d, e, f, g = c.initialIframeSrc || "javascript:false;";
- return {
- send: function(h, i) {
- d = a('<form style="display:none;"></form>'), d.attr("accept-charset", c.formAcceptCharset), f = /\?/.test(c.url) ? "&" : "?", "DELETE" === c.type ? (c.url = c.url + f + "_method=DELETE", c.type = "POST") : "PUT" === c.type ? (c.url = c.url + f + "_method=PUT", c.type = "POST") : "PATCH" === c.type && (c.url = c.url + f + "_method=PATCH", c.type = "POST"), b += 1, e = a('<iframe src="' + g + '" name="iframe-transport-' + b + '"></iframe>').bind("load", function() {
- var b, f = a.isArray(c.paramName) ? c.paramName : [c.paramName];
- e.unbind("load").bind("load", function() {
- var b;
- try {
- if (b = e.contents(), !b.length || !b[0].firstChild) throw new Error
- } catch (c) {
- b = void 0
- }
- i(200, "success", {
- iframe: b
- }), a('<iframe src="' + g + '"></iframe>').appendTo(d), window.setTimeout(function() {
- d.remove()
- }, 0)
- }), d.prop("target", e.prop("name")).prop("action", c.url).prop("method", c.type), c.formData && a.each(c.formData, function(b, c) {
- a('<input type="hidden"/>').prop("name", c.name).val(c.value).appendTo(d)
- }), c.fileInput && c.fileInput.length && "POST" === c.type && (b = c.fileInput.clone(), c.fileInput.after(function(a) {
- return b[a]
- }), c.paramName && c.fileInput.each(function(b) {
- a(this).prop("name", f[b] || c.paramName)
- }), d.append(c.fileInput).prop("enctype", "multipart/form-data").prop("encoding", "multipart/form-data"), c.fileInput.removeAttr("form")), d.submit(), b && b.length && c.fileInput.each(function(c, d) {
- var e = a(b[c]);
- a(d).prop("name", e.prop("name")).attr("form", e.attr("form")), e.replaceWith(d)
- })
- }), d.append(e).appendTo(document.body)
- },
- abort: function() {
- e && e.unbind("load").prop("src", g), d && d.remove()
- }
- }
- }
- }), a.ajaxSetup({
- converters: {
- "iframe text": function(b) {
- return b && a(b[0].body).text()
- },
- "iframe json": function(b) {
- return b && a.parseJSON(a(b[0].body).text())
- },
- "iframe html": function(b) {
- return b && a(b[0].body).html()
- },
- "iframe xml": function(b) {
- var c = b && b[0];
- return c && a.isXMLDoc(c) ? c : a.parseXML(c.XMLDocument && c.XMLDocument.xml || a(c.body).html())
- },
- "iframe script": function(b) {
- return b && a.globalEval(a(b[0].body).text())
- }
- }
- })
- }), ! function(a) {
- a.fn.multiselectable = function(b) {
- function c(c) {
- var d = a(this),
- e = d.parent(),
- f = d.index(),
- g = e.find(".multiselectable-previous");
- g = g.length ? g : a(e.find("." + b.selectedClass)[0]).addClass("multiselectable-previous");
- var h = g.index();
- if ((c.ctrlKey || c.metaKey) && (d.hasClass(b.selectedClass) ? (d.removeClass(b.selectedClass).removeClass("multiselectable-previous"), d.not(".child").length && d.nextUntil(":not(.child)").removeClass(b.selectedClass)) : (e.find(".multiselectable-previous").removeClass("multiselectable-previous"), d.addClass(b.selectedClass).addClass("multiselectable-previous"), d.not(".child").length && d.nextUntil(":not(.child)").addClass(b.selectedClass))), c.shiftKey) {
- var i = e.find(".multiselectable-shift");
- i.removeClass(b.selectedClass).removeClass("multiselectable-shift");
- var j;
- f > h ? j = d.prevUntil(".multiselectable-previous").add(g).add(d) : h > f && (j = d.nextUntil(".multiselectable-previous").add(g).add(d)), j.addClass(b.selectedClass).addClass("multiselectable-shift")
- } else e.find(".multiselectable-shift").removeClass("multiselectable-shift");
- c.ctrlKey || c.metaKey || c.shiftKey || (e.find(".multiselectable-previous").removeClass("multiselectable-previous"), d.hasClass(b.selectedClass) || (e.find("." + b.selectedClass).removeClass(b.selectedClass), d.addClass(b.selectedClass).addClass("multiselectable-previous"), d.not(".child").length && d.nextUntil(":not(.child)").addClass(b.selectedClass))), b.mousedown(c, d)
- }
- function d(c) {
- if (!a(this).is(".ui-draggable-dragging")) {
- var d = a(this),
- e = d.parent();
- c.ctrlKey || c.metaKey || c.shiftKey || (e.find(".multiselectable-previous").removeClass("multiselectable-previous"), e.find("." + b.selectedClass).removeClass(b.selectedClass), d.addClass(b.selectedClass).addClass("multiselectable-previous"), d.not(".child").length && d.nextUntil(":not(.child)").addClass(b.selectedClass)), b.click(c, d)
- }
- }
- return b || (b = {}), b = a.extend({}, a.fn.multiselectable.defaults, b), this.each(function() {
- var e = a(this);
- e.data("multiselectable") || e.data("multiselectable", !0).delegate(b.items, "mousedown", c).delegate(b.items, "click", d).disableSelection()
- })
- }, a.fn.multiselectable.defaults = {
- click: function(a, b) {},
- mousedown: function(a, b) {},
- selectedClass: "selected",
- items: "li"
- }, a.fn.multisortable = function(b) {
- function c(b, c) {
- if (c.find("." + d.selectedClass).length > 0) {
- var e = b.data("i"),
- f = c.find("." + d.selectedClass).filter(function() {
- return a(this).data("i") < e
- }).css({
- position: "",
- width: "",
- left: "",
- top: "",
- zIndex: ""
- });
- b.before(f);
- var g = c.find("." + d.selectedClass).filter(function() {
- return a(this).data("i") > e
- }).css({
- position: "",
- width: "",
- left: "",
- top: "",
- zIndex: ""
- });
- b.after(g), setTimeout(function() {
- g.add(f).addClass(d.selectedClass)
- }, 0)
- }
- }
- b || (b = {});
- var d = a.extend({}, a.fn.multisortable.defaults, b);
- return this.each(function() {
- var e = a(this);
- e.multiselectable({
- selectedClass: d.selectedClass,
- click: d.click,
- items: d.items,
- mousedown: d.mousedown
- }), b.cancel = d.items + ":not(." + d.selectedClass + ")", b.placeholder = d.placeholder, b.start = function(b, c) {
- if (c.item.hasClass(d.selectedClass)) {
- var e = c.item.parent();
- e.find("." + d.selectedClass).each(function(b) {
- a(this).data("i", b)
- });
- var f = e.find("." + d.selectedClass).length * c.item.outerHeight();
- c.placeholder.height(f)
- }
- d.start(b, c)
- }, b.stop = function(a, b) {
- c(b.item, b.item.parent()), d.stop(a, b)
- }, b.sort = function(b, c) {
- var e = c.item.parent(),
- f = c.item.data("i"),
- g = parseInt(c.item.css("top").replace("px", "")),
- h = parseInt(c.item.css("left").replace("px", ""));
- a.fn.reverse = Array.prototype._reverse || Array.prototype.reverse;
- var i = 0;
- a("." + d.selectedClass, e).filter(function() {
- return a(this).data("i") < f
- }).reverse().each(function() {
- i += a(this).outerHeight(), a(this).css({
- left: h,
- top: g - i,
- position: "absolute",
- zIndex: 1e3,
- width: c.item.width()
- })
- }), i = c.item.outerHeight(), a("." + d.selectedClass, e).filter(function() {
- return a(this).data("i") > f
- }).each(function() {
- var b = a(this);
- b.css({
- left: h,
- top: g + i,
- position: "absolute",
- zIndex: 1e3,
- width: c.item.width()
- }), i += b.outerHeight()
- }), d.sort(b, c)
- }, b.receive = function(a, b) {
- c(b.item, b.sender), d.receive(a, b)
- }, e.sortable(b).disableSelection()
- })
- }, a.fn.multisortable.defaults = {
- start: function(a, b) {},
- stop: function(a, b) {},
- sort: function(a, b) {},
- receive: function(a, b) {},
- click: function(a, b) {},
- mousedown: function(a, b) {},
- selectedClass: "selected",
- placeholder: "placeholder",
- items: "li"
- }
- }(jQuery),
- function(a) {
- "function" == typeof define && define.amd ? define(["jquery"], a) : a(jQuery)
- }(function(a) {
- function b() {
- var b = c(this),
- g = f.settings;
- return isNaN(b.datetime) || (0 == g.cutoff || e(b.datetime) < g.cutoff) && a(this).text(d(b.datetime)), this
- }
- function c(b) {
- if (b = a(b), !b.data("timeago")) {
- b.data("timeago", {
- datetime: f.datetime(b)
- });
- var c = a.trim(b.text());
- f.settings.localeTitle ? b.attr("title", b.data("timeago").datetime.toLocaleString()) : !(c.length > 0) || f.isTime(b) && b.attr("title") || b.attr("title", c)
- }
- return b.data("timeago")
- }
- function d(a) {
- return f.inWords(e(a))
- }
- function e(a) {
- return (new Date).getTime() - a.getTime()
- }
- a.timeago = function(b) {
- return d(b instanceof Date ? b : "string" == typeof b ? a.timeago.parse(b) : "number" == typeof b ? new Date(b) : a.timeago.datetime(b))
- };
- var f = a.timeago;
- a.extend(a.timeago, {
- settings: {
- refreshMillis: 6e4,
- allowFuture: !1,
- localeTitle: !1,
- cutoff: 0,
- strings: {
- prefixAgo: null,
- prefixFromNow: null,
- suffixAgo: "ago",
- suffixFromNow: "from now",
- seconds: "less than a minute",
- minute: "about a minute",
- minutes: "%d minutes",
- hour: "about an hour",
- hours: "about %d hours",
- day: "a day",
- days: "%d days",
- month: "about a month",
- months: "%d months",
- year: "about a year",
- years: "%d years",
- wordSeparator: " ",
- numbers: []
- }
- },
- inWords: function(b) {
- function c(c, e) {
- var f = a.isFunction(c) ? c(e, b) : c,
- g = d.numbers && d.numbers[e] || e;
- return f.replace(/%d/i, g)
- }
- var d = this.settings.strings,
- e = d.prefixAgo,
- f = d.suffixAgo;
- this.settings.allowFuture && 0 > b && (e = d.prefixFromNow, f = d.suffixFromNow);
- var g = Math.abs(b) / 1e3,
- h = g / 60,
- i = h / 60,
- j = i / 24,
- k = j / 365,
- l = 45 > g && c(d.seconds, Math.round(g)) || 90 > g && c(d.minute, 1) || 45 > h && c(d.minutes, Math.round(h)) || 90 > h && c(d.hour, 1) || 24 > i && c(d.hours, Math.round(i)) || 42 > i && c(d.day, 1) || 30 > j && c(d.days, Math.round(j)) || 45 > j && c(d.month, 1) || 365 > j && c(d.months, Math.round(j / 30)) || 1.5 > k && c(d.year, 1) || c(d.years, Math.round(k)),
- m = d.wordSeparator || "";
- return void 0 === d.wordSeparator && (m = " "), a.trim([e, l, f].join(m))
- },
- parse: function(b) {
- var c = a.trim(b);
- return c = c.replace(/\.\d+/, ""), c = c.replace(/-/, "/").replace(/-/, "/"), c = c.replace(/T/, " ").replace(/Z/, " UTC"), c = c.replace(/([\+\-]\d\d)\:?(\d\d)/, " $1$2"), c = c.replace(/([\+\-]\d\d)$/, " $100"), new Date(c)
- },
- datetime: function(b) {
- var c = f.isTime(b) ? a(b).attr("datetime") : a(b).attr("title");
- return f.parse(c)
- },
- isTime: function(b) {
- return "time" === a(b).get(0).tagName.toLowerCase()
- }
- });
- var g = {
- init: function() {
- var c = a.proxy(b, this);
- c();
- var d = f.settings;
- d.refreshMillis > 0 && (this._timeagoInterval = setInterval(c, d.refreshMillis))
- },
- update: function(c) {
- var d = f.parse(c);
- a(this).data("timeago", {
- datetime: d
- }), f.settings.localeTitle && a(this).attr("title", d.toLocaleString()), b.apply(this)
- },
- updateFromDOM: function() {
- a(this).data("timeago", {
- datetime: f.parse(f.isTime(this) ? a(this).attr("datetime") : a(this).attr("title"))
- }), b.apply(this)
- },
- dispose: function() {
- this._timeagoInterval && (window.clearInterval(this._timeagoInterval), this._timeagoInterval = null)
- }
- };
- a.fn.timeago = function(a, b) {
- var c = a ? g[a] : g.init;
- if (!c) throw new Error("Unknown function name '" + a + "' for timeago");
- return this.each(function() {
- c.call(this, b)
- }), this
- }, document.createElement("abbr"), document.createElement("time")
- }),
- function(a) {
- "function" == typeof define && define.amd ? define(["jquery"], a) : a(jQuery)
- }(function(a, b) {
- var c = 0,
- d = Array.prototype.slice,
- e = a.cleanData;
- a.cleanData = function(b) {
- for (var c, d = 0; null != (c = b[d]); d++) try {
- a(c).triggerHandler("remove")
- } catch (f) {}
- e(b)
- }, a.widget = function(b, c, d) {
- var e, f, g, h, i = {},
- j = b.split(".")[0];
- b = b.split(".")[1], e = j + "-" + b, d || (d = c, c = a.Widget), a.expr[":"][e.toLowerCase()] = function(b) {
- return !!a.data(b, e)
- }, a[j] = a[j] || {}, f = a[j][b], g = a[j][b] = function(a, b) {
- return this._createWidget ? void(arguments.length && this._createWidget(a, b)) : new g(a, b)
- }, a.extend(g, f, {
- version: d.version,
- _proto: a.extend({}, d),
- _childConstructors: []
- }), h = new c, h.options = a.widget.extend({}, h.options), a.each(d, function(b, d) {
- return a.isFunction(d) ? void(i[b] = function() {
- var a = function() {
- return c.prototype[b].apply(this, arguments)
- },
- e = function(a) {
- return c.prototype[b].apply(this, a)
- };
- return function() {
- var b, c = this._super,
- f = this._superApply;
- return this._super = a, this._superApply = e, b = d.apply(this, arguments), this._super = c, this._superApply = f, b
- }
- }()) : void(i[b] = d)
- }), g.prototype = a.widget.extend(h, {
- widgetEventPrefix: f ? h.widgetEventPrefix : b
- }, i, {
- constructor: g,
- namespace: j,
- widgetName: b,
- widgetFullName: e
- }), f ? (a.each(f._childConstructors, function(b, c) {
- var d = c.prototype;
- a.widget(d.namespace + "." + d.widgetName, g, c._proto)
- }), delete f._childConstructors) : c._childConstructors.push(g), a.widget.bridge(b, g)
- }, a.widget.extend = function(c) {
- for (var e, f, g = d.call(arguments, 1), h = 0, i = g.length; i > h; h++)
- for (e in g[h]) f = g[h][e], g[h].hasOwnProperty(e) && f !== b && (a.isPlainObject(f) ? c[e] = a.isPlainObject(c[e]) ? a.widget.extend({}, c[e], f) : a.widget.extend({}, f) : c[e] = f);
- return c
- }, a.widget.bridge = function(c, e) {
- var f = e.prototype.widgetFullName || c;
- a.fn[c] = function(g) {
- var h = "string" == typeof g,
- i = d.call(arguments, 1),
- j = this;
- return g = !h && i.length ? a.widget.extend.apply(null, [g].concat(i)) : g, h ? this.each(function() {
- var d, e = a.data(this, f);
- return e ? a.isFunction(e[g]) && "_" !== g.charAt(0) ? (d = e[g].apply(e, i), d !== e && d !== b ? (j = d && d.jquery ? j.pushStack(d.get()) : d, !1) : void 0) : a.error("no such method '" + g + "' for " + c + " widget instance") : a.error("cannot call methods on " + c + " prior to initialization; attempted to call method '" + g + "'")
- }) : this.each(function() {
- var b = a.data(this, f);
- b ? b.option(g || {})._init() : a.data(this, f, new e(g, this))
- }), j
- }
- }, a.Widget = function() {}, a.Widget._childConstructors = [], a.Widget.prototype = {
- widgetName: "widget",
- widgetEventPrefix: "",
- defaultElement: "<div>",
- options: {
- disabled: !1,
- create: null
- },
- _createWidget: function(b, d) {
- d = a(d || this.defaultElement || this)[0], this.element = a(d), this.uuid = c++, this.eventNamespace = "." + this.widgetName + this.uuid, this.options = a.widget.extend({}, this.options, this._getCreateOptions(), b), this.bindings = a(), this.hoverable = a(), this.focusable = a(), d !== this && (a.data(d, this.widgetFullName, this), this._on(!0, this.element, {
- remove: function(a) {
- a.target === d && this.destroy()
- }
- }), this.document = a(d.style ? d.ownerDocument : d.document || d), this.window = a(this.document[0].defaultView || this.document[0].parentWindow)), this._create(), this._trigger("create", null, this._getCreateEventData()), this._init()
- },
- _getCreateOptions: a.noop,
- _getCreateEventData: a.noop,
- _create: a.noop,
- _init: a.noop,
- destroy: function() {
- this._destroy(), this.element.unbind(this.eventNamespace).removeData(this.widgetName).removeData(this.widgetFullName).removeData(a.camelCase(this.widgetFullName)), this.widget().unbind(this.eventNamespace).removeAttr("aria-disabled").removeClass(this.widgetFullName + "-disabled ui-state-disabled"), this.bindings.unbind(this.eventNamespace), this.hoverable.removeClass("ui-state-hover"), this.focusable.removeClass("ui-state-focus")
- },
- _destroy: a.noop,
- widget: function() {
- return this.element
- },
- option: function(c, d) {
- var e, f, g, h = c;
- if (0 === arguments.length) return a.widget.extend({}, this.options);
- if ("string" == typeof c)
- if (h = {}, e = c.split("."), c = e.shift(), e.length) {
- for (f = h[c] = a.widget.extend({}, this.options[c]), g = 0; g < e.length - 1; g++) f[e[g]] = f[e[g]] || {}, f = f[e[g]];
- if (c = e.pop(), d === b) return f[c] === b ? null : f[c];
- f[c] = d
- } else {
- if (d === b) return this.options[c] === b ? null : this.options[c];
- h[c] = d
- }
- return this._setOptions(h), this
- },
- _setOptions: function(a) {
- var b;
- for (b in a) this._setOption(b, a[b]);
- return this
- },
- _setOption: function(a, b) {
- return this.options[a] = b, "disabled" === a && (this.widget().toggleClass(this.widgetFullName + "-disabled ui-state-disabled", !!b).attr("aria-disabled", b), this.hoverable.removeClass("ui-state-hover"), this.focusable.removeClass("ui-state-focus")), this
- },
- enable: function() {
- return this._setOption("disabled", !1)
- },
- disable: function() {
- return this._setOption("disabled", !0)
- },
- _on: function(b, c, d) {
- var e, f = this;
- "boolean" != typeof b && (d = c, c = b, b = !1), d ? (c = e = a(c), this.bindings = this.bindings.add(c)) : (d = c, c = this.element, e = this.widget()), a.each(d, function(d, g) {
- function h() {
- return b || f.options.disabled !== !0 && !a(this).hasClass("ui-state-disabled") ? ("string" == typeof g ? f[g] : g).apply(f, arguments) : void 0
- }
- "string" != typeof g && (h.guid = g.guid = g.guid || h.guid || a.guid++);
- var i = d.match(/^(\w+)\s*(.*)$/),
- j = i[1] + f.eventNamespace,
- k = i[2];
- k ? e.delegate(k, j, h) : c.bind(j, h)
- })
- },
- _off: function(a, b) {
- b = (b || "").split(" ").join(this.eventNamespace + " ") + this.eventNamespace, a.unbind(b).undelegate(b)
- },
- _delay: function(a, b) {
- function c() {
- return ("string" == typeof a ? d[a] : a).apply(d, arguments)
- }
- var d = this;
- return setTimeout(c, b || 0)
- },
- _hoverable: function(b) {
- this.hoverable = this.hoverable.add(b), this._on(b, {
- mouseenter: function(b) {
- a(b.currentTarget).addClass("ui-state-hover")
- },
- mouseleave: function(b) {
- a(b.currentTarget).removeClass("ui-state-hover")
- }
- })
- },
- _focusable: function(b) {
- this.focusable = this.focusable.add(b), this._on(b, {
- focusin: function(b) {
- a(b.currentTarget).addClass("ui-state-focus")
- },
- focusout: function(b) {
- a(b.currentTarget).removeClass("ui-state-focus")
- }
- })
- },
- _trigger: function(b, c, d) {
- var e, f, g = this.options[b];
- if (d = d || {}, c = a.Event(c), c.type = (b === this.widgetEventPrefix ? b : this.widgetEventPrefix + b).toLowerCase(), c.target = this.element[0], f = c.originalEvent)
- for (e in f) e in c || (c[e] = f[e]);
- return this.element.trigger(c, d), !(a.isFunction(g) && g.apply(this.element[0], [c].concat(d)) === !1 || c.isDefaultPrevented())
- }
- }, a.each({
- show: "fadeIn",
- hide: "fadeOut"
- }, function(b, c) {
- a.Widget.prototype["_" + b] = function(d, e, f) {
- "string" == typeof e && (e = {
- effect: e
- });
- var g, h = e ? e === !0 || "number" == typeof e ? c : e.effect || c : b;
- e = e || {}, "number" == typeof e && (e = {
- duration: e
- }), g = !a.isEmptyObject(e), e.complete = f, e.delay && d.delay(e.delay), g && a.effects && a.effects.effect[h] ? d[b](e) : h !== b && d[h] ? d[h](e.duration, e.easing, f) : d.queue(function(c) {
- a(this)[b](), f && f.call(d[0]), c()
- })
- }
- })
- }),
- function(a) {
- "function" == typeof define && define.amd ? define(["jquery"], a) : a(jQuery)
- }(function(a) {
- var b = {
- wheelSpeed: 10,
- wheelPropagation: !1,
- minScrollbarLength: null,
- useBothWheelAxes: !1,
- useKeyboard: !0,
- suppressScrollX: !1,
- suppressScrollY: !1,
- scrollXMarginOffset: 0,
- scrollYMarginOffset: 0,
- onscrollCallback: !1
- };
- a.fn.perfectScrollbar = function(c, d) {
- return this.each(function() {
- var e = a.extend(!0, {}, b),
- f = a(this);
- if ("object" == typeof c ? a.extend(!0, e, c) : d = c, "update" === d) return f.data("perfect-scrollbar-update") && f.data("perfect-scrollbar-update")(), f;
- if ("destroy" === d) return f.data("perfect-scrollbar-destroy") && f.data("perfect-scrollbar-destroy")(), f;
- if (f.data("perfect-scrollbar")) return f.data("perfect-scrollbar");
- f.addClass("ps-container");
- var g, h, i, j, k, l, m, n, o, p, q = a("<div class='ps-scrollbar-x-rail'></div>").appendTo(f),
- r = a("<div class='ps-scrollbar-y-rail'></div>").appendTo(f),
- s = a("<div class='ps-scrollbar-x'></div>").appendTo(q),
- t = a("<div class='ps-scrollbar-y'></div>").appendTo(r),
- u = parseInt(q.css("bottom"), 10),
- v = parseInt(r.css("right"), 10),
- w = function(a, b) {
- var c = a + b,
- d = j - o;
- p = 0 > c ? 0 : c > d ? d : c;
- var e = parseInt(p * (l - j) / (j - o), 10);
- f.scrollTop(e), q.css({
- bottom: u - e
- })
- },
- x = function(a, b) {
- var c = a + b,
- d = i - m;
- n = 0 > c ? 0 : c > d ? d : c;
- var e = parseInt(n * (k - i) / (i - m), 10);
- f.scrollLeft(e), r.css({
- right: v - e
- })
- },
- y = function(a) {
- return e.minScrollbarLength && (a = Math.max(a, e.minScrollbarLength)), a
- },
- z = function() {
- q.css({
- left: f.scrollLeft(),
- bottom: u - f.scrollTop(),
- width: i,
- display: e.suppressScrollX ? "none" : "inherit"
- }), r.css({
- top: f.scrollTop(),
- right: v - f.scrollLeft(),
- height: j,
- display: e.suppressScrollY ? "none" : "inherit"
- }), s.css({
- left: n,
- width: m
- }), t.css({
- top: p,
- height: o
- })
- },
- A = function() {
- i = f.width(), j = f.height(), k = f.prop("scrollWidth"), l = f.prop("scrollHeight"), !e.suppressScrollX && i + e.scrollXMarginOffset < k ? (g = !0, m = y(parseInt(i * i / k, 10)), n = parseInt(f.scrollLeft() * (i - m) / (k - i), 10)) : (g = !1, m = 0, n = 0, f.scrollLeft(0)), !e.suppressScrollY && j + e.scrollYMarginOffset < l ? (h = !0, o = y(parseInt(j * j / l, 10)), p = parseInt(f.scrollTop() * (j - o) / (l - j), 10)) : (h = !1, o = 0, p = 0, f.scrollTop(0)), p >= j - o && (p = j - o), n >= i - m && (n = i - m), z(), e.onscrollCallback && e.onscrollCallback.call(this, f.scrollTop(), l - j)
- },
- B = function() {
- var b, c;
- s.bind("mousedown.perfect-scrollbar", function(a) {
- c = a.pageX, b = s.position().left, q.addClass("in-scrolling"), a.stopPropagation(), a.preventDefault()
- }), a(document).bind("mousemove.perfect-scrollbar", function(a) {
- q.hasClass("in-scrolling") && (x(b, a.pageX - c), a.stopPropagation(), a.preventDefault())
- }), a(document).bind("mouseup.perfect-scrollbar", function(a) {
- q.hasClass("in-scrolling") && q.removeClass("in-scrolling")
- }), b = c = null
- },
- C = function() {
- var b, c;
- t.bind("mousedown.perfect-scrollbar", function(a) {
- c = a.pageY, b = t.position().top, r.addClass("in-scrolling"), a.stopPropagation(), a.preventDefault()
- }), a(document).bind("mousemove.perfect-scrollbar", function(a) {
- r.hasClass("in-scrolling") && (w(b, a.pageY - c), a.stopPropagation(), a.preventDefault())
- }), a(document).bind("mouseup.perfect-scrollbar", function(a) {
- r.hasClass("in-scrolling") && r.removeClass("in-scrolling")
- }), b = c = null
- },
- D = function(a, b) {
- var c = f.scrollTop();
- if (0 === a) {
- if (!h) return !1;
- if (0 === c && b > 0 || c >= l - j && 0 > b) return !e.wheelPropagation
- }
- var d = f.scrollLeft();
- if (0 === b) {
- if (!g) return !1;
- if (0 === d && 0 > a || d >= k - i && a > 0) return !e.wheelPropagation
- }
- return !0
- },
- E = function() {
- var a = !1;
- f.bind("mousewheel.perfect-scrollbar", function(b, c, d, i) {
- e.useBothWheelAxes ? h && !g ? i ? f.scrollTop(f.scrollTop() - i * e.wheelSpeed) : f.scrollTop(f.scrollTop() + d * e.wheelSpeed) : g && !h && (d ? f.scrollLeft(f.scrollLeft() + d * e.wheelSpeed) : f.scrollLeft(f.scrollLeft() - i * e.wheelSpeed)) : (f.scrollTop(f.scrollTop() - i * e.wheelSpeed), f.scrollLeft(f.scrollLeft() + d * e.wheelSpeed)), A(), a = D(d, i), a && b.preventDefault()
- }), f.bind("MozMousePixelScroll.perfect-scrollbar", function(b) {
- a && b.preventDefault()
- })
- },
- F = function() {
- var b = !1;
- f.bind("mouseenter.perfect-scrollbar", function(a) {
- b = !0
- }), f.bind("mouseleave.perfect-scrollbar", function(a) {
- b = !1
- });
- var c = !1;
- a(document).bind("keydown.perfect-scrollbar", function(a) {
- if (b) {
- var d = 0,
- g = 0;
- switch (a.which) {
- case 37:
- d = -3;
- break;
- case 38:
- g = 3;
- break;
- case 39:
- d = 3;
- break;
- case 40:
- g = -3;
- break;
- default:
- return
- }
- f.scrollTop(f.scrollTop() - g * e.wheelSpeed), f.scrollLeft(f.scrollLeft() + d * e.wheelSpeed), c = D(d, g), c && a.preventDefault()
- }
- })
- },
- G = function() {
- var a = function(a) {
- a.stopPropagation()
- };
- t.bind("click.perfect-scrollbar", a), r.bind("click.perfect-scrollbar", function(a) {
- var b = parseInt(o / 2, 10),
- c = a.pageY - r.offset().top - b,
- d = j - o,
- e = c / d;
- 0 > e ? e = 0 : e > 1 && (e = 1), f.scrollTop((l - j) * e)
- }), s.bind("click.perfect-scrollbar", a), q.bind("click.perfect-scrollbar", function(a) {
- var b = parseInt(m / 2, 10),
- c = a.pageX - q.offset().left - b,
- d = i - m,
- e = c / d;
- 0 > e ? e = 0 : e > 1 && (e = 1), f.scrollLeft((k - i) * e)
- })
- },
- H = function() {
- var b = function(a, b) {
- f.scrollTop(f.scrollTop() - b), f.scrollLeft(f.scrollLeft() - a), A()
- },
- c = {},
- d = 0,
- e = {},
- g = null,
- h = !1;
- a(window).bind("touchstart.perfect-scrollbar", function(a) {
- h = !0
- }), a(window).bind("touchend.perfect-scrollbar", function(a) {
- h = !1
- }), f.bind("touchstart.perfect-scrollbar", function(a) {
- var b = a.originalEvent.targetTouches[0];
- c.pageX = b.pageX, c.pageY = b.pageY, d = (new Date).getTime(), null !== g && clearInterval(g), a.stopPropagation()
- }), f.bind("touchmove.perfect-scrollbar", function(a) {
- if (!h && 1 === a.originalEvent.targetTouches.length) {
- var f = a.originalEvent.targetTouches[0],
- g = {};
- g.pageX = f.pageX, g.pageY = f.pageY;
- var i = g.pageX - c.pageX,
- j = g.pageY - c.pageY;
- b(i, j), c = g;
- var k = (new Date).getTime();
- e.x = i / (k - d), e.y = j / (k - d), d = k, a.preventDefault()
- }
- }), f.bind("touchend.perfect-scrollbar", function(a) {
- clearInterval(g), g = setInterval(function() {
- return Math.abs(e.x) < .01 && Math.abs(e.y) < .01 ? void clearInterval(g) : (b(30 * e.x, 30 * e.y), e.x *= .8, void(e.y *= .8))
- }, 10)
- })
- },
- I = function() {
- f.bind("scroll.perfect-scrollbar", function(a) {
- A()
- })
- },
- J = function() {
- f.unbind(".perfect-scrollbar"), a(window).unbind(".perfect-scrollbar"), a(document).unbind(".perfect-scrollbar"), f.data("perfect-scrollbar", null), f.data("perfect-scrollbar-update", null), f.data("perfect-scrollbar-destroy", null), s.remove(), t.remove(), q.remove(), r.remove(), s = t = i = j = k = l = m = n = u = o = p = v = null
- },
- K = function(b) {
- f.addClass("ie").addClass("ie" + b);
- var c = function() {
- var b = function() {
- a(this).addClass("hover")
- },
- c = function() {
- a(this).removeClass("hover")
- };
- f.bind("mouseenter.perfect-scrollbar", b).bind("mouseleave.perfect-scrollbar", c), q.bind("mouseenter.perfect-scrollbar", b).bind("mouseleave.perfect-scrollbar", c), r.bind("mouseenter.perfect-scrollbar", b).bind("mouseleave.perfect-scrollbar", c), s.bind("mouseenter.perfect-scrollbar", b).bind("mouseleave.perfect-scrollbar", c), t.bind("mouseenter.perfect-scrollbar", b).bind("mouseleave.perfect-scrollbar", c)
- },
- d = function() {
- z = function() {
- s.css({
- left: n + f.scrollLeft(),
- bottom: u,
- width: m
- }), t.css({
- top: p + f.scrollTop(),
- right: v,
- height: o
- }), s.hide().show(), t.hide().show()
- }
- };
- 6 === b && (c(), d())
- },
- L = "ontouchstart" in window || window.DocumentTouch && document instanceof window.DocumentTouch,
- M = function() {
- var a = navigator.userAgent.toLowerCase().match(/(msie) ([\w.]+)/);
- a && "msie" === a[1] && K(parseInt(a[2], 10)), A(), I(), B(), C(), G(), L && H(), f.mousewheel && E(), e.useKeyboard && F(), f.data("perfect-scrollbar", f), f.data("perfect-scrollbar-update", A), f.data("perfect-scrollbar-destroy", J)
- };
- return M(), f
- })
- }
- }), Dubtrack.Events = {}, _.extend(Dubtrack.Events, Backbone.Events), Dubtrack.realtime = {
- channel: null,
- dtPubNub: null,
- init: function() {
- var a = null;
- return a = Dubtrack.loggedIn ? Dubtrack.session.get("_id") : PUBNUB.uuid(), Dubtrack.realtime.dtPubNub = PUBNUB.init({
- backfill: !1,
- publish_key: "",
- subscribe_key: Dubtrack.config.keys.pubunub,
- ssl: !0,
- uuid: a
- }), this
- },
- destroy: function() {
- null !== Dubtrack.realtime.channel && (Dubtrack.realtime.dtPubNub.unsubscribe({
- channel: Dubtrack.realtime.channel
- }), Dubtrack.realtime.channel = null, Dubtrack.realtime.dtPubNub = null)
- },
- channelPresence: function(a) {
- null !== Dubtrack.realtime.channel && (null === Dubtrack.realtime.dtPubNub && Dubtrack.realtime.init(), Dubtrack.realtime.dtPubNub.here_now({
- channel: Dubtrack.realtime.channel,
- callback: a
- }))
- },
- subscribe: function(a, b, c) {
- if (null === Dubtrack.realtime.dtPubNub ? Dubtrack.realtime.init() : Dubtrack.realtime.destroy(), void 0 === a || null === a || "" === a) throw new Error("Cannot connect to empty channel");
- Dubtrack.realtime.channel = a, Dubtrack.loggedIn && (a = Dubtrack.realtime.channel + ",dubtrackuser-" + Dubtrack.session.get("_id")), Dubtrack.realtime.dtPubNub.subscribe({
- channel: a,
- callback: function(a) {
- Dubtrack.realtime.callback(a)
- },
- presence: function(a) {
- a.type = "pubnub-" + (a.type ? a.type : "presence"), Dubtrack.realtime.callback(a)
- },
- disconnect: function() {},
- reconnect: function() {},
- connect: function() {
- b && b()
- },
- error: function(a) {}
- })
- },
- callback: function(a) {
- a.type && Dubtrack.Events.trigger("realtime:" + a.type, a)
- }
- }, Dubtrack.els.templates = {
- messages: {
- message: '<div class="image-container"><%= image_str %></div><div class="message-content"><h3><%- name %></h3><p><%- latest_message_str %></p></div><div class="message-time"><%- latest_message %></div>',
- messageItem: '<figure class="media"><%= Dubtrack.helpers.image.getImage(_user._id, _user.username) %></figure><div class="message-content"><h3><%- _user.username %>: </h3><p><%= message %></p></div><div class="message-time"><%- created %></div>'
- },
- comments: {
- commentsContainer: '<% if(Dubtrack.loggedIn) { %><section class="post-comment-container"><figure><%= Dubtrack.helpers.image.getImage(Dubtrack.session.id, Dubtrack.session.username) %></figure><div class="comments-textarea-container"><textarea placeholder="Leave a message..."></textarea><button>Post a comment</button></div></section><% } %><div class="comments-list"></div><button class="comments-display-all">Display all comments</button>',
- commentsItem: '<figure><%= Dubtrack.helpers.image.getImage(user._id, user.username) %></figure><div class="content"><header><a href="#" class="username"><%- user.username %></a><i class="icon-dot"></i><time class="timeago" datetime="<%- date.toISOString() %>"><%- date.toLocaleString() %></time></header><div class="comment-content"><p><%- comment %></p></div><div class="comment-dub"><span class="comment-dubs-total"><%- updubs - downdubs %></span><span class="icon-arrow-up"></span><span>|</span><span class="icon-arrow-down"></span><% if(Dubtrack.session && Dubtrack.session.id == userid) { %><a href="#" class="delete">delete</a><% } %></div></div><a href="#" class="icon-flag"></a>'
- },
- search: {
- searchRoom: ' <img src="' + Dubtrack.config.apiUrl + '/room/<%- _id %>/image/thumbnail-small" alt="" /><span><%- name %></span><span class="count"><%- activeUsers %> users</span>',
- searchUser: " <%= Dubtrack.helpers.image.getImage(_id, username) %><span><%= username %></span>"
- },
- profile: {
- popover: '<div class="usercontent"></div><div class="global-actions"><a href="#" class="send-pm-message" title="Send private message"><span class="icon-chat"></span></a><a href="#" class="chat-mention" title="Mention in chat">@</a></div><div class="actions"><a href="#" class="kick">Kick</a><a href="#" class="ban">Ban for <input type="text" value="" maxlength="3" /> minutes</a><a href="#" class="mute">Mute</a><a href="#" class="unmute">Unmute</a><a href="#" class="setowner setrole" data-roleref="setOwnerUser">Set co-owner</a><a href="#" class="unsetowner unsetrole" data-roleref="setOwnerUser">Unset co-owner</a><a href="#" class="setmanager setrole" data-roleref="setManagerUser">Set manager</a><a href="#" class="unsetmanager unsetrole" data-roleref="setManagerUser">Unset manager</a><a href="#" class="setmod setrole" data-roleref="setModUser">Set mod</a><a href="#" class="unsetmod unsetrole" data-roleref="setModUser">Unset mod</a><a href="#" class="setvip setrole" data-roleref="setVIPUser">Set VIP</a><a href="#" class="unsetvip unsetrole" data-roleref="setVIPUser">Unset VIP</a><a href="#" class="setresdj setrole" data-roleref="setDJUser">Set Resident DJ</a><a href="#" class="unsetresdj unsetrole" data-roleref="setDJUser">Unset Resident DJ</a><a href="#" class="setdj setrole" data-roleref="setRoomDJUser">Set DJ</a><a href="#" class="unsetdj unsetrole" data-roleref="setRoomDJUser">Unset DJ</a></div>',
- popover_user: '<figure><img src="' + Dubtrack.config.apiUrl + '/user/<%- _id %>/image" alt="" /></figure><header><h3><%- username %></h3><span class="dubs"></span></header>',
- profileSidebar: '<div id="profileSidebar"><div id="followersEl"><div class="followingContainer"><div class="followers-counter">Followers<span class="total-followers"></span></div><ul class="avatarList clearfix avatarFollower"></ul></div></div></div>',
- profileView: '<div class="profileWrapper"><div class="profileView"><div class="rewindProfile"><a href="#"><span class="icon-close"></span></a></div><div class="header"><div class="pictureContainer"><% if(Dubtrack.session && Dubtrack.session.id === _id) { %><a class="updatePictureGif" href="#"><span class="icon-camera"></span></a><% } %><%= imgProfile %></div><div class="descriptionProfile"></div></div><div class="infoProfile"><h2><span class="usernameContainer"><%- username %></span><% if(Dubtrack.session && Dubtrack.session.id === _id) { %><input type="text" name="dt_username" value="<%- username %>" maxlength="30" /><div class="check_username_info"></div><span class="edit-btn editUsername">edit</span><span class="edit-btn saveUsername">save</span><span class="edit-btn cancelUsername">cancel</span><% } %></h2><% if(Dubtrack.session && Dubtrack.session.id !== _id) { %><button class="follow follow-btn message"><i class="icon-user"></i> ' + dubtrack_lang.profile.follow + '</button><button class="unfollow follow-btn message">' + dubtrack_lang.profile.unfollow + "</button><% } %></div></div></div>"
- },
- help: {
- chat: '<div class="modal help" id="maindthelp"><div class="modal-header"><button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button><h3>' + dubtrack_lang.help.chat_commands + '</h3></div><div class="modal-body chat-mod-help clearfix"><p class="clearfix"><b>/skip</b><span>' + dubtrack_lang.help.skip + '</span></p><p class="clearfix"><b>/kick @username</b><span>' + dubtrack_lang.help.kick + "</span><b>/kick @username||#</b><span>" + dubtrack_lang.help.kick_time + "</span><b>/ban @username</b><span>" + dubtrack_lang.help.ban + '</span></p><p class="clearfix"><b>/setmod @username</b><span>' + dubtrack_lang.help.set_mod + "</span><b>/removemod @username</b><span>" + dubtrack_lang.help.remove_mod + '</span></p><p class="clearfix"><b>/setdjcount #</b><span>' + dubtrack_lang.help.set_dj_count + "</span><b>/setdj @username</b><span>" + dubtrack_lang.help.set_dj + "</span><b>/removedj @username</b><span>" + dubtrack_lang.help.remove_dj + '</span></p></div><div class="modal-footer"><a href="#" class="btn btn-close">' + dubtrack_lang.help.close + "</a></div>"
- },
- rooms: {
- roomModalView: '<div class="room-info-display-container"><h2><%- name %><span>hosted by <i><%- _user.username %></i></span></h2><div class="description"><%= description %></div></div>',
- roomFormUpdate: ' <form class="form-horizontal"><span class="closebtn icon-close"></span><div class="modal-header mainForm"><h3>' + dubtrack_lang.roomForm.formLabel + '</h3></div><div class="mid"><div class="control-group"><label class="control-label display-block">' + dubtrack_lang.roomForm.roomNameLabel + '</label><div class="controls"><input class="input" name="name" id="roomName" placeholder="' + dubtrack_lang.roomForm.roomNameLabel + '" type="text" value="<%- name %>" maxlength="100"></div></div><div class="control-group" id="background-room-update"><label class="control-label display-block">Room background</label><div class="controls"><input id="fileupload" type="file" name="room_bg"><div id="progress"><div class="bar" style="width: 0%;"></div></div></div></div><div class="larger control-group"><label class="control-label display-block">' + dubtrack_lang.roomForm.roomDescLabel + '</label><div class="controls textarea"><textarea class="textarea" id="roomDescription" name="description" placeholder="' + dubtrack_lang.roomForm.roomDesc + '" maxlength="2000"><%- description %></textarea></div></div><div class="larger control-group"><label class="control-label display-block">Welcome message (you can use {username} and {roomname} as variables :])</label><div class="controls textarea"><textarea class="textarea mid-textarea" id="welcomeMessage" name="welcomeMessage" placeholder="Welcome message" maxlength="300"><%- welcomeMessage %></textarea></div></div><div class="larger control-group"><label class="control-label display-block">Metadata description (this will be shown on social media sites and google search engines)</label><div class="controls textarea"><textarea class="textarea mid-textarea" id="metaDescription" name="metaDescription" placeholder="Metadata description" maxlength="255"><%- metaDescription %></textarea></div></div><div class="control-group"><label class="control-label display-block">Lock queue</label><div class="controls textarea"><select name="lockQueue" id="lockQueueSelect"><option value="1"<% if(lockQueue){%> selected<%}%>>Yes</option><option value="0"<% if(!lockQueue){%> selected<%}%>>No</option></select></div><label class="control-label display-block">Room Type</label><div class="controls textarea"><select name="roomType" id="roomTypeSelect"><option value="room"<% if(roomType && roomType == "room"){%> selected<%}%>>Dubtrack</option><option value="iframe"<% if(roomType && roomType == "iframe"){%> selected<%}%>>Iframe Embed</option></select></div></div><div class="control-group" id="iframeEmbedField"><label class="control-label">Iframe embed url (src value in your embed code)</label><div class="controls textarea"><textarea class="textarea" name="roomEmbed" id="roomEmbedInput" placeholder="Iframe embed url (src value in your embed code)"><%- roomEmbed %></textarea></div><div id="iframe-embed-preview"></div></div></div><div class="modal-footer mainForm"><button class="btn cancel">' + dubtrack_lang.profile.cancel + '</button><button class="btn btn-primary" data-loading-text="' + dubtrack_lang.global.loading + '">' + dubtrack_lang.roomForm.save + "</button></div></form>",
- roomListItem: '<figure class="roomImage"><% if(currentSong && currentSong.songid){ %><img src="' + Dubtrack.config.apiUrl + '/song/<%- currentSong.songid %>/image/large" alt="" /><% } else { %><img src="' + Dubtrack.config.apiUrl + '/room/<%- _id %>/image/thumbnail" alt="" /><% } %><a class="join" href="/join/<%- roomUrl %>"><span>' + dubtrack_lang.room.tune_in + '</span></a></figure><div class="user-count"><% if(activeUsers) { %><span class="icon-people"></span><%- activeUsers %><% } %></div><header><div class="description"><span class="name"><%- name %></span></div><div class="user-info"><div class="room-user">' + dubtrack_lang.room.hosted_by + '<a href="/<%- userid %>" class="navigate"></a></div></div></header><span class="current-song"><% if(currentSong && currentSong.name){ %><%- currentSong.name %><% } else { %>Go ahead, play a song!<% } %></span>',
- avatarsContainer: '<div class="loadingAva">' + dubtrack_lang.global.loading + '</div><div class="avatar_tools"><div class="input-room-users-search"><input type="text" name="room-users-search" placeholder="Filter room users"></div></div><div class="tabsContainer"><div class="tabItem" id="main-user-list-room"><ul class="avatar-list" id="avatar-list"></ul></div></div>',
- avatarsContainerItem: '<p class="username"></p><p class="dubs"><span><%- dubs %> </span> dubs</p>',
- roomBanListItem: '<%- _user.username %><span class="actions">unban</span>',
- roomMuteListItem: '<%- _user.username %><span class="actions">unmute</span>',
- roomStaffListItem: '<%- _user.username %> - <%- roleid.label %><% if (Dubtrack.room.model.get("userid") != _user._id) { %><span class="actions">remove role</span><% } %>'
- },
- chat: {
- chatContainer: '<div class="chat_tools"><span class="display-chat icon-chat active"></span><span class="display-room-users icon-people"><i class="room-user-counter"></i><i class="room-guest-counter"></i></span><span class="display-chat-settings icon-chatsettings"></span></div><div class="chat-options"><span class="chat-option-header">Chat display</span><div class="chat-option-buttons chat-option-buttons-display"><span class="hideImagesToggle">Hide Images</span><span class="clearChatToggle">Clear chat</span></div><span class="chat-option-header">Sound notifications</span><div class="chat-option-buttons chat-option-buttons-sound"><span class="setOnChatNotifications"><i class="icon-volume-high"></i> On</span><span class="setMentionChatNotifications"><i class="icon-volume-high"></i> @Mention</span><span class="setOffChatNotifications"><i class="icon-volume-mute"></i> Off</span></div></div><div class="chat-container"><div class="chatLoading">' + dubtrack_lang.chat.loadingHistory + '</div><div class="hidden" id="sound-notification"></div><div class="chat-messages"><ul class="chat-main"></ul></div><div class="pusher-chat-widget-input"><div id="new-messages-counter"><span class="messages-display"></span> <i class="icon-arrow-down2"></i></div><% if(Dubtrack.loggedIn) { %><input id="chat-txt-message" name="message" type="text" placeholder= "' + dubtrack_lang.chat.type_message + '" autocomplete="off" maxlength="255"><span class="icon-camera"></span><button class= "pusher-chat-widget-send-btn"><span class="icon-arrow-right2"></span></button><% } else { %><div class="chatLogin">' + dubtrack_lang.chat.login_message + "</div><% } %></div></div>",
- chatMessage: '<div class="stream-item-content"><div class="chatDelete"><span class="icon-close"></span></div><div class="image_row"><%= Dubtrack.helpers.image.getImage(user._id, user.username, false, true) %></div><div class="activity-row"><div class="text"><p><a href="#" class="username"><%- user.username %></a> <%= message %></p></div><div class="meta-info"><span class="username"><%- user.username %> </span><i class="icon-dot"></i><span class="timeinfo"></span></div></div></div>'
- },
- playlist: {
- previewContainer: '<div class="close"><span class="icon-close"></span></div><div class="playerDubContainer"></div><div class="comments-container"></div>',
- playlistContainer: '<div class="create-playlist-header">Add to playlist <span class="icon-close"></span></div><div class="create-playlist-input"><input type="text" placeholder="' + dubtrack_lang.playlist.create + '" class="playlist-input" id="playlist-input" maxlength="50" /><span class="icon-add"></span></div><ul class="playlist-list-action"></ul>',
- playlistBrowser: '<%- name %> <span class="playlist-items-count"><%- totalItems %></span>',
- playlistSearchBrowser: '<div class="description"><span><i class="icon-search"></i> <%- name %></span></div>',
- playlistHistoryBrowser: '<div class="description"><input type="text" class="playlist_filter" placeholder="Filter history" value=""></div>',
- playlistInfo: '<div class="description"><input type="text" class="editplaylist_name" placeholder="Playlist name" value="<%- name %>" value="" /><span class="icon-save save-playlistname"></span><input type="text" class="playlist_filter" placeholder="' + dubtrack_lang.playlist.filter + '" value="" /></div><div class="right"><a href="#" class="icon-shuffle shuffle-playlist tt-wrapper"></a><a href="#" class="icon-editplaylist edit-playlist-name tt-wrapper"></a><a href="#" class="icon-trash delete-playlist tt-wrapper"></a><a href="#" class="playlist_type tt-wrapper"></a><a href="#" class="text-button queue-playlist">Queue all</a></div>',
- roomQueueInfo: '<div class="description"><input type="text" class="playlist_filter" placeholder="Filter queue" value="" /></div><div class="right"><a href="#" class="icon-lock room-queue-lock tt-wrapper"></a><a href="#" class="icon-unlocked room-queue-unlock tt-wrapper"></a></div>',
- myQueueInfo: '<div class="description"><input type="text" class="playlist_filter" placeholder="Filter queue" value="" /></div><div class="right"><a href="#" class="icon-shuffle shuffle-playlist tt-wrapper"></a><a href="#" class="text-button clear-queue clear-queue-browser-bth">Clear</a><a href="#" class="text-button pause-queue pause-queue-browser-bth">Pause</a></div>',
- playlistSearchItem: ' <span class="display-error"></span><span class="display-success"></span><span class="timeDisplay"><%- minute %>:<%- second %></span><figure><% if(images.thumbnail) {%><img src="<%- images.thumbnail %>" alt="" /><% } else {%><img src="' + Dubtrack.config.urls.mediaBaseUrl + '/assets/images/media/pic_notfound.jpg" alt="" /><% } %></figure><div class="description"><h2><%- name %></h2><p><span class="preview">' + dubtrack_lang.playlist.preview + '</span></p></div><div class="actions"><a href="#" class="img_bg add_to_queue"><span class="icon-play"></span></a><a class="img_bg add_to_playlist" href="#"><span class="icon-heart"></span></a><a href="#" class="set_song_to_top_queue"><span class="icon-angle-double-up"></span></a><a href="#" class="img_bg remove_icon"><span class="icon-trash"></span></a></div>',
- playlistHistoryItem: '<span class="display-error"></span><span class="timeDisplay"><%- minute %>:<%- second %></span><figure><% if(images.thumbnail) {%><img src="<%- images.thumbnail %>" alt="" /><% } else {%><img src="' + Dubtrack.config.urls.mediaBaseUrl + '/assets/images/media/pic_notfound.jpg" alt="" /><% } %></figure><div class="description"><h2><%- name %></h2><p><span class="preview">' + dubtrack_lang.playlist.preview + '</span><% if (_user) { %><span class="playedby">Played by <b><%- _user.username %></b></span><span class="dubs-display">updubs <b><%- updubs %></b> | downdubs <b><%- downdubs %></b> | grabs <b><%- grabs %></b></span><span class="timeinfo"></span><% if(skipped) { %><span class="skipped">skipped</span><% } %><% } %></p></div><div class="actions"><a href="#" class="img_bg add_to_queue"><span class="icon-play"></span></a><a class="img_bg add_to_playlist" href="#"><span class="icon-heart"></span></a></div>',
- playlistRoomQueueItem: '<span class="display-error"></span><span class="timeDisplay"><%- minute %>:<%- second %></span><figure><% if(images.thumbnail) {%><img src="<%- images.thumbnail %>" alt="" /><% } else {%><img src="' + Dubtrack.config.urls.mediaBaseUrl + '/assets/images/media/pic_notfound.jpg" alt="" /><% } %></figure><div class="description"><h2><%- name %></h2><p><span class="preview">' + dubtrack_lang.playlist.preview + '</span><span class="playedby">Queued by <b><%- _user.username %></b></span></p></div><div class="actions"><a href="#" class="set_song_to_top_queue"><span class="icon-angle-double-up"></span></a><a href="#" class="text-button remove_dj_all">Remove DJ</a><a class="img_bg add_to_playlist" href="#"><span class="icon-heart"></span></a><a href="#" class="img_bg remove_dj"><span class="icon-trash"></span></a></div>'
- },
- layout: {
- header: '<div id="header_login"><a href="/login" id="login-link">LOGIN</a> | <a href="/signup" id="signup-link">SIGN UP</a></div><% if(Dubtrack.loggedIn) {%><div class="header-right-navigation"><div class="user-info"><span><%- username %></span><figure class="user-image"><%= Dubtrack.helpers.image.getImage(_id, username) %></figure></div><div class="user-messages"><span class="message-counter"></span><span class="icon-message"></span></div></div><% } %>',
- soundCloudImportItem: '<%- title %><i class="total-items"><%- total_tracks %></i>',
- browser: '<div class="browser-content"><div id="import-playlist-container"><span class="close-import-playlist icon-close"></span><h3>Import playlists</h3><div class="playlist-type-select playlist-tab-import-active"><span class="icon-youtube import-youtube"></span><span class="icon-soundcloud import-soundcloud"></span></div><div class="import-playlist-youtube"><div class="loading-import">Importing playlist....</div><div class="err-message"></div><input class="youtube-username" placeholder="Youtube playlist ID" /><select class="playlist-select" name="playlist-id"></select><span class="import-playlist icon-inbox">Import</span></div><div class="import-playlist-soundcloud"><div class="loading-import">Importing playlist....</div><div class="err-message"></div><input class="soundcloud-username" placeholder="Soundcloud username" /><div class="playlist-container"><ul></ul></div><select class="playlist-select" name="playlist-id"></select><span class="import-playlist icon-inbox">Import</span></div></div><div class="browser-content-header"><span class="close-browser icon-downvote"></span><div class="form"><input type="text" class="placeholder" name="youtube-search" id="youtube-search" value="" placeholder="' + dubtrack_lang.global.search + '" /><a href="#" class="search-btn"><span class="icon-arrow-right2"></span></a><div class="music-type-select"><span class="current-music-type-selection"><i class="icon-youtube"></i></span><span class="icon-arrow-dropdown"></span><div class="music-type-dropdown"><span class="icon-youtube youtube-btn"></span><span class="icon-soundcloud" id="soundcloud-btn"></span></div></div></div><a href="#" class="close"><span class="icon-remove-circle"></span></a></div><div class="browser-content-main"><div class="sidebar"><div class="display-sidebar"><span class="icon-playlist"></span></div><div class="import-playlist"><span class="icon-inbox"></span> Import playlists</div><div class="create-playlist"><div class="create-playlist-display"><span class="icon-createplaylist"></span> Create playlist</div><div class="create-playlist-form"><input type="text" placeholder="' + dubtrack_lang.playlist.create + '" maxlength="100" /><span class="icon-createplaylist"></span></div></div><div id="queue-next"></div><span class="title">Your playlists</span><div id="playlists-scroll"><ul class="playlist-style"><li class="current_queue"><span class="icon-play"></span>' + dubtrack_lang.playlist.your_queue + '<span class="playlist-items-count"></span></li><li class="current_room_queue"><span class="icon-playlist"></span> ' + dubtrack_lang.playlist.room_queue + '<span class="playlist-items-count"></span></li><li class="room_history"><span class="icon-history"></span>Room history</li></ul><div><ul class="playlist-style playlist-list"></ul></div></div></div><div class="nano"><div class="content-videos"><div class="result-videos"><div class="loading">' + dubtrack_lang.global.loading + '</div><div id="results_video_api"><ul></ul></div></div></div></div></div></div>',
- playerController: '<div class="right"><ul><% if(Dubtrack.loggedIn) {%><li class="display-browser remove-if-banned"><a class="display-browser"><span class="icon-playlist"></span><span class="queue-position"></span><span class="queue-position-split">/</span><span class="queue-total"></span></a></li><li class="add-to-playlist remove-if-banned remove-if-iframe"><a class="add-to-playlist-button"><span class="icon-heart"></span><span class="grab-counter">0</span></a></li><% } %><li class="remove-if-banned remove-if-iframe"><a class="dubup"><span class="icon-arrow-up"></span><span class="dub-counter">0</span></a></li><li class="remove-if-banned remove-if-iframe"><a class="dubdown"><span class="icon-arrow-down"></span><span class="dub-counter">0</span></a></li></ul></div><div class="left"><div class="custom-embed-info">Custom embed channel</div><ul><% if(Dubtrack.loggedIn) {%><li class="playlist remove-if-banned"><a href="/browser" class="navigate"><span class="icon-list"></span></a></li><% } %><li class="imgEl"></li><li class="infoContainer"><div class="infoContainerInner"><div class="progressBg"></div><span class="currentDJSong"></span><span class="currentSong">' + dubtrack_lang.player.joinRoom + '</span><div class="currentTime"><span class="min"></span>:<span class="sec"></span></div></div></li></ul></div>'
- }
- }, Backbone.Collection.prototype.parse = Dubtrack.helpers.parse, Backbone.Model.prototype.idAttribute = "_id", Backbone.Model.prototype.initialize = function() {
- b.ajaxPrefilter(function(a, b, c) {
- a.crossDomain = {
- crossDomain: !0
- }, a.xhrFields = {
- withCredentials: !0
- }
- })
- }, Backbone.View.prototype.close = function() {
- return this.beforeClose && this.beforeClose(), this.remove(), this.unbind(), !1
- }, Dubtrack.Model.chat = Backbone.Model.extend({
- urlRoot: Dubtrack.config.apiUrl + Dubtrack.config.urls.chat,
- defaults: {
- message: null,
- type: null,
- chatid: null
- },
- parse: function(a, b) {
- return a.data
- }
- }), Dubtrack.Model.Comments = Backbone.Model.extend({
- defaults: {
- spamFlag: Number,
- comment: String,
- deleted: Boolean,
- dubs: Number,
- created: Number,
- model: String,
- fkid: String,
- userid: String
- }
- }), Dubtrack.Model.Dubs = Backbone.Model.extend({
- urlRoot: Dubtrack.config.apiUrl + Dubtrack.config.urls.dubs
- }), Dubtrack.Model.Message = Backbone.Model.extend({
- defaults: {
- created: "",
- name: "",
- latest_message: "",
- latest_message_str: "",
- updateItemRead: [],
- usersid: []
- }
- }), Dubtrack.Model.MessageItem = Backbone.Model.extend({
- defaults: {
- created: "",
- message: "",
- userid: "",
- messageid: "",
- _message: {},
- _user: {}
- }
- }), Dubtrack.Model.Playlist = Backbone.Model.extend({
- urlRoot: Dubtrack.config.apiUrl + Dubtrack.config.urls.playlist,
- defaults: {
- name: null,
- status: null,
- isPublic: !1,
- totalItems: 0,
- created: null,
- userid: null
- }
- }), Dubtrack.Model.SoundCloudPlaylist = Backbone.Model.extend({
- defaults: {
- description: null,
- genre: null,
- user_id: null,
- total_tracks: 0,
- title: null,
- permalink: null
- }
- }), Dubtrack.Model.Room = Backbone.Model.extend({
- urlRoot: Dubtrack.config.apiUrl + Dubtrack.config.urls.room,
- defaults: {
- name: null,
- roomDisplay: "public",
- description: null,
- roomUrl: null,
- status: null,
- roomType: null,
- lockQueue: !1,
- isPublic: null,
- lang: null,
- musicType: null,
- metaDescription: null,
- welcomeMessage: null,
- password: null,
- activeUsers: 0,
- allowedDjs: null,
- currentSong: null,
- realTimeChannel: null,
- maxLengthSong: null,
- displayQueue: null,
- background: null,
- roomEmbed: null,
- created: null,
- updated: null,
- userid: null
- }
- }), Dubtrack.Model.UserQueue = Backbone.Model.extend({
- defaults: {
- songLength: 0,
- isActive: !1,
- isPlayed: !1,
- skipped: !1,
- created: 0,
- played: 0,
- updubs: 0,
- downdubs: 0,
- grabs: 0,
- order: 0,
- songid: null,
- roomid: null,
- userid: null
- }
- }), Dubtrack.Model.ActiveQueue = Backbone.Model.extend({
- defaults: {
- song: null,
- songInfo: null,
- user: null,
- startTime: null
- }
- }), Dubtrack.Model.RoomActiveQueue = Backbone.Model.extend({
- defaults: {
- active: null,
- dubs: null,
- ip: null,
- playedCount: null,
- roomid: null,
- skippedCount: null,
- songsInQueue: null,
- updated: null,
- userid: null
- }
- }), Dubtrack.Model.Search = Backbone.Model.extend({
- urlRoot: Dubtrack.config.apiUrl + Dubtrack.config.urls.search,
- parse: Dubtrack.helpers.parse,
- defaults: {
- activeUsers: 0
- }
- }), Dubtrack.Model.Song = Backbone.Model.extend({
- urlRoot: Dubtrack.config.apiUrl + Dubtrack.config.urls.song,
- defaults: {
- name: null,
- description: null,
- images: {},
- genre: null,
- type: null,
- fkid: null,
- streamUrl: null,
- fileUrl: null,
- songArtist: null,
- songLength: 0,
- songBitrate: 0,
- songBpm: 0,
- songMeta: null,
- created: 0,
- updub: 0,
- downdub: 0,
- userid: null
- }
- }), Dubtrack.Model.User = Backbone.Model.extend({
- urlRoot: Dubtrack.config.apiUrl + Dubtrack.config.urls.user,
- defaults: {
- username: null,
- status: 0,
- roleid: null,
- dubs: 0,
- created: 0,
- lastLogin: 0,
- userInfo: {}
- }
- }), Dubtrack.Model.RoomUser = Backbone.Model.extend({
- defaults: {
- updated: Number,
- skippedCount: Number,
- playedCount: Number,
- songsInQueue: Number,
- active: Boolean,
- dubs: Number,
- user: null,
- roomid: String,
- userid: String
- },
- comparator: function(a) {
- return -parseInt(a.get("dubs"), 10)
- }
- }), Dubtrack.Model.UserFollowing = Backbone.Model.extend({
- defaults: {
- userid: String,
- following: String,
- created: Number
- }
- }), Dubtrack.Collection.chat = Backbone.Collection.extend({
- model: Dubtrack.Model.chat
- }), Dubtrack.Collection.Comments = Backbone.Collection.extend({
- model: Dubtrack.Model.Comments
- }), Dubtrack.Collection.Dubs = Backbone.Collection.extend({
- url: Dubtrack.config.apiUrl + Dubtrack.config.urls.dubs,
- model: Dubtrack.Model.Dubs
- }), Dubtrack.Collection.Message = Backbone.Collection.extend({
- url: Dubtrack.config.apiUrl + Dubtrack.config.urls.messages,
- model: Dubtrack.Model.Message
- }), Dubtrack.Collection.MessageItem = Backbone.Collection.extend({
- url: Dubtrack.config.apiUrl + Dubtrack.config.urls.messages_items,
- model: Dubtrack.Model.MessageItem
- }), Dubtrack.Collection.Playlist = Backbone.Collection.extend({
- url: Dubtrack.config.apiUrl + Dubtrack.config.urls.playlist,
- model: Dubtrack.Model.Playlist
- }), Dubtrack.Collection.Room = Backbone.Collection.extend({
- url: Dubtrack.config.apiUrl + Dubtrack.config.urls.room,
- model: Dubtrack.Model.Room
- }), Dubtrack.Collection.RoomUser = Backbone.Collection.extend({
- model: Dubtrack.Model.RoomUser
- }), Dubtrack.Collection.UserQueue = Backbone.Collection.extend({
- model: Dubtrack.Model.UserQueue
- }), Dubtrack.Collection.RoomActiveQueue = Backbone.Collection.extend({
- model: Dubtrack.Model.RoomActiveQueue
- }), Dubtrack.Collection.Song = Backbone.Collection.extend({
- url: Dubtrack.config.apiUrl + Dubtrack.config.urls.song,
- model: Dubtrack.Model.Song
- }), Dubtrack.Collection.User = Backbone.Collection.extend({
- model: Dubtrack.Model.User,
- comparator: function(a) {
- return -1 * a.get("dubs")
- }
- }), Dubtrack.Collection.UserFollowing = Backbone.Collection.extend({
- model: Dubtrack.Model.UserFollowing
- }), f.global.friendClickAction = !1, f.global.friendsView = Backbone.View.extend({
- tagName: "div",
- events: {
- "click .close": "closeAction"
- },
- initialize: function() {
- b(this.el).attr({
- "class": "ajax_container no-padding",
- id: "ajax_tmp_loader"
- })
- },
- render: function() {
- b(this.el).html(tpl.get("friendCont")), this.friendsUlEl = b(this.el).find("#friends_list");
- var a = this;
- return f.global.friendClickAction || (f.global.friendClickAction = !0, b("body").bind("click", function(c) {
- $parents = b(c.target).parents("#friends_list"), 0 === $parents.length && b(a.el).hide()
- })), this
- },
- closeAction: function() {
- return b(this.el).hide(), !1
- },
- fetchData: function(a, c) {
- b(this.el).show().css({
- top: a,
- right: c
- }), this.friendsUlEl.html(dubtrack_lang.global.loading);
- var d = this;
- this.model.fetch({
- success: function(a, b) {
- d.friendsUlEl.html(""), d.resetEl(b.data.friends_online, b.data.friends_offline)
- }
- })
- },
- resetEl: function(a, c) {
- this.friendsUlEl.append(b("<li/>", {
- "class": "cyan"
- }).html(dubtrack_lang.global.online + "(" + a.length + ")")), _.each(a, function(a) {
- this.appendEl(a, "friendsItem")
- }, this), this.friendsUlEl.append(b("<li/>", {
- "class": "cyan"
- }).html(dubtrack_lang.global.offline + "(" + c.length + ")")), _.each(c, function(a) {
- this.appendEl(a, "friendsOffline")
- }, this)
- },
- appendEl: function(a, c) {
- var a = b(new f.global.friendsViewItem({
- model: new f.global.friendsModel(a)
- }).render(c).el).appendTo(this.friendsUlEl)
- }
- }), f.global.friendsViewItem = Backbone.View.extend({
- tagName: "li",
- events: {
- click: "clickAction"
- },
- render: function(a) {
- var c = g.helpers.getProfileImg(this.model.get("oauth_uid"), this.model.get("username"), this.model.get("oauth_provider"));
- return this.model.set({
- img: c
- }), b(_.template(tpl.get(a), this.model.toJSON())).appendTo(b(this.el)), this
- },
- clickAction: function() {
- g.app.navigate("/" + this.model.get("username"), {
- trigger: !0
- }), this.close()
- }
- }), Dubtrack.View.LayoutView = Backbone.View.extend({
- el: b("body"),
- events: {
- "click #header-global .header-right-navigation .user-info": "navigateUser",
- "click #header-global a.navigate": "navigate",
- "click #header-global li.logout": "logout",
- "click #header-global .header-left-navigation h1": "setActiveMenu",
- "mouseenter #header-global .header-left-navigation h1": "setActiveMenu",
- "click #header-global #header_login #login-link": "displayLogin",
- "click #header-global #header_login #signup-link": "displaySignup",
- "click #header-global .user-messages": "setActiveMenuRight",
- "click #mobile-room-menu .chat-button": "diplayChatLayout",
- "click #mobile-room-menu .player-button": "diplayPlayerLayout"
- },
- displayLogin: function(a) {
- a.preventDefault(), Dubtrack.app.navigate("/login", {
- trigger: !0
- })
- },
- displaySignup: function(a) {
- a.preventDefault(), Dubtrack.app.navigate("/signup", {
- trigger: !0
- })
- },
- diplayPlayerLayout: function() {
- return this.$el.removeClass("diplay-chat"), !1
- },
- diplayChatLayout: function() {
- return this.$el.addClass("diplay-chat"), !1
- },
- initialize: function() {
- this.$("#header-global").append(_.template(Dubtrack.els.templates.layout.header, Dubtrack.session.toJSON())), this.searchView = new Dubtrack.View.SearchView({
- el: this.$("li.global-search-header")
- }), Dubtrack.loggedIn ? (this.$("#mobile-login").hide(), Dubtrack.Events.bind("realtime:user-update-" + Dubtrack.session.id, this.updateImage, this)) : (this.$("#header_login").show(), b("body").addClass("not-logged-in")), this.menu_right = new Dubtrack.View.MainRightMenuView, this.menu_left = new Dubtrack.View.MainLeftMenuView, b("body").bind("click", function(a) {
- 0 === b(a.target).parents("#main-menu-left").length && b("html").removeClass("menu-left-in"), 0 === b(a.target).parents("#main-menu-right").length && (b("html").removeClass("menu-right-in"), Dubtrack.layout.menu_right.message_view.$el.removeClass("view-message-details"))
- }.bind(this)), emojify.setConfig({
- img_dir: Dubtrack.config.urls.mediaBaseUrl + "/assets/emoji/images/emoji"
- }), this.main_login_window = new Dubtrack.View.LoginMainWindowView, this.getNewMessages()
- },
- setActiveMenu: function() {
- return b("html").addClass("menu-left-in"), !1
- },
- setActiveMenuRight: function() {
- return b("html").toggleClass("menu-right-in"), b("html").hasClass("menu-right-in") ? this.menu_right.loadMessages() : Dubtrack.layout.menu_right.message_view.$el.removeClass("view-message-details"), !1
- },
- getNewMessages: function() {
- var a = Dubtrack.config.apiUrl + Dubtrack.config.urls.messages_news,
- b = this;
- this.timeout_newmessages && clearTimeout(b.timeout_newmessages), Dubtrack.helpers.sendRequest(a, {}, "get", function(a, c) {
- if (c && c.data) {
- var d = parseInt(c.data, 10);
- d > 0 ? b.$(".user-messages .message-counter").html(d).show() : b.$(".user-messages .message-counter").hide()
- } else b.$(".user-messages .message-counter").hide();
- b.timeout_newmessages = setTimeout(function() {
- b.getNewMessages()
- }, 3e4)
- })
- },
- updateImage: function(a) {
- a && a.img && a.img.url && this.$("figure.user-image img").attr("src", a.img.url)
- },
- logout: function() {
- window.location = "/login/logout"
- },
- render: function() {},
- navigate: function(a) {
- return this.$(".menu-expand").removeClass("active"), $href = b(a.target).attr("href"), $href && Dubtrack.app.navigate($href, {
- trigger: !0
- }), !1
- },
- navigateUser: function() {
- return Dubtrack.app.navigate("/" + Dubtrack.session.get("username"), {
- trigger: !0
- }), !1
- }
- }), Dubtrack.View.SearchView = Backbone.View.extend({
- events: {
- "keyup input#global-search": "renderSearchResults"
- },
- initialize: function() {
- this.model = new Dubtrack.Model.Search, this.model.bind("change", this.render, this), this.model.bind("reset", this.render, this), this.search_results = this.$(".search-results"), this.search_results_rooms = this.$(".search-results-rooms"), this.search_results_users = this.$(".search-results-users");
- var a = this;
- b(window).on("click", function(c) {
- var d = b(c.target).parents(".global-search-header");
- 0 === d.length && (a.search_results.hide(), a.$("input#global-search").val(""))
- })
- },
- render: function() {
- this.search_results_rooms.empty(), this.search_results_users.empty();
- var a = this.model.get("rooms"),
- b = this.model.get("users"),
- c = this;
- a && a.length > 0 ? _.each(a, function(a) {
- c.appendRoomItem(a)
- }) : this.search_results_rooms.append('<div class="result-item"><span class="count">No results found</span></div>'), b && b.length > 0 ? _.each(b, function(a) {
- c.appendUserItem(a)
- }) : this.search_results_users.append('<div class="result-item"><span class="count">No results found</span></div>')
- },
- appendRoomItem: function(a) {
- this.search_results_rooms.append((new Dubtrack.View.SearchRoomItem).render(a).$el)
- },
- appendUserItem: function(a) {
- this.search_results_users.append((new Dubtrack.View.SearchUserItem).render(a).$el)
- },
- renderSearchResults: function() {
- var a = b.trim(this.$("input#global-search").val());
- if ("" === a || null === a) return void this.search_results.hide();
- this.search_results.show();
- this.model.fetch({
- data: {
- query: a
- }
- })
- }
- }), Dubtrack.View.SearchRoomItem = Backbone.View.extend({
- attributes: {
- "class": "result-item"
- },
- events: {
- click: "clickAction"
- },
- initialize: function() {},
- render: function(a) {
- return this.room = a, a.activeUsers || (a.activeUsers = 0), this.$el.html(_.template(Dubtrack.els.templates.search.searchRoom, a)), this
- },
- clickAction: function() {
- return window.location = "/join/" + this.room.roomUrl, Dubtrack.layout.searchView.$("input#global-search").val(""), Dubtrack.layout.searchView.search_results.hide(), !1
- }
- }), Dubtrack.View.SearchUserItem = Backbone.View.extend({
- attributes: {
- "class": "result-item"
- },
- events: {
- click: "clickAction"
- },
- initialize: function() {},
- render: function(a) {
- return this.user = a, this.$el.html(_.template(Dubtrack.els.templates.search.searchUser, a)), this
- },
- clickAction: function() {
- return Dubtrack.app.navigate("/" + this.user.username, {
- trigger: !0
- }), Dubtrack.layout.searchView.$("input#global-search").val(""), Dubtrack.layout.searchView.search_results.hide(), !1
- }
- }), Dubtrack.View.MainRightMenuView = Backbone.View.extend({
- el: b("#main-menu-right"),
- events: {
- "click a.close-menu": "closeMenu"
- },
- initialize: function() {
- this.message_view = new Dubtrack.View.Message.Main
- },
- loadMessages: function() {
- this.message_view.loadMessages()
- },
- closeMenu: function() {
- return b("html").removeClass("menu-right-in"), !1
- }
- }), Dubtrack.View.MainLeftMenuView = Backbone.View.extend({
- el: b("#main-menu-left"),
- events: {
- "click a.navigate": "navigate",
- "click a.close-menu": "closeMenu",
- mouseleave: "closeMenu"
- },
- initialize: function() {
- Dubtrack.loggedIn && this.$("a.logout-link").css("display", "block")
- },
- closeMenu: function() {
- return b("html").removeClass("menu-left-in"), !1
- },
- navigate: function(a) {
- var c = b(a.target).attr("href");
- return c && (b("html").removeClass("menu-left-in"), Dubtrack.app.navigate(c, {
- trigger: !0
- })), !1
- }
- }), Dubtrack.View.LoginMainWindowView = Backbone.View.extend({
- el: b("#login-model-window"),
- events: {
- "click .close-login-window": "hideWindow"
- },
- initialize: function() {
- return Dubtrack.loggedIn ? void this.$el.remove() : (this.signup_window = new Dubtrack.View.LoginWindowView({
- el: this.$("#login-create-window")
- }), this.forgot_window = new Dubtrack.View.LoginWindowView({
- el: this.$("#login-forgot-window")
- }), this.login_window = new Dubtrack.View.LoginWindowView({
- el: this.$("#login-window")
- }), this.change_window = new Dubtrack.View.LoginWindowView({
- el: this.$("#login-chage-password-window")
- }), this.login_password_window = new Dubtrack.View.LoginWindowView({
- el: this.$("#login-passwordupdate-window")
- }), this.signup_window.formSuccess = function() {
- this.sucess_el.text("Thanks for signing up! We sent you a verification email"), this.sucess_el.show()
- }, this.forgot_window.formSuccess = function() {
- this.sucess_el.text("We sent you an email, please follow the link to change your password"), this.sucess_el.show()
- }, this.change_window.formSuccess = function() {
- this.displayWindow("login_password_window")
- }.bind(this), this.login_window.formSuccess = function() {
- this.sucess_el.text("Login successful"), this.sucess_el.show(), Dubtrack.room && Dubtrack.room.model ? location.href = "/join/" + Dubtrack.room.model.get("roomUrl") : location.href = "/"
- }, void(this.login_password_window.formSuccess = function() {
- this.sucess_el.text("Login successful"), this.sucess_el.show(), Dubtrack.room && Dubtrack.room.model ? location.href = "/join/" + Dubtrack.room.model.get("roomUrl") : location.href = "/"
- }))
- },
- hideWindow: function() {
- this.$el.hide(), Dubtrack.room && Dubtrack.room.model ? Dubtrack.app.navigate("/join/" + Dubtrack.room.model.get("roomUrl"), {
- trigger: !0
- }) : Dubtrack.app.navigate("/lobby", {
- trigger: !0
- })
- },
- displayWindow: function(a) {
- return this[a] && this[a].$el ? (this.$el.show(), Dubtrack.els.mainLoading.hide(), this.$(".login-model-container").removeClass("show-form"), this.$(".login-model-container form").show(), this.$(".login-model-container form .err-message").hide(), this.$(".login-model-container .success-message").hide(), this[a].$el.addClass("show-form"), void("signup_window" !== a || this.captcah_loaded || (this.captcah_loaded = !0, b.getScript("https://www.google.com/recaptcha/api.js?onload=onRecaptchaloadCallback&render=explicit")))) : !1
- }
- }), Dubtrack.View.LoginWindowView = Backbone.View.extend({
- events: {
- "click .account-actions a": "triggerAction",
- "submit form": "submitForm"
- },
- initialize: function() {
- this.form_el = this.$("form"), this.password_el = this.$("form input[name=password]"), this.password2_el = this.$("form input[name=password2]"), this.token_el = this.$("form input[name=token]"), this.submit_el = this.$("form input[type=submit]"), this.form_target = this.form_el.length ? this.form_el.attr("action") : null, this.error_el = this.$("form .err-message"), this.sucess_el = this.$(".success-message"), this.token = null
- },
- triggerAction: function(a) {
- a.preventDefault();
- var c = b(a.target);
- if (c.is("a") || c.parents("a"), c) {
- var d = c.attr("href");
- d && Dubtrack.app.navigate(d, {
- trigger: !0
- })
- }
- },
- submitForm: function(a) {
- if (a.preventDefault(), this.error_el.hide(), this.sucess_el.hide(), this.form_target) {
- if (this.password2_el.length && this.password_el.length && this.password2_el.val() !== this.password_el.val()) return this.error_el.show(), void this.error_el.html("Passwords don't match");
- this.submit_el.attr("disabled", !0);
- var c = this.submit_el.val();
- this.submit_el.val("loading..."), this.token && this.token_el.length && this.token_el.val(this.token);
- var d = this.form_el.serialize();
- b.post(Dubtrack.config.apiUrl + this.form_target, d).fail(function(a) {
- try {
- var b = JSON.parse(a.responseText);
- b.data && b.data.details && b.data.details.message ? this.error_el.text(b.data.details.message) : this.error_el.text("error on form submission")
- } catch (c) {
- this.error_el.text("error on form submission")
- }
- this.error_el.show();
- try {
- grecaptcha.reset()
- } catch (c) {}
- }.bind(this)).done(function() {
- this.form_el.hide(), this.formSuccess()
- }.bind(this)).always(function() {
- this.submit_el.val(c), this.submit_el.attr("disabled", !1)
- }.bind(this))
- }
- },
- formSuccess: function() {}
- }), Dubtrack.View.PlayerController = Backbone.View.extend({
- el: b("#player-controller"),
- volume: 100,
- events: {
- "click .dubup": "voteUpAction",
- "click .dubdown": "voteDownAction",
- "click .add-to-playlist": "addToPlaylist",
- "click .display-browser": "displayBrowser"
- },
- initialize: function() {
- this.$el.html(_.template(Dubtrack.els.templates.layout.playerController)), this.volumeSliderEl = b("#volume-div"), this.fetchQueueInfoThrottled = _.debounce(this.fetchQueueInfo.bind(this), 1e3), Dubtrack.Events.bind("realtime:room_playlist-dub", this.realTimeDub, this), Dubtrack.Events.bind("realtime:room_playlist-queue-update-grabs", this.realTimeGrab, this), Dubtrack.Events.bind("realtime:room_playlist-update", this.realTimeUpdate, this), Dubtrack.Events.bind("realtime:room_playlist-queue-reorder", this.fetchQueueInfoThrottled, this), Dubtrack.Events.bind("realtime:room_playlist-queue-update-dub", this.fetchQueueInfoThrottled, this), Dubtrack.Events.bind("realtime:room_playlist-queue-remove-user", this.fetchQueueInfoThrottled, this), Dubtrack.Events.bind("realtime:user-leave", this.fetchQueueInfoThrottled, this), this.volumeControl()
- },
- update: function() {
- return this.addToPlaylistButton = this.$(".add-to-playlist-button"), this.voteUp = b(".dubup"), this.voteUpCounter = b(".dubup .dub-counter"), this.grabCounter = b(".add-to-playlist-button .grab-counter"), this.voteDown = b(".dubdown"), this.voteDownCounter = b(".dubdown .dub-counter"), this.queuePosition = this.$(".queue-position"), this.queuePositionSplit = this.$(".queue-position-split"), this.queueTotal = this.$(".queue-total"), this.inQueue = !1, this.updateVote(), this.fetchQueueInfo(), !1
- },
- realTimeUpdate: function(a) {
- Dubtrack.helpers.cookie["delete"]("dub-" + Dubtrack.room.model.get("_id")), Dubtrack.helpers.cookie["delete"]("grab-" + Dubtrack.room.model.get("_id")), this.fetchQueueInfoThrottled.call()
- },
- addToPlaylist: function(a) {
- if (Dubtrack.loggedIn) {
- var c = Dubtrack.room.player.activeSong.get("song");
- if (!Dubtrack.room || null === c) return !1;
- var d = {
- right: 200,
- bottom: 43
- };
- return Dubtrack.helpers.genPlaylistContainer(b("body"), d, c.songid, !1, "playerBottomFixed"), b("html, body").scrollTop(0), !1
- }
- },
- displayBrowser: function() {
- Dubtrack.app.navigate("/browser/queue", {
- trigger: !0
- })
- },
- fetchQueueInfo: function() {
- Dubtrack.room.player.activeQueueCollection.fetch({
- reset: !0,
- success: function() {
- var a = 0,
- b = !1;
- this.queueTotal.html() != Dubtrack.room.player.activeQueueCollection.length && this.queueTotal.html(Dubtrack.room.player.activeQueueCollection.length), Dubtrack.app.browserView && Dubtrack.app.browserView.$("#playlists-scroll .current_room_queue .playlist-items-count").text(Dubtrack.room.player.activeQueueCollection.length), _.each(Dubtrack.room.player.activeQueueCollection.models, function(c) {
- a++, Dubtrack.session.id == c.get("userid") && (this.inQueue = !0, b = !0, this.queuePositionSplit.show(), this.queuePosition.html(a), Dubtrack.app.browserView && Dubtrack.app.browserView.$("#playlists-scroll .current_queue .playlist-items-count").text(c.get("songsInQueue")))
- }, this), b || (this.inQueue = !1, Dubtrack.app.browserView && Dubtrack.app.browserView.$("#playlists-scroll .current_queue .playlist-items-count").text(0), this.queuePosition.empty(), this.queuePositionSplit.hide())
- }.bind(this)
- })
- },
- voteUpAction: function() {
- return this.vote("updub"), !1
- },
- voteDownAction: function() {
- return this.vote("downdub"), !1
- },
- realTimeDub: function(a) {
- var b = Dubtrack.room.player.activeSong.get("song");
- Dubtrack.room && null !== b && a.playlist._id === b._id && (this.voteUpCounter.text(a.playlist.updubs), this.voteDownCounter.text(a.playlist.downdubs), this.grabCounter.text(a.playlist.grabs), Dubtrack.room.player.activeSong.set({
- song: a.playlist
- }))
- },
- realTimeGrab: function(a) {
- a && a.playlist && a.playlist.grabs && (this.grabCounter.text(a.playlist.grabs), Dubtrack.session && Dubtrack.session.id == a.user._id && (this.addToPlaylistButton.addClass("grabbed"), Dubtrack.helpers.cookie.set("grab-" + Dubtrack.room.model.get("_id"), "grab", 30)))
- },
- shareFacebook: function() {
- var a = Dubtrack.room.player.activeSong.get("songInfo"),
- b = encodeURIComponent(Dubtrack.config.globalBaseUrl + "join/" + Dubtrack.room.model.get("roomUrl")),
- c = "";
- c = Dubtrack.room && null !== a ? encodeURIComponent(_.template(dubtrack_lang.room.facebookShare, {
- song: a.name
- })) : "Join my dubtrack.fm room";
- var d = "https://www.facebook.com/sharer.php?u=" + b + "&t=" + c,
- e = dubtrack_lang.room.shareTitle,
- f = "width=600,height=500,scrollbars=yes";
- return window.open(d, e, f), !1
- },
- shareTwitter: function() {
- var a = Dubtrack.room.player.activeSong.get("songInfo"),
- b = encodeURIComponent(Dubtrack.config.globalBaseUrl + "join/" + Dubtrack.room.model.get("roomUrl")),
- c = "";
- c = Dubtrack.room && null !== a ? encodeURIComponent(_.template(dubtrack_lang.room.twitterShare, {
- song: a.name
- })) : "Join my dubtrack.fm room";
- var d = "https://twitter.com/share?url=" + b + "&text=" + c,
- e = dubtrack_lang.room.shareTitle,
- f = "width=600,height=500,scrollbars=yes";
- return window.open(d, e, f), !1
- },
- vote: function(a) {
- if (Dubtrack.loggedIn) {
- var c = Dubtrack.room.player.activeSong.get("song");
- if (Dubtrack.room && null !== c) {
- var d = Dubtrack.config.urls.dubsPlaylistActive.replace(":id", Dubtrack.room.model.get("_id")).replace(":playlistid", c._id),
- e = Dubtrack.helpers.cookie.get("dub-" + Dubtrack.room.model.get("_id")),
- f = Dubtrack.helpers.cookie.get("dub-song"),
- g = c.updubs - c.downdubs;
- if (c.songid !== f && (e = null), !e || e !== a)
- if (Dubtrack.helpers.sendRequest(Dubtrack.config.apiUrl + d, {
- type: a
- }, "post"), b(".voted").removeClass("voted"), Dubtrack.helpers.cookie.set("dub-" + Dubtrack.room.model.get("_id"), a, 30), Dubtrack.helpers.cookie.set("dub-song", c.songid, 30), "updub" === a) {
- var h = parseInt(this.voteUpCounter.text(), 10),
- i = parseInt(this.voteDownCounter.text(), 10);
- e && (this.voteDownCounter.text(i - 1), g += 1), this.voteUpCounter.text(h + 1), g += 1
- } else {
- var h = parseInt(this.voteUpCounter.text(), 10),
- i = parseInt(this.voteDownCounter.text(), 10);
- e && (this.voteUpCounter.text(h - 1), g -= 1), this.voteDownCounter.text(i + 1), g -= 1
- }
- "updub" == a ? this.voteUp.addClass("voted") : this.voteDown.addClass("voted")
- }
- }
- },
- updateVote: function() {
- b(".voted").removeClass("voted"), this.addToPlaylistButton.removeClass("grabbed"), this.grabCounter.text(0), this.voteUpCounter.text(0), this.voteDownCounter.text(0);
- var a = Dubtrack.room.player.activeSong.get("song");
- if (null !== a) {
- var c = a.updubs - a.downdubs,
- d = Dubtrack.helpers.cookie.get("dub-" + Dubtrack.room.model.get("_id")),
- e = Dubtrack.helpers.cookie.get("grab-" + Dubtrack.room.model.get("_id")),
- f = Dubtrack.helpers.cookie.get("dub-song");
- a.songid !== f && (d = null), isNaN(c) && (c = 0), d && ("updub" === d ? this.voteUp.addClass("voted") : this.voteDown.addClass("voted")), e && this.addToPlaylistButton.addClass("grabbed"), this.voteUpCounter.text(a.updubs), this.voteDownCounter.text(a.downdubs), a.grabs && this.grabCounter.text(a.grabs)
- }
- },
- volumeControl: function() {
- var a = this,
- b = Dubtrack.helpers.cookie.get("dubtrack-room-volume");
- b || (b = 100), this.volumeSliderEl.slider({
- value: b,
- orientation: "horizontal",
- range: "min",
- animate: !1,
- slide: function(b, c) {
- a.setVolume(c.value, !1)
- },
- change: function(b, c) {
- a.setVolume(c.value, !0)
- }
- }), this.setVolume(b)
- },
- setVolume: function(a) {
- Dubtrack.helpers.cookie.set("dubtrack-room-volume", a, 30), this.volume = a, Dubtrack.room.player && Dubtrack.room.player.setVolume(a)
- }
- }), f.global.userPopover = Backbone.View.extend({
- tagName: "div",
- id: "user_popover",
- events: {
- "click a.kick": "kickuser",
- "click a.ban": "banuser",
- "keydown a.ban input": "banuserKeydown",
- "click a.mute": "muteuser",
- "click a.unmute": "unmuteuser",
- "click .usercontent": "navigateUser",
- "click a.unsetrole": "unsetRole",
- "click a.setrole": "setRole",
- "click a.chat-mention": "mentionUserInChat",
- "click a.send-pm-message": "sendPersonalMessage"
- },
- initialize: function() {
- this.offset_top = 0, this.$el.html(Dubtrack.els.templates.profile.popover)
- },
- displayUser: function(a) {
- Dubtrack.cache.users.get(a, this.renderUser, this), this.userActive = !1, Dubtrack.session && Dubtrack.room && Dubtrack.room.users ? Dubtrack.session.get("_id") == a ? (this.$(".global-actions").hide(), this.$(".actions").hide()) : (this.$(".global-actions").show(), this.$(".actions a").hide(), (Dubtrack.helpers.isDubtrackAdmin(Dubtrack.session.id) || Dubtrack.room.users.getIfHasRole(Dubtrack.session.id) || Dubtrack.room.model.get("userid") == Dubtrack.session.id) && (this.$(".actions").show(), this.$(".actions a.send-pm-message").show(), Dubtrack.helpers.isDubtrackAdmin(Dubtrack.session.id) || Dubtrack.room.users.getIfOwner(Dubtrack.session.id) || Dubtrack.room.users.getIfMod(Dubtrack.session.id) || Dubtrack.room.users.getIfVIP(Dubtrack.session.id) || Dubtrack.room.users.getIfResidentDJ(Dubtrack.session.id) || Dubtrack.room.users.getIfManager(Dubtrack.session.id), Dubtrack.helpers.isDubtrackAdmin(Dubtrack.session.id) || Dubtrack.room.users.getIfOwner(Dubtrack.session.id) || Dubtrack.room.users.getIfMod(Dubtrack.session.id) || Dubtrack.room.users.getIfVIP(Dubtrack.session.id) || Dubtrack.room.users.getIfManager(Dubtrack.session.id), (Dubtrack.helpers.isDubtrackAdmin(Dubtrack.session.id) || Dubtrack.room.users.getIfOwner(Dubtrack.session.id) || Dubtrack.room.users.getIfMod(Dubtrack.session.id) || Dubtrack.room.users.getIfManager(Dubtrack.session.id)) && (Dubtrack.room.users.getIfmuted(a) ? (this.$(".actions a.mute").hide(), this.$(".actions a.unmute").show()) : (this.$(".actions a.mute").show(), this.$(".actions a.unmute").hide()), this.$(".actions a.kick").show(), this.$(".actions a.ban").show()), (Dubtrack.helpers.isDubtrackAdmin(Dubtrack.session.id) || Dubtrack.room.users.getIfOwner(Dubtrack.session.id) || Dubtrack.room.users.getIfManager(Dubtrack.session.id)) && (Dubtrack.room.users.getIfMod(a) ? (this.$(".actions a.setmod").hide(), this.$(".actions a.unsetmod").show()) : (this.$(".actions a.unsetmod").hide(), this.$(".actions a.setmod").show()), Dubtrack.room.users.getIfVIP(a) ? (this.$(".actions a.setvip").hide(), this.$(".actions a.unsetvip").show()) : (this.$(".actions a.setvip").show(), this.$(".actions a.unsetvip").hide()), Dubtrack.room.users.getIfResidentDJ(a) ? (this.$(".actions a.setresdj").hide(), this.$(".actions a.unsetresdj").show()) : (this.$(".actions a.setresdj").show(), this.$(".actions a.unsetresdj").hide()), Dubtrack.room.users.getIfDJ(a) ? (this.$(".actions a.setdj").hide(), this.$(".actions a.unsetdj").show()) : (this.$(".actions a.setdj").show(), this.$(".actions a.unsetdj").hide())), (Dubtrack.helpers.isDubtrackAdmin(Dubtrack.session.id) || Dubtrack.room.users.getIfOwner(Dubtrack.session.id)) && (Dubtrack.room.users.getIfManager(a) ? (this.$(".actions a.setmanager").hide(), this.$(".actions a.unsetmanager").show()) : (this.$(".actions a.setmanager").show(), this.$(".actions a.unsetmanager").hide())), Dubtrack.room.model.get("userid") == Dubtrack.session.id && (Dubtrack.room.users.getIfOwner(a) ? (this.$(".actions a.setowner").hide(), this.$(".actions a.unsetowner").show()) : (this.$(".actions a.setowner").show(), this.$(".actions a.unsetowner").hide())))) : (this.$(".actions").hide(), this.$(".global-actions").hide()), (Dubtrack.helpers.isDubtrackAdmin(a) || Dubtrack.room.model.get("userid") == a) && this.$(".actions").hide(), (Dubtrack.helpers.isDubtrackAdmin(a) || Dubtrack.room.users.getIfHasRole(a)) && (this.$(".actions a.mute").hide(), this.$(".actions a.kick").hide(), this.$(".actions a.ban").hide());
- var c = this;
- b("body").bind("click.userPopover", function(a) {
- c.userActive && a && a.target && 0 === b(a.target).parents("a.ban").length && (c.userActive = !1, Dubtrack.views.user_popover.$el.hide(), b("body").unbind("click.userPopover"))
- }), this.timeout && clearTimeout(this.timeout), this.timeout = setTimeout(function() {
- c.userActive = !0
- }, 500)
- },
- renderUser: function(a, b) {
- this.user = b, this.$(".usercontent").html(_.template(Dubtrack.els.templates.profile.popover_user, b.toJSON())), Dubtrack.session && Dubtrack.room && Dubtrack.room.users && this.$(".usercontent .dubs").html(Dubtrack.room.users.getDubs(b.id) + " dubs")
- },
- sendPersonalMessage: function() {
- b("html").addClass("menu-right-in");
- var a = [];
- return a.push(this.user.get("_id")), Dubtrack.layout.menu_right.message_view.createMessageIds(a), Dubtrack.views.user_popover.$el.hide(), !1
- },
- mentionUserInChat: function() {
- var a = Dubtrack.room.chat._messageInputEl.val();
- return a.length > 0 ? Dubtrack.room.chat._messageInputEl.val(Dubtrack.room.chat._messageInputEl.val() + "@" + this.user.get("username") + " ") : Dubtrack.room.chat._messageInputEl.val("@" + this.user.get("username") + " "), Dubtrack.room.chat._messageInputEl.focus(), Dubtrack.views.user_popover.$el.hide(), Dubtrack.room.$el.removeClass("display-users-rooms"), !1
- },
- kickuser: function() {
- return this.userActive = !1, this.$el.hide(), Dubtrack.room.chat.kickUser(this.user.get("username")), !1
- },
- banuser: function(a) {
- if (a && a.target && !b(a.target).is("input")) {
- var c = this.$("a.ban input").val();
- c.length > 0 ? Dubtrack.room.chat.banUser(this.user.get("username"), parseInt(c, 10)) : Dubtrack.room.chat.banUser(this.user.get("username"), 0), Dubtrack.views.user_popover.$el.hide()
- }
- return !1
- },
- banuserKeydown: function(a) {
- if (c = a.which ? a.which : a.keyCode, 13 == c) {
- var b = this.$("a.ban input").val();
- return b.length > 0 ? Dubtrack.room.chat.banUser(this.user.get("username"), parseInt(b, 10)) : Dubtrack.room.chat.banUser(this.user.get("username"), 0), Dubtrack.views.user_popover.$el.hide(), !1
- }
- },
- muteuser: function() {
- return this.userActive = !1, this.$el.hide(), Dubtrack.room.chat.muteUser(this.user.get("username")), !1
- },
- unmuteuser: function() {
- return this.userActive = !1, this.$el.hide(), Dubtrack.room.chat.unmuteUser(this.user.get("username")), !1
- },
- setRole: function(a) {
- if (a && a.target) {
- var c = b(a.target).attr("data-roleref");
- return c && (this.userActive = !1, this.$el.hide(), Dubtrack.room.chat.setRole(this.user.get("username"), c)), !1
- }
- },
- unsetRole: function(a) {
- if (a && a.target) {
- var c = b(a.target).attr("data-roleref");
- return c && (this.userActive = !1, this.$el.hide(), Dubtrack.room.chat.unsetRole(this.user.get("username"), c)), !1
- }
- },
- navigateUser: function() {
- return this.userActive = !1, this.$el.hide(), Dubtrack.app.navigate("/" + this.user.get("username"), {
- trigger: !0
- }), !1
- }
- }), f.playlist.browserDocBind = !1, f.playlist.previewEl = !1, Dubtrack.View.Browser = Backbone.View.extend({
- el: b("#browser"),
- events: {
- "click .close-browser": "hideBrowser",
- "click .sidebar .display-sidebar": "toggleSidebar",
- "click .sidebar .import-playlist": "displayImportView",
- "keydown input#youtube-search": "searchKeyUp",
- "click .music-type-select .music-type-dropdown .youtube-btn": "setYoutube",
- "click .music-type-select .music-type-dropdown .icon-soundcloud": "setSoundcloud",
- "click #searchBtnMain": "search",
- "click a.search-btn": "search",
- "click li.current_queue": "displayQueue",
- "click li.room_history": "displayHistory",
- "click li.current_room_queue": "displayRoomQueue",
- "click li.my_tracks": "displayMyTracks",
- "click .create-playlist .create-playlist-display": "createPlaylistDisplay",
- "click .create-playlist .create-playlist-form span": "createPlaylist",
- "keydown .create-playlist .create-playlist-form input": "createPlaylistInput"
- },
- initialize: function() {
- this.searchCollection = new Dubtrack.Collection.Song, this.searchCollection.parse = function(a, b) {
- return a.data.nextPageToken && (this.nextPageToken = a.data.nextPageToken), a.data.items
- }, this.historyCollection = new Dubtrack.Collection.UserQueue, this.userQueueCollection = new Dubtrack.Collection.UserQueue, this.userPlaylistCollection = new Dubtrack.Collection.UserQueue, this.browser_view_state = null, this.canCloseBrowser = !1, b(window).bind("click.browser", function(a) {
- $parents = b(a.target).parents("#browser"), $parents_preview = b(a.target).parents(".playerPreview"), 0 === $parents.length && 0 === $parents_preview.length && this.canCloseBrowser && this.hideBrowser()
- }.bind(this)), this.render()
- },
- render: function() {
- this.$el.html(Dubtrack.els.templates.layout.browser).show().addClass("animate"), this.importPlaylistView = new Dubtrack.View.ImportPlaylistBrowser({
- el: this.$("#import-playlist-container")
- }), this.importPlaylistView.setBrowser(this), this.playlistListContainer = this.$("ul.playlist-list"), this.loadingEl = this.$("div.loading"), this.playlistContainer = this.$("div#results_video_api"), this.inputSearch = this.$("input#youtube-search"), _.each(this.model.models, function(a) {
- this.appendEl(a)
- }, this), this.model.bind("add", this.appendEl, this), this.setYoutube();
- return f.playlist.browserDocBind || (f.playlist.browserDocBind = !0), b("#browser .content-videos, #playlists-scroll").perfectScrollbar({
- wheelSpeed: 20,
- suppressScrollX: !0,
- wheelPropagation: !1,
- onscrollCallback: function(a, b) {
- 100 > b - a && this.scrollPlaylistItemsActionBottom()
- }.bind(this)
- }), Dubtrack.playerController && Dubtrack.playerController.fetchQueueInfo(), this
- },
- scrollPlaylistItemsActionBottom: function() {},
- displayImportView: function() {
- return this.importPlaylistView.openView(), !1
- },
- toggleSidebar: function() {
- return this.$el.toggleClass("display-browser-sidebar"), !1
- },
- createPlaylistDisplay: function() {
- return this.$el.addClass("display-create-form"), this.$(".create-playlist .create-playlist-form input").focus(), !1
- },
- createPlaylistInput: function(a) {
- c = a.which ? a.which : a.keyCode, 13 === c && this.createPlaylist()
- },
- createPlaylist: function() {
- var a = b.trim(this.$(".create-playlist input").val());
- if ("" !== a && null !== a) {
- var c = new Dubtrack.Model.Playlist({
- name: a
- });
- c.parse = Dubtrack.helpers.parse;
- var d = this;
- c.save({}, {
- success: function() {
- d.model.add(c), Dubtrack.app.navigate("/browser/user/" + c.id, {
- trigger: !0
- })
- }
- }), this.$(".create-playlist input").val("")
- }
- },
- setDubtrack: function() {
- return this.$find(".br-btn").removeClass("active"), this.$("a#dubtrack-btn").addClass("active"), !1
- },
- setYoutube: function() {
- return this.$(".music-type-select .current-music-type-selection i").attr("class", "").addClass("icon-youtube"), this.searchType = "youtube", !1
- },
- setSoundcloud: function() {
- return this.$(".music-type-select .current-music-type-selection i").attr("class", "").addClass("icon-soundcloud"), this.searchType = "soundcloud", !1
- },
- searchKeyUp: function(a) {
- c = a.which ? a.which : a.keyCode, 13 == c && this.search()
- },
- search: function() {
- return Dubtrack.app.navigate("/browser/search", {
- trigger: !1
- }), this.displayDetails("search", this.inputSearch.val()), !1
- },
- displayQueue: function() {
- return Dubtrack.app.navigate("/browser/queue/", {
- trigger: !0
- }), !1
- },
- displayHistory: function() {
- return Dubtrack.app.navigate("/browser/history/", {
- trigger: !0
- }), !1
- },
- displayRoomQueue: function() {
- return Dubtrack.app.navigate("/browser/room-queue/", {
- trigger: !0
- }), !1
- },
- displayMyTracks: function() {
- return dubtrackapp.navigate("/browser/tracks/", {
- trigger: !0
- }), !1
- },
- sortableUpdate: function(a, c) {
- var d = [];
- this.playlistDetailContainer.children("li").each(function(a, c) {
- d.push(b(c).attr("data-id"))
- }), Dubtrack.helpers.sendRequest(this.url_items_order, {
- "order[]": d
- }, "post", function(a) {}.bind(this))
- },
- displayDetails: function(a, c) {
- this.loadingEl.show(), this.canCloseBrowserTimeout = setTimeout(function() {
- this.canCloseBrowser = !0
- }.bind(this), 500), this.browserInfoEl && this.browserInfoEl.close();
- var d = this;
- switch (this.playlistDetailContainer = b("<ul/>", {
- "class": "browserPlaylistItems"
- }), this.scrollPlaylistItemsActionBottom = function() {}, this.moreItemsToLoadTimeout && clearTimeout(this.moreItemsToLoadTimeout), this.browserItemsList && this.browserItemsList.close(), this.playlistContainer.find(".timeago").timeago("dispose"), this.playlistContainer.html(this.playlistDetailContainer), this.$(".content-videos").scrollTop(0), this.$(".content-videos").perfectScrollbar("update"), this.$("#playlists-scroll .selected").removeClass("selected"), this.$el.removeClass("display-create-form"), this.$el.removeClass("display-browser-sidebar"), this.browser_view_state = a, a) {
- case "user":
- $c = this.model.get(c), $c ? this.browserInfoEl = new Dubtrack.View.BrowserPlaylistInfo({
- model: $c
- }).setBrowser(d).render("playlistInfo", this.userPlaylistCollection) : (this.browserInfoEl = (new Dubtrack.View.BrowserPlaylistInfo).setBrowser(d).render("playlistInfo", this.userPlaylistCollection), this.browserInfoEl.setName(dubtrack_lang.global.loading)), this.$("#playlists-scroll .playlist-" + c).addClass("selected");
- var e = Dubtrack.config.apiUrl + Dubtrack.config.urls.playlistSong.replace(":id", c),
- f = Dubtrack.config.apiUrl + Dubtrack.config.urls.playlistOrder.replace(":id", c);
- this.url_items_order = f, this.userPlaylistCollection.reset(), this.userPlaylistCollection.url = e, this.browserInfoEl.$el.prependTo(this.playlistContainer), this.browserItemsList = new Dubtrack.View.BrowserUserPlaylistList({
- model: this.userPlaylistCollection,
- el: this.playlistDetailContainer
- }), this.browserItemsList.setBrowser(this), this.browserItemsList.url_queue_order = f, this.browserItemsList.url_queue_order_data = "data-id", this.browserItemsList.setSortable(), this.browserItemsList.fetchItems(function() {
- this.scrollPlaylistItemsActionBottom = function() {
- this.browserItemsList.fetchItems()
- }.bind(this)
- }.bind(this));
- break;
- case "search":
- "" !== c || null !== c ? (this.browserInfoEl = (new Dubtrack.View.BrowserSearchInfo).render(c), this.browserInfoEl.$el.prependTo(this.playlistContainer), this.currentPage = 1, this.moreItemsToLoad = !1, this.scrollPlaylistItemsActionBottom = function() {
- this.moreItemsToLoad && this.searchCollection.nextPageToken && (this.moreItemsToLoad = !1, this.loadingEl.show(), Dubtrack.helpers.sendRequest(Dubtrack.config.apiUrl + Dubtrack.config.urls.song, {
- name: c,
- type: this.searchType,
- details: 1,
- nextPageToken: this.searchCollection.nextPageToken
- }, "get", function(a, c) {
- this.loadingEl.hide(), c && c.data && c.data.items && c.data.items.length > 1 && c.data.nextPageToken && c.data.nextPageToken != this.searchCollection.nextPageToken && (this.searchCollection.nextPageToken = c.data.nextPageToken, _.each(c.data.items, function(a) {
- var b = new Dubtrack.Model.Song(a),
- c = new Dubtrack.View.BrowserPlaylistItem({
- model: b
- }).render("playlistSearchItem").$el.appendTo(this.playlistDetailContainer);
- b.set({
- browserView: c,
- filterName: b.get("name")
- }), this.searchCollection.add(b)
- }.bind(this)), b("#browser .content-videos").perfectScrollbar("update"), this.moreItemsToLoadTimeout = setTimeout(function() {
- this.moreItemsToLoad = !0
- }.bind(this), 1e3))
- }.bind(this)))
- }.bind(this), this.nextPageToken = null, this.searchCollection.reset(), this.searchCollection.url = Dubtrack.config.apiUrl + Dubtrack.config.urls.song, this.searchCollection.fetch({
- data: {
- name: c,
- type: this.searchType,
- details: 1,
- nextPageToken: ""
- },
- success: function() {
- _.each(d.searchCollection.models, function(a) {
- var b = new Dubtrack.View.BrowserPlaylistItem({
- model: a
- }).render("playlistSearchItem").$el.appendTo(d.playlistDetailContainer);
- a.set({
- browserView: b,
- filterName: a.get("name")
- })
- }), d.searchCollection.models.length >= 15 && (d.moreItemsToLoad = !0), b("#browser .content-videos").perfectScrollbar("update"), d.loadingEl.hide()
- },
- error: function() {
- d.loadingEl.hide()
- }
- })) : this.loadingEl.hide();
- break;
- case "history":
- this.browserInfoEl = (new Dubtrack.View.BrowserHistoryInfo).render(this.historyCollection), this.browserInfoEl.$el.prependTo(this.playlistContainer), this.$("#playlists-scroll .room_history").addClass("selected");
- var g = Dubtrack.config.apiUrl + Dubtrack.config.urls.roomHistory.replace(":id", Dubtrack.room.model.get("_id"));
- this.historyCollection.url = g, this.historyCollection.reset(), this.browserItemsList = new Dubtrack.View.BrowserHistoryPlaylistList({
- model: this.historyCollection,
- el: this.playlistDetailContainer
- }), this.browserItemsList.setBrowser(this), this.browserItemsList.fetchItems(function() {
- this.browserItemsList.prependItems = !0
- }.bind(this));
- break;
- case "queue":
- if (this.browserInfoEl = (new Dubtrack.View.MyQueueInfo).setBrowser(d).render(this.userQueueCollection), this.browserInfoEl.$el.prependTo(this.playlistContainer), this.$("#playlists-scroll .current_queue").addClass("selected"), Dubtrack.room && Dubtrack.room.model.get("lockQueue") && !(Dubtrack.helpers.isDubtrackAdmin(Dubtrack.session.id) || Dubtrack.room.users && Dubtrack.room.users.getIfHasRole(Dubtrack.session.id))) d.loadingEl.hide(), b("<li/>").addClass("queue-locked-info").text("Queue is locked, but you can still enjoy the tunes in this room :]").appendTo(d.playlistDetailContainer);
- else {
- var h = Dubtrack.config.apiUrl + Dubtrack.config.urls.userQueue.replace(":id", Dubtrack.room.model.get("_id")),
- i = Dubtrack.config.apiUrl + Dubtrack.config.urls.userQueueOrder.replace(":id", Dubtrack.room.model.get("_id"));
- this.userQueueCollection.url = h, this.url_items_order = i, this.userQueueCollection.reset(), this.browserItemsList = new Dubtrack.View.BrowserUserQueuePlaylistList({
- model: this.userQueueCollection,
- el: this.playlistDetailContainer
- }), this.browserItemsList.setBrowser(this), this.browserItemsList.url_queue_order = i, this.browserItemsList.url_queue_order_data = "data-id", this.browserItemsList.setSortable(), this.browserItemsList.fetchItems()
- }
- break;
- case "room_queue":
- this.$("#playlists-scroll .current_room_queue").addClass("selected");
- var h = Dubtrack.config.apiUrl + Dubtrack.config.urls.roomQueueDetails.replace(":id", Dubtrack.room.model.get("_id")),
- i = Dubtrack.config.apiUrl + Dubtrack.config.urls.roomUserQueueOrder.replace(":id", Dubtrack.room.model.get("_id"));
- this.url_items_order = i, this.userQueueCollection.url = h, this.userQueueCollection.reset(), this.browserItemsList = new Dubtrack.View.BrowserRoomQueuePlaylistList({
- model: this.userQueueCollection,
- el: this.playlistDetailContainer
- }), this.browserItemsList.setBrowser(this), this.browserItemsList.fetchItems(function() {
- Dubtrack.session && Dubtrack.room && Dubtrack.room.users && (Dubtrack.helpers.isDubtrackAdmin(Dubtrack.session.id) || Dubtrack.room.users.getIfRoleHasPermission(Dubtrack.session.id, "queue-order")) ? (this.browserInfoEl = (new Dubtrack.View.RoomQueueInfo).setBrowser(this).render(this.userQueueCollection),
- this.browserInfoEl.$el.prependTo(this.playlistContainer), this.playlistDetailContainer.addClass("display-mod-controls"), this.browserItemsList.url_queue_order = i, this.browserItemsList.url_queue_order_data = "data-userid", this.browserItemsList.setSortable()) : this.playlistDetailContainer.removeClass("display-mod-controls")
- }.bind(this));
- break;
- default:
- this.loadingEl.hide()
- }
- },
- hideBrowser: function() {
- return this.browser_view_state = null, this.canCloseBrowserTimeout && clearTimeout(this.canCloseBrowserTimeout), this.canCloseBrowser = !1, b(".dubtrack_overlay").hide(), this.$el.show().removeClass("animate"), Dubtrack.room && Dubtrack.room.model ? Dubtrack.app.navigate("/join/" + Dubtrack.room.model.get("roomUrl"), {
- trigger: !0
- }) : Dubtrack.app.navigate("/", {
- trigger: !0
- }), !1
- },
- displayBrowser: function() {
- this.browser_view_state = null, this.$el.addClass("animate"), this.$("#youtube-search").val("").focus(), b(".dubtrack_overlay").show()
- },
- beforeClose: function() {
- this.browserItemsList && this.browserItemsList.close(), this.browser_view_state = null;
- try {
- this.playlistDetailContainer.multisortable("destroy")
- } catch (a) {}
- Dubtrack.app.navigate("/", {
- trigger: !0
- })
- },
- appendEl: function(a) {
- new Dubtrack.View.playlistItem({
- model: a
- }).render().$el.prependTo(this.playlistListContainer)
- }
- }), Dubtrack.View.BrowserInfo = Backbone.View.extend({
- tagName: "div",
- events: {
- "keyup input.editplaylist_name": "updatePlaylistNameKeyup",
- "keyup input.playlist_filter": "filterPlaylist",
- "click .save-playlistname": "updatePlaylistName",
- "click a.shuffle-playlist": "shufflePlaylist",
- "click a.delete-playlist": "removePlaylist",
- "click a.queue-playlist": "queuePlaylist",
- "click .edit-playlist-name": "togglePlaylistEdit",
- "click a.navigate": "navigate"
- },
- initialize: function() {
- this.$el.addClass("playlist_info")
- },
- render: function(a, c) {
- return this.model && this.$el.html(_.template(Dubtrack.els.templates.playlist[a], this.model.toJSON())), this.collection = c, this.aplaylist_typeEl = b(this.el).find("a.playlist_type"), this.model && this.renderPlaylistType(this.model.get("playlist_type")), this
- },
- navigate: function(a) {
- var c = b(a.target);
- return $href = c.attr("href"), $href && g.app.navigate($href, {
- trigger: !0
- }), !1
- },
- queuePlaylist: function() {
- this.$("a.queue-playlist").text("loading....");
- var a = Dubtrack.config.apiUrl + Dubtrack.config.urls.roomQueuePlaylist.replace(":playlistid", this.model.get("_id")).replace(":id", Dubtrack.room.model.get("_id"));
- return Dubtrack.helpers.sendRequest(a, {}, "post", function(a) {
- this.$("a.queue-playlist").text("Queue all")
- }.bind(this)), !1
- },
- renderPlaylistType: function(a) {
- "public" == a ? (this.aplaylist_typeEl.removeClass("playlist_type_private").html(dubtrack_lang.global.publicStr), this.aplaylist_typeEl.append("<span>your playlist is viewable by everyone</span>")) : (this.aplaylist_typeEl.addClass("playlist_type_private").html(dubtrack_lang.global.privateStr), this.aplaylist_typeEl.append("<span>your playlist is only viewable by you</span>"))
- },
- filterPlaylist: function(a) {
- var b = a.target.value;
- "" === b || " " === b ? _.each(this.collection.models, function(a) {
- var b = a.get("browserView");
- b.show()
- }, this) : (b = b.toLowerCase(), _.each(this.collection.models, function(a) {
- var c = a.get("browserView");
- $name = a.get("filterName").toLowerCase(), -1 === $name.indexOf(b) ? c.hide() : c.show()
- }, this))
- },
- togglePlaylistEdit: function() {
- return this.$el.toggleClass("displayEdit"), this.$el.hasClass("displayEdit") && this.$("input.editplaylist_name").focus(), !1
- },
- updatePlaylistNameKeyup: function(a) {
- c = a.which ? a.which : a.keyCode, 13 == c && this.updatePlaylistName()
- },
- updatePlaylistName: function() {
- var a = this.$("input.editplaylist_name").val();
- if (a && a.length > 0) {
- this.$el.removeClass("displayEdit");
- var b = Dubtrack.config.apiUrl + Dubtrack.config.urls.playlistUpdate.replace(":id", this.model.get("_id"));
- Dubtrack.helpers.sendRequest(b, {
- name: a
- }, "put", function(a) {}.bind(this));
- var c = Dubtrack.app.browserView.model.findWhere({
- _id: this.model.get("_id")
- });
- c && c.set({
- name: a
- })
- }
- },
- setBrowser: function(a) {
- return this.parent_browser = a, this
- },
- shufflePlaylist: function(a) {
- a && a.preventDefault(), this.parent_browser && (this.parent_browser.playlistDetailContainer.randomize("li.playlist-item"), this.parent_browser.sortableUpdate())
- },
- removePlaylist: function() {
- var a = confirm(dubtrack_lang.playlist.removePlaylistConfirm);
- return a && (this.model.destroy(), this.close()), this.parent_browser.playlistContainer.empty(), Dubtrack.app.navigate("/browser/queue/", {
- trigger: !1
- }), !1
- },
- setName: function(a) {
- this.aplaylist_typeEl.html(a)
- },
- changePlaylistType: function() {
- if (this.model) {
- var a = this;
- $type = this.model.get("type"), this.aplaylist_typeEl.html(dubtrack_lang.global.loading), b.ajax({
- url: g.config.changePlaylistType,
- data: {
- idplaylist: this.model.get("id"),
- type: $type
- },
- type: "POST",
- success: function(b) {
- "public" == $type ? (a.model.set({
- type: "private"
- }), a.renderPlaylistType("private")) : (a.model.set({
- type: "public"
- }), a.renderPlaylistType("public"))
- },
- error: function() {}
- }, "json")
- }
- return !1
- }
- }), Dubtrack.View.BrowserPlaylistInfo = Dubtrack.View.BrowserInfo.extend({
- filterPlaylist: function(a) {
- if (this.parent_browser) {
- var b = a.target.value;
- this.parent_browser.browserItemsList.currentPage = 1, this.parent_browser.browserItemsList.moreItemsToLoad = !0, this.parent_browser.browserItemsList.model.reset(), "" != b || b.length > 0 ? (this.parent_browser.browserItemsList.searchString = b, this.parent_browser.browserItemsList.removeOnFetch = !0) : (this.parent_browser.browserItemsList.searchString = "", this.parent_browser.browserItemsList.removeOnFetch = !1), this.parent_browser.browserItemsList.fetchItemsTimeout()
- }
- }
- }), Dubtrack.View.RoomQueueInfo = Backbone.View.extend({
- tagName: "div",
- events: {
- "click .room-queue-lock": "lockRoom",
- "click .room-queue-unlock": "lockRoom",
- "keyup input.playlist_filter": "filterPlaylist"
- },
- initialize: function() {
- this.$el.addClass("queue_info"), Dubtrack.Events.bind("realtime:room-lock-queue", this.lockRoomRT, this)
- },
- setBrowser: function(a) {
- return this.parent_browser = a, this
- },
- filterPlaylist: function(a) {
- var b = a.target.value;
- "" === b || " " === b ? _.each(this.collection.models, function(a) {
- var b = a.get("browserView");
- b.show()
- }, this) : (b = b.toLowerCase(), _.each(this.collection.models, function(a) {
- var c = a.get("browserView");
- $name = a.get("filterName").toLowerCase(), -1 === $name.indexOf(b) ? c.hide() : c.show()
- }, this))
- },
- render: function(a) {
- this.$el.html(_.template(Dubtrack.els.templates.playlist.roomQueueInfo));
- var b = Dubtrack.room && Dubtrack.room.model.get("lockQueue") ? !0 : !1;
- return b ? (this.$(".room-queue-lock").show(), this.$(".room-queue-unlock").hide()) : (this.$(".room-queue-lock").hide(), this.$(".room-queue-unlock").show()), this.collection = a, this
- },
- lockRoomRT: function(a) {
- a && a.room && (a.room.lockQueue ? (this.$(".room-queue-lock").show(), this.$(".room-queue-unlock").hide()) : (this.$(".room-queue-lock").hide(), this.$(".room-queue-unlock").show()))
- },
- lockRoom: function() {
- if (Dubtrack.helpers.isDubtrackAdmin(Dubtrack.session.id) || Dubtrack.room.users && Dubtrack.room.users.getIfHasRole(Dubtrack.session.id)) {
- if (this.loading_lock_queue) return !1;
- var a = Dubtrack.config.apiUrl + Dubtrack.config.urls.roomLockQueue.replace(":id", Dubtrack.room.model.get("_id")),
- b = Dubtrack.room && Dubtrack.room.model.get("lockQueue") ? 0 : 1;
- return this.loading_lock_queue = !0, Dubtrack.helpers.sendRequest(a, {
- lockQueue: b
- }, "put", function(a) {
- this.loading_lock_queue = !1
- }.bind(this)), !1
- }
- }
- }), Dubtrack.View.MyQueueInfo = Backbone.View.extend({
- tagName: "div",
- events: {
- "click .clear-queue": "clearMyQueue",
- "click .pause-queue": "pauseMyQueue",
- "click a.shuffle-playlist": "shufflePlaylist",
- "keyup input.playlist_filter": "filterPlaylist"
- },
- filterPlaylist: function(a) {
- var b = a.target.value;
- "" === b || " " === b ? _.each(this.collection.models, function(a) {
- var b = a.get("browserView");
- b.show()
- }, this) : (b = b.toLowerCase(), _.each(this.collection.models, function(a) {
- var c = a.get("browserView");
- $name = a.get("filterName").toLowerCase(), -1 === $name.indexOf(b) ? c.hide() : c.show()
- }, this))
- },
- initialize: function() {
- this.$el.addClass("queue_info"), Dubtrack.Events.bind("realtime:user-pause-queue", this.pauseMyQueueRT, this)
- },
- setBrowser: function(a) {
- return this.parent_browser = a, this
- },
- shufflePlaylist: function() {
- return this.parent_browser && (this.parent_browser.playlistDetailContainer.randomize("li.queue-item"), this.parent_browser.sortableUpdate()), !1
- },
- render: function(a) {
- return this.$el.html(_.template(Dubtrack.els.templates.playlist.myQueueInfo)), Dubtrack.session && Dubtrack.room && Dubtrack.room.users && this.pauseMyQueueRT({
- user_queue: {
- queuePaused: Dubtrack.room.users.getIfQueueIsActive(Dubtrack.session.id)
- }
- }), this.collection = a, this
- },
- pauseMyQueueRT: function(a) {
- a && a.user_queue && (a.user_queue.queuePaused ? this.$(".pause-queue").text("Resume") : this.$(".pause-queue").text("Pause"))
- },
- clearMyQueue: function(a) {
- return a && a.preventDefault(), confirm("Are you sure you want to clear your queue?") && Dubtrack.room && Dubtrack.room.model && (this.$(".clear-queue").text("loading...."), b.ajax({
- url: Dubtrack.config.apiUrl + "/room/" + Dubtrack.room.model.get("_id") + "/playlist",
- type: "delete"
- }).always(function() {
- this.$(".clear-queue").text("clear"), this.$(".clear-queue-browser-bth").text("Clear"), this.parent_browser.displayDetails("queue")
- }.bind(this))), !1
- },
- pauseMyQueue: function(a) {
- if (this.loading_pause_queue) return !1;
- this.$(".pause-queue").text("loading...."), this.loading_pause_queue = !0;
- var b = Dubtrack.config.apiUrl + Dubtrack.config.urls.userQueuePause.replace(":id", Dubtrack.room.model.get("_id")),
- c = Dubtrack.session && Dubtrack.room && Dubtrack.room.users && Dubtrack.room.users.getIfQueueIsActive(Dubtrack.session.id) ? 0 : 1;
- return Dubtrack.helpers.sendRequest(b, {
- queuePaused: c
- }, "put", function(a) {
- a && this.$(".pause-queue").text("Coundn't update your queue settings"), this.loading_pause_queue = !1
- }.bind(this)), !1
- }
- }), Dubtrack.View.BrowserSearchInfo = Backbone.View.extend({
- tagName: "div",
- events: {},
- initialize: function() {
- this.$el.addClass("queue_info")
- },
- setBrowser: function(a) {
- return this.parent_browser = a, this
- },
- render: function(a) {
- return this.$el.html(_.template(Dubtrack.els.templates.playlist.playlistSearchBrowser, {
- name: a
- })), this
- }
- }), Dubtrack.View.BrowserHistoryInfo = Dubtrack.View.BrowserInfo.extend({
- tagName: "div",
- initialize: function() {
- this.$el.addClass("queue_info")
- },
- setBrowser: function(a) {
- return this.parent_browser = a, this
- },
- render: function(a) {
- return this.$el.html(_.template(Dubtrack.els.templates.playlist.playlistHistoryBrowser)), this.collection = a, this
- }
- }), Dubtrack.View.playlistItem = Backbone.View.extend({
- tagName: "li",
- attributes: {
- "class": "playlist_icon"
- },
- events: {
- click: "viewDetails",
- "click .add_to_queue": "queuePlaylist",
- "click .delete": "removePlaylist"
- },
- initialize: function() {
- this.model.bind("change", this.render, this), this.model.bind("destroy", this.close, this)
- },
- queuePlaylist: function() {
- return Dubtrack.app.navigate("/browser/user/" + this.model.get("_id"), {
- trigger: !1
- }), Dubtrack.app.browserView.displayDetails("queueSong", this.model.get("_id")), !1
- },
- setBrowser: function() {
- return this
- },
- removePlaylist: function() {
- var a = confirm(dubtrack_lang.playlist.removePlaylistConfirm);
- return a && (this.model.destroy(), this.close()), !1
- },
- render: function() {
- return this.$el.html(_.template(Dubtrack.els.templates.playlist.playlistBrowser, this.model.toJSON())), this.$el.addClass("playlist-" + this.model.id), this
- },
- viewDetails: function(a) {
- return Dubtrack.app.navigate("/browser/user/" + this.model.get("_id"), {
- trigger: !0
- }), !1
- }
- }), Dubtrack.View.BrowserPlaylistItem = Backbone.View.extend({
- tagName: "li",
- attributes: {
- "class": "search-item"
- },
- events: {
- click: "closePlaylistCont",
- "click .add_to_queue": "addToQueue",
- "click .remove_icon": "removePlaylist",
- "click .add_to_playlist": "addPlaylistContainer",
- "click .add_to_playlistQueue": "addPlaylistQueueContainer",
- "click .remove_queue": "removeFromQueue",
- "click .remove_track": "removeTrack",
- "click .remove_dj": "removeDJFromQueue",
- "click .remove_dj_all": "removeDJAllFromQueue",
- "click .preview": "preview",
- "click a.editBtn": "focusInput",
- "blur input.track_name_input": "updateTrackName",
- "click .set_song_to_top_queue": "moveToTop"
- },
- initialize: function() {},
- moveToTop: function(a) {
- a && a.preventDefault(), this.parent_browser && (this.$el.prependTo(this.$el.parents(".browserPlaylistItems")), this.parent_browser.sortableUpdate())
- },
- setBrowser: function(a) {
- return this.parent_browser = a, this
- },
- closePlaylistCont: function(a) {
- $parents = b(a.target).parents(".playlist-options"), 0 === $parents.length && f.playlist.containerElCreateApp && f.playlist.containerElCreateApp.close()
- },
- setTime: function() {
- var a = Math.floor(parseFloat(this.model.get("songLength")) / 6e4),
- b = Math.floor(parseFloat(this.model.get("songLength")) / 1e3 - 60 * a);
- b.length < 2 && (b = "0" + b), a = "0".substring(a >= 10) + a, b = "0".substring(b >= 10) + b, this.model.set({
- minute: a,
- second: b
- })
- },
- render: function(a) {
- return this.setTime(), this.$el.html(_.template(Dubtrack.els.templates.playlist[a], this.model.toJSON())), this
- },
- focusInput: function() {
- return b(this.el).find("input.track_name_input").focus(), !1
- },
- updateTrackName: function(a) {
- $songName = b(a.target).val(), $songName && " " !== $songName && 0 !== $songName && b.ajax({
- url: g.config.updateMytracksUrl,
- data: {
- id: this.model.get("id"),
- title: $songName
- },
- type: "POST",
- success: function(a) {},
- error: function() {}
- }, "json")
- },
- removePlaylist: function() {
- return !1
- },
- preview: function() {
- return f.playlist.previewEl && f.playlist.previewEl.close(), f.playlist.previewEl = new Dubtrack.View.PreivewEl({
- model: this.model
- }), f.playlist.previewEl.$el.appendTo(b("body")), f.playlist.previewEl.render(), b("html,body").stop(!0).animate({
- scrollTop: 0
- }), !1
- },
- removeFromQueue: function() {
- return b.ajax({
- url: g.config.removeFromQueue,
- data: {
- id: this.model.get("id")
- },
- type: "POST",
- success: function(a) {},
- error: function() {}
- }, "json"), this.close(), !1
- },
- removeDJFromQueue: function() {
- return !1
- },
- removeDJAllFromQueue: function() {
- return !1
- },
- removeTrack: function() {
- var a = confirm(dubtrack_lang.playlist.confirmRemoveTrack);
- return a && (b.ajax({
- url: g.config.deleteMytracksUrl,
- data: {
- id: this.model.get("id")
- },
- type: "POST",
- success: function(a) {},
- error: function() {}
- }, "json"), this.close()), !1
- },
- addPlaylistContainer: function(a) {
- var b = {
- right: 0,
- top: 10
- };
- return Dubtrack.helpers.genPlaylistContainer(this.$el, b, this.model.get("fkid"), this.model.get("type")), !1
- },
- addToQueue: function() {
- var a = this.model.get("type"),
- b = this.model.get("fkid"),
- c = this;
- return this.$(".add_to_queue").addClass("loading-action"), Dubtrack.helpers.playlist.addQueue(b, a, function(a, b) {
- if (a) try {
- a && a.data && a.data.err && a.data.err.details && a.data.err.details && a.data.err.details.message ? c.$(".display-error").show().html(a.data.err.details.message) : c.$(".display-error").show().html("Song already in queue or played in the last hour")
- } catch (d) {
- c.$(".display-error").show().html("Song already in queue or played in the last hour")
- } else c.$(".display-success").show().html("Song added to queue");
- c.$(".add_to_queue").hide()
- }), !1
- }
- }), Dubtrack.View.BrowserPlaylisHistorytItem = Dubtrack.View.BrowserPlaylistItem.extend({
- attributes: {
- "class": "history-item"
- },
- fetchSong: function(a) {
- this.queue = a;
- var b = this.queue.get("_song");
- return b && "object" == typeof b ? (b = Dubtrack.cache.songs.add(b), this.render(null, b)) : Dubtrack.cache.songs.get(this.queue.get("songid"), this.render, this), this
- },
- render: function(a, c) {
- return this.model = c, this.queue.set("song", c.toJSON()), this.queue.set({
- filterName: c.get("name")
- }), this.setTime(), this.$el.html(_.template(Dubtrack.els.templates.playlist.playlistSearchItem, this.model.toJSON())).show(), b("#browser .content-videos").perfectScrollbar("update"), this
- }
- }), Dubtrack.View.BrowserPlaylisHistorytItemWithDescription = Dubtrack.View.BrowserPlaylistItem.extend({
- attributes: {
- "class": "history-item"
- },
- fetchSong: function(a) {
- this.queue = a;
- var b = this.queue.get("_song");
- return b && "object" == typeof b ? (b = Dubtrack.cache.songs.add(b), this.render(null, b)) : Dubtrack.cache.songs.get(this.queue.get("songid"), this.render, this), this
- },
- render: function(a, c) {
- this.model = c, this.queue.set("song", c.toJSON()), this.queue.set({
- filterName: c.get("name")
- }), this.setTime();
- var d = this.model.toJSON();
- d._user = this.queue.get("_user"), d.updubs = this.queue.get("updubs"), d.downdubs = this.queue.get("downdubs"), d.grabs = this.queue.get("grabs"), d.skipped = this.queue.get("skipped"), this.$el.html(_.template(Dubtrack.els.templates.playlist.playlistHistoryItem, d)).show();
- var e = new Date(this.queue.get("played") + this.queue.get("songLength"));
- return this.$(".timeinfo").html('<time class="timeago" datetime="' + e.toISOString() + '">' + e.toLocaleString() + "</time>"), this.$(".timeago").timeago(), b("#browser .content-videos").perfectScrollbar("update"), this
- }
- }), Dubtrack.View.BrowserPlaylisUserPlaylisttItem = Dubtrack.View.BrowserPlaylisHistorytItem.extend({
- attributes: {
- "class": "playlist-item"
- },
- render: function(a, b) {
- return Dubtrack.View.BrowserPlaylisHistorytItem.prototype.render.call(this, a, b), this.$el.attr("data-id", this.queue.get("_id")), this
- },
- removePlaylist: function() {
- var a = Dubtrack.config.apiUrl + Dubtrack.config.urls.playlistSong.replace(":id", this.model.get("playlistid"));
- return this.queue.baseUrl = a, this.queue.destroy({
- success: function(a, b) {
- if (b && b.data) {
- var c = Dubtrack.app.browserView.model.findWhere({
- _id: b.data._id
- });
- c && c.set(b.data)
- }
- }
- }), this.close(), !1
- }
- }), Dubtrack.View.BrowserQueuePlaylisttItem = Dubtrack.View.BrowserPlaylisHistorytItem.extend({
- attributes: {
- "class": "queue-item"
- },
- render: function(a, b) {
- return Dubtrack.View.BrowserPlaylisHistorytItem.prototype.render.call(this, a, b), this.$el.attr("data-id", this.queue.get("_id")), this
- },
- removePlaylist: function() {
- return Dubtrack.helpers.playlist.removeQueue(this.queue.get("_id")), this.close(), !1
- }
- }), Dubtrack.View.BrowserRoomQueuePlaylisttItem = Dubtrack.View.BrowserPlaylisHistorytItem.extend({
- attributes: {
- "class": "queue-item room-queue-item"
- },
- removeDJFromQueue: function() {
- return this.$(".remove_dj").addClass("loading-action"), b.ajax({
- url: Dubtrack.config.apiUrl + "/room/" + Dubtrack.room.model.get("_id") + "/queue/user/" + this.queue.get("userid"),
- type: "delete"
- }).success(function(a) {
- try {
- a && a.data && a.data.userNextSong && a.data.userNextSong._song ? this.render(null, new Dubtrack.Model.Song(a.data.userNextSong._song)) : this.$el.remove()
- } catch (b) {
- this.$el.remove()
- }
- }.bind(this)).error(function() {
- this.$(".display-error").show().html("You don't have permissions to do this")
- }.bind(this)).always(function() {
- this.$(".remove_dj").removeClass("loading-action")
- }.bind(this)), !1
- },
- removeDJAllFromQueue: function() {
- return this.$(".remove_dj_all").addClass("loading-action"), b.ajax({
- url: Dubtrack.config.apiUrl + "/room/" + Dubtrack.room.model.get("_id") + "/queue/user/" + this.queue.get("userid") + "/all",
- type: "delete"
- }).success(function(a) {
- this.$el.remove()
- }.bind(this)).error(function() {
- this.$(".display-error").show().html("You don't have permissions to do this")
- }.bind(this)).always(function() {
- this.$(".remove_dj_all").removeClass("loading-action")
- }.bind(this)), !1
- },
- render: function(a, c) {
- this.model = c, this.queue.set("song", c.toJSON()), this.$el.attr("data-userid", this.queue.get("userid")), this.$el.attr("data-id", this.queue.get("userid")), this.queue.set({
- filterName: c.get("name")
- }), this.setTime();
- var d = this.model.toJSON();
- return d._user = this.queue.get("_user"), this.$el.html(_.template(Dubtrack.els.templates.playlist.playlistRoomQueueItem, d)).show(), b("#browser .content-videos").perfectScrollbar("update"), this
- }
- }), Dubtrack.View.containerElCreate = Backbone.View.extend({
- tagName: "div",
- events: {
- "click .create-playlist-header .icon-close": "closeWindow",
- "click a": "addPLaylist",
- "click .create-playlist-input span": "createPlaylist",
- "keydown .create-playlist-input input": "createPlaylistInput"
- },
- attributes: {
- id: "addToPlaylistFloatContainer"
- },
- initialize: function() {
- b(this.el).attr("class", "playlist-options")
- },
- render: function(a, c, d, e) {
- return this.$el.html(_.template(Dubtrack.els.templates.playlist.playlistContainer, {})).appendTo("body"), this.songid = d, this.type = e, _.each(this.model.models, function(a) {
- this.appendEl(a)
- }, this), b("#addToPlaylistFloatContainer .playlist-list-action").perfectScrollbar({
- wheelSpeed: 20,
- suppressScrollX: !0,
- wheelPropagation: !1
- }), this.model.bind("add", this.appendEl, this), this
- },
- appendEl: function(a) {
- new Dubtrack.View.containerElCreateItem({
- model: a
- }).render(this).$el.prependTo(this.$("ul.playlist-list-action"))
- },
- createPlaylistInput: function(a) {
- c = a.which ? a.which : a.keyCode, 13 === c && this.createPlaylist()
- },
- createPlaylist: function() {
- var a = b.trim(this.$(".create-playlist-input input").val());
- if ("" !== a && null !== a) {
- var c = new Dubtrack.Model.Playlist({
- name: a
- });
- c.parse = Dubtrack.helpers.parse;
- c.save({}, {
- success: function() {
- Dubtrack.user.playlist.add(c), Dubtrack.app.browserView.appendEl(c)
- }
- }), this.$(".create-playlist-input input").val("")
- }
- },
- closeWindow: function() {
- return this.close(), !1
- }
- }), Dubtrack.View.containerElCreateItem = Backbone.View.extend({
- tagName: "li",
- events: {
- click: "addToPlaylist"
- },
- initialize: function() {},
- render: function(a) {
- return this.$el.html(this.model.get("name")), this.parentView = a, this
- },
- addToPlaylist: function() {
- this.$el.parents("li").find("a.add_to_playlist").addClass("active");
- var a = Dubtrack.config.apiUrl + Dubtrack.config.urls.playlistSong.replace(":id", this.model.get("_id"));
- return this.parentView.type ? Dubtrack.helpers.sendRequest(a, {
- fkid: this.parentView.songid,
- type: this.parentView.type
- }, "post", function(a, b) {
- if (!a && b && b.data) {
- var c = Dubtrack.app.browserView.model.findWhere({
- _id: this.model.get("_id")
- });
- c && (c.set(b.data), this.model.set(b.data))
- }
- }.bind(this)) : Dubtrack.helpers.sendRequest(a, {
- songid: this.parentView.songid
- }, "post", function(a, b) {
- if (!a && b && b.data) {
- var c = Dubtrack.app.browserView.model.findWhere({
- _id: this.model.get("_id")
- });
- c && (c.set(b.data), this.model.set(b.data))
- }
- }.bind(this)), this.parentView.close(), !1
- }
- }), Dubtrack.View.PreivewEl = Backbone.View.extend({
- tagName: "div",
- className: "playerPreview",
- events: {
- "click .close": "closeAction"
- },
- initialize: function() {
- this.$el.html(Dubtrack.els.templates.playlist.previewContainer)
- },
- render: function() {
- return this.player_container = this.$(".playerDubContainer"), b(document).on("click", function(a) {
- f.playlist.previewEl && ($parents = b(a.target).parents(".playerPreview"), 0 === $parents.length && f.playlist.previewEl.close())
- }), this.buildPlayer(), this.loadComments(), this
- },
- buildPlayer: function() {
- switch (this.id = this.model.get("fkid"), this.model.get("type")) {
- case "youtube":
- this.buildYT();
- break;
- case "soundcloud":
- case "dubtrack":
- this.buildSoundCloud()
- }
- },
- closeAction: function() {
- this.close()
- },
- buildYT: function() {
- this.player = new i, this.player_container.append(this.player.render(this.id, this.id + "_video").$el), this.player.buildPlayer(!0)
- },
- buildSoundCloud: function() {
- this.player = new scDubsPlayerView, this.player_container.append(this.player.render(this.model.get("streamUrl"), this.id + "_audio", this.model.get("type"), !0).$el)
- },
- loadComments: function() {},
- beforeClose: function() {
- this.player && this.player.close()
- }
- }), Dubtrack.View.BrowserPlaylistList = Backbone.View.extend({
- initialize: function() {
- this.prependItems = !1, this.moreItemsToLoad = !0, this.checkItemsOrder = !0, this.removeOnFetch = !0, this.currentPage = 1, this.loadingMoreItems = !1, this.paginationDisabled = !0, this.model.bind("add", this.addItem, this), this.model.bind("remove", this.removeItem, this), this.model.bind("change", this.updateItem, this), this.model.bind("reset", this.resetItems, this), this.setSortable()
- },
- setSortable: function() {
- this.url_queue_order && this.url_queue_order_data && this.$el.multisortable({
- axis: "y",
- cursor: "move",
- placeholder: "ui-state-highlight",
- update: function(a, c) {
- order = [], this.$("li").each(function(a, c) {
- order.push(b(c).attr(this.url_queue_order_data))
- }.bind(this)), Dubtrack.helpers.sendRequest(this.url_queue_order, {
- "order[]": order
- }, "post")
- }.bind(this)
- })
- },
- setBrowser: function(a) {
- return this.browser = a, this
- },
- resetItems: function(a) {
- this.$("li").remove()
- },
- addItem: function(a) {},
- updateItem: function(a) {},
- removeItem: function(a) {
- var b = a.get("browserView");
- b && b.remove()
- },
- fetchItemsTimeout: function(a) {
- this.fetchItemsTimeoutID && clearTimeout(this.fetchItemsTimeoutID), this.fetchItemsTimeoutID = setTimeout(function() {
- this.fetchItems()
- }.bind(this), 500)
- },
- getFetchData: function() {
- return {}
- },
- fetchItems: function(a) {
- !this.moreItemsToLoad && !this.paginationDisabled || this.loadingMoreItems || (this.moreItemsToLoad = !1, this.loadingMoreItems = !0, this.browser.loadingEl.show(), this.model.fetch({
- data: this.getFetchData(),
- remove: this.removeOnFetch,
- success: function(b, c) {
- if (this.loadingMoreItems = !1, this.moreItemsToLoadTimeout = setTimeout(function() {
- c && c.data && c.data.length >= 20 && (this.moreItemsToLoad = !0, this.currentPage++)
- }.bind(this), 500), this.browser.loadingEl.hide(), c && c.data && this.checkItemsOrder && _.each(c.data, function(a, b) {
- var c = this.model.findWhere({
- _id: a._id
- });
- if (c) {
- var d = c.get("browserView");
- c.get("_id");
- d && b != d.index() && d.insertBefore(this.$("li:eq(" + b + ")"))
- }
- }.bind(this)), a) try {
- a.call()
- } catch (d) {}
- }.bind(this),
- error: function() {
- this.browser.loadingEl.hide(), this.loadingMoreItems = !1
- }.bind(this)
- }))
- },
- beforeClose: function() {
- try {
- Dubtrack.Events.unbind(null, null, this), this.url_queue_order && this.$el.multisortable("destroy")
- } catch (a) {}
- }
- }), Dubtrack.View.BrowserRoomQueuePlaylistList = Dubtrack.View.BrowserPlaylistList.extend({
- initialize: function() {
- Dubtrack.View.BrowserPlaylistList.prototype.initialize.call(this), Dubtrack.Events.bind("realtime:room_playlist-update", this.fetchItemsTimeout, this), Dubtrack.Events.bind("realtime:room_playlist-queue-update", this.fetchItemsTimeout, this), Dubtrack.Events.bind("realtime:room_playlist-queue-reorder", this.fetchItemsTimeout, this)
- },
- addItem: function(a) {
- var b = (new Dubtrack.View.BrowserRoomQueuePlaylisttItem).fetchSong(a).setBrowser(this.browser).$el.appendTo(this.$el);
- a.set({
- browserView: b
- })
- }
- }), Dubtrack.View.BrowserHistoryPlaylistList = Dubtrack.View.BrowserPlaylistList.extend({
- initialize: function() {
- Dubtrack.View.BrowserPlaylistList.prototype.initialize.call(this), Dubtrack.Events.bind("realtime:room_playlist-update", this.fetchItemsTimeout, this)
- },
- addItem: function(a) {
- var b = "appendTo";
- this.prependItems && (b = "prependTo");
- var c = (new Dubtrack.View.BrowserPlaylisHistorytItemWithDescription).fetchSong(a).setBrowser(this.browser).$el[b](this.$el);
- a.set({
- browserView: c
- })
- }
- }), Dubtrack.View.BrowserUserQueuePlaylistList = Dubtrack.View.BrowserPlaylistList.extend({
- initialize: function() {
- Dubtrack.View.BrowserPlaylistList.prototype.initialize.call(this), Dubtrack.Events.bind("realtime:room_playlist-update", this.fetchItemsTimeout, this), Dubtrack.Events.bind("realtime:room_playlist-queue-update", this.fetchItemsTimeout, this)
- },
- addItem: function(a) {
- var b = (new Dubtrack.View.BrowserQueuePlaylisttItem).fetchSong(a).setBrowser(this.browser).$el.appendTo(this.$el);
- a.set({
- browserView: b
- })
- }
- }), Dubtrack.View.BrowserUserPlaylistList = Dubtrack.View.BrowserPlaylistList.extend({
- initialize: function() {
- Dubtrack.View.BrowserPlaylistList.prototype.initialize.call(this), this.checkItemsOrder = !1, this.removeOnFetch = !1, this.paginationDisabled = !1, this.searchString = ""
- },
- addItem: function(a) {
- var b = (new Dubtrack.View.BrowserPlaylisUserPlaylisttItem).fetchSong(a).setBrowser(this.browser).$el.appendTo(this.$el);
- a.set({
- browserView: b
- })
- },
- getFetchData: function() {
- return {
- name: this.searchString,
- page: this.currentPage
- }
- }
- }), Dubtrack.View.ImportPlaylistBrowser = Backbone.View.extend({
- events: {
- "click .playlist-type-select .import-youtube": "displayYoutubeImport",
- "click .import-playlist-youtube .import-playlist": "importYoutubePlaylist",
- "keyup .import-playlist-youtube input": "importYoutubePlaylistKeyUp",
- "click .playlist-type-select .import-soundcloud": "displaySoundCloudImport",
- "click .import-playlist-soundcloud .import-playlist": "importSoundcloudUserPlaylist",
- "keyup .import-playlist-soundcloud input": "importSoundcloudUserPlaylistKeyUp",
- "click .close-import-playlist": "closeView"
- },
- initialize: function() {
- return this.soundCloudPlaylistList = this.$(".import-playlist-soundcloud ul"), this.$(".playlist-container").perfectScrollbar({
- wheelSpeed: 20,
- suppressScrollX: !0,
- wheelPropagation: !1
- }), this
- },
- setBrowser: function(a) {
- this.browser = a
- },
- displayYoutubeImport: function() {
- return this.$(".playlist-tab-import-active").removeClass("playlist-tab-import-active"), this.$(".import-playlist-youtube").addClass("playlist-tab-import-active"), this.$(".import-playlist-youtube input").focus(), this.$(".err-message").hide(), !1
- },
- displaySoundCloudImport: function() {
- return this.$(".playlist-tab-import-active").removeClass("playlist-tab-import-active"), this.$(".import-playlist-soundcloud").addClass("playlist-tab-import-active"), this.$(".import-playlist-soundcloud input").focus(), this.$(".err-message").hide(), this.soundCloudPlaylistList.empty(), !1
- },
- importSoundcloudUserPlaylistKeyUp: function(a) {
- c = a.which ? a.which : a.keyCode, this.soundCloudPlaylistSelect = null, 13 == c && this.importSoundcloudUserPlaylist()
- },
- importSoundcloudUserPlaylist: function() {
- if (this.$(".import-playlist-soundcloud").addClass("importing"), this.soundCloudPlaylistSelect) {
- var a = Dubtrack.config.apiUrl + Dubtrack.config.urls.importSoundcloudPlaylist;
- Dubtrack.helpers.sendRequest(a, {
- id: this.$(".import-playlist-soundcloud select").val(),
- playlistid: this.soundCloudPlaylistSelect.get("id")
- }, "post", function(a, b) {
- a || b.data && b.data && b.data._id && (this.browser.model.add(b.data), Dubtrack.app.navigate("/browser/user/" + b.data._id, {
- trigger: !0
- })), this.setSelect(), this.soundCloudPlaylistList.find("li.selected").removeClass("selected"), this.soundCloudPlaylistSelect = null, this.$(".import-playlist-soundcloud").removeClass("importing")
- }.bind(this))
- } else {
- var b = this.$(".import-playlist-soundcloud input").val();
- if (this.$(".err-message").hide(), this.soundCloudPlaylistList.empty(), this.$(".playlist-container").perfectScrollbar("update"), this.soundCloudPlaylistSelect = null, b && b.length > 0) {
- var a = Dubtrack.config.apiUrl + Dubtrack.config.urls.getSoundCloudPlaylists;
- Dubtrack.helpers.sendRequest(a, {
- username: b
- }, "get", function(a, b) {
- a || b.data && _.each(b.data, function(a) {
- new Dubtrack.View.ImportPlaylistBrowserSoundCloudItem({
- model: new Dubtrack.Model.SoundCloudPlaylist(a)
- }).setParent(this).$el.appendTo(this.soundCloudPlaylistList)
- }.bind(this)), this.$(".import-playlist-soundcloud").removeClass("importing"), this.$(".playlist-container").perfectScrollbar("update")
- }.bind(this))
- }
- }
- },
- importYoutubePlaylistKeyUp: function(a) {
- c = a.which ? a.which : a.keyCode, 13 == c && this.importYoutubePlaylist()
- },
- importYoutubePlaylist: function() {
- var a = this.$(".import-playlist-youtube input").val();
- if (this.$(".err-message").hide(), a && a.length > 0) {
- this.$(".import-playlist-youtube").addClass("importing");
- var b = Dubtrack.config.apiUrl + Dubtrack.config.urls.importYoutubePlaylist;
- Dubtrack.helpers.sendRequest(b, {
- id: this.$(".import-playlist-youtube select").val(),
- yt_playlistid: a
- }, "post", function(a, b) {
- a ? this.$(".import-playlist-youtube .err-message").show().text(a.data && a.data.err && a.data.err.message ? a.data && a.data.err && a.data.err.message : "playlist not found") : (this.$(".import-playlist-youtube input").val(""), b.data && b.data._id && (this.browser.model.add(b.data), Dubtrack.app.navigate("/browser/user/" + b.data._id, {
- trigger: !0
- })), this.closeView()), this.$(".import-playlist-youtube").removeClass("importing")
- }.bind(this))
- }
- return !1
- },
- setSelectedPlaylist: function(a) {
- this.soundCloudPlaylistList.find("li.selected").removeClass("selected"), this.soundCloudPlaylistSelect = a
- },
- openView: function() {
- return this.$el.show(), this.$(".playlist-tab-import-active").removeClass("playlist-tab-import-active"), this.$(".playlist-type-select").addClass("playlist-tab-import-active"), this.$(".err-message").hide(), this.soundCloudPlaylistList.empty(), this.$(".playlist-container").perfectScrollbar("update"), this.soundCloudPlaylistSelect = null, this.setSelect(), !1
- },
- setSelect: function() {
- this.$("select.playlist-select").empty(), this.$("select.playlist-select").append('<option value="" selected>New playlist</option>'), _.each(this.browser.model.models, function(a) {
- this.$("select.playlist-select").append('<option value="' + a.id + '">' + a.get("name") + "</option>")
- }.bind(this))
- },
- closeView: function() {
- return this.$el.hide(), !1
- }
- }), Dubtrack.View.ImportPlaylistBrowserSoundCloudItem = Backbone.View.extend({
- tagName: "li",
- events: {
- click: "clickEvent"
- },
- setParent: function(a) {
- return this.parent = a, this
- },
- initialize: function() {
- return this.$el.html(_.template(Dubtrack.els.templates.layout.soundCloudImportItem, this.model.toJSON())), this.$el.attr("data-id", this.model.id), this
- },
- clickEvent: function() {
- return this.parent.setSelectedPlaylist(this.model), this.$el.addClass("selected"), !1
- }
- }), Dubtrack.AvatarUsersRegistered = new Backbone.Collection, Dubtrack.View.chat = Backbone.View.extend({
- renderSound: !0,
- el: b("#chat"),
- chatSoundFilter: "off",
- _type_message: null,
- events: {
- "keydown input#chat-txt-message": "keyPressAction",
- "click button.pusher-chat-widget-send-btn": "sendMessage",
- "click a.chatSound": "setSound",
- "click .setOnChatNotifications": "setSoundOn",
- "click .setOffChatNotifications": "setSoundOff",
- "click .setMentionChatNotifications": "setSoundMention",
- "click .disableVideo-el": "disableVideo",
- "click a.chat-commands": "displayChatHelp",
- "click #new-messages-counter": "clickChatCounter",
- "click .display-room-users": "displayRoomUsers",
- "click .display-chat": "displayChat",
- "click .display-chat-settings": "displayChatOptions",
- "click .pusher-chat-widget-input .icon-camera": "openGifCreator",
- "click .clearChatToggle": "clearChat",
- "click .hideImagesToggle": "hideImageToggleClick"
- },
- initialize: function() {
- this.chatEndPointUrl = Dubtrack.config.apiUrl + Dubtrack.config.urls.chat.replace(":id", Dubtrack.room.model.id), this.scrollToBottom = !0, this.model = new Dubtrack.Collection.chat, this.model.url = this.chatEndPointUrl, this.model.bind("add", this.appendItem, this), this.disableVideoElBtn = this.$(".disableVideo-el"), this.lastItemChatUser = !1, this.lastItemEl = !1, this.user_muted = !1, this.chatMessageWarningCounter = 0, this.lastSentChatMessage = 0, this.render(), Dubtrack.helpers.sendRequest(this.chatEndPointUrl, {}, "get", function(a, b) {
- this.bindRealtimeEvents(), this.model.add(new Dubtrack.Model.chat({
- time: Date.now(),
- type: "room-welcome-message"
- })), !a && b && b.data && (_.each(b.data, function(a) {
- if ("chat-message" == a.type) {
- var b = new Dubtrack.Model.chat(a);
- this.model.add(b)
- } else "delete-chat-message" == a.type ? this.deleteChatItem(a) : "delete-chat-message-global" == a.type ? this.deleteUserChat(a) : "user-ban" == a.type && this.removeBanUserChat(a)
- }.bind(this)), this.setSoundMention())
- }.bind(this), this), Dubtrack.HideImages && this.hideImageToggle()
- },
- bindRealtimeEvents: function() {
- Dubtrack.Events.bind("realtime:chat-message", this.receiveMessage, this), Dubtrack.Events.bind("realtime:chat-skip", this.receiveMessage, this), Dubtrack.Events.bind("realtime:user-kick", this.receiveMessage, this), Dubtrack.Events.bind("realtime:user-ban", this.receiveMessage, this), Dubtrack.Events.bind("realtime:user-unban", this.receiveMessage, this), Dubtrack.Events.bind("realtime:user-setrole", this.receiveMessage, this), Dubtrack.Events.bind("realtime:user-unsetrole", this.receiveMessage, this), Dubtrack.Events.bind("realtime:user-mute", this.muteUserRealtime, this), Dubtrack.Events.bind("realtime:user-unmute", this.unmuteUserRealtime, this), Dubtrack.Events.bind("realtime:room_playlist-queue-remove-user-song", this.receiveMessage, this), Dubtrack.Events.bind("realtime:room_playlist-queue-remove-user", this.receiveMessage, this), Dubtrack.Events.bind("realtime:room_playlist-queue-reorder", this.receiveMessage, this), Dubtrack.Events.bind("realtime:room-lock-queue", this.receiveMessage, this), Dubtrack.Events.bind("realtime:delete-chat-message", this.deleteChatItem, this), Dubtrack.Events.bind("realtime:delete-chat-message-global", this.deleteUserChat, this), Dubtrack.Events.bind("realtime:user-update-" + Dubtrack.session.id, this.updateImage, this)
- },
- hideImageToggleClick: function() {
- return Dubtrack.HideImages = !Dubtrack.HideImages, Dubtrack.helpers.cookie.set("dubtrack-hide-images", Dubtrack.HideImages ? "hide" : "show", 30), this.hideImageToggle(), this.displayChat(), !1
- },
- hideImageToggle: function() {
- Dubtrack.HideImages ? (this.$(".hideImagesToggle").html("Show Images"), this.$el.addClass("hide-images-in-text")) : (this.$(".hideImagesToggle").html("Hide Images"), this.$el.removeClass("hide-images-in-text")), this.$(".chat-messages").scrollTop(0), this.$(".chat-messages").perfectScrollbar("update");
- var a = this.$(".chat-messages")[0].scrollHeight;
- this.$(".chat-messages").scrollTop(a), this.$(".chat-messages").perfectScrollbar("update")
- },
- clearChat: function() {
- return this.model.reset({}), Dubtrack.room.chat._messagesEl.find("li").remove(), this.clear_chat_timeout && clearTimeout(this.clear_chat_timeout), this.clear_chat_timeout = setTimeout(function() {
- (new Dubtrack.View.chatLoadingItem).$el.text("Chat has been cleared!").appendTo(Dubtrack.room.chat._messagesEl)
- }, 300), this.$(".chat-messages").scrollTop(0), this.$(".chat-messages").perfectScrollbar("update"), this.displayChat(), !1
- },
- disableVideo: function() {
- var a;
- this.isdisableVideo ? (this.isdisableVideo = !1, Dubtrack.room.player.reloadVideo(), b(".chat-option-buttons-video span").css("color", "#878c8e"), this.disableVideoElBtn.removeClass("active"), a = "off") : (this.isdisableVideo = !0, Dubtrack.room.player.YTplayerDelegate && Dubtrack.room.player.YTplayerDelegate.close(), Dubtrack.room.player.SCplayerDelegate && Dubtrack.room.player.SCplayerDelegate.close(), Dubtrack.room.player.YTplayerDelegate = null, Dubtrack.room.player.SCplayerDelegate = null, b(".playerElement").remove(), b(".chat-option-buttons-video span").css("color", "white"), this.disableVideoElBtn.addClass("active"), a = "on")
- },
- muteUserRealtime: function(a) {
- Dubtrack.session && Dubtrack.session.id == a.mutedUser._id && (this.user_muted = !0)
- },
- unmuteUserRealtime: function(a) {
- Dubtrack.session && Dubtrack.session.id == a.mutedUser._id && (this.user_muted = !1)
- },
- openGifCreator: function() {
- return window.open("/imgur/index.html#&client_id=94daca23890c704?action=chat&roomid=" + Dubtrack.room.model.id, "Dubtrack FM - GIF creator", "height=590,width=340,resizable=no,location=no,scrollbars=no"), !1
- },
- displayRoomUsers: function() {
- return Dubtrack.room && Dubtrack.room.$el && (Dubtrack.room.$el.removeClass("display-chat-settings").addClass("display-users-rooms"), Dubtrack.room && Dubtrack.room.users && (Dubtrack.room.users.resetEl(), Dubtrack.room.users.displayActiveUsers())), !1
- },
- displayChat: function() {
- return Dubtrack.room && Dubtrack.room.$el && Dubtrack.room.$el.removeClass("display-users-rooms display-chat-settings"), !1
- },
- displayChatOptions: function() {
- return Dubtrack.room && Dubtrack.room.$el && Dubtrack.room.$el.removeClass("display-users-rooms").addClass("display-chat-settings"), !1
- },
- updateImage: function(a) {
- this.refreshImage = (new Date).getTime(), b.each(this.$("ul.chat-main li:regex(class, .*user-" + a.user._id.toLowerCase() + ".*)"), function() {
- b(this).find(".image_row img").attr("src", a.img)
- })
- },
- render: function() {
- var a = this;
- return this.$el.html(_.template(Dubtrack.els.templates.chat.chatContainer, {})), this._messageInputEl = this.$("input#chat-txt-message"), this._messagesEl = this.$("ul.chat-main"), this.chatSoundHtmlEl = this.$("a.chatSound"), this.renderSound = !1, this.chatCmdEl = this.$(".chat-commands"), this.loadingHistory = this.$(".chatLoading"), this.globalNotificationsEl = this.$("ul.globalNotifications"), this.renderSound = !0, this.isScrolling = !1, this.newMessageCounter = 0, this.createSound(), this.$(".chat-messages").perfectScrollbar({
- wheelSpeed: 50,
- suppressScrollX: !0,
- wheelPropagation: !1,
- onscrollCallback: function(b, c) {
- a.onChatScroll(b, c)
- }
- }), this
- },
- clickChatCounter: function() {
- return this.scrollToBottom = !0, this.scollBottomChat(), !1
- },
- onChatScroll: function(a, b) {
- b - 200 > a ? this.scrollToBottom = !1 : (this.scrollToBottom = !0, this.$("#new-messages-counter").hide(), this.newMessageCounter = 0)
- },
- receiveMessage: function(a) {
- var c = a.user && "_id" in a.user ? a.user._id : !1;
- if ("user-ban" === a.type && this.removeBanUserChat(a), !Dubtrack.session || !c || "chat-message" !== a.type || a.user._id !== Dubtrack.session.get("_id")) {
- var d = new Dubtrack.Model.chat(a);
- if (this.model.add(d), Dubtrack.session) {
- var e = "@" + Dubtrack.session.get("username");
- a && a.message && a.message.toLowerCase().indexOf(e) > -1 && b(".username-handle:contains(" + e + ")").css("color", "rgba(255,0,255,0.80)")
- }
- }
- },
- userJoin: function(a) {
- var b = a.user && "_id" in a.user ? a.user._id : !1;
- if (!Dubtrack.session || !b || a.user._id !== Dubtrack.session.get("_id")) {
- var c = Dubtrack.AvatarUsersRegistered.findWhere({
- _id: a.user._id
- });
- if (!c) {
- Dubtrack.AvatarUsersRegistered.add(a.user);
- var d = new Dubtrack.Model.chat(a);
- this.model.add(d)
- }
- }
- },
- displayChatHelp: function() {
- return this.chatHelp || (this.chatHelp = new Dubtrack.View.helpModalMod), this.chatHelp.$el.show(), !1
- },
- keyPressAction: function(a) {
- return c = a.which ? a.which : a.keyCode, 13 == c ? (this.sendMessage(), !1) : void 0
- },
- setDefaultSound: function(a) {
- switch (this.chatSoundHtmlEl.removeClass("mute"), a) {
- case "none":
- this.renderSound = !0, this.chatSoundFilter = "none", this.chatSoundHtmlEl.html(dubtrack_lang.chat.sound_on);
- break;
- case "mention":
- this.renderSound = !0, this.chatSoundFilter = "mention", this.chatSoundHtmlEl.html(dubtrack_lang.chat.sound_mention);
- break;
- case "off":
- this.renderSound = !1, this.chatSoundFilter = "off", this.chatSoundHtmlEl.html(dubtrack_lang.chat.sound_off), this.chatSoundHtmlEl.addClass("mute");
- break;
- default:
- this.renderSound = !0, this.chatSoundFilter = "none", this.chatSoundHtmlEl.html(dubtrack_lang.chat.sound_on)
- }
- return !1
- },
- setSoundOn: function() {
- return this.$(".chat-option-buttons-sound .active").removeClass("active"), this.$(".setOnChatNotifications").addClass("active"), this.renderSound = !0, this.chatSoundFilter = "none", !1
- },
- setSoundOff: function() {
- return this.$(".chat-option-buttons-sound .active").removeClass("active"), this.$(".setOffChatNotifications").addClass("active"), this.renderSound = !1, this.chatSoundFilter = "off", !1
- },
- setSoundMention: function() {
- return this.$(".chat-option-buttons-sound .active").removeClass("active"), this.$(".setMentionChatNotifications").addClass("active"), this.renderSound = !0, this.chatSoundFilter = "mention", !1
- },
- setSound: function() {
- switch (this.chatSoundHtmlEl.removeClass("mute"), this.chatSoundFilter) {
- case "none":
- this.renderSound = !0, this.chatSoundFilter = "mention", this.chatSoundHtmlEl.html(dubtrack_lang.chat.sound_mention);
- break;
- case "mention":
- this.renderSound = !1, this.chatSoundFilter = "off", this.chatSoundHtmlEl.html(dubtrack_lang.chat.sound_off), this.chatSoundHtmlEl.addClass("mute");
- break;
- case "off":
- this.renderSound = !0, this.chatSoundFilter = "none", this.chatSoundHtmlEl.html(dubtrack_lang.chat.sound_on);
- break;
- default:
- this.renderSound = !0, this.chatSoundFilter = "none", this.chatSoundHtmlEl.html(dubtrack_lang.chat.sound_on)
- }
- return !1
- },
- displayHistory: function() {
- var a = this;
- b.ajax({
- url: g.config.getChatHistory + g.roomModel.id,
- data: {},
- type: "GET",
- success: function(b) {
- _.each(b.data.chat_history, function(b) {
- a.appendEl(b)
- }), a.loadingHistory.hide(), a.createSound()
- },
- error: function() {
- a.loadingHistory.hide(), a.createSound()
- }
- }, "json")
- },
- appendItem: function(a) {
- var b;
- switch (a.get("type")) {
- case "chat-skip":
- this.lastItemChatUser = !1, this.lastItemEl = !1, b = new Dubtrack.View.chatSkipItem({
- model: a
- }), b.$el.appendTo(this._messagesEl), this.playSound(!1);
- break;
- case "user-join":
- this.lastItemChatUser = !1, this.lastItemEl = !1, b = new Dubtrack.View.chatJoinItem({
- model: a
- }), b.$el.appendTo(this._messagesEl), this.playSound(!1);
- break;
- case "user-kick":
- this.lastItemChatUser = !1, this.lastItemEl = !1, b = new Dubtrack.View.chatKickedItem({
- model: a
- }), b.$el.appendTo(this._messagesEl), this.playSound(!1);
- break;
- case "user-ban":
- this.lastItemChatUser = !1, this.lastItemEl = !1, b = new Dubtrack.View.chatBannedItem({
- model: a
- }), b.$el.appendTo(this._messagesEl), this.playSound(!1);
- break;
- case "user-unban":
- this.lastItemChatUser = !1, this.lastItemEl = !1, b = new Dubtrack.View.chatUnbannedItem({
- model: a
- }), b.$el.appendTo(this._messagesEl), this.playSound(!1);
- break;
- case "user-setrole":
- this.lastItemChatUser = !1, this.lastItemEl = !1, b = new Dubtrack.View.chatSetRoleItem({
- model: a
- }), b.$el.appendTo(this._messagesEl), this.playSound(!1);
- break;
- case "user-unsetrole":
- this.lastItemChatUser = !1, this.lastItemEl = !1, b = new Dubtrack.View.chatUnsetRoleItem({
- model: a
- }), b.$el.appendTo(this._messagesEl), this.playSound(!1);
- break;
- case "room_playlist-queue-remove-user-song":
- this.lastItemChatUser = !1, this.lastItemEl = !1, b = new Dubtrack.View.removedSongFromQueueItem({
- model: a
- }), b.$el.appendTo(this._messagesEl), this.playSound(!1);
- break;
- case "room_playlist-queue-remove-user":
- this.lastItemChatUser = !1, this.lastItemEl = !1, b = new Dubtrack.View.removedFromQueueItem({
- model: a
- }), b.$el.appendTo(this._messagesEl), this.playSound(!1);
- break;
- case "room_playlist-queue-reorder":
- this.lastItemChatUser = !1, this.lastItemEl = !1, b = new Dubtrack.View.reorderQueueItem({
- model: a
- }), b.$el.appendTo(this._messagesEl), this.playSound(!1);
- break;
- case "room-lock-queue":
- this.lastItemChatUser = !1, this.lastItemEl = !1, b = new Dubtrack.View.lockRoomQueueItem({
- model: a
- }), b.$el.appendTo(this._messagesEl), this.playSound(!1);
- break;
- case "user-pause-queue":
- this.lastItemChatUser = !1, this.lastItemEl = !1, b = new Dubtrack.View.pauseUserQueueItem({
- model: a
- }), b.$el.appendTo(this._messagesEl), this.playSound(!1);
- break;
- case "room-welcome-message":
- this.lastItemChatUser = !1, this.lastItemEl = !1, b = new Dubtrack.View.welcomeMessageChatItem({
- model: a
- }), b.$el.appendTo(this._messagesEl), this.playSound(!1);
- break;
- default:
- this.refreshImage && a.set({
- refreshVersion: this.refreshImage
- }), b = new Dubtrack.View.chatItem({
- model: a
- });
- var c = a.get("user"),
- d = a.get("message");
- if (/^\/me.*\S+/.test(d)) return this.lastItemChatUser = !1, this.lastItemEl = !1, b = new Dubtrack.View.chatMeCommand({
- model: a
- }), b.$el.appendTo(this._messagesEl), void this.playSound(!1);
- if (Dubtrack.session && Dubtrack.session.id != c._id && Dubtrack.room && Dubtrack.room.users && Dubtrack.room.users.getIfmuted(c._id)) return;
- this.lastItemEl && this.lastItemChatUser && c._id == this.lastItemChatUser._id && this.lastItemEl.$el.is(":visible") ? (this.lastItemEl.$(".text").append("<p>" + a.get("message") + "</p>"), this.lastItemEl.model.set("id", a.get("chatid")), this.lastItemEl.updateTime(a.get("time")), this.lastItemEl.$el.removeClass("deleted-message")) : (this.lastItemChatUser = c, this.lastItemEl = b, b.$el.appendTo(this._messagesEl), b.render());
- var e = new RegExp("@everyone\\b", "g"),
- f = new RegExp("@mods\\b", "g"),
- g = new RegExp("@djs\\b", "g");
- if (Dubtrack.loggedIn) try {
- var h = new RegExp("@" + Dubtrack.session.get("username") + "\\b", "g"),
- i = h.test(a.get("message")),
- j = e.test(a.get("message")) && (Dubtrack.helpers.isDubtrackAdmin(c._id) || Dubtrack.room.users.getIfRoleHasPermission(c._id, "chat-mention")),
- k = f.test(a.get("message")) && (Dubtrack.helpers.isDubtrackAdmin(Dubtrack.session.id) || Dubtrack.room.users.getIfRoleHasPermission(Dubtrack.session.id, "chat-mention")),
- l = g.test(a.get("message")) && (Dubtrack.helpers.isDubtrackAdmin(c._id) || Dubtrack.room.users.getIfRoleHasPermission(c._id, "chat-mention")) && Dubtrack.room.player && Dubtrack.room.player.activeQueueCollection && Dubtrack.room.player.activeQueueCollection.findWhere({
- userid: Dubtrack.session.id
- });
- this.playSound(i || j || k || l)
- } catch (m) {} else this.playSound(!1)
- }
- this.scrollToBottom || (this.$("#new-messages-counter").show(), this.newMessageCounter++, this.newMessageCounter > 1 ? this.$("#new-messages-counter .messages-display").html(this.newMessageCounter + " new messages") : this.$("#new-messages-counter .messages-display").html(this.newMessageCounter + " new message"))
- },
- createSound: function() {
- if (!this.chatSound) {
- this.chatSound = !0, this.mentionChatSound = !0;
- var a = this;
- soundManager.setup({
- url: "/assets/swf/",
- flashVersion: 9,
- onready: function() {
- a.chatSound = soundManager.createSound({
- id: "chatsound",
- autoPlay: !1,
- url: Dubtrack.config.urls.mediaBaseUrl + "/assets/music/notification.mp3",
- onerror: function() {
- a.chatSound = !1
- }
- }), a.mentionChatSound = soundManager.createSound({
- id: "chatmentionsound",
- autoPlay: !1,
- url: "/assets/music/user_ping.mp3",
- onerror: function() {
- a.chatSound = !1
- }
- })
- }
- })
- }
- },
- scollBottomChat: function() {
- if (this.scrollToBottom) {
- this.$(".chat-messages").perfectScrollbar("update");
- var a = this.$(".chat-messages")[0].scrollHeight;
- this.$(".chat-messages").scrollTop(a), this.$(".chat-messages").perfectScrollbar("update")
- }
- },
- playSound: function(a) {
- if (this.scollBottomChat(), this.renderSound) {
- if ("none" == this.chatSoundFilter) try {
- this.chatSound && this.chatSound.play()
- } catch (b) {}
- if ("off" != this.chatSoundFilter && a) try {
- this.mentionChatSound && this.mentionChatSound.play()
- } catch (b) {}
- }
- },
- systemMessageReceived: function(a) {
- null !== a && "" !== a && (Chat._messagesEl.append(content), this.playSound(!1))
- },
- genMessageInfo: function(a) {
- null !== a && "" !== a && this.playSound(!1)
- },
- sendMessage: function() {
- var a = b("<div/>").text(b.trim(this._messageInputEl.val())).html();
- if ("" !== a && null !== a) {
- this._messageInputEl.val("");
- var c, d, e;
- if (0 === a.indexOf("/kick @")) return e = a.replace(/(@[A-Za-z0-9_.]+)/g, function(a) {
- return d = a.replace("@", ""), a
- }), void this.kickUser(d, b.trim(a.replace("/kick @" + d, "")));
- if (0 === a.indexOf("/ban @")) return e = a.replace(/(@[A-Za-z0-9_.]+)/g, function(a) {
- return d = a.replace("@", ""), a
- }), void this.banUser(d, parseInt(b.trim(a.replace("/ban @" + d, "")), 10));
- if (0 === a.indexOf("/unban @")) return e = a.replace(/(@[A-Za-z0-9_.]+)/g, function(a) {
- return d = a.replace("@", ""), a
- }), void this.unbanUser(d);
- if (0 === a.indexOf("/setmod @")) return e = a.replace(/(@[A-Za-z0-9_.]+)/g, function(a) {
- return d = a.replace("@", ""), a
- }), void this.setRole(d, "setModUser");
- if (0 === a.indexOf("/unsetmod @")) return e = a.replace(/(@[A-Za-z0-9_.]+)/g, function(a) {
- return d = a.replace("@", ""), a
- }), void this.unsetRole(d, "setModUser");
- if (0 === a.indexOf("/setresdj @")) return e = a.replace(/(@[A-Za-z0-9_.]+)/g, function(a) {
- return d = a.replace("@", ""), a
- }), void this.setRole(d, "setDJUser");
- if (0 === a.indexOf("/unsetresdj @")) return e = a.replace(/(@[A-Za-z0-9_.]+)/g, function(a) {
- return d = a.replace("@", ""), a
- }), void this.unsetRole(d, "setDJUser");
- if (0 === a.indexOf("/setdj @")) return e = a.replace(/(@[A-Za-z0-9_.]+)/g, function(a) {
- return d = a.replace("@", ""), a
- }), void this.setRole(d, "setRoomDJUser");
- if (0 === a.indexOf("/unsetdj @")) return e = a.replace(/(@[A-Za-z0-9_.]+)/g, function(a) {
- return d = a.replace("@", ""), a
- }), void this.unsetRole(d, "setRoomDJUser");
- if (0 === a.indexOf("/setvip @")) return e = a.replace(/(@[A-Za-z0-9_.]+)/g, function(a) {
- return d = a.replace("@", ""), a
- }), void this.setRole(d, "setVIPUser");
- if (0 === a.indexOf("/unsetvip @")) return e = a.replace(/(@[A-Za-z0-9_.]+)/g, function(a) {
- return d = a.replace("@", ""), a
- }), void this.unsetRole(d, "setVIPUser");
- if (0 === a.indexOf("/setmanager @")) return e = a.replace(/(@[A-Za-z0-9_.]+)/g, function(a) {
- return d = a.replace("@", ""), a
- }), void this.setRole(d, "setManagerUser");
- if (0 === a.indexOf("/unsetmanager @")) return e = a.replace(/(@[A-Za-z0-9_.]+)/g, function(a) {
- return d = a.replace("@", ""), a
- }), void this.unsetRole(d, "setManagerUser");
- if (0 === a.indexOf("/setowner @")) return e = a.replace(/(@[A-Za-z0-9_.]+)/g, function(a) {
- return d = a.replace("@", ""), a
- }), void this.setRole(d, "setOwnerUser");
- if (0 === a.indexOf("/unsetowner @")) return e = a.replace(/(@[A-Za-z0-9_.]+)/g, function(a) {
- return d = a.replace("@", ""), a
- }), void this.unsetRole(d, "setOwnerUser");
- if (0 === a.indexOf("/unmute @")) return e = a.replace(/(@[A-Za-z0-9_.]+)/g, function(a) {
- return d = a.replace("@", ""), a
- }), void this.unmuteUser(d);
- if (0 === a.indexOf("/mute @")) return e = a.replace(/(@[A-Za-z0-9_.]+)/g, function(a) {
- return d = a.replace("@", ""), a
- }), void this.muteUser(d);
- if (0 === a.indexOf("/skip")) return void this.skipSong();
- Date.now() - this.lastSentChatMessage < 1500 ? (this.chatMessageWarningCounter++, this.chatMessageWarningCounter > 4 && (this.model.add(new Dubtrack.Model.chat({
- user: {
- _force_updated: 1448781184094,
- userInfo: {
- _id: "565aa52e6fe207830052f580",
- userid: "565aa52e6fe207830052f57f",
- __v: 0
- },
- _id: "565aa52e6fe207830052f57f",
- username: "dubtrack_bot",
- status: 1,
- roleid: 1,
- dubs: 0,
- created: 1448781102432,
- __v: 0
- },
- message: "whoa @" + Dubtrack.session.get("username") + "! slow down or you will be temporarily blocked from chatting",
- time: Date.now(),
- realTimeChannel: Dubtrack.room.model.get("realTimeChannel"),
- type: "chat-message"
- })), this.chatMessageWarningCounter = 0)) : this.chatMessageWarningCounter = 0, this.lastSentChatMessage = Date.now(), c = new Dubtrack.Model.chat({
- user: Dubtrack.session.toJSON(),
- message: a,
- time: Date.now(),
- realTimeChannel: Dubtrack.room.model.get("realTimeChannel"),
- type: "chat-message"
- }), this.user_muted || (c.urlRoot = this.chatEndPointUrl, c.save(null, {
- error: function(a, b) {
- this.lastItemChatUser = !1, this.lastItemEl = !1;
- var c = new Dubtrack.View.chatLoadingItem;
- if (c.$el.appendTo(this._messagesEl), b && b.status && 429 == b.status) try {
- var d = JSON.parse(b.responseText);
- d && d.data && d.data.details && d.data.details.message ? c.$el.addClass("system-error").html("You reached chat quota limit, please wait " + d.data.details.message + " before retrying") : c.$el.addClass("system-error").html("You reached chat quota limit, please wait 10 mins before retrying")
- } catch (e) {
- c.$el.addClass("system-error").html("You reached chat quota limit, please wait 10 mins before retrying")
- } else c.$el.addClass("system-error").html("An error occurred sending chat message");
- try {
- this.$(".chat-messages").scrollTop(0), this.$(".chat-messages").perfectScrollbar("update");
- var f = this.$(".chat-messages")[0].scrollHeight;
- this.$(".chat-messages").scrollTop(f), this.$(".chat-messages").perfectScrollbar("update")
- } catch (e) {}
- }.bind(this)
- })), this.model.add(c)
- }
- },
- deleteChatItem: function(a) {
- if (a.chatid && a.user && a.user.username) {
- this.$(".chat-main li.chat-id-" + a.chatid + " .text").html('<p class="deleted">chat message deleted by @' + a.user.username + "</p>"), this.$(".chat-main li.chat-id-" + a.chatid).addClass("deleted-message");
- try {
- this.$(".chat-messages").scrollTop(0), this.$(".chat-messages").perfectScrollbar("update");
- var b = this.$(".chat-messages")[0].scrollHeight;
- this.$(".chat-messages").scrollTop(b), this.$(".chat-messages").perfectScrollbar("update")
- } catch (c) {}
- }
- },
- deleteUserChat: function(a) {
- if (a.userdid && a.user && a.user.username) {
- this.$(".chat-main li.user-" + a.userdid + " .text").html('<p class="deleted">chat message deleted by @' + a.user.username + "</p>"), this.$(".chat-main li.user-" + a.userdid).addClass("deleted-message");
- try {
- this.$(".chat-messages").scrollTop(0), this.$(".chat-messages").perfectScrollbar("update");
- var b = this.$(".chat-messages")[0].scrollHeight;
- this.$(".chat-messages").scrollTop(b), this.$(".chat-messages").perfectScrollbar("update")
- } catch (c) {}
- }
- },
- removeBanUserChat: function(a) {
- if (a.user && a.user.username && a.kickedUser) {
- this.$(".chat-main li.user-" + a.kickedUser._id + " .text").html('<p class="deleted">user was banned by @' + a.user.username + "</p>"), this.$(".chat-main li.user-" + a.kickedUser._id).addClass("deleted-message");
- try {
- this.$(".chat-messages").scrollTop(0), this.$(".chat-messages").perfectScrollbar("update");
- var b = this.$(".chat-messages")[0].scrollHeight;
- this.$(".chat-messages").scrollTop(b), this.$(".chat-messages").perfectScrollbar("update")
- } catch (c) {}
- }
- },
- setUserCount: function(a) {
- this.$(".room-user-counter").html(a), b(".mobile-users-counter").html(a)
- },
- setGuestCount: function(a) {
- this.$(".room-guest-counter").html("+" + a)
- },
- skipSong: function() {
- var a = new Dubtrack.View.chatLoadingItem;
- if (a.$el.appendTo(this._messagesEl), Dubtrack.room && Dubtrack.room.player && Dubtrack.room.player.activeSong && Dubtrack.room.player.activeSong.get("song")) {
- var b = Dubtrack.room.player.activeSong.get("song");
- if (!b._id) return void a.$el.addClass("system-error").html("No active song");
- var c = Dubtrack.config.apiUrl + Dubtrack.config.urls.skipSong.replace(":id", Dubtrack.room.model.id).replace(":songid", b._id);
- Dubtrack.helpers.sendRequest(c, {
- realTimeChannel: Dubtrack.room.model.get("realTimeChannel")
- }, "post", function(b, c) {
- b ? b.data && b.data.err && b.data.err.details && b.data.err.details.message ? a.$el.addClass("system-error").html(b.data.err.details.message) : a.$el.addClass("system-error").html("unauthorized action") : a.$el.hide()
- }, this)
- } else a.$el.addClass("system-error").html("No active song")
- },
- setRole: function(a, b) {
- var c = new Dubtrack.View.chatLoadingItem;
- return c.$el.appendTo(this._messagesEl), Dubtrack.config.urls[b] ? void Dubtrack.cache.users.getByUsername(a, function(d, e) {
- (d || !e) && c.$el.addClass("system-error").html("Invalid user: @" + a);
- var f = Dubtrack.config.apiUrl + Dubtrack.config.urls[b].replace(":roomid", Dubtrack.room.model.id);
- f = f.replace(":id", e.id), Dubtrack.helpers.sendRequest(f, {
- realTimeChannel: Dubtrack.room.model.get("realTimeChannel")
- }, "post", function(a, b) {
- a ? a.data && a.data.err && a.data.err.details && a.data.err.details.message ? c.$el.addClass("system-error").html(a.data.err.details.message) : c.$el.addClass("system-error").html("unauthorized action") : c.$el.hide()
- }, this)
- }) : void c.$el.addClass("system-error").html("Invalid action")
- },
- unsetRole: function(a, b) {
- var c = new Dubtrack.View.chatLoadingItem;
- return c.$el.appendTo(this._messagesEl), Dubtrack.config.urls[b] ? void Dubtrack.cache.users.getByUsername(a, function(d, e) {
- (d || !e) && c.$el.addClass("system-error").html("Invalid user: @" + a);
- var f = Dubtrack.config.apiUrl + Dubtrack.config.urls[b].replace(":roomid", Dubtrack.room.model.id);
- f = f.replace(":id", e.id), Dubtrack.helpers.sendRequest(f, {
- realTimeChannel: Dubtrack.room.model.get("realTimeChannel")
- }, "delete", function(a, b) {
- a ? a.data && a.data.err && a.data.err.details && a.data.err.details.message ? c.$el.addClass("system-error").html(a.data.err.details.message) : c.$el.addClass("system-error").html("unauthorized action") : c.$el.hide()
- }, this)
- }) : void c.$el.addClass("system-error").html("Invalid action")
- },
- unmuteUser: function(a) {
- var b = new Dubtrack.View.chatLoadingItem;
- b.$el.appendTo(this._messagesEl);
- var c = this;
- Dubtrack.cache.users.getByUsername(a, function(d, e) {
- (d || !e) && b.$el.addClass("system-error").html("Invalid user: @" + a);
- var f = Dubtrack.config.apiUrl + Dubtrack.config.urls.muteUser.replace(":roomid", Dubtrack.room.model.id);
- f = f.replace(":id", e.id), Dubtrack.helpers.sendRequest(f, {
- realTimeChannel: Dubtrack.room.model.get("realTimeChannel")
- }, "delete", function(a, d) {
- a ? a.data && a.data.err && a.data.err.details && a.data.err.details.message ? b.$el.addClass("system-error").html(a.data.err.details.message) : b.$el.addClass("system-error").html("unauthorized action") : (c.lastItemChatUser = !1, c.lastItemEl = !1, b.$el.html("user quietly unmuted"))
- }, this)
- })
- },
- muteUser: function(a) {
- var b = new Dubtrack.View.chatLoadingItem;
- b.$el.appendTo(this._messagesEl);
- var c = this;
- Dubtrack.cache.users.getByUsername(a, function(d, e) {
- (d || !e) && b.$el.addClass("system-error").html("Invalid user: @" + a);
- var f = Dubtrack.config.apiUrl + Dubtrack.config.urls.muteUser.replace(":roomid", Dubtrack.room.model.id);
- f = f.replace(":id", e.id), Dubtrack.helpers.sendRequest(f, {
- realTimeChannel: Dubtrack.room.model.get("realTimeChannel")
- }, "post", function(a, d) {
- a ? a.data && a.data.err && a.data.err.details && a.data.err.details.message ? b.$el.addClass("system-error").html(a.data.err.details.message) : b.$el.addClass("system-error").html("unauthorized action") : (c.lastItemChatUser = !1, c.lastItemEl = !1, b.$el.html("user quietly muted"))
- }, this)
- })
- },
- unbanUser: function(a) {
- var b = new Dubtrack.View.chatLoadingItem;
- b.$el.appendTo(this._messagesEl), Dubtrack.cache.users.getByUsername(a, function(c, d) {
- (c || !d) && b.$el.addClass("system-error").html("Invalid user: @" + a);
- var e = Dubtrack.config.apiUrl + Dubtrack.config.urls.banUser.replace(":roomid", Dubtrack.room.model.id);
- e = e.replace(":id", d.id), Dubtrack.helpers.sendRequest(e, {
- realTimeChannel: Dubtrack.room.model.get("realTimeChannel")
- }, "delete", function(a, c) {
- a ? a.data && a.data.err && a.data.err.details && a.data.err.details.message ? b.$el.addClass("system-error").html(a.data.err.details.message) : b.$el.addClass("system-error").html("unauthorized action") : b.$el.hide()
- }, this)
- })
- },
- banUser: function(a, b) {
- var c = new Dubtrack.View.chatLoadingItem;
- c.$el.appendTo(this._messagesEl), Dubtrack.cache.users.getByUsername(a, function(d, e) {
- (d || !e) && c.$el.addClass("system-error").html("Invalid user: @" + a);
- var f = Dubtrack.config.apiUrl + Dubtrack.config.urls.banUser.replace(":roomid", Dubtrack.room.model.id);
- f = f.replace(":id", e.id), isNaN(b) && (b = 0), Dubtrack.helpers.sendRequest(f, {
- time: b,
- realTimeChannel: Dubtrack.room.model.get("realTimeChannel")
- }, "post", function(a, b) {
- a ? a.data && a.data.err && a.data.err.details && a.data.err.details.message ? c.$el.addClass("system-error").html(a.data.err.details.message) : c.$el.addClass("system-error").html("unauthorized action") : c.$el.hide()
- }, this)
- })
- },
- kickUser: function(a, b) {
- var c = new Dubtrack.View.chatLoadingItem;
- c.$el.appendTo(this._messagesEl), Dubtrack.cache.users.getByUsername(a, function(d, e) {
- (d || !e) && c.$el.addClass("system-error").html("Invalid user: @" + a);
- var f = Dubtrack.config.apiUrl + Dubtrack.config.urls.kickUser.replace(":roomid", Dubtrack.room.model.id);
- f = f.replace(":id", e.id), Dubtrack.helpers.sendRequest(f, {
- message: b,
- realTimeChannel: Dubtrack.room.model.get("realTimeChannel")
- }, "post", function(a, b) {
- a ? a.data && a.data.err && a.data.err.details && a.data.err.details.message ? c.$el.addClass("system-error").html(a.data.err.details.message) : c.$el.addClass("system-error").html("unauthorized action") : c.$el.hide()
- }, this)
- })
- }
- }), Dubtrack.UserImagesBustings = {}, Dubtrack.View.chatItem = Backbone.View.extend({
- tagName: "li",
- events: {
- "click a.username": "clickUsername",
- "click .chatDelete": "deleteChat"
- },
- initialize: function() {
- this.model.set("message", Dubtrack.helpers.text.convertHtmltoTags(this.model.get("message"), "Dubtrack.room.chat.scollBottomChat();")), this.model.set("message", Dubtrack.helpers.text.convertAttoLink(this.model.get("message"))), this.model.bind("change", this.setId, this);
- var a = this.model.toJSON();
- a.userImage = Dubtrack.config.apiUrl + "/user/" + a.user._id + "/image", a.refreshVersion && (a.userImage = a.userImage + "?v=" + a.refreshVersion), this.$el.html(_.template(Dubtrack.els.templates.chat.chatMessage, a)), Dubtrack.UserImagesBustings[a.user._id] && this.$(".image_row img").attr("src", Dubtrack.UserImagesBustings[a.user._id]), this.$el.addClass("user-" + a.user._id), Dubtrack.session && Dubtrack.session.id && Dubtrack.session.id == a.user._id && this.$el.addClass("current-chat-user"), Dubtrack.Events.bind("realtime:user-update-" + a.user._id, this.updateUser, this), this.setId()
- },
- render: function() {
- var a = new Date(this.model.get("time"));
- this.$(".timeinfo").html('<time class="timeago" datetime="' + a.toISOString() + '">' + a.toLocaleString() + "</time>"), this.$(".timeago").timeago(), this.$("img").load(function() {
- try {
- Dubtrack.room.chat.scollBottomChat()
- } catch (a) {}
- }), this.$("img").error(function() {
- b(this).attr("src", "/assets/images/media/chat_image_load_error.png")
- }), emojify.run(this.el)
- },
- setId: function() {
- var a = this.model.get("chatid");
- a && this.$el.addClass("chat-id-" + a)
- },
- updateTime: function(a) {
- var c = new Date(a);
- this.$(".timeago").timeago("update", c.toISOString()), this.$("img").load(function() {
- try {
- Dubtrack.room.chat.scollBottomChat()
- } catch (a) {}
- }), this.$("img").error(function() {
- b(this).attr("src", "/assets/images/media/chat_image_load_error.png")
- }), emojify.run(this.el)
- },
- navigateAvatar: function(a) {
- var c = b(a.target).data();
- return "username" in c && g.app.navigate("/" + c.username, {
- trigger: !0
- }), !1
- },
- updateUser: function(a) {
- if (a && a.img && a.img.url) {
- var b = this.model.get("user");
- b && (Dubtrack.UserImagesBustings[b._id] = a.img.url), this.$(".image_row img").attr("src", a.img.url)
- }
- },
- clickUsername: function() {
- var a = this.model.get("user");
- if (a) {
- var b = Dubtrack.room.chat._messageInputEl.val();
- b.length > 0 ? Dubtrack.room.chat._messageInputEl.val(Dubtrack.room.chat._messageInputEl.val() + "@" + a.username + " ") : Dubtrack.room.chat._messageInputEl.val("@" + a.username + " "), Dubtrack.room.chat._messageInputEl.focus()
- }
- return !1
- },
- deleteChat: function() {
- var a = this.model.get("chatid");
- if (a) {
- var b = a.split("-").shift();
- if (b === Dubtrack.session.id || Dubtrack.helpers.isDubtrackAdmin(Dubtrack.session.id) || Dubtrack.room.users && Dubtrack.room.users.getIfRoleHasPermission(Dubtrack.session.id, "delete-chat")) {
- this.$(".text").html('<p class="deleted">loading...</p>');
- var c = Dubtrack.config.apiUrl + Dubtrack.config.urls.deleteChat.replace(":id", Dubtrack.room.model.id).replace(":chatid", a);
- Dubtrack.helpers.sendRequest(c, {}, "delete", function(a, b) {
- a && this.$(".text").html('<p class="deleted">you don\'t have permissions to do this</p>')
- }.bind(this))
- } else this.close()
- }
- },
- beforeClose: function() {
- this.$("time.timeago").timeago("dispose")
- }
- }), Dubtrack.View.systemChatItem = Backbone.View.extend({
- tagName: "li",
- attributes: {
- "class": "system"
- },
- events: {},
- initialize: function() {
- this.$el.html(dubtrack_lang.global.loading)
- },
- beforeClose: function() {}
- }), Dubtrack.View.chatMeCommand = Dubtrack.View.chatItem.extend({
- attributes: {
- "class": "chat-me-command-joined"
- },
- initialize: function() {
- this.model.bind("change", this.setId, this);
- var a = this.model.get("user"),
- b = this.model.get("message");
- b && (b = b.replace(/^\/me\s/, "")), b && b.length > 0 && this.$el.html("<div class='chatDelete'><span class='icon-close'></span></div><div class='text'>@" + a.username + " " + b + "</div>"), emojify.run(this.el), this.setId()
- },
- render: function() {}
- }), Dubtrack.View.chatLoadingItem = Dubtrack.View.systemChatItem.extend({
- attributes: {
- "class": "chat-system-loading"
- }
- }), Dubtrack.View.chatJoinItem = Dubtrack.View.systemChatItem.extend({
- attributes: {
- "class": "chat-system-joined"
- },
- initialize: function() {
- var a = this.model.get("user");
- this.$el.html("@" + a.username + " joined the room")
- }
- }), Dubtrack.View.chatSkipItem = Dubtrack.View.systemChatItem.extend({
- initialize: function() {
- var a = this.model.get("username");
- a ? this.$el.html("song skipped by @" + a) : this.$el.html("song skipped by a moderator")
- }
- }), Dubtrack.View.chatKickedItem = Dubtrack.View.systemChatItem.extend({
- initialize: function() {
- var a = this.model.get("kickedUser"),
- b = this.model.get("user");
- this.$el.html("@" + a.username + " was kicked out of the room by @" + b.username)
- }
- }), Dubtrack.View.chatUnbannedItem = Dubtrack.View.systemChatItem.extend({
- initialize: function() {
- var a = this.model.get("kickedUser"),
- b = this.model.get("user");
- this.$el.html("@" + a.username + " was unbanned from the room by @" + b.username)
- }
- }), Dubtrack.View.chatUnsetRoleItem = Dubtrack.View.systemChatItem.extend({
- initialize: function() {
- var a = this.model.get("modUser"),
- b = this.model.get("user"),
- c = this.model.get("role_object");
- this.$el.html("@" + a.username + " was removed as a " + c.label + " by @" + b.username)
- }
- }), Dubtrack.View.chatSetRoleItem = Dubtrack.View.systemChatItem.extend({
- initialize: function() {
- var a = this.model.get("modUser"),
- b = this.model.get("user"),
- c = this.model.get("role_object");
- this.$el.html("@" + a.username + " was made a " + c.label + " by @" + b.username)
- }
- }), Dubtrack.View.chatBannedItem = Dubtrack.View.systemChatItem.extend({
- initialize: function() {
- var a = this.model.get("kickedUser"),
- b = this.model.get("user"),
- c = "@" + a.username + " was banned from the room by @" + b.username,
- d = parseInt(this.model.get("time"), 10);
- d && 0 !== d && (c += " for " + d + " minutes"), this.$el.html(c)
- }
- }), Dubtrack.View.removedSongFromQueueItem = Dubtrack.View.systemChatItem.extend({
- initialize: function() {
- var a = this.model.get("removedUser"),
- b = this.model.get("user"),
- c = "@" + b.username + " removed a song queued by @" + a.username;
- this.$el.html(c)
- }
- }), Dubtrack.View.removedFromQueueItem = Dubtrack.View.systemChatItem.extend({
- initialize: function() {
- var a = this.model.get("removedUser"),
- b = this.model.get("user"),
- c = "@" + b.username + " removed @" + a.username + " from the queue";
- this.$el.html(c)
- }
- }), Dubtrack.View.reorderQueueItem = Dubtrack.View.systemChatItem.extend({
- initialize: function() {
- var a = this.model.get("user"),
- b = "@" + a.username + " reordered the queue";
- this.$el.html(b)
- }
- }), Dubtrack.View.lockRoomQueueItem = Dubtrack.View.systemChatItem.extend({
- initialize: function() {
- var a = this.model.get("user"),
- b = this.model.get("room");
- b && b.lockQueue ? message = "@" + a.username + " locked the queue" : message = "@" + a.username + " unlocked the queue", this.$el.html(message)
- }
- }), Dubtrack.View.pauseUserQueueItem = Dubtrack.View.systemChatItem.extend({
- initialize: function() {
- var a = this.model.get("user"),
- b = this.model.get("user_queue");
- b && b.queuePaused ? message = "@" + a.username + " paused their queue" : message = "@" + a.username + " resumed their queue", this.$el.html(message)
- }
- }), Dubtrack.View.welcomeMessageChatItem = Dubtrack.View.systemChatItem.extend({
- attributes: {
- "class": "chat-welcome-message"
- },
- initialize: function() {
- if (Dubtrack.room) {
- var a = Dubtrack.room.model.get("welcomeMessage"),
- b = Dubtrack.room.model.get("name"),
- c = Dubtrack.session.get("username");
- a && a.length > 0 ? (b || (b = ""), c || (c = ""), a = a.replace("{roomname}", b), a = a.replace("{username}", c), this.$el.html(Dubtrack.helpers.text.convertHtmltoTags(a)), emojify.run(this.el)) : this.$el.remove()
- } else this.$el.remove()
- }
- }), Dubtrack.View.comment = Backbone.View.extend({
- tagName: "section",
- attributes: {
- "class": "comments-main"
- },
- events: {
- "click .loadMoreComments": "displayAllComments",
- "click .comments-textarea-container button": "postComment"
- },
- initialize: function() {
- this.$el.html(_.template(Dubtrack.els.templates.comments.commentsContainer)), this.collection = new Dubtrack.Collection.Comments, this.collection.bind("add", this.appendEl, this), this.commentsLoaded = !1, Dubtrack.Events.bind("realtime:comment-add", this.addRealTimeComment, this), Dubtrack.Events.bind("realtime:comment-remove", this.removeRealTimeComment, this)
- },
- render: function(a) {
- this.collection.url = a;
- var b = this;
- return this.collection.fetch({
- success: function() {
- b.commentsLoaded = !0
- },
- error: function() {
- b.commentsLoaded = !0
- }
- }), this
- },
- removeRealTimeComment: function(a) {
- var b = this.collection.findWhere({
- _id: a.comment._id
- });
- b && b.viewEl && b.viewEl.close()
- },
- addRealTimeComment: function(a) {
- var b = new Dubtrack.Model.Comments(a.comment);
- this.collection.add(b)
- },
- appendEl: function(a) {
- var b = new Dubtrack.View.commentItem({
- model: a
- });
- a.viewEl = b, this.commentsLoaded ? this.$(".comments-list").prepend(b.$el) : this.$(".comments-list").append(b.$el)
- },
- postComment: function() {
- var a = b.trim(this.$(".comments-textarea-container textarea").val()),
- c = this;
- if ("" !== a && null !== a) {
- this.$(".comments-textarea-container textarea").val(""), this.$(".comments-textarea-container button").html(dubtrack_lang.global.loading);
- var d = new Dubtrack.Model.Comments({
- comment: a
- });
- return d.url = this.collection.url, d.parse = Dubtrack.helpers.parse, d.save({}, {
- success: function() {
- c.$(".comments-textarea-container button").html("Post a comment"), c.collection.add(d)
- },
- error: function() {
- c.$(".comments-textarea-container button").html("Error creating comment")
- }
- }), !1
- }
- },
- beforeClose: function() {
- _.each(this.collection.models, function(a) {
- a.viewEl && a.viewEl.close()
- })
- }
- }), Dubtrack.View.commentItem = Backbone.View.extend({
- tagName: "section",
- attributes: {
- "class": "comment-item"
- },
- events: {
- "click a.delete": "deleteComment",
- "click span.icon-arrow-up": "dubUp",
- "click span.icon-arrow-down": "dubDown",
- "click a.icon-flag": "flagComment"
- },
- initialize: function() {
- Dubtrack.Events.bind("realtime:comment-update-" + this.model.id, this.updateDubsRealTime, this), Dubtrack.cache.users.get(this.model.get("userid"), this.renderUser, this)
- },
- renderUser: function(a, b) {
- if (a) return void this.close();
- this.user = b;
- var c = this.model.toJSON();
- c.user = this.user.toJSON(), c.date = new Date(c.created), this.$el.html(_.template(Dubtrack.els.templates.comments.commentsItem, c)), this.$(".timeago").timeago()
- },
- updateDubsRealTime: function(a) {
- a && a.comment && this.$("span.comment-dubs-total").html(a.comment.updubs - a.comment.downdubs)
- },
- deleteComment: function() {
- return this.model.destroy(), this.close(), !1
- },
- beforeClose: function() {
- this.$("time.timeago").timeago("dispose")
- },
- dubDown: function() {
- if (this.$("span.icon-arrow-down").hasClass("dubvoted")) return !1;
- var a = Dubtrack.config.apiUrl + Dubtrack.config.urls.commentsDubs.replace(":id", this.model.id),
- b = this;
- return this.$(".dubvoted").removeClass("dubvoted"), this.$("span.icon-arrow-down").addClass("dubvoted"), Dubtrack.helpers.sendRequest(a, {
- type: "downdub"
- }, "post", function(a, c) {
- c && c.data && c.data.comment && b.$("span.comment-dubs-total").html(c.data.comment.updubs - c.data.comment.downdubs)
- }, this), !1
- },
- dubUp: function() {
- if (this.$("span.icon-arrow-up").hasClass("dubvoted")) return !1;
- var a = Dubtrack.config.apiUrl + Dubtrack.config.urls.commentsDubs.replace(":id", this.model.id),
- b = this;
- return this.$(".dubvoted").removeClass("dubvoted"), this.$("span.icon-arrow-up").addClass("dubvoted"), Dubtrack.helpers.sendRequest(a, {
- type: "updub"
- }, "post", function(a, c) {
- c && c.data && c.data.comment && b.$("span.comment-dubs-total").html(c.data.comment.updubs - c.data.comment.downdubs)
- }, this), !1
- },
- flagComment: function() {
- var a = Dubtrack.config.apiUrl + Dubtrack.config.urls.commentsFlag.replace(":id", this.model.id),
- b = this;
- return Dubtrack.helpers.sendRequest(a, {}, "post", function(a, c) {
- b.$("a.icon-flag").html(" thank you!")
- }, this), !1
- }
- }), scDubsPlayerView = Backbone.View.extend({
- tagName: "div",
- className: "player soundcloud",
- events: {
- "click .pause": "pause",
- "click .play": "play",
- "click .progressContainer": "setPosition",
- "click .replay": "replay",
- "click canvas": "play"
- },
- initialize: function() {},
- render: function(a, c, e, f, g, h) {
- var i = b(this.el);
- Dubtrack.els.controls(i, this), this.playerWidth = g ? g : Dubtrack.config.player.playerEmbedWidth, this.playerHeight = h ? h : Dubtrack.config.player.playerEmbedHeight, this.canvasContEl = b("<div/>", {
- id: this.id
- }).html('<img src="' + Dubtrack.config.urls.mediaBaseUrl + '/assets/images/media/dubtrack-player.png" alt="" />').addClass("playerImage SCplayerImage").appendTo(this.$el), this.buildVolume(), this.scPlayer && this.scPlayer.destruct(), this.replayEl.hide(), "soundcloud" == e && (a += -1 == a.indexOf("secret_token") ? "?" : "&", a = a + "consumer_key=" + Dubtrack.config.keys.soundcloud);
- var j = this;
- return this.playEl.css("display", "block"), Dubtrack.playerController && (this.main_player_volume = Dubtrack.playerController.volume), soundManager.setup({
- url: "/assets/swf/",
- flashVersion: 9,
- onready: function() {
- j.loadingEl.hide(), j.playEl.css("display", "block"), j.scPlayer = soundManager.createSound({
- id: c,
- url: a,
- autoLoad: !0,
- autoPlay: !1,
- stream: !0,
- onerror: function() {
- j.errorEl.show()
- },
- whileplaying: function() {
- j.progressEl.css({
- width: parseInt(this.position * parseInt(j.progressOuterEl.outerWidth(), 10) / this.duration, 10)
- })
- },
- onfinish: function() {
- j.pauseEl.hide(), j.playEl.css("display", "block"), j.replayEl.show(), Dubtrack.room.player && Dubtrack.room.player.setVolumeRemote(Dubtrack.playerController.volume)
- },
- onbufferchange: function() {
- d() || (this.isBuffering ? j.bufferingEl.show() : j.bufferingEl.hide())
- }
- })
- }
- }), f && j.play(), this
- },
- replay: function() {
- this.setPosition(0), this.play()
- },
- play: function() {
- if (this.scPlayer) try {
- Dubtrack.room.player && Dubtrack.room.player.setVolumeRemote(0, !0), this.playEl.hide(), this.pauseEl.css("display", "block"), this.scPlayer.play(), this.replayEl.hide()
- } catch (a) {}
- return !1
- },
- pause: function() {
- if (this.scPlayer) try {
- Dubtrack.room.player ? Dubtrack.room.player.setVolumeRemote(Dubtrack.playerController.volume) : Dubtrack.room.player.setVolumeRemote(self.main_player_volume), this.pauseEl.hide(), this.playEl.css("display", "block"), this.scPlayer.pause()
- } catch (a) {}
- return !1
- },
- setPosition: function(a) {
- this.scPlayer && (this.scPlayer.stop(), this.scPlayer.setPosition(parseInt(a.offsetX / this.progressOuterEl.outerWidth() * this.scPlayer.duration)), this.playEl.hide(), this.pauseEl.css("display", "block"), this.scPlayer.play())
- },
- setVolume: function(a) {
- this.scPlayer && this.scPlayer.setVolume(parseInt(a))
- },
- buildVolume: function() {
- var a = this.volumeContainer.find(".volume-control"),
- b = this.volumeContainer.find(".tooltip"),
- c = this;
- b.hide(), a.slider({
- range: "min",
- min: 1,
- value: 100,
- start: function(a, c) {
- b.fadeIn("fast")
- },
- slide: function(d, e) {
- var f = a.slider("value"),
- g = c.volumeContainer.find(".volume");
- b.css("left", f).text(e.value), 5 >= f ? g.css("background-position", "0 0") : 25 >= f ? g.css("background-position", "0 -25px") : 75 >= f ? g.css("background-position", "0 -50px") : g.css("background-position", "0 -75px"), c.setVolume(f)
- },
- stop: function(a, c) {
- b.fadeOut("fast")
- }
- })
- },
- setVolume: function(a) {
- this.scPlayer && (this.scPlayer.unmute(), this.scPlayer.setVolume(parseInt(a)))
- },
- beforeClose: function() {
- Dubtrack.room.player && Dubtrack.room.player.setVolumeRemote(Dubtrack.playerController.volume), this.scPlayer && (this.scPlayer.destruct(), this.scPlayer.stop()), this.remove(), this.unbind()
- }
- });
- var i = Backbone.View.extend({
- tagName: "div",
- className: "player youtube",
- events: {
- "click .pause": "pause",
- "click .play": "play",
- "click .progressContainer": "setPlayer",
- "click .replay": "replay"
- },
- initialize: function() {},
- render: function(a, c, d, e, f) {
- var g = b(this.el);
- Dubtrack.els.controls(g, this), this.id = c, this.playerEl = b("<div/>", {
- id: c
- }).appendTo(g), this.videoId = a, this.replayEl.hide(), this.mainYTimg = b("<div/>", {
- "class": "playerImage"
- }).html('<img src="http://img.youtube.com/vi/' + a + '/0.jpg" alt="">').appendTo(g);
- var h = this;
- return this.mainYTimg.on("click", function() {
- h.play()
- }), this.buildVolume(), this.playerWidth = e ? e : Dubtrack.config.player.playerEmbedWidth, this.playerHeight = f ? f : Dubtrack.config.player.playerEmbedHeight, Dubtrack.playerController && (this.main_player_volume = Dubtrack.playerController.volume), this
- },
- buildPlayer: function(a) {
- var b = this;
- this.intervalUpdate = null, this.player = new YT.Player(this.id, {
- width: b.playerWidth,
- height: b.playerHeight,
- videoId: b.videoId,
- playerVars: Dubtrack.config.player.youtube.playerParams,
- events: {
- onReady: function() {
- b.loadingEl.hide(), b.intervalLoaded && clearTimeout(b.intervalLoaded), b.updateytplayerloaded(), b.pause(), a && b.play()
- },
- onStateChange: function(a) {
- switch (a.data) {
- case -1:
- break;
- case 0:
- b.mainYTimg.show(), b.replayEl.show(), Dubtrack.room.player && Dubtrack.room.player.setVolumeRemote(Dubtrack.playerController.volume);
- break;
- case 1:
- b.play();
- break;
- case 2:
- b.pause(), b.bufferingEl.hide();
- break;
- case 3:
- b.bufferingEl.show()
- }
- },
- onError: function(a) {
- b.errorEl.html("ERROR: " + a.data), b.errorEl.show()
- }
- }
- })
- },
- onPlayerStateChange: function(a) {},
- replay: function() {
- this.player && (this.mainYTimg.hide(), this.setPlayer(0))
- },
- play: function() {
- if (this.player) try {
- Dubtrack.room.player && Dubtrack.room.player.setVolumeRemote(0, !0), this.mainYTimg.hide(), this.bufferingEl.hide(), this.replayEl.hide(), this.playEl.hide(), this.pauseEl.show(), this.player.playVideo(), this.updateytplayerInfo(), this.intervalLoaded || this.updateytplayerloaded()
- } catch (a) {}
- return !1
- },
- pause: function() {
- if (this.player) try {
- Dubtrack.room.player ? Dubtrack.room.player.setVolumeRemote(Dubtrack.playerController.volume) : Dubtrack.room.player.setVolumeRemote(self.main_player_volume), this.pauseEl.hide(), this.playEl.show(), this.player.pauseVideo(), clearInterval(this.intervalUpdate)
- } catch (a) {}
- return !1
- },
- updateytplayerloaded: function() {
- if (this.player) {
- var a = this;
- this.intervalLoaded = setInterval(function() {
- a.loadedEl.css({
- width: parseInt(100 * a.player.getVideoLoadedFraction(), 10) + "%"
- }), a.player.getVideoLoadedFraction() >= 1 && (clearInterval(a.intervalLoaded), delete a.intervalLoaded)
- }, 1e3)
- }
- },
- updateytplayerInfo: function() {
- if (this.player) {
- var a = this;
- this.intervalUpdate = setInterval(function() {
- a.progressEl.css({
- width: parseInt(a.player.getCurrentTime() * parseInt(a.progressOuterEl.outerWidth(), 10) / a.player.getDuration(), 10)
- })
- }, 1e3)
- }
- },
- setPlayer: function(a) {
- this.play(), this.player.seekTo(a.offsetX / this.progressOuterEl.outerWidth() * this.player.getDuration(), !0)
- },
- buildVolume: function() {
- var a = this.volumeContainer.find(".volume-control"),
- b = this.volumeContainer.find(".tooltip"),
- c = this;
- b.hide(), a.slider({
- range: "min",
- min: 1,
- value: 100,
- start: function(a, c) {
- b.fadeIn("fast")
- },
- slide: function(d, e) {
- var f = a.slider("value"),
- g = c.volumeContainer.find(".volume");
- b.css("left", f).text(e.value), 5 >= f ? g.css("background-position", "0 0") : 25 >= f ? g.css("background-position", "0 -25px") : 75 >= f ? g.css("background-position", "0 -50px") : g.css("background-position", "0 -75px"), c.setVolume(f)
- },
- stop: function(a, c) {
- b.fadeOut("fast")
- }
- })
- },
- setVolume: function(a) {
- this.player && (this.player.unMute(), this.player.setVolume(a))
- },
- beforeClose: function() {
- if (Dubtrack.room.player && Dubtrack.room.player.setVolumeRemote(Dubtrack.playerController.volume), this.player) {
- try {
- this.player.stop(), this.player.destroy()
- } catch (a) {}
- clearInterval(this.intervalUpdate)
- }
- }
- });
- DubsView = Backbone.View.extend({
- tagName: "div",
- events: {
- "click a.dubs-link": "filter",
- "keyup input#dub_text": "search"
- },
- initialize: function() {
- this.dubsItemEl = new Array, b(this.el).html(tpl.get("dubsContainer")), this.model.bind("add", this.appendEl, this), this.model.bind("reset", this.render, this), this.dubsListEl = b(this.el).find("ul#top-dubs"), b(this.el).addClass("avatar_bg"), this.type = "day", this.render()
- },
- render: function() {
- return this.dubsListEl.html(""), _.each(this.model.models, function(a) {
- this.appendEl(a)
- }, this), this
- },
- runPlugins: function() {
- 1 === this.model.models.length && ($view = this.dubsItemEl[0], $view && $view.loadComments())
- },
- filter: function(a) {
- a.preventDefault();
- b(this.el).find(" a.active ").removeClass("active");
- var c = b(a.target).data();
- b(a.target).addClass("active");
- var d = c.type;
- g.elements.displayloading(dubtrack_lang.dubs.loading), this.dubsListEl.html(""), this.type = d;
- a.target.value;
- return g.app.dubsListCollection.url = g.config.dubsUrl + "/date/" + d, g.app.dubsListCollection.fetch({
- success: function() {
- g.app.navigate("/dubs/" + d), g.elements.mainLoading.hide()
- }
- }), !1
- },
- search: function(a) {
- var d = this;
- if (c = a.which ? a.which : a.keyCode, 13 == c || !b(a.target).hasValue()) {
- g.elements.displayloading(dubtrack_lang.dubs.loading), d.dubsListEl.html("");
- var e = a.target.value;
- b(a.target).hasValue() ? g.app.dubsListCollection.url = g.config.searchDubsUrl + "/dub_text/" + escape(e.replace(/[^a-zA-Z 0-9]+/g, "")) : g.app.dubsListCollection.url = g.config.dubsUrl + "/date/" + this.type, g.app.dubsListCollection.fetch({
- data: {
- dub_text: e
- },
- success: function() {
- g.elements.mainLoading.hide()
- }
- })
- }
- },
- buidPlayers: function() {
- _.each(this.dubsItemEl, function(a) {
- a.buidPlayers()
- })
- },
- stopPlayers: function() {
- _.each(this.dubsItemEl, function(a) {
- a.stopPlayer()
- })
- },
- appendEl: function(a) {
- var c = new DubsItemView({
- model: a
- });
- b(c.render().el).appendTo(this.dubsListEl), this.dubsItemEl.push(c)
- }
- }), DubsItemView = Backbone.View.extend({
- tagName: "li",
- events: {
- "click div.img": "loadComments",
- "click div.content": "loadComments",
- "click div.buttons": "loadComments"
- },
- initialize: function() {},
- render: function() {
- return this.$el.addClass("dub_cont"), b(_.template(tpl.get("dubsItem"), this.model.toJSON())).appendTo(this.$el), this.commentsAjax = this.$el.find(".ajax"), this
- },
- buildPlayer: function() {
- switch (this.PlayerContainer = this.$el.find("div.playerDubContainer"), this.model.get("type")) {
- case "youtube":
- this.id = this.model.get("url") + "_" + this.model.get("type"), this.buildYT();
- break;
- case "soundcloud":
- case "dubtrack":
- this.id = this.model.get("url_play") + "_" + this.model.get("type"), this.buildSoundCloud()
- }
- },
- loadComments: function() {
- this.commentsAjax.html('<div class="loadingComments">' + dubtrack_lang.dubs.loadingDetails + "...</div>"), this.commentsCollection = new CommentsCollection, this.commentsCollection.url = "/api/dubs/viewallcomments/format/json/id/" + this.model.get("url") + "/type/" + this.model.get("type");
- var a = {
- type: this.model.get("type"),
- url: this.model.get("url"),
- comment: ""
- },
- b = this;
- return this.commentsCollection.fetch({
- success: function() {
- b.commentsAjax.html(""), b.commentsView = new CommentsView({
- model: b.commentsCollection
- }), b.commentsAjax.append(b.commentsView.render(g.config.saveDubComment, a).el)
- }
- }), g.app.dubsView && g.app.dubsView.stopPlayers(), this.player || (this.buildPlayer(), this.buidPlayers()), !1
- },
- stopPlayer: function() {
- this.player && this.player.pause()
- },
- buidPlayers: function() {
- "youtube" == this.model.get("type") && this.player.buildPlayer()
- },
- buildYT: function() {
- this.player = new i, this.PlayerContainer.append(this.player.render(this.model.get("url"), this.id + "_video").el)
- },
- buildSoundCloud: function() {
- this.player = new scDubsPlayerView, this.PlayerContainer.append(this.player.render(this.model.get("url_play"), this.id + "_audio", this.model.get("type")).el)
- },
- beforeClose: function() {
- this.player.close()
- }
- }), f.help.mainView = Backbone.View.extend({
- tagName: "div",
- currentStep: 0,
- events: {
- "click .btn-tour": "takeTour",
- "click .btn-close": "closeHelp",
- "click .close": "closeHelp"
- },
- initialize: function() {},
- render: function() {
- return this.modalEl = this.$el.html(tpl.get("helpModal")).show().appendTo("body"), this.screenEl = b("<div/>", {
- "class": "help-modal"
- }).appendTo("body"), this
- },
- step: function() {
- if (b("body,html").scrollTop(0), f.help.global.interval && clearInterval(f.help.global.interval), this.toolTipView && (f.help.messages[this.currentStep].closeCall && f.help.messages[this.currentStep].closeCall.call(), this.toolTipView.close()), this.currentStep++, f.help.messages[this.currentStep]) {
- var a = new f.help.toolTipItemModel(f.help.messages[this.currentStep]);
- this.toolTipView = new f.help.toolTipItem({
- model: a
- }).render(), f.help.messages[this.currentStep].callback && f.help.messages[this.currentStep].callback.call()
- } else this.currentStep = 0, this.modalEl.show()
- },
- takeTour: function() {
- return this.modalEl.hide(), this.step(), !1
- },
- closeHelp: function() {
- return this.close(), !1
- },
- displayStep: function(a) {
- this.toolTipView && (f.help.messages[this.currentStep].closeCall && f.help.messages[this.currentStep].closeCall.call(), this.toolTipView.close()), this.currentStep = a - 1, this.step()
- },
- beforeClose: function() {
- this.toolTipView && (f.help.messages[this.currentStep].closeCall && f.help.messages[this.currentStep].closeCall.call(), this.toolTipView.close()), this.screenEl.remove()
- }
- }), Dubtrack.View.helpModalMod = Backbone.View.extend({
- events: {
- "click .btn-close": "closeHelp",
- "click .close": "closeHelp"
- },
- initialize: function() {
- this.modalEl = this.$el.html(Dubtrack.els.templates.help.chat).show().appendTo("body"), this.screenEl = b("<div/>", {
- "class": "help-modal"
- }).appendTo("body")
- },
- closeHelp: function() {
- return this.close(), !1
- },
- beforeClose: function() {
- this.screenEl.remove()
- }
- }), f.help.toolTipItem = Backbone.View.extend({
- tagName: "div",
- events: {
- "click button.btn-next": "next",
- "click button.btn-finish": "closeHelp",
- "click button.btn-close": "closeObject"
- },
- initialize: function() {
- this.$el.addClass("popover fade top in")
- },
- render: function() {
- return this.$el.html(_.template(tpl.get("tooltip"), this.model.toJSON())).addClass(this.model.get("styles")).show().appendTo("body"), this
- },
- closeObject: function() {
- return this.close(), !1
- },
- closeHelp: function() {
- f.help.helpViewRoute && f.help.helpViewRoute.close()
- },
- next: function() {
- f.help.helpViewRoute && f.help.helpViewRoute.step()
- }
- }), f.help.global = {
- next: '<button class="btn btn-small btn-primary btn-next">' + dubtrack_lang.help.next + "</button>",
- finish: '<button class="btn btn-small btn-finish">' + dubtrack_lang.help.finish + "</button>",
- interval: !1
- }, f.help.messages = {
- 1: {
- styles: "help cornerRight",
- title: dubtrack_lang.help.how_to_play,
- content: dubtrack_lang.help.how_to_play_des + f.help.global.next,
- callback: function() {
- b("#playerController").addClass("help")
- },
- closeCall: function() {
- b("#playerController").removeClass("help")
- }
- },
- 2: {
- styles: "help bottom cornerRight step2",
- title: dubtrack_lang.help.select_source,
- content: dubtrack_lang.help.select_source_des + f.help.global.next,
- callback: function() {
- g.app.navigate("/browser", {
- trigger: !0
- }), b("#browser").addClass("help")
- },
- closeCall: function() {
- b("#browser").removeClass("help")
- }
- },
- 3: {
- styles: "help bottom cornerRight step3",
- title: dubtrack_lang.help.search,
- content: dubtrack_lang.help.search_des + f.help.global.next,
- callback: function() {
- g.app.navigate("/browser", {
- trigger: !0
- }), b("#browser").addClass("help");
- var a = "dubtrack.fm",
- c = 0;
- f.help.global.interval = setInterval(function() {
- b("#youtube-search").val(b("#youtube-search").val() + a[c]), c++, c >= a.length && (clearInterval(f.help.global.interval), b("#youtube-search").focus())
- }, 300)
- },
- closeCall: function() {
- b("#browser").removeClass("help")
- }
- },
- 4: {
- styles: "help bottom step4",
- title: dubtrack_lang.help.add,
- content: dubtrack_lang.help.add_des + f.help.global.next,
- callback: function() {
- g.app.mainBrowserView && (g.app.mainBrowserView.setYoutube(), b("#youtube-search").val("dubtrack.fm"), g.app.mainBrowserView.search()), g.app.navigate("/browser", {
- trigger: !0
- }), b("#browser").addClass("help")
- },
- closeCall: function() {
- b("#browser").removeClass("help"), g.app.mainBrowserView.close()
- }
- },
- 5: {
- styles: "help cornerRight step5",
- title: dubtrack_lang.help.queue,
- content: dubtrack_lang.help.queue_des + f.help.global.next,
- callback: function() {
- g.app.navigate("/", {
- trigger: !0
- }), b("#playerController").addClass("help"), b("b.queueInfo").show().html("#")
- },
- closeCall: function() {
- b("b.queueInfo").hide(), b("#playerController").removeClass("help")
- }
- },
- 6: {
- styles: "help cornerRight step6",
- title: dubtrack_lang.help.favorites,
- content: dubtrack_lang.help.favorites_des + f.help.global.next,
- callback: function() {
- b("#playerController").addClass("help")
- },
- closeCall: function() {
- b("#playerController").removeClass("help")
- }
- },
- 7: {
- styles: "help step7",
- title: dubtrack_lang.help.upvote,
- content: dubtrack_lang.help.upvote_des + f.help.global.next,
- callback: function() {
- b("#playerController").addClass("help")
- },
- closeCall: function() {
- b("#playerController").removeClass("help")
- }
- },
- 8: {
- styles: "help bottom cornerRight step8",
- title: dubtrack_lang.help.lobby,
- content: dubtrack_lang.help.lobby_des + f.help.global.next,
- callback: function() {
- b("#header_global").addClass("help")
- },
- closeCall: function() {
- b("#header_global").removeClass("help")
- }
- },
- 9: {
- styles: "help bottom step9",
- title: dubtrack_lang.help.top_dubs,
- content: dubtrack_lang.help.top_dubs_des + f.help.global.next,
- callback: function() {
- b("#header_global").addClass("help")
- },
- closeCall: function() {
- b("#header_global").removeClass("help")
- }
- },
- 10: {
- styles: "help bottom step10",
- title: dubtrack_lang.help.profile,
- content: dubtrack_lang.help.profile_des + f.help.global.next,
- callback: function() {
- b("#header_global").addClass("help")
- },
- closeCall: function() {
- b("#header_global").removeClass("help")
- }
- },
- 11: {
- styles: "help bottom cornerLeft step11",
- title: dubtrack_lang.help.notifications,
- content: dubtrack_lang.help.notifications_des + f.help.global.next,
- callback: function() {
- b("#header_global").addClass("help")
- },
- closeCall: function() {
- b("#header_global").removeClass("help")
- }
- },
- 12: {
- styles: "help bottom cornerLeft step12",
- title: dubtrack_lang.help.friends,
- content: dubtrack_lang.help.friends_des + f.help.global.next,
- callback: function() {
- b("#header_global").addClass("help")
- },
- closeCall: function() {
- b("#header_global").removeClass("help")
- }
- },
- 13: {
- styles: "help bottom step13",
- title: dubtrack_lang.help.share,
- content: dubtrack_lang.help.share_des + f.help.global.finish,
- callback: function() {
- b("#header_global").addClass("help")
- },
- closeCall: function() {
- b("#header_global").removeClass("help")
- }
- }
- }, NoticiationView = Backbone.View.extend({
- tagName: "div",
- events: {
- "click a.loadMore": "loadMore"
- },
- initialize: function() {
- this.$el.html(tpl.get("notificationCont")), this.model.bind("add", this.addItem, this), this.model.bind("reset", this.render, this), this.loadMoreEl = this.$el.find("a.loadMore"), this.notificationEl = this.$el.find("ul#notifications_list"), this.$el.addClass("avatar_cont")
- },
- render: function() {
- return this.ytplayers = new Array, _.each(this.model.models, function(a) {
- this.addItem(a)
- }, this), this
- },
- addItem: function(a) {
- switch (a.get("type")) {
- case "dj_update":
- break;
- case "dub_comment":
- this.buildComment(a.toJSON());
- break;
- case "wall_comment":
- this.wallPost(a.toJSON());
- break;
- case "wall_post":
- this.wallPost(a.toJSON());
- break;
- case "following_post":
- g.user.loggedIn && (a.attributes.userid == g.user.id || a.attributes.id_rel == g.user.id) && this.buildFollowing(a.toJSON())
- }
- this.notificationEl.find(".timeago").timeago()
- },
- wallPost: function(a) {
- var c = b("<li/>", {
- id: "li" + a.id_rel
- }).appendTo(this.notificationEl),
- d = new WallpostModel({
- id: a.id_rel
- });
- d.fetch({
- success: function(a) {
- if ("" != d.get("message")) {
- b(new WallpostItemView({
- model: d
- }).render().el).appendTo(c)
- }
- }
- })
- },
- buildFollowing: function(a) {
- var c = b("<li/>", {
- id: "li" + a.id_rel
- }).appendTo(this.notificationEl);
- a.img = g.helpers.getProfileImg(a.oauth_uid, a.username, a.oauth_provider), a.img_rel = g.helpers.getProfileImg(a.user_rel_info.oauth_uid, a.user_rel_info.username, a.user_rel_info.oauth_provider);
- var d = "notificationFollowing";
- a.id_rel == g.user.id && (d = "notificationFollowing");
- b(_.template(tpl.get(d), a)).appendTo(c)
- },
- loadMore: function() {
- this.loadMoreEl.html(dubtrack_lang.global.loading);
- var a = this;
- return this.model.fetchPage(function() {
- a.loadMoreEl.html(dubtrack_lang.notification.loadMore)
- }), !1
- },
- buildComment: function(a) {
- for (var c = a.url.split("/"), d = "", e = "", f = 0; f < c.length; ++f) "type" == c[f] && (d = c[f + 1]), "id" == c[f] && (e = c[f + 1]), ++f;
- var h = e;
- if ("youtube" == d) {
- if (_.contains(this.ytplayers, e)) return;
- this.ytplayers.push(e)
- } else h = a.song_details.url_play;
- a.img = g.helpers.getProfileImg(a.oauth_uid, a.username, a.oauth_provider);
- var i = b(_.template(tpl.get("notificationComment"), a)).appendTo(this.notificationEl),
- j = i.find(".notificationsPlayer");
- this.buildPlayer(j, h, d, e), this.player && this.buidPlayers(d);
- i.find(".notificationsPlayer");
- this.commentsView && this.commentsView.close();
- var k = new CommentsCollection;
- k.url = "/api/dubs/viewallcomments/format/json/id/" + e + "/type/" + d;
- var l = {
- type: d,
- url: e,
- comment: ""
- };
- k.fetch({
- success: function() {
- var a = new CommentsView({
- model: k
- }),
- c = b(a.render(g.config.saveDubComment, l).el).appendTo(i.find("div.comments_main"));
- c.css("minHeight", 0)
- }
- })
- },
- buildPlayer: function(a, b, c, d) {
- var e = "";
- switch (c) {
- case "youtube":
- e = "notification_" + b + "_" + c, this.buildYT(a, e, b);
- break;
- case "soundcloud":
- case "dubtrack":
- e = "notification_" + d + "_" + c, this.buildSoundCloud(a, e, b, c)
- }
- },
- buildYT: function(a, b, c) {
- this.player = new i, a.append(this.player.render(c, b, 500, 300).el)
- },
- buildSoundCloud: function(a, b, c, d) {
- this.player = new scDubsPlayerView, a.append(this.player.render(c, b, d, 500, 300).el)
- },
- stopPlayer: function() {
- this.player && this.player.pause()
- },
- buidPlayers: function(a) {
- "youtube" == a && this.player.buildPlayer()
- },
- beforeClose: function() {
- this.player.close()
- }
- }), Dubtrack.View.roomUsers = Backbone.View.extend({
- el: b("#avatar"),
- allowed_dj: 0,
- intervalId: !1,
- roomId: !1,
- events: {
- "click a.loadRoomAva": "loadRoomAva",
- "click a.modLink": "loadModsAva",
- "keyup .input-room-users-search input": "filterRoomUsers"
- },
- initialize: function() {
- var a = this;
- this.$el.html(_.template(Dubtrack.els.templates.rooms.avatarsContainer, {})), Dubtrack.Events.bind("realtime:user-join", this.userJoin, this), Dubtrack.Events.bind("realtime:user-leave", this.userLeave, this), Dubtrack.Events.bind("realtime:user-setrole", this.setRole, this), Dubtrack.Events.bind("realtime:user-unsetrole", this.unsetRole, this), Dubtrack.Events.bind("realtime:room_playlist-dub", this.realTimeDub, this), Dubtrack.Events.bind("realtime:user-mute", this.setMuted, this), Dubtrack.Events.bind("realtime:user-unmute", this.setunMuted, this), Dubtrack.Events.bind("realtime:room-lock-queue", this.removeAllDJs, this), Dubtrack.Events.bind("realtime:user-setrole", this.receiveMessage, this), Dubtrack.Events.bind("realtime:user-unsetrole", this.receiveMessage, this), Dubtrack.Events.bind("realtime:user-pause-queue", this.updateUserQueue, this), Dubtrack.Events.bind("realtime:user-pause-queue", this.updateUserQueue, this), Dubtrack.Events.bind("realtime:user-pause-queue", this.updateUserQueue, this), Dubtrack.Events.bind("realtime:pubnub-presence", this.setTotalUsers, this);
- var b = Dubtrack.config.urls.roomUsers.replace("{id}", this.model.id);
- this.collection = new Dubtrack.Collection.RoomUser, this.collection.url = Dubtrack.config.apiUrl + b, this.collection.comparator = function(a) {
- return -parseInt(a.get("dubs"), 10)
- }, this.collection.bind("add", this.addUser, this), this.collection.bind("remove", this.removeEl, this), this.collection.bind("change", this.updateDubs, this), this.intervalId = setInterval(function() {
- a.autoLoad()
- }, 72e4), this.autoLoad(), this.uuids = [], this.rt_users = [], this.avatarContainer = this.$el.find("ul#avatar-list"), this.currentTabEl = this.$el.find(".currentBar"), this.avatarFriendsEl = this.$el.find(".friendsElAvatar"), this.tabsContainerEl = this.$el.find(".tabsContainer"), this.avatarModsEl = this.$el.find(".modsElAvatar"), this.loadingEl = this.$el.find(".loadingAva"), this.setTotalUsersDebouce = _.debounce(this.setTotalUsers.bind(this), 2e3), this.$("#main-user-list-room").perfectScrollbar({
- wheelSpeed: 30,
- suppressScrollX: !0,
- wheelPropagation: !1
- })
- },
- setTotalUsers: function() {
- Dubtrack.realtime.channelPresence(function(a) {
- a && a.uuids && (this.uuids = a.uuids), this.rt_users = [];
- var b = !1;
- if (_.each(this.uuids, function(a) {
- a.match(/^[0-9a-fA-F]{24}$/) && (this.rt_users.push(a), Dubtrack.loggedIn && Dubtrack.session && Dubtrack.session.id == a && (b = !0))
- }.bind(this)), Dubtrack.loggedIn && Dubtrack.session && !b && this.rt_users.push(Dubtrack.session.id), Dubtrack.room && Dubtrack.room.chat) {
- Dubtrack.room.chat.setUserCount(this.rt_users.length);
- var c = this.uuids.length - this.rt_users.length;
- Dubtrack.room.chat.setGuestCount(c >= 0 ? c : 0)
- }
- })
- },
- filterRoomUsers: function() {
- var a = b.trim(this.$(".input-room-users-search input").val());
- return "" === a || null === a ? void this.$("#avatar-list li").show() : (this.avatarContainer.find("li").hide(), void b.each(this.$("#avatar-list li:regex(class, .*user-" + a.toLowerCase() + ".*)"), function() {
- b(this).show()
- }))
- },
- updateDubs: function(a) {
- a && a.viewEl && a.viewEl.$(".dubs span").html(a.get("dubs"))
- },
- resetEl: function() {
- this.collection.sort(), this.avatarContainer.empty(), this.setTotalUsersDebouce.call(this), _.each(this.collection.models, function(a) {
- this.appendEl(a)
- }, this), this.$("#main-user-list-room").perfectScrollbar("update")
- },
- userJoin: function(a) {
- if (a && a.user) {
- var b = new Dubtrack.Model.RoomUser(a.roomUser);
- b.set("user", a.user), b.set("_user", a.user), this.collection.add(b)
- }
- },
- userLeave: function(a) {
- var b = this.collection.findWhere({
- userid: a.user._id
- });
- b && this.collection.remove(b)
- },
- addUser: function(a) {
- this.appendEl(a)
- },
- appendEl: function(a) {
- a.viewEl = new Dubtrack.View.roomUsersItem({
- model: a
- }).render(), this.avatarContainer.append(a.viewEl.$el), this.setTotalUsersDebouce.call(this), this.$("#main-user-list-room").perfectScrollbar("update"), Dubtrack.loggedIn && a.get("userid") == Dubtrack.session.id && this.timeoutErrorUserLeave && clearTimeout(this.timeoutErrorUserLeave)
- },
- displayActiveUsers: function() {
- this.avatarContainer.find("li").hide(), Dubtrack.realtime.channelPresence(function(a) {
- a && a.uuids && (this.uuids = a.uuids), this.rt_users = [], _.each(this.uuids, function(a) {
- a.match(/^[0-9a-fA-F]{24}$/) && (this.rt_users.push(a), this.avatarContainer.find("li.userid-" + a).show())
- }.bind(this))
- }.bind(this))
- },
- appendFeatureItem: function(a) {},
- removeEl: function(a) {
- a.viewEl.close();
- Dubtrack.helpers.cookie.get("dubtrack-room-id");
- Dubtrack.loggedIn && a.get("userid") == Dubtrack.session.id && this.collection.fetch({
- update: !0,
- success: function() {
- var a = this.collection.findWhere({
- userid: Dubtrack.session.id
- });
- a || (this.timeoutErrorUserLeave = setTimeout(function() {
- Dubtrack.helpers.displayError("Warning", "You were removed from this room, simply refresh this page to rejoin :)<br><br>Opening multiple tabs of this site can trigger this error, email us if you have any questions at support@dubtrack.fm", !0)
- }, 5e3))
- }.bind(this)
- }), this.setTotalUsersDebouce.call(this), this.$("#main-user-list-room").perfectScrollbar("update")
- },
- fetchDubs: function() {
- var a = Dubtrack.config.apiUrl + Dubtrack.config.urls.dubsPlaylistActive.replace(":id", this.model.id).replace(":playlistid", "active");
- Dubtrack.helpers.sendRequest(a, {}, "get", function(a, b) {
- a || (_.each(b.data.downDubs, function(a) {
- Dubtrack.room.users.setDubUser(a.userid, a.type)
- }), _.each(b.data.upDubs, function(a) {
- Dubtrack.room.users.setDubUser(a.userid, a.type)
- }))
- }, this)
- },
- loadRoomAva: function() {
- return Dubtrack.room && Dubtrack.room.$el && Dubtrack.room.$el.removeClass("display-users-rooms"), !1
- },
- realTimeDub: function(a) {
- var b = a.user && "_id" in a.user ? a.user._id : !1;
- b && this.setDubUser(b, a.dubtype)
- },
- setDubUser: function(a, b) {
- var c = this.collection.findWhere({
- userid: a
- });
- c && c.viewEl.$el.removeClass("downdub").removeClass("updub").addClass(b)
- },
- removeCurrentDJ: function() {
- this.$("li.currentDJ").removeClass("currentDJ")
- },
- removeDubs: function() {
- this.$("li.updub").removeClass("updub"), this.$("li.downdub").removeClass("downdub")
- },
- setCurrentDJ: function(a) {
- var b = this.collection.findWhere({
- userid: a
- });
- b && b.viewEl && b.viewEl.$el && b.viewEl.$el.addClass("currentDJ")
- },
- updateUserQueue: function(a) {
- var b = a.user_queue && "userid" in a.user_queue ? a.user_queue.userid : !1;
- if (b) {
- var c = this.collection.findWhere({
- userid: b
- });
- c && c.set("queuePaused", a.user_queue.queuePaused)
- }
- },
- removeAllDJs: function() {
- this.$("li.dj").removeClass("dj")
- },
- setRole: function(a) {
- var b = a.modUser && "_id" in a.modUser ? a.modUser._id : !1;
- if (b) {
- var c = this.collection.findWhere({
- userid: b
- });
- c && c.viewEl && c.viewEl.$el && (c.set("roleid", a.role_object), c.viewEl.$el.removeClass("mod co-owner manager vip resident-dj"), c.viewEl.$el.addClass(a.role_object.type))
- }
- },
- unsetRole: function(a) {
- var b = a.modUser && "_id" in a.modUser ? a.modUser._id : !1;
- if (b) {
- var c = this.collection.findWhere({
- userid: b
- });
- c && c.viewEl && c.viewEl.$el && (c.set("roleid", null), c.viewEl.$el.removeClass("mod co-owner manager vip resident-dj"))
- }
- },
- setMuted: function(a) {
- var b = a.mutedUser && "_id" in a.mutedUser ? a.mutedUser._id : !1;
- if (b) {
- var c = this.collection.findWhere({
- userid: b
- });
- c && c.viewEl && c.viewEl.$el && c.set("muted", !0)
- }
- },
- setunMuted: function(a) {
- var b = a.mutedUser && "_id" in a.mutedUser ? a.mutedUser._id : !1;
- if (b) {
- var c = this.collection.findWhere({
- userid: b
- });
- c && c.viewEl && c.viewEl.$el && c.set("muted", !1)
- }
- },
- getIfMod: function(a) {
- var b = this.collection.findWhere({
- userid: a
- });
- if (b) {
- var c = b.get("roleid");
- if (c && "52d1ce33c38a06510c000001" == c._id) return !0
- }
- return !1
- },
- getIfResidentDJ: function(a) {
- var b = this.collection.findWhere({
- userid: a
- });
- if (b) {
- var c = b.get("roleid");
- if (c && "5615feb8e596154fc2000002" == c._id) return !0
- }
- return !1
- },
- getIfDJ: function(a) {
- var b = this.collection.findWhere({
- userid: a
- });
- if (b) {
- var c = b.get("roleid");
- if (c && "564435423f6ba174d2000001" == c._id) return !0
- }
- return !1
- },
- getIfVIP: function(a) {
- var b = this.collection.findWhere({
- userid: a
- });
- if (b) {
- var c = b.get("roleid");
- if (c && "5615fe1ee596154fc2000001" == c._id) return !0
- }
- return !1
- },
- getIfManager: function(a) {
- var b = this.collection.findWhere({
- userid: a
- });
- if (b) {
- var c = b.get("roleid");
- if (c && "5615fd84e596150061000003" == c._id) return !0
- }
- return !1
- },
- getRoleType: function(a) {
- var b = this.collection.findWhere({
- userid: a
- });
- if (b) {
- var c = b.get("roleid");
- if (c) return c.type
- }
- return ""
- },
- getIfOwner: function(a) {
- var b = this.collection.findWhere({
- userid: a
- });
- if (b) {
- var c = b.get("roleid");
- if (c && "5615fa9ae596154a5c000000" == c._id) return !0
- }
- return !1
- },
- getIfRoleHasPermission: function(a, b) {
- var c = this.collection.findWhere({
- userid: a
- });
- if (c) {
- var d = c.get("roleid");
- if (d && d.rights && _.contains(d.rights, b)) return !0
- }
- return !1
- },
- getIfHasRole: function(a) {
- var b = this.collection.findWhere({
- userid: a
- });
- if (b) {
- var c = b.get("roleid");
- if (c && c._id) return !0
- }
- return !1
- },
- getIfmuted: function(a) {
- var b = this.collection.findWhere({
- userid: a
- });
- return b ? b.get("muted") : !1
- },
- getIfQueueIsActive: function(a) {
- var b = this.collection.findWhere({
- userid: a
- });
- return b && b.get("queuePaused") ? !0 : !1
- },
- getDubs: function(a) {
- var b = this.collection.findWhere({
- userid: a
- });
- return b ? b.get("dubs") : 0
- },
- autoLoad: function() {
- var a = this;
- this.collection.fetch({
- update: !0,
- success: function() {
- a.loadedInitialDubs || (a.loadedInitialDubs = !0, a.fetchDubs(), a.resetEl())
- }
- })
- },
- beforeClose: function() {
- this.intervalId && clearInterval(this.intervalId)
- }
- }), Dubtrack.View.roomUsersItem = Backbone.View.extend({
- tagName: "li",
- events: {
- click: "clickEvent"
- },
- initialize: function() {
- this.$el.attr({
- rel: this.model.get("dubs")
- }), this.model.bind("reset", this.render, this), Dubtrack.Events.bind("realtime:user_update_" + this.model.get("userid"), this.dubUpdate, this)
- },
- render: function() {
- this.$el.html(_.template(Dubtrack.els.templates.rooms.avatarsContainerItem, this.model.toJSON())), this.pictureEl = this.$(".picture"), this.usernameEl = this.$("p.username");
- var a = this.model.get("_user");
- Dubtrack.helpers.isDubtrackAdmin(this.model.get("userid")) && this.$el.addClass("admin"), this.model.get("userid") == Dubtrack.room.model.get("userid") && this.$el.addClass("creator");
- var c = this.model.get("roleid");
- if (c && (this.$el.addClass(c.type), this.model.get("userid") == Dubtrack.session.id && (Dubtrack.room && Dubtrack.room.player && Dubtrack.room.player.skipElBtn.show(), Dubtrack.room.users.getIfOwner(this.model.get("userid")) ? b("#main_player .edit-room").show() : b("#main_player .edit-room").hide())), Dubtrack.session && this.model.get("userid") == Dubtrack.session.id) {
- var d = Dubtrack.room.player.activeSong.get("user");
- d && d.id == this.model.get("userid") && (this.$el.addClass("currentDJ"), Dubtrack.room && Dubtrack.room.player && Dubtrack.room.player.skipElBtn.show()), (Dubtrack.helpers.isDubtrackAdmin(Dubtrack.session.id) || Dubtrack.room.users.getIfRoleHasPermission(Dubtrack.session.id, "ban")) && b("#main_player .display-mods-controls").css("display", "inline-block")
- }
- if (a && "object" == typeof a) {
- var e = Dubtrack.cache.users.add(a);
- this.renderUser(null, e)
- } else Dubtrack.cache.users.get(this.model.get("userid"), this.renderUser, this);
- return this
- },
- dubUpdate: function(a) {
- this.$(".dubs span").html(a.user.dubs)
- },
- renderUser: function(a, b) {
- this.user = b;
- try {
- this.usernameEl.html(b.get("username"));
- b.get("userInfo");
- this.$el.addClass("user-" + this.user.get("username").toLowerCase()), this.$el.addClass("userid-" + this.user.id)
- } catch (c) {
- this.$el.remove()
- }
- },
- clickEvent: function() {
- return Dubtrack.helpers.displayUser(this.user.get("_id"), this.$el), !1
- },
- setOffline: function() {
- this.$el.append(b("<div/>", {
- "class": "offline"
- }).html(dubtrack_lang.avatar.offline))
- }
- }), Dubtrack.View.SoundCloudPlayer = Backbone.View.extend({
- tagName: "div",
- id: null,
- url: null,
- events: {},
- initialize: function() {},
- render: function(a, c, d, e, f) {
- var g = this;
- this.id = "playeryt-" + Date.now(), this.url = a, this.loadBg = f, this.$el.addClass("playerElement soundcloud"), f && this.$el.addClass("hiddenPlayer");
- var h = "https://d3byct92ei5n7c.cloudfront.net/hhberclba/image/upload/c_fill,h_460,w_900/tiqxlzynh3rxrkwvzeak.jpg";
- try {
- var i = Dubtrack.room.player.activeSong.get("songInfo");
- i && i.images && i.images.thumbnail && (h = i.images.thumbnail.replace("large", "original"))
- } catch (j) {}
- return this.canvasContEl = b("<div/>", {
- id: this.id
- }).html('<img src="' + h + '" alt="" onerror="this.src=\'https://d3byct92ei5n7c.cloudfront.net/hhberclba/image/upload/c_fill,h_460,w_900/tiqxlzynh3rxrkwvzeak.jpg\'" />').css({
- position: "absolute",
- top: 0,
- left: 0,
- width: "100%",
- height: "100%"
- }).appendTo(this.$el), a += -1 == a.indexOf("secret_token") ? "?" : "&", a = a + "consumer_key=" + Dubtrack.config.keys.soundcloud, soundManager.destroySound("dubtrack_main_player"), g.scPlayer = soundManager.createSound({
- id: "dubtrack_main_player",
- url: a,
- autoLoad: !0,
- autoPlay: g.loadBg ? !1 : !0,
- stream: !0,
- from: 1e3 * c,
- position: 1e3 * c,
- usePeakData: !0,
- volume: g.loadBg ? 0 : Dubtrack.playerController.volume,
- onplay: function() {
- g.setVolume(Dubtrack.playerController.volume, !0), e.loadingEl.hide(), e.bufferingEl.hide(), e.errorElBtn.hide(), e.playing = !0
- },
- onload: function() {
- g.setVolume(Dubtrack.playerController.volume)
- },
- onerror: function() {
- e.loadingEl.hide(), e.bufferingEl.hide(), e.errorElBtn.show(), this.playing = !1
- },
- onfinish: function() {
- d && d.call()
- },
- onbufferchange: function() {}
- }), this
- },
- play: function() {
- this.loadBg = !1, this.$el.removeClass("hiddenPlayer"), this.scPlayer && this.scPlayer.play(), this.setVolume(Dubtrack.playerController.volume)
- },
- setPlaybackQuality: function(a) {},
- sync: function(a) {
- this.scPlayer && this.scPlayer.setPosition(1e3 * a)
- },
- getCurrentTime: function() {
- try {
- if (this.scPlayer) return this.scPlayer.position / 1e3
- } catch (a) {}
- },
- beforeClose: function() {
- try {
- this.scPlayer.destruct(), this.scPlayer = null
- } catch (a) {}
- b("#" + this.id).remove()
- },
- stop: function() {
- try {
- if (this.scPlayer) return this.scPlayer.destruct(), this.scPlayer.stop()
- } catch (a) {}
- },
- setVolume: function(a) {
- a = parseInt(a, 10), this.scPlayer && (a > 2 ? this.scPlayer.unmute() : this.scPlayer.mute(), this.scPlayer.setVolume(a))
- }
- }), Dubtrack.View.YoutubePlayer = Backbone.View.extend({
- tagName: "div",
- id: null,
- url: null,
- initialize: function() {},
- loadVideo: function(a, b, c, d, f) {
- if (!this.player) return this.render(a, b, c, d, f);
- this.url = a;
- var g = Dubtrack.config.player.youtube.youtubeVars;
- b >= 0 && (g.start = b);
- try {
- this.player.loadVideoById({
- width: Dubtrack.config.player.playerWidth,
- height: Dubtrack.config.player.playerHeight,
- startSeconds: b,
- videoId: a,
- playerVars: g,
- events: {
- onReady: function(a) {
- d.errorElBtn.hide(), d.loadingEl.hide(), self.setVolume(Dubtrack.playerController.volume), self.setPlaybackQuality(d.playbackQuality), e() || self.play()
- },
- onError: function(a) {
- d.loadingEl.hide(), d.playing = !1
- },
- onStateChange: function(a) {
- switch (a.data) {
- case 0:
- c && c.call();
- break;
- case 1:
- d.loadingEl.hide(), d.bufferingEl.hide(), d.playing = !0, d.autoplayStarted = !0;
- break;
- case 3:
- d.bufferingEl.show(), d.playing = !1;
- break;
- case 2:
- self.play()
- }
- }
- }
- })
- } catch (h) {}
- },
- render: function(a, c, d, f, g) {
- var h = this;
- this.id = "playeryt-" + Date.now(), this.url = a, this.ytPlayerContainer = b("<div/>", {
- id: this.id
- }).appendTo(this.$el), this.loadBg = g, this.$el.addClass("playerElement youtube"), g && this.$el.addClass("hiddenPlayer");
- var i = Dubtrack.config.player.youtube.youtubeVars;
- c >= 0 && (i.start = c), f.loadingEl.hide();
- try {
- this.player = new YT.Player(this.id, {
- width: Dubtrack.config.player.playerWidth,
- height: Dubtrack.config.player.playerHeight,
- startSeconds: c,
- videoId: a,
- playerVars: i,
- events: {
- onReady: function(a) {
- a && a.target && (h.player = a.target), f.errorElBtn.hide(), h.setVolume(Dubtrack.playerController.volume), h.setPlaybackQuality(f.playbackQuality), e() || h.play()
- },
- onError: function(a) {
- f.playing = !1
- },
- onStateChange: function(a) {
- switch (a.data) {
- case 0:
- d && d.call();
- break;
- case 1:
- f.loadingEl.hide(), f.bufferingEl.hide(), f.playing = !0, f.autoplayStarted = !0;
- break;
- case 3:
- f.bufferingEl.show(), f.playing = !1;
- break;
- case 2:
- h.play()
- }
- }
- }
- })
- } catch (j) {
- setTimeout(function() {
- h.render(a, c, d, f, g)
- }, 1e3)
- }
- return this
- },
- play: function() {
- if (this.loadBg = !1, this.$el.removeClass("hiddenPlayer"), this.player) {
- var a = this.player;
- try {
- a.playVideo()
- } catch (b) {}
- }
- return this.setVolume(Dubtrack.playerController.volume, !0), !1
- },
- sync: function(a) {
- this.player && this.player.seekTo(a, !0)
- },
- setPlaybackQuality: function(a) {
- this.player && this.player.setPlaybackQuality(a)
- },
- getAvailableQualityLevels: function() {
- return this.player ? this.player.getAvailableQualityLevels() : []
- },
- getCurrentTime: function() {
- try {
- if (this.player) return this.player.getCurrentTime()
- } catch (a) {}
- },
- stop: function() {
- try {
- if (this.player) return this.player.stopVideo()
- } catch (a) {}
- },
- beforeClose: function() {
- try {
- this.player.destroy(), this.player = null
- } catch (a) {}
- b("#" + this.id).remove()
- },
- setVolume: function(a) {
- if (a = parseInt(a, 10), this.player) try {
- a > 2 ? this.player.unMute() : this.player.mute(), this.player.setVolume(a)
- } catch (b) {}
- }
- }), Dubtrack.View.Player = Backbone.View.extend({
- el: b("#main_player"),
- voteCount: 0,
- playbackQuality: "default",
- events: {
- "click .placeholder": "displayQueueBrowser",
- "click .skip-el": "skipSong",
- "click .playbtn-el": "playCurrentSong",
- "click .refresh-el": "reloadVideo",
- "click .player-controller-container .mute": "mutePlayer",
- "click .play-song-link": "displayBrowserSearch",
- "click .videoquality-el": "changeYTQuality",
- "click .hideVideo-el": "hideVideo",
- "click .display-queue": "displayRoomQueue",
- "click .edit-room": "editRoom",
- "click .display-mods-controls": "displayModsControl",
- "click .room-info-display": "diplayRoomInfo",
- "click .displayVideo-el": "displayPlayer"
- },
- initialize: function() {
- this.playing = !1, this.autoplayStarted = !1, this.loadingEl = this.$(".loading-el"), this.bufferingEl = this.$(".buferring-el").html(dubtrack_lang.player.buffering), this.playElBtn = this.$(".playbtn-el"), this.queueInfo = b(".queue-info"), this.hideVideoElBtn = this.$(".hideVideo-el"), this.qualityElBtn = this.$(".videoquality-el"), this.displayRoomQueueEl = this.$(".display-queue"), this.refreshElBtn = this.$(".refresh-el"), this.skipElBtn = this.$(".skip-el"), this.errorElBtn = b("<div/>", {
- "class": "loading"
- }).html(dubtrack_lang.player.error).css({
- display: "none"
- }).appendTo(g.config.playerContainer), this.placeHolder = this.$(".placeholder"), this.customEmbedIframeDiv = this.$("#custom_iframe_embed"), this.customEmbedIframeErrorDiv = this.$("#custom_iframe_embed_error");
- var a = Dubtrack.config.urls.roomPlaylist.replace(":id", this.model.id);
- this.activeQueueCollection = new Dubtrack.Collection.RoomActiveQueue, this.activeQueueCollection.url = Dubtrack.config.apiUrl + a, Dubtrack.Events.bind("realtime:room-update", this.roomUpdate, this);
- this.minEl = Dubtrack.playerController.$(".min"), this.secEl = Dubtrack.playerController.$(".sec"), this.progressEl = Dubtrack.playerController.$(".progressBg"), this.currentDjName = Dubtrack.playerController.$(".currentDJSong"), this.pictureEl = Dubtrack.playerController.$(".imgEl");
- var c = Dubtrack.config.urls.roomPlaylistActive.replace(":id", this.model.id);
- this.activeSong = new Dubtrack.Model.ActiveQueue, this.activeSong.url = Dubtrack.config.apiUrl + c, this.room_type = null, this.activeSong.parse = Dubtrack.helpers.parse, Dubtrack.Events.bind("realtime:room_playlist-update", this.realTimeUpdate, this), Dubtrack.user.loggedIn && this.displayRoomQueueEl.show(), this.modsViewEl = new Dubtrack.View.ModsView, Dubtrack.session && Dubtrack.room && Dubtrack.room.users && (Dubtrack.helpers.isDubtrackAdmin(Dubtrack.session.id) || Dubtrack.room.users.getIfRoleHasPermission(Dubtrack.session.id, "ban")) && this.$(".display-mods-controls").css("display", "inline-block"), Dubtrack.helpers.cookie.get("dubtrack-room-volume") && this.setVolume(Dubtrack.helpers.cookie.get("dubtrack-room-volume")), this.fetchSong()
- },
- skipSong: function() {
- return this.skipElBtn.hide(), Dubtrack.room.chat.skipSong(), !1
- },
- displayPlayer: function() {
- return this.$("#mods-controllers").hide(), this.$("#room-info-display").hide(), this.$(".player_container").show(), this.$(".player_header .active").removeClass("active"), this.$(".player_header .displayVideo-el").addClass("active"), !1
- },
- displayModsControl: function() {
- return this.$(".player_container").hide(), this.$("#room-info-display").hide(), this.$("#mods-controllers").show(), this.$(".player_header .active").removeClass("active"), this.$(".player_header .display-mods-controls").addClass("active"), !1
- },
- diplayRoomInfo: function() {
- return this.$(".player_container").hide(), this.$("#mods-controllers").hide(), this.$("#room-info-display").show(), this.$(".player_header .active").removeClass("active"), this.$(".player_header .room-info-display").addClass("active"), this.roomInfoView || (this.roomInfoView = new Dubtrack.View.RoomInfo({
- model: this.model
- }).render()), !1
- },
- editRoom: function() {
- return Dubtrack.session && Dubtrack.room.users && Dubtrack.room.users.getIfOwner(Dubtrack.session.get("_id")) && (this.roomUpdateView && this.roomUpdateView.close(), this.roomUpdateView = new f.room.roomFormUpdateViewUpdate({
- model: Dubtrack.room.model
- }).render(), this.roomUpdateView.$el.appendTo("body")), !1
- },
- hideVideo: function() {
- var a;
- this.istoggleVideo ? (this.istoggleVideo = !1, b("#room-main-player-container").css("visibility", "visible"), b("#room-main-player-container iframe").css("visibility", "visible"), this.hideVideoElBtn.removeClass("active"), a = "off") : (this.istoggleVideo = !0, b("#room-main-player-container").css("visibility", "hidden"), b("#room-main-player-container iframe").css("visibility", "hidden"), this.hideVideoElBtn.addClass("active"), a = "on")
- },
- roomUpdate: function(a) {
- a && a.room && this.room_type != a.room.roomType && this.render()
- },
- displayRoomQueue: function() {
- return Dubtrack.app.navigate("/browser/room-queue", {
- trigger: !0
- }), !1
- },
- displayBrowserSearch: function() {
- return Dubtrack.app.navigate("/browser/search", {
- trigger: !0
- }), !1
- },
- mutePlayer: function() {
- return this.muted_player ? (this.muted_player = !1, this.volumeBeforeMuted && this.volumeBeforeMuted > 2 ? (this.setVolume(this.volumeBeforeMuted), Dubtrack.playerController.volumeSliderEl.slider("value", this.volumeBeforeMuted)) : (this.setVolume(100), Dubtrack.playerController.volumeSliderEl.slider("value", 100))) : (this.muted_player = !0, this.volumeBeforeMuted = Dubtrack.playerController.volume, this.setVolume(0), Dubtrack.playerController.volumeSliderEl.slider("value", 0)), !1
- },
- render: function() {
- var a = this.activeSong.get("songInfo"),
- c = this.activeSong.get("song"),
- d = "";
- if (this.skipElBtn.hide(), this.qualityElBtn.removeClass("show"), this.refreshElBtn.removeClass("show"), this.hideVideoElBtn.removeClass("show"), this.refreshTimeout && clearTimeout(this.refreshTimeout), this.queue_timeout && clearTimeout(this.queue_timeout), this.videoend_timeout && clearTimeout(this.videoend_timeout), this.customEmbedIframeDiv.empty(), this.$("#room-main-player-container #room-main-player-container-youtube").hide(), this.$("#room-main-player-container #room-main-player-container-soundcloud").hide(), this.activePlayerDelegate && this.activePlayerDelegate.stop(), this.activePlayerDelegate = null, "iframe" != Dubtrack.room.model.get("roomType")) {
- if (this.room_type = "room", b(".custom-embed-info").hide(), b(".remove-if-iframe").addClass("display-block"), b(".infoContainer").addClass("display-block"), b("body").addClass("no-song-playing"), this.customEmbedIframeDiv.hide(), this.customEmbedIframeErrorDiv.hide(), this.$("#room-main-player-container").show(), null !== a && (Dubtrack.playerController.$(".currentSong").html(a.name), Dubtrack.cache.users.get(c.userid, this.renderUser, this), b("body").removeClass("no-song-playing"), d = a.type, Dubtrack.session && Dubtrack.session.id)) {
- (Dubtrack.helpers.isDubtrackAdmin(Dubtrack.session.id) || Dubtrack.room.users && Dubtrack.room.users.getIfRoleHasPermission(Dubtrack.session.id, "skip")) && this.skipElBtn.show();
- var e = this.activeSong.get("user");
- e && e.id == Dubtrack.session.id && this.skipElBtn.show()
- }
- switch (d) {
- case "youtube":
- this.placeHolder.hide(), this.buildYT(), this.playCurrent();
- break;
- case "soundcloud":
- case "dubtrack":
- this.placeHolder.hide(), this.buildSoundCloud(), this.playCurrent();
- break;
- default:
- this.loadingEl.hide(), Dubtrack.playerController.$(".currentSong").html(dubtrack_lang.player.no_one_is_playing), this.placeHolder.show(), this.currentDjName.hide(), this.pictureEl.hide()
- }
- return Dubtrack.playerController.update(), this.fetchQueueInfo(), this
- }
- this.room_type = "iframe", this.placeHolder.hide(), Dubtrack.playerController.$(".currentTime").hide(), this.YTplayerDelegate && this.YTplayerDelegate.close(), this.SCplayerDelegate && this.SCplayerDelegate.close(), this.YTplayerDelegate = null, this.SCplayerDelegate = null, b(".remove-if-iframe").removeClass("display-block"), Dubtrack.playerController.$(".currentSong").html(""), b(".custom-embed-info").show(), this.pictureEl.hide(), this.currentDjName.hide(), this.loadingEl.hide(), b(".infoContainer").removeClass("display-block"), this.$("#room-main-player-container").hide(), this.intervalCounter && clearInterval(this.intervalCounter), this.progressEl.css("width", "0%");
- var f = Dubtrack.room.model.get("roomEmbed"),
- g = /(http:\/\/|https:\/\/|\/\/)(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/,
- h = /(twitch\.tv)\/([^\&\?\/]+)/;
- if (f && g.test(f))
- if (h.test(f)) {
- var i = f.match(h);
- try {
- if (i[2]) {
- var j = i[2];
- this.customEmbedIframeErrorDiv.hide(), this.customEmbedIframeDiv.show().html('<div id="custom_iframe_overlay"></div><object type="application/x-shockwave-flash" data="https://www-cdn.jtvnw.net/swflibs/TwitchPlayer.swff?channel=' + j + '" width="100%" height="100%" id="live_embed_player_flash"> <param name="movie" value="https://www-cdn.jtvnw.net/swflibs/TwitchPlayer.swff?channel=' + j + '"> <param name="quality" value="high"> <param name="allowFullScreen" value="true"> <param name="allowScriptAccess" value="always"> <param name="pluginspage" value="http://www.macromedia.com/go/getflashplayer"> <param name="autoplay" value="true"> <param name="autostart" value="true"> <param name="flashvars" value="hostname=www.twitch.tv&start_volume=' + Dubtrack.playerController.volume + "&channel=" + j + '&auto_play=true"> <embed src="https://www-cdn.jtvnw.net/swflibs/TwitchPlayer.swff?channel=' + j + '" flashvars="hostname=www.twitch.tv&start_volume=' + Dubtrack.playerController.volume + "&channel=" + j + '&auto_play=true" width="100%" height="100%" type="application/x-shockwave-flash"> </object>')
- }
- } catch (k) {
- this.customEmbedIframeErrorDiv.show()
- }
- } else this.customEmbedIframeErrorDiv.hide(), f = f.replace("http:", "https:"), this.customEmbedIframeDiv.show().html('<div id="custom_iframe_overlay"></div><iframe src="' + f + '" width="100%" height="100%" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>');
- else this.customEmbedIframeErrorDiv.show()
- },
- displayQueueBrowser: function() {
- return Dubtrack.app.navigate("/browser/queue", {
- trigger: !0
- }), !1
- },
- playCurrent: function() {
- var a = (this.activeSong.get("songInfo"), this.activeSong.get("song")),
- b = this.activeSong.get("startTime"),
- c = a.songLength / 1e3;
- return b > c ? this.videoEnd() : ((Dubtrack.helpers.isDubtrackAdmin(Dubtrack.session.id) || Dubtrack.room.users && Dubtrack.room.users.getIfRoleHasPermission(Dubtrack.session.id, "skip")) && this.skipElBtn.show(), this.activePlayerDelegate && this.activePlayerDelegate.play(), void this.setTimer(b, c))
- },
- playCurrentSong: function() {
- return this.playElBtn.hide(), this.activePlayerDelegate && this.activePlayerDelegate.play(), !1
- },
- loadComments: function() {},
- renderUser: function(a, b) {
- if (!a) {
- this.activeSong.set("user", b);
- b.get("userInfo");
- Dubtrack.room && Dubtrack.room.users && Dubtrack.room.users.setCurrentDJ(b.get("_id")), this.pictureEl.html(Dubtrack.helpers.image.getImage(b.get("_id"), b.get("username"), !1, !0)).show(), this.currentDjName.html(b.get("username") + " is playing").show()
- }
- },
- realTimeUpdate: function(a) {
- var b = this.activeSong.get("song");
- (null === b || b._id != a.song._id) && (this.activePlayerDelegate && this.activePlayerDelegate.stop(), this.activeSong.set({
- song: a.song,
- songInfo: a.songInfo,
- startTime: a.startTime,
- user: null
- }), this.refresh(), this.render())
- },
- refresh: function() {
- this.playing = !1, b("li.downdub").removeClass("downdub"), b("li.updub").removeClass("updub"), b(".shared").removeClass("shared"), this.$("#room-main-player-container #room-main-player-container-youtube").hide(), this.$("#room-main-player-container #room-main-player-container-soundcloud").hide(), this.activePlayerDelegate = null, this.loadingEl.show(), b("body").addClass("no-song-playing"), this.bufferingEl.hide(), this.progressEl.css("width", 0), Dubtrack.playerController.$(".currentTime").hide(), Dubtrack.playerController.$(".currentSong").html(dubtrack_lang.global.loading), this.pictureEl.empty(), this.currentDjName.empty(), Dubtrack.room && Dubtrack.room.users && Dubtrack.room.users.removeCurrentDJ(), Dubtrack.room && Dubtrack.room.users && Dubtrack.room.users.removeDubs(), this.intervalCounter && clearInterval(this.intervalCounter), this.videoend_timeout && clearTimeout(this.videoend_timeout)
- },
- fetchQueueInfo: function() {},
- changeYTQuality: function() {
- if (!this.YTplayerDelegate) return !1;
- var a = 0,
- b = this.YTplayerDelegate.getAvailableQualityLevels();
- if (!(b.length < 1)) {
- switch (this.playbackQuality) {
- case "default":
- this.qualityElBtn.addClass("active-hd"), this.playbackQuality = "highres", a = 0;
- break;
- default:
- this.qualityElBtn.removeClass("active-hd"), this.playbackQuality = "default", a = b.length - 1
- }
- return a >= 0 && this.YTplayerDelegate.setPlaybackQuality(b[a]), !1
- }
- },
- reloadVideo: function() {
- return this.activeSong.set({
- song: null,
- songInfo: null,
- user: null,
- startTime: null
- }), this.refresh(), this.fetchSong(), !1
- },
- videoEnd: function() {
- this.skipElBtn.hide(), this.playing = !1
- },
- fetchSong: function() {
- var a = this;
- this.refresh(), this.activeSong.fetch({
- success: function(b, c) {
- a.render()
- },
- error: function() {
- a.activeSong.set({
- song: null,
- songInfo: null,
- user: null,
- startTime: null
- }), a.render()
- }
- })
- },
- loadQueueNumber: function() {},
- getStarTime: function() {
- var a = this.activeSong.get("startTime"),
- b = this.activeSong.get("song");
- return -1 == a ? (a = 0, this.activeSong.set({
- startTime: a,
- played: Date.now()
- })) : (isNaN(a) || !a) && (a = parseInt((Date.now() - b.played) / 1e3, 10), 0 > a && (a = 0), this.activeSong.set({
- startTime: a
- })), a
- },
- buildYT: function() {
- this.SCplayerDelegate && (this.SCplayerDelegate.stop(), this.SCplayerDelegate.close()), this.$("#room-main-player-container #room-main-player-container-soundcloud").empty();
- var a = this.activeSong.get("song"),
- c = this.activeSong.get("songInfo"),
- d = this.getStarTime();
- this.$("#room-main-player-container #room-main-player-container-youtube").show(), this.YTplayerDelegate ? this.YTplayerDelegate.loadVideo(c.fkid, d, function() {
- this.videoend_timeout && clearTimeout(this.videoend_timeout), this.videoend_timeout = setTimeout(function() {
- this.videoEnd()
- }.bind(this), 1e4)
- }.bind(this), this, !0) : (this.YTplayerDelegate = new Dubtrack.View.YoutubePlayer, this.YTplayerDelegate.$el.appendTo(this.$("#room-main-player-container #room-main-player-container-youtube")), this.YTplayerDelegate.render(c.fkid, d, function() {
- this.videoend_timeout && clearTimeout(this.videoend_timeout), this.videoend_timeout = setTimeout(function() {
- this.videoEnd()
- }.bind(this), 1e4)
- }.bind(this), this, !0)), this.activePlayerDelegate = this.YTplayerDelegate, this.playElBtn.hide(), this.qualityElBtn.addClass("show"), this.refreshElBtn.addClass("show"), this.hideVideoElBtn.addClass("show"), a.songLength / 1e3 == 99999 && (d = -1), this.istoggleVideo && (b("#room-main-player-container").css("visibility", "hidden"), b("#room-main-player-container iframe").css("visibility", "hidden"))
- },
- buildSoundCloud: function() {
- this.$("#room-main-player-container #room-main-player-container-youtube").hide(), this.SCplayerDelegate && (this.SCplayerDelegate.stop(), this.SCplayerDelegate.close()), this.YTplayerDelegate && this.YTplayerDelegate.stop(), this.$("#room-main-player-container #room-main-player-container-soundcloud").empty(), this.refreshElBtn.addClass("show"), this.$("#room-main-player-container #room-main-player-container-soundcloud").show();
- var a = (this.activeSong.get("song"), this.activeSong.get("songInfo")),
- b = this.getStarTime(),
- c = this.$el.innerWidth(),
- d = this.$el.innerHeight();
- e() && (this.loadingEl.hide(), this.playElBtn.show()), this.SCplayerDelegate = new Dubtrack.View.SoundCloudPlayer, this.SCplayerDelegate.$el.appendTo(this.$("#room-main-player-container #room-main-player-container-soundcloud")), this.SCplayerDelegate.render(a.streamUrl, b, function() {
- this.videoend_timeout && clearTimeout(this.videoend_timeout), this.videoend_timeout = setTimeout(function() {
- this.videoEnd()
- }.bind(this), 1e4)
- }.bind(this), this, c, d, !0), this.activePlayerDelegate = this.SCplayerDelegate
- },
- setTimer: function(a, b) {
- if (Dubtrack.playerController.$(".currentTime").show(), this.videoLength = b, this.intervalCounter && clearInterval(this.intervalCounter), 99999 == b) return this.playingLive = !0, this.minEl.html(""), void this.secEl.html("LIVE");
- this.playingLive = !1;
- var c = b - a,
- d = Math.floor(c / 60),
- e = parseInt(c - 60 * d, 10);
- if (!(0 >= c)) {
- this.minEl.html("0".substring(d >= 10) + d), this.secEl.html("0".substring(e >= 10) + e);
- var f = this;
- this.intervalCounter = setInterval(function() {
- f.setTimerCounter()
- }, 1e3)
- }
- },
- setTimerCounter: function() {
- var a = this.activeSong.get("song"),
- b = 0;
- b = this.activePlayerDelegate && !this.playing ? parseInt((Date.now() - a.played) / 1e3, 10) : this.getCurrentTime();
- var c = this.videoLength - b,
- d = Math.floor(c / 60),
- e = parseInt(c - 60 * d, 10),
- f = this.activeSong.get("songInfo");
- if (!(0 >= c)) {
- this.minEl.html("0".substring(d >= 10) + d), this.secEl.html("0".substring(e >= 10) + e);
- var g = 100 * b / (f.songLength / 1e3);
- this.progressEl.css("width", g + "%")
- }
- },
- setVolume: function(a) {
- this.player_volume_level = a, Dubtrack.playerController.volume = a, a > 2 ? (this.$(".player-controller-container .mute").removeClass("sound-muted"), this.muted_player = !1) : (this.$(".player-controller-container .mute").addClass("sound-muted"), this.muted_player = !0), this.activePlayerDelegate && this.activePlayerDelegate.setVolume(a)
- },
- setVolumeRemote: function(a) {
- this.activePlayerDelegate && this.activePlayerDelegate.setVolume(a)
- },
- sync: function(a) {
- this.activePlayerDelegate && this.playing && this.activePlayerDelegate.sync(a)
- },
- getCurrentTime: function() {
- return this.activePlayerDelegate ? this.activePlayerDelegate.getCurrentTime() : void 0
- },
- beforeClose: function() {
- this.YTplayerDelegate && this.YTplayerDelegate.close(), this.SCplayerDelegate && this.SCplayerDelegate.close(), this.YTplayerDelegate = null, this.SCplayerDelegate = null, this.intervalCounter && clearInterval(this.intervalCounter), this.videoend_timeout && clearTimeout(this.videoend_timeout), this.playerControls && this.playerControls.close(), g.config.playerMainContainer.html(b("<div/>", {
- "class": "player_container"
- })), g.config.playerContainer = g.config.playerMainContainer.find("div.player_container")
- }
- }), Dubtrack.View.Room = Backbone.View.extend({
- el: b("#main-room"),
- videoChatCollapsed: !1,
- events: {
- "click button.view-users": "displayUsers",
- "click #mobile-room-menu a": "setMenuActive"
- },
- initialize: function() {
- if (this.currentMobileClass = "", this.roomInfoView = null, Dubtrack.Events.bind("realtime:room-update", this.roomUpdate, this), Dubtrack.Events.bind("realtime:user-kick", this.userKickedOut, this), Dubtrack.Events.bind("realtime:user-ban", this.userBannedOut, this), Dubtrack.helpers.cookie.set("dubtrack-room", this.model.get("roomUrl"), 60), Dubtrack.helpers.cookie.set("dubtrack-room-id", this.model.get("_id"), 60), Dubtrack.loggedIn) {
- var a = Dubtrack.config.apiUrl + Dubtrack.config.urls.roomBeacon.replace(":id", this.model.id).replace(":userid", Dubtrack.session.id);
- b(window).bind("beforeunload", function() {
- b.ajax({
- url: a,
- async: !1
- })
- }), b(window).bind("unload", function() {
- b.ajax({
- url: a,
- async: !1
- })
- })
- }
- Dubtrack.realtime.subscribe(this.model.get("realTimeChannel").toLowerCase(), function() {}.bind(this))
- },
- setMenuActive: function(a) {
- var c = b(a.target);
- c.is("a") || (c = c.parents("a"));
- var d = c.data("display");
- return d && (this.$el.removeClass(this.currentMobileClass), this.currentMobileClass = d, this.$el.addClass(this.currentMobileClass), this.$("#mobile-room-menu a.active").removeClass("active"), c.addClass("active")), !1
- },
- displayUsers: function() {
- return this.$el.addClass("display-users-rooms"), !1
- },
- roomUpdate: function(a) {
- if (a && a.room) {
- var c = this.model.get("background");
- a.room.background && a.room.background.public_id && c && c.public_id && c.public_id != a.room.background.public_id && this.updateBackground(!0), b("#roomNameMenu").html(a.room.name), this.model.set(a.room)
- }
- },
- updateBackground: function(a) {
- b.backstretch("destroy", !1);
- var c = Dubtrack.config.urls.roomImage;
- c = Dubtrack.config.apiUrl + c.replace(":id", this.model.get("_id")), a && (c += "?v" + Date.now()), b.backstretch(c)
- },
- render: function() {
- var a = Dubtrack.config.urls.roomUsers.replace("{id}", this.model.id);
- this.urlUsersRoom = Dubtrack.config.apiUrl + a, this.joinRoom(), this.renderChat(), this.player || Dubtrack.player_initialized || (Dubtrack.player_initialized = !0, this.player = new Dubtrack.View.Player({
- model: this.model
- })), Dubtrack.loggedIn ? b("#create-room-div").show() : b("#create-room-div").hide(), Dubtrack.session && Dubtrack.room.users && Dubtrack.room.users.getIfOwner(Dubtrack.session.get("_id")) ? (b("#create-room-div").hide(), b("#edit-room-div").show()) : (b("#create-room-div").show(), b("#edit-room-div").hide());
- var c = this.model.get("background");
- c && this.updateBackground(!1), this.$(".room-feautre-title span").html("Top users in " + this.model.get("name")), b("#main-room-active-link").attr("href", "/join/" + this.model.get("roomUrl")).addClass("active-room").find(".room-name").html(this.model.get("name")), b("#main-menu-left .room-active-link").attr("href", "/join/" + this.model.get("roomUrl")).css("display", "block").find("span.current-room").html(this.model.get("name")), b(".rewindProfile a").attr("href", "/join/" + this.model.get("roomUrl")), b(".close").attr("href", "/join/" + this.model.get("roomUrl"))
- },
- displayRoom: function() {
- this.$el.show()
- },
- userKickedOut: function(a) {
- var b = a.kickedUser && "_id" in a.kickedUser ? a.kickedUser._id : !1;
- if (Dubtrack.session && b && b === Dubtrack.session.get("_id")) {
- var c = "You were kicked out of the room";
- Dubtrack.helpers.displayError("Warning", c, !1, "Dubtrack.room.leaveRoom();"), setTimeout(function() {
- this.leaveRoom()
- }.bind(this), 3e4);
- try {
- Dubtrack.room.chat.mentionChatSound && Dubtrack.room.chat.mentionChatSound.play()
- } catch (d) {}
- }
- },
- userBannedOut: function(a) {
- var b = a.kickedUser && "_id" in a.kickedUser ? a.kickedUser._id : !1;
- if (Dubtrack.session && b && b === Dubtrack.session.get("_id")) {
- var c = "You were banned from this room",
- d = parseInt(a.time, 10);
- d && 0 !== d && (c += " for " + d + " minutes"), Dubtrack.helpers.displayError("Warning", c, !1, "Dubtrack.room.leaveRoom();"), setTimeout(function() {
- this.leaveRoom()
- }.bind(this), 3e4);
- try {
- Dubtrack.room.chat.mentionChatSound && Dubtrack.room.chat.mentionChatSound.play()
- } catch (e) {}
- }
- },
- leaveRoom: function() {
- Dubtrack.helpers.cookie["delete"]("dubtrack-room"), Dubtrack.helpers.cookie["delete"]("dubtrack-room-id");
- var a = Dubtrack.config.apiUrl + Dubtrack.config.urls.roomBeacon.replace(":id", this.model.id).replace(":userid", Dubtrack.session.id);
- b.ajax({
- url: a
- }).always(function() {
- window.onbeforeunload = null, window.location = "/"
- })
- },
- renderChat: function() {
- this.chat || (this.chat = new Dubtrack.View.chat)
- },
- joinRoom: function() {
- if (!this.joinedRoom) {
- this.joinedRoom = !0;
- var a = this;
- Dubtrack.loggedIn ? Dubtrack.helpers.sendRequest(this.urlUsersRoom, {}, "post", function(c, d) {
- if (a.loadRoomUsers(), c) switch (Dubtrack.playerController.$(".remove-if-banned").remove(), b("body").addClass("not-logged-in"), a.chat.$(".pusher-chat-widget-input").html(""), c.code) {
- case 401:
- try {
- a.chat.$(".pusher-chat-widget-input").html("<p>" + c.data.err.details.message + "</p>"), Dubtrack.helpers.displayError("[" + c.code + "] " + dubtrack_lang.global.error, c.data.err.details.message + ". <b><u>You won't be able to chat or play songs</u></b>", !1)
- } catch (e) {}
- Dubtrack.realtime.destroy(), Dubtrack.loggedIn = !1, Dubtrack.realtime.subscribe(a.model.get("realTimeChannel").toLowerCase(), function() {
- Dubtrack.loggedIn = !0
- });
- break;
- default:
- Dubtrack.helpers.displayError(dubtrack_lang.global.error, "An unexpected error occurred joining room", !0)
- } else d && d.data && d.data.user && d.data.user.muted && (a.chat.user_muted = !0)
- }) : this.loadRoomUsers()
- }
- },
- loadRoomUsers: function() {
- this.users ? this.users.autoLoad() : this.users = new Dubtrack.View.roomUsers({
- model: this.model
- })
- },
- setTopUsers: function() {}
- }), Dubtrack.View.RoomPassword = Backbone.View.extend({
- attributes: {
- id: "warning"
- },
- events: {
- submit: "submitForm"
- },
- render: function(a, b) {
- return this.$el.html("<form><h3>" + a + "</h3><p>" + b + "<input type='password' name='warning-password' id='warning-password' /></p><input type='submit' id='warning-input-submit' value='Join room' /></form>"), this.$el.appendTo("body"), this
- },
- resetFields: function() {
- this.$("#warning-password").val("").focus(), this.$("#warning-input-submit").val("Join Room")
- },
- submitForm: function() {
- this.$("#warning-input-submit").val("Loading...");
- var a = this.$("#warning-password").val();
- return a && a.length > 0 && Dubtrack.room.joinRoom({
- "password-room": a
- }), !1
- }
- }), f.room.roomFormUpdateViewUpdate = Backbone.View.extend({
- attributes: {
- id: "roomFormUpdate"
- },
- events: {
- "click .btn-primary": "saveForm",
- "click .cancel": "closeAction",
- "click .closebtn": "closeAction",
- "change select#roomTypeSelect": "roomTypeChange",
- "change select#roomDisplaySelect": "roomDisplayChange",
- "submit form": "saveForm",
- "keyup #roomEmbedInput": "replaceIframe"
- },
- render: function() {
- this.$el.html(_.template(Dubtrack.els.templates.rooms.roomFormUpdate, this.model.toJSON())), b(".dubtrack_overlay").show(), this.create_form = this.model.isNew();
- var a = this;
- if (this.create_form) this.$("#background-room-update").hide();
- else {
- var c = Dubtrack.config.urls.roomImage;
- c = c.replace(":id", this.model.get("_id")), this.$("#fileupload").fileupload({
- url: Dubtrack.config.apiUrl + c,
- dataType: "json",
- start: function() {
- a.$(".btn-primary").html("loading...")
- },
- done: function(a, b) {},
- always: function() {
- a.$(".btn-primary").html("Save"), a.$("#progress .bar").css({
- width: "0%"
- })
- },
- progress: function(b, c) {
- var d = parseInt(c.loaded / c.total * 100, 10);
- a.$("#progress .bar").css({
- width: d + "%"
- })
- }
- })
- }
- return this.roomTypeChange(), this.roomDisplayChange(), this
- },
- replaceIframe: function() {
- var a = this.$("#roomEmbedInput").val();
- try {
- if ($iframe = b(a), $iframe) {
- var c = $iframe.attr("src");
- c && (this.$("#roomEmbedInput").val(c), a = c)
- }
- } catch (d) {}
- this.displayCustomIframe()
- },
- saveForm: function(a) {
- a.preventDefault();
- var b = this.$("input#roomName").val(),
- c = this.$("input#maxLengthSongName").val(),
- d = this.$("#roomTypeSelect").val(),
- e = this.$("#lockQueueSelect").val();
- if (description = this.$("#roomDescription").val(), roomEmbed = this.$("#roomEmbedInput").val(), welcomeMessage = this.$("#welcomeMessage").val(), roomDisplay = this.$("#roomDisplaySelect").val(), roomPassword = this.$("#roomPassword").val(), metaDescription = this.$("#metaDescription").val(), b && " " !== b) {
- this.$(".btn-primary").html("loading...");
- var f = this;
- this.model.save({
- name: b,
- roomDisplay: roomDisplay,
- maxLengthSong: c,
- roomType: d,
- roomEmbed: roomEmbed,
- description: description,
- lockQueue: e,
- welcomeMessage: welcomeMessage,
- metaDescription: metaDescription,
- roomPassword: roomPassword
- }, {
- success: function(a, b) {
- if (200 === b.code)
- if (f.create_form) {
- var c = f.model.get("roomUrl");
- c && (window.location = "/join/" + c)
- } else f.close()
- },
- error: function() {
- f.create_form ? f.$(".btn-primary").html("room limit reached, you cannot create more rooms") : f.$(".btn-primary").html("an unexpected error occurred, please try again later")
- }
- })
- }
- return !1
- },
- displayCustomIframe: function() {
- var a = this.$("#roomEmbedInput").val(),
- b = /(http:\/\/|https:\/\/|\/\/)(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/,
- c = /(twitch\.tv)\/([^\&\?\/]+)/;
- if (a && b.test(a))
- if (c.test(a)) {
- var d = a.match(c);
- try {
- if (d[2]) {
- var e = d[2];
- this.$("#iframe-embed-preview").html('<object type="application/x-shockwave-flash" data="https://www-cdn.jtvnw.net/swflibs/TwitchPlayer.swff?channel=' + e + '" width="100%" height="100%"> <param name="movie" value="https://www-cdn.jtvnw.net/swflibs/TwitchPlayer.swff?channel=' + e + '"> <param name="quality" value="high"> <param name="allowFullScreen" value="true"> <param name="allowScriptAccess" value="always"> <param name="pluginspage" value="http://www.macromedia.com/go/getflashplayer"> <param name="autoplay" value="true"> <param name="autostart" value="true"> <param name="flashvars" value="hostname=www.twitch.tv&start_volume=25&channel=' + e + '&auto_play=true"> <embed src="https://www-cdn.jtvnw.net/swflibs/TwitchPlayer.swff?channel=' + e + '" flashvars="hostname=www.twitch.tv&start_volume=25&channel=' + e + '&auto_play=true" width="100%" height="100%" type="application/x-shockwave-flash"> </object>')
- }
- } catch (f) {}
- } else a = a.replace("http:", "https:"), this.$("#iframe-embed-preview").html('<iframe width="100%" height="100%" src="' + a + '" frameborder="0" allowfullscreen></iframe>');
- else this.$("#iframe-embed-preview").html("<h3>Invalid iframe url</h3>")
- },
- roomTypeChange: function() {
- "iframe" == this.$("#roomTypeSelect").val() ? (this.$("#iframeEmbedField").show(), this.displayCustomIframe()) : (this.$("#iframeEmbedField").hide(), this.$("#iframe-embed-preview").empty())
- },
- roomDisplayChange: function() {
- "private" == this.$("#roomDisplaySelect").val() ? (this.$("#room-password-control-group").show(), this.displayCustomIframe()) : this.$("#room-password-control-group").hide()
- },
- closeAction: function() {
- return this.close(), !1
- },
- beforeClose: function() {
- this.$("#iframe-embed-preview").empty(), b(".dubtrack_overlay").hide()
- }
- }), Dubtrack.View.RoomInfo = Backbone.View.extend({
- el: b("#room-info-display"),
- initialize: function() {
- Dubtrack.Events.bind("realtime:room-update", this.roomUpdate, this)
- },
- render: function() {
- var a = this.model.toJSON();
- return a.description && (a.description = Dubtrack.helpers.text.convertHtmltoTags(a.description).replace(/(?:\r\n|\r|\n)/g, "<br />")), this.$(".room-info-display-wrapper").html(_.template(Dubtrack.els.templates.rooms.roomModalView, a)), this.$(".room-info-display-wrapper").perfectScrollbar({
- wheelSpeed: 30,
- suppressScrollX: !0,
- wheelPropagation: !1
- }), this
- },
- roomUpdate: function(a) {
- a && a.room && (this.model.set(a.room), this.render())
- }
- }), Dubtrack.View.RoomList = Backbone.View.extend({
- el: b("#room-list"),
- events: {
- "keyup .room-lobby-header .room-search input": "triggerSearch",
- "click .room-lobby-header .create-room": "createRoom"
- },
- initialize: function() {
- this.model.bind("add", this.appendEl, this), this.model.bind("reset", this.render, this), this.roomListEl = this.$("#container-room-list"), this.$("#room-scroll-container").perfectScrollbar({
- wheelSpeed: 20,
- suppressScrollX: !0,
- wheelPropagation: !1,
- onscrollCallback: function(a, b) {
- 300 > b - a && b > 500 && this.loadMoreItems()
- }.bind(this)
- }), this.render()
- },
- render: function() {
- return this.roomListEl.empty(), this.offsetSearchItems = 0, this.moreItemsToLoad = !1, this.loadingMoreItems = !1, _.each(this.model.models, function(a) {
- this.appendEl(a)
- }, this), Dubtrack.els.displayloading(dubtrack_lang.room.searching), this
- },
- fetchUserRooms: function() {},
- triggerSearch: function(a) {
- var c = b.trim(this.$(".room-lobby-header .room-search input").val());
- this.searchTimeoutTrigger && clearTimeout(this.searchTimeoutTrigger), c && "" !== c && null !== c && c.length > 2 ? this.searchTimeoutTrigger = setTimeout(function() {
- this.search(c)
- }.bind(this), 700) : 0 === c.length && (this.searchTimeoutTrigger = setTimeout(function() {
- this.search("")
- }.bind(this), 300))
- },
- loadMoreItems: function() {
- if (!this.loadingMoreItems && Dubtrack.roomList.collection) {
- this.loadingMoreItems = !0;
- var a = new Dubtrack.Collection.Room;
- this.query && this.query.length > 0 ? a.url = Dubtrack.config.apiUrl + Dubtrack.config.urls.roomSearch.replace(":term", this.query.replace(/[^a-zA-Z 0-9]+/g, "")) : a.url = Dubtrack.config.apiUrl + Dubtrack.config.urls.room, Dubtrack.els.displayloading(dubtrack_lang.room.searching), this.offsetSearchItems = this.offsetSearchItems + 20, a.fetch({
- data: {
- offset: this.offsetSearchItems
- },
- success: function() {
- _.each(a.models, function(a) {
- this.model.add(a)
- }.bind(this)), Dubtrack.els.mainLoading.hide(), this.loadingMoreItems = !1
- }.bind(this),
- error: function() {
- this.loadingMoreItems = !1, Dubtrack.els.mainLoading.hide()
- }.bind(this)
- })
- }
- },
- search: function(a) {
- this.loadingMoreItems || (this.$("#room-scroll-container").scrollTop(0), Dubtrack.els.displayloading(dubtrack_lang.room.searching), this.offsetSearchItems = 0, this.moreItemsToLoad = !1, this.userRoomsCollection && this.userRoomsCollection.reset(), this.model.reset(), this.roomListEl.empty(), this.userRoomsCollection = new Dubtrack.Collection.Room, this.query = a, this.query && this.query.length > 0 ? this.userRoomsCollection.url = Dubtrack.config.apiUrl + Dubtrack.config.urls.roomSearch.replace(":term", this.query.replace(/[^a-zA-Z 0-9]+/g, "")) : this.userRoomsCollection.url = Dubtrack.config.apiUrl + Dubtrack.config.urls.room, this.userRoomsCollection.fetch({
- success: function() {
- _.each(this.userRoomsCollection.models, function(a) {
- this.model.add(a)
- }.bind(this)), Dubtrack.els.mainLoading.hide(), this.loadingMoreItems = !1
- }.bind(this),
- error: function() {
- this.loadingMoreItems = !1, Dubtrack.els.mainLoading.hide()
- }.bind(this)
- }))
- },
- createRoom: function() {
- if (Dubtrack.loggedIn) {
- var a = new Dubtrack.Model.Room;
- a.parse = Dubtrack.helpers.parse, this.roomUpdate = new f.room.roomFormUpdateViewUpdate({
- model: a
- }).render(), this.roomUpdate.$el.appendTo("body")
- } else Dubtrack.app.navigate("/login", {
- trigger: !0
- });
- return !1
- },
- appendEl: function(a) {
- var b = new Dubtrack.View.RoomListItem({
- model: a
- }).render();
- Dubtrack.loggedIn && a.get("userid") == Dubtrack.session.id ? b.$el.addClass("userRoom").prependTo(this.roomListEl) : b.$el.appendTo(this.roomListEl), this.$("#room-scroll-container").perfectScrollbar("update")
- },
- beforeClose: function() {}
- }), Dubtrack.View.ModsView = Backbone.View.extend({
- el: b("#mods-controllers"),
- events: {
- "click .mod-controllers-headers .display-mods-controls": "displayControls",
- "click .mod-controllers-headers .display-ban-list": "displayBanList",
- "click .mod-controllers-headers .display-mute-list": "displayMuteList",
- "click .mod-controllers-headers .display-staff-list": "displayStaffList"
- },
- initialize: function() {
- this.roomBanListView = (new Dubtrack.View.RoomBanList).render(), this.roomMuteListView = (new Dubtrack.View.RoomMuteList).render(), this.roomStaffListView = (new Dubtrack.View.RoomStaffList).render(), this.$(".mods-controllers-commands-list .mods-controller-container").perfectScrollbar({
- wheelSpeed: 30,
- suppressScrollX: !0,
- wheelPropagation: !1
- })
- },
- displayBanList: function() {
- return this.$(".mod-controllers-headers .active").removeClass("active"), this.$(".mod-controllers-headers .display-ban-list").addClass("active"), this.$(".show-controller").removeClass("show-controller"), this.$(".mods-controllers-ban-list").addClass("show-controller"), this.roomBanListView.fetchUsers(), !1
- },
- displayMuteList: function() {
- return this.$(".mod-controllers-headers .active").removeClass("active"), this.$(".mod-controllers-headers .display-mute-list").addClass("active"), this.$(".show-controller").removeClass("show-controller"), this.$(".mods-controllers-mute-list").addClass("show-controller"), this.roomMuteListView.fetchUsers(), !1
- },
- displayStaffList: function() {
- return this.$(".mod-controllers-headers .active").removeClass("active"), this.$(".mod-controllers-headers .display-staff-controls").addClass("active"), this.$(".show-controller").removeClass("show-controller"), this.$(".mods-controllers-staff-list").addClass("show-controller"), this.roomStaffListView.fetchUsers(), this.roomStaffListView.setClasses(), !1
- },
- displayControls: function() {
- return this.$(".mod-controllers-headers .active").removeClass("active"), this.$(".mod-controllers-headers .display-mods-controls").addClass("active"), this.$(".show-controller").removeClass("show-controller"), this.$(".mods-controllers-commands-list").addClass("show-controller"), !1
- }
- }), Dubtrack.View.RoomBanList = Backbone.View.extend({
- el: b("#mods-controllers .mods-controllers-ban-list"),
- initialize: function() {
- this.collection = new Dubtrack.Collection.RoomUser, this.collection.bind("add", this.addUser, this), this.collection.bind("remove", this.removeEl, this), this.collection.bind("reset", this.resetItems, this), this.userlistEl = this.$(".user-list"), this.$(".mods-controller-container").perfectScrollbar({
- wheelSpeed: 30,
- suppressScrollX: !0,
- wheelPropagation: !1
- })
- },
- render: function() {
- return this.collection.url = Dubtrack.config.apiUrl + Dubtrack.config.urls.roomBanUsers.replace(":id", Dubtrack.room.model.id), this.viewItems = Dubtrack.View.roomBanUsersItem, this
- },
- addUser: function(a) {
- this.appendEl(a)
- },
- resetItems: function(a) {
- this.$("li").remove()
- },
- appendEl: function(a) {
- a.viewEl = new this.viewItems({
- model: a
- }).render(), a.viewEl && this.userlistEl.append(a.viewEl.$el), this.$(".mods-controller-container").perfectScrollbar("update")
- },
- removeEl: function(a) {
- a.viewEl.close(), this.$(".mods-controller-container").perfectScrollbar("update")
- },
- fetchUsers: function() {
- this.$(".user-list li").show(), b("#mods-controllers .loading").show(), this.collection.reset(), this.collection.fetch({
- update: !0,
- success: function() {
- b("#mods-controllers .loading").hide()
- },
- error: function() {
- b("#mods-controllers .loading").hide()
- }
- })
- }
- }), Dubtrack.View.RoomMuteList = Dubtrack.View.RoomBanList.extend({
- el: b("#mods-controllers .mods-controllers-mute-list"),
- render: function() {
- return this.collection.url = Dubtrack.config.apiUrl + Dubtrack.config.urls.roomMuteUsers.replace(":id", Dubtrack.room.model.id), this.viewItems = Dubtrack.View.roomMuteUsersItem, this
- }
- }), Dubtrack.View.RoomStaffList = Dubtrack.View.RoomBanList.extend({
- el: b("#mods-controllers .mods-controllers-staff-list"),
- render: function() {
- return this.collection.url = Dubtrack.config.apiUrl + Dubtrack.config.urls.roomStaffUsers.replace(":id", Dubtrack.room.model.id), this.viewItems = Dubtrack.View.roomStaffUsersItem, this
- },
- setClasses: function() {
- this.$el.removeClass("co-owner vip resident-dj dj manager mod creator"), this.$el.addClass(Dubtrack.room.users.getRoleType(Dubtrack.session.id)), (Dubtrack.room.model.get("userid") == Dubtrack.session.id || Dubtrack.helpers.isDubtrackAdmin(Dubtrack.session.id)) && this.$el.addClass("creator")
- }
- }), Dubtrack.View.roomBanUsersItem = Backbone.View.extend({
- tagName: "li",
- events: {
- "click .actions": "clickAction"
- },
- render: function() {
- return this.$el.html(_.template(Dubtrack.els.templates.rooms.roomBanListItem, this.model.toJSON())), this
- },
- clickAction: function() {
- var a = this.model.get("_user");
- return Dubtrack.room.chat.unbanUser(a.username), this.$el.hide(), !1
- }
- }), Dubtrack.View.roomMuteUsersItem = Dubtrack.View.roomBanUsersItem.extend({
- render: function() {
- return this.$el.html(_.template(Dubtrack.els.templates.rooms.roomMuteListItem, this.model.toJSON())), this
- },
- clickAction: function() {
- var a = this.model.get("_user");
- return Dubtrack.room.chat.unmuteUser(a.username), this.$el.hide(), !1
- }
- }), Dubtrack.View.roomStaffUsersItem = Dubtrack.View.roomBanUsersItem.extend({
- render: function() {
- var a = this.model.get("roleid"),
- b = this.model.get("_user");
- return Dubtrack.session.id == b._id ? (this.close(), null) : (this.$el.html(_.template(Dubtrack.els.templates.rooms.roomStaffListItem, this.model.toJSON())), this.$el.addClass(a.type), this)
- },
- clickAction: function() {
- var a = "setModUser",
- b = this.model.get("roleid");
- switch (b.type) {
- case "co-owner":
- a = "setOwnerUser";
- break;
- case "vip":
- a = "setVIPUser";
- break;
- case "resident-dj":
- a = "setDJUser";
- break;
- case "dj":
- a = "setRoomDJUser";
- break;
- case "manager":
- a = "setManagerUser"
- }
- var c = this.model.get("_user");
- return Dubtrack.room.chat.unsetRole(c.username, a), this.$el.hide(), !1
- }
- }), Dubtrack.View.RoomListItem = Backbone.View.extend({
- tagName: "section",
- events: {
- "click a.join": "clickAction",
- "click .description": "clickAction",
- "click .image": "clickAction",
- "click .navigate": "navigate"
- },
- initialize: function() {
- this.$el.addClass("room-item")
- },
- render: function() {
- var a = this.model.toJSON();
- this.$el.html(_.template(Dubtrack.els.templates.rooms.roomListItem, a)), g.roomModel && ($id = g.roomModel.get("room.id"), $id && $id === this.model.get("id") && b(this.el).addClass("activeRoom"));
- var c = this.model.get("_user");
- return c && "object" == typeof c ? (Dubtrack.cache.users.add(c), c = new Dubtrack.Model.User(c), this.renderUser(null, c)) : Dubtrack.cache.users.get(this.model.get("userid"), this.renderUser, this), this
- },
- renderUser: function(a, b) {
- this.user = b, this.$(".user-info").show().find("a").attr("href", b.get("username")).html(b.get("username"));
- b.get("userInfo")
- },
- clickAction: function(a) {
- return Dubtrack.app.navigate("/join/" + this.model.get("roomUrl"), {
- trigger: !0
- }), !1
- },
- navigate: function(a) {
- return el = b(a.target), el.is("a") || (el = el.parents("a")), $href = el.attr("href"), $href && g.app.navigate($href, {
- trigger: !0
- }), !1
- }
- }), Dubtrack.View.Profile = Backbone.View.extend({
- el: b("#profileMainSection"),
- events: {
- "click .follow": "follow",
- "click .unfollow": "unfollow",
- "click a.readlessLink": "readLess",
- "click a.readmoreLink": "readMore",
- "click a.loadMoreWallPosts": "loadMoreWallPosts",
- "click a.navigate": "navigate",
- "click .followersCount": "loadFollowers",
- "click .followingCount": "loadFollowing",
- "click .updatePictureGif": "openGifCreator",
- "click .infoProfile h2 span.editUsername": "displayEditForm",
- "click .infoProfile h2 span.cancelUsername": "closeEditForm",
- "keyup .infoProfile h2 input": "keyUpCheckforUsername",
- "click .infoProfile h2 span.saveUsername": "updateUserName",
- "click .rewindProfile a": "closeProfile"
- },
- initialize: function() {
- this.render()
- },
- render: function() {
- this.currentPage = 0, this.$el.show();
- var a = this.model.toJSON();
- a.imgProfile = Dubtrack.helpers.image.getImage(a._id, a.username, !0), this.$el.html(_.template(Dubtrack.els.templates.profile.profileView, a)), Dubtrack.Events.bind("realtime:user-update-" + a._id, this.updateImage, this), this.socialEl = this.$("ul#ulSocial");
- this.model.get("links");
- return this.displayBarCurrent = this.$("span.progress"), this.loadingTabsEl = this.$(".tabLoading"), this.loadDetails(), this
- },
- closeProfile: function(a) {
- a && a.preventDefault(), Dubtrack.room && Dubtrack.room.model ? Dubtrack.app.navigate("/join/" + Dubtrack.room.model.get("roomUrl"), {
- trigger: !0
- }) : Dubtrack.app.navigate("/lobby", {
- trigger: !0
- })
- },
- closeEditForm: function() {
- return this.$(".infoProfile h2").removeClass("edit_username"), !1
- },
- displayEditForm: function() {
- return this.$(".infoProfile h2").addClass("edit_username"), this.$(".infoProfile h2 input").focus(), !1
- },
- keyUpCheckforUsername: function() {
- this.timeoutCheckForusername && clearTimeout(this.timeoutCheckForusername);
- var a = this;
- this.timeoutCheckForusername = setTimeout(function() {
- a.checkForUsername()
- }, 500)
- },
- updateUserName: function() {
- var a = b.trim(this.$(".infoProfile h2 input").val());
- if ("" !== a && null !== a) {
- var c = this;
- return this.$(".infoProfile h2 span.saveUsername").html(Dubtrack.config.loadingEls), b.ajax({
- url: Dubtrack.config.apiUrl + Dubtrack.config.urls.updateUsername,
- method: "post",
- xhrFields: {
- withCredentials: !0
- },
- data: {
- username: a
- }
- }).success(function(d) {
- d.data.username ? (c.$(".infoProfile h2 .check_username_info").removeClass("error").hide(), c.$(".infoProfile h2").removeClass("edit_username"), c.$(".infoProfile h2 span.usernameContainer").html(d.data.username), b(".user-header-menu button.user-info-button span").html(d.data.username), Dubtrack.session.set("username", d.data.username), Dubtrack.app.navigate("/" + d.data.username, {
- trigger: !1
- })) : c.$(".infoProfile h2 .check_username_info").html(a + " is taken").addClass("error").show()
- }).always(function() {
- c.$(".infoProfile h2 span.saveUsername").html('save <i class="icon-disk"></i>')
- }).error(function() {
- c.$(".infoProfile h2 .check_username_info").html(a + " is taken").addClass("error").show()
- }), !1
- }
- },
- checkForUsername: function() {
- var a = b.trim(this.$(".infoProfile h2 input").val());
- if ("" === a || null === a) return void this.$(".infoProfile h2 .check_username_info").hide();
- this.$(".infoProfile h2 .check_username_info").removeClass("error").hide();
- var c = this;
- b.ajax({
- url: Dubtrack.config.apiUrl + Dubtrack.config.urls.queryUsernameAvailability,
- method: "get",
- xhrFields: {
- withCredentials: !0
- },
- data: {
- username: a
- }
- }).success(function(a) {
- a.data.taken ? c.$(".infoProfile h2 .check_username_info").html(a.data.username + " is taken").addClass("error").show() : c.$(".infoProfile h2 .check_username_info").html(a.data.username + " is available").show()
- })
- },
- updateImage: function(a) {},
- updateImageWithSource: function(a) {
- var b = this.model.toJSON();
- this.$(".pictureContainer img").attr("src", "");
- var c = "http://api.dubtrack.fm/user/" + b._id + "/image/large?lastmod=" + Date.now();
- this.$(".pictureContainer img").attr("src", c)
- },
- openGifCreator: function() {
- return window.open("/imgur/index.html#&client_id=94daca23890c704", "Dubtrack FM - GIF creator", "height=590,width=340,resizable=no,location=no,scrollbars=no"), !1
- },
- navigate: function(a) {
- return $href = b(a.target).attr("href"), $href && Dubtrack.app.navigate($href, {
- trigger: !0
- }), !1
- },
- loadDetails: function() {
- this.profileSidebar = b(_.template(Dubtrack.els.templates.profile.profileSidebar, this.model.toJSON())).appendTo(this.$el), this.followersEl = this.$("#followersEl"), this.notificationsEl = this.$("#userNotifications"), this.loadFollowers()
- },
- follow: function(a) {
- var b = Dubtrack.config.apiUrl + Dubtrack.config.urls.userFollowing.replace(":id", this.model.get("_id"));
- return Dubtrack.helpers.sendRequest(b, {}, "post", function(a) {
- this.loadFollowers()
- }.bind(this)), this.$("button.unfollow").show(), this.$("button.follow").hide(), !1
- },
- unfollow: function(a) {
- var b = Dubtrack.config.apiUrl + Dubtrack.config.urls.userFollowing.replace(":id", this.model.get("_id"));
- return Dubtrack.helpers.sendRequest(b, {}, "delete", function(a) {
- this.loadFollowers()
- }.bind(this)), this.$("button.unfollow").hide(), this.$("button.follow").show(), !1
- },
- loadFollowers: function() {
- this.followersEl.find("span.active").removeClass("active"), this.$(".followersCount").addClass("active"), this.$(".followingContainer").css("left", "0"), this.$(".followingContainer .avatarFollower").empty(), this.follows = new Dubtrack.Collection.UserFollowing;
- var a = Dubtrack.config.apiUrl + Dubtrack.config.urls.userFollowing.replace(":id", this.model.get("_id"));
- this.follows.url = a;
- var b = this;
- return this.follows.reset({}), this.follows.fetch({
- success: function(a, c) {
- _.each(b.follows.models, function(a) {
- new Dubtrack.View.ProfileItemFollower({
- model: a
- }).render(a.get("userid")).$el.appendTo(b.$(".followingContainer .avatarFollower")), Dubtrack.loggedIn && a.get("userid") == Dubtrack.session.id && (b.$("button.follow").hide(), b.$("button.unfollow").show())
- }), b.$(".followingContainer .total-followers").text(b.follows.models.length)
- }
- }), !1
- },
- loadFollow: function(a, c) {
- this.ulFollowers = b("<ul/>", {
- "class": "messages wall-post-list"
- }).appendTo(b(this.el).find("div.content-main")), b.ajax({
- url: g.config.getFollowing + "id/" + this.model.get("id") + "/mode/" + a,
- data: {},
- type: "GET",
- success: function(d) {
- try {
- d.success && b.each(d.data.users, function() {
- this.img = g.helpers.getProfileImg(this.oauth_uid, this.username, this.oauth_provider), 1 === a && (this.userid = this.follow_by), b(_.template(tpl.get("followingListItem"), this)).appendTo(c)
- })
- } catch (e) {}
- },
- error: function() {}
- }, "json")
- },
- loadPlaylists: function() {
- return this.$(".contentMainProfile .active").removeClass("active"), this.$("#playlistContent").addClass("active"), this.$("li.playlistEl").addClass("active"), this.moveProgress(), !1
- },
- moveProgress: function() {
- this.displayBarCurrent.css("left", 33.33 * b(this.el).find(".contentMainProfile li.active").index() + "%")
- }
- }), Dubtrack.View.ProfileItemFollower = Backbone.View.extend({
- tagName: "li",
- initialize: function() {},
- render: function(a) {
- return Dubtrack.cache.users.get(a, this.renderUser, this), this
- },
- renderUser: function(a, b) {
- this.user = b;
- b.get("userInfo");
- this.$el.html(Dubtrack.helpers.image.getImage(b.id, b.get("username")))
- }
- }), Dubtrack.View.Message = {}, Dubtrack.View.Message.SearchUserItem = Dubtrack.View.SearchUserItem.extend({
- events: {
- click: "selectItem"
- },
- render: function(a, b) {
- return this.user = a, this.parentView = b, this.$el.attr("data-userid", a._id), this.$el.html(_.template(Dubtrack.els.templates.search.searchUser, a)), this
- },
- selectItem: function() {
- this.parentView && this.parentView.selectItem(this.user)
- }
- }), Dubtrack.View.Message.Main = Backbone.View.extend({
- el: b("#private-messages"),
- events: {
- "click .main-message-list .message-list .message-item": "loadMessagesDetails",
- "click .message-details .message-header": "loadMessages",
- "click .main-message-list .user_selected_items .result-item": "removeItem",
- "keyup input#new-message-input": "renderSearchResults",
- "click #create-new-message": "createMessage"
- },
- initialize: function() {
- this.message_main_list = new Dubtrack.View.Message.MainList, this.message_main_list_details = new Dubtrack.View.Message.MainListDetails, this.model = new Dubtrack.Model.Search, this.collectionItems = new Backbone.Collection, this.listenTo(this.collectionItems, "add", this.addUserToCreateMessage), this.model.bind("change", this.render, this), this.model.bind("reset", this.render, this), this.search_results = this.$(".search-results"), this.search_results_users = this.$(".search-results-users");
- var a = this;
- b(window).on("click", function(c) {
- var d = b(c.target).parents(".message-header");
- 0 === d.length && (a.search_results.hide(), a.$("input#new-message-input").val(""))
- })
- },
- addUserToCreateMessage: function(a) {
- var b = a.toJSON();
- b.username += " <b>remove</b>", this.$(".user_selected_items").append((new Dubtrack.View.Message.SearchUserItem).render(b, this).$el)
- },
- removeItem: function(a) {
- var c = b(a.target);
- c.is(".result-item") || (c = c.parents(".result-item"));
- var d = c.attr("data-userid");
- return d && (this.collectionItems.remove(d), this.$(".user_selected_items").empty(), _.each(this.collectionItems.models, function(a) {
- this.addUserToCreateMessage(a)
- }, this)), !1
- },
- loadMessages: function() {
- return this.collectionItems.reset(), this.$el.removeClass("view-message-details"), this.message_main_list.loadMessages(), !1
- },
- loadMessagesDetails: function(a) {
- var c = b(a.target);
- c.is("li.message-item") || (c = c.parents("li.message-item"));
- var d = c.attr("data-messageid");
- return d && (this.$el.addClass("view-message-details"), this.message_main_list_details.loadMessages(d)), !1
- },
- render: function() {
- this.search_results_users.empty();
- var a = this.model.get("users"),
- b = this;
- a && a.length > 0 ? _.each(a, function(a) {
- a._id != Dubtrack.session.get("_id") && b.appendUserItem(a)
- }) : this.search_results_users.append('<div class="result-item"><span class="count">No results found</span></div>')
- },
- appendUserItem: function(a) {
- this.search_results_users.append((new Dubtrack.View.Message.SearchUserItem).render(a, this).$el)
- },
- renderSearchResults: function(a) {
- if (c = a.which ? a.which : a.keyCode, 13 == c) return this.createMessage(), !1;
- if (9 == c) return !1;
- var d = b.trim(this.$("input#new-message-input").val());
- if ("" === d || null === d) return void this.search_results.hide();
- this.search_results.show();
- this.model.fetch({
- data: {
- query: d
- }
- })
- },
- selectItem: function(a) {
- return this.collectionItems.length > 10 ? !1 : (this.search_results.hide(), this.$("input#new-message-input").val("").focus(), void this.collectionItems.add(a))
- },
- createMessage: function() {
- if (this.collectionItems.length < 1) return !1;
- var a = [];
- return _.each(this.collectionItems.models, function(b) {
- a.push(b.get("_id"))
- }), this.createMessageIds(a), !1
- },
- createMessageIds: function(a) {
- var c = Dubtrack.config.apiUrl + Dubtrack.config.urls.messages,
- d = this;
- return b("#private-messages .loading").show(), this.$(".user_selected_items").empty(), this.collectionItems.reset(), Dubtrack.helpers.sendRequest(c, {
- usersid: a
- }, "post", function(a, c) {
- b("#private-messages .loading").hide(), c && c.data && c.data._id && (d.$el.addClass("view-message-details"), d.message_main_list_details.loadMessages(c.data._id))
- }), !1
- }
- }), Dubtrack.View.Message.MainList = Backbone.View.extend({
- el: b("#private-messages .main-message-list"),
- events: {},
- initialize: function() {
- this.collection = new Dubtrack.Collection.Message, this.listenTo(this.collection, "add", this.addMessage), this.listenTo(this.collection, "reset", this.resetMessages), this.items_container = this.$(".message-list"), this.loadPerfectScrollbar()
- },
- loadMessages: function() {
- this.$(".private-message-info").hide(), b("#private-messages .loading").show(), this.loadPerfectScrollbar(), this.main_items_loaded_check = !1;
- var a = this;
- this.collection.reset(), this.items_container.empty(), this.collection.fetch({
- update: !0,
- success: function() {
- b("#private-messages .loading").hide(), a.main_items_loaded_check = !0, 0 === a.collection.length && a.$(".private-message-info").show()
- }
- })
- },
- loadPerfectScrollbar: function() {
- this.perfectscrollbar_loaded && this.$(".message-list-wrapper-inner").perfectScrollbar("destroy"), this.perfectscrollbar_loaded = !0, this.$(".message-list-wrapper-inner").scrollTop(0), this.$(".message-list-wrapper-inner").perfectScrollbar({
- wheelSpeed: 50,
- suppressScrollX: !0,
- wheelPropagation: !1
- })
- },
- addMessage: function(a) {
- this.$(".private-message-info").hide();
- var b = new Dubtrack.View.Message.MainListItem({
- model: a
- });
- a.set("_view", b), this.main_items_loaded_check ? this.items_container.prepend(b.$el) : this.items_container.append(b.$el), this.$(".message-list-wrapper-inner").perfectScrollbar("update")
- },
- removeMessage: function(a) {
- if (this.model) {
- var b = this.model.get("_view");
- b && b.remove()
- }
- },
- resetMessages: function() {
- this.items_container.empty(), this.collection.each(this.addMessage, this)
- }
- }), Dubtrack.View.Message.MainListDetails = Dubtrack.View.Message.MainList.extend({
- el: b("#private-messages .message-details"),
- events: {
- "keydown input#message-input": "keyPressAction"
- },
- loadMessages: function(a) {
- this.messageid = a, this.main_items_loaded = !1, this.last_view = !1, this.last_model = !1, this.loadPerfectScrollbar(), this.$("input#message-input").focus(), b("#private-messages .loading").show(), this.$(".private-message-details-info").hide();
- var c = Dubtrack.config.apiUrl + Dubtrack.config.urls.messages_items.replace(":id", this.messageid);
- this.collection.url = c;
- var d = this;
- this.collection.reset(), this.collection.fetch({
- success: function() {
- b("#private-messages .loading").hide(), d.main_items_loaded = !0, d.setMessageAsRead(), 0 === d.collection.length && d.$(".private-message-details-info").show()
- }
- }), Dubtrack.Events.bind("realtime:new-message", this.newMessage, this)
- },
- setMessageAsRead: function() {
- var a = Dubtrack.config.apiUrl + Dubtrack.config.urls.messages_read.replace(":id", this.messageid);
- Dubtrack.helpers.sendRequest(a, {}, "post", function(a, b) {
- Dubtrack.layout.getNewMessages()
- })
- },
- addMessage: function(a) {
- this.$(".private-message-details-info").hide();
- var b = new Dubtrack.View.Message.MainListDetailsItem({
- model: a
- });
- a.set("_view", b), this.main_items_loaded ? this.items_container.append(b.$el) : this.items_container.prepend(b.$el), this.last_view = b, this.last_model = a, this.scollBottom()
- },
- newMessage: function(a) {
- var c = this;
- this.messageid && a.userid != Dubtrack.session.get("_id") && a.messageid == this.messageid && b("#private-messages").hasClass("view-message-details") ? this.collection.fetch({
- remove: !1,
- success: function() {
- c.setMessageAsRead()
- }
- }) : b("#private-messages").hasClass("view-message-details") || Dubtrack.layout.getNewMessages()
- },
- keyPressAction: function(a) {
- return c = a.which ? a.which : a.keyCode, 13 == c ? (this.sendMessage(), !1) : void 0
- },
- scollBottom: function() {
- this.$(".message-list-wrapper-inner").perfectScrollbar("update");
- var a = this.$(".message-list-wrapper-inner")[0].scrollHeight;
- this.$(".message-list-wrapper-inner").scrollTop(a), this.$(".message-list-wrapper-inner").perfectScrollbar("update")
- },
- sendMessage: function() {
- var a = b("<div/>").text(b.trim(this.$("input#message-input").val())).html();
- if ("" !== a && null !== a) {
- this.$("input#message-input").val(""), this.main_items_loaded = !0;
- var c = new Dubtrack.Model.MessageItem({
- created: Date.now(),
- message: a,
- userid: Dubtrack.session.get("_id"),
- messageid: "",
- _message: {},
- _user: Dubtrack.session.toJSON()
- }),
- d = Dubtrack.config.apiUrl + Dubtrack.config.urls.messages_items.replace(":id", this.messageid);
- c.urlRoot = d, c.parse = Dubtrack.helpers.parse, c.save({
- message: a
- }, {
- success: function() {
- c.set("_user", Dubtrack.session.toJSON())
- }
- }), this.collection.add(c)
- }
- }
- }), Dubtrack.View.Message.MainListItem = Backbone.View.extend({
- tagName: "li",
- className: "message-item",
- events: {},
- template: Dubtrack.els.templates.messages.message,
- initialize: function() {
- this.listenTo(this.model, "change", this.render), this.render()
- },
- render: function() {
- if (!this.model.get("name")) {
- var a = this.model.get("usersid"),
- b = [];
- if (a) {
- _.each(a, function(a) {
- a._id != Dubtrack.session.get("_id") && b.push(a.username)
- });
- var c = b.join();
- this.model.set("name", c)
- }
- }
- var d = this.model.get("usersid"),
- e = "",
- f = this.model.toJSON();
- d && (_.each(d, function(a) {
- a._id != Dubtrack.session.get("_id") && (e += '<figure class="media">' + Dubtrack.helpers.image.getImage(a._id, a.username) + "</figure>")
- }), this.$el.addClass("display-" + d.length + "-users"));
- var g = this.model.get("users_read"),
- h = !0;
- g && (_.each(g, function(a) {
- return a == Dubtrack.session.get("_id") ? void(h = !1) : void 0
- }), h ? this.$el.addClass("new-message") : this.$el.removeClass("new-message")), f.image_str = e, this.$el.attr("data-messageid", this.model.get("_id")), this.$el.html(_.template(this.template, f));
- var i = new Date(this.model.get("latest_message"));
- this.$(".message-time").html('<time class="timeago" datetime="' + i.toISOString() + '">' + i.toLocaleString() + "</time>"), this.$(".timeago").timeago()
- }
- }), Dubtrack.View.Message.MainListDetailsItem = Dubtrack.View.Message.MainListItem.extend({
- template: Dubtrack.els.templates.messages.messageItem,
- initialize: function() {
- this.render()
- },
- render: function() {
- this.$el.attr("data-messageid", this.model.get("_id")), this.model.set("message", Dubtrack.helpers.text.convertHtmltoTags(this.model.get("message"), "Dubtrack.layout.menu_right.message_view.message_main_list_details.scollBottom();")), this.model.set("message", Dubtrack.helpers.text.convertAttoLink(this.model.get("message"))), this.$el.html(_.template(this.template, this.model.toJSON()));
- var a = new Date(this.model.get("created"));
- this.$(".message-time").html('<time class="timeago" datetime="' + a.toISOString() + '">' + a.toLocaleString() + "</time>"), this.$(".timeago").timeago(), this.$("img").load(function() {
- Dubtrack.layout.menu_right.message_view.message_main_list_details.scollBottom()
- }), this.$("img").error(function() {
- b(this).attr("src", "/assets/images/media/chat_image_load_error.png")
- })
- },
- appendText: function(a, b, c) {
- var d = new Date(a);
- this.$(".message-time").html('<time class="timeago" datetime="' + d.toISOString() + '">' + d.toLocaleString() + "</time>"), this.$(".timeago").timeago(), c ? this.$(".message-content p").prepend(b + "<br>") : this.$(".message-content p").append("<br>" + b)
- }
- }), f.profile.linkCounter = 0, f.profile.editView = Backbone.View.extend({
- tagName: "div",
- events: {
- "click .close": "closeAction",
- "click .cancel": "closeAction",
- "click .btn-primary": "saveAction",
- "keyup .dt_username_input": "keyup_dtuseranme"
- },
- initialize: function() {
- b(this.el).attr("id", "dubuserForm").addClass("form")
- },
- render: function() {
- return this.formEl = b(_.template(tpl.get("profileFormUpdate"), this.model.toJSON())).appendTo(b(this.el)), this.dj_details = this.model.get("dj_details"), this.model.bind("change", this.saveModel, this), this.linkEl = b(this.el).find("#inputLinkContent"), this.username_messageEl = b(this.el).find("#username_message"), this.LinksView = new Array, this.renderLink(), this
- },
- renderLink: function() {
- var a = this.model.get("links");
- _.each(a, function(a) {
- b("<input/>", {
- "class": "input-xlarge",
- name: "updateLink[" + a.id + "]",
- value: a.link,
- type: "text"
- }).appendTo(this.linkEl)
- }, this), this.appendEl()
- },
- keyup_dtuseranme: function(a) {
- clearTimeout(this.timeout);
- var c = a.target.value;
- if (this.username_messageEl.removeClass("success error").html("dubtrack.fm/" + c), this.dj_details.username === c) return void this.username_messageEl.addClass("success");
- var d = this;
- this.timeout = setTimeout(function() {
- b.ajax({
- url: g.config.checkusername,
- data: {
- dt_username: c
- },
- type: "POST",
- success: function(a) {
- try {
- a.success ? d.username_messageEl.addClass("success").html("dubtrack.fm/" + a.data.username + " " + dubtrack_lang.profile.is_available) : d.username_messageEl.addClass("error").html("dubtrack.fm/" + a.data.username + " " + dubtrack_lang.profile.is_taken)
- } catch (b) {}
- },
- error: function() {}
- }, "json")
- }, 1e3)
- },
- appendEl: function() {
- f.profile.linkCounter++;
- var a = (new f.profile.profileInput).render(this, "", f.profile.linkCounter);
- return b(a.el).appendTo(this.linkEl), this.LinksView.push(a), !1
- },
- removeLink: function() {
- if (f.profile.linkCounter > 1) {
- var a = this.LinksView[f.profile.linkCounter - 1];
- "" === b(this.LinksView[f.profile.linkCounter - 2].el).val() && (a.close(), this.LinksView.pop(), f.profile.linkCounter--)
- }
- },
- runPlugins: function() {},
- saveAction: function() {
- return b(this.el).find(".btn-primary").html(dubtrack_lang.global.loading), this.model.set(b(this.el).find("form").serializeObject()), !1
- },
- saveModel: function() {
- var a = this;
- b.ajax({
- url: g.config.saveUserId,
- data: b(this.el).find("form").serialize(),
- type: "POST",
- success: function(c) {
- b(a.el).find(".btn-primary").html(dubtrack_lang.profile.save);
- try {
- c.success && ("username" in c.data ? (b("#header_dtusername").html(c.data.username), b("#dt_username_a").attr("href", "/" + c.data.username), g.app.navigate("/" + c.data.username, {
- trigger: !0
- })) : g.app.navigate("/" + a.dj_details.username, {
- trigger: !0
- }))
- } catch (d) {}
- },
- error: function() {}
- }, "json")
- },
- closeAction: function() {
- return this.close(), !1
- }
- }), f.profile.profileInput = Backbone.View.extend({
- tagName: "input",
- events: {
- focus: "createLink",
- blur: "removeLink"
- },
- initialize: function() {
- b(this.el).addClass("createLink input-xlarge"), b(this.el).attr({
- type: "text",
- name: "userLink[]"
- })
- },
- render: function(a, c, d) {
- return this.parentView = a, b(this.el).attr({
- value: c
- }), this.elId = d, this
- },
- createLink: function() {
- return this.elId === f.profile.linkCounter && this.parentView.appendEl(), !1
- },
- removeLink: function() {
- return this.elId === f.profile.linkCounter - 1 && this.parentView.removeLink(this.elId), !1
- }
- }), UserView = Backbone.View.extend({
- tagName: "div",
- events: {},
- initialize: function() {
- this.model.bind("add", this.appendEl, this), this.model.bind("reset", this.render, this), this.render()
- },
- render: function(a) {
- return _.each(this.model.models, function(a) {
- this.appendEl(a)
- }, this), this
- },
- appendEl: function(a, b) {}
- }), WallpostView = Backbone.View.extend({
- tagName: "ul",
- events: {},
- initialize: function() {
- this.model.bind("add", this.appendEl, this), b(this.el).addClass("messages wall-post-list")
- },
- render: function(a) {
- return this.userIdPost = a, this.replyView = (new WallPostReplyView).render(this), b(this.replyView.el).appendTo(b(this.el)), _.each(this.model.models, function(a) {
- this.appendEl(a)
- }, this), this
- },
- prependEl: function(a) {
- b(new WallpostItemView({
- model: a
- }).render().el).prependTo(b(this.el))
- },
- appendEl: function(a) {
- b(new WallpostItemView({
- model: a
- }).render().el).appendTo(b(this.el))
- }
- }), WallPostReplyView = Backbone.View.extend({
- tagName: "li",
- model: Backbone.Model.UserModel,
- paramas: {},
- urlSaveComment: "",
- events: {
- "click button": "submit"
- },
- initialize: function() {
- b(this.el).addClass("replyEl"), this.model = g.user
- },
- render: function(a) {
- return this.parentView = a, g.user.loggedIn ? (b(_.template(tpl.get("commentsReply"), this.model.toJSON())).appendTo(b(this.el)), b(this.el).find("textarea").autogrow()) : b(this.el).html('<div class="replyLogin">' + dubtrack_lang.comments.login_to_post + ' <a href="/login/facebook" class="facebook">' + dubtrack_lang.global.loginFB + '</a><a href="/login/twitter" class="twitter">' + dubtrack_lang.global.loginTW + "</a></div>"), this
- },
- submit: function(a) {
- var c = this,
- d = b(this.el).find("textarea");
- if (d.hasValue()) {
- var e = d.val();
- d.val(""), b(a.target).html("..."), b.ajax({
- url: g.config.saveWall,
- data: {
- message: e,
- post_userid: c.parentView.userIdPost
- },
- type: "POST",
- success: function(d) {
- try {
- b(a.target).html(dubtrack_lang.comments.submit);
- var e = new WallpostModel(d.data.wall_post);
- b(new WallpostItemView({
- model: e
- }).render().el).show().insertAfter(b(c.el))
- } catch (f) {}
- },
- error: function() {}
- }, "json")
- } else d.focus();
- return !1
- },
- beforeClose: function() {}
- }), WallpostItemView = Backbone.View.extend({
- tagName: "li",
- events: {
- "click a.updub": "updub",
- "click a.downdub": "downdub",
- "click a.wallremovemain": "deleteAction"
- },
- initialize: function() {},
- render: function() {
- return this.model.set({
- img: g.helpers.getProfileImg(this.model.get("oauth_uid"), this.model.get("username"), this.model.get("oauth_provider")),
- totaldubs: parseInt(this.model.get("updub")) - parseInt(this.model.get("downdub"))
- }), $type_wall = this.model.get("type_wall"), "dt_wall" === $type_wall ? ($to = this.model.get("to"), this.model.set({
- img_rel_to: g.helpers.getProfileImg($to.oauth_uid, $to.username, $to.oauth_provider)
- }), b(_.template(tpl.get("wallpostRel"), this.model.toJSON())).appendTo(b(this.el))) : b(_.template(tpl.get("wallpost"), this.model.toJSON())).appendTo(b(this.el)), b(this.el).find("div.timeago").timeago(), this.loadComments(), this
- },
- updub: function() {
- return this.dub("updub"), !1
- },
- downdub: function() {
- return this.dub("downdub"), !1
- },
- dub: function(a) {
- var c = this,
- d = b(this.el).find("span.walldubs_main"),
- e = d.html();
- return d.html("..."), b.ajax({
- url: g.config.dubWallPost,
- data: {
- id: this.model.get("id"),
- type: a
- },
- type: "POST",
- success: function(a) {
- try {
- if (a.success) {
- b(c.el).find("a.wallupdub").html(a.data.wall_post.updub), b(c.el).find("a.walldowndub").html(a.data.wall_post.downdub);
- var f = parseInt(a.data.wall_post.updub) - parseInt(a.data.wall_post.downdub);
- d.html(f), c.model.set({
- updub: a.data.wall_post.updub,
- downdub: a.data.wall_post.downdub,
- totaldubs: f
- })
- } else d.html(e)
- } catch (g) {
- d.html(e)
- }
- },
- error: function() {}
- }, "json"), !1
- },
- deleteAction: function() {
- b(this.el).fadeOut();
- var a = this;
- return b.ajax({
- url: g.config.deleteWall,
- data: {
- id: this.model.get("id")
- },
- type: "POST",
- success: function(c) {
- try {
- b(a.el).remove()
- } catch (d) {}
- },
- error: function() {}
- }, "json"), !1
- },
- loadComments: function() {
- var a = b("<div/>", {
- "class": "loading"
- }).html(dubtrack_lang.avatar.loadingComments).appendTo(b(this.el));
- this.commentsView && this.commentsView.close(), this.commentsCollection = new CommentsCollection, this.commentsCollection.url = "/api/users/getwall_comments/id/" + this.model.get("id");
- var c = {
- type: "wall_posts",
- url: this.model.get("id"),
- comment: ""
- },
- d = this;
- this.commentsCollection.fetch({
- success: function() {
- a.remove(), d.commentsView = new CommentsView({
- model: d.commentsCollection
- });
- var e = b(d.commentsView.render(g.config.saveDubComment, c).el).appendTo(b(d.el));
- e.css("minHeight", 0)
- }
- })
- },
- beforeClose: function() {}
- }), DubtrackRoute = Backbone.Router.extend({
- initialize: function() {
- b.backstretch("destroy", !1), b.backstretch("https://dubtrack-fm.s3.amazonaws.com/assets/images/backgrounds/2048.jpg"), Dubtrack.helpers.navigateHistoryTags(b("body"))
- },
- routes: {
- "(/)": "emptyRoute",
- "lobby(/)": "roomList",
- "search(/)": "roomList",
- "browser(/)": "browser",
- "browser/search(/)": "browser",
- "browser/queue(/)": "browserQueue",
- "browser/room-queue(/)": "browserRoomQueue",
- "browser/history(/)": "browserHistory",
- "browser/tracks(/)": "browserTracks",
- "browser/upload(/)": "browserUpload",
- "browser/:function/:id": "browserFunction",
- "join/:id(/)": "join",
- "dubs/:type(/)": "dubsLoader",
- "avatar/:id(/)": "avatarDisplay",
- "avatar/:id/edit(/)": "avatarEdit",
- "notifications(/)": "notifications",
- "login(/)": "login",
- "forgot(/)": "forgotPassword",
- "password(/)": "forgotPassword",
- "signup(/)": "createAccount",
- ":user(/)": "emptyRoute",
- "*notFound": "notFound"
- },
- notFound: function() {
- this.before(function() {
- Dubtrack.els.mainLoading.hide(), Dubtrack.helpers.displayError("404 - Page not found", "the requested page doesn't exist", !1)
- }).bind(this)
- },
- emptyRoute: function(a) {
- if (!a || " " === a || "_=_" === a) {
- var b = Dubtrack.helpers.cookie.get("dubtrack-room");
- return b ? this.navigate("join/" + b, {
- trigger: !0
- }) : this.roomList(), !1
- }
- switch (a) {
- case "lobby":
- this.roomList();
- break;
- case "search":
- case "browser":
- this.browser();
- break;
- case "notifications":
- this.notifications();
- break;
- default:
- this.avatarDisplay(a)
- }
- },
- containers: {},
- notifications: function() {
- var a = this;
- this.before(function() {
- document.title = dubtrack_lang.titles.notifications + " | Dubtrack.fm", b("#dt_mainplayer").addClass("inactive"), Dubtrack.els.displayloading(dubtrack_lang.notification.loading), this.notificationCollection ? (a.containers.notificationsSection.removeClass("inactive"), Dubtrack.els.mainLoading.hide()) : (a.notificationCollection = new NotificationCollection, a.notificationCollection.fetch({
- success: function(c) {
- var d = new NoticiationView({
- model: a.notificationCollection
- });
- a.containers.notificationsSection = b("<section/>", {
- "class": "dt_section",
- id: "notificationsSection"
- }).appendTo(g.config.mainSectionEl), a.notificationContainer = b(d.el).appendTo(a.containers.notificationsSection), d.render(), Dubtrack.els.mainLoading.hide()
- }
- }))
- })
- },
- roomList: function() {
- b("#create-room-div").show(), b("#edit-room-div").hide(), this.before(function() {
- document.title = dubtrack_lang.titles.lobby + " | Dubtrack.fm", Dubtrack.els.displayloading(dubtrack_lang.room.searching), Dubtrack.roomList.collection ? (Dubtrack.roomList.list_view.$el.show(), Dubtrack.roomList.collection.reset(), Dubtrack.roomList.collection.fetch({
- success: function() {
- Dubtrack.els.mainLoading.hide()
- }
- })) : (Dubtrack.roomList.collection = new Dubtrack.Collection.Room, Dubtrack.roomList.collection.fetch({
- success: function() {
- Dubtrack.roomList.list_view = new Dubtrack.View.RoomList({
- model: Dubtrack.roomList.collection
- }), Dubtrack.roomList.list_view.$el.show(), Dubtrack.els.mainLoading.hide()
- }
- }))
- })
- },
- browserQueue: function() {
- var a = this;
- this.browser(function() {
- a.browserView.displayDetails("queue")
- })
- },
- browserRoomQueue: function() {
- var a = this;
- this.browser(function() {
- a.browserView.displayDetails("room_queue")
- })
- },
- browserHistory: function() {
- var a = this;
- this.browser(function() {
- a.browserView.displayDetails("history")
- })
- },
- browserTracks: function() {
- var a = this;
- this.browser(function() {
- a.browserView.displayDetails("tracks")
- })
- },
- browserUpload: function() {
- var a = this;
- this.browser(function() {
- a.browserView.displayDetails("upload")
- })
- },
- browserFunction: function(a, b) {
- var c = this;
- switch (a) {
- case "user":
- this.browser(function() {
- c.browserView.displayDetails("user", b)
- });
- break;
- default:
- this.browser(function() {
- c.browserView.displayDetails("user", b)
- })
- }
- },
- login: function() {
- return Dubtrack.loggedIn ? void Dubtrack.app.navigate("/", {
- trigger: !0
- }) : void this.before(function() {
- Dubtrack.layout.main_login_window.displayWindow("login_window")
- })
- },
- createAccount: function() {
- return Dubtrack.loggedIn ? void Dubtrack.app.navigate("/", {
- trigger: !0
- }) : void this.before(function() {
- try {
- grecaptcha.reset()
- } catch (a) {}
- Dubtrack.layout.main_login_window.displayWindow("signup_window")
- })
- },
- forgotPassword: function() {
- return Dubtrack.loggedIn ? void Dubtrack.app.navigate("/", {
- trigger: !0
- }) : void this.before(function() {
- var a = Dubtrack.helpers.getParameterByName("token");
- a ? (Dubtrack.layout.main_login_window.change_window.token = a, Dubtrack.layout.main_login_window.displayWindow("change_window")) : Dubtrack.layout.main_login_window.displayWindow("forgot_window")
- })
- },
- browser: function(a, b) {
- if (!Dubtrack.loggedIn) return Dubtrack.els.mainLoading.hide(), Dubtrack.app.navigate("/login", {
- trigger: !0
- });
- var c = this;
- if (!Dubtrack.room.model && !b) {
- var d = Dubtrack.helpers.cookie.get("dubtrack-room");
- return void(d && this.join(d, function() {
- c.browser.call(c, a, !0)
- }))
- }
- this.browserView ? (c.browserView.displayBrowser(), a && a.call(c)) : this.loadUserPlaylists(function() {
- c.browserView = new Dubtrack.View.Browser({
- model: Dubtrack.user.playlist
- }), c.browserView.displayBrowser(), a ? a.call(c) : c.browserView.displayDetails()
- })
- },
- avatarDisplay: function(a) {
- var b = this;
- this.before(function() {
- document.title = a + " | Dubtrack.fm", Dubtrack.els.displayloading(dubtrack_lang.avatar.loading);
- var c = new Dubtrack.Model.User({
- _id: a
- });
- c.parse = Dubtrack.helpers.parse, c.fetch({
- success: function(a, d) {
- Dubtrack.els.mainLoading.hide(), d.data ? b.profileView ? (b.profileView.model = c, b.profileView.render()) : b.profileView = new Dubtrack.View.Profile({
- model: c
- }) : Dubtrack.helpers.displayError(dubtrack_lang.avatar.profileNotfound, dubtrack_lang.avatar.profileNotfound_des, !1)
- },
- error: function(a, b) {
- Dubtrack.els.mainLoading.hide();
- try {
- var c = b.statusCode();
- c && 404 == c.status ? Dubtrack.helpers.displayError("404 - Page not found", "the requested page doesn't exist", !1) : Dubtrack.helpers.displayError(dubtrack_lang.global.error, dubtrack_lang.global.error_des, !0)
- } catch (d) {
- Dubtrack.helpers.displayError(dubtrack_lang.global.error, dubtrack_lang.global.error_des, !0)
- }
- }
- })
- })
- },
- avatarEdit: function(a) {
- if (this.avatarModel) {
- var c = this.avatarModel.get("dj_details");
- if (g.user.id !== c.id) return !1;
- this.AvatarEditView = new f.profile.editView({
- model: this.avatarModel
- }).render(), b(this.AvatarEditView.el).appendTo(f.elements.body), this.AvatarEditView.runPlugins()
- } else g.app.navigate("/avatar/" + a, {
- trigger: !0
- })
- },
- loadUserPlaylists: function(a) {
- if (this.mainPlaylistCollection) a && a();
- else {
- Dubtrack.els.displayloading(dubtrack_lang.playlist.loading_playlists);
- var b = this;
- Dubtrack.user.playlist = new Dubtrack.Collection.Playlist, Dubtrack.user.playlist.fetch({
- success: function() {
- Dubtrack.els.mainLoading.hide(), a && a.call(b)
- }
- })
- }
- },
- help: function() {
- f.help.helpViewRoute && f.help.helpViewRoute.close(), f.help.helpViewRoute = (new f.help.mainView).render()
- },
- join: function(a, c, d) {
- if (b(".dubtrack-section").hide(), b("#login-model-window").hide(), b("html").removeClass("menu-left-in").removeClass("menu-right-in"), Dubtrack.room && Dubtrack.room.model) Dubtrack.room.model.get("roomUrl") === a ? (Dubtrack.room.displayRoom(), document.title = Dubtrack.room.model.get("name") + " | Dubtrack.fm", Dubtrack.session && Dubtrack.session.get("_id") === Dubtrack.room.model.get("userid") ? (b("#create-room-div").hide(), b("#edit-room-div").show()) : (b("#create-room-div").show(), b("#edit-room-div").hide())) : window.location = "/join/" + a;
- else {
- var e = this,
- f = new Dubtrack.Model.Room({
- _id: a
- });
- f.parse = Dubtrack.helpers.parse, f.fetch({
- success: function(a, b) {
- Dubtrack.els.mainLoading.hide(), Dubtrack.room = new Dubtrack.View.Room({
- model: f
- }), Dubtrack.room.render(), d || (Dubtrack.room.displayRoom(), document.title = Dubtrack.room.model.get("name") + " | Dubtrack.fm"), c && c.call(e)
- },
- error: function() {
- Dubtrack.els.mainLoading.hide(), Dubtrack.helpers.displayError(dubtrack_lang.global.error, "This room doesnt exists :("), Dubtrack.app.navigate("/lobby", {
- trigger: !0
- }), c && c.call(e)
- }
- })
- }
- },
- before: function(a, c) {
- if (b(".dubtrack-section").hide(), b("#login-model-window").hide(), b("html").removeClass("menu-left-in").removeClass("menu-right-in"), !Dubtrack.room.model) {
- var d = Dubtrack.helpers.cookie.get("dubtrack-room");
- d && this.join(d, !1, !0)
- }
- Dubtrack.views.user_popover && Dubtrack.views.user_popover.$el.hide(), a && a.call(this)
- },
- navigate: function(a, c) {
- if (c)
- if ("replace" in c) {
- if (!c.replace) try {
- ga("set", "page", a), ga("send", "pageview")
- } catch (d) {}
- } else ga("set", "page", a), ga("send", "pageview");
- return "undefined" != typeof window._atrk_fired && "undefined" != typeof window.atrk && (window._atrk_fired = !1, window.atrk()), b(".menu-expand").removeClass("active"), Backbone.Router.prototype.navigate.call(this, a, c)
- }
- }), Dubtrack.cache = {
- users: {
- collection: new Dubtrack.Collection.User,
- get: function(a, b, c) {
- if ("function" != typeof b) throw new Error("DT Cache user collection callback has to be a function");
- c || (c = this);
- var d = Dubtrack.cache.users.collection.get(a);
- return d ? b.call(c, null, d) : (d = new Dubtrack.Model.User({
- _id: a
- }), d.parse = Dubtrack.helpers.parse, void d.fetch({
- success: function() {
- Dubtrack.cache.users.collection.add(d), b.call(c, null, d)
- },
- error: function() {
- b.call(c, !0, null)
- }
- }))
- },
- getByUsername: function(a, b, c) {
- var d = Dubtrack.cache.users.collection.findWhere({
- username: a
- });
- return d ? b.call(c, null, d) : void Dubtrack.cache.users.get(a, b, c)
- },
- add: function(a) {
- var b = new Dubtrack.Model.User(a);
- return Dubtrack.cache.users.collection.add(b), b
- }
- },
- songs: {
- collection: new Dubtrack.Collection.Song,
- get: function(a, b, c) {
- if ("function" != typeof b) throw new Error("DT Cache song collection callback has to be a function");
- c || (c = this);
- var d = Dubtrack.cache.songs.collection.get(a);
- return d ? b.call(c, null, d) : (d = new Dubtrack.Model.Song({
- _id: a
- }), d.parse = Dubtrack.helpers.parse, void d.fetch({
- success: function() {
- Dubtrack.cache.songs.collection.add(d), b.call(c, null, d)
- }
- }))
- },
- add: function(a) {
- var b = new Dubtrack.Model.Song(a);
- return Dubtrack.cache.songs.collection.add(b), b
- }
- }
- }
- }(window, jQuery);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement