Created
March 13, 2012 10:06
-
-
Save alivedise/2027961 to your computer and use it in GitHub Desktop.
GS
This file has been truncated, but you can view the full file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $.Model.extend("GS.Models.Base", { | |
| cache: {}, | |
| getOneFromCache: function( a, b ) { | |
| return this.addLibraryFavoriteFlags(this.cache[_.orEqual(b, "") + a]) | |
| }, | |
| addLibraryFavoriteFlags: function( a ) { | |
| var b = this.shortName.toLowerCase() + "s"; | |
| if ( a && GS.user ) { | |
| var c = a[a.Class.id]; | |
| if ( GS.user.favorites[b] ) a.isFavorite = _.defined(GS.user.favorites[b][c]) ? 1 : 0; | |
| if ( b == "songs" && GS.user.library.songs ) a.fromLibrary = _.defined(GS.user.library.songs[c]) ? 1 : 0 | |
| } | |
| return a | |
| }, | |
| getManyFromCache: function( a, b ) { | |
| for ( var c = [], g = 0, h = a.length; g < h; g++ ) | |
| c.push(this.getOneFromCache(a[g], b)); | |
| return c | |
| }, | |
| wrap: function( a, b, c ) { | |
| var g = this.id, | |
| h = a[g]; | |
| b = _.orEqual(b, true); | |
| c = _.orEqual(c, ""); | |
| if ( h && b ) if ( h = this.getOneFromCache(h, c) ) return h; | |
| a = this.addLibraryFavoriteFlags(this._super(a)); | |
| if ( b && a[g] ) { | |
| this.cache[c + a[g]] = a; | |
| a.cachePrefix = c | |
| } | |
| return a | |
| }, | |
| wrapCollection: function( a, b, c, g, h, k ) { | |
| var m, p, n = [], | |
| o, t; | |
| b = _.orEqual(b, null); | |
| c = _.orEqual(c, false); | |
| g = _.orEqual(g, false); | |
| h = _.orEqual(h, true); | |
| k = _.orEqual(k, ""); | |
| for ( m in a ) | |
| if ( a.hasOwnProperty(m) ) { | |
| o = a[m]; | |
| t = this.wrap(o, h, k).dupe(); | |
| if ( c ) for ( p in o ) { | |
| if ( o.hasOwnProperty(p) ) t[p] = o[p] | |
| } | |
| else if ( b ) for ( p in b ) if ( b.hasOwnProperty(p) ) if ( p === "USE_INDEX" ) t[b[p]] = parseInt(m, 10) + 1; | |
| else t[p] = _.orEqual(o[p], b[p]); | |
| if (!g || !$.isFunction(t.validate) || t.validate() ) n.push(t) | |
| } | |
| n._use_call = true; | |
| return n | |
| }, | |
| wrapCollectionInObject: function( a, b, c, g, h, k ) { | |
| var m, p, n, o; | |
| b = _.orEqual(b, null); | |
| c = _.orEqual(c, false); | |
| g = _.orEqual(g, false); | |
| h = _.orEqual(h, true); | |
| k = _.orEqual(k, ""); | |
| for ( m in a ) | |
| if ( a.hasOwnProperty(m) ) { | |
| n = a[m]; | |
| (o = this.getOneFromCache(n[this.id], k)) || (o = this.wrap(n, h, k).dupe()); | |
| if ( c ) for ( p in n ) { | |
| if ( n.hasOwnProperty(p) ) o[p] = n[p] | |
| } | |
| else if ( b ) for ( p in b ) if ( b.hasOwnProperty(p) ) o[p] = _.orEqual(n[p], b[p]); | |
| if (!g || !$.isFunction(o.validate) || o.validate() ) a[m] = o; | |
| else delete a[m] | |
| } | |
| return a | |
| } | |
| }, { | |
| songs: {}, | |
| albums: {}, | |
| cachePrefix: "", | |
| dupe: function() { | |
| return new this.Class(this.attrs()) | |
| }, | |
| wrapSongCollection: function( a, b, c ) { | |
| b = GS.Models.Song.wrapCollection(a.Songs || a.songs || a.result || a, b, c, true); | |
| for ( c = 0; c < b.length; c++ ) { | |
| this.songs[b[c].SongID] = b[c]; | |
| if ( b[c].AlbumName && b[c].AlbumName.length ) { | |
| if ( this.albums[b[c].AlbumID] ) { | |
| if ( this.albums[b[c].AlbumID].ArtistName != b[c].ArtistName ) this.albums[b[c].AlbumID].ArtistName = "Various Artists" | |
| } else { | |
| album = GS.Models.Album.wrap({ | |
| AlbumName: b[c].AlbumName, | |
| AlbumID: b[c].AlbumID, | |
| ArtistName: b[c].ArtistName, | |
| ArtistID: b[c].ArtistID, | |
| CoverArtFilename: b[c].CoverArtFilename, | |
| IsVerified: b[c].IsVerified | |
| }, true, "s_"); | |
| this.albums[b[c].AlbumID] = album | |
| } | |
| this.albums[b[c].AlbumID].songs[b[c].SongID] = b[c] | |
| } | |
| } | |
| if ( a && a.hasMore ) this.currentPage++; | |
| else this.songsLoaded = true; | |
| return b | |
| }, | |
| playSongs: function( a ) { | |
| var b = _.orEqual(a.index, -1), | |
| c = _.orEqual(a.playOnAdd, false), | |
| g = _.orEqual(a.shuffle, false), | |
| h = _.orEqual(a.sort, false), | |
| k = _.orEqual(a.numericSort, false), | |
| m = new GS.Models.PlayContext((this.shortName || "").toLowerCase(), this); | |
| a.verified && _.isEmpty(this.songs) && this.getSongs(this.callback("playSongs", { | |
| index: b, | |
| playOnAdd: c, | |
| sort: "TrackNum", | |
| numericSort: true, | |
| verified: false | |
| }), null, false); | |
| b = []; | |
| var p = []; | |
| _.forEach(this.songs, function( n ) { | |
| p.push(n) | |
| }); | |
| if ( g ) p = p.shuffle(); | |
| else if ( h ) p = p.sort(function( n, o ) { | |
| if ( n.hasOwnProperty(h) && o.hasOwnProperty(h) ) { | |
| var t = n[h], | |
| w = o[h]; | |
| if ( k ) { | |
| t = | |
| parseFloat(t, 10); | |
| if ( isNaN(t) ) t = 0; | |
| w = parseFloat(w, 10); | |
| if ( isNaN(w) ) w = 0; | |
| return t - w | |
| } | |
| if ( t > w ) return 1; | |
| else if ( t < w ) return -1; | |
| return 0 | |
| } else if ( n.hasOwnProperty(h) ) return 1; | |
| return 0 | |
| }); | |
| for ( g = 0; g < p.length; g++ ) | |
| b.push(p[g].SongID); | |
| GS.player.addSongsToQueueAt(b, a.index, a.playOnAdd, m) | |
| }, | |
| getClipboardAction: function( a ) { | |
| if (!window.contextMenuClipboards ) window.contextMenuClipboards = []; | |
| return this.callback(function() { | |
| if ( ZeroClipboard && a ) { | |
| var b = $("div[id^=jjmenu_main_sub]"); | |
| $.each(a, function( c, g ) { | |
| var h = $(g.selector, b); | |
| if ( window.contextMenuClipboards[c] ) window.contextMenuClipboards[c].reposition(h.get(0)); | |
| else { | |
| window.contextMenuClipboards[c] = new ZeroClipboard.Client(h.get(0)); | |
| window.contextMenuClipboards[c].addEventListener("complete", function( k, m ) { | |
| console.log("copied: ", m); | |
| $("div[id^=jjmenu]").remove() | |
| }) | |
| } | |
| window.contextMenuClipboards[c].setText(g.text); | |
| h.bind("remove", function() { | |
| try { | |
| $.each(window.contextMenuClipboards, function( m, p ) { | |
| p.hide() | |
| }) | |
| } catch (k) {} | |
| }) | |
| }) | |
| } | |
| }) | |
| } | |
| }); | |
| (function( a ) { | |
| GS.Models.Base.extend("GS.Models.Song", { | |
| id: "SongID", | |
| cache: {}, | |
| artPath: "http://images.grooveshark.com/static/albums/", | |
| defaults: { | |
| AlbumID: null, | |
| AlbumName: "", | |
| ArtistID: null, | |
| ArtistName: "", | |
| CoverArtFilename: "", | |
| EstimateDuration: 0, | |
| Flags: 0, | |
| IsLowBitrateAvailable: 0, | |
| Popularity: "0", | |
| SongID: null, | |
| SongName: "", | |
| TrackNum: "0", | |
| Year: "0", | |
| fromLibrary: 0, | |
| isFavorite: 0, | |
| IsVerified: 0, | |
| TSAdded: "", | |
| TSFavorited: "", | |
| _token: null, | |
| tokenFailed: false | |
| }, | |
| songsLoaded: false, | |
| songsUnverifiedLoaded: false, | |
| getSong: function( b, c, g, h ) { | |
| var k = this.getOneFromCache(b), | |
| m = arguments[arguments.length - 1] === h ? {} : arguments[arguments.length - 1]; | |
| h = _.orEqual(h, false); | |
| if ( k ) a.isFunction(c) && c(k); | |
| else { | |
| h && a.publish("gs.page.loading.page"); | |
| GS.service.getQueueSongListFromSongIDs([b], this.callback(["wrapSingleSongFromIDs", c]), g, m) | |
| } | |
| }, | |
| getOneSynchronous: function( b ) { | |
| var c = this.getOneFromCache(b); | |
| if ( c ) return c; | |
| else { | |
| GS.service.getQueueSongListFromSongIDs([b], this.callback(this.wrapSingleSongFromIDs), null, { | |
| async: false | |
| }); | |
| return this.getOneFromCache(b) | |
| } | |
| }, | |
| getSongFromToken: function( b, c, g, h ) { | |
| var k = this.getOneFromCache(b); | |
| h = _.orEqual(h, true); | |
| if ( k ) c(k); | |
| else { | |
| h && a.publish("gs.page.loading.page"); | |
| GS.service.getSongFromToken(b, this.callback("wrapSongFromToken", b, c), g) | |
| } | |
| }, | |
| getVerifiedDivider: function() { | |
| var b = this.wrap({ | |
| SongID: -1, | |
| SongName: "", | |
| ArtistName: "", | |
| ArtistID: 0, | |
| AlbumName: "", | |
| AlbumID: 0, | |
| CoverArtFilename: "" | |
| }, false); | |
| b.IsVerified = 0.5; | |
| return b | |
| }, | |
| wrap: function( b, c ) { | |
| b = _.orEqual(b, {}); | |
| var g = _.orEqualEx(b.TrackNum, b.trackNum, "0").toString(), | |
| h = this._super({ | |
| AlbumID: _.orEqualEx(b.AlbumID, b.albumID, 0), | |
| AlbumName: _.cleanText(_.orEqual(b.AlbumName, b.albumName)) || "Unknown Album", | |
| ArtistID: _.orEqualEx(b.ArtistID, b.artistID, 0), | |
| ArtistName: _.cleanText(_.orEqual(b.ArtistName, b.artistName)) || "Unknown Artist", | |
| CoverArtFilename: _.orEqualEx(b.CoverArtFilename, b.artFilename, ""), | |
| EstimateDuration: _.orEqualEx(b.EstimateDuration, b.estimateDuration, 0), | |
| Flags: _.orEqualEx(b.Flags, b.flags, 0), | |
| IsLowBitrateAvailable: _.orEqualEx(b.IsLowBitrateAvailable, 0), | |
| SongID: _.orEqualEx(b.SongID, b.songID, 0), | |
| SongName: _.cleanText(_.orEqualEx(b.SongName, b.songName, b.Name)) || "Unknown Title", | |
| TrackNum: g, | |
| Year: _.cleanText(_.orEqualEx(b.Year, b.year, "0")), | |
| Popularity: _.orEqualEx(b.Popularity, b.popularity, 0), | |
| IsVerified: _.orEqual(parseFloat(b.IsVerified, 10), 0), | |
| _token: _.orEqualEx(b._token, null) | |
| }, c); | |
| if ( h.TrackNum !== g && g !== "0" ) h.TrackNum = g; | |
| if ( h.CoverArtFilename == "default.png" ) h.CoverArtFilename = null; | |
| return h | |
| }, | |
| wrapQueue: function( b ) { | |
| return this.wrapCollection(b, { | |
| Flags: 0, | |
| EstimateDuration: 0, | |
| autoplayVote: 0, | |
| parentQueueID: 0, | |
| queueSongID: 0, | |
| source: "", | |
| index: -1, | |
| context: null, | |
| sponsoredAutoplayID: 0 | |
| }, false, true, true) | |
| }, | |
| wrapSingleSongFromIDs: function( b ) { | |
| b = this.wrapCollection(b); | |
| if ( b.length ) return b[0] | |
| }, | |
| wrapSongFromToken: function( b, c, g ) { | |
| if ( a.isArray(g) ) g = {}; | |
| g = this.wrap(g); | |
| g.validate() && g.checkToken({ | |
| Token: b | |
| }); | |
| a.isFunction(c) && c(g); | |
| return g | |
| }, | |
| archive: function( b ) { | |
| return { | |
| A: b.AlbumID, | |
| B: b.AlbumName, | |
| C: b.ArtistID, | |
| D: b.ArtistName, | |
| E: b.CoverArtFilename, | |
| F: b.EstimateDuration, | |
| G: b.Flags, | |
| H: b.Popularity, | |
| I: b.SongID, | |
| J: b.SongName, | |
| K: b.TSAdded, | |
| L: b.TrackNum, | |
| M: b.Year, | |
| N: b.isFavorite | |
| } | |
| }, | |
| unarchive: function( b ) { | |
| return { | |
| AlbumID: b.A, | |
| AlbumName: b.B, | |
| ArtistID: b.C, | |
| ArtistName: b.D, | |
| CoverArtFilename: b.E, | |
| EstimateDuration: b.F, | |
| Flags: b.G, | |
| Popularity: b.H, | |
| SongID: b.I, | |
| SongName: b.J, | |
| TSAdded: b.K, | |
| TrackNum: isNaN(b.L) ? "0" : b.L, | |
| Year: isNaN(b.M) ? "0" : b.M, | |
| isFavorite: b.N | |
| } | |
| }, | |
| itemRenderer: function( b ) { | |
| var c = "" + ('<a class="name ellipsis" href="' + b.toUrl() + '">' + b.SongName + "</a>"); | |
| ['<a href="', b.toUrl(), '">', b.SongName, "</a>"].join(""); | |
| var g = ['<a href="', b.toArtistUrl(), '">', b.ArtistName, "</a>"].join(""); | |
| g = a("<span></span>").localeDataString("BY_ARTIST", { | |
| artist: g | |
| }); | |
| var h = ['<img width="70" height="70" src="', b.getImageURL(70), '"/>'].join(""); | |
| return ['<a href="', b.toUrl(), '" class="albumImage">', h, '<span class="playBtn" data-albumid="', b.AlbumID, '"></span></a><div class="meta">', c, '<span class="by">', g.render(), "</span></div>"].join("") | |
| }, | |
| slideItemRenderer: function( b ) { | |
| var c = ['<a class="slideTitle songLink ellipsis" data-songid="', b.SongID, '">' + b.SongName + "</a>"].join(""), | |
| g = ['<a href="', b.toArtistUrl(), '">', b.ArtistName, "</a>"].join(""); | |
| g = a('<span class="slideSub"></span>').localeDataString("BY_ARTIST", { | |
| artist: g | |
| }); | |
| var h = ['<img src="', b.getImageURL(200), '"/>'].join(""); | |
| return ['<div class="page_content_slide exploreSlide" data-dragtype="song" data-dragid="', b.SongID, '"><a class="slideImg songLink" data-songid="', b.SongID, '">', h, '<span href="#" class="slide_playBtn" data-songid="', b.SongID, '"></span></a>', c, g.render(), "</div>"].join("") | |
| }, | |
| matchFilter: function( b, c ) { | |
| c = _.orEqual(c, false); | |
| var g; | |
| if ( c ) { | |
| g = RegExp("^" + b, "i"); | |
| return function( h ) { | |
| h.SongName.match(g) | |
| } | |
| } else { | |
| g = RegExp(b, "gi"); | |
| return function( h ) { | |
| return h.SongName.match(g) || h.ArtistName.match(g) || h.AlbumName.match(g) | |
| } | |
| } | |
| } | |
| }, { | |
| validate: function() { | |
| if ( this.SongID > 0 && this.ArtistID > 0 && this.AlbumID > 0 ) return true; | |
| return false | |
| }, | |
| init: function( b ) { | |
| if ( b ) { | |
| this._super(b); | |
| this.SongName = _.orEqual(b.SongName, b.Name) || "Unknown Title"; | |
| this.AlbumName = b.AlbumName || "Unknown Album"; | |
| this.ArtistName = b.ArtistName || "Unknown Artist"; | |
| this.searchText = [this.SongName, this.ArtistName, this.AlbumName].join(" ").toLowerCase(); | |
| this.fanbase = false; | |
| this.songs = {}; | |
| delete this.Name | |
| } | |
| }, | |
| toUrl: function( b ) { | |
| if ( this._token ) return _.cleanUrl(this.SongName, this.SongID, "s", this._token, b); | |
| else if ( this.tokenFailed ) return _.generate404(); | |
| else { | |
| this.getToken(); | |
| return this._token ? _.cleanUrl(this.SongName, this.SongID, "s", this._token, b) : _.generate404() | |
| } | |
| }, | |
| toArtistUrl: function( b ) { | |
| return _.cleanUrl(this.ArtistName, this.ArtistID, "artist", null, b) | |
| }, | |
| toAlbumUrl: function( b ) { | |
| return _.cleanUrl(this.AlbumName, this.AlbumID, "album", null, b) | |
| }, | |
| getToken: function() { | |
| if ( this._token ) return this._token; | |
| else if ( this.tokenFailed ) return null; | |
| else { | |
| GS.service.getTokenForSong(this.SongID, this.callback(this.checkToken), this.callback(this.tokenCallFail), { | |
| async: false | |
| }); | |
| return this._token | |
| } | |
| }, | |
| checkToken: function( b ) { | |
| if ( b.Token ) { | |
| this._token = b.Token; | |
| GS.Models.Song.cache[this._token] = this; | |
| GS.Models.Song.getOneFromCache(this.SongID)._token = this._token | |
| } else this.tokenFailed = true | |
| }, | |
| tokenCallFail: function() { | |
| this._token = null | |
| }, | |
| getImageURL: function( b ) { | |
| b = _.orEqual(b, 70); | |
| var c = GS.Models.Song.artPath + b + "_album.png"; | |
| if ( this.CoverArtFilename && this.CoverArtFilename.indexOf("default") == -1 ) c = GS.Models.Song.artPath + b + "_" + this.CoverArtFilename; | |
| return c | |
| }, | |
| getDetailsForFeeds: function() { | |
| return { | |
| songID: this.SongID, | |
| songName: this.SongName, | |
| albumID: this.AlbumID, | |
| albumName: this.AlbumName, | |
| artistID: this.ArtistID, | |
| artistName: this.ArtistName, | |
| artFilename: this.CoverArtFilename, | |
| track: this.TrackNum | |
| } | |
| }, | |
| getRelatedSongs: function( b, c, g ) { | |
| g = _.orEqual(g, true); | |
| this.album ? this.album.getSongs(b, c, g) : GS.Models.Album.getAlbum(this.AlbumID, this.callback(function( h ) { | |
| this.album = h; | |
| h.getSongs(b, c, g) | |
| }), c, false) | |
| }, | |
| getAffiliateDownloadURLs: function( b ) { | |
| var c; | |
| if ( _.isEmpty(this.affiliateDownloadURLs) ) c = this; | |
| else return this.affiliateDownloadURLs; | |
| var g = []; | |
| GS.service.getAffiliateDownloadURLs(this.SongName, this.ArtistName, function( h ) { | |
| a.each(h, function( k, m ) { | |
| if ( k === "amazon" ) k = "Amazon"; | |
| g.push({ | |
| name: k, | |
| url: m.url | |
| }) | |
| }); | |
| c.affiliateDownloadURLs = g; | |
| b(c.affiliateDownloadURLs) | |
| }, function() { | |
| b({}) | |
| }) | |
| }, | |
| getContextMenu: function( b ) { | |
| b = _.orEqual(b, {}); | |
| var c; | |
| if ( b ) c = _.orEqual(b.menuType, ""); | |
| var g = GS.getGuts().extractSongItemInfo(b.gridController), | |
| h = [], | |
| k = { | |
| menuType: c, | |
| multiClick: false, | |
| gridController: b.gridController | |
| }; | |
| GS.user.library.songs[this.SongID] ? h.push({ | |
| title: a.localize.getString("CONTEXT_REMOVE_FROM_LIBRARY"), | |
| customClass: "last jj_menu_item_hasIcon jj_menu_item_remove_music", | |
| action: { | |
| type: "fn", | |
| callback: this.callback(function() { | |
| GS.user.removeFromLibrary(this.SongID); | |
| GS.getGuts().onContextMenuClick("contextRemoveFromLibrary", c, false, g) | |
| }) | |
| } | |
| }) : h.push({ | |
| title: a.localize.getString("CONTEXT_ADD_TO_LIBRARY"), | |
| customClass: "last jj_menu_item_hasIcon jj_menu_item_music", | |
| action: { | |
| type: "fn", | |
| callback: this.callback(function() { | |
| GS.user.addToLibrary(this.SongID); | |
| GS.getGuts().onContextMenuClick("contextAddToLibrary", c, false, g) | |
| }) | |
| } | |
| }); | |
| GS.user.favorites.songs[this.SongID] ? h.push({ | |
| title: a.localize.getString("CONTEXT_REMOVE_FROM_FAVORITES"), | |
| customClass: "last jj_menu_item_hasIcon jj_menu_item_remove_favorite", | |
| action: { | |
| type: "fn", | |
| callback: this.callback(function() { | |
| GS.user.removeFromSongFavorites(this.SongID); | |
| GS.getGuts().onContextMenuClick("contextRemoveFromFavorites", c, false, g) | |
| }) | |
| } | |
| }) : h.push({ | |
| title: a.localize.getString("CONTEXT_ADD_TO_FAVORITES"), | |
| customClass: "last jj_menu_item_hasIcon jj_menu_item_favorites", | |
| action: { | |
| type: "fn", | |
| callback: this.callback(function() { | |
| GS.user.addToSongFavorites(this.SongID); | |
| GS.getGuts().onContextMenuClick("contextAddToFavorites", c, false, g) | |
| }) | |
| } | |
| }); | |
| GS.user.isShortcut("song", this.SongID) ? h.push({ | |
| title: a.localize.getString("CONTEXT_REMOVE_FROM_PINBOARD"), | |
| customClass: "last jj_menu_item_hasIcon jj_menu_item_remove_music", | |
| action: { | |
| type: "fn", | |
| callback: this.callback(function() { | |
| GS.user.removeFromShortcuts("song", this.SongID); | |
| GS.getGuts().onContextMenuClick("contextRemoveFromPinboard", c, false, g) | |
| }) | |
| } | |
| }) : h.push({ | |
| title: a.localize.getString("CONTEXT_ADD_TO_PINBOARD"), | |
| customClass: "last jj_menu_item_hasIcon jj_menu_item_pinboard", | |
| action: { | |
| type: "fn", | |
| callback: this.callback(function() { | |
| GS.user.addToShortcuts("song", this.SongID, this.SongName); | |
| GS.getGuts().onContextMenuClick("contextAddToPinboard", c, false, g) | |
| }) | |
| } | |
| }); | |
| h = h.concat([{ | |
| customClass: "separator" | |
| }, | |
| { | |
| title: a.localize.getString("CONTEXT_ADD_TO_PLAYLIST"), | |
| type: "sub", | |
| customClass: "jj_menu_item_hasIcon jj_menu_item_playlists", | |
| src: GS.Models.Playlist.getPlaylistsMenu(this.SongID, this.callback(function( m ) { | |
| m.addSongs([this.SongID], null, true) | |
| }), null, null, k) | |
| }]); | |
| h.push({ | |
| customClass: "separator" | |
| }); | |
| h = h.concat([{ | |
| title: a.localize.getString("CONTEXT_SHARE_SONG"), | |
| type: "sub", | |
| customClass: "jj_menu_item_hasIcon jj_menu_item_share", | |
| src: this.getShareMenu(c, g) | |
| }, | |
| { | |
| customClass: "separator" | |
| }, | |
| { | |
| title: a.localize.getString("CONTEXT_BUY_SONG"), | |
| customClass: "last jj_menu_item_hasIcon jj_menu_item_download", | |
| action: { | |
| type: "fn", | |
| callback: this.callback(function() { | |
| GS.getLightbox().open("buySong", this.SongID); | |
| GS.getGuts().onContextMenuClick("contextBuySong", c, false, g) | |
| }) | |
| } | |
| }]); | |
| b.isQueue = _.orEqual(b.isQueue, false); | |
| if ( b.isQueue ) { | |
| h.push({ | |
| customClass: "separator" | |
| }, { | |
| title: a.localize.getString("CONTEXT_FLAG_SONG"), | |
| customClass: "last jj_menu_item_hasIcon jj_menu_item_flag", | |
| type: "sub", | |
| src: [{ | |
| title: a.localize.getString("CONTEXT_FLAG_BAD_SONG"), | |
| customClass: "last jj_menu_item_hasIcon jj_menu_item_flag", | |
| action: { | |
| type: "fn", | |
| callback: function() { | |
| b.flagSongCallback(1) | |
| } | |
| } | |
| }, | |
| { | |
| title: a.localize.getString("CONTEXT_FLAG_BAD_METADATA"), | |
| customClass: "last jj_menu_item_hasIcon jj_menu_item_flag", | |
| action: { | |
| type: "fn", | |
| callback: function() { | |
| b.flagSongCallback(4) | |
| } | |
| } | |
| }] | |
| }); | |
| (k = GS.player.getCurrentQueue()) && k.autoplayEnabled && h.push({ | |
| customClass: "separator" | |
| }, { | |
| title: a.localize.getString("QUEUE_ITEM_SMILE"), | |
| customClass: "last jj_menu_item_hasIcon jj_menu_item_smile", | |
| action: { | |
| type: "fn", | |
| callback: function() { | |
| b.voteSongCallback(1) | |
| } | |
| } | |
| }, { | |
| title: a.localize.getString("QUEUE_ITEM_FROWN"), | |
| customClass: "last jj_menu_item_hasIcon jj_menu_item_frown", | |
| action: { | |
| type: "fn", | |
| callback: function() { | |
| b.voteSongCallback(-1) | |
| } | |
| } | |
| }) | |
| } | |
| return h | |
| }, | |
| getShareMenu: function( b, c ) { | |
| var g = []; | |
| GS.user.isLoggedIn && g.push({ | |
| title: a.localize.getString("SHARE_EMAIL"), | |
| customClass: "jj_menu_item_hasIcon jj_menu_item_share_email", | |
| action: { | |
| type: "fn", | |
| callback: this.callback(function() { | |
| GS.getLightbox().open("share", { | |
| service: "email", | |
| type: "song", | |
| id: this.SongID | |
| }); | |
| GS.getGuts().onContextMenuClick("contextShareEmail", b, false, c) | |
| }) | |
| } | |
| }); | |
| return g = g.concat([{ | |
| title: a.localize.getString("SHARE_FACEBOOK"), | |
| customClass: "jj_menu_item_hasIcon jj_menu_item_share_facebook", | |
| action: { | |
| type: "fn", | |
| callback: this.callback(function() { | |
| GS.getLightbox().open("share", { | |
| service: "facebook", | |
| type: "song", | |
| id: this.SongID | |
| }); | |
| GS.getGuts().onContextMenuClick("contextShareFacebook", b, false, c) | |
| }) | |
| } | |
| }, | |
| { | |
| title: a.localize.getString("SHARE_TWITTER"), | |
| customClass: "jj_menu_item_hasIcon jj_menu_item_share_twitter", | |
| action: { | |
| type: "fn", | |
| callback: this.callback(function() { | |
| GS.getLightbox().open("share", { | |
| service: "twitter", | |
| type: "song", | |
| id: this.SongID | |
| }); | |
| GS.getGuts().onContextMenuClick("contextShareTwitter", b, false, c) | |
| }) | |
| } | |
| }, | |
| { | |
| title: a.localize.getString("SHARE_STUMBLE"), | |
| customClass: "jj_menu_item_hasIcon jj_menu_item_share_stumbleupon", | |
| action: { | |
| type: "fn", | |
| callback: this.callback(function() { | |
| window.open(_.makeUrlForShare("stumbleupon", "song", this), "_blank"); | |
| a("div[id^=jjmenu]").remove(); | |
| GS.getGuts().onContextMenuClick("contextShareStumble", b, false, c) | |
| }) | |
| } | |
| }, | |
| { | |
| title: a.localize.getString("SHARE_REDDIT"), | |
| customClass: "jj_menu_item_hasIcon jj_menu_item_share jj_menu_item_share_reddit", | |
| action: { | |
| type: "fn", | |
| callback: this.callback(function() { | |
| window.open(_.makeUrlForShare("reddit", "song", this), "_blank"); | |
| a("div[id^=jjmenu]").remove(); | |
| GS.getGuts().onContextMenuClick("contextShareReddit", b, false, c) | |
| }) | |
| } | |
| }, | |
| { | |
| title: a.localize.getString("SHARE_WIDGET"), | |
| customClass: "jj_menu_item_hasIcon jj_menu_item_share_widget", | |
| action: { | |
| type: "fn", | |
| callback: this.callback(function() { | |
| GS.getLightbox().open("share", { | |
| service: "widget", | |
| type: "song", | |
| id: this.SongID | |
| }); | |
| GS.getGuts().onContextMenuClick("contextShareWidget", b, false, c) | |
| }) | |
| } | |
| }, | |
| { | |
| title: a.localize.getString("COPY_URL"), | |
| type: "sub", | |
| action: { | |
| type: "fn", | |
| callback: this.callback(function() { | |
| this.getClipboardAction([{ | |
| text: "http://grooveshark.com/" + this.toUrl().replace("#/", ""), | |
| selector: "div.songUrl" | |
| }, | |
| { | |
| text: "http://grooveshark.com/" + _.cleanUrl(this.AlbumName, this.AlbumID, "album").replace("#/", ""), | |
| selector: "div.albumUrl" | |
| }, | |
| { | |
| text: "http://grooveshark.com/" + _.cleanUrl(this.ArtistName, this.ArtistID, "artist").replace("#/", ""), | |
| selector: "div.artistUrl" | |
| }])(); | |
| a("div[name$=Url]", elem).show() | |
| }) | |
| }, | |
| customClass: "last copyUrl jj_menu_item_hasIcon jj_menu_item_copy", | |
| src: [{ | |
| title: a.localize.getString("SONG_URL"), | |
| customClass: "songUrl jj_menu_item_hasIcon jj_menu_item_copy" | |
| }, | |
| { | |
| title: a.localize.getString("ALBUM_URL"), | |
| customClass: "albumUrl jj_menu_item_hasIcon jj_menu_item_copy" | |
| }, | |
| { | |
| title: a.localize.getString("ARTIST_URL"), | |
| customClass: " artistUrl jj_menu_item_hasIcon jj_menu_item_copy" | |
| }] | |
| }]) | |
| }, | |
| getTitle: function() { | |
| return ['"', this.SongName, '" by ', this.ArtistName, ' on "', this.AlbumName, '"'].join("") | |
| }, | |
| getVideos: function( b, c, g ) { | |
| g = _.orEqual(g, 5); | |
| GS.getYoutube().search("", g, this.callback(function( h ) { | |
| var k = []; | |
| if ( h && h[0] && h[0].VideoID ) { | |
| for ( var m = 0; m < h.length; m++ ) { | |
| h[m].title = this.ArtistName + " - " + this.SongName; | |
| k.push(h[m]) | |
| } | |
| b(k) | |
| } else { | |
| console.warn("bad youtube search items", h); | |
| c([]) | |
| } | |
| }), c, this) | |
| }, | |
| toProxyLabel: function() { | |
| return _.getString("SELECTION_SONG_SINGLE", { | |
| SongName: _.cleanText(this.SongName), | |
| ArtistName: _.cleanText(this.ArtistName) | |
| }) | |
| }, | |
| toString: function( b ) { | |
| return (b = _.orEqual(b, false)) ? ["Song. sid:", this.SongID, ", name:", this.SongName, ", aid:", this.ArtistID, ", arname: ", this.ArtistName, ", alid: ", this.AlbumID, ", alname:", this.AlbumName, ", track: ", this.TrackNum, ", verified: ", this.IsVerified].join("") : _.getString("SELECTION_SONG_SINGLE", { | |
| SongName: _.cleanText(this.SongName), | |
| ArtistName: _.cleanText(this.ArtistName) | |
| }) | |
| } | |
| }) | |
| })(jQuery); | |
| (function( a ) { | |
| GS.Models.Base.extend("GS.Models.Album", { | |
| id: "AlbumID", | |
| cache: {}, | |
| artPath: "http://images.grooveshark.com/static/albums/", | |
| smallAlbum: 5, | |
| defaults: { | |
| AlbumName: "", | |
| AlbumID: null, | |
| ArtistName: "", | |
| ArtistID: null, | |
| CoverArtFilename: "", | |
| Year: "", | |
| IsVerified: 0, | |
| PathName: false, | |
| PathNameEmpty: false, | |
| isFavorite: 0, | |
| songsLoaded: false, | |
| songsUnverifiedLoaded: false, | |
| fanbase: null | |
| }, | |
| getAlbum: function( b, c, g, h ) { | |
| var k = this.getOneFromCache(b); | |
| h = _.orEqual(h, false); | |
| if ( k ) a.isFunction(c) && c(k); | |
| else { | |
| h && a.publish("gs.page.loading.page"); | |
| GS.service.getAlbumByID(b, this.callback(["wrap", c]), g) | |
| } | |
| }, | |
| getOneSynchronous: function( b ) { | |
| var c = this.getOneFromCache(b); | |
| if ( c ) return c; | |
| else { | |
| GS.service.getAlbumByID(b, this.callback(this.wrap), null, { | |
| async: false | |
| }); | |
| return this.getOneFromCache(b) | |
| } | |
| }, | |
| getFilterAll: function( b ) { | |
| return this.wrap({ | |
| AlbumID: -1, | |
| AlbumName: a.localize.getString("ALL_ALBUMS"), | |
| ArtistName: b || "", | |
| ArtistID: -1, | |
| IsVerified: 2, | |
| isFilterAll: 1 | |
| }, false) | |
| }, | |
| defaultSongSort: function( b, c ) { | |
| var g = parseFloat(_.orEqual(b.TrackNum, 0), 10), | |
| h = parseFloat(_.orEqual(c.TrackNum, 0), 10); | |
| if ( isNaN(g) ) g = 0; | |
| if ( isNaN(h) ) h = 0; | |
| if ( g !== 0 && h === 0 ) return -1; | |
| if ( h !== 0 && g === 0 ) return 1; | |
| return g - h | |
| }, | |
| prettySort: function( b, c ) { | |
| return b.IsVerified && b.CoverArtFilename || b.IsVerified && !c.CoverArtFilename ? -1 : c.IsVerified && c.CoverArtFilename ? 1 : 0 | |
| }, | |
| itemRenderer: function( b ) { | |
| var c = "" + ('<a class="name ellipsis" href="' + b.toUrl() + '">' + b.AlbumName + "</a>"), | |
| g = ['<a href="', b.toArtistUrl(), '">', b.ArtistName, "</a>"].join(""); | |
| g = a("<span></span>").localeDataString("BY_ARTIST", { | |
| artist: g | |
| }); | |
| var h = ['<img width="70" height="70" src="', b.getImageURL(70), '"/>'].join(""), | |
| k = _.count(b.songs); | |
| k = k > 0 ? '<p class="numSongs">' + _.printf("NUM_SONGS", { | |
| numSongs: k | |
| }) + "</p>" : ""; | |
| return ['<a href="', b.toUrl(), '" class="albumImage insetBorder height70">', h, '<span class="playBtn" data-albumid="', b.AlbumID, '"></span></a><div class="meta">', c, '<span class="by">', g.render(), "</span>", k, "</div>"].join("") | |
| }, | |
| exploreItemRenderer: function( b ) { | |
| var c = "" + ('<a class="name ellipsis" href="' + b.toUrl() + '">' + b.AlbumName + "</a>"), | |
| g = ['<a href="', b.toArtistUrl(), '">', b.ArtistName, "</a>"].join(""); | |
| g = a("<span></span>").localeDataString("BY_ARTIST", { | |
| artist: g | |
| }); | |
| var h = ['<img height="120" src="', b.getImageURL(120), '"/>'].join(""), | |
| k = b.tags ? '<div class="tags"><span class="icon"></span><span class="label ellipsis">' + b.tags + "</span></div>" : ""; | |
| return ['<div class="tooltip" data-tip-type="album" data-albumid="', b.AlbumID, '" data-cachePrefix="', b.cachePrefix, '"><a href="', b.toUrl(), '" class="albumImage insetBorder height120" >', h, '<span class="playBtn" data-albumid="', b.AlbumID, '"></span></a><div class="meta">', c, '<span class="by ellipsis">', g.render(), "</span>", k, "</div></div>"].join("") | |
| }, | |
| slideItemRenderer: function( b ) { | |
| var c = "" + ('<a class="slideTitle ellipsis" href="' + b.toUrl() + '">' + b.AlbumName + "</a>"), | |
| g = ['<a href="', b.toArtistUrl(), '">', b.ArtistName, "</a>"].join(""); | |
| g = a('<span class="slideSub"></span>').localeDataString("BY_ARTIST", { | |
| artist: g | |
| }); | |
| var h = ['<img src="', b.getImageURL(200), '"/>'].join(""); | |
| return ['<div class="page_content_slide exploreSlide" data-dragtype="album" data-dragid="', b.AlbumID, '"><a href="', b.toUrl(), '" class="slideImg insetBorder height120">', h, '<span href="#" class="slide_playBtn" data-albumid="', b.AlbumID, '"></span></a>', c, g.render(), "</div>"].join("") | |
| }, | |
| wrap: function( b, c ) { | |
| b = _.orEqual(b, {}); | |
| b.ArtistName = _.cleanText(b.ArtistName) || "Unknown Artist"; | |
| b.AlbumName = _.cleanText(_.orEqual(b.AlbumName, b.Name)) || "Unknown Album"; | |
| return this._super(b, c) | |
| }, | |
| matchFilter: function( b ) { | |
| var c = RegExp(b, "gi"); | |
| return function( g ) { | |
| return g.ArtistName.match(c) || g.AlbumName.match(c) | |
| } | |
| } | |
| }, { | |
| getSongs: function( b, c, g ) { | |
| var h = arguments[arguments.length - 1] === g ? {} : arguments[arguments.length - 1]; | |
| g = _.orEqual(g, true); | |
| if ( this.songsLoaded ) { | |
| var k = this.wrapManySongs(this.songs); | |
| if (!_.isEmpty(k) || this.songsUnverifiedLoaded ) b(k); | |
| if (!g && !this.songsUnverifiedLoaded ) { | |
| this.songsUnverifiedLoaded = true; | |
| GS.service.albumGetSongs(this.AlbumID, false, 0, this.callback(["wrapManySongs", "resetAlbumInfo", b]), c, h) | |
| } | |
| } else { | |
| this.songsLoaded = true; | |
| g ? GS.service.albumGetSongs(this.AlbumID, true, 0, this.callback(["wrapManyVerifiedSongs", "resetAlbumInfo", b]), c, h) : GS.service.albumGetSongs(this.AlbumID, false, 0, this.callback(["wrapManySongs", "resetAlbumInfo", b]), c, h) | |
| } | |
| }, | |
| wrapManySongs: function( b, c ) { | |
| c = _.orEqual(c, false); | |
| return this.wrapSongCollection(b, { | |
| IsVerified: c ? 1 : 0, | |
| TrackNum: 0, | |
| AlbumName: this.AlbumName, | |
| AlbumID: this.AlbumID, | |
| CoverArtFilename: this.CoverArtFilename, | |
| Popularity: "0" | |
| }) | |
| }, | |
| wrapManyVerifiedSongs: function( b ) { | |
| return this.wrapManySongs(b, true) | |
| }, | |
| play: function( b, c, g ) { | |
| this.getSongs(this.callback("playSongs", { | |
| index: b, | |
| playOnAdd: c, | |
| sort: "TrackNum", | |
| numericSort: true, | |
| verified: true, | |
| shuffle: g | |
| })) | |
| }, | |
| resetAlbumInfo: function( b ) { | |
| for ( i = 0; i < b.length; i++ ) { | |
| b[i].AlbumName = this.AlbumName; | |
| b[i].AlbumID = this.AlbumID | |
| } | |
| return b | |
| }, | |
| validate: function() { | |
| if ( this.AlbumID > 0 && this.ArtistID > 0 ) return true; | |
| return false | |
| }, | |
| init: function( b ) { | |
| this._super(b); | |
| this.AlbumName = _.cleanText(_.orEqual(b.AlbumName, b.Name) || "Unknown Album"); | |
| if (!this.isFilterAll ) this.ArtistName = _.cleanText(b.ArtistName || "Unknown Artist"); | |
| this.fanbase = false; | |
| this.songs = {}; | |
| this.songsUnverifiedLoaded = this.songsLoaded = false; | |
| this.searchText = [this.AlbumName, this.ArtistName].join(" ").toLowerCase() | |
| }, | |
| getDetailsForFeeds: function() { | |
| return { | |
| albumID: this.AlbumID, | |
| albumName: this.AlbumName, | |
| artistID: this.ArtistID, | |
| artistName: this.ArtistName, | |
| artFilename: this.ArtFilename | |
| } | |
| }, | |
| toUrl: function( b ) { | |
| return this.PathName ? _.makeUrlFromPathName(this.PathName, b) : _.cleanUrl(this.AlbumName, this.AlbumID, "album", null, b) | |
| }, | |
| toArtistUrl: function( b ) { | |
| return _.cleanUrl(this.ArtistName, this.ArtistID, "artist", null, b) | |
| }, | |
| _onPathNameSuccess: function( b, c ) { | |
| if ( c.name ) this.PathName = c.name; | |
| else { | |
| this.PathName = ""; | |
| this.PathNameEmpty = true | |
| } | |
| a.isFunction(b) && b(this.PathName) | |
| }, | |
| _onPathNameFailed: function( b ) { | |
| this.PathName = ""; | |
| this.PathNameEmpty = true; | |
| a.isFunction(b) && b(this.PathName) | |
| }, | |
| getImageURL: function( b ) { | |
| b = _.orEqual(b, 70); | |
| var c = GS.Models.Album.artPath + b + "_album.png"; | |
| if ( this.CoverArtFilename && this.CoverArtFilename.indexOf("default") == -1 ) return GS.Models.Album.artPath + b + "_" + this.CoverArtFilename; | |
| return c | |
| }, | |
| getTitle: function() { | |
| return ['"', this.AlbumName, '" by ', this.ArtistName].join("") | |
| }, | |
| getContextMenu: function() { | |
| new GS.Models.PlayContext(GS.player.PLAY_CONTEXT_ALBUM, this); | |
| var b = [{ | |
| title: a.localize.getString("CONTEXT_PLAY_ALBUM"), | |
| action: { | |
| type: "fn", | |
| callback: this.callback(function() { | |
| this.play(GS.player.INDEX_DEFAULT, true) | |
| }) | |
| }, | |
| customClass: "jj_menu_item_hasIcon jj_menu_item_play" | |
| }, | |
| { | |
| title: a.localize.getString("CONTEXT_PLAY_ALBUM_NEXT"), | |
| action: { | |
| type: "fn", | |
| callback: this.callback(function() { | |
| this.play(GS.player.INDEX_NEXT, false) | |
| }) | |
| }, | |
| customClass: "jj_menu_item_hasIcon jj_menu_item_play_next" | |
| }, | |
| { | |
| title: a.localize.getString("CONTEXT_PLAY_ALBUM_LAST"), | |
| action: { | |
| type: "fn", | |
| callback: this.callback(function() { | |
| this.play(GS.player.INDEX_LAST, false) | |
| }) | |
| }, | |
| customClass: "jj_menu_item_hasIcon jj_menu_item_play_last" | |
| }, | |
| { | |
| customClass: "separator" | |
| }, | |
| { | |
| title: a.localize.getString("CONTEXT_REPLACE_ALL_SONGS"), | |
| action: { | |
| type: "fn", | |
| callback: this.callback(function() { | |
| this.play(GS.player.INDEX_REPLACE, GS.player.isPlaying) | |
| }) | |
| }, | |
| customClass: "jj_menu_item_hasIcon jj_menu_item_replace_playlist" | |
| }, | |
| { | |
| customClass: "separator" | |
| }]; | |
| b = b.concat([{ | |
| title: a.localize.getString("SHARE_ALBUM"), | |
| type: "sub", | |
| action: { | |
| type: "fn", | |
| callback: this.getClipboardAction([{ | |
| text: "http://grooveshark.com/" + this.toUrl().replace("#/", ""), | |
| selector: "div.albumUrl" | |
| }]) | |
| }, | |
| src: this.getShareMenu(), | |
| customClass: "jj_menu_item_hasIcon jj_menu_item_share jj_menu_item_more" | |
| }, | |
| { | |
| customClass: "separator" | |
| }]); | |
| GS.user.isShortcut("album", this.AlbumID) ? b.push({ | |
| title: a.localize.getString("CONTEXT_REMOVE_FROM_PINBOARD"), | |
| customClass: "last jj_menu_item_hasIcon jj_menu_item_remove_pinboard", | |
| action: { | |
| type: "fn", | |
| callback: this.callback(function() { | |
| GS.user.removeFromShortcuts("album", this.AlbumID) | |
| }) | |
| } | |
| }) : b.push({ | |
| title: a.localize.getString("CONTEXT_ADD_TO_PINBOARD"), | |
| customClass: "last jj_menu_item_hasIcon jj_menu_item_pinboard", | |
| action: { | |
| type: "fn", | |
| callback: this.callback(function() { | |
| GS.user.addToShortcuts("album", this.AlbumID, this.AlbumName) | |
| }) | |
| } | |
| }); | |
| return b | |
| }, | |
| getShareMenu: function() { | |
| var b = [], | |
| c = this.AlbumID; | |
| b.push({ | |
| title: a.localize.getString("SHARE_FACEBOOK"), | |
| action: { | |
| type: "fn", | |
| callback: function() { | |
| GS.getLightbox().open("share", { | |
| service: "facebook", | |
| type: "album", | |
| id: c | |
| }) | |
| } | |
| }, | |
| customClass: "jj_menu_item_hasIcon jj_menu_item_share_facebook" | |
| }, { | |
| title: a.localize.getString("SHARE_TWITTER"), | |
| action: { | |
| type: "fn", | |
| callback: function() { | |
| GS.getLightbox().open("share", { | |
| service: "twitter", | |
| type: "album", | |
| id: c | |
| }) | |
| } | |
| }, | |
| customClass: "jj_menu_item_hasIcon jj_menu_item_share_twitter" | |
| }, { | |
| title: a.localize.getString("SHARE_STUMBLE"), | |
| action: { | |
| type: "fn", | |
| callback: this.callback(function() { | |
| window.open(_.makeUrlForShare("stumbleupon", "album", this), "_blank"); | |
| a("div[id^=jjmenu]").remove() | |
| }) | |
| }, | |
| customClass: "jj_menu_item_hasIcon jj_menu_item_share_stumbleupon" | |
| }, { | |
| title: a.localize.getString("SHARE_REDDIT"), | |
| action: { | |
| type: "fn", | |
| callback: this.callback(function() { | |
| window.open(_.makeUrlForShare("reddit", "album", this), "_blank"); | |
| a("div[id^=jjmenu]").remove() | |
| }) | |
| }, | |
| customClass: "jj_menu_item_hasIcon jj_menu_item_share_reddit" | |
| }, { | |
| title: a.localize.getString("ALBUM_URL"), | |
| customClass: "albumUrl jj_menu_item_hasIcon jj_menu_item_copy" | |
| }); | |
| return b | |
| }, | |
| toProxyLabel: function() { | |
| return _.getString(this.ArtistName ? "SELECTION_ALBUM_SINGLE" : "SELECTION_ALBUM_SINGLE_NO_ARTIST", { | |
| AlbumName: _.cleanText(this.AlbumName), | |
| ArtistName: _.cleanText(this.ArtistName) | |
| }) | |
| }, | |
| toString: function( b ) { | |
| b = _.orEqual(b, false); | |
| var c = this.ArtistName ? "SELECTION_ALBUM_SINGLE" : "SELECTION_ALBUM_SINGLE_NO_ARTIST"; | |
| return b ? ["Album. alid: ", this.AlbumID, ", alname:", this.AlbumName, ", aid:", this.ArtistID, ", arname: ", this.ArtistName, ", verified: ", this.IsVerified].join("") : _.getString(c, { | |
| AlbumName: _.cleanText(this.AlbumName), | |
| ArtistName: _.cleanText(this.ArtistName) | |
| }) | |
| } | |
| }) | |
| })(jQuery); | |
| (function( a ) { | |
| GS.Models.Base.extend("GS.Models.Artist", { | |
| id: "ArtistID", | |
| cache: {}, | |
| artPath: "http://images.grooveshark.com/static/artists/", | |
| defaults: { | |
| ArtistName: "", | |
| ArtistID: null, | |
| CoverArtFilename: "", | |
| PathName: null, | |
| PathNameEmpty: false, | |
| isFavorite: 0, | |
| songsLoaded: false, | |
| eventsLoaded: false, | |
| eventIDs: [], | |
| fanbase: null, | |
| tunipopID: NaN, | |
| lastFMInfo: {} | |
| }, | |
| getArtist: function( b, c, g, h ) { | |
| var k = this.getOneFromCache(b); | |
| h = _.orEqual(h, false); | |
| if ( k ) a.isFunction(c) && c(k); | |
| else { | |
| h && a.publish("gs.page.loading.page"); | |
| GS.service.getArtistByID(b, this.callback(["wrap", c]), g) | |
| } | |
| }, | |
| getOneSynchronous: function( b ) { | |
| var c = this.getOneFromCache(b); | |
| if ( c ) return c; | |
| else { | |
| GS.service.getArtistByID(b, this.callback(this.wrap), null, { | |
| async: false | |
| }); | |
| return this.getOneFromCache(b) | |
| } | |
| }, | |
| getFilterAll: function() { | |
| return this.wrap({ | |
| ArtistID: -1, | |
| ArtistName: a.localize.getString("ALL_ARTISTS"), | |
| IsVerified: 2, | |
| isFilterAll: 1 | |
| }, false) | |
| }, | |
| defaultSongSort: function( b, c ) { | |
| var g = _.orEqual(b.AlbumName, ""), | |
| h = _.orEqual(b.AlbumName, ""); | |
| if ( g > h ) return 1; | |
| else if ( g < h ) return -1; | |
| return GS.Models.Album.defaultSongSort(b, c) | |
| }, | |
| itemRenderer: function( b ) { | |
| var c = "", | |
| g = "ARTIST_FOLLOW"; | |
| if ( b.isFavorite ) { | |
| c = "following"; | |
| g = "ARTIST_FOLLOWING" | |
| } | |
| var h = ['<a class="name ellipsis" href="', b.toUrl(), '">', b.ArtistName, "</a>"].join(""); | |
| ['<a href="', b.toUrl(), '">', b.ArtistName, "</a>"].join(""); | |
| var k = ['<img width="70" height="70" src="', b.getImageURL(), '"/>'].join(""); | |
| c = ['<button class="btn button_style2 followArtist artistID', b.ArtistID, " ", c, '" data-artistid="', b.ArtistID, '"><div><span class="icon"></span><span class="label" data-translate-text="', g, '">', a.localize.getString(g), "</span></div></button>"].join(""); | |
| return ['<a href="', b.toUrl(), '" class="artistImage insetBorder height70">', k, '</a><div class="meta">', h, c, "</div>"].join("") | |
| }, | |
| exploreItemRenderer: function( b ) { | |
| var c = "", | |
| g = ""; | |
| if ( b.isFavorite ) { | |
| c = "following"; | |
| g = a.localize.getString("UNFOLLOW") | |
| } | |
| var h = ['<a class="name ellipsis" href="', b.toUrl(), '">', b.ArtistName, "</a>"].join(""); | |
| ['<a href="', b.toUrl(), '">', b.ArtistName, "</a>"].join(""); | |
| var k = ['<img src="', b.getImageURL(120), '"/>'].join(""); | |
| c = ['<button class="followArtist artistID', b.ArtistID, " ", c, '"data-artistid="', b.ArtistID, '" title="', g, '" data-cachePrefix="' + b.cachePrefix + '"><div><span class="icon"></span></div></button>'].join(""); | |
| g = b.tags ? '<div class="tags"><span class="icon"></span><span class="label ellipsis">' + b.tags + "</span></div>" : ""; | |
| return ['<div class="tooltip" data-tip-type="artist" data-artistid="', b.ArtistID, '" data-cachePrefix="', b.cachePrefix, '"><a href="', b.toUrl(), '" class="artistImage insetBorder height120">', k, "</a>", c, '<div class="meta">', h, g, "</div></div>"].join("") | |
| }, | |
| slideItemRenderer: function( b ) { | |
| var c = "" + ('<a class="slideTitle ellipsis" href="' + b.toUrl() + '">' + b.ArtistName + "</a>"), | |
| g = ['<img src="', b.getImageURL(90), '"/>'].join(""); | |
| return ['<div class="page_content_slide exploreSlide artist tooltip" data-tip-type="artist" data-ArtistID="', b.ArtistID, '" data-dragtype="artist" data-dragid="', b.ArtistID, '"><a href="', b.toUrl(), '" class="slideImg insetBorder height120">', g, "</a>", c, "</div>"].join("") | |
| }, | |
| matchFilter: function( b ) { | |
| var c = | |
| RegExp(b, "gi"); | |
| return function( g ) { | |
| return g.ArtistName.match(c) || g.AlbumName.match(c) | |
| } | |
| } | |
| }, { | |
| smallCollection: 10, | |
| artistFeed: null, | |
| init: function( b ) { | |
| this._super(b); | |
| this.ArtistName = _.cleanText(_.orEqual(b.ArtistName, b.Name) || "Unknown Artist"); | |
| this.CoverArtFilename = _.orEqual(b.ArtistCoverArtFilename, b.CoverArtFilename); | |
| this.fanbase = false; | |
| this.songs = {}; | |
| this.albums = {}; | |
| this.songsUnverifiedLoaded = this.songsLoaded = false; | |
| this.eventIDs = []; | |
| this.eventsLoaded = false; | |
| this.searchText = this.ArtistName.toLowerCase(); | |
| this.feed = | |
| false | |
| }, | |
| loadSongs: function( b, c ) { | |
| this.allSongs ? b(this.allSongs) : GS.service.artistGetAllSongs(this.ArtistID, this.callback(function( g ) { | |
| this.allSongs = g; | |
| b(g) | |
| }), c, {}) | |
| }, | |
| getSongs: function( b, c, g ) { | |
| this.loadSongs(this.callback(function( h ) { | |
| h = this._returnFreshSongCollection(h, c); | |
| b(h) | |
| }), g) | |
| }, | |
| getAlbums: function( b, c, g ) { | |
| this.loadSongs(this.callback(function( h ) { | |
| var k = [], | |
| m = {}, | |
| p, n, o; | |
| n = 0; | |
| for ( o = h.length; n < o; n++ ) { | |
| p = h[n]; | |
| if (!m[p.AlbumID] && p.AlbumID ) { | |
| k.push({ | |
| AlbumName: p.AlbumName, | |
| AlbumID: p.AlbumID, | |
| ArtistName: p.ArtistName, | |
| ArtistID: p.ArtistID, | |
| CoverArtFilename: _.orEqualEx(p.CoverArtFilename, p.artFilename, ""), | |
| IsVerified: _.orEqual(parseFloat(p.IsVerified, 10), 0) | |
| }); | |
| m[p.AlbumID] = true | |
| } | |
| } | |
| k = k.sort(function( t, w ) { | |
| return parseFloat(t.AlbumID, 10) <= parseFloat(w.AlbumID, 10) ? -1 : 1 | |
| }); | |
| k = c(k); | |
| n = 0; | |
| for ( o = k.length; n < o; n++ ) | |
| k[n] = GS.Models.Album.wrap(k[n], false); | |
| b(k) | |
| }), g) | |
| }, | |
| wrap: function( b, c ) { | |
| b = _.orEqual(b, {}); | |
| try { | |
| delete b.AlbumID | |
| } catch (g) {} | |
| b.ArtistName = _.cleanText(b.ArtistName) || "Unknown Artist"; | |
| b.CoverArtFilename = _.orEqual(b.ArtistCoverArtFilename, b.CoverArtFilename); | |
| return this._super(b, c) | |
| }, | |
| _returnFreshSongCollection: function( b, c ) { | |
| if ( typeof c === "function" ) { | |
| b = c(b); | |
| this.songsLoaded = false | |
| } else this.songsLoaded = true; | |
| return this.wrapSongCollection(b, { | |
| Popularity: "0" | |
| }) | |
| }, | |
| getEvent: function( b, c, g ) { | |
| var h = arguments[arguments.length - 1] === g ? {} : arguments[arguments.length - 1]; | |
| g = _.orEqual(g, true); | |
| if ( this.eventsLoaded ) { | |
| h = GS.Models.Event.getManyFromCache(this.eventIDs); | |
| b(h) | |
| } else { | |
| g && a.publish("gs.page.loading.grid"); | |
| GS.service.artistGetEvents(this.ArtistID, this.ArtistName, this.callback([GS.Models.Event.wrapMany, b]), c, h) | |
| } | |
| }, | |
| cacheAndReturnEvents: function( b ) { | |
| for ( var c = GS.Models.User.wrapMany(b.Users || b.Return.fans || b.Return), g = 0; g < c.length; g++ ) { | |
| var h = c[g]; | |
| this.userIDs.push(h.UserID); | |
| GS.Models.User.cache[h.UserID] = h | |
| } | |
| if ( _.defined(b.hasMore) && b.hasMore ) this.currentPage++; | |
| else this.fansLoaded = true; | |
| return c | |
| }, | |
| _tunipopDeferred: null, | |
| getTunipopID: function() { | |
| if (!this._tunipopDeferred ) { | |
| this._tunipopDeferred = a.Deferred(); | |
| GS.service.getTunipopID(this.ArtistName, false, this.callback(this._tunipopSuccess), this.callback(this._tunipopFailed)) | |
| } | |
| return this._tunipopDeferred.promise() | |
| }, | |
| _tunipopSuccess: function( b ) { | |
| b = parseInt(b, 10); | |
| if ( isNaN(b) ) b = 0; | |
| this.tunipopID = b; | |
| this._tunipopDeferred.resolve(this.tunipopID) | |
| }, | |
| _tunipopFailed: function( b ) { | |
| console.warn("tunipop failed", this.ArtistName, b.details); | |
| this.tunipopID = 0; | |
| this._tunipopDeferred.resolve(this.tunipopID) | |
| }, | |
| validate: function() { | |
| if ( this.ArtistID > 0 ) return true; | |
| return false | |
| }, | |
| getDetailsForFeeds: function() { | |
| return { | |
| artistID: this.ArtistID, | |
| artistName: this.ArtistName, | |
| artFilename: this.CoverArtFilename | |
| } | |
| }, | |
| toUrl: function( b ) { | |
| return this.PathName ? _.makeUrlFromPathName(this.PathName, b) : _.cleanUrl(this.ArtistName, this.ArtistID, "artist", null, b) | |
| }, | |
| getPathName: function( b ) { | |
| if ( this.PathName || this.PathNameEmpty ) a.isFunction(b) && b(this.PathName); | |
| else GS.service.getPageNameByIDType(this.ArtistID, "artist", this.callback(this._onPathNameSuccess, b), this.callback(this._onPathNameFailed, b)) | |
| }, | |
| _onPathNameSuccess: function( b, c ) { | |
| if ( c.name ) this.PathName = c.name; | |
| else { | |
| this.PathName = ""; | |
| this.PathNameEmpty = true | |
| } | |
| a.isFunction(b) && b(this.PathName) | |
| }, | |
| _onPathNameFailed: function( b ) { | |
| this.PathName = ""; | |
| this.PathNameEmpty = | |
| true; | |
| a.isFunction(b) && b(this.PathName) | |
| }, | |
| getImageURL: function( b ) { | |
| b = _.orEqual(b, 70); | |
| if ( this.CoverArtFilename ) return GS.Models.Artist.artPath + b + "_" + this.CoverArtFilename; | |
| return GS.Models.Artist.artPath + b + "_artist.png" | |
| }, | |
| getTitle: function() { | |
| return this.ArtistName | |
| }, | |
| play: function( b, c, g ) { | |
| this.getSongs(this.callback("playSongs", { | |
| index: b, | |
| playOnAdd: c, | |
| verified: true, | |
| shuffle: g | |
| })) | |
| }, | |
| getArtAttribution: function( b ) { | |
| if ( this.artAttribution ) a.isFunction(b) && b(this.artAttribution); | |
| else GS.service.artistGetArtAttribution(this.ArtistID, this.callback(function( c ) { | |
| this.artAttribution = c; | |
| a.isFunction(b) && b(c) | |
| })) | |
| }, | |
| getContextMenu: function() { | |
| new GS.Models.PlayContext(GS.player.PLAY_CONTEXT_ARTIST, this); | |
| var b = [{ | |
| title: a.localize.getString("CONTEXT_PLAY_ARTIST"), | |
| action: { | |
| type: "fn", | |
| callback: this.callback(function() { | |
| this.play(GS.player.INDEX_DEFAULT, true) | |
| }) | |
| }, | |
| customClass: "jj_menu_item_hasIcon jj_menu_item_play" | |
| }, | |
| { | |
| title: a.localize.getString("CONTEXT_PLAY_ARTIST_NEXT"), | |
| action: { | |
| type: "fn", | |
| callback: this.callback(function() { | |
| this.play(GS.player.INDEX_NEXT, false) | |
| }) | |
| }, | |
| customClass: "jj_menu_item_hasIcon jj_menu_item_play_next" | |
| }, | |
| { | |
| title: a.localize.getString("CONTEXT_PLAY_ARTIST_LAST"), | |
| action: { | |
| type: "fn", | |
| callback: this.callback(function() { | |
| this.play(GS.player.INDEX_LAST, false) | |
| }) | |
| }, | |
| customClass: "jj_menu_item_hasIcon jj_menu_item_play_last" | |
| }, | |
| { | |
| customClass: "separator" | |
| }, | |
| { | |
| title: a.localize.getString("CONTEXT_REPLACE_ALL_SONGS"), | |
| action: { | |
| type: "fn", | |
| callback: this.callback(function() { | |
| this.play(GS.player.INDEX_REPLACE, GS.player.isPlaying) | |
| }) | |
| }, | |
| customClass: "jj_menu_item_hasIcon jj_menu_item_replace_playlist" | |
| }, | |
| { | |
| customClass: "separator" | |
| }]; | |
| b = b.concat([{ | |
| title: a.localize.getString("SHARE_ARTIST"), | |
| type: "sub", | |
| action: { | |
| type: "fn", | |
| callback: this.getClipboardAction([{ | |
| text: "http://grooveshark.com/" + this.toUrl().replace("#/", ""), | |
| selector: "div.artistUrl" | |
| }]) | |
| }, | |
| src: this.getShareMenu(), | |
| customClass: "jj_menu_item_hasIcon jj_menu_item_share jj_menu_item_more" | |
| }, | |
| { | |
| customClass: "separator" | |
| }]); | |
| GS.user.isShortcut("artist", this.ArtistID) ? b.push({ | |
| title: a.localize.getString("CONTEXT_REMOVE_FROM_PINBOARD"), | |
| customClass: "last jj_menu_item_hasIcon jj_menu_item_remove_pinboard", | |
| action: { | |
| type: "fn", | |
| callback: this.callback(function() { | |
| GS.user.removeFromShortcuts("artist", this.ArtistID) | |
| }) | |
| } | |
| }) : b.push({ | |
| title: a.localize.getString("CONTEXT_ADD_TO_PINBOARD"), | |
| customClass: "last jj_menu_item_hasIcon jj_menu_item_pinboard", | |
| action: { | |
| type: "fn", | |
| callback: this.callback(function() { | |
| GS.user.addToShortcuts("artist", this.ArtistID, this.ArtistName) | |
| }) | |
| } | |
| }); | |
| return b | |
| }, | |
| getShareMenu: function() { | |
| var b = [], | |
| c = this.ArtistID; | |
| b.push({ | |
| title: a.localize.getString("SHARE_FACEBOOK"), | |
| action: { | |
| type: "fn", | |
| callback: function() { | |
| GS.getLightbox().open("share", { | |
| service: "facebook", | |
| type: "artist", | |
| id: c | |
| }) | |
| } | |
| }, | |
| customClass: "jj_menu_item_hasIcon jj_menu_item_share_facebook" | |
| }, { | |
| title: a.localize.getString("SHARE_TWITTER"), | |
| action: { | |
| type: "fn", | |
| callback: function() { | |
| GS.getLightbox().open("share", { | |
| service: "twitter", | |
| type: "artist", | |
| id: c | |
| }) | |
| } | |
| }, | |
| customClass: "jj_menu_item_hasIcon jj_menu_item_share_twitter" | |
| }, { | |
| title: a.localize.getString("SHARE_STUMBLE"), | |
| action: { | |
| type: "fn", | |
| callback: this.callback(function() { | |
| window.open(_.makeUrlForShare("stumbleupon", "artist", this), "_blank"); | |
| a("div[id^=jjmenu]").remove() | |
| }) | |
| }, | |
| customClass: "jj_menu_item_hasIcon jj_menu_item_share_stumbleupon" | |
| }, { | |
| title: a.localize.getString("SHARE_REDDIT"), | |
| action: { | |
| type: "fn", | |
| callback: this.callback(function() { | |
| window.open(_.makeUrlForShare("reddit", "artist", this), "_blank"); | |
| a("div[id^=jjmenu]").remove() | |
| }) | |
| }, | |
| customClass: "jj_menu_item_hasIcon jj_menu_item_share_reddit" | |
| }, { | |
| title: a.localize.getString("ARTIST_URL"), | |
| customClass: "artistUrl jj_menu_item_hasIcon jj_menu_item_copy" | |
| }); | |
| return b | |
| }, | |
| toProxyLabel: function() { | |
| return _.cleanText(this.ArtistName) | |
| }, | |
| toString: function( b ) { | |
| return (b = | |
| _.orEqual(b, false)) ? ["Artist. aid:", this.ArtistID, ", arname: ", this.ArtistName].join("") : _.cleanText(this.ArtistName) | |
| } | |
| }) | |
| })(jQuery); | |
| (function( a ) { | |
| GS.Models.Base.extend("GS.Models.Playlist", { | |
| id: "PlaylistID", | |
| cache: {}, | |
| artPath: "http://images.grooveshark.com/static/playlists/", | |
| defaults: { | |
| PlaylistID: 0, | |
| PlaylistName: "", | |
| UserID: 0, | |
| Username: "", | |
| UserName: "", | |
| FName: "", | |
| LName: "", | |
| Description: "", | |
| NumSongs: 0, | |
| Picture: "", | |
| Sort: null, | |
| isFavorite: 0, | |
| songs: [], | |
| originalOrder: [], | |
| songsLoaded: false, | |
| hasUnsavedChanges: false, | |
| searchText: "", | |
| fanbase: null, | |
| gridKey: 1, | |
| gridKeyLookup: {}, | |
| songIDLookup: {}, | |
| isDeleted: false | |
| }, | |
| playlistsLoaded: false, | |
| playlistIDs: [], | |
| getPlaylist: function( b, c, g, h ) { | |
| var k = this.getOneFromCache(b); | |
| h = _.orEqual(h, false); | |
| if ( k ) a.isFunction(c) && c(k); | |
| else { | |
| h && a.publish("gs.page.loading.page"); | |
| GS.service.getPlaylistByID(b, this.callback(["wrap", c]), g, { | |
| async: false | |
| }) | |
| } | |
| }, | |
| getOneSynchronous: function( b ) { | |
| var c = this.getOneFromCache(b); | |
| if ( c ) return c; | |
| else { | |
| GS.service.getPlaylistByID(b, this.callback(this.wrap), null, { | |
| async: false | |
| }); | |
| return this.getOneFromCache(b) | |
| } | |
| }, | |
| getPlaylistsOrdered: function( b, c ) { | |
| c = _.orEqual(c, false); | |
| b = _.orEqual(b, "PlaylistName"); | |
| var g = []; | |
| a.each(c === false ? GS.user.playlists : GS.user.favorites.playlists, function( h, k ) { | |
| k = GS.Models.Playlist.getOneFromCache(k.PlaylistID); | |
| if ( c ) k.TSAdded = k.TSFavorited; | |
| g.push(k) | |
| }); | |
| g.sort(function( h, k ) { | |
| var m, p; | |
| try { | |
| m = h[b].toString().toLowerCase(); | |
| p = k[b].toString().toLowerCase() | |
| } catch (n) { | |
| console.warn("playlistOrdered error: " + n, b, h[b], k[b]); | |
| return 0 | |
| } | |
| return m == p ? 0 : m > p ? 1 : -1 | |
| }); | |
| return g | |
| }, | |
| getPlaylistsMenu: function( b, c, g, h, k ) { | |
| b = a.makeArray(b); | |
| var m = "", | |
| p = "", | |
| n = null; | |
| if ( k ) { | |
| m = k.menuType; | |
| p = k.multiClick; | |
| n = k.gridController | |
| } | |
| var o = {}; | |
| o = p ? GS.getGuts().extractMultiSongInfo(n, b) : GS.getGuts().extractSongItemInfo(n); | |
| g = _.orEqual(g, false); | |
| h = _.orEqual(h, true); | |
| var t; | |
| t = []; | |
| if ( h ) { | |
| t.push({ | |
| title: a.localize.getString("CONTEXT_NEW_PLAYLIST"), | |
| customClass: "jj_menu_item_hasIcon jj_menu_item_new_playlist", | |
| action: { | |
| type: "fn", | |
| callback: function() { | |
| GS.getLightbox().open("newPlaylist", b); | |
| GS.getGuts().onContextMenuClick("contextNewPlaylist", m, p, o) | |
| } | |
| } | |
| }); | |
| _.isEmpty(GS.user.playlists) || t.push({ | |
| customClass: "separator" | |
| }) | |
| } | |
| a.each(this.getPlaylistsOrdered("PlaylistName"), function( w, x ) { | |
| t.push({ | |
| title: x.PlaylistName, | |
| customClass: "jj_menu_item_hasIcon jj_menu_item_playlist", | |
| action: { | |
| type: "fn", | |
| callback: function() { | |
| c(x); | |
| GS.getGuts().onContextMenuClick("contextAddToExistingPlaylist", m, p, o, x.PlaylistID); | |
| return true | |
| } | |
| } | |
| }) | |
| }); | |
| g && a.each(this.getPlaylistsOrdered("PlaylistName", true), function( w, x ) { | |
| t.push({ | |
| title: x.PlaylistName, | |
| customClass: "jj_menu_item_hasIcon jj_menu_item_playlist_subscribed", | |
| action: { | |
| type: "fn", | |
| callback: function() { | |
| c(x) | |
| } | |
| } | |
| }) | |
| }); | |
| return t | |
| }, | |
| itemRenderer: function( b ) { | |
| var c = "", | |
| g = "PLAYLIST_SUBSCRIBE"; | |
| if ( b.isFavorite ) { | |
| c = "subscribed"; | |
| g = "PLAYLIST_UNSUBSCRIBE" | |
| } | |
| var h = ['<a href="', b.toUserUrl(), '">', b.UserName, "</a>"].join(""); | |
| h = a("<span></span>").localeDataString("BY_ARTIST", { | |
| artist: h | |
| }); | |
| var k = ['<span class="lineHeight"><a class="name ellipsis" href="', b.toUrl(), '">' + b.PlaylistName + "</a></span>"].join(""), | |
| m = ['<a href="', b.toUrl(), '"class="playlistImage insetBorder height70"><img width="70" height="70" src="', b.getImageURL(), '"/></a>'].join(""); | |
| b = b.UserID === GS.user.UserID ? "" : ['<button class="btn button_style2 ', c, '" data-follow-userid="', b.UserID, '" ><div><span class="label" data-translate-text="', g, '">', a.localize.getString(g), "</span></div></button>"].join(""); | |
| return [m, '<div class="meta">', k, '<span class="ellipsis by">', h.render(), "</span>", b, "</div>"].join("") | |
| }, | |
| exploreItemRenderer: function( b ) { | |
| var c = "" + ('<a class="name ellipsis" href="' + b.toUrl() + '">' + b.PlaylistName + "</a>"), | |
| g; | |
| g = b.uri && b.uri.length > 6 && b.uri !== "" ? b.uri.indexOf("grooveshark.com") == -1 ? _.printf("BY_USER", { | |
| user: '<a href="' + b.uri + '" target="_blank">' + b.attributor + "</a>" | |
| }) : _.printf("BY_USER", { | |
| user: '<a href="' + b.uri + '">' + b.attributor + "</a>" | |
| }) : _.printf("BY_USER", { | |
| user: b.attributor | |
| }); | |
| var h = ['<img height="120" src="', b.hasCustomImage ? GS.Models.Explore.IMG_PATH + "120_" + b.Picture : b.getImageURL(200), '"/>'].join(""), | |
| k = b.tags ? '<div class="tags"> <span class="icon"></span> <span class="label ellipsis" title="' + b.tags + '">' + b.tags + "</span></div>" : ""; | |
| return ['<div class="tooltip" data-tip-type="playlist" data-playlistID="', b.PlaylistID, '" data-cachePrefix="', b.cachePrefix, '"><a href="', b.toUrl(), '" class="playlistImage insetBorder height120">', h, '<span class="playBtn" data-playlistid="', b.PlaylistID, '"></span></a><div class="meta">', c, '<span class="by ellipsis">', g, "</span>", k, "</div></div>"].join("") | |
| }, | |
| prettySort: function( b, c ) { | |
| return b.Picture || !c.Picture ? -1 : c.Picture ? 1 : 0 | |
| }, | |
| matchFilter: function( b ) { | |
| var c = RegExp(b, "gi"); | |
| return function( g ) { | |
| return g.PlaylistName.match(c) || g.UserName.match(c) | |
| } | |
| } | |
| }, { | |
| init: function( b ) { | |
| this._super(b); | |
| this.PlaylistName = _.defined(b.PlaylistName) ? _.cleanText(b.PlaylistName) : _.cleanText(b.Name); | |
| this.Description = _.orEqual(b.Description, b.About || ""); | |
| this.Username = this.Username && this.Username.length ? this.Username : b.Username; | |
| this.UserName = _.cleanText(a.trim(this.FName + (this.LName && this.LName.length ? " " + this.LName : ""))); | |
| this.fanbase = false; | |
| this.searchText = [this.PlaylistName, this.FName, this.Description].join(" ").toLowerCase(); | |
| this.songs = []; | |
| this.albums = {}; | |
| this.originalOrder = []; | |
| this.images = []; | |
| this.songsLoaded = _.orEqual(b.songsLoaded, false); | |
| this.hasUnsavedChanges = false; | |
| delete this.Name; | |
| delete this.About | |
| }, | |
| getSongs: function( b, c, g ) { | |
| var h = arguments[arguments.length - 1] === g ? {} : arguments[arguments.length - 1]; | |
| g = _.orEqual(g, true); | |
| if ( this.songsLoaded ) { | |
| this._updateSongs(); | |
| b(this.songs) | |
| } else { | |
| g && a.publish("gs.page.loading.grid"); | |
| GS.service.playlistGetSongs(this.PlaylistID, this.callback(["wrapManySongs", b]), c, h) | |
| } | |
| }, | |
| validate: function() { | |
| if ( this.PlaylistID > 0 ) return true; | |
| return false | |
| }, | |
| wrapManySongs: function( b ) { | |
| var c = []; | |
| if ( this.hasUnsavedChanges ) c = this.songs; | |
| var g = b.Songs || b.songs || b.result || b; | |
| this.songs = []; | |
| this.gridKeyLookup = {}; | |
| this.songIDLookup = {}; | |
| var h; | |
| g.sort(function( k, m ) { | |
| return parseFloat(k.Sort, 10) - parseFloat(m.Sort, 10) | |
| }); | |
| for ( h = 0; h < g.length; h++ ) { | |
| b = GS.Models.Song.wrap(g[h]).dupe(); | |
| b.Sort = h; | |
| b.GridKey = this.gridKey; | |
| if (!this.albums[b.AlbumID] ) { | |
| album = GS.Models.Album.wrap({ | |
| AlbumName: b.AlbumName, | |
| AlbumID: b.AlbumID, | |
| ArtistName: b.ArtistName, | |
| ArtistID: b.ArtistID, | |
| CoverArtFilename: b.CoverArtFilename, | |
| IsVerified: b.IsVerified | |
| }, false); | |
| this.albums[b.AlbumID] = album | |
| } | |
| this.songs.push(b); | |
| this.gridKeyLookup[b.GridKey] = | |
| b; | |
| this.songIDLookup[b.SongID] = b; | |
| this.gridKey++ | |
| } | |
| for ( g = 0; g < c.length; g++ ) { | |
| b = c[g]; | |
| b.Sort = g + h; | |
| b.GridKey = this.gridKey; | |
| c[g] = b; | |
| this.gridKeyLookup[b.GridKey] = b; | |
| this.songIDLookup[b.SongID] = b; | |
| this.gridKey++ | |
| } | |
| this.originalOrder = this.songs.concat(); | |
| this.songs = this.songs.concat(c); | |
| this.songsLoaded = true; | |
| a.publish("gs.playlist.songs.update", this); | |
| a.publish("gs.playlist.view.update", this); | |
| this.songs._use_call = true; | |
| return this.songs | |
| }, | |
| _updateSongs: function() { | |
| var b, c, g = GS.Models.Song; | |
| for ( b = 0; b < this.songs.length; b++ ) { | |
| c = | |
| g.getOneFromCache(this.songs[b].SongID); | |
| this.songs[b].isFavorite = c.isFavorite; | |
| this.songs[b].fromLibrary = c.fromLibrary | |
| } | |
| }, | |
| reapplySorts: function() { | |
| for ( var b = 0; b < this.songs.length; b++ ) | |
| this.songs[b].Sort = b | |
| }, | |
| play: function( b, c, g ) { | |
| this.getSongs(this.callback("playSongs", { | |
| index: b, | |
| playOnAdd: c, | |
| shuffle: g | |
| }), null, false) | |
| }, | |
| playSongs: function( b ) { | |
| _.orEqual(b.index, -1); | |
| _.orEqual(b.playOnAdd, false); | |
| var c = _.orEqual(b.shuffle, false); | |
| _.orEqual(b.sort, false); | |
| var g = new GS.Models.PlayContext(GS.player.PLAY_CONTEXT_PLAYLIST, this), | |
| h = []; | |
| if ( c ) { | |
| var k = this.songs.shuffle(); | |
| for ( c = 0; c < k.length; c++ ) | |
| h.push(k[c].SongID) | |
| } else for ( c = 0; c < this.songs.length; c++ ) h.push(this.songs[c].SongID); | |
| GS.player.addSongsToQueueAt(h, b.index, b.playOnAdd, g) | |
| }, | |
| getImageURL: function( b ) { | |
| b = _.orEqual(b, 200); | |
| var c = GS.Models.Playlist.artPath + b + "_playlist.png"; | |
| if ( this.Picture ) c = GS.Models.Playlist.artPath + b + "_" + this.Picture; | |
| return c | |
| }, | |
| getDefaultImageUrl: function( b ) { | |
| return GS.Models.Playlist.artPath + b + "_playlist.png" | |
| }, | |
| getPlaylistArt: function( b ) { | |
| b = _.orEqual(b, 200); | |
| if ( this.Picture ) return [GS.Models.Playlist.artPath + b + "_" + this.Picture]; | |
| var c = [], | |
| g = {}, | |
| h = []; | |
| _.forEach(this.songs, function( m ) { | |
| if ( m.CoverArtFilename ) if ( g.hasOwnProperty(m.AlbumID) ) g[m.AlbumID].weight++; | |
| else g[m.AlbumID] = { | |
| CoverArtFilename: m.CoverArtFilename, | |
| weight: 1 | |
| } | |
| }); | |
| for ( var k in g ) | |
| g.hasOwnProperty(k) && h.push([k, g[k]]); | |
| h = h.sort(function( m, p ) { | |
| return p[1].weight - m[1].weight | |
| }).slice(0, 4); | |
| if ( h.length >= 4 ) b = 90; | |
| for ( k = 0; k < h.length && k < 4; ++k ) | |
| c.push(GS.Models.Album.artPath + b + "_" + h[k][1].CoverArtFilename); | |
| return c.length ? c : [this.getDefaultImageUrl(b)] | |
| }, | |
| _addSongAtEnd: function( b ) { | |
| this.hasUnsavedChanges && this.addSongs([b], this.songs.length, true); | |
| if ( GS.user.UserID != this.UserID ) return false; | |
| if (!(b <= 0)) { | |
| GS.getGuts().logEvent("songAddedToPlaylist", { | |
| songID: b | |
| }); | |
| if ( this.songsLoaded ) { | |
| var c; | |
| c = GS.Models.Song.getOneFromCache(b).dupe(); | |
| c.GridKey = this.gridKey; | |
| this.gridKeyLookup[c.GridKey] = c; | |
| this.songIDLookup[c.SongID] = c; | |
| this.gridKey++; | |
| this.hasUnsavedChanges = true; | |
| GS.Controllers.PageController.ALLOW_LOAD = false; | |
| this.songs.push(c); | |
| this.reapplySorts(); | |
| GS.user.isLoggedIn ? GS.service.playlistAddSongToExisting(this.PlaylistID, b, this.callback("saveSuccess"), this.callback("saveFailed")) : this.saveSuccess(); | |
| a.publish("gs.playlist.view.update", this) | |
| } else if ( GS.user.isLoggedIn ) GS.service.playlistAddSongToExisting(this.PlaylistID, b, this.callback("addSongSuccess"), this.callback("saveFailed")); | |
| else return false | |
| } | |
| }, | |
| addSongs: function( b, c, g ) { | |
| c = _.orEqual(c, this.songs.length); | |
| g = _.orEqual(g, false); | |
| if ( this.songsLoaded && b.length + this.songs.length > 2500 ) { | |
| b = (new GS.Models.DataString(a.localize.getString("POPUP_FAIL_ADD_PLAYLIST_TOO_MANY_MSG"), { | |
| playlist: this.PlaylistName, | |
| numSongs: b.length | |
| })).render(); | |
| a.publish("gs.notification", { | |
| type: "error", | |
| message: b | |
| }) | |
| } else if ( b.length == 1 && !this.hasUnsavedChanges && g && c == this.songs.length ) this._addSongAtEnd(b[0]); | |
| else { | |
| if ( GS.user.UserID != this.UserID ) return false; | |
| for ( var h, k = [], m = 0; m < b.length; m++ ) | |
| if (!(b[m] <= 0)) { | |
| h = GS.Models.Song.getOneFromCache(b[m]).dupe(); | |
| h.GridKey = this.gridKey; | |
| this.gridKeyLookup[h.GridKey] = h; | |
| this.songIDLookup[h.SongID] = h; | |
| this.gridKey++; | |
| k.push(h); | |
| GS.getGuts().logEvent("songAddedToPlaylist", { | |
| songID: h.SongID | |
| }) | |
| } | |
| this.hasUnsavedChanges = true; | |
| GS.Controllers.PageController.ALLOW_LOAD = false; | |
| this.songs.splice.apply(this.songs, [c, 0].concat(k)); | |
| this.reapplySorts(); | |
| g && this.save(); | |
| a.publish("gs.playlist.view.update", this) | |
| } | |
| }, | |
| removeSongs: function( b, c ) { | |
| if ( GS.user.UserID != this.UserID ) return false; | |
| c = _.orEqual(c, false); | |
| this.hasUnsavedChanges = true; | |
| GS.Controllers.PageController.ALLOW_LOAD = false; | |
| for ( var g, h = 0; h < b.length; h++ ) | |
| if ( g = this.songs[b[h]] ) g.isDeleted = true; | |
| this.reapplySorts(); | |
| c && this.save(); | |
| a.publish("gs.playlist.view.update", this) | |
| }, | |
| overwriteWithSongs: function( b, c ) { | |
| if ( GS.user.UserID != this.UserID ) return false; | |
| c = _.orEqual(c, false); | |
| this.songs = []; | |
| for ( var g = 0; g < b.length; g++ ) | |
| if (!(b[g] <= 0)) { | |
| song = GS.Models.Song.getOneFromCache(b[g]).dupe(); | |
| song.GridKey = this.gridKey; | |
| this.gridKeyLookup[song.GridKey] = song; | |
| this.songIDLookup[song.SongID] = song; | |
| this.gridKey++; | |
| this.songs.push(song) | |
| } | |
| this.reapplySorts(); | |
| this.hasUnsavedChanges = this.songsLoaded = true; | |
| GS.Controllers.PageController.ALLOW_LOAD = false; | |
| c && this.save(); | |
| a.publish("gs.playlist.view.update", this) | |
| }, | |
| moveSongsTo: function( b, c, g ) { | |
| if ( GS.user.UserID != this.UserID ) return false; | |
| g = _.orEqual(g, false); | |
| this.hasUnsavedChanges = true; | |
| GS.Controllers.PageController.ALLOW_LOAD = false; | |
| var h, k = []; | |
| for ( h = 0; h < b.length; h++ ) | |
| k.push(this.songs[b[h]]); | |
| for ( h = 0; h < k.length; h++ ) { | |
| b = this.songs.indexOf(k[h]); | |
| this.songs.splice(b, 1); | |
| b < c && c-- | |
| } | |
| this.songs.splice.apply(this.songs, [c, 0].concat(k)); | |
| this.reapplySorts(); | |
| g && this.save(); | |
| a.publish("gs.playlist.view.update", this) | |
| }, | |
| save: function() { | |
| if ( this.songsLoaded ) { | |
| var b, c = [], | |
| g = []; | |
| for ( b = | |
| 0; b < this.songs.length; b++ ) | |
| this.songs[b].isDeleted ? GS.getGuts().logEvent("songRemovedFromPlaylist", { | |
| songID: this.songs[b].SongID | |
| }) : c.push(this.songs[b].SongID); | |
| for ( b = 0; b < this.originalOrder.length; b++ ) | |
| g.push(this.originalOrder[b].SongID); | |
| if ( c.join(".") == g.join(".") ) { | |
| this.originalOrder = this.songs.concat(); | |
| this.hasUnsavedChanges = false; | |
| GS.Controllers.PageController.ALLOW_LOAD = true; | |
| a.publish("gs.playlist.view.update", this) | |
| } else { | |
| GS.user.isLoggedIn ? GS.service.overwritePlaylist(this.PlaylistID, this.PlaylistName, c, this.callback("saveSuccess"), this.callback("saveFailed")) : this.saveSuccess(); | |
| GS.getGuts().gaTrackEvent("playlist", "savePlaylist") | |
| } | |
| } else this.getSongs(this.callback("save"), this.callback("saveFailed"), false) | |
| }, | |
| saveSuccess: function() { | |
| for ( var b = [], c = 0; c < this.songs.length; c++ ) | |
| this.songs[c].isDeleted || b.push(this.songs[c]); | |
| this.songsLoaded = true; | |
| this.songs = b; | |
| this.originalOrder = this.songs.concat(); | |
| this.hasUnsavedChanges = false; | |
| GS.Controllers.PageController.ALLOW_LOAD = true; | |
| b = (new GS.Models.DataString(a.localize.getString("POPUP_SAVE_PLAYLIST_MSG"), { | |
| playlist: this.PlaylistName | |
| })).render(); | |
| a.publish("gs.notification", { | |
| type: "notice", | |
| message: b | |
| }); | |
| a.publish("gs.playlist.songs.update", this); | |
| a.publish("gs.playlist.view.update", this) | |
| }, | |
| addSongSuccess: function() { | |
| var b = (new GS.Models.DataString(a.localize.getString("POPUP_SAVE_PLAYLIST_MSG"), { | |
| playlist: this.PlaylistName | |
| })).render(); | |
| a.publish("gs.notification", { | |
| type: "notice", | |
| message: b | |
| }); | |
| a.publish("gs.playlist.songs.update", this); | |
| a.publish("gs.playlist.view.update", this) | |
| }, | |
| saveFailed: function() { | |
| a.publish("gs.notification", { | |
| type: "error", | |
| message: a.localize.getString("POPUP_FAIL_SAVE_PLAYLIST_MSG") | |
| }) | |
| }, | |
| remove: function( b ) { | |
| GS.user.deletePlaylist(this.PlaylistID, b); | |
| GS.getGuts().logEvent("playlistDeleted", { | |
| playlistID: this.PlaylistID | |
| }) | |
| }, | |
| restore: function( b ) { | |
| GS.user.restorePlaylist(this.PlaylistID, b) | |
| }, | |
| undo: function() { | |
| this.songs = this.originalOrder.concat(); | |
| for ( var b = 0; b < this.songs.length; b++ ) | |
| this.songs[b].isDeleted = false; | |
| this.hasUnsavedChanges = false; | |
| GS.Controllers.PageController.ALLOW_LOAD = true; | |
| this.reapplySorts(); | |
| a.publish("gs.playlist.songs.update", this); | |
| a.publish("gs.playlist.view.update", this) | |
| }, | |
| rename: function( b, c, g ) { | |
| GS.service.renamePlaylist(this.PlaylistID, b, this.callback([this._renameSuccess, c], b), this.callback([this._renameFailed, g])) | |
| }, | |
| _renameSuccess: function( b, c ) { | |
| this.PlaylistName = b; | |
| var g = this.Class.getOneFromCache(this.PlaylistID); | |
| if ( g ) g.PlaylistName = b; | |
| if ( g = GS.user.playlists[this.PlaylistID] ) g.PlaylistName = b; | |
| a.publish("gs.playlist.view.update", this); | |
| a.publish("gs.auth.playlists.update", this); | |
| return c | |
| }, | |
| _renameFailed: function( b ) { | |
| return b | |
| }, | |
| changeDescription: function( b, c, g ) { | |
| GS.service.setPlaylistAbout(this.PlaylistID, b, this.callback([this._changeDescSuccess, c], b), this.callback([this._changeDescFailed, g])) | |
| }, | |
| _changeDescSuccess: function( b, c ) { | |
| this.Description = b; | |
| var g = this.Class.getOneFromCache(this.PlaylistID); | |
| if ( g ) g.Description = b; | |
| if ( g = GS.user.playlists[this.PlaylistID] ) g.Description = b; | |
| a.publish("gs.playlist.view.update", this); | |
| return c | |
| }, | |
| _changeDescFailed: function( b ) { | |
| return b | |
| }, | |
| getDetailsForFeeds: function() { | |
| var b = { | |
| playlistID: this.PlaylistID, | |
| playlistName: this.PlaylistName, | |
| userID: this.UserID, | |
| displayName: this.FName + (this.LName && this.LName.length ? " " + this.LName : ""), | |
| artFilename: this.Picture | |
| }; | |
| if ( this.songs ) { | |
| b.songs = []; | |
| for ( var c = 0; c < b.songs; c++ ) | |
| b.songs.push(songs[c].getDetailsForFeeds()) | |
| } | |
| return b | |
| }, | |
| getTitle: function() { | |
| return ['"', this.PlaylistName, '" by ', this.UserName].join("") | |
| }, | |
| isSubscribed: function() { | |
| return GS.user.UserID != this.UserID && this.isFavorite || !_.isEmpty(GS.user.favorites.playlists[this.PlaylistID]) | |
| }, | |
| subscribe: function() { | |
| GS.user.addToPlaylistFavorites(this.PlaylistID) | |
| }, | |
| unsubscribe: function() { | |
| GS.user.removeFromPlaylistFavorites(this.PlaylistID) | |
| }, | |
| getContextMenu: function() { | |
| var b = new GS.Models.PlayContext(GS.player.PLAY_CONTEXT_PLAYLIST, this), | |
| c = [{ | |
| title: a.localize.getString("CONTEXT_PLAY_PLAYLIST"), | |
| customClass: "last jj_menu_item_hasIcon jj_menu_item_play", | |
| action: { | |
| type: "fn", | |
| callback: this.callback(function() { | |
| this.getSongs(function( g ) { | |
| var h = []; | |
| a.each(g, function( k, m ) { | |
| h.push(m.SongID) | |
| }); | |
| GS.player.addSongsToQueueAt(h, GS.player.INDEX_DEFAULT, true, b) | |
| }, function() {}, false) | |
| }) | |
| } | |
| }, | |
| { | |
| title: a.localize.getString("CONTEXT_PLAY_PLAYLIST_NEXT"), | |
| customClass: "last jj_menu_item_hasIcon jj_menu_item_play_next", | |
| action: { | |
| type: "fn", | |
| callback: this.callback(function() { | |
| this.getSongs(function( g ) { | |
| var h = []; | |
| a.each(g, function( k, m ) { | |
| h.push(m.SongID) | |
| }); | |
| GS.player.addSongsToQueueAt(h, GS.player.INDEX_NEXT, false, b) | |
| }, function() {}, false) | |
| }) | |
| } | |
| }, | |
| { | |
| title: a.localize.getString("CONTEXT_PLAY_PLAYLIST_LAST"), | |
| customClass: "last jj_menu_item_hasIcon jj_menu_item_play_last", | |
| action: { | |
| type: "fn", | |
| callback: this.callback(function() { | |
| this.getSongs(function( g ) { | |
| var h = []; | |
| a.each(g, function( k, m ) { | |
| h.push(m.SongID) | |
| }); | |
| GS.player.addSongsToQueueAt(h, GS.player.INDEX_LAST, false, b) | |
| }, function() {}, false) | |
| }) | |
| } | |
| }, | |
| { | |
| customClass: "separator" | |
| }]; | |
| if ( this.PlaylistID > 0 ) c = c.concat([{ | |
| title: a.localize.getString("SHARE_PLAYLIST"), | |
| type: "sub", | |
| action: { | |
| type: "fn", | |
| callback: this.getClipboardAction([{ | |
| text: "http://grooveshark.com/" + this.toUrl().replace("#/", ""), | |
| selector: "div.playlistUrl" | |
| }]) | |
| }, | |
| src: this.getShareMenu(), | |
| customClass: "jj_menu_item_hasIcon jj_menu_item_share jj_menu_item_more" | |
| }, | |
| { | |
| customClass: "separator" | |
| }]); | |
| c = c.concat([{ | |
| title: a.localize.getString("CONTEXT_REPLACE_ALL_SONGS"), | |
| customClass: "last jj_menu_item_hasIcon jj_menu_item_now_playing", | |
| action: { | |
| type: "fn", | |
| callback: this.callback(function() { | |
| this.getSongs(function( g ) { | |
| var h = [], | |
| k = GS.player.isPlaying; | |
| a.each(g, function( m, p ) { | |
| h.push(p.SongID) | |
| }); | |
| GS.player.addSongsToQueueAt(h, GS.player.INDEX_REPLACE, k, b) | |
| }, function() {}, false) | |
| }) | |
| } | |
| }, | |
| { | |
| customClass: "separator" | |
| }]); | |
| GS.user.isShortcut("playlist", this.PlaylistID) ? c.push({ | |
| title: a.localize.getString("CONTEXT_REMOVE_FROM_PINBOARD"), | |
| customClass: "last jj_menu_item_hasIcon jj_menu_item_remove_pinboard", | |
| action: { | |
| type: "fn", | |
| callback: this.callback(function() { | |
| GS.user.removeFromShortcuts("playlist", this.PlaylistID) | |
| }) | |
| } | |
| }) : c.push({ | |
| title: a.localize.getString("CONTEXT_ADD_TO_PINBOARD"), | |
| customClass: "last jj_menu_item_hasIcon jj_menu_item_pinboard", | |
| action: { | |
| type: "fn", | |
| callback: this.callback(function() { | |
| GS.user.addToShortcuts("playlist", this.PlaylistID, this.PlaylistName) | |
| }) | |
| } | |
| }); | |
| return c | |
| }, | |
| getShareMenu: function() { | |
| var b = []; | |
| GS.user.isLoggedIn && b.push({ | |
| title: a.localize.getString("SHARE_EMAIL"), | |
| customClass: "jj_menu_item_hasIcon jj_menu_item_share_email", | |
| action: { | |
| type: "fn", | |
| callback: this.callback(function() { | |
| GS.getLightbox().open("share", { | |
| service: "email", | |
| type: "playlist", | |
| id: this.PlaylistID | |
| }) | |
| }) | |
| } | |
| }); | |
| return b = b.concat([{ | |
| title: a.localize.getString("SHARE_FACEBOOK"), | |
| customClass: "jj_menu_item_hasIcon jj_menu_item_share_facebook", | |
| action: { | |
| type: "fn", | |
| callback: this.callback(function() { | |
| GS.getLightbox().open("share", { | |
| service: "facebook", | |
| type: "playlist", | |
| id: this.PlaylistID | |
| }) | |
| }) | |
| } | |
| }, | |
| { | |
| title: a.localize.getString("SHARE_TWITTER"), | |
| customClass: "jj_menu_item_hasIcon jj_menu_item_share_twitter", | |
| action: { | |
| type: "fn", | |
| callback: this.callback(function() { | |
| GS.getLightbox().open("share", { | |
| service: "twitter", | |
| type: "playlist", | |
| id: this.PlaylistID | |
| }) | |
| }) | |
| } | |
| }, | |
| { | |
| title: a.localize.getString("SHARE_STUMBLE"), | |
| customClass: "jj_menu_item_hasIcon jj_menu_item_share_stumbleupon", | |
| action: { | |
| type: "fn", | |
| callback: this.callback(function() { | |
| window.open(_.makeUrlForShare("stumbleupon", "playlist", this), "_blank"); | |
| a("div[id^=jjmenu]").remove() | |
| }) | |
| } | |
| }, | |
| { | |
| title: a.localize.getString("SHARE_REDDIT"), | |
| customClass: "jj_menu_item_hasIcon jj_menu_item_share jj_menu_item_share_reddit", | |
| action: { | |
| type: "fn", | |
| callback: this.callback(function() { | |
| window.open(_.makeUrlForShare("reddit", "playlist", this), "_blank"); | |
| a("div[id^=jjmenu]").remove() | |
| }) | |
| } | |
| }, | |
| { | |
| title: a.localize.getString("SHARE_WIDGET"), | |
| customClass: "jj_menu_item_hasIcon jj_menu_item_share_widget", | |
| action: { | |
| type: "fn", | |
| callback: this.callback(function() { | |
| GS.getLightbox().open("share", { | |
| service: "widget", | |
| type: "playlist", | |
| id: this.PlaylistID | |
| }) | |
| }) | |
| } | |
| }, | |
| { | |
| title: a.localize.getString("PLAYLIST_URL"), | |
| customClass: "playlistUrl jj_menu_item_hasIcon jj_menu_item_copy" | |
| }]) | |
| }, | |
| toUrl: function( b ) { | |
| return _.cleanUrl(this.PlaylistName, this.PlaylistID, "playlist", null, b) | |
| }, | |
| toUserUrl: function( b ) { | |
| return _.cleanUrl(this.UserName, this.UserID, "user", null, b) | |
| }, | |
| toProxyLabel: function() { | |
| return _.getString("SELECTION_PLAYLIST_SINGLE", { | |
| PlaylistName: _.cleanText(this.PlaylistName), | |
| Username: _.cleanText(this.UserName) | |
| }) | |
| }, | |
| toString: function( b ) { | |
| return (b = _.orEqual(b, false)) ? ["Playlist. pid: ", this.PlaylistID, ", pname:", this.PlaylistName, ", uid:", this.UserID, ", uname: ", this.UserName].join("") : _.getString("SELECTION_PLAYLIST_SINGLE", { | |
| PlaylistName: _.cleanText(this.PlaylistName), | |
| Username: _.cleanText(this.UserName) | |
| }) | |
| } | |
| }) | |
| })(jQuery); | |
| (function() { | |
| GS.Models.Base.extend("GS.Models.Explore", { | |
| IMG_PATH: "http://images.grooveshark.com/static/featured/", | |
| cache: {}, | |
| getType: function( a ) { | |
| var b = this.getOneFromCache(a); | |
| if (!b ) { | |
| b = this.wrap({ | |
| type: a | |
| }); | |
| this.cache[a] = b | |
| } | |
| return b | |
| }, | |
| slideProxyRenderer: function( a, b, c ) { | |
| if ( a.PlaylistID ) return GS.Models.Playlist.slideItemRenderer(a, b, c); | |
| else if ( a.SongID ) return GS.Models.Song.slideItemRenderer(a, b, c); | |
| else if ( a.AlbumID ) return GS.Models.Album.slideItemRenderer(a, b, c); | |
| else if ( a.ArtistID ) return GS.Models.Artist.slideItemRenderer(a, b, c); | |
| else console.warn("Wrong type of object for featured itemrenderers") | |
| }, | |
| proxyRenderer: function( a, b, c ) { | |
| if ( a.PlaylistID ) return GS.Models.Playlist.exploreItemRenderer(a, b, c); | |
| else if ( a.VideoID ) return GS.Models.Video.exploreItemRenderer(a, b, c); | |
| else if ( a.SongID ) return GS.Models.Song.exploreItemRenderer(a, b, c); | |
| else if ( a.AlbumID ) return GS.Models.Album.exploreItemRenderer(a, b, c); | |
| else if ( a.ArtistID ) return GS.Models.Artist.exploreItemRenderer(a, b, c); | |
| else console.warn("Wrong type of object for featured itemrenderers") | |
| } | |
| }, { | |
| type: null, | |
| songsLoaded: false, | |
| featuredData: null, | |
| featuredPlaylists: [], | |
| featuredVideos: [], | |
| videoGroups: {}, | |
| init: function( a ) { | |
| this._super(a); | |
| this.songsLoaded = false; | |
| this.songs = [] | |
| }, | |
| getFeaturedData: function( a, b ) { | |
| this.featuredData ? a(this.featuredData) : GS.service.featuredGetCurrentFeatured(null, this.callback(["wrapFeatured", a]), b) | |
| }, | |
| wrapFeatured: function( a ) { | |
| this.featuredPlaylists = []; | |
| this.featuredData = a; | |
| i = 0; | |
| for ( l = this.featuredData.Contents.length; i < l; i++ ) { | |
| j = 0; | |
| for ( l2 = this.featuredData.Contents[i].items.length; j < l2; j++ ) | |
| if ( this.featuredData.Contents[i].items[j].PlaylistID ) this.featuredData.Contents[i].items[j] = GS.Models.Playlist.wrap(this.featuredData.Contents[i].items[j], true, "featured"); | |
| else if ( this.featuredData.Contents[i].items[j].VideoID ) { | |
| this.featuredData.Contents[i].items[j] = GS.Models.Video.wrap(this.featuredData.Contents[i].items[j], true, "featured"); | |
| a = this.featuredData.Contents[i].items[j]; | |
| if ( this.videoGroups[a.set] ) this.videoGroups[a.set].push(a); | |
| else this.videoGroups[a.set] = [a] | |
| } else if ( this.featuredData.Contents[i].items[j].SongID ) this.featuredData.Contents[i].items[j] = GS.Models.Song.wrap(this.featuredData.Contents[i].items[j], true, "featured"); | |
| else if ( this.featuredData.Contents[i].items[j].AlbumID ) this.featuredData.Contents[i].items[j] = GS.Models.Album.wrap(this.featuredData.Contents[i].items[j], true, "featured"); | |
| else if ( this.featuredData.Contents[i].items[j].ArtistID ) this.featuredData.Contents[i].items[j] = GS.Models.Artist.wrap(this.featuredData.Contents[i].items[j], true, "featured"); | |
| if ( this.featuredData.Contents[i].items[0].PlaylistID ) this.featuredPlaylists.push(this.featuredData.Contents[i]); | |
| else this.featuredData.Contents[i].items[0].VideoID && this.featuredVideos.push(this.featuredData.Contents[i]) | |
| } | |
| }, | |
| getPopularSongs: function( a, b ) { | |
| if ( this.songsLoaded ) { | |
| this.songs = this.wrapSongCollection(this.songs, { | |
| Popularity: 0, | |
| Weight: "", | |
| NumPlays: "" | |
| }); | |
| a(this.songs) | |
| } else GS.service.popularGetSongs(this.type, this.callback(["wrapManySongs", a]), b) | |
| }, | |
| wrapManySongs: function( a ) { | |
| a.Songs && a.Songs.reverse(); | |
| return this.wrapSongCollection(a, { | |
| USE_INDEX: "Popularity", | |
| Weight: "", | |
| NumPlays: "" | |
| }) | |
| } | |
| }) | |
| })(jQuery); | |
| (function( a ) { | |
| GS.Models.Base.extend("GS.Models.User", { | |
| id: "UserID", | |
| cache: {}, | |
| usersLoaded: false, | |
| userIDs: [], | |
| artPath: "http://images.grooveshark.com/static/users/", | |
| defaults: { | |
| UserID: 0, | |
| Username: "", | |
| Name: "", | |
| FName: "", | |
| LName: "", | |
| Picture: "", | |
| IsPremium: 0, | |
| SignupDate: null, | |
| Location: "", | |
| Sex: "", | |
| FollowingFlags: 0, | |
| Flags: 0, | |
| PathName: null, | |
| PathNameEmpty: false, | |
| isFavorite: 0, | |
| library: {}, | |
| favorites: { | |
| songs: {}, | |
| albums: {}, | |
| artists: {}, | |
| playlists: {}, | |
| users: {} | |
| }, | |
| fanbase: null, | |
| playlists: {}, | |
| profileFeed: {}, | |
| communityFeed: {}, | |
| mentionsFeed: {} | |
| }, | |
| getUser: function( b, c, g, h ) { | |
| var k = this.getOneFromCache(b); | |
| h = _.orEqual(h, false); | |
| if ( k ) c(k); | |
| else { | |
| h && a.publish("gs.page.loading.page"); | |
| GS.service.getUserByID(b, this.callback(["wrapProxy", c]), g) | |
| } | |
| }, | |
| itemRenderer: function( b ) { | |
| var c = GS.user.favorites.users && GS.user.favorites.users[b.UserID] ? " following" : "", | |
| g = GS.user.favorites.users && GS.user.favorites.users[b.UserID] ? "FOLLOWING" : "FOLLOW", | |
| h = "" + ('<a class="name ellipsis capitalize" href="' + _.cleanUrl(b.UserID, b.Name, "user") + '">' + b.Name + "</a>"), | |
| k = b.City && b.State && b.Country ? b.Location : b.Country ? b.Country : ""; | |
| k = ['<span class="location ellipsis', k.length ? "" : " emphasis", '">', k.length ? k : a.localize.getString("USER_NO_LOCATION"), "</span>"].join(""); | |
| var m = b.getImageURL(70); | |
| m = ['<img src="', m, '"/>'].join(""); | |
| c = b.UserID === GS.user.UserID ? "" : ['<button class="follow btn button_style2 ', c, '" data-follow-userid="', b.UserID, '" ><div><span class="icon"></span><span class="label" data-translate-text="', g, '">', a.localize.getString(g), "</span></div></button>"].join(""); | |
| return ['<a href="', _.cleanUrl(b.UserID, b.Name, "user"), '" class="userImage insetBorder height70"><div class="status ', b.getVipPackage(), '"></div>', m, '</a><div class="meta">', h, k, c, "</div>"].join("") | |
| }, | |
| sliderRenderer: function( b ) { | |
| var c = '<div class="page_content_slide subcontent-item fans"><a href="' + b.toUrl() + '" class="image"><img src="' + b.getImageURL() + '"></a><a class="title" href="' + b.toUrl() + '">' + (b.FName || b.Name) + '</a><span class="duration">'; | |
| b = b.getAccountDuration(); | |
| c += a("<span></span>").localeDataString(b.key, b).render(); | |
| c += "</span></div>"; | |
| return c | |
| }, | |
| matchFilter: function( b ) { | |
| var c = RegExp(b, "gi"); | |
| return function( g ) { | |
| return g.Name.match(c) | |
| } | |
| }, | |
| wrapProxy: function( b ) { | |
| return this.wrap(b.User || b) | |
| }, | |
| FLAG_PLUS: 1, | |
| FLAG_LASTFM: 2, | |
| FLAG_FACEBOOK: 4, | |
| FLAG_FACEBOOKUSER: 16, | |
| FLAG_GOOGLEUSER: 32, | |
| FLAG_GOOGLE: 64, | |
| FLAG_ANYWHERE: 128, | |
| FLAG_ISARTIST: 256, | |
| FLAG_MUSIC_BUSINESS: 1024 | |
| }, { | |
| validate: function() { | |
| if ( this.UserID > 0 ) return true; | |
| return false | |
| }, | |
| init: function( b ) { | |
| this._super(b); | |
| var c = _.orEqual(this.City, ""); | |
| c += this.State && c.length ? ", " + this.State : _.orEqual(this.State, ""); | |
| c += this.Country && c.length ? ", " + this.Country : _.orEqual(this.Country, ""); | |
| this.Name = _.defined(this.displayName) ? this.displayName : _.cleanText(this.FName) + (this.LName && this.LName.length ? " " + _.cleanText(this.LName) : ""); | |
| this.Username = this.UserID > 0 ? this.Username && this.Username.length ? this.Username : this.Name : "New User"; | |
| this.Location = c; | |
| this.IsPremium = this.IsPremium == 1 ? 1 : 0; | |
| this.library = this.isAuth ? {} : false; | |
| this.communityFeed = this.profileFeed = this.fanbase = false; | |
| this.mentionsFeed = GS.Models.MentionsFeed.wrap({ | |
| user: this | |
| }); | |
| this.searchText = [this.Locale, this.FName, this.LName].join(" ").toLowerCase(); | |
| this.playlists = {}; | |
| this.favorites = { | |
| songs: {}, | |
| albums: {}, | |
| artists: {}, | |
| playlists: {}, | |
| users: {} | |
| }; | |
| this.TSAdded = _.orEqual(b.TSAdded, false) | |
| }, | |
| autocompleteFavoriteUsers: function() { | |
| var b = []; | |
| a.each(this.favorites.users, function( c, g ) { | |
| a.each(g.searchText.trim().split(), function( h, k ) { | |
| b.push([k.trim(), g.UserID]) | |
| }) | |
| }); | |
| return b | |
| }, | |
| getFavoritesByType: function( b, c, g ) { | |
| var h = arguments[arguments.length - 1] === g ? {} : arguments[arguments.length - 1], | |
| k = b.toLowerCase(); | |
| if ( _.isEmpty(this.favorites[k]) ) GS.service.getFavorites(this.UserID, b, !this.isAuth, this.callback(["load" + b + "Favorites", c]), g, h); | |
| else { | |
| h = this.favorites[k]; | |
| this.favorites[k] = GS.Models[b.substring(0, b.length - 1)].wrapCollectionInObject(h, { | |
| TSFavorited: "", | |
| TSAdded: "" | |
| }); | |
| c(this.favorites[k]) | |
| } | |
| }, | |
| loadAlbumsFavorites: function( b ) { | |
| var c = {}; | |
| for ( var g in b ) | |
| if ( b.hasOwnProperty(g) ) { | |
| b[g].TSAdded = b[g].TSFavorited; | |
| c[b[g].AlbumID] = b[g]; | |
| if ( this.isAuth ) b[g].isFavorite = 1 | |
| } | |
| this.favorites.albums = GS.Models.Album.wrapCollectionInObject(c, { | |
| TSFavorited: "", | |
| TSAdded: "" | |
| }); | |
| return this.favorites.albums | |
| }, | |
| loadArtistsFavorites: function( b ) { | |
| var c = {}; | |
| for ( var g in b ) | |
| if ( b.hasOwnProperty(g) ) { | |
| b[g].TSAdded = b[g].TSFavorited; | |
| c[b[g].ArtistID] = b[g]; | |
| if ( this.isAuth ) b[g].isFavorite = 1 | |
| } | |
| this.favorites.artists = GS.Models.Artist.wrapCollectionInObject(c, { | |
| TSFavorited: "", | |
| TSAdded: "" | |
| }); | |
| return this.favorites.artists | |
| }, | |
| loadPlaylistsFavorites: function( b ) { | |
| var c = {}; | |
| for ( var g in b ) | |
| if ( b.hasOwnProperty(g) ) { | |
| b[g].TSAdded = b[g].TSFavorited; | |
| c[b[g].PlaylistID] = b[g]; | |
| if ( this.isAuth ) b[g].isFavorite = 1 | |
| } | |
| this.favorites.playlists = GS.Models.Playlist.wrapCollectionInObject(c, { | |
| TSFavorited: "", | |
| TSAdded: "" | |
| }); | |
| return this.favorites.playlists | |
| }, | |
| loadSongsFavorites: function( b ) { | |
| var c = {}; | |
| for ( var g in b ) | |
| if ( b.hasOwnProperty(g) ) { | |
| b[g].TSAdded = b[g].TSFavorited; | |
| c[b[g].SongID] = b[g] | |
| } | |
| this.favorites.songs = GS.Models.Song.wrapCollectionInObject(c, { | |
| TSFavorited: "", | |
| TSAdded: "" | |
| }); | |
| if (!this.library ) this.library = GS.Models.Library.wrap({ | |
| userID: this.UserID | |
| }); | |
| for ( g in this.favorites.songs ) | |
| if ( this.favorites.songs.hasOwnProperty(g) ) { | |
| b = | |
| this.favorites.songs[g]; | |
| if ( this.isAuth ) { | |
| b.isFavorite = 1; | |
| b.fromLibrary = 1 | |
| } | |
| this.library.songs[b.SongID] = b.dupe() | |
| } | |
| return this.favorites.songs | |
| }, | |
| loadUsersFavorites: function( b ) { | |
| var c = {}; | |
| for ( var g in b ) | |
| if ( b.hasOwnProperty(g) ) { | |
| b[g].FollowingFlags = parseInt(b[g].FollowingFlags, 10); | |
| c[b[g].UserID] = b[g]; | |
| if ( this.isAuth ) b[g].isFavorite = 1 | |
| } | |
| this.favorites.users = GS.Models.User.wrapCollectionInObject(c, { | |
| TSFavorited: "", | |
| TSAdded: "", | |
| FollowingFlags: 0 | |
| }); | |
| return this.favorites.users | |
| }, | |
| getPlaylists: function( b, c ) { | |
| if ( _.isEmpty(this.playlists) ) GS.service.userGetPlaylists(this.UserID, !this.isAuth, this.callback(["cachePlaylists", b]), c); | |
| else a.isFunction(b) && b() | |
| }, | |
| cachePlaylists: function( b ) { | |
| var c = {}; | |
| b = b.Playlists; | |
| for ( var g in b ) | |
| if ( b.hasOwnProperty(g) ) { | |
| b[g].UserName = this.Name; | |
| b[g].FName = this.FName; | |
| b[g].LName = this.LName; | |
| b[g].UserID = this.UserID; | |
| c[b[g].PlaylistID] = b[g] | |
| } | |
| g = this.playlists; | |
| this.playlists = GS.Models.Playlist.wrapCollectionInObject(c); | |
| if ( this.isAuth ) { | |
| _.forEach(g, function( h ) { | |
| _.defined(this.playlists[h.PlaylistID]) || (this.playlists[h.PlaylistID] = h) | |
| }, this); | |
| a.publish("gs.auth.playlists.update") | |
| } | |
| }, | |
| getProfileFeed: function( b, c ) { | |
| if (!this.profileFeed ) this.profileFeed = GS.Models.ProfileFeed.wrap({ | |
| user: this | |
| }); | |
| this.profileFeed.getFeed(this.callback(b), c) | |
| }, | |
| getCommunityExceptions: function() { | |
| return this.isAuth ? this.filterFriends(1) : this.favorites.users | |
| }, | |
| getCommunityFeed: function( b, c ) { | |
| var g = []; | |
| if (!this.communityFeed ) this.communityFeed = GS.Models.CommunityFeed.wrap({ | |
| user: user | |
| }); | |
| if ( this.isAuth ) g = _.toArrayID(this.getCommunityExceptions()); | |
| if ( this.UserID > 0 ) { | |
| this.communityFeed.userIDs = g; | |
| this.communityFeed.getFeed(this.callback(b), c) | |
| } | |
| }, | |
| playUserRadio: function() {}, | |
| filterFriends: function( b, c ) { | |
| var g = {}; | |
| if ( c ) for ( var h in this.favorites.users ) this.favorites.users[h].FollowingFlags & b || (g[h] = this.favorites.users[h]); | |
| else for ( h in this.favorites.users ) if ( this.favorites.users[h].FollowingFlags & b ) g[h] = this.favorites.users[h]; | |
| return g | |
| }, | |
| getRecentlyActiveUsersFeed: function( b, c ) { | |
| this.recentActiveUsersFeed.getFeed(this.callback(b), c) | |
| }, | |
| getVipPackage: function() { | |
| var b = ""; | |
| if ( this.Flags & GS.Models.User.FLAG_ANYWHERE ) b = "anywhere"; | |
| else if ( this.Flags & GS.Models.User.FLAG_PLUS ) b = "plus"; | |
| return b | |
| }, | |
| getAccountDuration: function() { | |
| var b = {}; | |
| if ( this.TSAdded ) { | |
| var c = this.TSAdded.split(" "); | |
| if ( c ) { | |
| c = c[0].split("-"); | |
| var g = new Date; | |
| b = parseInt(g.getFullYear() - parseInt(c[0])); | |
| c = parseInt(g.getMonth() - parseInt(c[1]) + 1); | |
| if ( c < 0 ) { | |
| b--; | |
| c = 12 + parseInt(c) | |
| } | |
| b = { | |
| months: c, | |
| years: b | |
| }; | |
| b.key = b.years > 0 ? b.years == 1 ? "USER_MEMBER_FOR_YEAR" : "USER_MEMBER_FOR_YEARS" : b.months < 1 ? "USER_MEMBER_LESS_THAN_MONTH" : b.months == 1 ? "USER_MEMBER_FOR_MONTH" : "USER_MEMBER_FOR_MONTHS" | |
| } | |
| } | |
| return b | |
| }, | |
| toUrl: function( b ) { | |
| return this.PathName ? _.makeUrlFromPathName(this.PathName, b) : _.cleanUrl(this.UserID ? this.Name : "New User", this.UserID, "user", null, b) | |
| }, | |
| getPathName: function( b ) { | |
| if ( this.PathName || this.PathNameEmpty ) a.isFunction(b) && b(this.PathName); | |
| else this.UserID > 0 && GS.service.getPageNameByIDType(this.UserID, "user", this.callback(this._onPathNameSuccess, b), this.callback(this._onPathNameFailed, b)) | |
| }, | |
| _onPathNameSuccess: function( b, c ) { | |
| if ( c.name ) this.PathName = c.name; | |
| else { | |
| this.PathName = ""; | |
| this.PathNameEmpty = true | |
| } | |
| a.isFunction(b) && b(this.PathName) | |
| }, | |
| _onPathNameFailed: function( b ) { | |
| this.PathName = ""; | |
| this.PathNameEmpty = true; | |
| a.isFunction(b) && b(this.PathName) | |
| }, | |
| getImageURL: function( b ) { | |
| b = _.orEqual(b, 70); | |
| var c = GS.Models.User.artPath + b + "_user.png"; | |
| if ( this.Picture ) c = GS.Models.User.artPath + b + "_" + this.Picture; | |
| return c | |
| }, | |
| getDetailsForFeeds: function() { | |
| return { | |
| userID: this.UserID, | |
| userName: this.Name, | |
| isPremium: this.IsPremium, | |
| location: this.location, | |
| picture: this.Picture | |
| } | |
| }, | |
| getTitle: function() { | |
| return this.Name | |
| }, | |
| toString: function( b ) { | |
| return (b = _.orEqual(b, false)) ? ["User. uid: ", this.UserID, ", uname:", this.Name].join("") : _.cleanText(this.Name) | |
| } | |
| }) | |
| })(jQuery); | |
| (function( a ) { | |
| GS.Models.Base.extend("GS.Models.Library", {}, { | |
| currentPage: 0, | |
| userID: null, | |
| lastModified: 0, | |
| songsLoaded: false, | |
| init: function( b ) { | |
| this._super(b); | |
| this.songsLoaded = false; | |
| this.lastModified = this.currentPage = 0; | |
| this.songs = {} | |
| }, | |
| getSongs: function( b, c, g ) { | |
| g = _.orEqual(g, true); | |
| if ( this.songsLoaded ) { | |
| this.songs = this.wrapSongCollection(this.songs, { | |
| TSAdded: "", | |
| TSFavorited: "" | |
| }); | |
| b(this.songs) | |
| } else { | |
| g && this.currentPage === 0 && a.publish("gs.page.loading.grid"); | |
| GS.service.userGetSongsInLibrary(this.userID, this.currentPage, !(GS.user && GS.user.UserID === this.userID), this.callback(["saveLastModified", "loadSongs", b]), c) | |
| } | |
| }, | |
| reloadLibrary: function( b, c, g ) { | |
| this.songsLoaded = false; | |
| this.lastModified = this.currentPage = 0; | |
| this.songs = {}; | |
| this.getSongs(b, c, g) | |
| }, | |
| loadSongs: function( b ) { | |
| return this.wrapSongCollection(b, { | |
| TSAdded: "", | |
| TSFavorited: "", | |
| fromLibrary: GS.user.UserID == this.userID ? 1 : 0 | |
| }) | |
| }, | |
| saveLastModified: function( b ) { | |
| this.lastModified = b.TSModified; | |
| return b | |
| }, | |
| refreshLibrary: function( b ) { | |
| b.TSModified > this.lastModified && this.reloadLibrary(null, null, false) | |
| } | |
| }) | |
| })(jQuery); | |
| (function( a ) { | |
| GS.Models.Base.extend("GS.Models.Station", { | |
| id: "StationID", | |
| TAG_STATIONS: [{ | |
| StationID: 136, | |
| StationTitle: "STATION_INDIE", | |
| TagID: 136 | |
| }, | |
| { | |
| StationID: 67, | |
| StationTitle: "STATION_ELECTRONICA", | |
| TagID: 67 | |
| }, | |
| { | |
| StationID: 750, | |
| StationTitle: "STATION_CLASSICAL", | |
| TagID: 750 | |
| }, | |
| { | |
| StationID: 56, | |
| StationTitle: "STATION_POP", | |
| TagID: 56 | |
| }, | |
| { | |
| StationID: 3, | |
| StationTitle: "STATION_RAP", | |
| TagID: 3 | |
| }, | |
| { | |
| StationID: 80, | |
| StationTitle: "STATION_COUNTRY", | |
| TagID: 80 | |
| }, | |
| { | |
| StationID: 13, | |
| StationTitle: "STATION_ALTERNATIVE", | |
| TagID: 13 | |
| }, | |
| { | |
| StationID: 29, | |
| StationTitle: "STATION_HIP_HOP", | |
| TagID: 29 | |
| }, | |
| { | |
| StationID: 3529, | |
| StationTitle: "STATION_CLASSIC_ROCK", | |
| TagID: 3529 | |
| }, | |
| { | |
| StationID: 75, | |
| StationTitle: "STATION_AMBIENT", | |
| TagID: 75 | |
| }, | |
| { | |
| StationID: 111, | |
| StationTitle: "STATION_PUNK", | |
| TagID: 111 | |
| }, | |
| { | |
| StationID: 9, | |
| StationTitle: "STATION_90S_ALT_ROCK", | |
| TagID: 9 | |
| }, | |
| { | |
| StationID: 230, | |
| StationTitle: "STATION_BLUES", | |
| TagID: 230 | |
| }, | |
| { | |
| StationID: 12, | |
| StationTitle: "STATION_ROCK", | |
| TagID: 12 | |
| }, | |
| { | |
| StationID: 43, | |
| StationTitle: "STATION_JAZZ", | |
| TagID: 43 | |
| }, | |
| { | |
| StationID: 4, | |
| StationTitle: "STATION_RNB", | |
| TagID: 4 | |
| }, | |
| { | |
| StationID: 122, | |
| StationTitle: "STATION_FOLK", | |
| TagID: 122 | |
| }, | |
| { | |
| StationID: 2563, | |
| StationTitle: "STATION_DUBSTEP", | |
| TagID: 2563 | |
| }, | |
| { | |
| StationID: 55, | |
| StationTitle: "STATION_80s", | |
| TagID: 55 | |
| }, | |
| { | |
| StationID: 69, | |
| StationTitle: "STATION_TRANCE", | |
| TagID: 69 | |
| }, | |
| { | |
| StationID: 96, | |
| StationTitle: "STATION_BLUEGRASS", | |
| TagID: 96 | |
| }, | |
| { | |
| StationID: 160, | |
| StationTitle: "STATION_REGGAE", | |
| TagID: 160 | |
| }, | |
| { | |
| StationID: 17, | |
| StationTitle: "STATION_METAL", | |
| TagID: 17 | |
| }, | |
| { | |
| StationID: 102, | |
| StationTitle: "STATION_OLDIES", | |
| TagID: 102 | |
| }, | |
| { | |
| StationID: 191, | |
| StationTitle: "STATION_EXPERIMENTAL", | |
| TagID: 191 | |
| }, | |
| { | |
| StationID: 528, | |
| StationTitle: "STATION_LATIN", | |
| TagID: 528 | |
| }], | |
| tagStations: [], | |
| extraStations: {}, | |
| stationsByName: {}, | |
| getStationsStartMenu: function() { | |
| for ( var b = [], c, g = function( k ) { | |
| return function() { | |
| GS.player.setAutoplay(true, k) | |
| } | |
| }, h = 0; h < GS.Models.Station.tagStations.length; h++ ) { | |
| c = GS.Models.Station.tagStations[h]; | |
| b.push({ | |
| title: a.localize.getString(c.StationTitle), | |
| customClass: "jj_menu_item_hasIcon jj_menu_item_station", | |
| action: { | |
| type: "fn", | |
| callback: g(c.TagID) | |
| } | |
| }) | |
| } | |
| b.sort(function( k, m ) { | |
| var p = k.title.toLowerCase(), | |
| n = m.title.toLowerCase(); | |
| return p == n ? 0 : p > n ? 1 : -1 | |
| }); | |
| return b | |
| }, | |
| getStationsStartMenuForPinboard: function() { | |
| for ( var b = [], c, g = function( k ) { | |
| return function() { | |
| GS.user.addToShortcuts("station", k, true) | |
| } | |
| }, h = 0; h < GS.Models.Station.tagStations.length; h++ ) { | |
| c = GS.Models.Station.tagStations[h]; | |
| GS.user.isShortcut("station", c.TagID) || b.push({ | |
| title: a.localize.getString(c.StationTitle), | |
| customClass: "jj_menu_item_hasIcon jj_menu_item_station", | |
| action: { | |
| type: "fn", | |
| callback: g(c.TagID) | |
| } | |
| }) | |
| } | |
| b.sort(function( k, m ) { | |
| var p = k.title.toLowerCase(), | |
| n = m.title.toLowerCase(); | |
| return p == n ? 0 : p > n ? 1 : -1 | |
| }); | |
| return b | |
| }, | |
| getStationByName: function( b ) { | |
| if ( a.localize.ready && GS.getLocale && GS.Models.Station.stationsByName.locale != GS.getLocale().locale ) { | |
| GS.Models.Station.stationsByName = {}; | |
| _.forEach(GS.Models.Station.TAG_STATIONS, function( c ) { | |
| var g = a.localize.getString(c.StationTitle).toLowerCase(); | |
| GS.Models.Station.stationsByName[g] = c | |
| }, this); | |
| GS.Models.Station.stationsByName.locale = GS.getLocale().locale | |
| } | |
| if ( GS.Models.Station.stationsByName[b] ) return GS.Models.Station.stationsByName[b]; | |
| return false | |
| }, | |
| FeedStation: null, | |
| lastHeardFeedEvent: 0, | |
| init: function() { | |
| a.subscribe("gs.player.nowplaying", this.callback("onSongPlay")); | |
| a.subscribe("gs.app.ready", this.callback(function() { | |
| _.forEach(GS.Models.Station.TAG_STATIONS, function( b ) { | |
| GS.Models.Station.tagStations.push(GS.Models.Station.wrap(b)) | |
| }, this) | |
| })) | |
| }, | |
| setFeedStation: function( b ) { | |
| if ( b && this.Station !== b ) { | |
| this.lastHeardFeedEvent = 0; | |
| b.playSongs(-1, true) | |
| } | |
| GS.Models.Station.FeedStation = b | |
| }, | |
| onSongPlay: function() { | |
| if ( this.Station ) { | |
| GS.Models.Feed.Station.play(-1, false, GS.Models.Feed.lastHeardFeedEvent); | |
| GS.Models.Feed.lastHeardFeedEvent = GS.Models.Feed.Station.newestTime | |
| } | |
| }, | |
| itemRenderer: function( b, c ) { | |
| return c = ['<a class="name ellipsis" href="#/station/-/', b, '">', c, "</a>"].join("") | |
| }, | |
| makeChristmasHappen: function() { | |
| GS.player.setAutoplay(true, 703) | |
| } | |
| }, { | |
| StationID: 0, | |
| TagID: 0, | |
| StationTitle: "", | |
| StationName: "", | |
| Artists: [], | |
| init: function( b ) { | |
| this._super(b); | |
| this.StationName = a.localize.getString(b.StationTitle); | |
| if (!this.StationName ) this.StationName = this.StationTitle | |
| }, | |
| toProxyLabel: function() { | |
| return _.cleanText(a.localize.getString(this.StationTitle)) | |
| }, | |
| getContextMenu: function() { | |
| var b = []; | |
| b.push({ | |
| title: a.localize.getString("CONTEXT_START_STATION"), | |
| customClass: "jj_menu_item_hasIcon jj_menu_item_station", | |
| action: { | |
| type: "fn", | |
| callback: this.callback(function() { | |
| GS.player.setAutoplay(true, this.TagID) | |
| }) | |
| } | |
| }); | |
| b.push({ | |
| title: a.localize.getString("CONTEXT_ADD_TO_PINBOARD"), | |
| customClass: "jj_menu_item_hasIcon jj_menu_item_pinboard", | |
| action: { | |
| type: "fn", | |
| callback: this.callback(function() { | |
| GS.user.addToShortcuts("station", this.StationID, true) | |
| }) | |
| } | |
| }); | |
| return b | |
| } | |
| }) | |
| })(jQuery); | |
| (function( a ) { | |
| a.Model.extend("GS.Models.PlayContext", {}, { | |
| type: null, | |
| data: null, | |
| init: function( b, c ) { | |
| this.type = _.orEqual(b, "unknown"); | |
| this.data = _.orEqual(c, {}); | |
| var g; | |
| if ( this.type === "album" && this.data.hasOwnProperty("CoverArtFilename") ) g = this.data.CoverArtFilename; | |
| if ( a.isFunction(this.data.getDetailsForFeeds) ) this.data = this.data.getDetailsForFeeds(); | |
| if ( g ) this.data.CoverArtFilename = g | |
| } | |
| }) | |
| })(jQuery); | |
| (function( a ) { | |
| a.fn.dataString = function() { | |
| if ( arguments.length === 0 ) return _.orEqual(this.data("DataString"), null); | |
| var b = new GS.Models.DataString(arguments[0], arguments[1]); | |
| b.hookup(this); | |
| return b | |
| }; | |
| a.fn.localeDataString = function( b, c, g ) { | |
| b = _.orEqual(b, ""); | |
| c = _.orEqual(c, {}); | |
| g = _.orEqual(g, false); | |
| var h = a(this).dataString(); | |
| if (!h ) { | |
| h = new GS.Models.DataString; | |
| h.hookup(this) | |
| } | |
| h.string = a.localize.getString(b); | |
| h.data = c; | |
| g ? a(this).attr("data-translate-title", b).attr("title", h.render()) : a(this).attr("data-translate-text", b).html(h.render()); | |
| return h | |
| }; | |
| a.Model.extend("GS.Models.DataString", {}, { | |
| string: null, | |
| data: null, | |
| element: null, | |
| init: function( b, c ) { | |
| this.string = _.orEqual(b, ""); | |
| this.data = _.orEqual(c, {}) | |
| }, | |
| setString: function( b ) { | |
| if ( this.string !== b ) { | |
| this.string = b; | |
| this.render() | |
| } | |
| }, | |
| setData: function( b, c ) { | |
| if ( this.data[b] !== c ) { | |
| this.data[b] = c; | |
| this.render() | |
| } | |
| }, | |
| hookup: function( b ) { | |
| this.element = a(b); | |
| this.element.data("DataString", this) | |
| }, | |
| render: function() { | |
| for ( var b = this.string, c = [], g, h = /^[^\{]+/, k = /^\{(.*?)\}/, m = this.data; b; ) { | |
| if ( g = h.exec(b) ) c.push(g[0]); | |
| else if ( g = k.exec(b) ) { | |
| var p = g[1]; | |
| m[p] ? c.push(m[p]) : c.push(g[0]) | |
| } else throw "Error rendering data object"; | |
| b = b.substring(g[0].length) | |
| } | |
| b = c.join(""); | |
| if ( this.element && this.element.length ) this.element[0].tagName == "INPUT" ? this.element.val(b) : this.element.html(b); | |
| return b | |
| } | |
| }) | |
| })(jQuery); | |
| (function( a ) { | |
| GS.Models.User.extend("GS.Models.AuthUser", { | |
| id: "AuthUserID", | |
| cache: {}, | |
| loggedOutPlaylistCount: 0, | |
| wrap: function( b ) { | |
| return this._super(b, false) | |
| }, | |
| wrapFromService: function( b ) { | |
| return this.wrap(a.extend({}, b, { | |
| Email: b.Email || b.email, | |
| Sex: b.Sex || b.sex, | |
| UserID: b.UserID || b.userID, | |
| IsPremium: b.IsPremium || b.isPremium, | |
| FName: b.FName || b.fName, | |
| LName: b.LName || b.lName, | |
| TSDOB: b.TSDOB || b.tsDOB, | |
| Flags: b.Flags || b.flags, | |
| Username: b.Username || b.username, | |
| Privacy: _.orEqualEx(b.Privacy, b.privacy, 0) | |
| })) | |
| }, | |
| getPricing: function() { | |
| var b = | |
| Math.floor((new Date).getTime() / 1E3), | |
| c = { | |
| vip: { | |
| month: 3, | |
| year: 30 | |
| }, | |
| plus: { | |
| month: 6, | |
| year: 60 | |
| }, | |
| anywhere: { | |
| month: 9, | |
| year: 90 | |
| } | |
| }; | |
| if ( b >= 1322697600 && b < 1325376E3 ) { | |
| c.plus = { | |
| month: 3, | |
| year: 30 | |
| }; | |
| c.anywhere = { | |
| month: 5, | |
| year: 50 | |
| } | |
| } | |
| return c | |
| } | |
| }, { | |
| authRealm: 1, | |
| authToken: "", | |
| autoAutoplay: false, | |
| badAuthToken: false, | |
| favoritesLimit: 500, | |
| librarySizeLimit: 5E3, | |
| themeID: "", | |
| uploadsEnabled: 0, | |
| UserID: -1, | |
| Username: "", | |
| Email: "", | |
| City: "", | |
| Country: "", | |
| State: "", | |
| TSDOB: "", | |
| Privacy: 0, | |
| Flags: 0, | |
| Points: 0, | |
| settings: null, | |
| isLoggedIn: false, | |
| isAuth: true, | |
| artistsPlayed: [], | |
| defaultStations: ["750", "12", "136", "3", "56", "67"], | |
| defaultFromService: null, | |
| searchVersion: "", | |
| promotions: {}, | |
| userFavoritesLoaded: false, | |
| userTrackingID: 0, | |
| songPlays: 0, | |
| init: function( b ) { | |
| this._super(b); | |
| this.defaultFromService = {}; | |
| this.refreshLibraryStatic = this.callback(this.refreshLibrary); | |
| this.library.songs = {}; | |
| this.playlists = {}; | |
| this.favorites = { | |
| songs: {}, | |
| albums: {}, | |
| artists: {}, | |
| playlists: {}, | |
| users: {} | |
| }; | |
| this.sidebarLoaded = false; | |
| this.sidebar = { | |
| playlists: [], | |
| stations: [], | |
| subscribedPlaylists: [], | |
| songs: [], | |
| artists: [], | |
| albums: [], | |
| meta: { | |
| playlists: {}, | |
| stations: {}, | |
| subscribedPlaylists: {}, | |
| songs: {}, | |
| artists: {}, | |
| albums: {} | |
| } | |
| }; | |
| this.settings = GS.Models.UserSettings.wrap({ | |
| UserID: this.UserID | |
| }); | |
| this._pointsDirty = true; | |
| this.Points = 0; | |
| if ( this.UserID > 0 ) { | |
| this.isLoggedIn = true; | |
| this.getPlaylists(); | |
| this.getFavorites(); | |
| this.getSidebar(); | |
| this.getLibrary(); | |
| this.handleLiveRamp() | |
| } else { | |
| this.isDirty = this.isLoggedIn = false; | |
| this.sidebarLoaded = true; | |
| this.sidebar.stations = this.defaultStations.concat() | |
| } | |
| this.artistsPlayed = GS.store.get("artistsPlayed" + this.UserID) || []; | |
| a.subscribe("gs.player.nowplaying", this.callback(this.onSongPlay)); | |
| setTimeout(function() { | |
| a.publish("gs.auth.stations.update") | |
| }, 10); | |
| this.checkVipExpiring(); | |
| this.searchVersion = "" | |
| }, | |
| uploadComplete: function() { | |
| var b = this.toUrl("music").substring(1); | |
| this.library.reloadLibrary(function() { | |
| location.hash = b | |
| }) | |
| }, | |
| onSongPlay: function( b ) { | |
| if ( this === GS.user ) { | |
| if ( b && b.ArtistID ) { | |
| var c = this.artistsPlayed.indexOf(b.ArtistID); | |
| c != -1 && this.artistsPlayed.splice(c, 1); | |
| this.artistsPlayed.unshift(b.ArtistID); | |
| this.artistsPlayed.splice(999, 1) | |
| } | |
| this.songPlays++; | |
| this.songPlays > 5 && !this.IsPremium && (new Date).getTime() < 13254624E5 && !store.get("holiday.promotion.seen") && GS.getLightbox().open("holiday") | |
| } | |
| }, | |
| storeData: function() { | |
| var b; | |
| if ( _.isEmpty(this.library.songs) ) b = null; | |
| else { | |
| b = { | |
| currentPage: this.library.currentPage, | |
| songsLoaded: this.library.songsLoaded, | |
| userID: this.library.userID, | |
| lastModified: this.library.lastModified, | |
| songs: {} | |
| }; | |
| for ( var c in this.library.songs ) | |
| if ( this.library.songs.hasOwnProperty(c) ) b.songs[c] = GS.Models.Song.archive(this.library.songs[c]) | |
| } | |
| this.settings.changeLocalSettings({}); | |
| GS.store.set("artistsPlayed" + this.UserID, this.artistsPlayed); | |
| GS.store.set("library" + this.UserID, b) | |
| }, | |
| clearData: function() { | |
| GS.store.remove("library" + this.UserID) | |
| }, | |
| createPlaylist: function( b, c, g, h, k, m ) { | |
| m = _.orEqual(m, true); | |
| c = _.orEqual(c, []); | |
| if ( this.isLoggedIn ) GS.service.createPlaylist(b, c, g, this.callback(["createPlaylistSuccess"], { | |
| callback: h, | |
| name: b, | |
| songIDs: c, | |
| description: g, | |
| notify: m | |
| }), k); | |
| else { | |
| GS.Models.AuthUser.loggedOutPlaylistCount++; | |
| g = GS.Models.Playlist.wrap({ | |
| PlaylistID: -GS.Models.AuthUser.loggedOutPlaylistCount, | |
| PlaylistName: b, | |
| UserName: this.Name, | |
| UserID: this.UserID, | |
| songsLoaded: true, | |
| TSAdded: (new Date).format("Y-m-d G:i:s"), | |
| Description: g | |
| }); | |
| g.addSongs(c, 0, true); | |
| this.playlists[g.PlaylistID] = g; | |
| this.isDirty = true; | |
| a.publish("gs.auth.playlists.update"); | |
| a.publish("gs.auth.playlists.add", g); | |
| m && a.publish("gs.notification.playlist.create", g); | |
| h(g) | |
| } | |
| GS.getGuts().logEvent("playlistCreated", { | |
| playlistName: b | |
| }); | |
| GS.getGuts().gaTrackEvent("user", "newPlaylist") | |
| }, | |
| createPlaylistSuccess: function( b, c ) { | |
| var g = GS.Models.Playlist.wrap({ | |
| PlaylistID: c, | |
| PlaylistName: b.name, | |
| Description: b.description, | |
| UserID: this.UserID, | |
| UserName: this.Name, | |
| FName: this.Name, | |
| TSAdded: (new Date).format("Y-m-d G:i:s"), | |
| NumSongs: b.songIDs.length | |
| }); | |
| this.playlists[g.PlaylistID] = g; | |
| a.publish("gs.auth.playlists.update"); | |
| b.notify && a.publish("gs.notification.playlist.create", g); | |
| b.callback(g) | |
| }, | |
| deletePlaylist: function( b, c ) { | |
| var g = GS.Models.Playlist.getOneFromCache(b); | |
| if ( g && g.UserID === this.UserID ) { | |
| c = _.orEqual(c, true); | |
| if ( this.isLoggedIn ) GS.service.deletePlaylist(g.PlaylistID, g.PlaylistName, this.callback(function() { | |
| g.isDeleted = true; | |
| this.removeFromShortcuts("playlist", g.PlaylistID, false); | |
| delete this.playlists[g.PlaylistID]; | |
| a.publish("gs.playlist.view.update", g); | |
| a.publish("gs.auth.playlists.update"); | |
| a.publish("gs.user.playlist.remove"); | |
| if ( c ) { | |
| var h = (new GS.Models.DataString(a.localize.getString("POPUP_DELETE_PLAYLIST_MSG"), { | |
| playlist: g.PlaylistName | |
| })).render(); | |
| a.publish("gs.notification", { | |
| type: "notice", | |
| message: h | |
| }) | |
| } | |
| }), this.callback(function() { | |
| g.isDeleted = false; | |
| if ( c ) { | |
| var h = (new GS.Models.DataString(a.localize.getString("POPUP_FAIL_DELETE_PLAYLIST_MSG"), { | |
| playlist: g.PlaylistName | |
| })).render(); | |
| a.publish("gs.notification", { | |
| type: "error", | |
| message: h | |
| }) | |
| } | |
| })); | |
| else { | |
| g.isDeleted = true; | |
| this.removeFromShortcuts("playlist", g.PlaylistID, false); | |
| delete this.playlists[g.PlaylistID]; | |
| a.publish("gs.playlist.view.update", g); | |
| a.publish("gs.auth.playlists.update"); | |
| a.publish("gs.user.playlist.remove"); | |
| c && a.publish("gs.notification", { | |
| type: "notice", | |
| message: a.localize.getString("NOTIFICATION_PLAYLIST_DELETED") | |
| }) | |
| } | |
| } | |
| GS.getGuts().gaTrackEvent("user", "deletePlaylist") | |
| }, | |
| restorePlaylist: function( b, c ) { | |
| var g = GS.Models.Playlist.getOneFromCache(b); | |
| if ( g && g.UserID === this.UserID ) { | |
| c = _.orEqual(c, true); | |
| if ( this.isLoggedIn ) GS.service.playlistUndelete(g.PlaylistID, this.callback(function() { | |
| g.isDeleted = false; | |
| this.playlists[g.PlaylistID] = g; | |
| a.publish("gs.playlist.view.update", g); | |
| c && a.publish("gs.notification", { | |
| type: "notice", | |
| message: a.localize.getString("NOTIFICATION_PLAYLIST_RESTORED") | |
| }) | |
| }), function() { | |
| c && a.publish("gs.notification", { | |
| type: "error", | |
| message: a.localize.getString("NOTIFICATION_PLAYLIST_RESTORE_FAIL") | |
| }) | |
| }); | |
| else { | |
| g.isDeleted = false; | |
| this.playlists[g.PlaylistID] = g; | |
| a.publish("gs.playlist.view.update", g); | |
| c && a.publish("gs.notification", { | |
| type: "notice", | |
| message: a.localize.getString("NOTIFICATION_PLAYLIST_RESTORED") | |
| }) | |
| } | |
| } | |
| GS.getGuts().gaTrackEvent("user", "restorePlaylist") | |
| }, | |
| getSidebar: function() { | |
| GS.service.getUserSidebar(this.callback("loadSidebar")) | |
| }, | |
| loadSidebar: function( b ) { | |
| this.sidebarLoaded = true; | |
| if ( a.isArray(b.meta) ) b.meta = {}; | |
| this.sidebar = a.extend(true, this.sidebar, b); | |
| a.publish("gs.auth.sidebar.loaded"); | |
| if ( this.sidebar.stations.length === 0 ) { | |
| var c = this; | |
| _.forEach(this.defaultStations, function( g ) { | |
| c.addToShortcuts("station", g, "", false) | |
| }) | |
| } | |
| }, | |
| getFavorites: function() { | |
| var b = this; | |
| _.forEach(["Albums", "Artists", "Playlists", "Songs", "Users"], function( c ) { | |
| GS.service.getFavorites(b.UserID, c, false, b.callback("load" + c + "Favorites")) | |
| }) | |
| }, | |
| loadAlbumsFavorites: function( b ) { | |
| _.forEach(this.favorites.albums, function( c ) { | |
| b.push(c) | |
| }); | |
| this._super(b); | |
| a.publish("gs.auth.favorites.albums.update") | |
| }, | |
| loadArtistsFavorites: function( b ) { | |
| _.forEach(this.favorites.artists, function( c ) { | |
| b.push(c) | |
| }); | |
| this._super(b); | |
| a.publish("gs.auth.favorites.artists.update") | |
| }, | |
| loadPlaylistsFavorites: function( b ) { | |
| _.forEach(this.favorites.playlists, function( c ) { | |
| b.push(c) | |
| }); | |
| this._super(b); | |
| a.publish("gs.auth.favorites.playlists.update") | |
| }, | |
| loadSongsFavorites: function( b ) { | |
| _.forEach(this.favorites.songs, function( c ) { | |
| b.push(c) | |
| }); | |
| this._super(b); | |
| a.publish("gs.auth.favorites.songs.update") | |
| }, | |
| loadUsersFavorites: function( b ) { | |
| _.forEach(this.favorites.users, function( c ) { | |
| b.push(c) | |
| }); | |
| this._super(b); | |
| this.userFavoritesLoaded = true; | |
| a.publish("gs.auth.favorites.users.update") | |
| }, | |
| getLibrary: function() { | |
| var b = GS.store.get("library" + this.UserID); | |
| if ( b ) { | |
| var c = b.songs; | |
| delete b.songs; | |
| this.library = GS.Models.Library.wrap(b); | |
| for ( var g in c ) | |
| if ( c.hasOwnProperty(g) ) { | |
| c[g] = GS.Models.Song.unarchive(c[g]); | |
| c[g].fromLibrary = 1 | |
| } | |
| b = this.library.songs; | |
| this.library.songs = GS.Models.Song.wrapCollectionInObject(c, { | |
| TSAdded: "", | |
| TSFavorited: "" | |
| }); | |
| _.forEach(b, function( h ) { | |
| _.defined(this.library.songs[h.SongID]) || (this.library.songs[h.SongID] = h) | |
| }, this); | |
| GS.service.userGetLibraryTSModified(this.UserID, this.callback("refreshLibrary")) | |
| } else { | |
| this.library = | |
| GS.Models.Library.wrap({ | |
| userID: this.UserID | |
| }); | |
| this.library.getSongs(this.callback("loadLibrary"), false, false) | |
| } | |
| }, | |
| refreshLibrary: function( b ) { | |
| if ( b.TSModified > this.library.lastModified ) { | |
| this.library.currentPage = 0; | |
| this.library.songsLoaded = false; | |
| this.library.getSongs(this.callback("loadLibrary"), false, false) | |
| } else a.publish("gs.auth.library.update") | |
| }, | |
| loadLibrary: function( b ) { | |
| for ( var c = 0; c < b.length; c++ ) | |
| this.library.songs[b[c].SongID] = b[c]; | |
| a.publish("gs.auth.library.update"); | |
| this.library.songsLoaded || this.library.getSongs(this.callback("loadLibrary"), false, false) | |
| }, | |
| addToSongFavorites: function( b, c ) { | |
| c = _.orEqual(c, true); | |
| if (!this.favorites.songs[b] ) { | |
| var g = GS.Models.Song.getOneFromCache(b); | |
| if (!g ) throw "AUTH.ADDTOSONGFAVES. SONGID NOT IN CACHE: " + b; | |
| g = g.dupe(); | |
| g.isFavorite = 1; | |
| g.fromLibrary = 1; | |
| g.TSFavorited = (new Date).format("Y-m-d G:i:s"); | |
| if (!_.defined(g.TSAdded) || g.TSAdded === "" ) g.TSAdded = g.TSFavorited; | |
| if ( this.library.songs[b] ) this.library.songs[b] = g; | |
| else { | |
| this.library.songs[b] = g; | |
| a.publish("gs.auth.library.add", g) | |
| } | |
| this.favorites.songs[b] = g.dupe(); | |
| GS.getGuts().logEvent("objectFavorited", { | |
| type: "song", | |
| id: b | |
| }); | |
| a.publish("gs.auth.song.update", g); | |
| a.publish("gs.auth.favorites.songs.add", g); | |
| c && a.publish("gs.notification.favorite.song", g); | |
| if ( this.isLoggedIn ) GS.service.favorite("Song", g.SongID, g.getDetailsForFeeds(), null, this.callback(this._favoriteFail, "Song", g)); | |
| else this.isDirty = true; | |
| GS.getGuts().gaTrackEvent("user", "favoriteSong") | |
| } | |
| }, | |
| addToPlaylistFavorites: function( b, c ) { | |
| c = _.orEqual(c, true); | |
| if (!this.favorites.playlists[b] ) { | |
| var g = GS.Models.Playlist.getOneFromCache(b); | |
| if (!g ) throw "AUTH.ADDTOPLAYLISTFAVES. PLAYLISTID NOT IN CACHE: " + b; | |
| g.isFavorite = 1; | |
| g.TSFavorited = (new Date).format("Y-m-d G:i:s"); | |
| this.favorites.playlists[b] = g; | |
| GS.getGuts().logEvent("objectFavorited", { | |
| type: "playlist", | |
| id: b | |
| }); | |
| this.addToShortcuts("playlist", b, g.PlaylistName, false); | |
| a.publish("gs.auth.favorites.playlists.update"); | |
| a.publish("gs.auth.playlist.update", g); | |
| a.publish("gs.auth.favorite.playlist", g); | |
| a.publish("gs.playlist.view.update", this); | |
| c && a.publish("gs.notification.favorite.playlist", g); | |
| if ( this.isLoggedIn ) GS.service.favorite("Playlist", g.PlaylistID, g.getDetailsForFeeds(), null, this.callback(this._favoriteFail, "Playlist", g)); | |
| else this.isDirty = true; | |
| GS.getGuts().gaTrackEvent("user", "favoritePlaylist") | |
| } | |
| }, | |
| removeFromPlaylistFavorites: function( b, c ) { | |
| c = _.orEqual(c, true); | |
| var g = GS.Models.Playlist.getOneFromCache(b); | |
| if ( g ) { | |
| this.removeFromShortcuts("playlist", g.PlaylistID, false); | |
| g.isFavorite = 0; | |
| GS.Models.Playlist.cache[b] = g; | |
| delete this.favorites.playlists[b]; | |
| GS.getGuts().logEvent("objectUnfavorited", { | |
| type: "playlist", | |
| id: b | |
| }); | |
| a.publish("gs.auth.favorites.playlists.update"); | |
| a.publish("gs.auth.playlist.update", g); | |
| a.publish("gs.playlist.view.update", this); | |
| this.isLoggedIn && GS.service.unfavorite("Playlist", b); | |
| c && a.publish("gs.notification", { | |
| type: "notify", | |
| message: a.localize.getString("NOTIFICATION_PLAYLIST_UNSUBSCRIBED") | |
| }); | |
| GS.getGuts().gaTrackEvent("user", "unfavoritePlaylist") | |
| } | |
| }, | |
| addToArtistFavorites: function( b, c ) { | |
| c = _.orEqual(c, true); | |
| if (!this.favorites.artists[b] ) { | |
| var g = GS.Models.Artist.getOneFromCache(b); | |
| if (!g ) throw "AUTH.ADDTOARTSTTFAVES. ARTISTID NOT IN CACHE: " + b; | |
| g.isFavorite = 1; | |
| g.TSFavorited = (new Date).format("Y-m-d G:i:s"); | |
| this.favorites.artists[b] = g; | |
| GS.getGuts().logEvent("objectFavorited", { | |
| type: "artist", | |
| id: b | |
| }); | |
| a.publish("gs.auth.favorites.artists.update"); | |
| c && a.publish("gs.notification.favorite.artist", g); | |
| if ( this.isLoggedIn ) GS.service.favorite("Artist", g.ArtistID, g.getDetailsForFeeds(), null, this.callback(this._favoriteFail, "Artist", g)); | |
| else this.isDirty = true; | |
| GS.getGuts().gaTrackEvent("user", "favoriteArtist") | |
| } | |
| }, | |
| removeFromArtistFavorites: function( b, c ) { | |
| c = _.orEqual(c, true); | |
| var g = GS.Models.Artist.getOneFromCache(b); | |
| if ( g ) { | |
| g.isFavorite = | |
| 0; | |
| GS.Models.Artist.cache[b] = g; | |
| delete this.favorites.artists[b]; | |
| GS.getGuts().logEvent("objectUnfavorited", { | |
| type: "artist", | |
| id: b | |
| }); | |
| a.publish("gs.auth.favorites.artists.update"); | |
| this.isLoggedIn && GS.service.unfavorite("Artist", b); | |
| c && a.publish("gs.notification", { | |
| type: "notify", | |
| message: a.localize.getString("NOTIFICATION_ARTIST_UNSUBSCRIBED") | |
| }); | |
| GS.getGuts().gaTrackEvent("user", "unfavoriteArtist") | |
| } | |
| }, | |
| removeFromSongFavorites: function( b, c ) { | |
| c = _.orEqual(c, true); | |
| var g = this.favorites.songs[b]; | |
| if ( g ) { | |
| g.isFavorite = 0; | |
| delete this.favorites.songs[b]; | |
| GS.getGuts().logEvent("objectUnfavorited", { | |
| type: "song", | |
| id: b | |
| }); | |
| this.library.songs[b] = g.dupe(); | |
| a.publish("gs.auth.song.update", g); | |
| a.publish("gs.auth.favorites.songs.remove", g); | |
| this.isLoggedIn && GS.service.unfavorite("Song", g.SongID); | |
| if ( c ) { | |
| g = { | |
| songLink: "<a class='songLink' rel='" + g.SongID + "'>" + g.SongName + "</a>", | |
| artistLink: "<a href='" + _.cleanUrl(g.ArtistName, g.ArtistID, "artist", null, null) + "'>" + g.ArtistName + "</a>" | |
| }; | |
| a.publish("gs.notification", { | |
| type: "notify", | |
| message: (new GS.Models.DataString(a.localize.getString("NOTIF_UNFAVORITED_SONG"), g)).render() | |
| }) | |
| } | |
| GS.getGuts().gaTrackEvent("user", "unfavoriteSong") | |
| } | |
| }, | |
| addToUserFavorites: function( b, c ) { | |
| c = _.orEqual(c, true); | |
| if (!(!b || this.favorites.users[b])) { | |
| var g = GS.Models.User.getOneFromCache(b); | |
| if (!g || this.UserID === g.UserID ) this._favoriteFail("User", null); | |
| else { | |
| g.isFavorite = 1; | |
| this.favorites.users[b] = g; | |
| GS.getGuts().logEvent("objectFavorited", { | |
| type: "user", | |
| id: b | |
| }); | |
| a.publish("gs.auth.favorites.users.update"); | |
| a.publish("gs.auth.user.update", g); | |
| a.publish("gs.auth.favorite.user", g); | |
| c && a.publish("gs.notification.favorite.user", g); | |
| if ( this.isLoggedIn ) GS.service.favorite("User", g.UserID, g.getDetailsForFeeds(), null, this.callback(this._favoriteFail, "User", g)); | |
| else this.isDirty = true; | |
| this.communityFeed.isDirty = true; | |
| GS.getGuts().gaTrackEvent("user", "followUser") | |
| } | |
| } | |
| }, | |
| removeFromUserFavorites: function( b ) { | |
| var c = GS.Models.User.getOneFromCache(b); | |
| if (!(!c || this.UserID === c.UserID)) { | |
| c.isFavorite = 0; | |
| GS.Models.User.cache[b] = c; | |
| delete this.favorites.users[b]; | |
| GS.getGuts().logEvent("objectUnfavorited", { | |
| type: "user", | |
| id: b | |
| }); | |
| a.publish("gs.auth.favorites.users.update"); | |
| a.publish("gs.auth.user.update", c); | |
| this.communityFeed.isDirty = true; | |
| this.isLoggedIn && GS.service.unfavorite("User", c.UserID); | |
| GS.getGuts().gaTrackEvent("user", "unfollowUser") | |
| } | |
| }, | |
| changeFollowFlags: function( b ) { | |
| this.isLoggedIn ? GS.service.changeFollowFlags(b, this.callback("changeFollowFlagsSuccess", b), this.callback("changeFollowFlagsFail")) : this.changeFollowFlagsFail() | |
| }, | |
| changeFollowFlagsSuccess: function( b, c ) { | |
| if ( c.success ) { | |
| for ( var g in b ) | |
| if ( b.hasOwnProperty(g) ) if ( this.favorites.users[b[g].userID] ) this.favorites.users[b[g].userID].FollowingFlags = b[g].flags; | |
| this.communityFeed.isDirty = true; | |
| a.publish("gs.auth.favorites.users.update") | |
| } else this.changeFollowFlagsFail() | |
| }, | |
| changeFollowFlagsFail: function() { | |
| a.publish("gs.notification", { | |
| message: a.localize.getString("SETTINGS_USER_HIDE_FAIL") | |
| }) | |
| }, | |
| addToLibrary: function( b, c ) { | |
| c = _.orEqual(c, true); | |
| var g = []; | |
| b = a.makeArray(b); | |
| for ( var h = 0; h < b.length; h++ ) { | |
| var k = b[h]; | |
| if (!this.library.songs[k] ) { | |
| var m = GS.Models.Song.getOneFromCache(k); | |
| if ( m ) { | |
| m = m.dupe(); | |
| m.fromLibrary = 1; | |
| if ( this.favorites.songs[k] ) m.isFavorite = 1; | |
| if (!_.defined(m.TSAdded) || m.TSAdded === "" ) m.TSAdded = (new Date).format("Y-m-d G:i:s"); | |
| this.library.songs[k] = m; | |
| GS.getGuts().logEvent("songAddedToLibrary", { | |
| id: k | |
| }); | |
| a.publish("gs.auth.library.add", m); | |
| a.publish("gs.auth.song.update", m); | |
| g.push(m.getDetailsForFeeds()) | |
| } | |
| } | |
| } | |
| if (!_.isEmpty(g) ) { | |
| if ( this.isLoggedIn ) GS.service.userAddSongsToLibrary(g, this.callback("addToLibrarySuccess", c, g), this.callback("addtoLibraryFailed")); | |
| else { | |
| this.isDirty = true; | |
| this.addToLibrarySuccess(c, g) | |
| } | |
| GS.getGuts().gaTrackEvent("user", "addLibrarySong") | |
| } | |
| }, | |
| addToLibrarySuccess: function( b, c, g ) { | |
| b && a.publish("gs.auth.library.songsAdded", { | |
| songs: c | |
| }); | |
| if ( g ) { | |
| tsAdded = parseInt(g.Timestamps.newTSModified, 10); | |
| parseInt(g.Timestamps.oldTSModified, 10) > this.library.lastModified && this.library.getSongs(this.callback("loadLibrary"), false, false) | |
| } else tsAdded = _.unixTime(); | |
| this.library.lastModified = tsAdded; | |
| b = (new Date(tsAdded * 1E3)).format("Y-m-d G:i:s"); | |
| for ( g = 0; g < c.length; g++ ) | |
| this.library.songs[c[g].songID].TSAdded = b | |
| }, | |
| _favoriteFail: function( b, c ) { | |
| var g = "NOTIFICATION_LIBRARY_ADD_FAIL", | |
| h = {}; | |
| if ( c ) switch ( b ) { | |
| case "Song": | |
| g += "_SONG"; | |
| h.name = c.SongName; | |
| break; | |
| case "Playlist": | |
| g += "_PLAYLIST"; | |
| h.name = c.PlaylistName; | |
| break; | |
| case "User": | |
| g += "_USER"; | |
| h.name = c.Name; | |
| break | |
| } | |
| a.publish("gs.notification", { | |
| type: "error", | |
| message: (new GS.Models.DataString(a.localize.getString(g), h)).render() | |
| }) | |
| }, | |
| addToLibraryFailed: function() { | |
| var b = { | |
| numSongs: songIDsToAdd.length | |
| }; | |
| a.publish("gs.notification", { | |
| type: "error", | |
| message: (new GS.Models.DataString(a.localize.getString(songIDsToAdd.length > 1 ? "NOTIFICATION_LIBRARY_ADD_SONGS_FAIL" : "NOTIFICATION_LIBRARY_ADD_SONG_FAIL"), b)).render() | |
| }) | |
| }, | |
| removeFromLibrary: function( b, c ) { | |
| c = _.orEqual(c, true); | |
| b = a.makeArray(b); | |
| for ( var g = [], h = [], k = [], m = 0; m < b.length; m++ ) { | |
| var p = b[m], | |
| n = this.library.songs[p]; | |
| if ( n ) { | |
| delete this.library.songs[p]; | |
| GS.getGuts().logEvent("songRemovedFromLibrary", { | |
| id: p | |
| }); | |
| delete this.favorites.songs[p]; | |
| n.fromLibrary = 0; | |
| n.isFavorite = 0; | |
| GS.Models.Song.cache[n.SongID] = n; | |
| a.publish("gs.auth.library.remove", n); | |
| a.publish("gs.auth.song.update", n); | |
| g.push(n.SongID); | |
| h.push(n.ArtistID); | |
| k.push(n.AlbumID) | |
| } else console.warn("removing song not in library!", p) | |
| } | |
| if (!_.isEmpty(g) ) { | |
| if ( this.isLoggedIn ) { | |
| GS.service.userRemoveSongsFromLibrary(this.UserID, g, k, h, this.callback("removeFromLibrarySuccess", c, g), this.callback("removeFromLibraryFailed", n)); | |
| GS.service.unfavorite("Song", n.SongID) | |
| } else this.removeFromLibrarySuccess(c, g); | |
| GS.getGuts().gaTrackEvent("user", "removeLibrarySong") | |
| } | |
| }, | |
| removeFromLibrarySuccess: function( b, c, g ) { | |
| if ( g ) if ( parseInt(g.Timestamps.oldTSModified, 10) > this.library.lastModified ) this.library.getSongs(this.callback("loadLibrary"), false, false); | |
| else this.library.lastModified = parseInt(g.Timestamps.newTSModified, 10); | |
| if ( b ) { | |
| b = GS.Models.Song.getOneFromCache(c[0]); | |
| !b || !b.SongName || c.length > 1 ? a.publish("gs.notification", { | |
| message: _.getString("NOTIFICATION_LIBRARY_REMOVE_SONGS", { | |
| numSongs: c.length | |
| }) | |
| }) : a.publish("gs.notification", { | |
| message: _.getString("NOTIFICATION_LIBRARY_REMOVE_SONG", { | |
| song: b.SongName | |
| }) | |
| }) | |
| } | |
| }, | |
| removeFromLibraryFailed: function() { | |
| a.publish("gs.notification", { | |
| type: "error", | |
| message: a.localize.getString("NOTIFICATION_LIBRARY_REMOVE_FAIL") | |
| }) | |
| }, | |
| isShortcut: function( b, c ) { | |
| if (!c || !b ) return false; | |
| b = b.toLowerCase(); | |
| c = c.toString(); | |
| switch ( b ) { | |
| case "playlist": | |
| return this.sidebar.playlists.indexOf(c) > -1 || this.sidebar.subscribedPlaylists.indexOf(c) > -1; | |
| case "station": | |
| return this.sidebar.stations.indexOf(c) > -1; | |
| case "song": | |
| return this.sidebar.songs.indexOf(c) > -1; | |
| case "artist": | |
| return this.sidebar.artists.indexOf(c) > -1; | |
| case "album": | |
| return this.sidebar.albums.indexOf(c) > -1 | |
| } | |
| return false | |
| }, | |
| addToShortcuts: function( b, c, g, h ) { | |
| h = _.orEqual(h, true); | |
| b = b.toLowerCase(); | |
| var k = c.toString(); | |
| switch ( b ) { | |
| case "playlist": | |
| b = GS.Models.Playlist.getOneFromCache(c); | |
| if (!b ) return; | |
| b = b.UserID === this.UserID ? "playlists" : "subscribedPlaylists"; | |
| break; | |
| case "station": | |
| case "song": | |
| case "artist": | |
| case "album": | |
| b = b + "s"; | |
| break; | |
| default: | |
| return | |
| } | |
| if ( this.sidebar[b].indexOf(k) === -1 ) { | |
| this.sidebar[b].unshift(k); | |
| this.sidebar.meta[b][c] = g; | |
| a.publish("gs.auth.pinboard.update", { | |
| type: b | |
| }); | |
| if ( this.isLoggedIn ) GS.service.addShortcutToUserSidebar(b, c, g, this.callback(this._addShortcutSuccess, b, c, h), this.callback(this._addShortcutFailed, b, c, h)); | |
| else { | |
| this.isDirty = true; | |
| this._addShortcutSuccess(b, c, h, {}) | |
| } | |
| GS.getGuts().gaTrackEvent("user", "addShortcut") | |
| } | |
| }, | |
| _addShortcutSuccess: function( b, c, g ) { | |
| var h, k = {}; | |
| switch ( b ) { | |
| case "playlists": | |
| case "subscribedPlaylists": | |
| if ( b = GS.Models.Playlist.getOneFromCache(c) ) { | |
| h = "NOTIFICATION_PLAYLIST_PINBOARD_ADD_SUCCESS"; | |
| k.playlist = b.PlaylistName; | |
| a.publish("gs.playlist.view.update", b) | |
| } | |
| break; | |
| case "stations": | |
| b = GS.Models.Station.getOneFromCache(c); | |
| h = "NOTIFICATION_STATION_PINBOARD_ADD_SUCCESS"; | |
| k.station = a.localize.getString(b.StationTitle); | |
| break; | |
| case "songs": | |
| if ( b = GS.Models.Song.getOneFromCache(c) ) { | |
| h = "NOTIFICATION_SONG_PINBOARD_ADD_SUCCESS"; | |
| k.song = b.SongName | |
| } | |
| break; | |
| case "artists": | |
| if ( b = GS.Models.Artist.getOneFromCache(c) ) { | |
| h = "NOTIFICATION_ARTIST_PINBOARD_ADD_SUCCESS"; | |
| k.artist = b.ArtistName | |
| } | |
| break; | |
| case "albums": | |
| if ( b = GS.Models.Album.getOneFromCache(c) ) { | |
| h = "NOTIFICATION_ALBUM_PINBOARD_ADD_SUCCESS"; | |
| k.album = b.AlbumName | |
| } | |
| break | |
| } | |
| if ( g && h ) { | |
| g = new GS.Models.DataString(a.localize.getString(h), k); | |
| a.publish("gs.notification", { | |
| type: "notice", | |
| message: g.render() | |
| }) | |
| } | |
| }, | |
| _addShortcutFailed: function( b, c, g ) { | |
| var h, k = {}, | |
| m = this.sidebar[b].indexOf(c.toString()); | |
| if ( m != -1 ) { | |
| this.sidebar[b].splice(m, 1); | |
| a.publish("gs.auth.pinboard.update", { | |
| type: b | |
| }) | |
| } | |
| switch ( b ) { | |
| case "playlists": | |
| case "subscribedPlaylists": | |
| if ( b = GS.Models.Playlist.getOneFromCache(c) ) { | |
| h = "NOTIFICATION_PLAYLIST_PINBOARD_ADD_FAILED"; | |
| k.playlist = b.PlaylistName; | |
| a.publish("gs.playlist.view.update", b) | |
| } | |
| break; | |
| case "stations": | |
| b = GS.Models.Station.getOneFromCache(c); | |
| h = "NOTIFICATION_STATION_PINBOARD_ADD_FAILED"; | |
| k.station = a.localize.getString(b.StationTitle); | |
| break; | |
| case "songs": | |
| if ( b = GS.Models.Song.getOneFromCache(c) ) { | |
| h = "NOTIFICATION_SONG_PINBOARD_ADD_FAILED"; | |
| k.song = b.SongName | |
| } | |
| break; | |
| case "artists": | |
| if ( b = GS.Models.Artist.getOneFromCache(c) ) { | |
| h = "NOTIFICATION_ARTIST_PINBOARD_ADD_FAILED"; | |
| k.artist = b.ArtistName | |
| } | |
| break; | |
| case "albums": | |
| if ( b = GS.Models.Album.getOneFromCache(c) ) { | |
| h = "NOTIFICATION_ALBUM_PINBOARD_ADD_FAILED"; | |
| k.album = b.AlbumName | |
| } | |
| break | |
| } | |
| if ( g && h ) { | |
| g = new GS.Models.DataString(a.localize.getString(h), k); | |
| a.publish("gs.notification", { | |
| type: "error", | |
| message: g.render() | |
| }) | |
| } | |
| }, | |
| removeFromShortcuts: function( b, c, g ) { | |
| g = _.orEqual(g, true); | |
| switch ( b ) { | |
| case "playlist": | |
| b = GS.Models.Playlist.getOneFromCache(c); | |
| if (!b ) return; | |
| b = b.UserID === this.UserID ? "playlists" : "subscribedPlaylists"; | |
| break; | |
| case "station": | |
| case "song": | |
| case "artist": | |
| case "album": | |
| b = b + "s"; | |
| break; | |
| default: | |
| return | |
| } | |
| var h = this.sidebar[b].indexOf(c.toString()); | |
| if ( h != -1 ) { | |
| this.sidebar[b].splice(h, 1); | |
| a.publish("gs.auth.pinboard.update", { | |
| type: b | |
| }); | |
| if ( this.isLoggedIn ) GS.service.removeShortcutFromUserSidebar(b, c, this.callback(this._removeShortcutSuccess, b, c, g), this.callback(this._removeShortcutFailed, b, c, h, g)); | |
| else { | |
| this.isDirty = true; | |
| this._removeShortcutSuccess(b, c, g, {}) | |
| } | |
| GS.getGuts().gaTrackEvent("user", "removeShortcut") | |
| } | |
| }, | |
| _removeShortcutSuccess: function( b, c, g ) { | |
| var h, k = {}; | |
| switch ( b ) { | |
| case "playlists": | |
| case "subscribedPlaylists": | |
| if ( b = GS.Models.Playlist.getOneFromCache(c) ) { | |
| h = "NOTIFICATION_PLAYLIST_PINBOARD_REMOVE_SUCCESS"; | |
| k.playlist = b.PlaylistName; | |
| a.publish("gs.playlist.view.update", b) | |
| } | |
| break; | |
| case "stations": | |
| b = GS.Models.Station.getOneFromCache(c); | |
| h = "NOTIFICATION_STATION_PINBOARD_REMOVE_SUCCESS"; | |
| k.station = a.localize.getString(b.StationTitle); | |
| break; | |
| case "songs": | |
| if ( b = GS.Models.Song.getOneFromCache(c) ) { | |
| h = "NOTIFICATION_SONG_PINBOARD_REMOVE_SUCCESS"; | |
| k.song = b.SongName | |
| } | |
| break; | |
| case "artists": | |
| if ( b = GS.Models.Artist.getOneFromCache(c) ) { | |
| h = "NOTIFICATION_ARTIST_PINBOARD_REMOVE_SUCCESS"; | |
| k.artist = b.ArtistName | |
| } | |
| break; | |
| case "albums": | |
| if ( b = GS.Models.Album.getOneFromCache(c) ) { | |
| h = "NOTIFICATION_ALBUM_PINBOARD_REMOVE_SUCCESS"; | |
| k.album = b.AlbumName | |
| } | |
| break | |
| } | |
| if ( g && h ) { | |
| g = new GS.Models.DataString(a.localize.getString(h), k); | |
| a.publish("gs.notification", { | |
| type: "notice", | |
| message: g.render() | |
| }) | |
| } | |
| }, | |
| _removeShortcutFailed: function( b, c, g, h ) { | |
| var k, m, p = {}; | |
| if ( g < 0 ) g = 0; | |
| switch ( b ) { | |
| case "playlists": | |
| case "subscribedPlaylists": | |
| if ( k = GS.Models.Playlist.getOneFromCache(c) ) { | |
| m = "NOTIFICATION_PLAYLIST_PINBOARD_REMOVE_FAILED"; | |
| p.playlist = k.PlaylistName; | |
| a.publish("gs.playlist.view.update", k) | |
| } | |
| break; | |
| case "stations": | |
| k = GS.Models.Station.getOneFromCache(c); | |
| m = "NOTIFICATION_STATION_PINBOARD_REMOVE_FAILED"; | |
| p.station = a.localize.getString(k.StationTitle); | |
| break; | |
| case "songs": | |
| if ( k = GS.Models.Song.getOneFromCache(c) ) { | |
| m = "NOTIFICATION_SONG_PINBOARD_REMOVE_FAILED"; | |
| p.song = k.SongName | |
| } | |
| break; | |
| case "artists": | |
| if ( k = GS.Models.Artist.getOneFromCache(c) ) { | |
| m = "NOTIFICATION_ARTIST_PINBOARD_REMOVE_FAILED"; | |
| p.artist = k.ArtistName | |
| } | |
| break; | |
| case "albums": | |
| if ( k = GS.Models.Album.getOneFromCache(c) ) { | |
| m = "NOTIFICATION_ALBUM_PINBOARD_REMOVE_FAILED"; | |
| p.album = k.AlbumName | |
| } | |
| break | |
| } | |
| if ( g != -1 ) { | |
| this.sidebar[b].splice(g, 0, c.toString()); | |
| a.publish("gs.auth.pinboard.update", { | |
| type: b | |
| }) | |
| } | |
| if ( h && m ) { | |
| b = new GS.Models.DataString(a.localize.getString(m), p); | |
| a.publish("gs.notification", { | |
| type: "error", | |
| message: b.render() | |
| }) | |
| } | |
| }, | |
| changePassword: function( b, c, g, h ) { | |
| this.isLoggedIn ? GS.service.changePassword(b, c, this.callback(this._passwordSuccess, g, h), this.callback(this._passwordFailed, h)) : this._passwordFailed(h); | |
| GS.getGuts().gaTrackEvent("user", "changePassword") | |
| }, | |
| _passwordSuccess: function( b, c, g ) { | |
| if ( g && g.statusCode === 1 ) a.isFunction(b) && b(g); | |
| else this._passwordFailed(c, g) | |
| }, | |
| _passwordFailed: function( b, c ) { | |
| a.isFunction(b) && b(c) | |
| }, | |
| updateAccountType: function( b ) { | |
| b = b.toLowerCase(); | |
| switch ( b ) { | |
| case "plus": | |
| this.IsPremium = | |
| 1; | |
| this.Flags |= 1; | |
| break; | |
| case "anywhere": | |
| this.IsPremium = 1; | |
| this.Flags |= 128; | |
| break; | |
| default: | |
| this.IsPremium = 0; | |
| this.Flags &= -2; | |
| this.Flags &= -129; | |
| break | |
| } | |
| a.publish("gs.auth.update"); | |
| this.checkVipExpiring(); | |
| GS.getGuts().gaTrackEvent("user", "updateAccount", b) | |
| }, | |
| checkVipExpiring: function() { | |
| this.IsPremium && GS.service.getSubscriptionDetails(this.callback("checkVipExpiringCallback"), this.callback("checkVipExpiringCallback")) | |
| }, | |
| checkVipExpiringCallback: function( b ) { | |
| var c, g, h = new Date; | |
| c = false; | |
| if (!(b === false || b.fault || b.code)) { | |
| b.bVip = | |
| b.bVip ? parseInt(b.bVip, 10) : false; | |
| b.bActive = b.bActive ? parseInt(b.bActive, 10) : false; | |
| if (!b.bRecurring ) { | |
| g = b.period === "MONTH" ? true : false; | |
| if ( c = _.orEqual(b.dateSubcriptionEnd, b.dateEnd) ) { | |
| c = c.split("-"); | |
| c = g ? new Date(c[0], parseInt(c[1], 10) - 1, c[2]) : new Date(parseInt(c[0], 10) + 1, c[1], c[2]) | |
| } else if ( b.dateStart ) { | |
| c = b.dateStart.split("-"); | |
| c = g ? new Date(c[0], parseInt(c[1], 10), c[2]) : new Date(parseInt(c[0], 10) + 1, c[1], c[2]) | |
| } | |
| if ( c && !b.bRecurring ) { | |
| g = _.orEqual(GS.store.get("gs.vipExpire.hasSeen" + this.UserID), 0); | |
| g = h.getTime() - g; | |
| h = c.getTime() - h.getTime(); | |
| c = Math.max(0, Math.ceil(h / 864E5)); | |
| c += c == 1 ? " day" : " days"; | |
| c = h <= 0 ? (new GS.Models.DataString(a.localize.getString("POPUP_VIP_EXPIRES_NO_DAYS"), { | |
| vipPackage: b.subscriptionType | |
| })).render() : (new GS.Models.DataString(a.localize.getString("POPUP_VIP_EXPIRES_DAYS_LEFT"), { | |
| daysLeft: c, | |
| vipPackage: b.subscriptionType | |
| })).render(); | |
| b.daysLeft = c; | |
| if ( g >= 1728E5 ) if ( h < 864E5 ) { | |
| b.timeframe = "oneDay"; | |
| GS.getLightbox().open("vipExpires", b) | |
| } else if ( h < 1728E5 ) { | |
| b.timeframe = "twoDays"; | |
| GS.getLightbox().open("vipExpires", b) | |
| } else if ( h < 12096E5 ) { | |
| b.timeframe = "twoWeeks"; | |
| GS.getLightbox().open("vipExpires", b) | |
| } else if ( h <= 0 && Math.abs(h) <= 6048E5 ) { | |
| b.timeframe = "expired"; | |
| GS.getLightbox().open("vipExpires", b) | |
| } | |
| setTimeout(this.callback("checkVipExpiring"), 1728E5) | |
| } | |
| } | |
| } | |
| }, | |
| getAutoNewPlaylistName: function() { | |
| var b, c, g, h = []; | |
| g = this.Name && this.Name.length ? this.Name + "'s Playlist " : "Playlist "; | |
| _.forEach(this.playlists, function( k ) { | |
| b = k.PlaylistName.indexOf(g); | |
| if ( b != -1 )(c = parseInt(k.PlaylistName.substring(b + g.length), 10)) && h.push(c) | |
| }); | |
| if ( h.length ) { | |
| h.sort(_.numSortA); | |
| c = h[h.length - 1] + 1 | |
| } else c = 1; | |
| return g + c | |
| }, | |
| isPlaylistNameAvailable: function( b ) { | |
| var c; | |
| for ( c in this.playlists ) | |
| if ( this.playlists.hasOwnProperty(c) ) if ( b === this.playlists[c].PlaylistName ) return false; | |
| return true | |
| }, | |
| getPoints: function( b, c ) { | |
| if ( this._pointsDirty ) if ( this._pointsPending ) this._pointsPending.then(b, c); | |
| else { | |
| this._pointsPending = a.Deferred(); | |
| this._pointsPending.then(b, c); | |
| GS.service.userGetPoints(this.callback("_pointsSuccess"), this.callback("_pointsFail")) | |
| } | |
| else b(this.Points) | |
| }, | |
| _pointsSuccess: function( b ) { | |
| var c = | |
| parseInt(b, 10); | |
| if ( isNaN(c) ) { | |
| this._pointsPending.reject(b); | |
| this._pointsPending = false | |
| } else { | |
| var g = this.Points; | |
| this._pointsDirty = false; | |
| this.Points = c; | |
| this._pointsPending.resolve(c); | |
| this._pointsPending = false; | |
| g !== c && a.publish("gs.auth.pointsUpdated"); | |
| return b | |
| } | |
| }, | |
| _pointsFail: function( b ) { | |
| this._pointsPending.reject(b); | |
| this._pointsPending = false; | |
| return b | |
| }, | |
| invalidatePoints: function() { | |
| this._pointsDirty = true; | |
| a.publish("gs.auth.pointsUpdated") | |
| }, | |
| addPoints: function( b, c ) { | |
| c = _.orEqual(c, false); | |
| b = parseInt(b, 10); | |
| if (!isNaN(b) ) { | |
| this._pointsDirty = | |
| true; | |
| this.Points += b; | |
| a.publish("gs.auth.pointsUpdated"); | |
| c || GS.getNotice().displaySurveyPoints(b) | |
| } | |
| }, | |
| handleLiveRamp: function() { | |
| var b = GS.store.get("lastLiveRamp" + this.UserID), | |
| c = (new Date).valueOf(); | |
| if ( this.Email && (!b || c - b > 1296E6) ) { | |
| GS.store.set("lastLiveRamp" + this.UserID, c); | |
| var g = hex_sha1(a.trim(this.Email.toLowerCase())); | |
| _.wait(3E4).then(function() { | |
| a("iframe#liveRamp").remove(); | |
| var h = a('<iframe id="liveRamp" name="_rlcdn" width=0 height=0 frameborder=0></iframe>'), | |
| k = "http://ei.rlcdn.com/44054.html?s=" + g; | |
| h.css("visibility", "hidden"); | |
| h.bind("load", function() { | |
| h.css("visibility", "visible").unbind("load") | |
| }); | |
| h.attr("src", k); | |
| a("body").append(h) | |
| }) | |
| } | |
| } | |
| }) | |
| })(jQuery); | |
| (function( a ) { | |
| GS.Models.Base.extend("GS.Models.Fanbase", {}, { | |
| currentPage: 0, | |
| objectID: null, | |
| objectType: "", | |
| userIDs: [], | |
| fansLoaded: false, | |
| init: function( b ) { | |
| this._super(b); | |
| this.userIDs = _.orEqual(b.userIDs, []); | |
| this.fansLoaded = _.orEqual(b.fansLoaded, false) | |
| }, | |
| getFans: function( b, c, g ) { | |
| g = _.orEqual(g, false); | |
| if ( this.fansLoaded ) { | |
| c = GS.Models.User.getManyFromCache(this.userIDs); | |
| a.isFunction(b) && b(c) | |
| } else { | |
| g && this.currentPage === 0 && a.publish("gs.page.loading.grid"); | |
| this.objectType === "playlist" ? GS.service[this.objectType + "GetFans"](this.objectID, this.callback(["cacheAndReturnUsers", b]), c) : GS.service[this.objectType + "GetFans"](this.objectID, this.currentPage, this.callback(["cacheAndReturnUsers", b]), c) | |
| } | |
| }, | |
| cacheAndReturnUsers: function( b ) { | |
| for ( var c = GS.Models.User.wrapCollection(b.Users || b.Return.fans || b.Return), g = 0; g < c.length; g++ ) { | |
| var h = c[g]; | |
| this.userIDs.indexOf(h.UserID) == -1 && this.userIDs.push(h.UserID) | |
| } | |
| if ( _.defined(b.hasMore) && b.hasMore ) this.currentPage++; | |
| else this.fansLoaded = true; | |
| return c | |
| } | |
| }) | |
| })(jQuery); | |
| (function( a ) { | |
| GS.Models.Base.extend("GS.Models.Feed", { | |
| QUEUE_ADD_LIMIT: 50 | |
| }, { | |
| user: null, | |
| type: null, | |
| lastDocumentID: null, | |
| lastEventID: null, | |
| events: [], | |
| pages: [], | |
| currentPage: 0, | |
| hasMore: false, | |
| isLoaded: false, | |
| isComplete: false, | |
| isDirty: false, | |
| isErrored: false, | |
| lastRequest: 0, | |
| cache: {}, | |
| RATE_LIMIT: 6E4, | |
| PAGE_LIMIT: 5, | |
| getFeed: function( b, c ) { | |
| this.reset(); | |
| this.isComplete ? b(this.events) : this.fetch({ | |
| callback: b, | |
| errback: c | |
| }) | |
| }, | |
| next: function( b, c ) { | |
| this.fetch({ | |
| callback: b, | |
| errback: c | |
| }) | |
| }, | |
| reset: function() { | |
| var b = new Date; | |
| if (!this.isLoaded || b.getTime() > this.lastRequest + this.RATE_LIMIT || this.isDirty ) { | |
| this.events = []; | |
| this.lastDocumentID = this.lastEventID = 0; | |
| this.isLoaded = this.hasMore = this.isComplete = this.isDirty = this.isErrored = false; | |
| this.lastRequest = b.getTime(); | |
| this.cache = {}; | |
| this.pages = []; | |
| this.currentPage = 0 | |
| } | |
| }, | |
| fetch: function() { | |
| return [] | |
| }, | |
| onError: function( b ) { | |
| this.isLoaded = this.isErrored = true; | |
| b && b.errback && b.errback([]) | |
| }, | |
| filterFollows: function( b ) { | |
| return b.type == GS.Models.FeedEvent.USER_FOLLOWED_TYPE || b.type == GS.Models.FeedEvent.USERS_FOLLOWED_TYPE || b.type == GS.Models.FeedEvent.FAVORITE_USERS_TYPE ? false : true | |
| }, | |
| parseEvent: function( b ) { | |
| var c = null; | |
| try { | |
| c = GS.Models.FeedEvent.wrap(b) | |
| } catch (g) { | |
| gsConfig.runMode == "dev" && console.warn("Feed Parse Error: ", b.activityName, b, g) | |
| } | |
| return c | |
| }, | |
| parseUser: function( b, c ) { | |
| var g = [], | |
| h; | |
| for ( var k in b ) | |
| if ( b.hasOwnProperty(k) ) if ( h = parseEvent(k) ) { | |
| h.user = c; | |
| g.push(h) | |
| } | |
| return g | |
| }, | |
| getEvents: function( b ) { | |
| b = _.orEqual(b, 0); | |
| var c = this.events.concat(); | |
| if ( b ) { | |
| c = []; | |
| for ( var g = 0; g < this.events.length; g++ ) | |
| if ( this.events[g].time > b ) c.push(this.events[g]); | |
| else break | |
| } | |
| return c | |
| }, | |
| getSongGroups: function( b, c ) { | |
| var g = [], | |
| h, k, m, p, n, o = 0, | |
| t = {}; | |
| b = _.orEqual(b, 0); | |
| c = _.orEqual(c, GS.Models.Feed.QUEUE_ADD_LIMIT); | |
| var w = this.getEvents(b); | |
| for ( m = 0; m < w.length; m++ ) { | |
| n = w[m]; | |
| h = n.getSongs(); | |
| if ( o <= c && h.length && GS.Models.FeedEvent.ListenTypes[n.activityName] ) { | |
| k = []; | |
| for ( p = 0; p < h.length; p++ ) | |
| if (!t[h[p].SongID] ) { | |
| k.push(h[p].SongID); | |
| t[h[p].SongID] = true; | |
| o++ | |
| } | |
| g.push({ | |
| songIDs: k, | |
| context: n.getDetailsForFeeds() | |
| }); | |
| if ( o > c ) break | |
| } | |
| } | |
| return g | |
| }, | |
| play: function( b, c, g, h, k ) { | |
| this.isComplete ? this.playSongs(b, c, g, h, k) : this.getFeed(this.callback(function() { | |
| this.isComplete && this.playSongs(b, c, g, h, k) | |
| })) | |
| }, | |
| playSongs: function( b, c, g, h, k ) { | |
| if ( this.isComplete ) { | |
| b = _.orEqual(b, -1); | |
| c = _.orEqual(c, false); | |
| g = _.orEqual(g, 0); | |
| h = _.orEqual(h, GS.Models.Feed.QUEUE_ADD_LIMIT); | |
| k = _.orEqual(k, false); | |
| for ( var m = this.getSongGroups(g, h), p = this.getDetailsForFeeds(), n = m.length - 1; n >= 0; n-- ) { | |
| g = m[n]; | |
| h = g.songIDs.reverse(); | |
| GS.player.addSongsToQueueAt(h, b, c, a.extend({ | |
| event: g.context | |
| }, p), k && n === 0); | |
| if ( h.length ) c = false | |
| } | |
| } | |
| }, | |
| getDetailsForFeeds: function() { | |
| return { | |
| user: this.user ? this.user.getDetailsForFeeds() : null, | |
| type: GS.player.PLAY_CONTEXT_FEED, | |
| feedType: this.type | |
| } | |
| } | |
| }) | |
| })(jQuery); | |
| (function( a ) { | |
| GS.Models.Base.extend("GS.Models.FeedEvent", { | |
| ListenTypes: {}, | |
| PlaylistTypes: {}, | |
| SongTypes: {}, | |
| AlbumTypes: {}, | |
| ArtistTypes: {}, | |
| init: function() { | |
| GS.Models.FeedEvent.setTypes(); | |
| a.subscribe("gs.locale.ready", this.callback(this.updateDaysOfWeek)); | |
| a.subscribe("gs.locale.update", this.callback(this.updateDaysOfWeek)); | |
| this.updateDaysOfWeek() | |
| }, | |
| setTypes: function() { | |
| var b = {}; | |
| b.songPlayed = true; | |
| b.obsession = true; | |
| b.playlistPlayed = true; | |
| b.artistPlayed = true; | |
| b.albumPlayed = true; | |
| var c = {}; | |
| c.songPlayed = true; | |
| c.obsession = | |
| true; | |
| c.playlistPlayed = true; | |
| c.artistPlayed = true; | |
| c.albumPlayed = true; | |
| var g = {}; | |
| g.playlistPlayed = true; | |
| var h = {}; | |
| h.albumPlayed = true; | |
| var k = {}; | |
| k.artistPlayed = true; | |
| GS.Models.FeedEvent.ListenTypes = b; | |
| GS.Models.FeedEvent.SongTypes = c; | |
| GS.Models.FeedEvent.PlaylistTypes = g; | |
| GS.Models.FeedEvent.AlbumTypes = h; | |
| GS.Models.FeedEvent.ArtistTypes = k | |
| }, | |
| songPlayed: function( b ) { | |
| var c = {}; | |
| c.user = GS.Models.FeedEvent.getUserLink(b.user); | |
| c.song = ['<a class="songLink">', _.cleanText(b.data.songs[0].songName), "</a>"].join(""); | |
| c.artist = ['<a href="', _.cleanUrl(b.data.songs[0].artistName, b.data.songs[0].artistID, "artist"), '">', _.cleanText(b.data.songs[0].artistName), "</a>"].join(""); | |
| c.album = ['<a href="', _.cleanUrl(b.data.songs[0].albumName, b.data.songs[0].albumID, "album"), '">', _.cleanText(b.data.songs[0].albumName), "</a>"].join(""); | |
| c.numSongs = b.data.songs.length; | |
| if ( c.numSongs > 2 ) { | |
| b.dataKey = "FEED_LISTEN_SONGS_MANY"; | |
| c.numSongs-- | |
| } else if ( c.numSongs == 2 ) { | |
| c.song2 = ['<a class="songLink" data-song-index="1">', _.cleanText(b.data.songs[1].songName), "</a>"].join(""); | |
| b.dataKey = "FEED_LISTEN_SONGS_TWO" | |
| } else b.dataKey = "FEED_LISTEN_SONG"; | |
| return new GS.Models.DataString(a.localize.getString(b.dataKey), c) | |
| }, | |
| favoriteSong: function( b ) { | |
| var c = {}; | |
| c.user = GS.Models.FeedEvent.getUserLink(b.user); | |
| c.song = ['<a class="songLink">', _.cleanText(b.data.songs[0].songName), "</a>"].join(""); | |
| c.artist = ['<a href="', _.cleanUrl(b.data.songs[0].artistName, b.data.songs[0].artistID, "artist"), '">', _.cleanText(b.data.songs[0].artistName), "</a>"].join(""); | |
| c.album = ['<a href="', _.cleanUrl(b.data.songs[0].albumName, b.data.songs[0].albumID, "album"), '">', _.cleanText(b.data.songs[0].albumName), "</a>"].join(""); | |
| c.numSongs = b.data.songs.length; | |
| if ( c.numSongs > 2 ) { | |
| b.dataKey = "FEED_FAVORITE_SONGS_MANY"; | |
| c.numSongs-- | |
| } else if ( c.numSongs == 2 ) { | |
| c.song2 = ['<a class="songLink" data-song-index="1">', _.cleanText(b.data.songs[1].songName), "</a>"].join(""); | |
| b.dataKey = "FEED_FAVORITE_SONGS_TWO" | |
| } else b.dataKey = "FEED_FAVORITE_SONG"; | |
| return new GS.Models.DataString(a.localize.getString(b.dataKey), c) | |
| }, | |
| obsession: function( b ) { | |
| var c = {}; | |
| c.user = GS.Models.FeedEvent.getUserLink(b.user); | |
| c.song = ['<a class="songLink">', _.cleanText(b.data.songs[0].songName), "</a>"].join(""); | |
| c.artist = ['<a href="', _.cleanUrl(b.data.songs[0].artistName, b.data.songs[0].artistID, "artist"), '">', _.cleanText(b.data.songs[0].artistName), "</a>"].join(""); | |
| c.album = ['<a href="', _.cleanUrl(b.data.songs[0].albumName, b.data.songs[0].albumID, "album"), '">', _.cleanText(b.data.songs[0].albumName), "</a>"].join(""); | |
| c.numSongs = b.data.songs.length; | |
| if ( c.numSongs > 2 ) { | |
| b.dataKey = "FEED_SONG_OBSESSION_MANY"; | |
| c.numSongs-- | |
| } else if ( c.numSongs == 2 ) { | |
| c.song2 = ['<a class="songLink" data-song-index="1">', _.cleanText(b.data.songs[1].songName), "</a>"].join(""); | |
| b.dataKey = "FEED_SONG_OBSESSION_TWO" | |
| } else b.dataKey = b.data.songs[0].timestamp.length >= 11 ? "FEED_SONG_OBSESSION_COWBELL" : b.data.songs[0].timestamp.length >= 7 ? "FEED_SONG_OBSESSION_BLEEDING" : b.data.songs[0].timestamp.length >= 5 ? "FEED_SONG_OBSESSION_ADDICT" : "FEED_SONG_OBSESSION"; | |
| return new GS.Models.DataString(a.localize.getString(b.dataKey), c) | |
| }, | |
| addSongsToLibrary: function( b ) { | |
| var c = {}; | |
| c.user = GS.Models.FeedEvent.getUserLink(b.user); | |
| c.song = ['<a class="songLink">', _.cleanText(b.data.songs[0].songName), "</a>"].join(""); | |
| c.artist = ['<a href="', _.cleanUrl(b.data.songs[0].artistName, b.data.songs[0].artistID, "artist"), '">', _.cleanText(b.data.songs[0].artistName), "</a>"].join(""); | |
| c.album = ['<a href="', _.cleanUrl(b.data.songs[0].albumName, b.data.songs[0].albumID, "album"), '">', _.cleanText(b.data.songs[0].albumName), "</a>"].join(""); | |
| c.numSongs = b.data.songs.length; | |
| if ( c.numSongs > 2 ) { | |
| b.dataKey = "FEED_ADD_LIBRARY_SONGS_MANY"; | |
| c.numSongs-- | |
| } else if ( c.numSongs == 2 ) { | |
| c.song2 = ['<a class="songLink" data-song-index="1">', _.cleanText(b.data.songs[1].songName), "</a>"].join(""); | |
| b.dataKey = b.user.Sex == "M" ? "FEED_ADD_LIBRARY_SONGS_TWO_MALE" : b.user.Sex == "F" ? "FEED_ADD_LIBRARY_SONGS_TWO_FEMALE" : "FEED_ADD_LIBRARY_SONGS_TWO_ALIEN" | |
| } else b.dataKey = b.user.Sex == "M" ? "FEED_ADD_LIBRARY_SONG_MALE" : b.user.Sex == "F" ? "FEED_ADD_LIBRARY_SONG_FEMALE" : "FEED_ADD_LIBRARY_SONG_ALIEN"; | |
| return new GS.Models.DataString(a.localize.getString(b.dataKey), c) | |
| }, | |
| createPlaylist: function( b ) { | |
| var c = {}; | |
| b.data.playlists[0].owningName = | |
| b.user.Name; | |
| b.data.playlists[0].owningID = b.user.UserID; | |
| c.user = GS.Models.FeedEvent.getUserLink(b.user); | |
| c.playlist = ['<a href="', _.cleanUrl(b.data.playlists[0].playlistName, b.data.playlists[0].playlistID, "playlist"), '">', _.cleanText(b.data.playlists[0].playlistName), "</a>"].join(""); | |
| c.numSongs = _.isArray(b.data.songIDs) ? b.data.songIDs.length : 0; | |
| b.dataKey = c.numSongs && c.numSongs > 1 ? "FEED_PLAYLIST_CREATED" : "FEED_PLAYLIST_CREATED_NO_SONGS"; | |
| return new GS.Models.DataString(a.localize.getString(b.dataKey), c) | |
| }, | |
| overwritePlaylist: function( b ) { | |
| var c = {}; | |
| b.data.playlists[0].owningName = b.user.Name; | |
| b.data.playlists[0].owningID = b.user.UserID; | |
| c.user = GS.Models.FeedEvent.getUserLink(b.user); | |
| c.playlist = ['<a href="', _.cleanUrl(b.data.playlists[0].playlistName, b.data.playlists[0].playlistID, "playlist"), '">', _.cleanText(b.data.playlists[0].playlistName), "</a>"].join(""); | |
| c.numSongs = _.isArray(b.data.songIDs) ? b.data.songIDs.length : 0; | |
| b.dataKey = c.numSongs && c.numSongs > 1 ? "FEED_PLAYLIST_EDITED" : "FEED_PLAYLIST_EDITED_NO_SONGS"; | |
| return new GS.Models.DataString(a.localize.getString(b.dataKey), c) | |
| }, | |
| subscribePlaylist: function( b ) { | |
| var c = {}, | |
| g = b.data.playlists[0].owningName, | |
| h = b.data.playlists[0].subscribingName; | |
| c.user = GS.Models.FeedEvent.getUserLink(b.user); | |
| c.playlist = ['<a href="', _.cleanUrl(b.data.playlists[0].playlistName, b.data.playlists[0].playlistID, "playlist"), '">', _.cleanText(b.data.playlists[0].playlistName), "</a>"].join(""); | |
| c.author = ['<a href="', _.cleanUrl(g, b.data.playlists[0].owningUserID, "user"), '">', g, "</a>"].join(""); | |
| c.fan = ['<a href="', _.cleanUrl(h, b.userID, "user"), '">', h, "</a>"].join(""); | |
| b.dataKey = "FEED_PLAYLIST_FOLLOWED"; | |
| return new GS.Models.DataString(a.localize.getString(b.dataKey), c) | |
| }, | |
| playlistPlayed: function( b ) { | |
| var c = {}; | |
| c.user = GS.Models.FeedEvent.getUserLink(b.user); | |
| c.playlist = ['<a href="', _.cleanUrl(b.data.playlists[0].playlistName, b.data.playlists[0].playlistID, "playlist"), '">', _.cleanText(b.data.playlists[0].playlistName), "</a>"].join(""); | |
| b.dataKey = "FEED_LISTEN_PLAYLIST"; | |
| return new GS.Models.DataString(a.localize.getString(b.dataKey), c) | |
| }, | |
| favoriteArtist: function( b ) { | |
| var c = {}; | |
| c.user = GS.Models.FeedEvent.getUserLink(b.user); | |
| c.artist = ['<a href="', _.cleanUrl(b.data.artists[0].artistName, b.data.artists[0].artistID, "artist"), '">', _.cleanText(b.data.artists[0].artistName), "</a>"].join(""); | |
| c.numArtists = b.data.artists.length; | |
| if ( c.numArtists > 2 ) { | |
| b.dataKey = "FEED_FAVORITE_ARTIST_MANY"; | |
| c.artist2 = ['<a href="', _.cleanUrl(b.data.artists[1].artistName, b.data.artists[1].artistID, "artist"), '">', _.cleanText(b.data.artists[1].artistName), "</a>"].join(""); | |
| c.numArtists -= 2 | |
| } else if ( c.numArtists == 2 ) { | |
| b.dataKey = "FEED_FAVORITE_ARTIST_TWO"; | |
| c.artist2 = ['<a href="', _.cleanUrl(b.data.artists[1].artistName, b.data.artists[1].artistID, "artist"), '">', _.cleanText(b.data.artists[1].artistName), "</a>"].join("") | |
| } else b.dataKey = "FEED_FAVORITE_ARTIST_ONE"; | |
| return null | |
| }, | |
| addArtistToLibrary: function( b ) { | |
| var c = {}; | |
| c.user = GS.Models.FeedEvent.getUserLink(b.user); | |
| c.numSongs = b.data.songs.length - 1; | |
| c.song = ['<a class="songLink">', _.cleanText(b.data.songs[0].songName), "</a>"].join(""); | |
| c.artist = ['<a href="', _.cleanUrl(b.data.songs[0].artistName, b.data.songs[0].artistID, "artist"), '">', _.cleanText(b.data.songs[0].artistName), "</a>"].join(""); | |
| b.dataKey = "FEED_ADD_LIBRARY_ARTIST"; | |
| return new GS.Models.DataString(a.localize.getString(b.dataKey), c) | |
| }, | |
| artistPlayed: function( b ) { | |
| var c = {}; | |
| c.user = GS.Models.FeedEvent.getUserLink(b.user); | |
| c.numSongs = b.data.songs.length; | |
| c.song = ['<a class="songLink">', _.cleanText(b.data.songs[0].songName), "</a>"].join(""); | |
| c.artist = ['<a href="', _.cleanUrl(b.data.songs[0].artistName, b.data.songs[0].artistID, "artist"), '">', _.cleanText(b.data.songs[0].artistName), "</a>"].join(""); | |
| b.dataKey = "FEED_LISTEN_ARTIST"; | |
| return new GS.Models.DataString(a.localize.getString(b.dataKey), c) | |
| }, | |
| albumPlayed: function( b ) { | |
| var c = {}; | |
| c.user = GS.Models.FeedEvent.getUserLink(b.user); | |
| c.numSongs = b.data.songs.length; | |
| c.artist = ['<a href="', _.cleanUrl(b.data.songs[0].artistName, b.data.songs[0].artistID, "artist"), '">', _.cleanText(b.data.songs[0].artistName), "</a>"].join(""); | |
| c.album = ['<a href="', _.cleanUrl(b.data.songs[0].albumName, b.data.songs[0].albumID, "album"), '">', _.cleanText(b.data.songs[0].albumName), "</a>"].join(""); | |
| b.dataKey = "FEED_LISTEN_ALBUM"; | |
| return new GS.Models.DataString(a.localize.getString(b.dataKey), c) | |
| }, | |
| addAlbumToLibrary: function( b ) { | |
| var c = {}; | |
| c.user = GS.Models.FeedEvent.getUserLink(b.user); | |
| c.artist = ['<a href="', _.cleanUrl(b.data.songs[0].artistName, b.data.songs[0].artistID, "artist"), '">', _.cleanText(b.data.songs[0].artistName), "</a>"].join(""); | |
| c.album = ['<a href="', _.cleanUrl(b.data.songs[0].albumName, b.data.songs[0].albumID, "album"), '">', _.cleanText(b.data.songs[0].albumName), "</a>"].join(""); | |
| c.numSongs = b.data.songs.length; | |
| b.dataKey = "FEED_ADD_LIBRARY_ALBUM"; | |
| return new GS.Models.DataString(a.localize.getString(b.dataKey), c) | |
| }, | |
| favoriteUser: function( b ) { | |
| var c = {}; | |
| c.user = GS.Models.FeedEvent.getUserLink(b.user); | |
| c.followed = ['<a href="', b.getUrlByType("user", 0), '">', b.getMetaByType("user", 0), "</a>"].join(""); | |
| c.numUsers = b.data.users.length; | |
| if ( c.numUsers > 2 ) { | |
| b.dataKey = "FEED_FAVORITE_USER_MANY"; | |
| c.numUsers-- | |
| } else if ( c.numUsers == 2 ) { | |
| b.dataKey = "FEED_FAVORITE_USER_TWO"; | |
| c.followed2 = ['<a href="', b.getUrlByType("user", 1), '">', b.getMetaByType("user", 1), "</a>"].join("") | |
| } else b.dataKey = "FEED_FAVORITE_USER_ONE"; | |
| console.warn(b.dataKey, c); | |
| return new GS.Models.DataString(a.localize.getString(b.dataKey), c) | |
| }, | |
| share: function( b ) { | |
| var c = {}; | |
| if ( b.data.playlists ) { | |
| var g = b.data.playlists[0].owningName, | |
| h = b.data.playlists[0].subscribingName; | |
| c.user = GS.Models.FeedEvent.getUserLink(b.user); | |
| c.playlist = ['<a href="', _.cleanUrl(b.data.playlists[0].playlistName, b.data.playlists[0].playlistID, "playlist"), '">', _.cleanText(b.data.playlists[0].playlistName), "</a>"].join(""); | |
| c.author = ['<a href="', _.cleanUrl(g, b.data.playlists[0].userID, "user"), '">', g, "</a>"].join(""); | |
| c.fan = ['<a href="', _.cleanUrl(h, b.userID, "user"), '">', h, "</a>"].join(""); | |
| b.dataKey = "FEED_SHARE_PLAYLIST" | |
| } else { | |
| c.user = GS.Models.FeedEvent.getUserLink(b.user); | |
| c.song = ['<a class="songLink">', _.cleanText(b.data.songs[0].songName), "</a>"].join(""); | |
| c.artist = ['<a href="', _.cleanUrl(b.data.songs[0].artistName, b.data.songs[0].artistID, "artist"), '">', _.cleanText(b.data.songs[0].artistName), "</a>"].join(""); | |
| c.album = ['<a href="', _.cleanUrl(b.data.songs[0].albumName, b.data.songs[0].albumID, "album"), '">', _.cleanText(b.data.songs[0].albumName), "</a>"].join(""); | |
| c.numSongs = b.data.songs.length; | |
| if ( c.numSongs > 2 ) { | |
| b.dataKey = "FEED_SHARE_SONGS_MANY"; | |
| c.numSongs-- | |
| } else if ( c.numSongs == 2 ) { | |
| c.song2 = ['<a class="songLink" data-song-index="1">', _.cleanText(b.data.songs[1].songName), "</a>"].join(""); | |
| b.dataKey = "FEED_SHARE_SONGS_TWO" | |
| } else b.dataKey = "FEED_SHARE_SONG" | |
| } | |
| return new GS.Models.DataString(a.localize.getString(b.dataKey), c) | |
| }, | |
| broadcast: function( b ) { | |
| var c = {}, | |
| g, h = false, | |
| k = b.people ? b.people.length : 0; | |
| c.user = GS.Models.FeedEvent.getUserLink(b.user); | |
| for ( g = 0; g < k; g++ ) | |
| if ( b.people[g].userID == GS.user.UserID ) { | |
| h = true; | |
| break | |
| } | |
| if ( b.data.playlists ) { | |
| c.playlist = ['<a href="', _.cleanUrl(b.data.playlists[0].playlistName, b.data.playlists[0].playlistID, "playlist"), '">', _.cleanText(b.data.playlists[0].playlistName), "</a>"].join(""); | |
| if ( b.people && b.people.length ) if ( b.people.length > 2 ) { | |
| c.person = ['<a href="', b.getUrlByType("taggedUser", 0), '">', b.getMetaByType("taggedUser", 0), "</a>"].join(""); | |
| c.numUsers = b.people.length - 1; | |
| b.dataKey = h ? "FEED_BROADCAST_PLAYLIST_MANY_USERS_AND_YOU" : "FEED_BROADCAST_PLAYLIST_MANY_USERS" | |
| } else if ( b.people.length == 2 ) { | |
| c.person = ['<a href="', b.getUrlByType("taggedUser", 0), '">', b.getMetaByType("taggedUser", 0), "</a>"].join(""); | |
| c.person2 = ['<a href="', b.getUrlByType("taggedUser", 1), '">', b.getMetaByType("taggedUser", 1), "</a>"].join(""); | |
| b.dataKey = "FEED_BROADCAST_PLAYLIST_TWO_USERS" | |
| } else { | |
| c.person = ['<a href="', b.getUrlByType("taggedUser", 0), '">', b.getMetaByType("taggedUser", 0), "</a>"].join(""); | |
| b.dataKey = "FEED_BROADCAST_PLAYLIST_ONE_USER" | |
| } | |
| else b.dataKey = "FEED_BROADCAST_PLAYLIST_NO_USERS" | |
| } else if ( b.data.songs ) { | |
| c.song = ['<a class="songLink">', _.cleanText(b.data.songs[0].songName), "</a>"].join(""); | |
| c.artist = ['<a href="', _.cleanUrl(b.data.songs[0].artistName, b.data.songs[0].artistID, "artist"), '">', _.cleanText(b.data.songs[0].artistName), "</a>"].join(""); | |
| c.album = ['<a href="', _.cleanUrl(b.data.songs[0].albumName, b.data.songs[0].albumID, "album"), '">', _.cleanText(b.data.songs[0].albumName), "</a>"].join(""); | |
| if ( b.people && b.people.length ) if ( b.people.length > 2 ) { | |
| c.person = ['<a href="', b.getUrlByType("taggedUser", 0), '">', b.getMetaByType("taggedUser", 0), "</a>"].join(""); | |
| c.numUsers = b.people.length - 1; | |
| b.dataKey = h ? "FEED_BROADCAST_SONG_MANY_USERS_AND_YOU" : "FEED_BROADCAST_SONG_MANY_USERS" | |
| } else if ( b.people.length == 2 ) { | |
| c.person = ['<a href="', b.getUrlByType("taggedUser", 0), '">', b.getMetaByType("taggedUser", 0), "</a>"].join(""); | |
| c.person2 = ['<a href="', b.getUrlByType("taggedUser", 1), '">', b.getMetaByType("taggedUser", 1), "</a>"].join(""); | |
| b.dataKey = "FEED_BROADCAST_SONG_TWO_USERS" | |
| } else { | |
| c.person = ['<a href="', b.getUrlByType("taggedUser", 0), '">', b.getMetaByType("taggedUser", 0), "</a>"].join(""); | |
| b.dataKey = "FEED_BROADCAST_SONG_ONE_USER" | |
| } | |
| else b.dataKey = "FEED_BROADCAST_SONG_NO_USERS" | |
| } else if ( b.data.artists ) { | |
| c.artist = ['<a href="', _.cleanUrl(b.data.artists[0].artistName, b.data.artists[0].artistID, "artist"), '">', _.cleanText(b.data.artists[0].artistName), "</a>"].join(""); | |
| if ( b.people && b.people.length ) if ( b.people.length > 2 ) { | |
| c.person = ['<a href="', b.getUrlByType("taggedUser", 0), '">', b.getMetaByType("taggedUser", 0), "</a>"].join(""); | |
| c.numUsers = b.people.length - 1; | |
| b.dataKey = h ? "FEED_BROADCAST_ARTIST_MANY_USERS_AND_YOU" : "FEED_BROADCAST_ARTIST_MANY_USERS" | |
| } else if ( b.people.length == 2 ) { | |
| c.person = ['<a href="', b.getUrlByType("taggedUser", 0), '">', b.getMetaByType("taggedUser", 0), "</a>"].join(""); | |
| c.person2 = ['<a href="', b.getUrlByType("taggedUser", 1), '">', b.getMetaByType("taggedUser", 1), "</a>"].join(""); | |
| b.dataKey = "FEED_BROADCAST_ARTIST_TWO_USERS" | |
| } else { | |
| c.person = ['<a href="', b.getUrlByType("taggedUser", 0), '">', b.getMetaByType("taggedUser", 0), "</a>"].join(""); | |
| b.dataKey = "FEED_BROADCAST_ARTIST_ONE_USER" | |
| } | |
| else b.dataKey = "FEED_BROADCAST_ARTIST_NO_USERS" | |
| } else if ( b.data.albums ) { | |
| c.artist = ['<a href="', _.cleanUrl(b.data.albums[0].artistName, b.data.albums[0].artistID, "artist"), '">', _.cleanText(b.data.albums[0].artistName), "</a>"].join(""); | |
| c.album = ['<a href="', _.cleanUrl(b.data.albums[0].albumName, b.data.albums[0].albumID, "album"), '">', _.cleanText(b.data.albums[0].albumName), "</a>"].join(""); | |
| if ( b.people && b.people.length ) if ( b.people.length > 2 ) { | |
| c.person = ['<a href="', b.getUrlByType("taggedUser", 0), '">', b.getMetaByType("taggedUser", 0), "</a>"].join(""); | |
| c.numUsers = b.people.length - 1; | |
| b.dataKey = h ? "FEED_BROADCAST_ALBUM_MANY_USERS_AND_YOU" : "FEED_BROADCAST_ALBUM_MANY_USERS" | |
| } else if ( b.people.length == 2 ) { | |
| c.person = ['<a href="', b.getUrlByType("taggedUser", 0), '">', b.getMetaByType("taggedUser", 0), "</a>"].join(""); | |
| c.person2 = ['<a href="', b.getUrlByType("taggedUser", 1), '">', b.getMetaByType("taggedUser", 1), "</a>"].join(""); | |
| b.dataKey = "FEED_BROADCAST_ALBUM_TWO_USERS" | |
| } else { | |
| c.person = ['<a href="', b.getUrlByType("taggedUser", 0), '">', b.getMetaByType("taggedUser", 0), "</a>"].join(""); | |
| b.dataKey = "FEED_BROADCAST_ALBUM_ONE_USER" | |
| } | |
| else b.dataKey = "FEED_BROADCAST_ALBUM_NO_USERS" | |
| } | |
| return new GS.Models.DataString(a.localize.getString(b.dataKey), c) | |
| }, | |
| usersAddArtistToLibrary: function( b ) { | |
| var c = {}; | |
| c.user = GS.Models.FeedEvent.getUserLink(b.user); | |
| c.artist = ['<a href="', _.cleanUrl(b.data.songs[0].artistName, b.data.songs[0].artistID, "artist"), '">', _.cleanText(b.data.songs[0].artistName), "</a>"].join(""); | |
| b.dataKey = b.user.Sex == "M" ? "FEED_USERS_ADD_LIBRARY_ARTIST_MALE" : b.user.Sex == "F" ? "FEED_USERS_ADD_LIBRARY_ARTIST_FEMALE" : "FEED_USERS_ADD_LIBRARY_ARTIST_ALIEN"; | |
| return new GS.Models.DataString(a.localize.getString(b.dataKey), c) | |
| }, | |
| usersAddAlbumToLibrary: function( b ) { | |
| var c = {}; | |
| c.user = GS.Models.FeedEvent.getUserLink(b.user); | |
| c.artist = ['<a href="', _.cleanUrl(b.data.albums[0].artistName, b.data.albums[0].artistID, "artist"), '">', _.cleanText(b.data.albums[0].artistName), "</a>"].join(""); | |
| c.album = ['<a href="', _.cleanUrl(b.data.albums[0].albumName, b.data.albums[0].albumID, "album"), '">', _.cleanText(b.data.albums[0].albumName), "</a>"].join(""); | |
| c.numAlbums = b.data.albums.length; | |
| b.dataKey = b.user.Sex == "M" ? "FEED_USERS_ADD_LIBRARY_ALBUM_MALE" : b.user.Sex == "F" ? "FEED_USERS_ADD_LIBRARY_ALBUM_FEMALE" : "FEED_USERS_ADD_LIBRARY_ALBUM_ALIEN"; | |
| return new GS.Models.DataString(a.localize.getString(b.dataKey), c) | |
| }, | |
| getUserLink: function( b ) { | |
| return ['<a href="', b.toUrl(), '">', b.Name.length ? b.Name : b.FName, "</a>"].join("") | |
| }, | |
| wrapUsers: function( b ) { | |
| for ( var c = [], g, h = 0; h < b.length; h++ ) { | |
| g = b[h]; | |
| c.push(GS.Models.User.wrap({ | |
| UserID: g.userID, | |
| displayName: g.displayName, | |
| Picture: g.userPicture | |
| })) | |
| } | |
| return c | |
| }, | |
| updateDaysOfWeek: function() { | |
| var b = a.localize.getString("WEEK_DAYS"); | |
| if ( b && b.length ) this.daysOfWeek = b.split(",") | |
| }, | |
| daysOfWeek: [], | |
| dateText: function( b ) { | |
| var c, g = {}; | |
| c = new Date; | |
| var h = c.getTime() - b.getTime(); | |
| if ( h < 6E4 ) c = a.localize.getString("SECONDS_AGO"); | |
| else if ( h < 36E5 ) { | |
| c = a.localize.getString("MINUTES_AGO"); | |
| g = { | |
| minutes: Math.ceil(h / 6E4) | |
| } | |
| } else if ( h < 432E5 || c.getDate() == b.getDate() && h < 6048E5 ) { | |
| c = a.localize.getString("HOURS_AGO"); | |
| g = { | |
| hours: Math.ceil(h / 36E5) | |
| } | |
| } else if ( c.getDate() - 1 == b.getDate() && h < 6048E5 ) { | |
| c = a.localize.getString("YESTERDAY_AGO"); | |
| g = { | |
| time: b.format("g:i a") | |
| } | |
| } else if ( h < 6048E5 ) { | |
| c = a.localize.getString("DAY_AGO"); | |
| g = { | |
| day: this.daysOfWeek[b.getDay()], | |
| time: b.format("g:i a") | |
| } | |
| } else { | |
| c = a.localize.getString("OVER_A_WEEK_AGO"); | |
| g = { | |
| day: this.daysOfWeek[b.getDay()], | |
| date: b.format("F jS") | |
| } | |
| } | |
| return new GS.Models.DataString(c, g) | |
| } | |
| }, { | |
| eventID: null, | |
| activityName: null, | |
| activity: 0, | |
| data: null, | |
| timestamp: null, | |
| userID: 0, | |
| user: null, | |
| time: null, | |
| date: null, | |
| data: null, | |
| dataString: null, | |
| dataKey: null, | |
| users: null, | |
| validate: function() { | |
| return event.userID && event.data | |
| }, | |
| init: function( b ) { | |
| this._super(b); | |
| this.user = b.userIDFrom ? GS.Models.User.getOneFromCache(b.userIDFrom) : GS.Models.User.getOneFromCache(b.userID); | |
| if (!this.user && b.userID && b.userID == GS.user.UserID ) this.user = GS.user; | |
| else if (!this.user && b.data.users && b.data.users.length ) { | |
| this.users = GS.Models.FeedEvent.wrapUsers(b.data.users); | |
| this.user = this.users[0] | |
| } else if (!this.user && b.displayName ) this.user = GS.Models.User.wrap({ | |
| UserID: b.userID, | |
| displayName: b.displayName, | |
| Picture: b.userPicture | |
| }, false); | |
| this.date = new Date(b.timestamp * 1E3); | |
| this.dataString = GS.Models.FeedEvent[b.activityName] ? GS.Models.FeedEvent[b.activityName](this) : null; | |
| if (!this.dataString || !this.user ) throw "no_dataString"; | |
| }, | |
| toHTML: function() { | |
| return this.dataString ? this.dataString.render() : "" | |
| }, | |
| playSongs: function( b, c ) { | |
| c = _.orEqual(c, false); | |
| if ( this.data.songs && this.data.songs.length ) { | |
| var g = [], | |
| h = new GS.Models.PlayContext(GS.player.PLAY_CONTEXT_FEED, this); | |
| GS.Models.Song.wrapCollection(this.data.songs); | |
| for ( var k in this.data.songs ) | |
| this.data.songs.hasOwnProperty(k) && g.push(this.data.songs[k].songID); | |
| GS.player.addSongsToQueueAt(g, b, c, h) | |
| } else this.data.playlists && this.data.playlists.playlistID && GS.Models.Playlist.getPlaylist(this.data.playlists.playlistID, this.callback("playPlaylist", { | |
| index: b, | |
| playOnAdd: c | |
| }), null, false) | |
| }, | |
| getSongs: function( b ) { | |
| var c = this.data.songs && this.data.songs.length ? GS.Models.Song.wrapCollection(this.data.songs) : []; | |
| return b ? c.reverse() : c | |
| }, | |
| getSongsWithArt: function( b ) { | |
| b = _.orEqual(b, 7); | |
| var c = [], | |
| g = {}; | |
| if ( this.data.songs && this.data.songs.length ) for ( var h = 0; h < this.data.songs.length; h++ ) { | |
| if ( this.data.songs[h].artFilename && !g[this.data.songs[h].artFilename] ) { | |
| c.push(h); | |
| g[this.data.songs[h].artFilename] = true | |
| } | |
| if ( c.length == b ) break | |
| } | |
| return c | |
| }, | |
| getUrlByType: function( b, c ) { | |
| c = _.orEqual(c, 0); | |
| try { | |
| switch ( b ) { | |
| case "album": | |
| if ( this.data && this.data.songs ) return _.cleanUrl(this.data.songs[c].albumName, this.data.songs[c].albumID, "album"); | |
| else if ( this.data && this.data.albums ) return _.cleanUrl(this.data.albums[c].albumName, this.data.albums[c].albumID, "album"); | |
| break; | |
| case "artist": | |
| if ( this.data && this.data.songs ) return _.cleanUrl(this.data.songs[c].artistName, this.data.songs[c].artistID, "artist"); | |
| else if ( this.data && this.data.artists ) return _.cleanUrl(this.data.artists[c].artistName, this.data.artists[c].artistID, "artist"); | |
| else if ( this.data && this.data.albums ) return _.cleanUrl(this.data.albums[c].artistName, this.data.albums[c].artistID, "artist"); | |
| break; | |
| case "playlist": | |
| if ( this.data && this.data.playlists ) return _.cleanUrl(this.data.playlists[c].playlistName, this.data.playlists[c].playlistID, "playlist"); | |
| break; | |
| case "playlistAuthor": | |
| if ( this.data && this.data.playlists ) return _.cleanUrl(this.data.playlists[c].owningName, this.data.playlists[c].owningUserID, "user"); | |
| break; | |
| case "user": | |
| if ( this.data && this.data.users ) if ( this.data.users[c].userName ) return _.cleanUrl(this.data.users[c].userName, this.data.users[c].userID, "user"); | |
| else if ( this.data.users[c].displayName ) return _.cleanUrl(this.data.users[c].displayName, this.data.users[c].userID, "user"); | |
| break; | |
| case "taggedUser": | |
| if ( this.data && this.people ) return _.cleanUrl(this.people[c].userName, this.people[c].userID, "user"); | |
| break; | |
| default: | |
| return null | |
| } | |
| } catch (g) { | |
| return null | |
| } | |
| }, | |
| getMetaByType: function( b, c ) { | |
| c = _.orEqual(c, 0); | |
| try { | |
| switch ( b ) { | |
| case "song": | |
| return _.cleanText(this.data.songs[c].songName); | |
| case "album": | |
| if ( this.data.songs && this.data.songs[c] ) return _.cleanText(this.data.songs[c].albumName); | |
| else if ( this.data.albums && this.data.albums[c] ) return _.cleanText(this.data.albums[c].albumName); | |
| break; | |
| case "artist": | |
| if ( this.data.songs ) return _.cleanText(this.data.songs[c].artistName); | |
| else if ( this.data.artists ) return _.cleanText(this.data.artists[c].artistName); | |
| else if ( this.data.albums ) return _.cleanText(this.data.albums[c].artistName); | |
| break; | |
| case "playlist": | |
| return _.cleanText(this.data.playlists[c].playlistName); | |
| case "playlistAuthor": | |
| return _.cleanText(this.data.playlists[c].owningName); | |
| case "user": | |
| if ( this.data.users[c].userName ) return _.cleanText(this.data.users[c].userName); | |
| else if ( this.data.users[c].displayName ) return _.cleanText(this.data.users[c].displayName); | |
| break; | |
| case "taggedUser": | |
| return _.cleanText(this.people[c].userName) | |
| } | |
| } catch (g) { | |
| return null | |
| } | |
| return null | |
| }, | |
| getImageURL: function( b, c, g ) { | |
| var h = "", | |
| k = ""; | |
| c = _.orEqual(c, 0); | |
| g = _.orEqual(g, 70); | |
| switch ( b ) { | |
| case "song": | |
| case "album": | |
| k = this.data.songs && this.data.songs[c] && this.data.songs[c].artFilename ? _.cleanText(this.data.songs[c].artFilename) : this.data.albums && this.data.albums[c] && this.data.albums[c].artFilename ? _.cleanText(this.data.albums[c].artFilename) : "album.png"; | |
| h = GS.Models.Album.artPath + g + "_" + k; | |
| break; | |
| case "artist": | |
| k = | |
| this.data.songs && this.data.songs[c] && this.data.songs[c].artFilename ? _.cleanText(this.data.songs[c].artFilename) : this.data.artists && this.data.artists[c] && this.data.artists[c].artFilename ? _.cleanText(this.data.artists[c].artFilename) : "artist.png"; | |
| h = GS.Models.Artist.artPath + g + "_" + k; | |
| break; | |
| case "playlist": | |
| if ( this.data.playlists && this.data.playlists[c] && this.data.playlists[c].artFilename ) { | |
| k = _.cleanText(this.data.playlists[c].artFilename); | |
| h = GS.Models.Playlist.artPath + g + "_" + k | |
| } else { | |
| k = "album.png"; | |
| h = GS.Models.Album.artPath + g + "_" + k | |
| } | |
| break; | |
| case "user": | |
| k = this.data.users && this.data.users[c] && this.data.users[c].picture ? _.cleanText(this.data.users[c].picture) : "user.png"; | |
| h = GS.Models.User.artPath + g + "_" + k; | |
| break; | |
| case "taggedUser": | |
| k = this.people && this.people[c] && this.people[c].picture ? _.cleanText(this.people[c].picture) : "user.png"; | |
| h = GS.Models.User.artPath + g + "_" + k; | |
| break | |
| } | |
| return h | |
| }, | |
| playPlaylist: function( b, c ) { | |
| c && c.PlaylistID && GS.player.playPlaylist(b, c) | |
| }, | |
| remove: function( b, c ) { | |
| this.user.UserID == GS.user.UserID && GS.service.hideUserEvent(this.eventID, b, c) | |
| }, | |
| getDetailsForFeeds: function() { | |
| return { | |
| user: this.user.getDetailsForFeeds(), | |
| eventID: this.eventID, | |
| activityName: this.activityName | |
| } | |
| }, | |
| canComment: function() { | |
| if (!GS.user.fanbase ) GS.user.fanbase = GS.Models.Fanbase.wrap({ | |
| objectID: GS.user.UserID, | |
| objectType: "user" | |
| }); | |
| if ( GS.user.UserID > 0 && (GS.user.UserID == this.user.UserID || GS.user.fanbase.userIDs.indexOf(this.user.UserID) != -1) ) return true; | |
| return false | |
| }, | |
| addComment: function( b, c, g ) { | |
| GS.service.addEventComment(this.eventID, b, this.callback([this.addCommentSuccess, c]), g) | |
| }, | |
| addCommentSuccess: function( b ) { | |
| if (!b || !b._id ) return false; | |
| this.hasComments = true; | |
| if (!this.comments ) this.comments = []; | |
| this.comments.push(b); | |
| return b | |
| }, | |
| removeComment: function( b ) { | |
| for ( var c = 0; c < this.comments.length; c++ ) { | |
| var g = this.comments[c]; | |
| if ( b == g._id && (GS.user.UserID == g.userID || GS.user.UserID == this.user.UserID) ) { | |
| GS.service.hideEventComment(b, this.eventID); | |
| this.comments.splice(c, 1); | |
| return | |
| } | |
| } | |
| }, | |
| toString: function() { | |
| return ["Feed. type:", this.activityName, ", usname: ", this.user.UserName].join("") | |
| } | |
| }) | |
| })(jQuery); | |
| (function() { | |
| GS.Models.Feed.extend("GS.Models.ProfileFeed", {}, { | |
| type: "profile", | |
| fetch: function( a ) { | |
| this.user.UserID > 0 && GS.user.UserID == this.user.UserID ? GS.service.getProfileFeed(this.lastDocumentID, this.lastEventID, this.callback("parseFeed", { | |
| lastDocumentID: this.lastDocumentID, | |
| lastEventID: this.lastEventID, | |
| currentPage: this.currentPage, | |
| callback: a.callback, | |
| errback: a.errback | |
| }), this.callback("onError", a)) : GS.service.getUserProfileFeed(this.user.UserID, this.lastDocumentID, this.lastEventID, this.callback("parseFeed", { | |
| lastDocumentID: this.lastDocumentID, | |
| lastEventID: this.lastEventID, | |
| currentPage: this.currentPage, | |
| callback: a.callback, | |
| errback: a.errback | |
| }), this.callback("onError", a)) | |
| }, | |
| parseFeed: function( a, b ) { | |
| var c, g = []; | |
| if ( _.isEmpty(b) || !b.events ) return this.onError(a); | |
| if (!this.pages[a.currentPage] ) { | |
| for ( var h = 0; h < b.events.length; h++ ) | |
| if ( b.events[h] ) if ( c = this.parseEvent(b.events[h]) ) { | |
| g.push(c); | |
| this.cache[c.eventID] = c | |
| } | |
| this.events = this.events.concat(g); | |
| this.pages.push(g); | |
| this.currentPage++; | |
| this.lastDocumentID = b.lastDocumentID; | |
| this.lastEventID = b.lastEventID; | |
| this.isComplete = this.isLoaded = true; | |
| this.hasMore = b.count && this.currentPage < 10 | |
| } | |
| a.callback && a.callback(this.pages[a.currentPage]); | |
| this.isComplete || this.fetch(a) | |
| } | |
| }) | |
| })(jQuery); | |
| (function() { | |
| GS.Models.Feed.extend("GS.Models.CommunityFeed", {}, { | |
| type: "community", | |
| userIDs: [], | |
| fetch: function( a ) { | |
| GS.user.UserID > 0 && GS.user.UserID == this.user.UserID ? GS.service.getCombinedFeed(this.userIDs, this.lastEventID, this.callback("parseFeed", { | |
| currentPage: this.currentPage, | |
| lastEventID: this.lastEventID, | |
| callback: a.callback, | |
| errback: a.errback | |
| }), this.callback("onError", a)) : GS.service.getUserCombinedFeed(this.user.UserID, this.userIDs, this.lastEventID, this.callback("parseFeed", { | |
| currentPage: this.currentPage, | |
| lastEventID: this.lastEventID, | |
| callback: a.callback, | |
| errback: a.errback | |
| }), this.callback("onError", a)) | |
| }, | |
| parseFeed: function( a, b ) { | |
| var c, g = []; | |
| a = _.orEqual(a, {}); | |
| if ( _.isEmpty(b) || !b.events ) return this.onError(a); | |
| if (!this.pages[a.currentPage] ) { | |
| for ( var h = 0; h < b.events.length; h++ ) | |
| if ( b.events[h] ) if ( c = this.parseEvent(b.events[h]) ) { | |
| g.push(c); | |
| this.cache[c.eventID] = c | |
| } | |
| this.events = this.events.concat(g); | |
| this.pages.push(g); | |
| this.currentPage++; | |
| this.lastEventID = b.lastEventID; | |
| this.isLoaded = Boolean(this.events.length); | |
| this.isComplete = | |
| true; | |
| if ( this.events.length < 75 && b.count >= 25 && this.pages.length < GS.Models.Feed.PAGE_LIMIT ) this.isComplete = false; | |
| this.hasMore = b.count && this.currentPage < 10 | |
| } | |
| a.callback && a.callback(this.pages[a.currentPage]); | |
| this.isComplete || this.fetch(a) | |
| } | |
| }) | |
| })(jQuery); | |
| (function() { | |
| GS.Models.Feed.extend("GS.Models.MentionsFeed", {}, { | |
| type: "mentions", | |
| fetch: function( a ) { | |
| GS.user.UserID > 0 && GS.user.UserID == this.user.UserID && GS.service.getUserNotifications(this.callback("parseFeed", { | |
| currentPage: this.currentPage, | |
| callback: a.callback, | |
| errback: a.errback | |
| }), a.errback) | |
| }, | |
| parseFeed: function( a, b ) { | |
| var c, g = []; | |
| a = _.orEqual(a, {}); | |
| if (!this.pages[a.currentPage] ) { | |
| for ( var h = 0; h < b.length; h++ ) | |
| if ( b[h] ) if ( c = this.parseEvent(b[h]) ) { | |
| g.push(c); | |
| this.cache[c.eventID] = c | |
| } | |
| this.events = this.events.concat(g); | |
| this.pages.push(g); | |
| this.currentPage++; | |
| this.lastEventID = b.lastEventID; | |
| this.hasMore = Boolean(b.hasMore); | |
| this.isLoaded = !Boolean(b.hasMore) || this.events.length; | |
| this.isComplete = true | |
| } | |
| a.callback && a.callback(this.pages[a.currentPage]); | |
| this.isComplete || this.fetch(a) | |
| } | |
| }) | |
| })(jQuery); | |
| (function() { | |
| GS.Models.Feed.extend("GS.Models.ArtistFeed", {}, { | |
| type: "artist", | |
| artist: null, | |
| fetch: function( a ) { | |
| GS.service.getArtistProfileFeed(this.artist.ArtistID, this.lastDocumentID, this.lastEventID, this.callback("parseFeed", { | |
| artistID: this.artist.ArtistID, | |
| lastDocumentID: this.lastDocumentID, | |
| lastEventID: this.lastEventID, | |
| currentPage: this.currentPage, | |
| callback: a.callback, | |
| errback: a.errback | |
| }), a.errback) | |
| }, | |
| parseFeed: function( a, b ) { | |
| var c, g = []; | |
| a = _.orEqual(a, {}); | |
| if (!this.pages[a.currentPage] ) { | |
| for ( var h = 0; h < b.events.length; h++ ) | |
| if ( b.events[h] ) if ( c = | |
| this.parseEvent(b.events[h]) ) { | |
| g.push(c); | |
| this.cache[c.eventID] = c | |
| } | |
| this.events = this.events.concat(g); | |
| this.pages.push(g); | |
| this.currentPage++; | |
| this.lastDocumentID = b.lastDocumentID; | |
| this.lastEventID = b.lastEventID; | |
| this.hasMore = Boolean(b.hasMore); | |
| this.isLoaded = !Boolean(b.hasMore) || this.events.length; | |
| this.isComplete = true; | |
| this.events.length < 25 && b.count >= 25 && ++this.pages.length | |
| } | |
| a.callback && a.callback(this.pages[a.currentPage]); | |
| this.isComplete || this.fetch(a) | |
| } | |
| }) | |
| })(jQuery); | |
| (function() { | |
| GS.Models.Feed.extend("GS.Models.RecentFeed", { | |
| interestingFeed: null, | |
| init: function() { | |
| this.interestingFeed = new GS.Models.RecentFeed({}) | |
| } | |
| }, { | |
| type: "recent", | |
| fetch: function( a ) { | |
| a = _.orEqual(a, {}); | |
| a.limit = _.orEqual(a.limit, 50); | |
| GS.service.getInterestingEvents(a.limit, this.callback("parseFeed", { | |
| limit: a.limit, | |
| callback: a.callback, | |
| errback: a.errback, | |
| currentPage: this.currentPage | |
| }), a.errback) | |
| }, | |
| parseFeed: function( a, b ) { | |
| var c = [], | |
| g; | |
| if (!this.pages[a.currentPage] ) { | |
| for ( var h = 0; h < b.length; h++ ) | |
| if ( g = this.parseEvent(b[h]) ) { | |
| c.push(g); | |
| this.cache[g.eventID] = g | |
| } | |
| this.events = this.events.concat(c); | |
| this.pages.push(c); | |
| this.currentPage++; | |
| this.isComplete = this.isLoaded = true | |
| } | |
| a.callback && a.callback(this.pages[a.currentPage]); | |
| this.isComplete || this.fetch(a) | |
| } | |
| }) | |
| })(jQuery); | |
| (function( a ) { | |
| var b; | |
| GS.Models.Base.extend("GS.Models.Theme", {}, { | |
| themeID: null, | |
| version: "1.0", | |
| title: "Unknown", | |
| author: "Grooveshark", | |
| location: "default", | |
| premium: false, | |
| sponsored: false, | |
| sections: null, | |
| assetLocation: "", | |
| clickIDs: null, | |
| tracking: null, | |
| pageTracking: null, | |
| expandableTracking: null, | |
| artistNotifTracking: null, | |
| videoLBTracking: null, | |
| adSync: false, | |
| misc: null, | |
| videos: null, | |
| artistIDs: null, | |
| isFirstLoad: true, | |
| isFirstLoadPageheader: true, | |
| screensaver: false, | |
| ready: null, | |
| removeReady: null, | |
| onAuthChange: null, | |
| CSS: "css", | |
| TOP: "top", | |
| BOTTOM: "bottom", | |
| CENTER: "center", | |
| LEFT: "left", | |
| RIGHT: "right", | |
| AUTO: "auto", | |
| SCALEX: "scalex", | |
| SCALEY: "scaley", | |
| init: function( c ) { | |
| b = this; | |
| c && this._super(c); | |
| this.assetLocation = "/themes/" + c.location + "/assets/" | |
| }, | |
| bindAssets: function( c ) { | |
| var g, h, k, m, p, n, o = 0, | |
| t; | |
| c = a(c); | |
| var w = c.attr("id"); | |
| c.children().each(function() { | |
| var x = a(this); | |
| x.hasClass("flash") || x.click(b.callback(b.handleClick)); | |
| if ( x.hasClass("flash") ) { | |
| g = _.orEqual(x.attr("data-flash-wmode"), "opaque"); | |
| h = _.orEqual(x.attr("data-flash-width"), "100%"); | |
| k = _.orEqual(x.attr("data-flash-height"), "100%"); | |
| m = _.orEqual(x.attr("data-flash-src"), null); | |
| flashParams = _.orEqual(x.attr("data-flash-params"), ""); | |
| flashVisualizer = _.orEqual(x.attr("data-flash-visualizer"), null); | |
| if ( m && x.attr("id") ) { | |
| t = flashVisualizer ? "visualizerTheme" : w + "-flash-" + o++; | |
| x.append('<div id="' + t + '"></div>'); | |
| swfobject.embedSWF(b.assetLocation + m + "?ver=" + b.version + "&themeID=" + b.themeID + "¤tTarget=#" + x.attr("id") + flashParams, t, h, k, "9.0.0", null, null, { | |
| wmode: g | |
| }) | |
| } | |
| } else if ( x.hasClass("img") ) if ( n = _.orEqual(x.attr("data-img-src"), null) ) { | |
| p = | |
| a(new Image); | |
| p.css({ | |
| visibility: "hidden" | |
| }).bind("load", { | |
| section: c | |
| }, b.onImageLoad).attr("src", gsConfig.assetHost + b.assetLocation + n + "?ver=" + b.version).appendTo(x) | |
| } | |
| }) | |
| }, | |
| onImageLoad: function( c ) { | |
| var g = a(this); | |
| c = c.data.section; | |
| var h = g.is("[display=none]") || c.is("[display=none]"); | |
| g.parent().andSelf().show(); | |
| var k = !c.is(":visible"); | |
| c.show(); | |
| var m = g[0].width, | |
| p = g[0].height; | |
| h && g.parent().andSelf().hide(); | |
| g.css({ | |
| visibility: "visible" | |
| }).attr({ | |
| "data-img-width": m, | |
| "data-img-height": p | |
| }); | |
| k && c.hide(); | |
| b.position(c) | |
| }, | |
| position: function( c ) { | |
| if ( GS.page.activePage instanceof | |
| GS.Controllers.Page.HomeController ) { | |
| c = a(c); | |
| var g, h, k, m, p, n, o, t, w, x, v, B, E, H, G, D, y, A, I = a(c).height(), | |
| q = a(c).width(); | |
| c.children(".img").each(function() { | |
| g = a(this); | |
| h = g.find("img"); | |
| k = _.orEqual(parseInt(h.attr("data-img-width")), 0); | |
| m = _.orEqual(parseInt(h.attr("data-img-height")), 0); | |
| if ( k && m ) { | |
| y = _.orEqual(g.attr("data-img-top"), 0); | |
| A = _.orEqual(g.attr("data-img-bottom"), 0); | |
| G = _.orEqual(g.attr("data-img-left"), 0); | |
| D = _.orEqual(g.attr("data-img-right"), 0); | |
| n = q - G - D; | |
| p = I - y - A; | |
| w = parseInt(_.orEqual(g.attr("data-img-min-width"), 0)); | |
| o = parseInt(_.orEqual(g.attr("data-img-min-height"), 0)); | |
| t = parseInt(_.orEqual(g.attr("data-img-max-height"), p)); | |
| maxWidth = parseInt(_.orEqual(g.attr("data-img-max-width"), n)); | |
| x = g.attr("data-img-proportional") === "false" ? false : true; | |
| switch ( g.attr("data-img-scale") ) { | |
| case "scalex": | |
| h.width(Math.min(Math.max(w, n), maxWidth)); | |
| x ? h.height(Math.round(h.width() / k * m)) : h.height(Math.min(Math.max(o, Math.round(p), t))); | |
| break; | |
| case "scaley": | |
| h.height(Math.min(Math.max(o, p), t)); | |
| x ? h.width(Math.round(h.height() / m * k)) : h.width(Math.min(Math.max(w, Math.round(n), maxWidth))); | |
| break; | |
| case "fit": | |
| v = Math.min(n / k, p / m); | |
| h.width(Math.round(v * k)); | |
| h.height(Math.round(v * m)); | |
| break; | |
| case "auto": | |
| default: | |
| if ( x ) { | |
| v = Math.max(n / k, p / m); | |
| h.width(Math.round(v * k)); | |
| h.height(Math.round(v * m)) | |
| } else { | |
| h.width(Math.round(n / k * k)); | |
| h.height(Math.round(p / m * m)) | |
| } | |
| break | |
| } | |
| B = _.orEqual(g.attr("data-pos-x"), b.CENTER); | |
| E = _.orEqual(g.attr("data-pos-y"), b.CENTER); | |
| switch ( B ) { | |
| case b.LEFT: | |
| H = isNaN(G) ? G : G + "px"; | |
| h.css(b.LEFT, H); | |
| break; | |
| case b.RIGHT: | |
| H = isNaN(D) ? D : D + "px"; | |
| h.css(b.RIGHT, H); | |
| break; | |
| case b.CENTER: | |
| h.css(b.LEFT, Math.round((n - h.width()) / 2) + "px"); | |
| break | |
| } | |
| switch ( E ) { | |
| case b.TOP: | |
| H = isNaN(y) ? y : y + "px"; | |
| h.css(b.TOP, H); | |
| break; | |
| case b.BOTTOM: | |
| H = isNaN(A) ? A : A + "px"; | |
| h.css(b.BOTTOM, H); | |
| break; | |
| case b.CENTER: | |
| h.css(b.TOP, Math.round((p - h.height()) / 2) + "px"); | |
| break | |
| } | |
| } | |
| }) | |
| } | |
| }, | |
| handleClick: function( c ) { | |
| var g = a(c.currentTarget), | |
| h; | |
| GS.theme.setLastDFPAction(); | |
| switch ( g.attr("data-click-action") ) { | |
| case "playSong": | |
| (c = g.attr("data-song-id")) && a.publish("gs.song.play", { | |
| songID: c, | |
| playOnAdd: true, | |
| getFeedback: true | |
| }); | |
| break; | |
| case "playAlbum": | |
| c = g.attr("data-album-id"); | |
| h = g.attr("data-album-shuffle") == "true"; | |
| c && a.publish("gs.album.play", { | |
| albumID: c, | |
| playOnAdd: true, | |
| getFeedback: true, | |
| shuffle: h | |
| }); | |
| break; | |
| case "playPlaylist": | |
| c = g.attr("data-playlist-id"); | |
| h = g.attr("data-playlist-shuffle") == "true"; | |
| var k = g.attr("data-radio-enabled") == "true"; | |
| c && a.publish("gs.playlist.play", { | |
| playlistID: c, | |
| playOnAdd: true, | |
| getFeedback: true, | |
| shuffle: h | |
| }); | |
| k && setTimeout(function() { | |
| GS.player.setAutoplay(true) | |
| }, 5E3); | |
| break; | |
| case "playStation": | |
| c = g.attr("data-station-id"); | |
| h = g.attr("data-station-name"); | |
| if ( c && h ) { | |
| GS.Models.Station.extraStations[c] = h; | |
| a.publish("gs.station.play", { | |
| tagID: c, | |
| stationName: h | |
| }) | |
| } | |
| break; | |
| case "playVideo": | |
| c = new GS.Models.Video({ | |
| src: g.attr("data-video-src"), | |
| swf: g.attr("data-video-swf"), | |
| title: _.orEqual(g.attr("data-video-title"), null), | |
| author: _.orEqual(g.attr("data-video-author"), null), | |
| tracking: _.orEqual(g.attr("data-video-tracking"), null), | |
| originalWidth: _.orEqual(g.attr("data-video-originalWidth"), null), | |
| originalHeight: _.orEqual(g.attr("data-video-originalHeight"), null) | |
| }); | |
| c.swf.length && GS.getLightbox().open("video", { | |
| video: c | |
| }); | |
| break; | |
| case "playVideos": | |
| if ( b.videos && b.videos.length ) { | |
| c = _.defined(c.index) ? c.index % b.videos.length : 0; | |
| GS.getLightbox().open("video", { | |
| video: b.videos[c], | |
| videos: b.videos, | |
| index: c | |
| }) | |
| } | |
| break; | |
| case "promotion": | |
| GS.getLightbox().open("promotion", { | |
| theme: b | |
| }); | |
| break; | |
| case "openLightbox": | |
| (c = g.attr("data-lightbox-name")) && GS.getLightbox().open(c); | |
| break; | |
| case "expandable": | |
| c = g.attr("data-expandable-id"); | |
| h = g.attr("data-expandable-height"); | |
| a(c).animate({ | |
| height: h | |
| }); | |
| if ( a.isArray(b.expandableTracking) ) { | |
| var m = (new Date).valueOf(), | |
| p = a("body"), | |
| n; | |
| _.forEach(b.expandableTracking, function( o ) { | |
| o += o.indexOf("?") != -1 ? "&" + m : "?" + m; | |
| n = new Image; | |
| p.append(a(n).load(function( t ) { | |
| a(t.target).remove() | |
| }).css("visibility", "hidden").attr("src", o)) | |
| }) | |
| } | |
| break; | |
| case "collapse": | |
| c = g.attr("data-expandable-id"); | |
| a(c).height(0); | |
| break; | |
| default: | |
| break | |
| } | |
| g.attr("data-click-id") && GS.service.logThemeOutboundLinkClick(b.themeID, g.attr("data-click-id")) | |
| } | |
| }) | |
| })(jQuery); | |
| (function() { | |
| GS.Models.Base.extend("GS.Models.Event", { | |
| defaults: { | |
| EventID: 0, | |
| City: "", | |
| EventName: "", | |
| StartTime: "", | |
| TicketsURL: "", | |
| VenueName: "", | |
| ArtistName: "", | |
| searchText: "" | |
| } | |
| }, { | |
| EventID: 0, | |
| City: "", | |
| EventName: "", | |
| StartTime: "", | |
| TicketsURL: "", | |
| VenueName: "", | |
| ArtistName: "", | |
| searchText: "", | |
| init: function( a ) { | |
| this._super(a); | |
| this.TicketsURL.match("utm_source") || (this.TicketsURL += "?utm_source=1&utm_medium=partner"); | |
| this.searchText = [a.ArtistName, a.EventName, a.City, a.VenueName].join(" ").toLowerCase() | |
| } | |
| }) | |
| })(jQuery); | |
| (function( a ) { | |
| GS.Models.Base.extend("GS.Models.UserSettings", { | |
| NOTIF_EMAIL_USER_FOLLOW: 1, | |
| NOTIF_EMAIL_INVITE_SIGNUP: 2, | |
| NOTIF_EMAIL_PLAYLIST_SUBSCRIBE: 16, | |
| NOTIF_EMAIL_NEW_FEATURE: 4096, | |
| NOTIF_CIVICSCIENCE: 32768, | |
| RSS_LISTENS: 2, | |
| RSS_FAVORITES: 1 | |
| }, { | |
| UserID: 0, | |
| local: { | |
| restoreQueue: 0, | |
| lowerQuality: 0, | |
| noPrefetch: 0, | |
| playPauseFade: 0, | |
| crossfadeAmount: 5E3, | |
| crossfadeEnabled: 0, | |
| tooltips: 0, | |
| persistShuffle: 1, | |
| lastShuffle: 0, | |
| persistPinboard: 0 | |
| }, | |
| FName: "", | |
| Email: "", | |
| Country: "", | |
| Zip: "", | |
| Sex: "", | |
| TSDOB: "", | |
| FeedsDisabled: 0, | |
| NotificationEmailPrefs: 0, | |
| emailNotifications: { | |
| userFollow: true, | |
| inviteSignup: true, | |
| playlistSubscribe: true, | |
| newFeature: true, | |
| civicScience: true | |
| }, | |
| rssFeeds: { | |
| listens: true, | |
| favorites: true | |
| }, | |
| _hasLoadedSettings: false, | |
| init: function( b ) { | |
| this._super(b); | |
| b = GS.store.get("player.restoreQueue"); | |
| if (!_.defined(b) ) { | |
| b = GS.store.get("player.restoreQueue" + this.UserID); | |
| if ( _.defined(b) ) try { | |
| GS.store.set("player.restoreQueue", b) | |
| } catch (c) {} | |
| } | |
| this.local.restoreQueue = _.orEqual(b, 0); | |
| this.local.lowerQuality = _.orEqual(GS.store.get("player.lowerQuality" + this.UserID), 0); | |
| this.local.noPrefetch = _.orEqual(GS.store.get("player.noPrefetch" + this.UserID), 0); | |
| this.local.playPauseFade = _.orEqual(GS.store.get("player.playPauseFade" + this.UserID), 0); | |
| this.local.crossfadeAmount = _.orEqual(GS.store.get("player.crossfadeAmount" + this.UserID), 5E3); | |
| this.local.crossfadeEnabled = _.orEqual(GS.store.get("player.crossfadeEnabled" + this.UserID), 0); | |
| this.local.lastShuffle = _.orEqual(GS.store.get("player.lastShuffle" + this.UserID), 0); | |
| this.local.persistShuffle = _.orEqual(GS.store.get("player.persistShuffle" + this.UserID), 1); | |
| this.local.tooltips = _.orEqual(GS.store.get("user.tooltips" + this.UserID), 0); | |
| this.local.themeFlags = _.orEqual(GS.store.get("user.themeFlags" + this.UserID), 0); | |
| this.local.persistPinboard = _.orEqual(GS.store.get("user.persistPinboard" + this.UserID), 0); | |
| if ( this.UserID <= 0 ) this._hasLoadedSettings = true | |
| }, | |
| getUserSettings: function( b, c ) { | |
| if ( this.UserID ) if ( this._hasLoadedSettings ) a.isFunction(b) && b(this); | |
| else GS.service.getUserSettings(this.callback(this._onSettingsSuccess, b), this.callback(this._onSettingsFailed, c)) | |
| }, | |
| _onSettingsSuccess: function( b, c ) { | |
| if ( c.hasOwnProperty("userInfo") ) { | |
| a.extend(this, c.userInfo); | |
| if ( this.hasOwnProperty("LName") && this.hasOwnProperty("FName") ) { | |
| var g = this.LName, | |
| h = this.FName; | |
| this.LName = a.trim(this.LName); | |
| this.FName = a.trim(this.FName); | |
| if ( this.LName ) { | |
| this.FName += " " + this.LName; | |
| this.FName = a.trim(this.FName) | |
| } | |
| delete this.LName; | |
| var k = {}; | |
| if ( this.FName !== h ) k.FName = this.FName; | |
| if ( g ) k.LName = ""; | |
| _.isEmpty(k) || GS.service.changeUserInfoEx(k) | |
| } | |
| this.NotificationEmailPrefs = parseInt(this.NotificationEmailPrefs, 10); | |
| this.FeedsDisabled = parseInt(this.FeedsDisabled, 10); | |
| this._updateBitmaskProps() | |
| } | |
| this._hasLoadedSettings = true; | |
| a.isFunction(b) && b(this) | |
| }, | |
| _onSettingsFailed: function( b ) { | |
| a.isFunction(b) && b(this) | |
| }, | |
| _updateBitmaskProps: function() { | |
| this.emailNotifications = { | |
| userFollow: !(this.NotificationEmailPrefs & GS.Models.UserSettings.NOTIF_EMAIL_USER_FOLLOW), | |
| inviteSignup: !(this.NotificationEmailPrefs & GS.Models.UserSettings.NOTIF_EMAIL_INVITE_SIGNUP), | |
| playlistSubscribe: !(this.NotificationEmailPrefs & GS.Models.UserSettings.NOTIF_EMAIL_PLAYLIST_SUBSCRIBE), | |
| newFeature: !(this.NotificationEmailPrefs & GS.Models.UserSettings.NOTIF_EMAIL_NEW_FEATURE), | |
| civicScience: !(this.NotificationEmailPrefs & GS.Models.UserSettings.NOTIF_CIVICSCIENCE) | |
| }; | |
| this.rssFeeds = { | |
| listens: !(this.FeedsDisabled & GS.Models.UserSettings.RSS_LISTENS), | |
| favorites: !(this.FeedsDisabled & GS.Models.UserSettings.RSS_FAVORITES) | |
| } | |
| }, | |
| updateProfile: function( b, c, g ) { | |
| b = a.extend({}, { | |
| FName: this.FName, | |
| Email: this.Email, | |
| Country: this.Country, | |
| Zip: this.Zip, | |
| Sex: this.Sex, | |
| TSDOB: this.TSDOB, | |
| PageName: GS.user.PathName | |
| }, b); | |
| if ( this.UserID < 1 ) this._saveProfileFailed({ | |
| statusCode: -1 | |
| }); | |
| else { | |
| b.PageName === GS.user.PathName && delete b.PageName; | |
| var h; | |
| for ( h in b ) | |
| b.hasOwnProperty(h) && b[h] == this[h] && delete b[h]; | |
| if ( _.isEmpty(b) ) this._saveProfileSuccess({ | |
| statusCode: 1 | |
| }); | |
| else if ((b.hasOwnProperty("Email") || b.hasOwnProperty("PageName")) && !_.defined(b.password) ) GS.getLightbox().open("confirmPasswordProfile", { | |
| params: b, | |
| callback: c, | |
| errback: g | |
| }); | |
| else { | |
| h = b.password; | |
| delete b.password; | |
| GS.service.changeUserInfoEx(b, h, this.callback(this._saveProfileSuccess, b, c, g), this.callback(this._saveProfileFailed, g)) | |
| } | |
| } | |
| }, | |
| _saveProfileSuccess: function( b, c, g, h ) { | |
| if ( h && h.statusCode === 1 ) { | |
| a.extend(this, b); | |
| if ( b.hasOwnProperty("PageName") ) GS.user.PathName = b.PageName; | |
| a.isFunction(c) && c(h) | |
| } else this._saveProfileFailed(g, h) | |
| }, | |
| _saveProfileFailed: function( b, c ) { | |
| a.isFunction(b) && b(c) | |
| }, | |
| changeNotificationSettings: function( b, c, g ) { | |
| b = a.extend({}, this.emailNotifications, b); | |
| b = (b.userFollow ? 0 : GS.Models.UserSettings.NOTIF_EMAIL_USER_FOLLOW) | (b.inviteSignup ? 0 : GS.Models.UserSettings.NOTIF_EMAIL_INVITE_SIGNUP) | (b.playlistSubscribe ? 0 : GS.Models.UserSettings.NOTIF_EMAIL_PLAYLIST_SUBSCRIBE) | (b.newFeature ? 0 : GS.Models.UserSettings.NOTIF_EMAIL_NEW_FEATURE) | (b.civicScience ? 0 : GS.Models.UserSettings.NOTIF_CIVICSCIENCE); | |
| if ( this.UserID < 1 ) a.isFunction(g) && g("Not logged in"); | |
| else GS.service.changeNotificationSettings(b, this.callback(this._notificationsSuccess, b, c, g), this.callback(this._notificationsFailed, g)) | |
| }, | |
| _notificationsSuccess: function( b, c, g, h ) { | |
| if ( h && h.statusCode === 1 ) { | |
| this.NotificationEmailPrefs = b; | |
| this._updateBitmaskProps(); | |
| a.isFunction(c) && c(h) | |
| } else this._notificationsFailed(g, h) | |
| }, | |
| _notificationsFailed: function( b, c ) { | |
| a.isFunction(b) && b(c) | |
| }, | |
| changeRSSSettings: function( b, c, g ) { | |
| b = a.extend({}, this.rssFeeds, b); | |
| b = (b.listens ? 0 : GS.Models.UserSettings.RSS_LISTENS) | (b.favorites ? 0 : GS.Models.UserSettings.RSS_FAVORITES); | |
| if ( this.UserID < 1 ) a.isFunction(g) && g("Not logged in"); | |
| else GS.service.changeFeedSettings(b, this.callback(this._notificationsSuccess, b, c, g), this.callback(this._notificationsFailed, g)) | |
| }, | |
| _rssSuccess: function( b, c, g, h ) { | |
| if ( h && h.statusCode === 1 ) { | |
| this.FeedsDisabled = b; | |
| this._updateBitmaskProps(); | |
| a.isFunction(c) && c(h) | |
| } else this._rssFailed(g, h) | |
| }, | |
| _rssFailed: function( b, c ) { | |
| a.isFunction(b) && b(c) | |
| }, | |
| changeLocalSettings: function( b, c ) { | |
| a.extend(this.local, b); | |
| GS.store.set("player.restoreQueue", this.local.restoreQueue); | |
| GS.store.set("player.lowerQuality" + this.UserID, this.local.lowerQuality); | |
| GS.store.set("player.noPrefetch" + this.UserID, this.local.noPrefetch); | |
| GS.store.set("player.playPauseFade" + this.UserID, this.local.playPauseFade); | |
| GS.store.set("player.crossfadeAmount" + this.UserID, this.local.crossfadeAmount); | |
| GS.store.set("player.crossfadeEnabled" + this.UserID, this.local.crossfadeEnabled); | |
| GS.store.set("player.lastShuffle" + this.UserID, this.local.lastShuffle); | |
| GS.store.set("player.persistShuffle" + this.UserID, this.local.persistShuffle); | |
| GS.store.set("user.tooltips" + this.UserID, this.local.tooltips); | |
| GS.store.set("user.themeFlags" + this.UserID, this.local.themeFlags); | |
| GS.store.set("user.persistPinboard" + this.UserID, this.local.persistPinboard); | |
| a.publish("gs.settings.local.update", this.local); | |
| a.isFunction(c) && c(this) | |
| } | |
| }) | |
| })(jQuery); | |
| (function( a ) { | |
| var b; | |
| GS.Models.Base.extend("GS.Models.Video", { | |
| id: "VideoID", | |
| artPath: "http://images.grooveshark.com/static/featured/", | |
| wrapYoutube: function( c, g ) { | |
| if (!c.thumbnail ) var h = c.Thumbnails && c.Thumbnails.length && c.Thumbnails[0] ? c.Thumbnails[0].url : ""; | |
| g = g || c.Title || c.title || c.Video; | |
| return this.wrap(a.extend(true, {}, c, { | |
| title: g, | |
| duration: _.millisToMinutesSeconds((c.duration || c.Duration) * 1E3), | |
| type: "youtube", | |
| thumbnail: h, | |
| width: _.orEqual(c.Width, 480), | |
| height: _.orEqual(c.Height, 385), | |
| author: _.orEqual(c.Author, "") | |
| })) | |
| }, | |
| exploreItemRenderer: function( c ) { | |
| var g = "" + ('<a class="name ellipsis">' + c.title + "</a>"), | |
| h = ['<img height="120" src="', c.getImageURL(120), '"/>'].join(""), | |
| k = ['<a href="', c.uri, '">', c.attributor, "</a>"].join(""); | |
| k = a("<span></span>").localeDataString("BY_ARTIST", { | |
| artist: k | |
| }); | |
| var m = c.set ? '<span class="group">in ' + c.set + "</span>" : ""; | |
| return ['<div class="tooltip" data-tip-type="video" data-videoid="', c.VideoID, '" data-cachePrefix="', c.cachePrefix, '"><a class="videoImage insetBorder height120">', h, '<span class="videoPlayBtn" data-videoid="', c.VideoID, '" data-videogroup="' + c.set + '"></span></a>', '<div class="meta">', g, '<span class="by ellipsis">', k.render(), "</span>", m, "</div></div>"].join("") | |
| }, | |
| sliderRenderer: function( c, g, h ) { | |
| var k = '<li class="subcontent-item videos page_content_slide"><a class="subcontent-item-content video image insetBorder height90" rel="' + g + '"><img src="' + c.thumbnail + '" width="120" height="90" /></a><div class="meta">'; | |
| k += c.Title.length > 56 ? '<a class="subcontent-item-content video" title="' + c.Title.replace(/["]/g, """) + '" rel="' + g + '">' + c.Title.substr(0, 40) + "…</a>" : '<a class="subcontent-item-content video" rel="' + g + '">' + h[g].Title + "</a>"; | |
| k += '<span class="author"><span data-translate-text="SONG_BY">' + a.localize.getString("SONG_BY") + "</span>: " + c.Author + '</span><span class="duration"><span data-translate-text="SONG_DURATION">' + a.localize.getString("SONG_DURATION") + "</span>: " + c.duration + '</span><span class="source"><span data-translate-text="SONG_SOURCE">' + a.localize.getString("SONG_SOURCE") + "</span>: Youtube</span></div></li>"; | |
| return k | |
| } | |
| }, { | |
| title: "", | |
| author: "", | |
| type: "flash", | |
| swf: "/webincludes/flash/videoplayer.swf", | |
| src: "", | |
| thumb: null, | |
| thumbnail: null, | |
| thumbTracking: null, | |
| originalWidth: null, | |
| originalHeight: null, | |
| id: "", | |
| width: 480, | |
| height: 385, | |
| flashvars: { | |
| version: gsConfig.coreVersion | |
| }, | |
| params: { | |
| allowscriptaccess: "always", | |
| allowfullscreen: true | |
| }, | |
| attributes: { | |
| name: "videoPlayer" | |
| }, | |
| object: null, | |
| init: function( c ) { | |
| b = this; | |
| if ( c ) { | |
| this._super(c); | |
| this.type = _.orEqual(c.embedType, c.type); | |
| this.embedType = _.orEqual(c.embedType, c.type); | |
| this.vimeoID = _.orEqual(c.vimeoID, c.VimeoID) | |
| } | |
| }, | |
| embed: function( c, g ) { | |
| if ( this.type == "flash" ) { | |
| g = _.orEqual(g, b.refreshWindow); | |
| object = swfobject.embedSWF(this.swf, c, this.width, this.height, "9.0.0", null, this.flashvars, this.params, this.attributes, g) | |
| } else if ( this.type == "iframe" ) return GS.getVimeo().attachPlayer(this.vimeoID, this.width, this.height, c, g); | |
| else this.type == "youtube" && GS.getYoutube().attachPlayer(this.VideoID, this.width, this.height, c, g) | |
| }, | |
| refreshWindow: function() { | |
| setTimeout(function() { | |
| a(window).resize() | |
| }, 500) | |
| }, | |
| getImageURL: function( c ) { | |
| c = | |
| _.orEqual(c, 70); | |
| if ( this.Picture ) return GS.Models.Video.artPath + c + "_" + this.Picture; | |
| return GS.Models.Video.artPath + c + "_artist.png" | |
| } | |
| }) | |
| })(jQuery); | |
| (function( a ) { | |
| function b(n, o) { | |
| var t = true, | |
| w = "http://rest.clearvoicesurveys.com/CVSRestfulService.svc/Json/"; | |
| o = _.orEqual(o, 0); | |
| if ( o >= 3 ) console.warn("service.sendRequest. numRetries maxed out. ", n); | |
| else { | |
| if ( o > 0 ) t = false; | |
| if ( n.url ) w = n.url; | |
| w += n.method + "?orgGUID=BDE3B99E-44DD-4806-9278-89543B177460"; | |
| if ( n.memberGuid && !n.nomemberGuid ) w += "&memberGUID=" + n.memberGuid; | |
| a.ajax(a.extend({}, n.options, { | |
| contentType: "application/json", | |
| cache: t, | |
| url: w, | |
| success: function( x, v, B ) { | |
| if ( x ) { | |
| if ( x.HasError ) if ( a.isFunction(n.errback) ) { | |
| n.errback(x, B, v); | |
| return | |
| } | |
| a.isFunction(n.callback) && n.callback(x, v, B) | |
| } else { | |
| o++; | |
| console.warn("service.success NO DATA. retry request again", n); | |
| setTimeout(function() { | |
| b(n, o) | |
| }, 100 + o * 100) | |
| } | |
| }, | |
| error: function( x, v, B ) { | |
| a.isFunction(n.errback) && n.errback(false, x, v, B) | |
| } | |
| })) | |
| } | |
| } | |
| var c = [19, 49, 50, 63, 94, 97, 103, 104, 117, 139, 153, 159, 160, 173, 182, 191, 200], | |
| g = { | |
| create: "Member/CreateMember/", | |
| member: "Member/GetMember/", | |
| profile: "Demographics/GetProfilesForMember/", | |
| demographic: "Demographics/GetDemographicQuestions/", | |
| save: "Demographics/SaveDemographicAnswers/", | |
| reward: "Rewards/GetAvailableRewards/", | |
| redeem: "Rewards/RedeemReward/" | |
| }, | |
| h = { | |
| method: false, | |
| options: { | |
| contentType: "application/json", | |
| dataType: "jsonp", | |
| data: {}, | |
| cache: false | |
| } | |
| }, | |
| k = null, | |
| m = false, | |
| p = false; | |
| GS.Models.Base.extend("GS.Models.Clearvoice", { | |
| init: function() { | |
| a.subscribe("gs.app.ready", function() { | |
| m = true; | |
| GS.Models.Clearvoice.askOptInCivicScience(6E5) | |
| }); | |
| a.subscribe("gs.auth.update", function() { | |
| GS.Models.Clearvoice.askOptInCivicScience(6E5) | |
| }); | |
| a.subscribe("gs.state.active", function() { | |
| GS.Models.Clearvoice.askOptInCivicScience(0) | |
| }) | |
| }, | |
| askOptInCivicScience: function( n ) { | |
| if ( m ) if ( GS.user.isLoggedIn && !GS.user.IsPremium && a.isReady && !location.hash.substring(2).match(/^signup/i) ) GS.getGuts().shouldLog && GS.user.settings.getUserSettings(function( o ) { | |
| if ( o.emailNotifications.civicScience ) if (!GS.store.get("civicscience.hasSeenInvitation" + GS.user.UserID) && !p ) p = setTimeout(function() { | |
| p = false; | |
| var t = GS.Models.Clearvoice._checkIfIdle(); | |
| if ( GS.user.settings.emailNotifications.civicScience && !t ) { | |
| t = { | |
| text: a.localize.getString("SURVEY_CIVICSCIENCE_OPTIN"), | |
| id: "optInCivicScience", | |
| name: "GS", | |
| type: "radio", | |
| answers: [{ | |
| text: a.localize.getString("SURVEY_CIVICSCIENCE_OPTIN_SURE"), | |
| id: 0 | |
| }, | |
| { | |
| text: a.localize.getString("SURVEY_CIVICSCIENCE_OPTIN_NO"), | |
| id: 1 | |
| }] | |
| }; | |
| GS.getNotice().displaySurveyOptIn({ | |
| question: t, | |
| callback: function() { | |
| GS.Models.Clearvoice.setupCivicScience(0) | |
| } | |
| }) | |
| } | |
| }, n); | |
| else GS.Models.Clearvoice.setupCivicScience(n) | |
| }); | |
| else if ( a.isReady && !GS.user.isLoggedIn ) { | |
| if ( p ) { | |
| clearTimeout(p); | |
| p = false | |
| } | |
| GS.getNotice().closeAllSurveyNotifs() | |
| } | |
| }, | |
| setupCivicScience: function( n ) { | |
| var o = {}; | |
| o.answeredList = []; | |
| o.answeredIndex = 0; | |
| o.session = new civicscience.iqapi.Session(473, false); | |
| o.askQuestion = function( t ) { | |
| if ( t == null ) { | |
| var w = new Date; | |
| if (!GS.store.get("civicscience.polltroll" + GS.user.UserID + w.getDay()) ) { | |
| a.publish("gs.notification", { | |
| type: "success", | |
| message: a.localize.getString("SURVEY_COME_BACK") | |
| }); | |
| GS.store.set("civicscience.polltroll" + GS.user.UserID + w.getDay()); | |
| w = w.getDay() - 1; | |
| GS.store.remove("civicscience.polltroll" + GS.user.UserID + w) | |
| } | |
| } else { | |
| w = { | |
| text: t.getText(), | |
| id: t.getId(), | |
| name: "CivicScience", | |
| type: "radio" | |
| }; | |
| t = t.getOptions(); | |
| var x = []; | |
| _.forEach(t, function( v ) { | |
| x.push({ | |
| text: v.getText(), | |
| id: v.getId(), | |
| option: v | |
| }) | |
| }); | |
| w.answers = x; | |
| o.question = w; | |
| GS.getNotice().displaySurveyQuestion({ | |
| question: w | |
| }) | |
| } | |
| }; | |
| o.handleCommit = function() { | |
| o.handleResults() | |
| }; | |
| o.handleResults = function() { | |
| o.answeredList = o.session.getAnsweredQuestions(); | |
| o.answeredList[o.answeredIndex].getResults(o.showResults); | |
| GS.getGuts().logEvent("civicscience.questionAnswered", { | |
| userID: GS.user.UserID, | |
| questionNum: o.answeredIndex, | |
| timestamp: (new Date).getTime() | |
| }); | |
| o.answeredIndex++ | |
| }; | |
| o.showResults = function( t, w ) { | |
| if ( w != null ) { | |
| var x = {}; | |
| x.questionText = t.getText(); | |
| x.numOfTotalResponses = w.getTotal(); | |
| var v = w.getCommittedOption(), | |
| B = t.getOptions(), | |
| E = []; | |
| v.id = v.getId(); | |
| _.forEach(B, function( D ) { | |
| var y = w.getCountForOption(D), | |
| A = 0; | |
| if ( x.numOfTotalResponses != 0 ) { | |
| A = Math.round(100 * y / x.numOfTotalResponses); | |
| E.push({ | |
| text: D.getText(), | |
| id: D.getId(), | |
| percent: A, | |
| selected: v.id == D.getId() ? true : false | |
| }) | |
| } | |
| }); | |
| x.answers = E; | |
| B = E[0].percent; | |
| var H = E[0]; | |
| v = E[0]; | |
| for ( var G = 0; G < E.length - 1; G++ ) { | |
| if ( E[G + 1].selected ) v = E[G + 1]; | |
| if ( B < E[G + 1].percent ) { | |
| B = E[G + 1].percent; | |
| H = E[G + 1] | |
| } | |
| } | |
| x.selectedAnswer = v; | |
| x.mostPopular = H; | |
| GS.getNotice().displaySurveyResult({ | |
| responses: x, | |
| callback: function() { | |
| o.session.getNextUnansweredQuestion(o.askQuestion) | |
| } | |
| }) | |
| } | |
| }; | |
| if ( GS.user.userPrivacyTokens && GS.user.userPrivacyTokens.authenticated ) { | |
| o.session.setExternalUserId(GS.user.userPrivacyTokens.authenticated); | |
| GS.user.civicScience = o; | |
| GS.Models.Clearvoice.initCivicScienceNotifTracking(o, n) | |
| } | |
| }, | |
| initCivicScienceNotifTracking: function( n, o ) { | |
| p || (p = setTimeout(function() { | |
| p = | |
| false; | |
| if ( GS.user.settings.emailNotifications.civicScience ) GS.Models.Clearvoice._checkIfIdle() || n.session.getNextUnansweredQuestion(n.askQuestion) | |
| }, o)) | |
| }, | |
| changeCivicScienceSettings: function( n ) { | |
| n && GS.user.settings.changeNotificationSettings({ | |
| civicScience: false | |
| }, function() { | |
| a.publish("gs.notification", { | |
| type: "notice", | |
| message: a.localize.getString("SURVEY_CIVICSCIENCE_OPTOUT") | |
| }); | |
| GS.getGuts().logEvent("civicscience.optOut", { | |
| userID: GS.user.UserID, | |
| timestamp: (new Date).getTime() | |
| }) | |
| }) | |
| }, | |
| _checkIfIdle: function() { | |
| var n = | |
| GS.getAd().lastActive.getTime(), | |
| o = (new Date).getTime(), | |
| t = GS.getAd().maxRotationTime; | |
| return o - n > t | |
| }, | |
| createMember: function( n, o, t, w, x, v, B, E ) { | |
| var H = a.extend(true, {}, h); | |
| n = { | |
| emailAddress: _.orEqual(n, ""), | |
| firstName: _.orEqual(o, ""), | |
| lastName: _.orEqual(t, ""), | |
| gender: _.orEqual(w, ""), | |
| zipCode: _.orEqual(x, ""), | |
| dateOfBirth: _.orEqual(v, "") | |
| }; | |
| B = a.extend(true, {}, n, { | |
| callback: B, | |
| errback: E | |
| }); | |
| H.method = g.create; | |
| H.nomemberGuid = true; | |
| H.options.data = a.extend(true, {}, n, H.options.data); | |
| H.callback = this.callback("createSuccess", B); | |
| H.errback = | |
| this.callback("createFailed", B); | |
| b(H) | |
| }, | |
| createSuccess: function( n, o ) { | |
| if ((n.member = o) && o.MemberGuid ) GS.service.saveClearvoiceMemberInfo(o.MemberGuid, n.firstName, n.lastName, n.emailAddress, this.callback("saveSuccess", n), this.callback("saveFail", n)); | |
| else a.isFunction(n.errback) && n.errback(n.member) | |
| }, | |
| createFailed: function( n, o ) { | |
| n.member = o; | |
| if ( o.ExceptionMessage && o.ExceptionMessage.match(/email/i) && o.ExceptionMessage.match(/exists/i) ) { | |
| var t = o.MemberGuid; | |
| GS.user.clearvoice && GS.user.clearvoice.MemberGuid == t ? GS.service.saveClearvoiceMemberInfo(t, n.firstName, n.lastName, n.emailAddress, this.callback("saveSuccess", n), this.callback("saveFail", n)) : GS.service.getClearvoiceMemberInfo(t, this.callback("_createMemberGSCheckSuccess", n), this.callback("_createMemberGSCheckFailed", n)) | |
| } else a.isFunction(n.errback) && n.errback(n.member) | |
| }, | |
| _createMemberGSCheckSuccess: function( n, o ) { | |
| if ( _.isArray(o) && o.length === 0 || !o.hasOwnProperty("userID") ) { | |
| n.member = a.extend(true, n.member, o); | |
| GS.service.getUserIDByClearvoiceEmail(n.emailAddress, this.callback("_createMemberEmailCheckSuccess", n), this.callback("_createMemberEmailCheckFailed", n)) | |
| } else if ( o.hasOwnProperty("userID") && o.userID == GS.user.UserID ) this.memberSuccess(n, o); | |
| else if ( a.isFunction(n.errback) ) { | |
| try { | |
| delete n.member.ExceptionMessage | |
| } catch (t) {} | |
| n.errback(n.member) | |
| } | |
| }, | |
| _createMemberGSCheckFailed: function( n ) { | |
| a.isFunction(n.errback) && n.errback(n.member) | |
| }, | |
| _createMemberEmailCheckSuccess: function( n, o ) { | |
| if ((o = parseInt(o, 10)) && o === GS.user.UserID ) this.memberSuccess(n, n.member); | |
| else if ( a.isFunction(n.errback) ) if ( o === 0 ) GS.service.saveClearvoiceMemberInfo(n.member.MemberGuid, n.firstName, n.lastName, n.emailAddress, this.callback("saveSuccess", n), this.callback("saveFail", n)); | |
| else { | |
| if ( o ) try { | |
| delete n.member.ExceptionMessage | |
| } catch (t) {} | |
| n.errback(n.member) | |
| } | |
| }, | |
| _createMemberEmailCheckFailed: function( n ) { | |
| a.isFunction(n.errback) && n.errback(n.member) | |
| }, | |
| saveSuccess: function( n ) { | |
| a.isFunction(n.callback) && GS.Models.Clearvoice.getMember(n.callback) | |
| }, | |
| saveFail: function( n, o ) { | |
| a.isFunction(n.errback) && n.errback(o, n.member) | |
| }, | |
| getMember: function( n, o ) { | |
| GS.service.getClearvoiceMemberInfo(null, this.callback("getAvailablePollsForUser", { | |
| callback: n, | |
| errback: o | |
| }), o) | |
| }, | |
| getAvailablePollsForUser: function( n, o ) { | |
| GS.user.isLoggedIn ? GS.service.getUserSurveys(GS.user.userID, this.callback("memberSuccess", n, o)) : this.memberSuccess(n, null, { | |
| available: [], | |
| completed: [] | |
| }) | |
| }, | |
| memberSuccess: function( n, o, t ) { | |
| o = _.isArray(o) && o.length === 0 ? GS.Models.Clearvoice.wrap(o) : GS.Models.Clearvoice.wrap({}); | |
| o.profileProgressTotal = 25; | |
| o = this.loadInPolls(o, t); | |
| GS.user.clearvoice = o; | |
| n.callback(o) | |
| }, | |
| loadInPolls: function( n, o ) { | |
| var t = o.available, | |
| w = o.completed; | |
| t.sort(function( v, B ) { | |
| return B.TSModified - v.TSModified | |
| }); | |
| w.sort(function( v, B ) { | |
| return B.endDate - v.endDate | |
| }); | |
| n.polls = {}; | |
| n.polls.available = t; | |
| n.polls.completed = w; | |
| t = []; | |
| if ( n.polls.completed.length != 0 ) { | |
| for ( w = 0; w < n.polls.available.length; w++ ) | |
| for ( var x = 0; x < n.polls.completed.length; x++ ) | |
| if ( n.polls.available[w].SurveyID == n.polls.completed[x].SurveyID ) { | |
| n.polls.completed[x] = n.polls.available[w]; | |
| break | |
| } else x == n.polls.completed.length - 1 && t.push(n.polls.available[w]); | |
| n.polls.available = t.concat() | |
| } | |
| return n | |
| }, | |
| clearvoiceMemberSuccess: function( n, o ) { | |
| o = a.extend(true, n.member, o); | |
| o = GS.Models.Clearvoice.wrap(o); | |
| GS.user.clearvoice = this.member; | |
| n.callback(o); | |
| GS.header.update() | |
| }, | |
| getMemberClearvoice: function( n, o, t ) { | |
| request = a.extend(true, {}, h); | |
| request.memberGuid = n; | |
| request.method = g.member; | |
| request.callback = o; | |
| request.errback = t; | |
| b(request) | |
| }, | |
| defaultPointsPerProfiler: 6, | |
| defaultPointsPerSurvey: 150, | |
| numPointsForPlus: 600, | |
| numPointsForAnywhere: 900, | |
| CLEARVOICE_TO_GROOVESHARK_CONVERSION: 100 | |
| }, { | |
| MemberGuid: false, | |
| EmailAddress: "", | |
| FirstName: "", | |
| LastName: "", | |
| AvailableSurveys: [], | |
| CompletedSurveys: [], | |
| DynamicSurveys: [], | |
| RewardHistory: [], | |
| Profilers: [], | |
| profileProgress: 0, | |
| profileProgressTotal: 0, | |
| baseRequest: {}, | |
| answers: null, | |
| surveyLookup: {}, | |
| totalSurveys: 0, | |
| init: function( n ) { | |
| this._super(n); | |
| console.log("loaded"); | |
| (this.enabled = GS.service.country && c.indexOf(parseInt(GS.service.country.ID, 10)) === -1) || (GS.service.country ? console.log("clearvoice disabled, banned country", GS.service.country.ID) : console.warn("clearvoice init, service has no country. disabled")); | |
| this.Profilers = _.orEqual(this.Profilers, []); | |
| this.baseRequest = | |
| a.extend(true, { | |
| memberGuid: this.MemberGuid | |
| }, h); | |
| this.getQuestions(this.callback("initFinish")) | |
| }, | |
| initFinish: function() { | |
| this.profileProgressTotal = this.questions.length; | |
| this.surveyLookup = {}; | |
| this.AvailableSurveys = _.orEqual(this.AvailableSurveys, []); | |
| this.CompletedSurveys = _.orEqual(this.CompletedSurveys, []); | |
| this.totalSurveys = this.AvailableSurveys.length; | |
| for ( var n = 0; n < this.AvailableSurveys.length; n++ ) | |
| this.surveyLookup[this.AvailableSurveys[n].SurveyId] = this.AvailableSurveys[n]; | |
| for ( n = 0; n < this.CompletedSurveys.length; n++ ) | |
| this.surveyLookup[this.CompletedSurveys[n].ProjectId] = | |
| this.CompletedSurveys[n]; | |
| window.displaySurveyResult = this.callback(function( o ) { | |
| if ((this.lastSurveyResult = o) && o.SurveyLength ) { | |
| o.gsResult > 0 && GS.user.addPoints(o.gsResult, true); | |
| if ( o.ResultCode == "S" && a("#page").is(".gs_page_surveys") ) { | |
| var t = o.hasOwnProperty(SurveyID) ? o.SurveyID : o.ProjectQuotaID; | |
| a("#survey" + t + " a.startSurvey").replaceWith('<span class="surveyCompleted"><span data-translate-text="SURVEY_SURVEY_COMPLETED">' + a.localize.getString("SURVEY_SURVEY_COMPLETED") + "</span></span>"); | |
| a("div.surveys.completed", "#page.gs_page_surveys").append(a("#survey" + t)); | |
| a("div.surveys.available div.survey", "#page.gs_page_surveys").removeClass("last").filter(":last").addClass("last"); | |
| a("div.surveys.completed div.survey", "#page.gs_page_surveys").removeClass("last").filter(":last").addClass("last"); | |
| a("div.surveys.completed,h3.completed", "#page.gs_page_surveys").show() | |
| } | |
| GS.getLightbox().open("surveyResult", o) | |
| } else GS.getLightbox().open("surveyResult", { | |
| ResultCode: "R", | |
| gsResult: -1 | |
| }) | |
| }) | |
| }, | |
| questions: false, | |
| getQuestions: function( n ) { | |
| if ( this.questions ) if ( a.isFunction(n) ) n(this.questions); | |
| else return this.questions; | |
| var o = []; | |
| if ( k ) { | |
| this.formatDemographics(k, o); | |
| this.questions = o | |
| } else a.ajax({ | |
| url: "/webincludes/json/clearvoiceTop25Questions.json", | |
| async: false, | |
| success: this.callback(function( t ) { | |
| try { | |
| k = JSON.parse(t) | |
| } catch (w) { | |
| return | |
| } | |
| this.formatDemographics(k, o); | |
| this.questions = o; | |
| a.isFunction(n) && n(this.questions) | |
| }), | |
| error: function() {} | |
| }) | |
| }, | |
| getDemographics: function( n, o, t ) { | |
| request = a.extend(true, {}, this.baseRequest); | |
| request.method = g.demographic; | |
| request.options.data = a.extend(true, { | |
| profileId: n | |
| }, request.options.data); | |
| request.callback = this.callback("demographicSuccess", o, n); | |
| request.errback = this.callback("handleError", t); | |
| b(request) | |
| }, | |
| demographicSuccess: function( n, o, t ) { | |
| o = []; | |
| this.formatDemographics(t.Demographics, o); | |
| a.isFunction(n) && n(o) | |
| }, | |
| answers: {}, | |
| formatDemographics: function( n, o ) { | |
| var t = {}; | |
| _.forEach(n, this.callback(function( w ) { | |
| if (!t[w.DemographicId] ) { | |
| var x = w.Conditions; | |
| this.cacheAnswers(w.PossibleAnswers); | |
| o.push(w); | |
| t[w.DemographicId] = true; | |
| w.MemberAnswers && this.saveLocalAnswers(w.MemberAnswers); | |
| x && x.length && _.forEach(x, this.callback(function( v ) { | |
| var B = v.ConditionalDemographics; | |
| if ( B && B.length == 1 ) if (!t[v.DemographicId] ) { | |
| o.push(a.extend(true, {}, v, B[0])); | |
| t[v.DemographicId] = true; | |
| this.cacheAnswers(B[0].PossibleAnswers); | |
| B[0].MemberAnswers && this.saveLocalAnswers(B[0].MemberAnswers) | |
| } | |
| })) | |
| } | |
| })) | |
| }, | |
| answerLookup: {}, | |
| cacheAnswers: function( n ) { | |
| _.forEach(n, this.callback(function( o ) { | |
| this.answerLookup[o.AnswerId] = o | |
| })) | |
| }, | |
| saveLocalAnswers: function( n ) { | |
| n = _.isArray(n) ? n : [n]; | |
| if (!this.answers ) this.answers = {}; | |
| for ( var o = 0; o < n.length; o++ ) { | |
| this.answers[n[o].DemographicId] || (this.answers[n[o].DemographicId] = {}); | |
| this.answers[n[o].DemographicId][n[o].AnswerId] = n[o] | |
| } | |
| }, | |
| saveAnswers: function( n, o, t ) { | |
| n = _.isArray(n) ? n : [n]; | |
| this.saveLocalAnswers(n); | |
| request = a.extend(true, {}, this.baseRequest); | |
| request.method = g.save; | |
| request.options.data = a.extend(true, { | |
| memberAnswers: JSON.stringify(n) | |
| }, request.options.data); | |
| b(request); | |
| var w, x = {}; | |
| for ( w = 0; w < n.length; w++ ) { | |
| x[n[w].DemographicId] || (x[n[w].DemographicId] = []); | |
| x[n[w].DemographicId].push(n[w].AnswerId) | |
| } | |
| GS.service.addClearvoiceAnswers(x, o, t); | |
| GS.user.addPoints(GS.Models.Clearvoice.defaultPointsPerProfiler, true) | |
| }, | |
| answerSuccess: function( n, o ) { | |
| a.isFunction(n) && n(o) | |
| }, | |
| savePollAnswers: function( n, o, t, w, x ) { | |
| GS.service.saveUserAnswers(n, o, t, true, x, this.callback("savePollAnswersError")) | |
| }, | |
| savePollAnswersError: function() { | |
| a.publish("gs.notification", { | |
| type: "error", | |
| message: a.localize.getString("GROOVESHARK_SURVEYS_SAVE_ERROR_MSG") | |
| }); | |
| location.hash = "/surveys" | |
| }, | |
| resetProgress: function() { | |
| this.getQuestions(this.callback(function() { | |
| this.profileProgress = _.toArrayID(this.answers).length; | |
| this.profileProgressTotal = this.questions.length | |
| })) | |
| }, | |
| getRewards: function( n, o ) { | |
| request = a.extend(true, {}, baseRequest); | |
| request.method = g.reward; | |
| request.callback = this.callback("rewardsSuccess", n); | |
| request.errback = this.callback("handleError", o); | |
| b(request) | |
| }, | |
| rewardsSuccess: function( n, o ) { | |
| a.isFunction(n) && n(o) | |
| }, | |
| payByPoints: function() { | |
| var n = hex_md5((new Date).getTime()), | |
| o = gsConfig.runMode == "production" ? "https://vip.grooveshark.com/" : "https://stagingvip.grooveshark.com/", | |
| t = { | |
| callbackMethod: n, | |
| callbackUrl: location.protocol + "//" + location.host + "/vipCallback.php", | |
| bExtend: GS.user.IsPremium ? 1 : 0 | |
| }; | |
| window[n] = this.callback(function( w ) { | |
| if ( w.bSuccess && w.token ) { | |
| var x = hex_md5((new Date).getTime()), | |
| v = w.description.match(/anywhere/i) ? "anywhere" : "plus", | |
| B = gsConfig.runMode == "production" ? "https://vip.grooveshark.com/" : "https://stagingvip.grooveshark.com/"; | |
| w = { | |
| callbackMethod: x, | |
| callbackUrl: location.protocol + "//" + location.host + "/vipCallback.php", | |
| token: w.token | |
| }; | |
| window[x] = this.callback(function( E ) { | |
| if ( E.bSuccess ) { | |
| GS.user.updateAccountType(v); | |
| location.hash += " " | |
| } | |
| }); | |
| GS.service.httpsFormSubmit(B + "payByPointsConfirm.php", w, x) | |
| } | |
| }); | |
| GS.service.httpsFormSubmit(o + "payByPoints.php", t, n) | |
| }, | |
| redeemRewards: function( n, o, t ) { | |
| request = a.extend(true, {}, baseRequest); | |
| request.method = g.redeem; | |
| request.callback = this.callback("redeemSuccess", o); | |
| request.errback = this.callback("handleError", t); | |
| b(request) | |
| }, | |
| redeemSuccess: function( n, o ) { | |
| a.isFunction(n) && n(o) | |
| }, | |
| handleError: function( n, o, t, w, x ) { | |
| a.isFunction(n) && n(o, t, w, x) | |
| }, | |
| askSurveyQuestionNotification: function() { | |
| if (!a("#page_content").is(".surveys") ) if ( this.enabled ) for ( var n, o = 0, t = { | |
| 6: true, | |
| 7: true | |
| }; n = | |
| this.questions[o]; ) if ( this.answers && this.answers[n.DemographicId] ) o++; | |
| else if ( this.answers && n.AnswerId && this.answers[n.ParentDemographicId] && !this.answers[n.ParentDemographicId][n.AnswerId] ) o++; | |
| else if ( t[n.DemographicTypeId] ) o++; | |
| else if ( o < this.questions.length ) { | |
| GS.getNotice().displaySurveyQuestion({ | |
| question: n, | |
| questionIndex: o, | |
| callback: this.callback("questionNotificationAnswered") | |
| }); | |
| return | |
| } | |
| }, | |
| questionNotificationAnswered: function( n, o, t ) { | |
| if ( this.answerLookup[o] ) { | |
| this.saveAnswers([this.answerLookup[o]], function( w ) { | |
| GS.user.clearvoice.determineValidAnswer(w) | |
| }); | |
| t == this.questions.length - 1 ? GS.getNotice().displaySurveyProfilersComplete() : setTimeout(this.callback("askSurveyQuestionNotification"), 750) | |
| } | |
| }, | |
| determineValidAnswer: function( n ) { | |
| var o = false, | |
| t = []; | |
| if ( n && n.questionResults ) { | |
| _.forEach(n.questionResults, function( w, x ) { | |
| if ( w < 1 ) { | |
| t.push(x + "=" + w); | |
| o = true | |
| } | |
| }); | |
| o && GS.getNotice().displaySurveyAnswerError(t.join(", ")) | |
| } | |
| }, | |
| showInvitationNotification: function() { | |
| this.enabled && !GS.user.IsPremium && GS.getNotice().displaySurveyInvitation() | |
| }, | |
| showSurveysAvailableNotification: function() { | |
| this.enabled && this.AvailableSurveys.length > 0 && GS.getNotice().displaySurveysAvailable(GS.user.clearvoice.AvailableSurveys[0]) | |
| } | |
| }) | |
| })(jQuery); | |
| (function() { | |
| GS.Models.Base.extend("GS.Models.Visualizer", {}, { | |
| title: "", | |
| author: "", | |
| swf: "/webincludes/flash/visualizerplayer.swf", | |
| src: "", | |
| thumb: null, | |
| width: 480, | |
| height: 270, | |
| flashvars: { | |
| version: gsConfig.coreVersion | |
| }, | |
| params: { | |
| allowscriptaccess: "always", | |
| allowfullscreen: true, | |
| wmode: "window" | |
| }, | |
| attributes: { | |
| name: "visualizerPlayer" | |
| }, | |
| object: null, | |
| init: function( a ) { | |
| a && this._super(a) | |
| }, | |
| embed: function( a ) { | |
| object = swfobject.embedSWF(this.swf, a, this.width, this.height, "9.0.0", null, this.flashvars, this.params, this.attributes) | |
| } | |
| }) | |
| })(jQuery); | |
| (function() { | |
| GS.Models.Base.extend("GS.Models.Promotion", { | |
| promotions: { | |
| 1: { | |
| title: "Can't Wait to Get It On Playlists" | |
| } | |
| }, | |
| submitPlaylistForCampaign: function( a, b, c, g ) { | |
| GS.service.submitPlaylistForCampaign(a, b, c, g) | |
| }, | |
| submitSongVoteForCampaign: function( a, b, c, g ) { | |
| GS.service.submitSongVoteForCampaign(a, b, c, g) | |
| } | |
| }, { | |
| campaignID: 0, | |
| title: null, | |
| playlists: null, | |
| init: function( a ) { | |
| this.campaignID = a; | |
| this.title = GS.Models.Promotion.promotions[this.campaignID].title | |
| }, | |
| getPlaylistsForCampaign: function( a, b ) { | |
| GS.service.getPlaylistsForCampaign(this.campaignID, this.callback(["savePlaylists", a]), b) | |
| }, | |
| savePlaylists: function( a ) { | |
| return this.playlists = GS.Models.Playlist.wrapCollection(a) | |
| } | |
| }) | |
| })(jQuery); | |
| (function( a ) { | |
| a.Model.extend("GS.Models.Feature", { | |
| TYPE_ACTIVATE: "ACTIVATE", | |
| TYPE_PASSIVE: "PASSIVE", | |
| TYPE_PLUGIN: "PLUGIN", | |
| Features: {}, | |
| Activated: {}, | |
| Plugins: {}, | |
| init: function() { | |
| GS.Models.Feature.Plugins.sharkZapper = new GS.Models.Feature({}) | |
| }, | |
| register: function( b, c ) { | |
| GS.Models.Feature.Features[b] = new GS.Models.Feature(c) | |
| } | |
| }, { | |
| FeatureID: "", | |
| TextKey: "", | |
| Author: "Grooveshark", | |
| URL: "", | |
| IsPremium: true, | |
| Type: "PASSIVE", | |
| IsLoaded: false, | |
| LoadOnActivate: false, | |
| ActivateCallback: null, | |
| IsActiveCallback: null, | |
| init: function( b ) { | |
| this._super(b) | |
| }, | |
| activate: function( b ) { | |
| if ((GS.user.IsPremium || !this.IsPremium) && this.ActivateCallback ) { | |
| this.ActivateCallback(); | |
| b && b() | |
| } else this.ActivateCallback && GS.getLightbox().open("vipOnlyFeature", { | |
| callback: this.callback(this.activate, b) | |
| }) | |
| }, | |
| isActive: function() { | |
| return this.IsActiveCallback ? this.IsActiveCallback() : false | |
| }, | |
| getImageURL: function( b ) { | |
| b = _.orEqual(b, "s"); | |
| return gsConfig.assetHost + "/features/" + this.FeatureID + "/icon_" + b + ".png" | |
| }, | |
| getButtonKey: function() { | |
| return this.Type + (this.isActive() ? "_BUTTON_OFF" : "_BUTTON_ON") | |
| } | |
| }) | |
| })(jQuery); | |
| $.extend($.View.EJS.Helpers.prototype, { | |
| localeTag: function( a, b, c, g ) { | |
| c = c || {}; | |
| c["data-translate-text"] = b; | |
| b = $.localize.getString(b); | |
| if ( g ) b = $("<span></span>").dataString(b, g).render(); | |
| return [this.tag(a, c), b, this.tagEnd(a)].join("") | |
| }, | |
| tag: function( a, b, c ) { | |
| var g = ["<" + a]; | |
| _.forEach(b, function( h, k ) { | |
| g.push(" " + k + '="' + h + '"') | |
| }); | |
| g.push(c || ">"); | |
| return g.join("") | |
| }, | |
| tagEnd: function( a ) { | |
| return ["</", a, ">"].join("") | |
| } | |
| }); | |
| jQuery.Controller.extend("GS.Controllers.BaseController", { | |
| setup: function() { | |
| this._super.apply(this, arguments); | |
| this.preSetup && this.preSetup() | |
| }, | |
| init: function() { | |
| this._super(); | |
| if ( this.onWindow && !this.isGSSingleton ) new this($(window)); | |
| else this.onElement && !this.isGSSingleton && new this($(this.onElement)) | |
| }, | |
| instance: function() { | |
| if ( this.isGSSingleton ) return new this(this.onElement && $(this.onElement) || this.onWindow && window || document.documentElement); | |
| if ( this.onDocument ) return $(document.documentElement).controller(this._shortName); | |
| if ( this.onWindow ) return $(window).controller(this._shortName); | |
| if ( this.onElement ) return $(this.onElement).controller(this._shortName); | |
| if ( this.hasActiveElement ) return $(this.hasActiveElement).controller(this._shortName); | |
| throw "BaseController. controller, " + this._shortName + ", is improperly embedded on page"; | |
| }, | |
| singletonCallback: function( a, b ) { | |
| a = "get" + _.ucwords(a); | |
| var c = arguments; | |
| return function() { | |
| var g = GS[a](), | |
| h = jQuery.makeArray(c).slice(2); | |
| h.push.apply(h, arguments); | |
| if ( g.onUpdateSubcription && !g.loaded ) { | |
| var k = | |
| $.subscribe(g.onUpdateSubcription, g.callback(function() { | |
| g.loaded = true; | |
| g[b].apply(g, h); | |
| $.unsubscribe(k) | |
| })); | |
| return null | |
| } | |
| return g[b].apply(g, h) | |
| } | |
| }, | |
| viewBundles: {}, | |
| bundleVersions: {} | |
| }, { | |
| init: function() { | |
| this.subscribe("gs.app.ready", this.callback(this.appReady)) | |
| }, | |
| appReady: function() {}, | |
| destroy: function() { | |
| if ( $.isArray(this.subscriptions) ) for (; this.subscriptions.length; ) $.unsubscribe(this.subscriptions.pop()); | |
| this._super() | |
| }, | |
| subscribe: function( a, b, c ) { | |
| c = _.orEqual(c, true); | |
| if (!_.defined(this.subscriptions) ) this.subscriptions = []; | |
| if ( c ) { | |
| a = $.subscribe(a, b); | |
| this.subscriptions.push(a); | |
| return a | |
| } else return $.subscribe(a, b) | |
| }, | |
| view: function( a, b, c, g ) { | |
| var h = ["gs", "views"]; | |
| if ( a.match(/^themes/) ) h = [a]; | |
| else if ( a.match(/^\//) ) h.push(a.replace(/^\//, "")); | |
| else { | |
| h.push(this.Class._shortName); | |
| h.push(a) | |
| } | |
| h = "/" + h.join("/"); | |
| h += $.View.ext; | |
| var k = h.replace(/[\/\.]/g, "_").replace(/_+/g, "_").replace(/^_/, ""), | |
| m = GS.Controllers.BaseController.viewBundles[k], | |
| p = GS.Controllers.BaseController.bundleVersions[m] || "", | |
| n = "", | |
| o = true; | |
| b = _.orEqual(b, this); | |
| c = this.calculateHelpers.call(this, c); | |
| if ( $.View.preCached[k] || !m ) return $.View(h, b, c); | |
| g = _.orEqual(g, 0); | |
| if (!(g >= 3)) { | |
| if ( g > 0 ) o = false; | |
| k = { | |
| contentType: "application/json", | |
| dataType: "json", | |
| type: "GET", | |
| url: "/gs/views/" + m + ".json?" + p, | |
| async: false, | |
| cache: o, | |
| success: this.callback(function( t ) { | |
| if ( t ) { | |
| _.forEach(t, function( w, x ) { | |
| $.View.preCached[x] = w | |
| }); | |
| n = $.View(h, b, c) | |
| } else { | |
| g++; | |
| setTimeout(this.callback(function() { | |
| this.view(a, b, c, g) | |
| }), g * 100) | |
| } | |
| }), | |
| error: this.callback(function() { | |
| g++; | |
| setTimeout(this.callback(function() { | |
| this.view(a, b, c, g) | |
| }), g * 100) | |
| }) | |
| }; | |
| if ( window.gsConfig && window.gsConfig.viewsJSONP ) { | |
| k.url = gsConfig.assetHost + "/gs/views/" + m + ".json?" + p; | |
| k.dataType = "jsonp"; | |
| k.jsonp = false; | |
| k.jsonpCallback = window.gsConfig.viewsJSONP + m | |
| } | |
| $.ajax(k); | |
| return n | |
| } | |
| } | |
| }); | |
| GS.Controllers.BaseController.extend("GS.Controllers.AirbridgeController", { | |
| onDocument: true | |
| }, { | |
| isDesktop: false, | |
| _bridge: null, | |
| oldWindowOpen: null, | |
| init: function() { | |
| if ( window.parentSandboxBridge ) { | |
| this.isDesktop = true; | |
| this._bridge = window.parentSandboxBridge; | |
| window.childSandboxBridge = this; | |
| window.console.error = this._bridge.consoleError; | |
| GS.store.set = this._bridge.storeSet; | |
| GS.store.get = this._bridge.storeGet; | |
| GS.store.remove = this._bridge.storeRemove; | |
| GS.store.clear = this._bridge.storeClear; | |
| gsConfig.assetHost = "http://" + window.location.host; | |
| this.subscribe("gs.player.playstatus", this.callback(this._onPlayStatus)); | |
| this.subscribe("gs.player.song.change", this.callback(this._onSongChange)); | |
| this.subscribe("gs.player.queue.change", this.callback(this._onQueueChange)); | |
| this.subscribe("gs.auth.favorites.songs.add", this.callback(this._onFavLibChanged)); | |
| this.subscribe("gs.auth.favorites.songs.remove", this.callback(this._onFavLibChanged)); | |
| this.subscribe("gs.auth.library.add", this.callback(this._onFavLibChanged)); | |
| this.subscribe("gs.auth.library.remove", this.callback(this._onFavLibChanged)); | |
| var a = this; | |
| $("body").delegate('a[target="_blank"]', "click", function( b ) { | |
| if (!$(b.target).closest("a").hasClass("airNoFollow") ) { | |
| b.preventDefault(); | |
| b = $(b.target).closest("a").attr("href"); | |
| a._bridge.consoleWarn(b); | |
| b && a._bridge.navigateToUrl(b, "_blank"); | |
| return false | |
| } | |
| }); | |
| this.oldWindowOpen = window.open; | |
| window.open = function( b, c, g ) { | |
| g = _.orEqual(g, "width=800,height=600"); | |
| return c == "_blank" ? a._bridge.navigateToUrl(b, c) : a.oldWindowOpen.call(window, b, c, g) | |
| } | |
| } | |
| this._super() | |
| }, | |
| _lastStatus: null, | |
| _onPlayStatus: function( a ) { | |
| if ( a && this._lastStatus ) if ( a.status === this._lastStatus.status ) if (!a.activeSong && !this._lastStatus.activeSong ) { | |
| this._lastStatus = a; | |
| return | |
| } else if ( a.activeSong && this._lastStatus.activeSong ) if ( a.activeSong.SongID == this._lastStatus.activeSong.SongID && a.activeSong.autoplayVote == this._lastStatus.activeSong.autoplayVote ) { | |
| this._lastStatus = a; | |
| return | |
| } | |
| this._lastStatus = a; | |
| this._bridge && this._bridge.playerChange() | |
| }, | |
| _onQueueChange: function() { | |
| this._bridge && this._bridge.playerChange() | |
| }, | |
| _onSongChange: function( a ) { | |
| if (!this._lastStatus || this._lastStatus.activeSong && this._lastStatus.activeSong.SongID === a.SongID && this._lastStatus.activeSong.autoplayVote !== a.autoplayVote ) { | |
| if ( this._lastStatus ) this._lastStatus.activeSong.autoplayVote = a.autoplayVote; | |
| this._bridge && this._bridge.playerChange() | |
| } | |
| }, | |
| _onFavLibChanged: function( a ) { | |
| if ( a && GS.player.queue && GS.player.queue.activeSong && parseInt(a.SongID, 10) == parseInt(GS.player.queue.activeSong.SongID, 10) ) { | |
| GS.player.queue.activeSong.isFavorite = a.isFavorite; | |
| GS.player.queue.activeSong.fromLibrary = a.fromLibrary; | |
| this._bridge && this._bridge.playerChange() | |
| } | |
| }, | |
| appReady: function() { | |
| this._bridge && this._bridge.ready() | |
| }, | |
| getDesktopPreferences: function() { | |
| return this._bridge ? this._bridge.getDesktopPreferences() : null | |
| }, | |
| setDesktopPreferences: function( a ) { | |
| this._bridge && this._bridge.setDesktopPreferences(a) | |
| }, | |
| displayNotification: function( a, b ) { | |
| $.publish("gs.notification", { | |
| type: a, | |
| message: $.localize.getString(b) | |
| }) | |
| }, | |
| getQueueStatus: function() { | |
| var a = GS.player.getCurrentQueue(true); | |
| a || (a = {}); | |
| if ( a.activeSong ) { | |
| a.activeSong.url = "http://grooveshark.com/" + a.activeSong.toUrl().replace("#/", ""); | |
| a.activeSong.imageUrl = a.activeSong.getImageURL() | |
| } | |
| a.playStatus = GS.player.lastStatus; | |
| return a | |
| }, | |
| setHash: function( a ) { | |
| window.location.hash = a | |
| }, | |
| safeToClose: function() { | |
| return window.onbeforeunload() | |
| }, | |
| addSongsToQueueAt: function() { | |
| return GS.player.addSongsToQueueAt.apply(GS.player, arguments) | |
| }, | |
| playSong: function() { | |
| return GS.player.playSong.apply(GS.player, arguments) | |
| }, | |
| pauseSong: function() { | |
| return GS.player.pauseSong.apply(GS.player, arguments) | |
| }, | |
| resumeSong: function() { | |
| return GS.player.resumeSong.apply(GS.player, arguments) | |
| }, | |
| stopSong: function() { | |
| return GS.player.stopSong.apply(GS.player, arguments) | |
| }, | |
| previousSong: function() { | |
| return GS.player.previousSong.apply(GS.player, arguments) | |
| }, | |
| nextSong: function() { | |
| return GS.player.nextSong.apply(GS.player, arguments) | |
| }, | |
| flagSong: function() { | |
| return GS.player.flagSong.apply(GS.player, arguments) | |
| }, | |
| voteSong: function() { | |
| return GS.player.voteSong.apply(GS.player, arguments) | |
| }, | |
| getIsMuted: function() { | |
| return GS.player.getIsMuted.apply(GS.player, arguments) | |
| }, | |
| setIsMuted: function() { | |
| return GS.player.setIsMuted.apply(GS.player, arguments) | |
| }, | |
| getVolume: function() { | |
| return GS.player.getVolume.apply(GS.player, arguments) | |
| }, | |
| setVolume: function() { | |
| return GS.player.setVolume.apply(GS.player, arguments) | |
| }, | |
| getShuffle: function() { | |
| return GS.player.getShuffle.apply(GS.player, arguments) | |
| }, | |
| setShuffle: function() { | |
| return GS.player.setShuffle.apply(GS.player, arguments) | |
| }, | |
| setAutoplay: function() { | |
| return GS.player.setAutoplay.apply(GS.player, arguments) | |
| }, | |
| clearQueue: function() { | |
| return GS.player.clearQueue.apply(GS.player, arguments) | |
| }, | |
| getRepeat: function() { | |
| return GS.player.getRepeat.apply(GS.player, arguments) | |
| }, | |
| setRepeat: function() { | |
| return GS.player.setRepeat.apply(GS.player, arguments) | |
| }, | |
| addPlaylist: function( a, b, c ) { | |
| GS.Models.Playlist.getPlaylist(a, function( g ) { | |
| g.play(b, c) | |
| }, null, false) | |
| }, | |
| addSongFromToken: function( a, b, c ) { | |
| GS.Models.Song.getSongFromToken(a, function( g ) { | |
| GS.player.addSongsToQueueAt([g.SongID], b, c) | |
| }, null, false) | |
| }, | |
| favoriteSong: function( a ) { | |
| GS.user.addToSongFavorites(a) | |
| }, | |
| unfavoriteSong: function( a ) { | |
| GS.user.removeFromSongFavorites(a) | |
| }, | |
| addSongToLibrary: function( a ) { | |
| GS.user.addToLibrary([a]) | |
| }, | |
| removeSongFromLibrary: function( a ) { | |
| GS.user.removeFromLibrary(a) | |
| }, | |
| executeProtocol: function( a ) { | |
| GS.Controllers.ApiController.instance().executeProtocol(a) | |
| } | |
| }); | |
| (function() { | |
| function a() { | |
| this.requests = []; | |
| this.pendingRequest = null | |
| } | |
| function b(q) { | |
| var r = [].slice.call(arguments, 1), | |
| s = (new Date).valueOf(), | |
| u = new this; | |
| this.apply(u, r); | |
| r = 6E5; | |
| if ( q ) { | |
| if ( typeof q == "number" ) r = q; | |
| var C = u.getCacheKey(), | |
| F = u.pendingCallCache[C]; | |
| if ( _.defined(F) && (!F.isResolved() || s - F.lastResolution < r) ) u = F; | |
| else u.pendingCallCache[C] = u | |
| } | |
| return u | |
| } | |
| function c(q, r, s, u, C) { | |
| function F() { | |
| J.isPending = false; | |
| J.lastResolution = (new Date).valueOf() | |
| } | |
| this.method = _.orEqual(q, ""); | |
| this.parameters = _.orEqual(r, {}); | |
| this.options = | |
| _.orEqual(s, {}); | |
| this.useHTTPS = _.orEqual(u, false); | |
| this.useSWF = _.orEqual(C, false); | |
| this.overrideHeaders = {}; | |
| this.type = "normal"; | |
| this.isPending = this.failedAuth = false; | |
| this.numRetries = 0; | |
| this.lastFault = null; | |
| this.lastResolution = 0; | |
| this.successFilters = []; | |
| this.faultFilters = []; | |
| this._dfd = $.Deferred(); | |
| var J = this; | |
| this.promise().then(F, F) | |
| } | |
| function g(q, r, s) { | |
| c.call(this, q, r); | |
| this.httpMethod = _.orEqual(s, "POST"); | |
| this.type = "facebook" | |
| } | |
| function h(q) { | |
| c.call(this, null, q); | |
| this.type = "lastfm" | |
| } | |
| function k() { | |
| var q = String(Math.floor(Math.random() * 1E4)); | |
| return !GS.service.outgoingSWFCalls[q] ? q : k() | |
| } | |
| function m(q, r) { | |
| var s; | |
| if ( $.isFunction(GS.service.swfProxy) ) { | |
| s = k(); | |
| GS.service.outgoingSWFCalls[s] = q; | |
| GS.service.swfProxy(q.getSWFable(), r, s) | |
| } else { | |
| q.isPending = false; | |
| GS.service.callsPendingSWF.push(q) | |
| } | |
| } | |
| function p() { | |
| for ( var q = "", r = 0; r < 6; r++ ) | |
| q += Math.floor(Math.random() * 16).toString(16); | |
| return q != GS.service.lastRandomizer ? q : p() | |
| } | |
| function n(q) { | |
| q = _.orEqual(q, {}); | |
| var r = { | |
| client: GS.service.client, | |
| clientRevision: GS.service.clientRevision, | |
| privacy: GS.service.privacy, | |
| country: GS.service.country, | |
| uuid: GS.service.uuID | |
| }; | |
| if ( GS.service.sessionID ) r.session = GS.service.sessionID; | |
| return $.extend(r, q) | |
| } | |
| function o(q, r) { | |
| _.defined(q) || (q = { | |
| fault: { | |
| message: "Empty Result", | |
| code: GS.service.faultCodes.EMPTY_RESULT | |
| } | |
| }); | |
| if ( q.header ) { | |
| var s = q.header, | |
| u = s.session; | |
| if ( u && u != GS.service.sessionID ) { | |
| GS.service.sessionID = u; | |
| GS.service.tokenPending = false; | |
| x() | |
| } | |
| if ( s.expiredClient ) { | |
| GS.service.clientExpired = true; | |
| GS.player && GS.player.expireSWFService(); | |
| t() | |
| } | |
| s = s.secondsUntilDowntime; | |
| if ( s < 0 ) _.wait(5E3).then(E); | |
| else if ( s > 0 ) { | |
| s = Math.floor(s / 60); | |
| u = (new Date).valueOf(); | |
| if ( s <= 60 ) if ( GS.service.lastDowntimeNotification == 0 || s > 30 && u - GS.service.lastDowntimeNotification > 36E5 || s <= 30 && s > 15 && u - GS.service.lastDowntimeNotification > 18E5 || s <= 15 && s > 10 && u - GS.service.lastDowntimeNotification > 9E5 || s <= 10 && s > 5 && u - GS.service.lastDowntimeNotification > 6E5 || s <= 5 && u - GS.service.lastDowntimeNotification > 3E5 ) { | |
| GS.service.lastDowntimeNotification = u; | |
| s = new GS.Models.DataString($.localize.getString("NOTIFICATION_MAINTENANCE_WARNING"), { | |
| min: s | |
| }); | |
| $.publish("gs.notification", { | |
| type: "info", | |
| message: s | |
| }) | |
| } | |
| } | |
| } | |
| q.fault ? w(q.fault, r) : r.resolve(_.orEqual(q.result, q)) | |
| } | |
| function t() { | |
| GS.getLightbox().open({ | |
| type: "invalidClient", | |
| notCloseable: true, | |
| view: { | |
| header: "POPUP_INVALID_CLIENT_TITLE", | |
| message: "POPUP_INVALID_CLIENT_MSG", | |
| buttonsRight: [{ | |
| label: "POPUP_INVALID_CLIENT_SUBMIT", | |
| className: "submit" | |
| }] | |
| }, | |
| callbacks: { | |
| ".submit": function( q ) { | |
| q.stopImmediatePropagation(); | |
| window.location.reload(true) | |
| } | |
| } | |
| }) | |
| } | |
| function w(q, r) { | |
| if ( q && _.defined(q.code) ) { | |
| console.log("HANDLE FAULT CODE", q.code, r.method); | |
| if ( q.code == GS.service.faultCodes.INVALID_TOKEN ) { | |
| var s = (new Date).valueOf(); | |
| if ((!GS.service.lastTokenFailed || s - GS.service.lastTokenFailed >= 3E5) && r.numRetries === 0 ) { | |
| GS.service.lastTokenFailed = false; | |
| r.isPending = false; | |
| r.numRetries++; | |
| GS.service.callsPendingToken.push(r); | |
| x(); | |
| return | |
| } else $.publish("gs.notification", { | |
| type: "error", | |
| message: $.localize.getString("SERVICE_ERROR_COMMUNICATING"), | |
| uniqueInstance: "errorCommunicating" | |
| }) | |
| } else if ( q.code == GS.service.faultCodes.HTTP_TIMEOUT || q.code == GS.service.faultCodes.EMPTY_RESULT ) { | |
| r.lastFault = | |
| q; | |
| r.retry(100 + r.numRetries * 100); | |
| return | |
| } else if ( q.code == GS.service.faultCodes.MAINTENANCE ) _.wait(5E3).then(E); | |
| else if ( q.code == GS.service.faultCodes.INVALID_CLIENT ) t(); | |
| else if ( q.code == GS.service.faultCodes.INVALID_SESSION ) GS.getLightbox().open({ | |
| type: "sessionBad", | |
| notCloseable: true, | |
| view: { | |
| header: "POPUP_SESSION_BAD_TITLE", | |
| message: "POPUP_SESSION_BAD_MSG", | |
| buttonsLeft: [{ | |
| label: "POPUP_REFRESH_GROOVESHARK", | |
| className: "submit" | |
| }] | |
| }, | |
| callbacks: { | |
| ".submit": function( u ) { | |
| u.stopImmediatePropagation(); | |
| window.location.reload(true) | |
| } | |
| } | |
| }); | |
| else if ( gsConfig.runMode == "dev" && q.code == GS.service.faultCodes.HTTP_ERROR && r.method == "getCommunicationToken" ) { | |
| window.location.hash && GS.store.set("httpsHash", window.location.hash); | |
| window.location = "https://" + window.location.host | |
| } | |
| } | |
| r.reject(q) | |
| } | |
| function x() { | |
| if (!GS.service.tokenPending ) { | |
| GS.service.currentToken = null; | |
| GS.service.tokenExpires = 0; | |
| GS.service.tokenPending = true; | |
| if ( GS.service.sessionID ) { | |
| var q = hex_md5(GS.service.sessionID); | |
| q = A(false, "getCommunicationToken", { | |
| secretKey: q | |
| }, {}, true); | |
| q.promise().then(v, function() { | |
| var r = new Date; | |
| GS.service.tokenPending = false; | |
| for ( GS.service.lastTokenFailed = r.valueOf(); GS.service.callsPendingToken.length; ) { | |
| r = GS.service.callsPendingToken.shift(); | |
| r.reject({ | |
| message: $.localize.getString("SERVICE_CREATE_TOKEN_FAIL"), | |
| code: GS.service.faultCodes.INVALID_TOKEN | |
| }) | |
| } | |
| }) | |
| } else q = A(false, "initiateSession"); | |
| q.send(); | |
| if ( gsConfig.runMode == "dev" && GS.store.get("httpsHash") ) { | |
| window.location.hash = GS.store.get("httpsHash"); | |
| GS.store.remove("httpsHash") | |
| } | |
| } | |
| } | |
| function v(q) { | |
| var r = new Date; | |
| GS.service.lastTokenFailed = | |
| false; | |
| GS.service.currentToken = q; | |
| GS.service.tokenPending = false; | |
| for ( GS.service.tokenExpires = 15E5 + r.valueOf(); GS.service.callsPendingToken.length; ) { | |
| q = GS.service.callsPendingToken.shift(); | |
| q.send() | |
| } | |
| $.publish("gs.cowbell.ready") | |
| } | |
| function B(q) { | |
| for ( this.country = q ? q : { | |
| CC1: 0, | |
| ID: 223, | |
| CC4: 1073741824, | |
| CC3: 0, | |
| CC2: 0 | |
| }; this.callsPendingCountry.length; ) { | |
| q = this.callsPendingCountry.shift(); | |
| q.parameters.country = this.country; | |
| q.send() | |
| } | |
| } | |
| function E() { | |
| if (!GS.service.downForMaintenance ) { | |
| GS.service.downForMaintenance = true; | |
| GS.getLightbox().open({ | |
| type: "maintenance", | |
| notCloseable: true, | |
| view: { | |
| header: "POPUP_MAINT_TITLE", | |
| message: "POPUP_MAINT_MESSAGE", | |
| buttonsLeft: [{ | |
| label: "POPUP_MAINT_TWITTER", | |
| href: "http://twitter.com/sharkjanitor" | |
| }] | |
| } | |
| }); | |
| H() | |
| } | |
| } | |
| function H() { | |
| var q = A(false, "getServiceStatus"); | |
| q.promise().then(G, D); | |
| q.send() | |
| } | |
| function G(q) { | |
| if ( q.status == 1 ) { | |
| GS.service.downForMaintenance = false; | |
| GS.getLightbox().close() | |
| } else _.wait(2E4).then(H) | |
| } | |
| function D() { | |
| _.wait(2E4).then(H) | |
| } | |
| a.prototype.queue = function( q ) { | |
| function r() { | |
| if ( this.requests.length ) { | |
| this.pendingRequest = this.requests.shift(); | |
| var s = this, | |
| u = function() { | |
| s.pendingRequest = null; | |
| r.call(s) | |
| }; | |
| this.pendingRequest.promise().then(u, u); | |
| this.pendingRequest.send() | |
| } | |
| } | |
| this.requests.push(q); | |
| this.pendingRequest || r.call(this) | |
| }; | |
| var y = function( q, r ) { | |
| return q[q.length - 1] === r ? {} : q[q.length - 1] | |
| }; | |
| c.createRequest = function() { | |
| return b.apply(this, arguments) | |
| }; | |
| var A = function() { | |
| return b.apply(c, arguments) | |
| }; | |
| c.prototype.promise = function() { | |
| return this._dfd.promise() | |
| }; | |
| c.prototype.isResolved = function() { | |
| return this._dfd.isResolved() | |
| }; | |
| c.prototype.isRejected = function() { | |
| return this._dfd.isRejected() | |
| }; | |
| c.prototype.resolve = function( q ) { | |
| for ( var r = 0; r < this.successFilters.length; r++ ) | |
| if ( $.isFunction(this.successFilters[r]) ) q = this.successFilters[r](q); | |
| this.lastResolution = (new Date).valueOf(); | |
| this._dfd.resolve(q) | |
| }; | |
| c.prototype.resolveWith = function( q, r ) { | |
| for ( var s = 0; s < this.successFilters.length; s++ ) | |
| if ( $.isFunction(this.successFilters[s]) ) r = this.successFilters[s](r); | |
| this.lastResolution = (new Date).valueOf(); | |
| this._dfd.resolveWith(q, r) | |
| }; | |
| c.prototype.reject = function( q ) { | |
| for ( var r = 0; r < this.faultFilters.length; r++ ) | |
| if ( $.isFunction(this.faultFilters[r]) ) q = this.faultFilters[r](q); | |
| this._dfd.reject(q) | |
| }; | |
| c.prototype.rejectWith = function( q, r ) { | |
| for ( var s = 0; s < this.faultFilters.length; s++ ) | |
| if ( $.isFunction(this.faultFilters[s]) ) r = this.faultFilters[s](r); | |
| this._dfd.rejectWith(q, r) | |
| }; | |
| c.prototype.getSWFable = function() { | |
| return { | |
| type: this.type, | |
| method: this.method, | |
| parameters: this.parameters, | |
| useHTTPS: this.useHTTPS, | |
| overrideHeaders: this.overrideHeaders, | |
| overrideKey: GS.service ? GS.service.revToken : GS.Controllers.ServiceController.instance().revToken | |
| } | |
| }; | |
| c.prototype.pendingCallCache = []; | |
| c.prototype.cacheKeyProps = ["method", "parameters", "type"]; | |
| c.prototype.getCacheKey = function() { | |
| var q, r, s = ""; | |
| for ( q in this.cacheKeyProps ) | |
| if ( this.cacheKeyProps.hasOwnProperty(q) ) { | |
| r = this[this.cacheKeyProps[q]]; | |
| s += r instanceof String ? r : JSON.stringify(r) | |
| } | |
| return hex_md5(s) | |
| }; | |
| c.prototype.send = function( q ) { | |
| q && q.length == 2 && this.promise().then(q[0], q[1]); | |
| GS.service = GS.service || GS.Controllers.ServiceController.instance(); | |
| var r = this; | |
| q = true; | |
| var s = (new Date).valueOf(); | |
| if (!(this.isPending || this.isResolved())) if ( GS.service.clientExpired ) this.reject({ | |
| message: $.localize.getString("POPUP_INVALID_CLIENT_MSG"), | |
| code: GS.service.faultCodes.INVALID_CLIENT | |
| }); | |
| else { | |
| this.isPending = true; | |
| if ( this.numRetries >= 3 ) this.reject(this.lastFault); | |
| else { | |
| if ( this.numRetries > 0 ) q = false; | |
| if ( this.type == "facebook" || this.type == "lastfm" ) m(this, {}); | |
| else if ( GS.service.tokenExpires > s || ["getCommunicationToken", "initiateSession", "getServiceStatus"].indexOf(this.method) != -1 ) if ( GS.service.downForMaintenance && this.method != "getServiceStatus" ) this.reject({ | |
| message: $.localize.getString("SERVICE_DOWN_MAINTENANCE"), | |
| code: GS.service.faultCodes.MAINTENANCE | |
| }); | |
| else { | |
| s = "http://" + GS.service.hostname + "/" + GS.service.defaultEndpoint + "?" + this.method; | |
| var u = { | |
| header: n(this.overrideHeaders), | |
| method: this.method, | |
| parameters: this.parameters | |
| }; | |
| if ( GS.service.currentToken ) { | |
| GS.service.lastRandomizer = p(); | |
| var C = hex_sha1(this.method + ":" + GS.service.currentToken + ":" + GS.service.revToken + ":" + GS.service.lastRandomizer); | |
| u.header.token = GS.service.lastRandomizer + C | |
| } | |
| this.useSWF || this.useHTTPS ? m(this, u.header) : $.ajax($.extend({}, this.options, { | |
| contentType: "application/json", | |
| dataType: "json", | |
| type: "POST", | |
| data: JSON.stringify(u), | |
| cache: q, | |
| url: s, | |
| success: function( F ) { | |
| o(F, r) | |
| }, | |
| error: function( F, J, K ) { | |
| console.warn("ajax error: status: " + J + ", error: " + K, F, this); | |
| F = {}; | |
| switch ( J ) { | |
| case "parsererror": | |
| F.code = GS.service.faultCodes.PARSE_ERROR; | |
| F.message = $.localize.getString("SERVICE_PARSE_JSON"); | |
| break; | |
| case "timeout": | |
| F.code = GS.service.faultCodes.HTTP_TIMEOUT; | |
| F.message = $.localize.getString("SERVICE_REQUEST_TIMEOUT"); | |
| break; | |
| case "error": | |
| case "notmodified": | |
| default: | |
| F.code = GS.service.faultCodes.HTTP_ERROR; | |
| F.message = | |
| $.localize.getString("SERVICE_HTTP_ERROR"); | |
| break | |
| } | |
| w(F, r) | |
| } | |
| })) | |
| } | |
| else { | |
| this.isPending = false; | |
| GS.service.callsPendingToken.push(this); | |
| x() | |
| } | |
| } | |
| } | |
| }; | |
| c.prototype.retry = function( q ) { | |
| var r = this; | |
| this.isPending = false; | |
| this.numRetries++; | |
| _.wait(q).then(function() { | |
| r.send() | |
| }) | |
| }; | |
| c.prototype.queue = function( q ) { | |
| if (!_.defined(c.prototype.queues) ) c.prototype.queues = {}; | |
| var r = c.prototype.queues[q]; | |
| _.defined(r) || (r = c.prototype.queues[q] = new a); | |
| r.queue(this) | |
| }; | |
| g.createRequest = function() { | |
| return b.apply(this, arguments) | |
| }; | |
| g.prototype = $.extend(g.prototype, c.prototype); | |
| g.prototype.getSWFable = function() { | |
| return { | |
| type: this.type, | |
| method: this.method, | |
| parameters: this.parameters, | |
| httpMethod: this.httpMethod | |
| } | |
| }; | |
| h.createRequest = function() { | |
| return b.apply(this, arguments) | |
| }; | |
| h.prototype = $.extend(h.prototype, c.prototype); | |
| h.prototype.getSWFable = function() { | |
| return { | |
| type: this.type, | |
| parameters: this.parameters | |
| } | |
| }; | |
| var I; | |
| $.Class.extend("GS.Controllers.ServiceController", { | |
| configDefaults: { | |
| hostname: window.location.host, | |
| sessionID: null, | |
| client: "htmlshark", | |
| clientRevision: "20111117", | |
| revToken: "bewareOfTheGingerApocalypse", | |
| country: null, | |
| privacy: 0, | |
| uuID: "", | |
| defaultEndpoint: "more.php" | |
| }, | |
| instance: function() { | |
| I || (I = new GS.Controllers.ServiceController({ | |
| hostname: window.location.host, | |
| sessionID: gsConfig.sessionID, | |
| country: gsConfig.country, | |
| privacy: gsConfig.user.Privacy, | |
| uuID: gsConfig.uuid, | |
| defaultEndpoint: gsConfig.endpoint | |
| })); | |
| return I | |
| } | |
| }, { | |
| faultCodes: { | |
| INVALID_CLIENT: 1024, | |
| RATE_LIMITED: 512, | |
| INVALID_TOKEN: 256, | |
| INVALID_SESSION: 16, | |
| MAINTENANCE: 10, | |
| MUST_BE_LOGGED_IN: 8, | |
| HTTP_TIMEOUT: 6, | |
| PARSE_ERROR: 4, | |
| HTTP_ERROR: 2, | |
| EMPTY_RESULT: -256 | |
| }, | |
| init: function( q ) { | |
| $.extend(this, GS.Controllers.ServiceController.configDefaults, q); | |
| this.currentToken = null; | |
| this.tokenExpires = 0; | |
| this.lastTokenFailed = this.tokenPending = false; | |
| this.lastRandomizer = null; | |
| this.downForMaintenance = false; | |
| this.lastDowntimeNotification = 0; | |
| this.clientExpired = false; | |
| this.callsPendingToken = []; | |
| this.callsPendingCountry = []; | |
| this.callsPendingSWF = []; | |
| this.outgoingSWFCalls = {}; | |
| this.swfProxy = null; | |
| this.sessionID || A(false, "initiateSession", {}, { | |
| async: false | |
| }).send(); | |
| var r = c.createRequest(false, "getCountry"); | |
| r.faultFilters.push(function() { | |
| return false | |
| }); | |
| r.promise().then(this.callback(B), this.callback(B)); | |
| this.country ? r.resolve(this.country) : _.wait(1).then(function() { | |
| r.send() | |
| }) | |
| }, | |
| serviceExists: function() { | |
| return true | |
| }, | |
| swfReady: function() { | |
| for ( var q; this.callsPendingSWF.length; ) { | |
| q = this.callsPendingSWF.shift(); | |
| q.send() | |
| } | |
| return true | |
| }, | |
| swfBadHost: function() { | |
| GS.getLightbox().open({ | |
| type: "badHost", | |
| notCloseable: true, | |
| view: { | |
| header: "POPUP_BAD_HOST_TITLE", | |
| message: "POPUP_BAD_HOST_MSG", | |
| buttonsLeft: [{ | |
| href: "http://www.grooveshark.com", | |
| labelHTML: "http://www.grooveshark.com" | |
| }] | |
| } | |
| }) | |
| }, | |
| swfSuccess: function( q, r ) { | |
| var s = this.outgoingSWFCalls[r]; | |
| s && o(q, s); | |
| delete this.outgoingSWFCalls[r] | |
| }, | |
| swfFault: function( q, r ) { | |
| var s = this.outgoingSWFCalls[r]; | |
| s && w(q, s); | |
| delete this.outgoingSWFCalls[r] | |
| }, | |
| swfNeedsToken: function() { | |
| x() | |
| }, | |
| onChatData: function( q ) { | |
| if ( q = q.data.data || q.data || q ) switch ( q.messageType ) { | |
| case "userPointsAwarded": | |
| q.awardedPoints && GS.user && GS.user.addPoints(q.awardedPoints); | |
| break; | |
| case "apiMethodCall": | |
| if ( q.method && window.Grooveshark ) { | |
| if (!$.isArray(q.parameters) ) q.parameters = []; | |
| var r = Grooveshark[q.method]; | |
| $.isFunction(r) && r.apply(Grooveshark, q.parameters) | |
| } | |
| break; | |
| default: | |
| console.log("unhandled chat data:", q) | |
| } | |
| }, | |
| onChatError: function( q ) { | |
| console.log("Got chat error, event:", q) | |
| }, | |
| httpsFormSubmit: function( q, r, s ) { | |
| var u = $("#httpsForm"); | |
| $("#httpsIframe"); | |
| var C = []; | |
| u.html(""); | |
| u.attr("action", q); | |
| u.attr("method", "post"); | |
| u.attr("target", "httpsIframe"); | |
| u.attr("enctype", "multipart/form-data"); | |
| _.forEach(r, function( F, J ) { | |
| C.push('<input type="hidden" name="' + J + '" value="' + F + '" />') | |
| }); | |
| u.append(C.join("")); | |
| window.setupBridge = | |
| GS.airbridge && GS.airbridge.isDesktop ? | |
| function() { | |
| var F = {}; | |
| F[s] = window[s]; | |
| document.getElementById("httpsIframe").contentWindow.parentSandboxBridge = F | |
| } : function() {}; | |
| u.submit() | |
| }, | |
| isFirstVisit: function( q ) { | |
| A(false, "isFirstVisit", {}, {}, false, true).send([q, null]) | |
| }, | |
| makeFacebookRequest: function( q, r, s, u, C ) { | |
| g.createRequest(false, q, r, s).send([u, C]) | |
| }, | |
| makeLastfmRequest: function( q, r, s ) { | |
| q = h.createRequest(false, q); | |
| q.promise().then(r, s); | |
| q.send() | |
| }, | |
| rapleafPersonalize: function( q, r, s ) { | |
| var u = y(arguments, s); | |
| u = A(false, "personalize", { | |
| redirectURL: q | |
| }, u, false, true); | |
| u.type = "rapleaf"; | |
| u.send([r, s]) | |
| }, | |
| rapleafDirect: function( q, r, s ) { | |
| var u = y(arguments, s); | |
| u = A(false, "direct", { | |
| email: q | |
| }, u, false, true); | |
| u.type = "rapleaf"; | |
| u.send([r, s]) | |
| }, | |
| getAlbumByID: function( q, r, s ) { | |
| var u = y(arguments, s); | |
| A(true, "getAlbumByID", { | |
| albumID: q | |
| }, u).send([r, s]) | |
| }, | |
| getArtistByID: function( q, r, s ) { | |
| var u = y(arguments, s); | |
| A(true, "getArtistByID", { | |
| artistID: q | |
| }, u).send([r, s]) | |
| }, | |
| getPlaylistByID: function( q, r, s ) { | |
| var u = y(arguments, s); | |
| A(true, "getPlaylistByID", { | |
| playlistID: q | |
| }, u).send([r, s]) | |
| }, | |
| getQueueSongListFromSongIDs: function( q, r, s ) { | |
| var u = y(arguments, s); | |
| A(true, "getQueueSongListFromSongIDs", { | |
| songIDs: q | |
| }, u).send([r, s]) | |
| }, | |
| getSongFromToken: function( q, r, s ) { | |
| var u = y(arguments, s); | |
| u = A(true, "getSongFromToken", { | |
| token: q, | |
| country: this.country | |
| }, u); | |
| u.promise().then(r, s); | |
| this.country ? u.send() : this.callsPendingCountry.push(u) | |
| }, | |
| getTokenForSong: function( q, r, s ) { | |
| var u = y(arguments, s); | |
| u = A(true, "getTokenForSong", { | |
| songID: q, | |
| country: this.country | |
| }, u); | |
| u.promise().then(r, s); | |
| this.country ? u.send() : this.callsPendingCountry.push(u) | |
| }, | |
| getUserByID: function( q, r, s ) { | |
| var u = y(arguments, s); | |
| A(true, "getUserByID", { | |
| userID: q | |
| }, u).send([r, s]) | |
| }, | |
| albumGetSongs: function( q, r, s, u, C ) { | |
| r = _.orEqual(r, true); | |
| s = _.orEqual(s, 0); | |
| var F = y(arguments, C); | |
| A(true, "albumGetSongs", { | |
| albumID: q, | |
| isVerified: r, | |
| offset: s | |
| }, F).send([u, C]) | |
| }, | |
| artistGetAllSongs: function( q, r, s ) { | |
| var u = y(arguments, s); | |
| A(true, "artistGetAllSongs", { | |
| artistID: q | |
| }, u).send([r, s]) | |
| }, | |
| artistGetArtAttribution: function( q, r, s ) { | |
| var u = y(arguments, s); | |
| A(true, "artistGetArtAttribution", { | |
| artistID: q | |
| }, u).send([r, s]) | |
| }, | |
| playlistGetSongs: function( q, r, s ) { | |
| var u = y(arguments, s); | |
| A(true, "playlistGetSongs", { | |
| playlistID: q | |
| }, u).send([r, s]) | |
| }, | |
| getArtistRecentListeners: function( q, r, s ) { | |
| req = c.createRequest(true, "getArtistRecentListeners", { | |
| artistID: q | |
| }, arguments[arguments.length - 1] === s ? {} : arguments[arguments.length - 1]); | |
| req.promise().then(r, s); | |
| req.send() | |
| }, | |
| getAlbumRecentListeners: function( q, r, s ) { | |
| req = c.createRequest(true, "getAlbumRecentListeners", { | |
| albumID: q | |
| }, arguments[arguments.length - 1] === s ? {} : arguments[arguments.length - 1]); | |
| req.promise().then(r, s); | |
| req.send() | |
| }, | |
| getSongRecentListeners: function( q, r, s ) { | |
| req = c.createRequest(true, "getSongRecentListeners", { | |
| songID: q | |
| }, arguments[arguments.length - 1] === s ? {} : arguments[arguments.length - 1]); | |
| req.promise().then(r, s); | |
| req.send() | |
| }, | |
| popularGetSongs: function( q, r, s ) { | |
| var u = y(arguments, s); | |
| ({ | |
| daily: true, | |
| weekly: true, | |
| monthly: true | |
| })[q] || (q = "daily"); | |
| A(true, "popularGetSongs", { | |
| type: q | |
| }, u).send([r, s]) | |
| }, | |
| featuredGetCurrentFeatured: function( q, r, s ) { | |
| var u = y(arguments, s); | |
| A(true, "featuredGetCurrentFeatured", { | |
| date: q | |
| }, u).send([r, s]) | |
| }, | |
| getArtistsForTagRadio: function( q, r, s ) { | |
| var u = y(arguments, s); | |
| u = A(true, "getArtistsForTagRadio", { | |
| tagID: q | |
| }, u); | |
| u.promise().then(r, s); | |
| u.send() | |
| }, | |
| albumGetFans: function( q, r, s, u ) { | |
| var C = y(arguments, u); | |
| A(true, "albumGetFans", { | |
| albumID: q, | |
| offset: r | |
| }, C).send([s, u]) | |
| }, | |
| artistGetFans: function( q, r, s, u ) { | |
| var C = y(arguments, u); | |
| A(true, "artistGetFans", { | |
| artistID: q, | |
| offset: r | |
| }, C).send([s, u]) | |
| }, | |
| playlistGetFans: function( q, r, s ) { | |
| var u = y(arguments, s); | |
| A(true, "playlistGetFans", { | |
| playlistID: q | |
| }, u).send([r, s]) | |
| }, | |
| songGetFans: function( q, r, s, u ) { | |
| var C = y(arguments, u); | |
| A(true, "songGetFans", { | |
| songID: q, | |
| offset: r | |
| }, C).send([s, u]) | |
| }, | |
| userGetFans: function( q, r, s, u ) { | |
| var C = y(arguments, u); | |
| A(true, "userGetFans", { | |
| userID: q, | |
| offset: r | |
| }, C).send([s, u]) | |
| }, | |
| authenticateUser: function( q, r, s, u, C ) { | |
| var F = y(arguments, C); | |
| A(false, "authenticateUser", { | |
| username: q, | |
| password: r, | |
| savePassword: s | |
| }, F, true, true).send([u, C]) | |
| }, | |
| authenticateFacebookUser: function( q, r, s, u, C, F, J ) { | |
| var K = y(arguments, J); | |
| A(false, "authenticateFacebookUser", { | |
| facebookUserID: q, | |
| sessionKey: r, | |
| accessToken1: s, | |
| accessToken3: u, | |
| accessTokenEx: C | |
| }, K, true, true).send([F, J]) | |
| }, | |
| authenticateGoogleUser: function( q, r ) { | |
| var s = y(arguments, r); | |
| A(false, "authenticateGoogleUser", {}, s, true, true).send([q, r]) | |
| }, | |
| reportUserChange: function( q, r, s, u ) { | |
| var C = y(arguments, u), | |
| F = { | |
| userID: q.UserID, | |
| email: q.Email, | |
| username: q.FName, | |
| userTrackingID: q.userTrackingID, | |
| picture: q.Picture, | |
| privacy: _.defined(r) ? r : q.Privacy | |
| }; | |
| A(false, "reportUserChange", F, C, false, true).send([s, u]) | |
| }, | |
| logoutUser: function( q, r ) { | |
| var s = y(arguments, r); | |
| A(false, "logoutUser", {}, s).send([q, r]) | |
| }, | |
| userForgotPassword: function( q, r, s ) { | |
| var u = y(arguments, s); | |
| A(false, "userForgotPassword", { | |
| usernameOrEmail: q | |
| }, u, true).send([r, s]) | |
| }, | |
| resetPassword: function( q, r, s, u, C ) { | |
| var F = y(arguments, C); | |
| A(false, "resetPassword", { | |
| usernameOrEmail: q, | |
| secretResetCode: r, | |
| newPassword: s | |
| }, F, true).send([u, C]) | |
| }, | |
| changePassword: function( q, r, s, u ) { | |
| var C = y(arguments, u); | |
| A(false, "changePassword", { | |
| oldPassword: q, | |
| newPassword: r | |
| }, C, true, true).send([s, u]) | |
| }, | |
| registerUser: function( q, r, s, u, C, F, J, K, L, M, O, N ) { | |
| var P = y(arguments, N); | |
| A(false, "registerUser", { | |
| username: q, | |
| password: r, | |
| firstName: s, | |
| lastName: u, | |
| emailAddress: C, | |
| sex: F, | |
| birthDate: J, | |
| flags: K, | |
| inviteID: L, | |
| savePassword: M | |
| }, P, true, true).send([O, N]) | |
| }, | |
| userDisableAccount: function( q, r, s, u, C, F ) { | |
| var J = y(arguments, F); | |
| A(false, "userDisableAccount", { | |
| password: q, | |
| reason: r, | |
| details: s, | |
| contact: u | |
| }, J, true, true).send([C, F]) | |
| }, | |
| getIsUsernameEmailAvailable: function( q, r, s, u ) { | |
| var C = y(arguments, u); | |
| A(false, "getIsUsernameEmailAvailable", { | |
| username: q, | |
| emailAddress: r | |
| }, C).send([s, u]) | |
| }, | |
| getUserByInviteID: function( q, r, s ) { | |
| var u = y(arguments, s); | |
| A(true, "getUserByInviteID", { | |
| inviteID: q | |
| }, u, true).send([r, s]) | |
| }, | |
| sendInvites: function( q, r, s ) { | |
| var u = y(arguments, s); | |
| A(false, "sendInvites", { | |
| emailAddresses: q | |
| }, u).send([r, s]) | |
| }, | |
| getUserSettings: function( q, r ) { | |
| var s = y(arguments, r); | |
| A(false, "getUserSettings", {}, s).send([q, r]) | |
| }, | |
| getUserTopArtists: function( q, r, s ) { | |
| var u = y(arguments, s); | |
| A(true, "getUserTopArtists", { | |
| userID: q | |
| }, u).send([r, s]) | |
| }, | |
| changeUserInfoEx: function( q, r, s, u ) { | |
| var C = y(arguments, u); | |
| A(false, "changeUserInfoEx", { | |
| shitToChange: q, | |
| password: r | |
| }, C, true).send([s, u]) | |
| }, | |
| changeNotificationSettings: function( q, r, s ) { | |
| var u = y(arguments, s); | |
| A(false, "changeNotificationSettings", { | |
| newValue: q | |
| }, u).send([r, s]) | |
| }, | |
| changePrivacySettings: function( q, r, s ) { | |
| var u = y(arguments, s); | |
| A(false, "changePrivacySettings", { | |
| newValue: q | |
| }, u).send([r, s]) | |
| }, | |
| changeFeedSettings: function( q, r, s ) { | |
| var u = y(arguments, s); | |
| A(false, "changeFeedSettings", { | |
| newValue: q | |
| }, u).send([r, s]) | |
| }, | |
| getSubscriptionDetails: function( q, r ) { | |
| var s = y(arguments, r); | |
| A(false, "getSubscriptionDetails", {}, s, true, true).send([q, r]) | |
| }, | |
| userGetSongsInLibrary: function( q, r, s, u, C ) { | |
| r = _.orEqual(r, 0); | |
| var F = y(arguments, C); | |
| A(s, "userGetSongsInLibrary", { | |
| userID: q, | |
| page: r | |
| }, F).send([u, C]) | |
| }, | |
| userGetLibraryTSModified: function( q, r, s ) { | |
| var u = y(arguments, s); | |
| A(false, "userGetLibraryTSModified", { | |
| userID: q | |
| }, u).send([r, s]) | |
| }, | |
| userAddSongsToLibrary: function( q, r, s ) { | |
| var u = y(arguments, s); | |
| u = A(false, "userAddSongsToLibrary", { | |
| songs: q | |
| }, u); | |
| u.promise().then(r, s); | |
| u.queue("library") | |
| }, | |
| userRemoveSongsFromLibrary: function( q, r, s, u, C, F ) { | |
| var J = y(arguments, F); | |
| J = A(false, "userRemoveSongsFromLibrary", { | |
| userID: q, | |
| songIDs: r, | |
| albumIDs: s, | |
| artistIDs: u | |
| }, J); | |
| J.promise().then(C, F); | |
| J.queue("library") | |
| }, | |
| getFavorites: function( q, r, s, u, C ) { | |
| r = r || "Songs"; | |
| var F = y(arguments, C); | |
| A(s, "getFavorites", { | |
| userID: q, | |
| ofWhat: r | |
| }, F).send([u, C]) | |
| }, | |
| favorite: function( q, r, s, u, C ) { | |
| var F = y(arguments, C); | |
| F = A(false, "favorite", { | |
| what: q, | |
| ID: r, | |
| details: s | |
| }, F); | |
| F.promise().then(u, C); | |
| F.queue("library") | |
| }, | |
| unfavorite: function( q, r, s, u ) { | |
| var C = y(arguments, u); | |
| C = A(false, "unfavorite", { | |
| what: q, | |
| ID: r | |
| }, C); | |
| C.promise().then(s, u); | |
| C.queue("library") | |
| }, | |
| getUserSidebar: function( q, r ) { | |
| var s = y(arguments, r); | |
| A(false, "getUserSidebar", {}, s).send([q, r]) | |
| }, | |
| addShortcutToUserSidebar: function( q, r, s, u, C ) { | |
| var F = y(arguments, C); | |
| F = A(false, "addShortcutToUserSidebar", { | |
| what: q, | |
| id: r, | |
| name: s | |
| }, F); | |
| F.promise().then(u, C); | |
| F.queue("library") | |
| }, | |
| removeShortcutFromUserSidebar: function( q, r, s, u ) { | |
| var C = y(arguments, u); | |
| C = A(false, "removeShortcutFromUserSidebar", { | |
| what: q, | |
| id: r | |
| }, C); | |
| C.promise().then(s, u); | |
| C.queue("library") | |
| }, | |
| userGetPlaylists: function( q, r, s, u ) { | |
| var C = y(arguments, u); | |
| A(r, "userGetPlaylists", { | |
| userID: q | |
| }, C).send([s, u]) | |
| }, | |
| createPlaylist: function( q, r, s, u, C ) { | |
| var F = y(arguments, C); | |
| A(false, "createPlaylist", { | |
| playlistName: q, | |
| songIDs: r, | |
| playlistAbout: s | |
| }, F).send([u, C]) | |
| }, | |
| deletePlaylist: function( q, r, s, u ) { | |
| var C = y(arguments, u); | |
| C = A(false, "deletePlaylist", { | |
| playlistID: q, | |
| name: r | |
| }, C); | |
| C.promise().then(s, u); | |
| C.queue("playlist") | |
| }, | |
| playlistUndelete: function( q, r, s ) { | |
| var u = y(arguments, s); | |
| u = A(false, "playlistUndelete", { | |
| playlistID: q | |
| }, u); | |
| u.promise().then(r, s); | |
| u.queue("playlist") | |
| }, | |
| overwritePlaylist: function( q, r, s, u, C ) { | |
| var F = y(arguments, C); | |
| F = A(false, "overwritePlaylist", { | |
| playlistID: q, | |
| playlistName: r, | |
| songIDs: s | |
| }, F); | |
| F.promise().then(u, C); | |
| F.queue("playlist") | |
| }, | |
| playlistAddSongToExisting: function( q, r, s, u ) { | |
| var C = y(arguments, u); | |
| C = A(false, "playlistAddSongToExisting", { | |
| playlistID: q, | |
| songID: r | |
| }, C); | |
| C.promise().then(s, u); | |
| C.queue("playlist") | |
| }, | |
| renamePlaylist: function( q, r, s, u ) { | |
| var C = y(arguments, u); | |
| C = A(false, "renamePlaylist", { | |
| playlistID: q, | |
| playlistName: r | |
| }, C); | |
| C.promise().then(s, u); | |
| C.queue("playlist") | |
| }, | |
| setPlaylistAbout: function( q, r, s, u ) { | |
| var C = y(arguments, u); | |
| C = A(false, "setPlaylistAbout", { | |
| playlistID: q, | |
| about: r | |
| }, C); | |
| C.promise().then(s, u); | |
| C.queue("playlist") | |
| }, | |
| getResultsFromSearch: function( q, r, s, u, C ) { | |
| var F = y(arguments, C); | |
| F = A(true, "getResultsFromSearch", { | |
| query: q, | |
| type: r, | |
| guts: GS.guts ? GS.getGuts().shouldLog : 0, | |
| ppOverride: s | |
| }, F); | |
| r === "Artists" && F.successFilters.push(function( J ) { | |
| if ( $.isArray(J.result) ) J.result = _.map(J.result, function( K ) { | |
| K.hasOwnProperty("AlbumID") && delete K.AlbumID; | |
| K.hasOwnProperty("AlbumName") && delete K.AlbumName; | |
| K.hasOwnProperty("SongName") && delete K.SongName; | |
| return K | |
| }); | |
| return J | |
| }); | |
| F.send([u, C]) | |
| }, | |
| getSearchSuggestion: function( q, r, s ) { | |
| var u = y(arguments, s); | |
| A(true, "getSearchSuggestion", { | |
| query: q | |
| }, u).send([r, s]) | |
| }, | |
| getAutocomplete: function( q, r, s, u ) { | |
| var C = y(arguments, u); | |
| A(true, "getAutocomplete", { | |
| query: q, | |
| type: r | |
| }, C).send([s, u]) | |
| }, | |
| getProfileFeed: function( q, r, s, u ) { | |
| var C = y(arguments, u); | |
| A(1E4, "getProfileFeed", { | |
| lastDocumentID: q, | |
| lastEventID: r | |
| }, C).send([s, u]) | |
| }, | |
| getUserProfileFeed: function( q, r, s, u, C ) { | |
| var F = y(arguments, C); | |
| A(1E4, "getUserProfileFeed", { | |
| userID: q, | |
| lastDocumentID: r, | |
| lastEventID: s | |
| }, F).send([u, C]) | |
| }, | |
| getCombinedFeed: function( q, r, s, u ) { | |
| var C = y(arguments, u); | |
| A(1E4, "getCombinedFeed", { | |
| excludeUsers: q, | |
| lastEventID: r | |
| }, C).send([s, u]) | |
| }, | |
| getUserCombinedFeed: function( q, r, s, u, C ) { | |
| var F = y(arguments, C); | |
| A(3E4, "getUserCombinedFeed", { | |
| userID: q, | |
| excludeUsers: r, | |
| lastEventID: s | |
| }, F).send([u, C]) | |
| }, | |
| getInterestingEvents: function( q, r, s ) { | |
| var u = y(arguments, s); | |
| A(3E4, "getInterestingEvents", { | |
| limit: q | |
| }, u).send([r, s]) | |
| }, | |
| getArtistProfileFeed: function( q, r, s, u, C ) { | |
| var F = y(arguments, C); | |
| A(false, "getArtistProfileFeed", { | |
| artistID: q, | |
| lastDocumentID: r, | |
| lastEventID: s | |
| }, F).send([u, C]) | |
| }, | |
| hideUserEvent: function( q, r, s ) { | |
| var u = y(arguments, s); | |
| A(true, "hideUserEvent", { | |
| eventID: q | |
| }, u).send([r, s]) | |
| }, | |
| changeFollowFlags: function( q, r, s ) { | |
| var u = y(arguments, s); | |
| A(false, "changeFollowFlags", { | |
| userIDsFlags: q | |
| }, u).send([r, s]) | |
| }, | |
| sendFeedBroadcast: function( q, r, s, u, C, F ) { | |
| var J = y(arguments, F); | |
| A(false, "sendFeedBroadcast", { | |
| what: q, | |
| ID: r, | |
| people: s, | |
| message: u | |
| }, J).send([C, F]) | |
| }, | |
| addEventComment: function( q, r, s, u ) { | |
| var C = y(arguments, u); | |
| A(false, "addEventComment", { | |
| eventID: q, | |
| comment: r | |
| }, C).send([s, u]) | |
| }, | |
| hideEventComment: function( q, r, s, u ) { | |
| var C = y(arguments, u); | |
| A(false, "hideEventComment", { | |
| eventID: r, | |
| commentID: q | |
| }, C).send([s, u]) | |
| }, | |
| getUserNotifications: function( q, r ) { | |
| var s = y(arguments, r); | |
| A(6E4, "getUserNotifications", {}, s).send([q, r]) | |
| }, | |
| feedsBanArtist: function( q, r, s ) { | |
| var u = y(arguments, s); | |
| A(false, "feedsBanArtist", { | |
| artistID: q | |
| }, u).send([r, s]) | |
| }, | |
| feedsUnbanArtist: function( q, r, s ) { | |
| var u = y(arguments, s); | |
| A(false, "feedsUnbanArtist", { | |
| artistID: q | |
| }, u).send([r, s]) | |
| }, | |
| feedsGetBannedArtists: function( q, r ) { | |
| var s = y(arguments, r); | |
| A(false, "feedsGetBannedArtists", {}, s).send([q, r]) | |
| }, | |
| feedsRemoveEventFromProfile: function( q, r, s, u ) { | |
| var C = y(arguments, u); | |
| A(false, "feedsRemoveEventFromProfile", { | |
| type: q, | |
| time: r | |
| }, C).send([s, u]) | |
| }, | |
| logTargetedThemeImpression: function( q, r, s ) { | |
| var u = y(arguments, s); | |
| A(false, "logTargetedThemeImpression", { | |
| themeID: q | |
| }, u).send([r, s]) | |
| }, | |
| logThemeOutboundLinkClick: function( q, r, s, u ) { | |
| var C = y(arguments, u); | |
| A(false, "logThemeOutboundLinkClick", { | |
| themeID: q, | |
| linkID: r | |
| }, C).send([s, u]) | |
| }, | |
| provideSongFeedbackMessage: function( q, r, s, u ) { | |
| var C = y(arguments, u); | |
| A(false, "provideSongFeedbackMessage", { | |
| songID: q, | |
| message: r | |
| }, C).send([s, u]) | |
| }, | |
| provideSongFeedbackVote: function( q, r, s, u, C ) { | |
| var F = y(arguments, C); | |
| A(false, "provideSongFeedbackVote", { | |
| songID: q, | |
| vote: r, | |
| artistID: s | |
| }, F).send([u, C]) | |
| }, | |
| sendShare: function( q, r, s, u, C, F, J, K ) { | |
| var L = y(arguments, K); | |
| L = A(false, "sendShare", { | |
| what: q, | |
| ID: r, | |
| people: s, | |
| country: this.country, | |
| override: u, | |
| message: C | |
| }, L); | |
| L.promise().then(J, K); | |
| if ( F ) L.overrideHeaders.privacy = 1; | |
| this.country ? L.send() : this.callsPendingCountry.push(L); | |
| GS.getGuts().logEvent("itemSharePerformed", { | |
| type: q, | |
| id: r | |
| }) | |
| }, | |
| getContactInfoForFollowers: function( q, r ) { | |
| var s = y(arguments, r); | |
| A(false, "getContactInfoForFollowers", {}, s).send([q, r]) | |
| }, | |
| getSongkickEventsFromArtists: function( q, r, s, u ) { | |
| var C = y(arguments, u); | |
| A(true, "getSongkickEventsFromArtists", { | |
| artistIDs: q, | |
| names: r | |
| }, C).send([s, u]) | |
| }, | |
| getGoogleAuthToken: function( q, r, s, u ) { | |
| var C = "EscapeMG-Grooveshark-" + this.clientRevision, | |
| F = y(arguments, u); | |
| A(false, "getGoogleAuthToken", { | |
| Email: q, | |
| Passwd: r, | |
| source: C | |
| }, F, true).send([s, u]) | |
| }, | |
| getGoogleContacts: function( q, r, s ) { | |
| var u = y(arguments, s); | |
| req = A(false, "getGoogleContacts", { | |
| authToken: q | |
| }, u, false, true); | |
| req.send([r, s]) | |
| }, | |
| getDetailsForBroadcast: function( q, r, s ) { | |
| var u = y(arguments, s); | |
| A(true, "getDetailsForBroadcast", { | |
| songID: q | |
| }, u).send([r, s]) | |
| }, | |
| broadcastSong: function( q, r, s, u, C, F, J, K, L ) { | |
| var M = y(arguments, L); | |
| A(false, "broadcastSong", { | |
| songID: q, | |
| message: r, | |
| username: s, | |
| password: u, | |
| saveCredentials: C, | |
| service: F, | |
| song: J | |
| }, M, true).send([K, L]) | |
| }, | |
| getUserFacebookData: function( q, r ) { | |
| var s = y(arguments, r); | |
| A(false, "getUserFacebookDataEx", {}, s, true).send([q, r]) | |
| }, | |
| saveUserFacebookData: function( q, r, s, u, C, F, J, K ) { | |
| var L = y(arguments, K); | |
| A(false, "saveUserFacebookDataEx", { | |
| facebookUserID: q, | |
| sessionKey: r, | |
| accessToken1: s, | |
| accessToken3: u, | |
| flags: C, | |
| accessTokenEx: F | |
| }, L, true, true).send([J, K]) | |
| }, | |
| updateUserFacebookData: function( q, r, s, u, C, F, J, K ) { | |
| var L = y(arguments, K); | |
| A(false, "updateUserFacebookData", { | |
| facebookUserID: q, | |
| sessionKey: r, | |
| accessToken1: s, | |
| accessToken3: u, | |
| flags: C, | |
| accessTokenEx: F | |
| }, L, true, true).send([J, K]) | |
| }, | |
| removeUserFacebookData: function( q, r, s ) { | |
| var u = y(arguments, s); | |
| A(false, "removeUserFacebookData", { | |
| facebookUserID: q | |
| }, u).send([r, s]) | |
| }, | |
| getUserGoogleData: function( q, r ) { | |
| var s = y(arguments, r); | |
| A(false, "getUserGoogleData", {}, s, true, true).send([q, r]) | |
| }, | |
| saveUserGoogleData: function( q, r ) { | |
| var s = y(arguments, r); | |
| A(false, "saveUserGoogleData", {}, s).send([q, r]) | |
| }, | |
| updateUserGoogleData: function( q, r ) { | |
| req = c.createRequest(false, "updateUserGoogleData", {}, arguments[arguments.length - 1] === r ? {} : arguments[arguments.length - 1]); | |
| req.promise().then(q, r); | |
| req.send() | |
| }, | |
| updateUserGoogleData: function( q, r ) { | |
| var s = y(arguments, r); | |
| A(false, "updateUserGoogleData", {}, s).send([q, r]) | |
| }, | |
| removeUserGoogleData: function( q, r, s ) { | |
| var u = y(arguments, s); | |
| A(false, "removeUserGoogleData", { | |
| googleID: q | |
| }, u).send([r, s]) | |
| }, | |
| getUsernameSuggestions: function( q, r, s, u, C ) { | |
| var F = y(arguments, C); | |
| A(true, "getUsernameSuggestions", { | |
| baseUsername: q, | |
| fullName: r, | |
| idOrRand: s | |
| }, F).send([u, C]) | |
| }, | |
| registerFacebookUser: function( q, r, s, u, C, F, J, K, L, M, O, N, P, R, Q ) { | |
| var S = y(arguments, Q); | |
| A(false, "registerFacebookUser", { | |
| username: q, | |
| firstName: r, | |
| emailAddress: s, | |
| sex: u, | |
| birthDate: C, | |
| flags: F, | |
| inviteID: J, | |
| facebookUserID: K, | |
| sessionKey: L, | |
| accessToken1: M, | |
| accessToken3: O, | |
| accessTokenEx: N, | |
| facebookFlags: P | |
| }, S, true, true).send([R, Q]) | |
| }, | |
| getGroovesharkUsersFromFacebookUserIDs: function( q, r, s ) { | |
| var u = y(arguments, s); | |
| A(false, "getGroovesharkUsersFromFacebookUserIDs", { | |
| facebookUserIDs: q | |
| }, u).send([r, s]) | |
| }, | |
| registerGoogleUser: function( q, r, s, u, C, F, J, K, L ) { | |
| var M = y(arguments, L); | |
| A(false, "registerGoogleUser", { | |
| username: q, | |
| firstName: r, | |
| emailAddress: s, | |
| sex: u, | |
| birthDate: C, | |
| flags: F, | |
| inviteID: J | |
| }, M, true, true).send([K, L]) | |
| }, | |
| updateLastfmService: function( q, r, s, u, C, F, J ) { | |
| var K = y(arguments, J); | |
| A(false, "updateLastfmService", { | |
| session: q, | |
| token: r, | |
| username: s, | |
| flagsAdd: u, | |
| flagsRemove: C | |
| }, K).send([F, J]) | |
| }, | |
| saveLastfmService: function( q, r, s, u, C, F ) { | |
| var J = y(arguments, F); | |
| A(false, "saveLastfmService", { | |
| session: q, | |
| token: r, | |
| username: s, | |
| flags: u | |
| }, J).send([C, F]) | |
| }, | |
| getLastfmService: function( q, r ) { | |
| var s = y(arguments, r); | |
| A(false, "getLastfmService", {}, s).send([q, r]) | |
| }, | |
| removeLastfmService: function( q, r, s ) { | |
| var u = y(arguments, s); | |
| A(false, "removeLastfmService", { | |
| lastfmUsername: q | |
| }, u).send([r, s]) | |
| }, | |
| getAffiliateDownloadURLs: function( q, r, s, u ) { | |
| var C = y(arguments, u); | |
| A(false, "getAffiliateDownloadURLs", { | |
| songName: q, | |
| artistName: r | |
| }, C).send([s, u]) | |
| }, | |
| getServiceStatus: function( q, r ) { | |
| var s = y(arguments, r); | |
| A(false, "getServiceStatus", {}, s).send([q, r]) | |
| }, | |
| provideVIPFeedback: function( q, r, s, u ) { | |
| var C = y(arguments, u); | |
| A(false, "provideVIPFeedback", { | |
| fromAddress: q, | |
| message: r | |
| }, C).send([s, u]) | |
| }, | |
| artistGetSimilarArtists: function( q, r, s ) { | |
| var u = y(arguments, s); | |
| u = A(true, "artistGetSimilarArtists", { | |
| artistID: q | |
| }, u); | |
| u.promise().then(r, s); | |
| u.send() | |
| }, | |
| getThemeFromDFP: function( q, r, s ) { | |
| var u = y(arguments, s); | |
| u = A(false, "getThemeFromDFP", { | |
| paramString: q | |
| }, u, false, true); | |
| u.type = "dfp"; | |
| u.send([r, s]) | |
| }, | |
| getNotificationFromDFP: function( q, r, s ) { | |
| var u = y(arguments, s); | |
| u = A(false, "getNotificationFromDFP", { | |
| paramString: q | |
| }, u, false, true); | |
| u.type = "dfp"; | |
| u.send([r, s]) | |
| }, | |
| getItemByPageName: function( q, r, s ) { | |
| var u = y(arguments, s); | |
| A(true, "getItemByPageName", { | |
| name: q | |
| }, u).send([r, s]) | |
| }, | |
| getPageNameByIDType: function( q, r, s, u ) { | |
| var C = y(arguments, u); | |
| C = A(true, "getPageNameByIDType", { | |
| id: q, | |
| type: r | |
| }, C); | |
| C.promise().then(s, u); | |
| C.promise().then(function( F ) { | |
| F.name && window.GS && GS.router && GS.router.cachePageName(F.name, r, q) | |
| }); | |
| C.send() | |
| }, | |
| userGetPoints: function( q, r ) { | |
| var s = y(arguments, r); | |
| A(false, "userGetPoints", {}, s).send([q, r]) | |
| }, | |
| getClearvoiceMemberInfo: function( q, r, s ) { | |
| var u = y(arguments, s), | |
| C = {}; | |
| if ( q ) C.guid = q; | |
| A(false, "getClearvoiceMemberInfo", C, u, true).send([r, s]) | |
| }, | |
| getUserIDByClearvoiceEmail: function( q, r, s ) { | |
| var u = y(arguments, s); | |
| A(false, "getUserIDByClearvoiceEmail", { | |
| email: q | |
| }, u, true).send([r, s]) | |
| }, | |
| saveClearvoiceMemberInfo: function( q, r, s, u, C, F ) { | |
| var J = y(arguments, F); | |
| A(false, "saveClearvoiceMemberInfo", { | |
| guid: q, | |
| fName: r, | |
| lName: s, | |
| email: u | |
| }, J, true).send([C, F]) | |
| }, | |
| addClearvoiceAnswers: function( q, r, s ) { | |
| var u = y(arguments, s); | |
| A(false, "addClearvoiceAnswers", { | |
| questionsAndAnswers: q | |
| }, u, true).send([r, s]) | |
| }, | |
| getUserSurveys: function( q, r, s ) { | |
| var u = y(arguments, s); | |
| A(false, "getUserSurveys", { | |
| userID: q | |
| }, u).send([r, s]) | |
| }, | |
| getAvailableSurveys: function( q, r ) { | |
| var s = y(arguments, r); | |
| A(false, "getAvailableSurveys", {}, s).send([q, r]) | |
| }, | |
| saveUserAnswers: function( q, r, s, u, C, F ) { | |
| var J = y(arguments, F); | |
| A(false, "saveUserAnswers", { | |
| surveyID: q, | |
| userID: r, | |
| questionsAndAnswers: s, | |
| finalize: u | |
| }, J, true, true).send([C, F]) | |
| }, | |
| finalizeUserSurvey: function( q, r, s, u ) { | |
| var C = y(arguments, u); | |
| A(false, "finalizeUserSurvey", { | |
| surveyID: q, | |
| userID: r | |
| }, C, true, true).send([s, u]) | |
| }, | |
| submitPlaylistForCampaign: function( q, r, s, u ) { | |
| var C = y(arguments, u); | |
| (new c("submitPlaylistForCampaign", { | |
| playlistID: q, | |
| campaignID: r | |
| }, C, false)).send([s, u]) | |
| }, | |
| submitSongVoteForCampaign: function( q, r, s, u ) { | |
| var C = y(arguments, u); | |
| (new c("submitSongVoteForCampaign", { | |
| songID: q, | |
| campaignID: r | |
| }, C, false)).send([s, u]) | |
| }, | |
| getPlaylistsForCampaign: function( q, r, s ) { | |
| var u = y(arguments, s); | |
| (new c("getPlaylistsForCampaign", { | |
| campaignID: q | |
| }, u, false)).send([r, s]) | |
| }, | |
| giveFreePlusForPinningIE9: function( q, r ) { | |
| var s = y(arguments, r); | |
| (new c("giveFreePlusForPinningIE9", {}, s, false)).send([q, r]) | |
| }, | |
| getTunipopID: function( q, r, s, u ) { | |
| var C = y(arguments, u), | |
| F = {}; | |
| if ( r ) F.brand = q; | |
| else F.artist = q; | |
| C = A(true, "getTunipopID", F, C, null, true); | |
| C.type = "tunipop"; | |
| C.send([s, u]) | |
| }, | |
| getSubscriptionHistory: function( q, r ) { | |
| var s = y(arguments, r); | |
| A(true, "getSubscriptionHistory", {}, s, true, true).send([q, r]) | |
| } | |
| }) | |
| })(); | |
| GS.Controllers.BaseController.extend("GS.Controllers.AuthController", { | |
| onWindow: true | |
| }, { | |
| init: function() { | |
| GS.service = GS.service || GS.Controllers.ServiceController.instance(); | |
| if (!gsConfig.user.UserID ) gsConfig.user.UserID = -1; | |
| this._handleLoginChange(GS.Models.AuthUser.wrap(gsConfig.user)); | |
| this._super(); | |
| this.subscribe("gs.auth.update", this.callback(this._onAuthUpdate)) | |
| }, | |
| appReady: function() { | |
| if ( GS.user.UserID > 0 && GS.user.TSDOB !== "" && GS.user.UserID != 42 ) { | |
| var a = new Date, | |
| b = GS.user.TSDOB.split("-"), | |
| c = parseInt(b[1], 10) - 1; | |
| b = parseInt(b[2], 10); | |
| a.getMonth() == c && a.getDate() == b && GS.getNotice().displayPerAnum() | |
| } | |
| }, | |
| login: function( a, b, c, g, h ) { | |
| GS.service.authenticateUser(a, b, c, this.callback(this._loginSuccess, "normal", g, h), this.callback(this._loginFailed, "normal", h)) | |
| }, | |
| loginViaFacebook: function( a, b ) { | |
| GS.getFacebook().login(this.callback(this._loginSuccess, "facebook", a, b), this.callback(this._loginFailed, "facebook", b)) | |
| }, | |
| loginViaGoogle: function( a, b ) { | |
| GS.getGoogle().login(this.callback(this._loginSuccess, "google", a, b), this.callback(this._loginFailed, "google", b)) | |
| }, | |
| _loginSuccess: function( a, b, c, g ) { | |
| if ( g && g.userID === 0 || !g ) return this._loginFailed(a, c, g); | |
| g.authType = a; | |
| if ( window.GS && GS.Controllers.PageController.activePageName === "surveys" ) g.doNotReset = true; | |
| this._updateUser({}, { | |
| User: g | |
| }); | |
| if ( GS.airbridge && GS.airbridge.isDesktop && parseInt(g.isPremium, 10) !== 1 || gsConfig.isPreview && parseInt(g.isPremium, 10) !== 1 && parseInt(g.userID, 10) % 5 != 0 ) { | |
| if ( $.isFunction(c) ) { | |
| g.error = "POPUP_SIGNUP_LOGIN_FORM_PREMIUM_REQUIRED_ERROR"; | |
| c(g) | |
| } | |
| } else $.isFunction(b) && b(g); | |
| return g | |
| }, | |
| _loginFailed: function( a, b, c ) { | |
| c || (c = {}); | |
| c.authType = a; | |
| $.isFunction(b) && b(c); | |
| return c | |
| }, | |
| logout: function( a ) { | |
| GS.service.logoutUser(this.callback(this._logoutSuccess, a), this.callback(this._logoutFailed)) | |
| }, | |
| _logoutSuccess: function( a ) { | |
| GS.user.clearData(); | |
| GS.getGuts().logEvent("logout", {}); | |
| GS.getGuts().endContext("userID"); | |
| location.hash = "/"; | |
| this._handleLoginChange(GS.Models.AuthUser.wrap({ | |
| userTrackingID: GS.user.userTrackingID | |
| })); | |
| $.isFunction(a) && a() | |
| }, | |
| _logoutFailed: function() {}, | |
| signup: function( a, b, c, g, h, k, m, p, n, o ) { | |
| var t = this._getInviteCode(); | |
| GS.service.registerUser(a, b, c, "", g, h, k, m, t, p, this.callback(this._signupSuccess, "normal", t, g, n, o), this.callback(this._signupFailed, "normal", o)) | |
| }, | |
| signupViaFacebook: function( a, b, c, g, h, k, m, p, n ) { | |
| var o = this._getInviteCode(); | |
| m.accessToken1 ? GS.service.registerFacebookUser(a, b, c, g, h, k, o, m.facebookUserID, m.sessionKey, m.accessToken1, m.accessToken3, null, m.flags, this.callback(this._signupSuccess, "facebook", o, c, p, n), this.callback(this._signupFailed, "facebook", n)) : GS.service.registerFacebookUser(a, b, c, g, h, k, o, m.facebookUserID, "", "", "", m.accessTokenEx, m.flags, this.callback(this._signupSuccess, "facebook", o, c, p, n), this.callback(this._signupFailed, "facebook", n)) | |
| }, | |
| signupViaGoogle: function( a, b, c, g, h, k, m, p ) { | |
| var n = this._getInviteCode(); | |
| GS.service.registerGoogleUser(a, b, c, g, h, k, n, this.callback(this._signupSuccess, "google", n, c, m, p), this.callback(this._signupFailed, "google", p)) | |
| }, | |
| _signupSuccess: function( a, b, c, g, h, k ) { | |
| if ( k && k.userID === 0 || !k ) return this._signupFailed(a, h, k); | |
| k.authType = a; | |
| k.Email = c; | |
| if ( b ) { | |
| GS.store.set("lastInviteCode", null); | |
| gsConfig.inviteCode = null; | |
| GS.service.getUserByInviteID(b, this.callback(this._getInviterSuccess)) | |
| } | |
| k.doNotReset = true; | |
| GS.service.getUserByID(k.userID, this.callback(this._updateUser, k)); | |
| $.isFunction(g) && g(k); | |
| return k | |
| }, | |
| _signupFailed: function( a, b, c ) { | |
| c || (c = {}); | |
| c.authType = a; | |
| $.isFunction(b) && b(c); | |
| return c | |
| }, | |
| _getInviteCode: function() { | |
| var a = "", | |
| b = new Date, | |
| c = GS.store.get("lastInviteCode"); | |
| if ( c ) if ( c.expires && c.expires > b.valueOf() ) a = c.inviteCode; | |
| else GS.store.remove("lastInviteCode"); | |
| else if ( gsConfig.inviteCode ) a = gsConfig.inviteCode; | |
| return a | |
| }, | |
| _getInviterSuccess: function( a ) { | |
| var b = GS.Models.User.wrap(a); | |
| GS.getLightbox().open({ | |
| type: "followInviter", | |
| view: { | |
| header: "POPUP_FOLLOW_INVITER_TITLE", | |
| messageHTML: (new GS.Models.DataString($.localize.getString("POPUP_FOLLOW_INVITER_MESSAGE"), { | |
| user: b.Name | |
| })).render(), | |
| buttonsLeft: [{ | |
| label: "POPUP_FOLLOW_INVITER_CANCEL", | |
| className: "close" | |
| }], | |
| buttonsRight: [{ | |
| label: "POPUP_FOLLOW_INVITER_FOLLOW", | |
| className: "submit" | |
| }] | |
| }, | |
| callbacks: { | |
| ".submit": function() { | |
| GS.user.addToUserFavorites(b.UserID) | |
| } | |
| } | |
| }) | |
| }, | |
| _updateUser: function( a, b ) { | |
| b.User.UserID = a.userID; | |
| if (!a.doNotReset ) location.hash = "/"; | |
| var c = $.extend({}, a, b.User); | |
| this._handleLoginChange(GS.Models.AuthUser.wrapFromService(c), a); | |
| $("#notifications li.survey").remove() | |
| }, | |
| _handleLoginChange: function( a, b ) { | |
| var c = GS.user; | |
| GS.user = a; | |
| GS.service.reportUserChange(GS.user); | |
| if ( c && c.isDirty ) { | |
| var g = {}; | |
| _.forEach(c.playlists, function( k ) { | |
| var m = [], | |
| p = k.PlaylistID; | |
| _.forEach(k.songs, function( n ) { | |
| m.push(n.SongID) | |
| }); | |
| GS.user.createPlaylist(k.PlaylistName, m, k.Description, function() { | |
| g[p] = | |
| k.PlaylistID | |
| }, null, false) | |
| }); | |
| var h = _.map(c.library.songs, function( k ) { | |
| return k.SongID | |
| }); | |
| GS.user.addToLibrary(h, false); | |
| _.forEach(c.favorites.artists, function( k ) { | |
| GS.user.addToArtistFavorites(k.ArtistID, false) | |
| }); | |
| _.forEach(c.favorites.playlists, function( k ) { | |
| GS.user.addToPlaylistFavorites(k.PlaylistID, false) | |
| }); | |
| _.forEach(c.favorites.songs, function( k ) { | |
| GS.user.addToSongFavorites(k.SongID, false) | |
| }); | |
| _.forEach(c.favorites.users, function( k ) { | |
| GS.user.addToUserFavorites(k.UserID, false) | |
| }); | |
| _.forEach(c.sidebar.stations, function( k ) { | |
| c.defaultStations.indexOf(k) == -1 && GS.user.addToShortcuts("station", k, "", false) | |
| }); | |
| _.forEach(c.sidebar.playlists, function( k ) { | |
| if ( k < 0 ) k = g[k]; | |
| (k = GS.Models.Playlist.getOneFromCache(k)) && GS.user.addToShortcuts("playlist", k.PlaylistID, k.PlaylistName, false) | |
| }); | |
| _.forEach(c.sidebar.subscribedPlaylists, function( k ) { | |
| (k = GS.Models.Playlist.getOneFromCache(k)) && GS.user.addToShortcuts("playlist", k.PlaylistID, k.PlaylistName, false) | |
| }); | |
| _.forEach(c.sidebar.songs, function( k ) { | |
| (k = GS.Models.Song.getOneFromCache(k)) && GS.user.addToShortcuts("song", k.SongID, k.SongName, false) | |
| }); | |
| _.forEach(c.sidebar.artists, function( k ) { | |
| (k = GS.Models.Artist.getOneFromCache(k)) && GS.user.addToShortcuts("artist", k.ArtistID, k.ArtistName, false) | |
| }); | |
| _.forEach(c.sidebar.albums, function( k ) { | |
| (k = GS.Models.Album.getOneFromCache(k)) && GS.user.addToShortcuts("album", k.AlbumID, k.AlbumName, false) | |
| }) | |
| } | |
| GS.service.reportUserChange(GS.user); | |
| $.publish("gs.auth.update", b); | |
| if (!GS.user.IsPremium && GS.Controllers.AirbridgeController.instance().isDesktop || gsConfig.isPreview && !GS.user.IsPremium && GS.user.UserID % 5 != 0 ) { | |
| if ( h = GS.Controllers.LightboxController ? GS.Controllers.LightboxController.instance() : null ) $("#lightbox_wrapper .lbcontainer.gs_lightbox_login:visible").length || h.open("login", { | |
| premiumRequired: true, | |
| showPreview: true, | |
| notCloseable: true | |
| }); | |
| else gsConfig.lightboxOnInit = { | |
| type: "login", | |
| defaults: { | |
| premiumRequired: true, | |
| showPreview: true, | |
| notCloseable: true | |
| } | |
| }; | |
| GS.player && GS.player.pauseNextSong() | |
| } | |
| GS.user.isLoggedIn || $.publish("gs.auth.library.update"); | |
| if ( GS.getGuts && GS.user && GS.user.UserID > 0 ) { | |
| h = _.browserDetect(); | |
| GS.getGuts().logEvent("login", { | |
| userID: GS.user.UserID, | |
| browser: h.browser, | |
| browserVersion: h.version, | |
| os: navigator.platform, | |
| ip: gsConfig.remoteAddr | |
| }); | |
| GS.getGuts().beginContext({ | |
| userID: GS.user.UserID | |
| }) | |
| } | |
| }, | |
| _onAuthUpdate: function() { | |
| $.isFunction(this.vipUpdateCallback) && GS.user.IsPremium && this.vipUpdateCallback(); | |
| this.vipUpdateCallback = null; | |
| $.isFunction(this.authUpdateCallback) && this.authUpdateCallback(); | |
| this.authUpdateCallback = null | |
| } | |
| }); | |
| jQuery.Controller.extend("GS.Controllers.ThemeController", { | |
| _instance: null, | |
| themes: themes, | |
| sortOrder: themesSortOrder, | |
| plusThemes: plusThemes, | |
| artistThemes: artistThemes, | |
| instance: function() { | |
| return this._instance ? this._instance : new this($(document)) | |
| }, | |
| init: function() { | |
| this._super() | |
| } | |
| }, { | |
| currentTheme: null, | |
| themes: null, | |
| sort: null, | |
| themesLocation: "themes", | |
| themePreferences: {}, | |
| hasSeenSponsoredTheme: true, | |
| hasSeenRotationCount: true, | |
| promptOnLogin: false, | |
| themeVisualizerForcedOnce: false, | |
| themeIsReady: false, | |
| manualSelectThemeID: null, | |
| lastActivePage: null, | |
| lastThemeNotification: null, | |
| lastDFPChange: null, | |
| lastUserChange: null, | |
| PAGE_HOME: "home", | |
| DEFAULT_USER_THEMEID: 511, | |
| DEFAULT_PREMIUM_THEMEID: 511, | |
| THEME_URL_PATTERN: /^#\/(theme)\/(.*)\/?/, | |
| THEME_USER_LIMIT: 6E5, | |
| THEME_RATE_LIMIT: 6E4, | |
| THEME_NOTIF_RATE_LIMIT: 864E5, | |
| THEME_FLAG_DEFAULT: 0, | |
| THEME_FLAG_FAMILY_FRIENDLY: 1, | |
| init: function() { | |
| this.themes = themes; | |
| this.sort = themesSortOrder; | |
| this.themePreferences = GS.store.get("themePreferences") || {}; | |
| $.subscribe("gs.app.ready", this.callback(this.appReady)); | |
| $.subscribe("gs.app.resize", this.callback(this.positionTheme)); | |
| $.subscribe("gs.auth.update", this.callback(this.onAuthUpdate)); | |
| $.subscribe("gs.page.home.update", this.callback(this.positionTheme)); | |
| $.subscribe("gs.player.nowplaying", this.callback(this.onSongPlay)); | |
| $.subscribe("gs.player.streamserver", this.callback(this.onStreamServer)); | |
| $.subscribe("gs.page.view", this.callback(this.pageView)); | |
| $.subscribe("gs.theme.click", this.callback(this.onThemeClick)); | |
| $.subscribe("gs.theme.playVideo", this.callback(this.playVideo)) | |
| }, | |
| appReady: function() { | |
| if (!(location.hash && location.hash.match(GS.theme.THEME_URL_PATTERN))) { | |
| if ( GS.user.UserID > 0 || _.defined(GS.store.get("isFirstVisit")) || _.defined(gsConfig.isNoob) && !gsConfig.isNoob ) { | |
| this.isFirstVisit = false; | |
| this.resetTheme(); | |
| this.handlePreviewLightboxTrigger() | |
| } else GS.service.isFirstVisit(this.callback("onIsFirstVisit")); | |
| setTimeout(this.callback(function() { | |
| this.currentTheme || this.lastOrDefault() | |
| }), 1E4) | |
| } | |
| }, | |
| onAuthUpdate: function( a ) { | |
| if (!(a && a.hasOwnProperty("doNotReset") || location.hash.indexOf("#/signup") == 0)) { | |
| this.lastDFPChange = | |
| this.lastUserChange = this.lastThemeNotification = null; | |
| this.hasSeenRotationCount = this.hasSeenSponsoredTheme = true; | |
| if ( this.promptOnLogin && GS.user.UserID > 0 ) { | |
| this.promptOnLogin = false; | |
| this.lastDFPChange = (new Date).getTime(); | |
| GS.getLightbox().open("promotion", { | |
| theme: this.currentTheme | |
| }) | |
| } else!this.promptOnLogin && GS.getLightbox().curType !== "promotion" && this.resetTheme(); | |
| if ( GS.user.IsPremium ) { | |
| $("#sidebarCapital_160").removeClass("capital"); | |
| GS.getAd().hideAdBar() | |
| } | |
| this.currentTheme.onAuthChange && this.currentTheme.onAuthChange() | |
| } | |
| }, | |
| resetTheme: function( a ) { | |
| if (!(a && a.hasOwnProperty("doNotReset") || this.isFirstVisit)) { | |
| a = new Date; | |
| !gsConfig.isPreview && !GS.user.IsPremium && this.hasSeenSponsoredTheme && this.hasSeenRotationCount && (!this.lastUserChange || a.getTime() - this.lastUserChange > this.THEME_USER_LIMIT) ? this.loadFromDFP() : this.lastOrDefault() | |
| } | |
| }, | |
| onIsFirstVisit: function( a ) { | |
| this.isFirstVisit = a; | |
| GS.store.set("isFirstVisit", false); | |
| if ( this.isFirstVisit ) { | |
| this.setCurrentTheme(this.DEFAULT_USER_THEMEID); | |
| this.trackFirstVisit() | |
| } else this.resetTheme(); | |
| this.handlePreviewLightboxTrigger() | |
| }, | |
| lastOrDefault: function() { | |
| var a = this.getLastTheme(); | |
| if ( this.themes ) { | |
| if ( a && themes[a] && (GS.user.IsPremium && a || themes[a] && !themes[a].premium) ) { | |
| themes[a].pageTracking = []; | |
| this.setCurrentTheme(a) | |
| } else GS.user.IsPremium ? this.setCurrentTheme(this.DEFAULT_PREMIUM_THEMEID) : this.setCurrentTheme(this.DEFAULT_USER_THEMEID); | |
| this.themeNotification(GS.player.getCurrentSong()) | |
| } | |
| }, | |
| setCurrentTheme: function( a, b ) { | |
| if (!this.themes[a] || this.currentTheme && this.currentTheme.themeID == a || !GS.user.IsPremium && this.themes[a].premium ) return false; | |
| var c = !this.currentTheme; | |
| (this.lastTheme = this.currentTheme) && this.lastTheme.removeReady && this.lastTheme.removeReady(); | |
| this.promptOnLogin = false; | |
| this.currentTheme = GS.Models.Theme.wrap(this.themes[a]); | |
| this.renderTheme(); | |
| var g = new Date; | |
| if ( GS.getAd ) GS.getAd().rotationCountPerImpression = 0; | |
| if ( b ) { | |
| this.hasSeenRotationCount = this.hasSeenSponsoredTheme = true; | |
| this.setLastTheme(a); | |
| if ( this.lastTheme ) this.setLastSeen(this.lastTheme.themeID); | |
| else this.lastUserChange = g.getTime() | |
| } else { | |
| this.lastDFPChange = | |
| g.getTime(); | |
| this.hasSeenRotationCount = this.hasSeenSponsoredTheme = false | |
| } | |
| if ( c ) { | |
| this.onReady(); | |
| GS.getGuts().gaTrackEvent("themes", "firstTheme", a); | |
| this.firstTheme = "" + a | |
| } else this.adSync(); | |
| GS.getGuts().gaTrackEvent("themes", "change", a); | |
| this.themeImpression(); | |
| this.themePageImpression(); | |
| this.setRecentSeen(this.currentTheme.themeID); | |
| this.currentTheme.ready && setTimeout(this.callback(function() { | |
| this.currentTheme.ready(); | |
| GS.getFacebook(); | |
| GS.getNotice() | |
| }, 0)); | |
| $.publish("gs.theme.set"); | |
| this.buildSidebarAd() | |
| }, | |
| setLastTheme: function( a ) { | |
| if ( this.themePreferences[GS.user.UserID] ) this.themePreferences[GS.user.UserID].lastTheme = a; | |
| else this.themePreferences[GS.user.UserID] = { | |
| lastTheme: a, | |
| lastSeen: {} | |
| } | |
| }, | |
| setLastSeen: function( a ) { | |
| var b = new Date; | |
| this.lastUserChange = b.getTime(); | |
| if ( this.themePreferences[GS.user.UserID] ) this.themePreferences[GS.user.UserID].lastSeen[a] = b.getTime() | |
| }, | |
| setRecentSeen: function( a ) { | |
| this.themePreferences[GS.user.UserID] || (this.themePreferences[GS.user.UserID] = { | |
| lastTheme: a, | |
| lastSeen: {}, | |
| recentSeenThemes: [] | |
| }); | |
| if (!this.themePreferences[GS.user.UserID].recentSeenThemes ) this.themePreferences[GS.user.UserID].recentSeenThemes = []; | |
| if ( this.themePreferences[GS.user.UserID].recentSeenThemes.indexOf(a) < 0 ) if ( this.themePreferences[GS.user.UserID].recentSeenThemes.length >= 10 ) { | |
| this.themePreferences[GS.user.UserID].recentSeenThemes.push(a); | |
| this.themePreferences[GS.user.UserID].recentSeenThemes.shift() | |
| } else this.themePreferences[GS.user.UserID].recentSeenThemes.push(a) | |
| }, | |
| getRecentSeen: function() { | |
| return this.themePreferences[GS.user.UserID] ? this.themePreferences[GS.user.UserID].recentSeenThemes : null | |
| }, | |
| setLastDFPAction: function() { | |
| this.lastDFPChange = (new Date).getTime() | |
| }, | |
| getLastTheme: function() { | |
| return this.themePreferences[GS.user.UserID] && this.themePreferences[GS.user.UserID].lastTheme ? this.themePreferences[GS.user.UserID].lastTheme : null | |
| }, | |
| getLastSeen: function( a ) { | |
| return this.themePreferences[GS.user.UserID] && this.themePreferences[GS.user.UserID].lastSeen[a] ? this.themePreferences[GS.user.UserID].lastSeen[a] : null | |
| }, | |
| canCallAdServer: function() { | |
| return !this.isFirstVisit && !gsConfig.isPreview && !GS.user.IsPremium && this.hasSeenSponsoredTheme && this.hasSeenRotationCount && (!this.lastUserChange || (new Date).getTime() - this.lastUserChange > this.THEME_USER_LIMIT) | |
| }, | |
| adSync: function() { | |
| if (!GS.user.IsPremium && (this.currentTheme.misc && this.currentTheme.misc.adSync || this.currentTheme.adSync) ) GS.getAd().startAdTimer() | |
| }, | |
| adUnSync: function() { | |
| if (!GS.user.IsPremium && (this.currentTheme.misc && this.currentTheme.misc.adUnSync || this.currentTheme.adUnSync) ) GS.getAd().startAdTimer() | |
| }, | |
| hasAdSyncUnSync: function() { | |
| return this.currentTheme.misc && this.currentTheme.misc.adSync && this.currentTheme.misc.adUnSync || this.currentTheme.adSync && this.currentTheme.adUnSync | |
| }, | |
| loadFromDFPManual: function( a ) { | |
| this.manualSelectThemeID = a; | |
| a = ";" + ["id=" + this.manualSelectThemeID, "m=1;dcmt=text/json;sz=777x777"].join(";"); | |
| GS.service.getThemeFromDFP(a, this.callback("onGetThemeManual"), this.callback("onGetThemeErr")) | |
| }, | |
| onGetThemeManual: function( a ) { | |
| this.onGetTheme(a, true) | |
| }, | |
| loadFromDFP: function() { | |
| var a = new Date; | |
| if (!gsConfig.isPreview && !GS.user.IsPremium && (!this.lastDFPChange || a.getTime() - this.lastDFPChange > this.THEME_RATE_LIMIT) ) GS.service.getThemeFromDFP(this.buildParams(), this.callback("onGetTheme"), this.callback("onGetThemeErr")) | |
| }, | |
| onGetTheme: function( a, b ) { | |
| var c = new Date; | |
| if (!b && c.getTime() - this.lastUserChange < this.THEME_USER_LIMIT ) console.warn("[Stopped DFP Override]"); | |
| else { | |
| try { | |
| a = JSON.parse(a) | |
| } catch (g) { | |
| console.log("invalid json from DFP", g); | |
| this.lastOrDefault(); | |
| return | |
| } | |
| if ( a ) { | |
| if ( b ) { | |
| if ( this.manualSelectThemeID && this.manualSelectThemeID.toString() != a.themeID.toString() ) { | |
| this.themes[this.manualSelectThemeID].pageTracking = []; | |
| this.setCurrentTheme(this.manualSelectThemeID, true); | |
| return | |
| } | |
| } else { | |
| if ( a.themeID < 0 ) { | |
| this.trackDefault(a.themeID); | |
| this.lastOrDefault(); | |
| return | |
| } | |
| if ( this.getLastSeen(a.themeID) ) { | |
| this.lastOrDefault(); | |
| return | |
| } | |
| } | |
| if ( this.themes[a.themeID] ) $.extend(this.themes[a.themeID], a); | |
| else this.themes[a.themeID] = a; | |
| this.themes[a.themeID].themeID = _.isString(a.themeID) ? parseInt(a.themeID) : a.themeID; | |
| this.themes[a.themeID].premium = _.isString(a.premium) ? a.premium === "true" : a.premium; | |
| this.themes[a.themeID].sponsored = _.isString(a.sponsored) ? a.sponsored === "true" : a.sponsored; | |
| this.themes[a.themeID].adSync = | |
| _.isString(a.adSync) ? a.adSync === "true" : a.adSync; | |
| this.themes[a.themeID].adUnSync = _.isString(a.adUnSync) ? a.adUnSync === "true" : a.adUnSync; | |
| c = parseFloat(a.pageHeaderFrequency); | |
| if (!isNaN(c) ) if ( c == 0 || Math.random() > c ) this.themes[a.themeID].pageTracking = null; | |
| c = parseFloat(a.artistNotifFrequency); | |
| if (!isNaN(c) ) if ( c == 0 || Math.random() > c ) this.themes[a.themeID].artistNotifTracking = null; | |
| this.setCurrentTheme(a.themeID, b) | |
| } else this.lastOrDefault() | |
| } | |
| }, | |
| onGetThemeErr: function() { | |
| if ( this.manualSelectThemeID && (!this.currentTheme || this.manualSelectThemeID != this.currentTheme.themeID) && this.themes[this.manualSelectThemeID] ) { | |
| themes[this.manualSelectThemeID].pageTracking = []; | |
| this.setCurrentTheme(this.manualSelectThemeID, true); | |
| this.manualSelectThemeID = null | |
| } else this.lastOrDefault() | |
| }, | |
| onReady: function() { | |
| if (!this.themeIsReady ) { | |
| this.themeIsReady = true; | |
| GS.user.IsPremium || GS.getAd().startAdTimer() | |
| } | |
| }, | |
| onSongPlay: function( a ) { | |
| if ( a && a.SongID ) if (!this.currentSong || this.currentSong.SongID != a.SongID ) { | |
| this.currentSong = a; | |
| this.canCallAdServer() ? this.loadFromDFP() : this.themeNotification(a) | |
| } | |
| }, | |
| onStreamServer: function( a ) { | |
| if ( document.visualizerTheme && document.visualizerTheme.loadCrossdomain ) { | |
| document.visualizerTheme.loadCrossdomain(a.streamServer); | |
| if (!this.themeVisualizerForcedOnce ) if ( document.visualizerTheme && document.visualizerTheme.visualizerForceStart ) { | |
| document.visualizerTheme.visualizerForceStart(); | |
| this.themeVisualizerForcedOnce = true | |
| } | |
| } | |
| }, | |
| savePreferences: function() { | |
| GS.store.set("themePreferences", this.themePreferences) | |
| }, | |
| buildSidebarAd: function() { | |
| if (!GS.user.IsPremium && !this.isFirstVisit && (!this.currentTheme.sponsored || this.currentTheme.sidebarAd) && GS.Controllers.PageController.activePageName == this.PAGE_HOME ) { | |
| GS.getAd().showAdBar(); | |
| GS.getAd().updateRotationCount(); | |
| $("#sidebarCapital_160").addClass("capital"); | |
| GS.getAd().buildAd($("#sidebarCapital_160"), 160, 600, ["p=home"]) | |
| } else GS.getAd().hideAdBar() | |
| }, | |
| pageView: function( a ) { | |
| if (!(!this.currentTheme && !this.themeIsReady || !this.lastActivePage)) switch ( a ) { | |
| case this.PAGE_HOME: | |
| this.positionTheme(); | |
| this.hasAdSyncUnSync() && this.adSync(); | |
| this.themeImpression(); | |
| this.buildSidebarAd(); | |
| break; | |
| default: | |
| this.canCallAdServer() && this.loadFromDFP(); | |
| this.hasAdSyncUnSync() && this.lastActivePage == this.PAGE_HOME && this.adUnSync(); | |
| this.themePageImpression(); | |
| break | |
| } | |
| this.lastActivePage = a | |
| }, | |
| themeImpression: function() { | |
| if ( this.currentTheme && this.themeIsReady && this.currentTheme.sponsored ) if ( GS.Controllers.PageController.activePageName && GS.Controllers.PageController.activePageName.toLowerCase() == this.PAGE_HOME ) if ( this.currentTheme.tracking ) { | |
| this.hasSeenSponsoredTheme = | |
| true; | |
| GS.service.logTargetedThemeImpression(this.currentTheme.themeID); | |
| this.loadTracking(this.currentTheme.tracking); | |
| if ( GS.getAd ) GS.getAd().rotationCountPerImpression = 0 | |
| } | |
| }, | |
| themePageImpression: function() { | |
| this.currentTheme && this.themeIsReady && this.currentTheme.sponsored && $("#theme_page_header").is(".active:visible") && this.loadTracking(this.currentTheme.pageTracking) | |
| }, | |
| loadTracking: function( a ) { | |
| if ( $.isArray(a) ) { | |
| var b = (new Date).valueOf(), | |
| c; | |
| _.forEach(a, function( g ) { | |
| if ( g ) { | |
| g += g.indexOf("?") != -1 ? "&" + b : "?" + b; | |
| c = new Image; | |
| $("body").append($(c).load(function( h ) { | |
| $(h.target).remove() | |
| }).css("visibility", "hidden").attr("src", g)) | |
| } | |
| }) | |
| } | |
| }, | |
| trackDefault: function( a ) { | |
| this.loadTracking(["http://ad.doubleclick.net/ad/grooveshark.wall/;id=" + a + ";d=1;sz=1x1;ord="]); | |
| GS.getGuts().logEvent("trackDefaultTheme", { | |
| id: a | |
| }) | |
| }, | |
| trackFirstVisit: function() { | |
| this.loadTracking(["http://ad.doubleclick.net/ad/grooveshark.wall/;id=-1;v=1;sz=1x1;ord="]) | |
| }, | |
| onThemeClick: function( a ) { | |
| a && a.currentTarget && this.currentTheme && this.currentTheme.handleClick(a) | |
| }, | |
| playVideo: function( a ) { | |
| if ( this.currentTheme ) { | |
| index = _.orEqual(a.index, 0); | |
| GS.getLightbox().open("video", { | |
| video: this.currentTheme.videos[index], | |
| videos: this.currentTheme.videos, | |
| index: index | |
| }) | |
| } | |
| }, | |
| renderTheme: function() { | |
| var a = $("#theme_page_header.measure").height(); | |
| if ( this.currentTheme ) { | |
| $("#themeStyleSheet").attr("href", [gsConfig.assetHost, this.themesLocation, this.currentTheme.location, "theme.css"].join("/") + "?ver=" + this.currentTheme.version); | |
| $(".theme_component").html("").removeClass("active"); | |
| for ( var b = | |
| 0; b < this.currentTheme.sections.length; b++ ) | |
| this.renderSection(this.currentTheme.sections[b]); | |
| this.positionTheme(); | |
| if ( window.location.hash !== "#/" && window.location.hash !== "" && window.location.hash.toString().indexOf("#/theme") != 0 && window.location.hash.toString().indexOf("#/sessions") != 0 ) { | |
| $("#theme_home object").hide(); | |
| window.location.hash.toString().indexOf("#/signup"); | |
| this.currentTheme.artistIDs && this.themeNotification(GS.player.getCurrentSong()) | |
| } | |
| } | |
| $("#theme_page_header.measure").height() !== a && GS.resize() | |
| }, | |
| renderSection: function( a ) { | |
| if ( this.currentTheme && a.length && $(a).length ) { | |
| var b = [this.themesLocation, this.currentTheme.location]; | |
| b.push(a.substr(7, a.length)); | |
| b = b.join("/"); | |
| $(a).html(this.view(b)).addClass("active"); | |
| if ( a === "#theme_page_header" || a === "#theme_page_header_expandable" ) $(a).prepend($("<div class='border'></div>")); | |
| this.currentTheme.bindAssets(a) | |
| } | |
| }, | |
| positionTheme: function() { | |
| var a; | |
| if ( this.currentTheme && this.currentTheme.sections ) for ( var b = 0; b < this.currentTheme.sections.length; b++ ) { | |
| a = this.currentTheme.sections[b]; | |
| this.currentTheme.position(a) | |
| } | |
| }, | |
| themeNotification: function( a ) { | |
| a = _.orEqual(a, GS.player.getCurrentSong()); | |
| var b = new Date; | |
| if ( a && this.currentTheme.artistIDs && window.location.hash !== "#/" && window.location.hash !== "" ) for ( var c, g = 0; g < this.currentTheme.artistIDs.length; g++ ) { | |
| c = this.currentTheme.artistIDs[g]; | |
| if ( c == a.ArtistID && this.currentTheme.artistNotifTracking && (!this.lastThemeNotification || b.getTime() - this.lastThemeNotification > this.THEME_NOTIF_RATE_LIMIT) ) { | |
| this.lastThemeNotification = b.getTime(); | |
| GS.getNotice().displayThemeArtistNotification(a, this.currentTheme); | |
| break | |
| } | |
| } | |
| }, | |
| view: function( a, b, c ) { | |
| a = [a]; | |
| b = _.orEqual(b, this); | |
| c = this.calculateHelpers.call(this, c); | |
| a = "/" + a.join("/"); | |
| a += $.View.ext + "?ver=" + this.currentTheme.version.toString().replace(/[\/\.\?]/g, "_"); | |
| a.replace(/[\/\.]/g, "_").replace(/_+/g, "_").replace(/^_/, ""); | |
| return $.View(a, b, c) | |
| }, | |
| buildParams: function() { | |
| return GS.getAd().buildParams(["dcmt=text/json", "sz=777x777"], ";", ";") | |
| }, | |
| themeCenter: function() { | |
| $(".theme-center").each(function() { | |
| var a = $(this); | |
| a.css({ | |
| left: "50%", | |
| marginLeft: -(a.outerWidth() / 2) | |
| }) | |
| }) | |
| }, | |
| downloadIE9: function() { | |
| function a(o) { | |
| return b.indexOf(o) >= 0 | |
| } | |
| var b = navigator.userAgent.toLowerCase(); | |
| parseFloat(window.navigator.appMinorVersion); | |
| a("windows nt"); | |
| var c = a("windows nt 6.0"), | |
| g = a("windows nt 6.1"), | |
| h = a("windows nt 5.1"), | |
| k = a("msie"); | |
| a("msie 7"); | |
| a("msie 8"); | |
| a("trident/5.0"); | |
| a("trident/6.0"); | |
| var m = a("firefox"), | |
| p = a("chrome"), | |
| n = false; | |
| if ( p ) Version = b.match(/chrome\/(\d{1,2})/)[1]; | |
| if ( m && /Firefox[\/\s](\d+\.\d+)/.test(navigator.userAgent) ) Version = Number(RegExp.$1); | |
| if ( k || m && Version >= 4 || p && Version >= 11 ) { | |
| BitSniffed = true; | |
| n = a("win64") || a("wow64") | |
| } | |
| WinVersion = h ? "xp" : c ? "vista" : g ? "win7" : ""; | |
| WinBits = n ? "64" : "32"; | |
| c = { | |
| "win7-32": "/8/6/D/86DB5DC9-5706-4A5B-BD46-FFBA6FA67D44/IE9-Windows7-x86-enu.exe", | |
| "win7-64": "/8/6/D/86DB5DC9-5706-4A5B-BD46-FFBA6FA67D44/IE9-Windows7-x64-enu.exe", | |
| "vista-32": "/8/6/D/86DB5DC9-5706-4A5B-BD46-FFBA6FA67D44/IE9-WindowsVista-x86-enu.exe", | |
| "vista-64": "/8/6/D/86DB5DC9-5706-4A5B-BD46-FFBA6FA67D44/IE9-WindowsVista-x64-enu.exe" | |
| }; | |
| g = WinVersion ? WinVersion + "-" + WinBits : ""; | |
| return c[g] ? "http://download.microsoft.com/download" + c[g] : false | |
| }, | |
| handlePreviewLightboxTrigger: function() { | |
| var a = new Date, | |
| b = new Date(2011, 11, 1); | |
| if (!(a.valueOf() > b.valueOf())) if ( this.isFirstVisit ) GS.store.set("hasSeenUkuleleWelcome", true); | |
| else if (!GS.store.get("hasSeenUkuleleWelcome") ) { | |
| GS.store.set("hasSeenUkuleleWelcome", true); | |
| GS.getLightbox().open("preview") | |
| } | |
| } | |
| }); | |
| $.Class.extend("GS.Notification", { | |
| defaults: { | |
| duration: 5E3, | |
| view: "notification", | |
| viewParams: false, | |
| uniqueInstance: false, | |
| element: null, | |
| isOpen: false, | |
| isAdded: false, | |
| timeout: false, | |
| focusInText: false, | |
| mouseIsOut: false, | |
| listenersSet: false, | |
| useAnimation: true, | |
| onOpen: null | |
| } | |
| }, { | |
| controller: null, | |
| init: function( a ) { | |
| a = $.extend({}, GS.Notification.defaults, a); | |
| for ( var b in a ) | |
| if ( a.hasOwnProperty(b) ) this[b] = a[b]; | |
| if (!this.notificationID ) this.notificationID = this.controller.generateNotificationID(); | |
| this.controller.notificationLookup[this.notificationID] = | |
| this; | |
| if ( this.uniqueInstance ) this.controller.uniquesLookup[this.uniqueInstance] = this; | |
| if (!this.viewParams ) this.viewParams = {}; | |
| this.viewParams.notificationID = this.notificationID; | |
| if (!this.element ) this.element = $(this.controller.view(this.view, this.viewParams)) | |
| }, | |
| open: function() { | |
| this.isAdded || this.add(); | |
| this.useAnimation ? this.element.slideDown("fast") : this.element.show(); | |
| this.isOpen = true; | |
| this.beginTimeout(); | |
| this.controller.reportOpen(this); | |
| $.isFunction(this.onOpen) && this.onOpen() | |
| }, | |
| close: function() { | |
| this.remove(); | |
| this.isOpen = false; | |
| this.endTimeout(); | |
| this.controller.reportClose(this) | |
| }, | |
| beginTimeout: function( a ) { | |
| a = _.orEqual(a, this.duration); | |
| this.timeout && this.endTimeout(); | |
| if ( a ) this.timeout = setTimeout(this.callback(function() { | |
| this.close() | |
| }), a) | |
| }, | |
| endTimeout: function() { | |
| clearTimeout(this.timeout) | |
| }, | |
| setListeners: function() { | |
| this.element.mouseout(this.callback(function() { | |
| this.mouseOut = true; | |
| this.focusInText || this.beginTimeout(this.duration) | |
| })); | |
| this.element.mouseover(this.callback(function() { | |
| this.mouseOut = false; | |
| this.endTimeout() | |
| })); | |
| this.element.find("textarea").focus(this.callback(function() { | |
| this.focusInText = true; | |
| this.endTimeout() | |
| })); | |
| this.element.find("textarea").focusout(this.callback(function() { | |
| this.focusInText = false; | |
| this.mouseOut && this.beginTimeout(this.duration) | |
| })) | |
| }, | |
| add: function() { | |
| $("#notifications").append(this.element); | |
| this.element.hide(); | |
| this.listenersSet || this.setListeners(); | |
| this.isAdded = true | |
| }, | |
| remove: function() { | |
| if ( this.useAnimation ) this.element.stop().slideUp("fast", this.callback(function() { | |
| this.element.remove(); | |
| this.isAdded = | |
| false | |
| })); | |
| else { | |
| this.element.remove(); | |
| this.isAdded = false | |
| } | |
| } | |
| }); | |
| GS.Controllers.BaseController.extend("GS.Controllers.NotificationsController", { | |
| isGSSingleton: true, | |
| preSetup: function() { | |
| var a = GS.Controllers.BaseController.singletonCallback, | |
| b = $.subscribe; | |
| b("gs.notification", a("notice", "displayMessage")); | |
| b("gs.player.nowplaying", a("notice", "onSongPlay")); | |
| b("gs.notification.restorequeue", a("notice", "displayRestoreQueue")); | |
| b("gs.facebook.notification.sent", a("notice", "displayFacebookSent")); | |
| b("gs.facebook.notification.removed", a("notice", "displayFacebookUndoPost")); | |
| b("gs.notification.favorite.song", a("notice", "displayFavoritedObject", "song")); | |
| b("gs.notification.favorite.playlist", a("notice", "displayFavoritedObject", "playlist")); | |
| b("gs.notification.favorite.artist", a("notice", "displayFavoritedObject", "artist")); | |
| b("gs.notification.favorite.user", a("notice", "displayFavoritedObject", "user")); | |
| b("gs.notification.playlist.create", a("notice", "displayFavoritedObject", "newPlaylist")); | |
| b("gs.auth.library.songsAdded", a("notice", "displayLibraryAddedObject")); | |
| b("gs.facebook.notification.connect", a("notice", "displayFacebookConnect")); | |
| b("gs.facebook.notification.songComment", a("notice", "displayFacebookSongComment")); | |
| b("gs.facebook.notification.findFriends", a("notice", "displayFacebookFindFriends")); | |
| b("gs.facebook.notification.cannotPost", a("notice", "displayFacebookCannotPost")); | |
| b("gs.facebook.notification.rateLimited", a("notice", "displayFacebookRateLimit")) | |
| } | |
| }, { | |
| appIsReady: false, | |
| localeIsReady: false, | |
| queuedNotifications: [], | |
| openNotifications: [], | |
| maxOnScreen: 3, | |
| uniquesLookup: {}, | |
| notificationLookup: {}, | |
| seenArtistNotifications: [], | |
| seenPromoNotifications: null, | |
| sawSignupNotification: false, | |
| sawRestoreQueueNotification: false, | |
| feedbackOnNextSong: false, | |
| currentPromotionIntervalID: null, | |
| lastPromoNotification: null, | |
| sawPreviewNotification: 0, | |
| doNotShowPreviewNotification: false, | |
| sawPreviewNotificationThisSession: false, | |
| beenToPreview: false, | |
| PROMO_NOTIF_RATE_LIMIT: 108E5, | |
| init: function() { | |
| this.seenPromoNotifications = GS.store.get("seenPromoNotifications") || {}; | |
| this.sawPreviewNotification = parseInt(GS.store.get("sawPreviewNotification"), 10) || 0; | |
| this.doNotShowPreviewNotification = | |
| _.orEqual(GS.store.get("doNotShowPreviewNotification"), false); | |
| this.sawRestoreQueueNotification = parseInt(GS.store.get("sawRestoreQueueNotification"), 10) || 0; | |
| this.beenToPreview = _.orEqual(GS.store.get("beenToPreview"), false); | |
| this._super(); | |
| if ( $.localize.ready ) this.localeIsReady = true; | |
| else this.subscribe("gs.locale.ready", this.callback("localeReady")); | |
| GS.Notification.prototype.controller = this; | |
| var a = _.browserDetect(), | |
| b = false; | |
| switch ( a.browser ) { | |
| case "chrome": | |
| b = true; | |
| break; | |
| case "firefox": | |
| b = a.version >= 6; | |
| break; | |
| case "msie": | |
| b = a.version >= 8; | |
| break | |
| } | |
| GS.Notification.defaults.useAnimation = b | |
| }, | |
| appReady: function() { | |
| this.appIsReady = true; | |
| this.openNext(); | |
| GS.IE.canPin && !GS.IE.isPinned && GS.IE.firstVisit ? this.getPromoNotifFromDFP({ | |
| subid: 2.2 | |
| }) : this.getPromoNotifFromDFP() | |
| }, | |
| showPreviewLightbox: function() { | |
| if (!this.beenToPreview && (GS.user.IsPremium || GS.user.UserID % 5 === 0) ) { | |
| this.beenToPreview = true; | |
| GS.store.set("beenToPreview", true); | |
| GS.getLightbox().open("preview") | |
| } | |
| }, | |
| localeReady: function() { | |
| this.localeIsReady = true; | |
| this.openNext() | |
| }, | |
| generateNotificationID: function() { | |
| var a = (Math.floor(Math.random() * 1E4) + 1).toString(); | |
| return this.notificationLookup.hasOwnProperty(a) ? this.generateNotificationID() : a | |
| }, | |
| queueNotification: function( a ) { | |
| this.queuedNotifications.indexOf(a) === -1 && this.queuedNotifications.push(a); | |
| this.openNext() | |
| }, | |
| openNext: function() { | |
| this.appIsReady && this.localeIsReady && this.queuedNotifications.length && this.openNotifications.length < this.maxOnScreen && this.queuedNotifications.shift().open() | |
| }, | |
| reportOpen: function( a ) { | |
| this.openNotifications.indexOf(a) === -1 && this.openNotifications.push(a) | |
| }, | |
| reportClose: function( a ) { | |
| var b = this.openNotifications.indexOf(a); | |
| b !== -1 && this.openNotifications.splice(b, 1); | |
| this.notificationLookup.hasOwnProperty(a.notificationID) && delete this.notificationLookup[a.notificationID]; | |
| a.uniqueInstance && this.uniquesLookup.hasOwnProperty(a.uniqueInstance) && delete this.uniquesLookup[a.uniqueInstance]; | |
| this.openNext() | |
| }, | |
| displayMessage: function( a ) { | |
| var b; | |
| if ( a.uniqueInstance ) if ((b = this.uniquesLookup[a.uniqueInstance]) && b.isOpen ) { | |
| b.beginTimeout(); | |
| return | |
| } | |
| b || (b = new GS.Notification({ | |
| view: "notification", | |
| viewParams: { | |
| controller: this, | |
| notification: a | |
| }, | |
| duration: a.manualClose ? 0 : a.displayDuration, | |
| uniqueInstance: _.orEqual(a.uniqueInstance, false) | |
| })); | |
| b.isOpen || this.queueNotification(b) | |
| }, | |
| onSongPlay: function( a ) { | |
| if ( a && (this.feedbackOnNextSong || a.sponsoredAutoplayID) ) { | |
| this.feedbackOnNextSong = false; | |
| if ( this.seenArtistNotifications.indexOf(a.ArtistID) === -1 ) { | |
| this.seenArtistNotifications.push(a.ArtistID); | |
| this.displayArtistFeedback(a) | |
| } | |
| } | |
| this.uniquesLookup.promotion || this.getPromoNotifFromDFP({ | |
| song: a | |
| }) | |
| }, | |
| closeAllNotifs: function() { | |
| if (!_.isEmpty(this.uniquesLookup) ) for ( var a in this.uniquesLookup ) this.uniquesLookup.hasOwnProperty(a) && this.uniquesLookup[a].close() | |
| }, | |
| closeAllSurveyNotifs: function() { | |
| if (!_.isEmpty(this.uniquesLookup) ) for ( var a in this.uniquesLookup ) if ( this.uniquesLookup.hasOwnProperty(a) ) if ( a == "surveyOptIn" || a == "surveyResult" || a == "surveyQuestion" ) this.uniquesLookup[a].close() | |
| }, | |
| saveSeenPromoNotifications: function() { | |
| GS.store.set("seenPromoNotifications", this.seenPromoNotifications) | |
| }, | |
| getPromoNotifFromDFP: function( a ) { | |
| var b = new Date; | |
| if ( a && _.isNumber(a.subid) ) GS.service.getNotificationFromDFP(this.buildParams(a), this.callback("displayPromotionManual"), this.callback("displayPromotionErr")); | |
| else if (!this.lastPromoNotification || b.getTime() - this.lastPromoNotification > this.PROMO_NOTIF_RATE_LIMIT ) { | |
| this.lastPromoNotification = b.getTime(); | |
| GS.service.getNotificationFromDFP(this.buildParams(a), this.callback("displayPromotion"), this.callback("displayPromotionErr")) | |
| } | |
| }, | |
| buildParams: function( a ) { | |
| var b = []; | |
| b.push("notif=1"); | |
| if ( a && _.isNumber(a.subid) ) { | |
| b.push("m=1"); | |
| b.push("subid=" + a.subid) | |
| } | |
| if ( GS.theme && GS.theme.currentTheme ) { | |
| var c = parseInt(GS.theme.currentTheme.themeID, 10); | |
| c && b.push("11=" + c) | |
| } | |
| a && a.song && b.push("2=" + a.song.ArtistID); | |
| if ( GS.user.isLoggedIn ) { | |
| if ( GS.user.Sex ) b.push("1=" + (GS.user.Sex.toLowerCase() == "m" ? "0" : "1")); | |
| if ( GS.user.TSDOB ) { | |
| a = GS.user.TSDOB.split("-"); | |
| if ( a.length == 3 ) { | |
| c = new Date; | |
| var g = c.getFullYear() - parseInt(a[0], 10); | |
| if ( parseInt(a[1], 10) > c.month ) g -= 1; | |
| else if ( parseInt(a[1], 10) == c.month && parseInt(a[2], 10) > c.date ) g -= 1; | |
| var h; | |
| if ( g >= 13 && g < 18 ) h = "1"; | |
| else if ( g >= 18 && g < 25 ) h = "2"; | |
| else if ( g >= 25 && g < 35 ) h = "3"; | |
| else if ( g >= 35 && g < 50 ) h = "4"; | |
| else if ( g >= 50 ) h = "5"; | |
| g >= 21 && b.push("a=1"); | |
| h && b.push("10=" + h) | |
| } | |
| } | |
| } | |
| GS.getAd && b.push("4=" + GS.getAd().rotationCount); | |
| if ( GS.theme ) { | |
| b.push("5=" + ((GS.user.settings.local.themeFlags & GS.theme.THEME_FLAG_FAMILY_FRIENDLY) == GS.theme.THEME_FLAG_FAMILY_FRIENDLY ? 1 : 0)); | |
| GS.theme.currentTheme && GS.theme.currentTheme.sections.indexOf("#theme_page_header") >= 0 && b.push("6=1") | |
| } | |
| if ( GS.Controllers.PageController ) if ( GS.Controllers.PageController.activePageName && GS.Controllers.PageController.activePageName.toLowerCase() == "home" ) b.push("9=1"); | |
| else GS.Controllers.PageController.activePageName && GS.Controllers.PageController.activePageName.toLowerCase() == "search" && (!GS.search.type || GS.search.type === "" || GS.search.type == "everything") ? b.push("9=2") : b.push("9=0"); | |
| if ( GS.IE ) if ( GS.IE.canPin ) if ( GS.IE.canPin && !GS.IE.isPinned ) b.push("ie=1"); | |
| else GS.IE.isPinned && b.push("ie=2"); | |
| else b.push("ie=0"); | |
| if ( GS.user.IsPremium ) if ((GS.user.Flags & GS.Models.User.FLAG_ANYWHERE) > 0 ) b.push("f=1"); | |
| else(GS.user.Flags & GS.Models.User.FLAG_PLUS) > 0 && b.push("f=2"); | |
| else b.push("f=0"); | |
| b.push("dcmt=text/json"); | |
| b.push("sz=468x60"); | |
| if (!GS.user.IsPremium && !GS.user.isLoggedIn && GS.store.get("webvisit") && GS.store.get("webvisit").theme ) b = b.concat(GS.store.get("webvisit").theme); | |
| return ";" + b.join(";") | |
| }, | |
| displayPromotionManual: function( a ) { | |
| this.displayPromotion(a, true) | |
| }, | |
| displayPromotion: function( a, b ) { | |
| try { | |
| a = JSON.parse(a) | |
| } catch (c) { | |
| console.log("invalid json from DFP", c); | |
| return | |
| } | |
| if ( a.id != "-1" ) if (!this.currentPromotionIntervalID && !this.uniquesLookup.promotion && !this.getLastPromoNotifSeen(a.id) || b ) { | |
| if ( a.delay && _.isArray(a.delay) && a.delay.length ) { | |
| var g = a.delay; | |
| g = g.shuffle(); | |
| a.delay = g[0] | |
| } | |
| g = parseInt(a.delay, 10); | |
| if ( isNaN(g) ) g = 0; | |
| var h = parseInt(a.duration, 10); | |
| if ( isNaN(h) ) h = 15E3; | |
| var k = a.view ? a.view : "promotionalNotification"; | |
| if ( b ) { | |
| g = 0; | |
| if ( a.type == "ie9" ) g = 5E3 | |
| } | |
| this.currentPromotionIntervalID = setTimeout(this.callback(function() { | |
| if (!b ) { | |
| if ( a.type == "signup" ) if ( GS.user.isLoggedIn || this.userActivityCheck() ) { | |
| this.setLastPromoNotifSeen(a.id); | |
| this.currentPromotionIntervalID = null; | |
| return | |
| } | |
| if ( a.type == "ie9" ) if ( GS.user.IsPremium || GS.IE.isPinned ) { | |
| this.setLastPromoNotifSeen(a.id); | |
| this.currentPromotionIntervalID = null; | |
| return | |
| } | |
| } | |
| this.queueNotification(new GS.Notification({ | |
| uniqueInstance: "promotion", | |
| view: k, | |
| viewParams: { | |
| controller: this, | |
| notifData: a | |
| }, | |
| duration: h | |
| })); | |
| this.setLastPromoNotifSeen(a.id) | |
| }), g) | |
| } | |
| }, | |
| displayPromotionErr: function() { | |
| console.warn("Promotional Notification Error") | |
| }, | |
| userActivityCheck: function() { | |
| var a = false, | |
| b = 0; | |
| _.forEach(GS.theme.themePreferences, function( c, g ) { | |
| b++; | |
| if ( g != "-1" || b > 1 ) a = true | |
| }); | |
| return a | |
| }, | |
| setLastPromoNotifSeen: function( a ) { | |
| var b = new Date; | |
| if (!this.seenPromoNotifications ) this.seenPromoNotifications = {}; | |
| if (!this.seenPromoNotifications[GS.user.UserID] ) { | |
| this.seenPromoNotifications[GS.user.UserID] = {}; | |
| this.seenPromoNotifications[GS.user.UserID].lastSeen = {} | |
| } | |
| this.seenPromoNotifications[GS.user.UserID].lastSeen[a] = b.getTime() | |
| }, | |
| getLastPromoNotifSeen: function( a ) { | |
| return this.seenPromoNotifications && this.seenPromoNotifications[GS.user.UserID] && this.seenPromoNotifications[GS.user.UserID].lastSeen[a] ? this.seenPromoNotifications[GS.user.UserID].lastSeen[a] : null | |
| }, | |
| loadTracking: function( a ) { | |
| if ( $.isArray(a) ) { | |
| var b = (new Date).valueOf(), | |
| c; | |
| _.forEach(a, function( g ) { | |
| g += g.indexOf("?") != -1 ? "&" + b : "?" + b; | |
| c = new Image; | |
| $("body").append($(c).load(function( h ) { | |
| $(h.target).remove() | |
| }).css("visibility", "hidden").attr("src", g)) | |
| }) | |
| } | |
| }, | |
| "li.notification.promo .promoNotifClickTracking click": function( a ) { | |
| if ( a = this.notificationLookup[$(a).closest("li.notification").attr("data-notificationid")] ) { | |
| this.loadTracking(a.viewParams.notifData.clickTracking); | |
| a.close() | |
| } | |
| }, | |
| displayArtistFeedback: function( a ) { | |
| this.uniquesLookup.artistFeedback || this.queueNotification(new GS.Notification({ | |
| uniqueInstance: "artistFeedback", | |
| view: "artistNotification", | |
| viewParams: { | |
| controller: this, | |
| feedbackSong: a | |
| }, | |
| duration: 15E3 | |
| })) | |
| }, | |
| displaySurveyQuestion: function( a ) { | |
| a = _.orEqual(a, {}); | |
| this.queueNotification(new GS.Notification({ | |
| uniqueInstance: "surveyQuestion", | |
| view: "surveyQuestion", | |
| viewParams: { | |
| controller: this, | |
| question: a.question, | |
| callback: a.callback | |
| }, | |
| duration: 6E4 | |
| })) | |
| }, | |
| displaySurveyOptIn: function( a ) { | |
| a = | |
| _.orEqual(a, {}); | |
| this.queueNotification(new GS.Notification({ | |
| uniqueInstance: "surveyOptIn", | |
| view: "surveyOptIn", | |
| viewParams: { | |
| controller: this, | |
| question: a.question, | |
| callback: a.callback | |
| }, | |
| duration: 6E4 | |
| })); | |
| GS.getGuts().logEvent("civicscience.invitationSeen", { | |
| userID: GS.user.UserID, | |
| timestamp: (new Date).getTime() | |
| }) | |
| }, | |
| displaySurveyResult: function( a ) { | |
| a = _.orEqual(a, {}); | |
| this.queueNotification(new GS.Notification({ | |
| uniqueInstance: "surveyResults", | |
| view: "surveyResults", | |
| viewParams: { | |
| controller: this, | |
| mostPopular: a.responses.mostPopular, | |
| selectedAnswer: a.responses.selectedAnswer, | |
| responses: a.responses, | |
| callback: a.callback | |
| }, | |
| duration: 15E3 | |
| })) | |
| }, | |
| "li.notification #surveyOptOut click": function( a, b ) { | |
| b.preventDefault(); | |
| GS.store.set("civicscience.hasSeenInvitation" + GS.user.UserID, true); | |
| var c = this.uniquesLookup.surveyOptIn; | |
| if ( c ) { | |
| GS.Models.Clearvoice.changeCivicScienceSettings(true); | |
| c.close() | |
| } | |
| return false | |
| }, | |
| "li.notification #surveyOptIn click": function( a, b ) { | |
| b.preventDefault(); | |
| GS.store.set("civicscience.hasSeenInvitation" + GS.user.UserID, true); | |
| var c = | |
| this.uniquesLookup.surveyOptIn; | |
| if ( c ) { | |
| var g = c.viewParams.callback; | |
| c.close(); | |
| g(); | |
| GS.getGuts().logEvent("civicscience.optIn", { | |
| userID: GS.user.UserID, | |
| timestamp: (new Date).getTime() | |
| }) | |
| } | |
| return false | |
| }, | |
| "li.notification #nextQuestion click": function( a, b ) { | |
| b.preventDefault(); | |
| var c = this.uniquesLookup.surveyResults; | |
| if ( c ) { | |
| var g = c.viewParams.callback; | |
| c.close(); | |
| g() | |
| } | |
| return false | |
| }, | |
| "li.notification form.survey submit": function( a, b ) { | |
| b.preventDefault(); | |
| var c = this.uniquesLookup.surveyQuestion; | |
| if ( c ) { | |
| var g = c.viewParams.question.answers, | |
| h = $(a).find(".selection"); | |
| name = c.viewParams.question.name; | |
| callback = c.viewParams.callback; | |
| if ( h.attr("value") != "" ) if ( name == "CivicScience" ) { | |
| var k = GS.user.civicScience, | |
| m = k.session, | |
| p = null; | |
| if ( h && h.length ) { | |
| for ( p = 0; p < g.length; p++ ) | |
| if ( g[p].id == h.attr("value") ) { | |
| p = g[p].option; | |
| p.select(); | |
| break | |
| } | |
| c.close(); | |
| m.commit(k.handleCommit) | |
| } | |
| } else if ( $.isFunction(callback) ) { | |
| g = { | |
| text: h.text(), | |
| id: h.attr("value"), | |
| questionId: h.attr("name") | |
| }; | |
| callback(g); | |
| c.close() | |
| } | |
| } | |
| return false | |
| }, | |
| "li.notification.survey button.startNow click": function() { | |
| var a = | |
| this.uniquesLookup.surveyAvailable; | |
| if ( a ) { | |
| var b = a.viewParams.survey; | |
| b && GS.getLightbox().open("startSurvey", { | |
| survey: b | |
| }); | |
| a.close() | |
| } | |
| }, | |
| displaySurveyInvitation: function() { | |
| GS.store.set("gs.surveys.hasSeenInvitation" + GS.user.UserID, 1); | |
| var a = (new Date).getTime(), | |
| b = GS.store.get("gs.surveys.lastInvitationClosedTime" + GS.user.UserID); | |
| GS.store.get("gs.surveys.notificationInvitationClosed" + GS.user.UserID) >= 3 && a - b < 2592E6 || b && a - b < 36E5 || $("#page_content").is(".surveyPage") || this.uniquesLookup.surveyInvitation || this.queueNotification(new GS.Notification({ | |
| uniqueInstance: "surveyInvitation", | |
| view: "surveyInvitation", | |
| viewParams: { | |
| controller: this | |
| }, | |
| duration: 6E4 | |
| })) | |
| }, | |
| "li.notification.survey button.surveyStart click": function() { | |
| var a = this.uniquesLookup.surveyInvitation; | |
| if ( a ) { | |
| location.hash = "/surveys"; | |
| a.close() | |
| } | |
| }, | |
| displaySurveysAvailable: function( a ) { | |
| var b = (new Date).getTime(), | |
| c = GS.store.get("gs.surveys.lastAvailableClosedTime" + GS.user.UserID); | |
| GS.store.get("gs.surveys.notificationAvailableClosed" + GS.user.UserID) >= 3 && b - c < 2592E6 || c && b - c < 36E5 || this.uniquesLookup.surveyAvailable || this.queueNotification(new GS.Notification({ | |
| uniqueInstance: "surveyAvailable", | |
| view: "surveyAvailable", | |
| viewParams: { | |
| controller: this, | |
| survey: a | |
| }, | |
| duration: 6E4 | |
| })) | |
| }, | |
| displaySurveyPoints: function( a ) { | |
| this.queueNotification(new GS.Notification({ | |
| view: "surveyPoints", | |
| viewParams: { | |
| controller: this, | |
| points: a | |
| }, | |
| duration: 15E3 | |
| })) | |
| }, | |
| displaySurveyAnswerError: function( a ) { | |
| this.queueNotification(new GS.Notification({ | |
| view: "surveyAnswerError", | |
| viewParams: { | |
| controller: this, | |
| errorCode: a | |
| } | |
| })) | |
| }, | |
| displaySurveyProfilersComplete: function() { | |
| this.queueNotification(new GS.Notification({ | |
| view: "surveyProfilersComplete", | |
| viewParams: { | |
| controller: this | |
| } | |
| })) | |
| }, | |
| displayPerAnum: function() { | |
| this.queueNotification(new GS.Notification({ | |
| view: "perAnum", | |
| viewParams: { | |
| controller: this | |
| } | |
| })) | |
| }, | |
| displayThemeArtistNotification: function( a, b ) { | |
| var c = this.uniquesLookup.artistFeedback; | |
| c && c.close(); | |
| this.queueNotification(new GS.Notification({ | |
| uniqueInstance: "artistFeedback", | |
| view: "themes/" + b.location + "/artist_notification", | |
| viewParams: { | |
| controller: this, | |
| feedbackSong: a | |
| }, | |
| duration: false | |
| })); | |
| GS.theme.lastDFPChange = (new Date).getTime() + 15E3 | |
| }, | |
| displayIE9PromoNotification: function() { | |
| this.queueNotification(new GS.Notification({ | |
| uniqueInstance: "promotion", | |
| view: "ie9PromoNotification", | |
| viewParams: { | |
| controller: this | |
| }, | |
| duration: false | |
| })) | |
| }, | |
| "li.notification a.theme_link click": function( a, b ) { | |
| b.index = parseInt($(a).attr("data-video-index"), 10); | |
| GS.theme.currentTheme.handleClick(b); | |
| GS.theme.lastDFPChange = (new Date).getTime(); | |
| if ( $(a).attr("data-click-action") ) { | |
| var c = this.notificationLookup[$(a).closest("li.notification").attr("data-notificationid")]; | |
| c && c.close() | |
| } | |
| }, | |
| "li.notification a.ie9_download click": function( a, b ) { | |
| var c = $(a).closest("li.notification").attr("data-notificationid"), | |
| g = $(b.target).attr("data-notif-ctp"), | |
| h = $(b.target).attr("data-theme-id"); | |
| GS.service.logThemeOutboundLinkClick(parseInt(h), 400); | |
| GS.theme.loadTracking(g.split(",")); | |
| (c = this.notificationLookup[c]) && c.close() | |
| }, | |
| "li.notification img.ie9_pin mousedown": function( a, b ) { | |
| $(a).closest("li.notification").attr("data-notificationid"); | |
| var c = $(b.target).attr("data-notif-ctp"), | |
| g = $(b.target).attr("data-pin-ctp"), | |
| h = $(b.target).attr("data-theme-id"); | |
| GS.service.logThemeOutboundLinkClick(parseInt(h), 401); | |
| GS.theme.loadTracking(c.split(",")); | |
| GS.theme.loadTracking(g.split(",")) | |
| }, | |
| "li.notification a.ie9_learnMore click": function( a, b ) { | |
| GS.getLightbox().open("ie9Promotion", { | |
| state: "pin" | |
| }); | |
| var c = $(a).closest("li.notification").attr("data-notificationid"), | |
| g = $(b.target).attr("data-notif-ctp"), | |
| h = $(b.target).attr("data-theme-id"); | |
| GS.service.logThemeOutboundLinkClick(parseInt(h), 402); | |
| GS.theme.loadTracking(g.split(",")); | |
| (c = this.notificationLookup[c]) && c.close() | |
| }, | |
| "li.notification a.gsAnywhereHoliday click": function( a, b ) { | |
| var c = $(a).closest("li.notification").attr("data-notificationid"), | |
| g = $(b.target).attr("data-notif-ctp"), | |
| h = $(b.target).attr("data-theme-id"); | |
| GS.service.logThemeOutboundLinkClick(parseInt(h), 400); | |
| GS.theme.loadTracking(g.split(",")); | |
| window.location = "#/settings/subscriptions"; | |
| (c = this.notificationLookup[c]) && c.close() | |
| }, | |
| displayLibraryAddedObject: function( a ) { | |
| var b = { | |
| controller: this | |
| }; | |
| if ( a.songs ) { | |
| if ( a.songs.length == 1 ) { | |
| b.msgKey = "NOTIF_LIBRARY_ADDED_SONG"; | |
| b.msgData = a.songs[0]; | |
| b.msgData.songLink = "<a class='songLink' rel='" + a.songs[0].songID + "'>" + a.songs[0].songName + "</a>"; | |
| b.msgData.artistLink = "<a href='" + _.cleanUrl(a.songs[0].artistName, a.songs[0].artistID, "artist", null, null) + "'>" + a.songs[0].artistName + "</a>"; | |
| b.object = a.songs[0].songID; | |
| b.type = "song" | |
| } else { | |
| b.msgKey = "NOTIFICATION_LIBRARY_ADD_SONGS"; | |
| b.msgData = { | |
| numSongs: a.songs.length | |
| }; | |
| b.type = "songs" | |
| } | |
| this.queueNotification(new GS.Notification({ | |
| view: "libraryAddedNotification", | |
| viewParams: b | |
| })) | |
| } | |
| }, | |
| displayFavoritedObject: function( a, b ) { | |
| function c(k) { | |
| if ( k.view == "libraryAddedNotification" && k.viewParams.type === "song" && k.viewParams.msgData ) if ( _.orEqual(k.viewParams.msgData.SongID, k.viewParams.msgData.songID) == _.orEqual(b.songID, b.SongID) ) return true; | |
| return false | |
| } | |
| var g, h; | |
| if ( b ) { | |
| if ( a == "song" ) { | |
| for ( g = 0; g < this.openNotifications.length; g++ ) { | |
| h = this.openNotifications[g]; | |
| c(h) && h.close() | |
| } | |
| for ( g = 0; g < this.queuedNotifications.length; g++ ) { | |
| h = this.queuedNotifications[g]; | |
| if ( c(h) ) { | |
| this.queuedNotifications.splice(g, 1); | |
| g-- | |
| } | |
| } | |
| } | |
| g = { | |
| controller: this, | |
| type: a, | |
| object: b | |
| }; | |
| switch ( a ) { | |
| case "playlist": | |
| g.msgKey = "NOTIF_SUBSCRIBED_PLAYLIST"; | |
| g.msgData = { | |
| playlistName: b.PlaylistName, | |
| playlistLink: "<a href='" + _.cleanUrl(b.PlaylistName, b.PlaylistID, "playlist", null, null) + "'>" + b.PlaylistName + "</a>" | |
| }; | |
| break; | |
| case "song": | |
| g.msgKey = "NOTIF_FAVORITED_SONG"; | |
| g.msgData = { | |
| songName: _.orEqual(b.SongName, b.songName), | |
| artistName: _.orEqual(b.ArtistName, b.artistName), | |
| songLink: "<a class='songLink' rel='" + b.SongID + "'>" + b.SongName + "</a>", | |
| artistLink: "<a href='" + _.cleanUrl(b.ArtistName, b.ArtistID, "artist", null, null) + "'>" + b.ArtistName + "</a>" | |
| }; | |
| break; | |
| case "user": | |
| if ( b.Username ) { | |
| g.msgKey = "NOTIF_FOLLOWED_USER"; | |
| g.msgData = { | |
| userName: b.Name, | |
| userLink: "<a href='" + _.cleanUrl(b.Name, b.UserID, "user", null, null) + "'>" + b.Name + "</a>" | |
| } | |
| } else { | |
| g.msgKey = "NOTIF_FOLLOWED_USERS"; | |
| g.msgData = {} | |
| } | |
| break; | |
| case "newPlaylist": | |
| g.msgKey = "NOTIF_CREATED_PLAYLIST"; | |
| g.msgData = { | |
| playlistName: b.PlaylistName, | |
| playlistLink: "<a href='" + _.cleanUrl(b.PlaylistName, b.PlaylistID, "playlist", null, null) + "'>" + b.PlaylistName + "</a>" | |
| }; | |
| break; | |
| case "artist": | |
| g.msgKey = "NOTIF_FOLLOWED_ARTIST"; | |
| g.msgData = { | |
| artistName: b.ArtistName, | |
| artistLink: "<a href='" + _.cleanUrl(b.ArtistName, b.ArtistID, "artist", null, null) + "'>" + b.ArtistName + "</a>" | |
| }; | |
| break | |
| } | |
| h = new GS.Notification({ | |
| view: "favoriteNotification", | |
| viewParams: g | |
| }); | |
| this.queueNotification(h) | |
| } | |
| }, | |
| "li.notification .favorited button.loginWithFacebook click": function( a, b ) { | |
| b.stopImmediatePropagation(); | |
| var c = this.notificationLookup[$(a).closest("li.notification").attr("data-notificationid")]; | |
| if ( c ) { | |
| console.log(c, c.endTimeout); | |
| c.duration = false; | |
| c.endTimeout(); | |
| $("button.loginWithFacebook", c.element).hide(); | |
| $("button.closeNotif", c.element).show(); | |
| GS.getFacebook().login(this.callback(function() { | |
| $("button.closeNotif", c.element).hide(); | |
| c.duration = 5E3; | |
| this.shareWithFacebook(c) | |
| })) | |
| } | |
| return false | |
| }, | |
| "li.notification .favorited button.shareWithFacebook click": function( a, b ) { | |
| b.stopImmediatePropagation(); | |
| this.shareWithFacebook(this.notificationLookup[$(a).closest("li.notification").attr("data-notificationid")]); | |
| return false | |
| }, | |
| shareWithFacebook: function( a ) { | |
| if ( a ) { | |
| a.element.removeClass("notification_success").addClass("notification_form"); | |
| $("button.shareWithFacebook", a.element).hide(); | |
| $("div.facebookShare", a.element).show(); | |
| $("div.content", a.element).prepend('<img src="/webincludes/images/notifications/facebook.png" />'); | |
| $("div.content p", a.element).addClass("hasIcon"); | |
| var b = $("#fb_share_message", a.element); | |
| b.focus(this.callback(function() { | |
| b.val() == $.localize.getString("NOTIF_SHARE_PREFILL_MSG") && b.val("") | |
| })); | |
| b.focusout(this.callback(function() { | |
| b.val() === "" && b.val($.localize.getString("NOTIF_SHARE_PREFILL_MSG")) | |
| })) | |
| } | |
| }, | |
| "li.notification .favorited button.shareWithFacebookSubmit click": function( a, b ) { | |
| b.stopImmediatePropagation(); | |
| var c = this.notificationLookup[$(a).closest("li.notification").attr("data-notificationid")]; | |
| if ( c ) { | |
| var g = c.viewParams.object, | |
| h = c.viewParams.type, | |
| k = $("#fb_share_message", c.element).val(); | |
| if ( k == $.localize.getString("NOTIF_SHARE_PREFILL_MSG") ) k = ""; | |
| console.log("sharing to facebook: ", h, g, k); | |
| switch ( h ) { | |
| case "song": | |
| GS.getFacebook().onFavoriteSong(g, k, true); | |
| break; | |
| case "playlist": | |
| GS.getFacebook().onSubscribePlaylist(g, k); | |
| break; | |
| case "newPlaylist": | |
| GS.getFacebook().onPlaylistCreate(g, k, true); | |
| break; | |
| case "user": | |
| GS.getFacebook().onFollowUser(g, k); | |
| break; | |
| case "artist": | |
| GS.getFacebook().onFollowArtist(g, k); | |
| break | |
| } | |
| c.close() | |
| } | |
| return false | |
| }, | |
| displayFacebookSent: function( a ) { | |
| if ( a && a.params && a.data ) { | |
| var b = this.uniquesLookup.facebook; | |
| b && b.close(); | |
| b = new GS.Notification({ | |
| uniqueInstance: "facebook", | |
| view: "facebookPostNotification", | |
| viewParams: { | |
| controller: this, | |
| type: a.params.type, | |
| hideUndo: a.params.hideUndo, | |
| ref: a.params.ref, | |
| data: a.data, | |
| object: a.params.object | |
| } | |
| }); | |
| this.queueNotification(b) | |
| } | |
| }, | |
| "li.notification .facebook button.undo click": function( a, b ) { | |
| b.stopImmediatePropagation(); | |
| var c = this.notificationLookup[$(a).closest("li.notification").attr("data-notificationid")]; | |
| if ( c ) { | |
| var g = c.viewParams.data; | |
| g.object = c.viewParams.object; | |
| GS.getFacebook().removeEvent(g); | |
| c.close() | |
| } | |
| return false | |
| }, | |
| "li.notification .facebook button.ok click": function( a, b ) { | |
| b.stopImmediatePropagation(); | |
| var c = this.notificationLookup[$(a).closest("li.notification").attr("data-notificationid")]; | |
| c && c.close(); | |
| return false | |
| }, | |
| "li.notification .facebook button.settings click": function( a, b ) { | |
| b.stopImmediatePropagation(); | |
| var c = this.notificationLookup[$(a).closest("li.notification").attr("data-notificationid")]; | |
| if ( c ) { | |
| c.close(); | |
| location.hash = "#/settings/services" | |
| } | |
| return false | |
| }, | |
| "li.notification .facebook a.resetPerms click": function( a, b ) { | |
| b.stopImmediatePropagation(); | |
| var c = this.notificationLookup[$(a).closest("li.notification").attr("data-notificationid")]; | |
| c && c.close(); | |
| GS.getFacebook().showReAuthLightbox(); | |
| return false | |
| }, | |
| "li.notification a.logoutFacebook click": function() { | |
| GS.auth.logout(function() { | |
| FB.logout(function() { | |
| location.hash = "#/signup"; | |
| GS.auth.loginViaFacebook() | |
| }) | |
| }) | |
| }, | |
| "li.notification a.logoutGoogle click": function() { | |
| GS.auth.logout(function() { | |
| location.hash = "#/signup"; | |
| GS.getGoogle().serviceLogout() | |
| }) | |
| }, | |
| displayFacebookUndoPost: function( a ) { | |
| if ( a.data ) { | |
| var b = "that one"; | |
| if ( a.params && a.params.object ) { | |
| b = a.params.object; | |
| b = _.orEqualEx(b.SongName, b.PlaylistName, b.ArtistName, b.AlbumName) | |
| }(a = this.uniquesLookup.facebook) && a.close(); | |
| a = new GS.Notification({ | |
| uniqueInstance: "facebook", | |
| view: "facebookUndoPostNotification", | |
| viewParams: { | |
| controller: this, | |
| msgData: { | |
| title: b | |
| }, | |
| msgKey: "NOTIF_FACEBOOK_SHARE_UNDO" | |
| } | |
| }); | |
| this.queueNotification(a) | |
| } | |
| }, | |
| displayFacebookCannotPost: function( a ) { | |
| var b = this.uniquesLookup.facebook; | |
| b && b.close(); | |
| b = new GS.Notification({ | |
| uniqueInstance: "facebook", | |
| view: "facebookCannotPostNotification", | |
| viewParams: { | |
| controller: this, | |
| notifLocale: a && a.notifLocale ? a.notifLocale : "POPUP_LOGIN_FACEBOOK_FLAGS" | |
| } | |
| }); | |
| this.queueNotification(b) | |
| }, | |
| "li.notification .facebook button.loginToFacebook click": function( a, b ) { | |
| b.stopImmediatePropagation(); | |
| var c = this.notificationLookup[$(a).closest("li.notification").attr("data-notificationid")]; | |
| if ( c ) { | |
| c.duration = false; | |
| c.endTimeout(); | |
| $("button.loginToFacebook", c.element).hide(); | |
| $("button.closeNotif", c.element).show(); | |
| GS.getFacebook().login(this.callback(function() { | |
| c.close() | |
| })) | |
| } | |
| return false | |
| }, | |
| displayFacebookRateLimit: function( a ) { | |
| if ( a.callback ) { | |
| var b = this.uniquesLookup.facebook; | |
| b && b.close(); | |
| b = new GS.Notification({ | |
| uniqueInstance: "facebook", | |
| view: "facebookRateLimitNotification", | |
| viewParams: { | |
| controller: this, | |
| callback: a.callback, | |
| type: a.type | |
| } | |
| }); | |
| this.queueNotification(b) | |
| } | |
| }, | |
| "li.notification .facebook button.doItAnyway click": function( a, b ) { | |
| b.stopImmediatePropagation(); | |
| var c = this.notificationLookup[$(a).closest("li.notification").attr("data-notificationid")]; | |
| if ( c ) { | |
| var g = c.viewParams.callback; | |
| g(); | |
| c.close() | |
| } | |
| return false | |
| }, | |
| "li.notification form.artistFeedback button click": function( a, b ) { | |
| b.stopImmediatePropagation(); | |
| var c = this.uniquesLookup.artistFeedback; | |
| if ( c ) { | |
| var g = $(a).attr("data-vote"), | |
| h = c.element.find("textarea").val(); | |
| c = c.viewParams.feedbackSong; | |
| h && h.length && GS.service.provideSongFeedbackMessage(c.SongID, h); | |
| GS.service.provideSongFeedbackVote(c.SongID, g, c.ArtistID, this.callback("onArtistFeedback", g), this.callback("onArtistFeedbackFail")) | |
| } | |
| return false | |
| }, | |
| displayFacebookConnect: function() { | |
| var a = this.uniquesLookup.facebook; | |
| a && a.close(); | |
| a = new GS.Notification({ | |
| uniqueInstance: "facebook", | |
| view: "facebookConnectNotification", | |
| viewParams: { | |
| controller: this | |
| }, | |
| duration: 1E4 | |
| }); | |
| this.queueNotification(a) | |
| }, | |
| "#fbNotifConnect-btn click": function( a ) { | |
| (a = this.notificationLookup[$(a).closest("li.notification").attr("data-notificationid")]) && a.close(); | |
| GS.getFacebook().login(function() {}, this.callback("fbConnectErrback")) | |
| }, | |
| fbConnectErrback: function( a ) { | |
| if ( typeof a == "object" && a.error ) a = a.error; | |
| this.queueNotification(new GS.Notification({ | |
| view: "notification", | |
| viewParams: { | |
| controller: this, | |
| notification: { | |
| type: "error", | |
| message: $.localize.getString(a) | |
| } | |
| }, | |
| duration: 5E3 | |
| })) | |
| }, | |
| displayFacebookFindFriends: function( a ) { | |
| var b = this.uniquesLookup.facebook; | |
| b && b.close(); | |
| a || (a = { | |
| message: false, | |
| inviteFriends: false | |
| }); | |
| b = new GS.Notification({ | |
| uniqueInstance: "facebook", | |
| view: "facebookFindFriendsNotification", | |
| viewParams: { | |
| controller: this, | |
| message: a.message, | |
| inviteFriends: a.inviteFriends | |
| }, | |
| duration: 1E4 | |
| }); | |
| this.queueNotification(b) | |
| }, | |
| "a.findFacebookFriends click": function( a, b ) { | |
| if ( b.which ) { | |
| var c = this.notificationLookup[$(a).closest("li.notification").attr("data-notificationid")]; | |
| c && c.close(); | |
| GS.getFacebook().getGroovesharkUsersFromFriends() | |
| } | |
| }, | |
| "a.inviteFriends click": function( a, b ) { | |
| if ( b.which ) { | |
| var c = this.notificationLookup[$(a).closest("li.notification").attr("data-notificationid")]; | |
| c && c.close(); | |
| GS.getLightbox().open("invite") | |
| } | |
| }, | |
| displayFacebookSongComment: function() { | |
| var a = | |
| this.uniquesLookup.facebook; | |
| a && a.close(); | |
| a = new GS.Notification({ | |
| uniqueInstance: "facebook", | |
| view: "facebookSongCommentNotification", | |
| viewParams: { | |
| controller: this | |
| }, | |
| duration: 1E4 | |
| }); | |
| this.queueNotification(a) | |
| }, | |
| "a.songLink click": function( a, b ) { | |
| b.preventDefault(); | |
| var c = parseInt($(a).attr("rel"), 10); | |
| c && GS.Models.Song.getSong(c, function( g ) { | |
| if ( g ) location.hash = g.toUrl() | |
| }) | |
| }, | |
| onArtistFeedback: function( a, b ) { | |
| var c = this.uniquesLookup.artistFeedback; | |
| if ( c ) { | |
| var g = { | |
| controller: this, | |
| feedbackSong: c.viewParams.feedbackSong | |
| }; | |
| if ( b.success && a == 2 ) { | |
| g.urls = b.urls; | |
| c.element.find(".content").html(this.view("artistNotificationResult", g)); | |
| _.isEmpty(b.urls) && c.beginTimeout(5E3) | |
| } else c.close() | |
| } | |
| }, | |
| onArtistFeedbackFail: function() { | |
| var a = this.uniquesLookup.artistFeedback; | |
| a && a.close() | |
| }, | |
| displayRestoreQueue: function() { | |
| if ( this.sawRestoreQueueNotification < 3 ) { | |
| this.queueNotification(new GS.Notification({ | |
| view: "restoreQueue", | |
| viewParams: { | |
| controller: this | |
| } | |
| })); | |
| this.sawRestoreQueueNotification++; | |
| GS.store.set("sawRestoreQueueNotification", this.sawRestoreQueueNotification) | |
| } | |
| }, | |
| "li.notification a.close click": function( a ) { | |
| (a = this.notificationLookup[$(a).closest("li.notification").attr("data-notificationid")]) && a.close() | |
| }, | |
| "li.notification .cancel click": function( a ) { | |
| (a = this.notificationLookup[$(a).closest("li.notification").attr("data-notificationid")]) && a.close() | |
| }, | |
| "form.feedback submit": function() { | |
| console.log("submit song feedback"); | |
| return false | |
| }, | |
| "li.notification .loginCTA click": function( a ) { | |
| (a = this.notificationLookup[$(a).closest("li.notification").attr("data-notificationid")]) && a.close(); | |
| GS.getLightbox().open("login") | |
| }, | |
| "li.notification .signupCTA click": function( a ) { | |
| (a = this.notificationLookup[$(a).closest("li.notification").attr("data-notificationid")]) && a.close(); | |
| location.hash = "#/signup" | |
| }, | |
| "li.notification.restoreQueue .restore click": function( a ) { | |
| (a = this.notificationLookup[$(a).closest("li.notification").attr("data-notificationid")]) && a.close(); | |
| GS.player.restoreQueue() | |
| }, | |
| "li.notification.restoreQueue a.settings click": function( a ) { | |
| (a = this.notificationLookup[$(a).closest("li.notification").attr("data-notificationid")]) && a.close(); | |
| if ( GS.user.isLoggedIn ) location.hash = "/settings"; | |
| else GS.getLightbox().open("login") | |
| }, | |
| "input focus": function( a ) { | |
| $(a).parent().parent().addClass("active") | |
| }, | |
| "textarea focus": function( a ) { | |
| $(a).parent().parent().parent().addClass("active") | |
| }, | |
| "input blur": function( a ) { | |
| $(a).parent().parent().removeClass("active") | |
| }, | |
| "textarea blur": function( a ) { | |
| $(a).parent().parent().parent().removeClass("active") | |
| }, | |
| ".selection_survey focus": function( a ) { | |
| a.parents(".input_wrapper").addClass("active") | |
| }, | |
| ".selection_survey blur": function( a ) { | |
| a.parents(".input_wrapper").removeClass("active") | |
| }, | |
| ".selection_survey keydown": function( a ) { | |
| a.change() | |
| }, | |
| ".selection_survey change": function( a ) { | |
| var b = a.siblings("span"); | |
| a = a.find("#profilerQuestion:selected"); | |
| b.html(a.html()); | |
| b.attr("value", a.attr("value")) | |
| } | |
| }); | |
| (function() { | |
| function a(b) { | |
| console.log("re-rendering language", b); | |
| $("[data-translate-text]").localize("gs", { | |
| language: b | |
| }); | |
| $("[data-translate-title]").localize("gs", { | |
| language: b, | |
| callback: "titleCallback" | |
| }) | |
| } | |
| GS.Controllers.BaseController.extend("GS.Controllers.LocaleController", { | |
| onWindow: true, | |
| isGSSingleton: true | |
| }, { | |
| locale: "en", | |
| init: function() { | |
| var b = this, | |
| c = (GS.store.get("gs.locale") || gsConfig.lang || this.detectLangauge() || this.locale).substring(0, 2); | |
| a(c); | |
| this.subscribe("gs.locale.changed", function( g ) { | |
| b.locale = | |
| g; | |
| a(g); | |
| $.publish("gs.locale.update", g); | |
| GS.store.set("gs.locale", g) | |
| }); | |
| this.locale = c; | |
| $.localize.ready ? console.log("locale is already ready") : this.subscribe("gs.locale.ready", this.callback(function() { | |
| console.log("localize controller got locale ready"); | |
| a(this.locale) | |
| })) | |
| }, | |
| detectLangauge: function() { | |
| var b = window.navigator; | |
| return b.language || b.browserLanguage || b.systemLanguage || b.userLanguage | |
| } | |
| }) | |
| })(); | |
| GS.Controllers.BaseController.extend("GS.Controllers.HeaderController", { | |
| onElement: "#header" | |
| }, { | |
| init: function() { | |
| this.subscribe("gs.auth.update", this.callback("update")); | |
| this.subscribe("gs.page.view", this.callback("updateSection")); | |
| this.subscribe("gs.router.history.change", this.callback("updateNavButtons")); | |
| this._super() | |
| }, | |
| appReady: function() { | |
| this.update() | |
| }, | |
| update: function() { | |
| this.user = GS.user; | |
| this.isDesktop = GS.airbridge ? GS.airbridge.isDesktop : false; | |
| var a = $("#dropdown_loginForm"); | |
| a.detach(); | |
| $("#header_userOptions").html(this.view(GS.user.isLoggedIn ? "loggedIn" : "loggedOut")); | |
| $("#header_mainNavigation").html(this.view("mainNavigation")); | |
| GS.user.isLoggedIn ? $("#loginFormHolder").append(a) : $("#putLoginFormHere").append(a); | |
| this.updateSection(GS.page.activePageName, GS.page.activePageIdentifier); | |
| this.updateNavButtons() | |
| }, | |
| updateSection: function( a ) { | |
| switch ( a ) { | |
| case "home": | |
| case "search": | |
| a = $("#header_search_btn"); | |
| a.hasClass("active") || a.addClass("active").siblings().removeClass("active"); | |
| break; | |
| case "explore": | |
| $("#header_explore_btn").addClass("active").siblings().removeClass("active"); | |
| break; | |
| case "music": | |
| GS.page.activePageIdentifier == GS.user.UserID ? $("#header_music_btn").addClass("active").siblings().removeClass("active") : $("#header_mainNavigation a").removeClass("active"); | |
| break; | |
| case "user": | |
| GS.page.activePageIdentifier == GS.user.UserID && GS.page.activePageParams.section == "community" ? $("#header_community_btn").addClass("active").siblings().removeClass("active") : $("#header_mainNavigation a").removeClass("active"); | |
| break; | |
| default: | |
| $("#header_mainNavigation a").removeClass("active") | |
| } | |
| }, | |
| updateFeedCount: function() { | |
| this.user = | |
| GS.user; | |
| this.isDesktop = GS.airbridge ? GS.airbridge.isDesktop : false; | |
| $("#header_mainNavigation").html(this.view("mainNavigation")); | |
| this.updateSection(GS.page.activePageName, GS.page.activePageIdentifier); | |
| this.updateNavButtons() | |
| }, | |
| updateNavButtons: function() { | |
| if ( GS.router && GS.airbridge.isDesktop ) { | |
| $("#header_back_btn").attr("disabled", !GS.router.hasBack); | |
| $("#header_forward_btn").attr("disabled", !GS.router.hasForward) | |
| } | |
| }, | |
| "#grooveshark click": function() { | |
| if ( $("#page").is(".gs_page_home") ) { | |
| $("input.search.autocomplete", "#page").blur(); | |
| $("#searchBar_input input").val() == "" && $("#searchBar_input span").show() | |
| } else setTimeout(function() { | |
| $("input.search.autocomplete", "#page").blur() | |
| }, 0) | |
| }, | |
| "#header_search_btn mousedown": function() { | |
| if ( $("#page").is(".gs_page_home") ) { | |
| $("input.search.autocomplete", "#page").focus(); | |
| $("#searchBar_input input").val() == "" && $("#searchBar_input span").show().addClass("faded"); | |
| $("#searchBar_input input").addClass("focused") | |
| } else var a = $.subscribe("gs.page.home.view", function() { | |
| setTimeout(function() { | |
| $("input.search.autocomplete", "#page").focus() | |
| }, 0); | |
| $("#searchBar_input span").show(); | |
| $.unsubscribe(a) | |
| }) | |
| }, | |
| "#header_forward_btn click": function() { | |
| GS.router.forward() | |
| }, | |
| "#header_back_btn click": function() { | |
| GS.router.back() | |
| }, | |
| "#header_login click": function( a ) { | |
| $(a).toggleClass("active"); | |
| $("#dropdown_loginForm_box").toggle(); | |
| if ( $("#dropdown_loginForm_box").is(":visible") ) { | |
| $("#dropdown_loginForm_box").find("input:first").focus(); | |
| this.element.find(".error").hide(); | |
| $("div.capital iframe").hide().parent().hide() | |
| } else { | |
| $("#dropdown_loginForm_box").find("input").blur(); | |
| $("div.capital iframe").show().parent().show() | |
| } | |
| var b = this; | |
| $("body").click(function( c ) { | |
| if (!$(c.target).parents("#dropdown_loginForm_box").length && !$(c.target).parents("#header_loginOption").length ) { | |
| b.closeLoginDropdown(); | |
| $("div.capital iframe").show().parent().show() | |
| } | |
| }) | |
| }, | |
| "#loginReplace click": function( a, b ) { | |
| $("#header_login").trigger("click"); | |
| b.preventDefault() | |
| }, | |
| closeLoginDropdown: function() { | |
| $("#dropdown_loginForm_box").hide(); | |
| $("#dropdown_loginForm_box").find("input").blur(); | |
| $("#header_login").removeClass("active") | |
| }, | |
| "a.account click": function() { | |
| function a(c) { | |
| if ( c.target !== b.target ) { | |
| $("#header_account_button").removeClass("active"); | |
| $("#header_userSelectOptions").hide(); | |
| $("div.capital iframe").show().parent().show(); | |
| $(document).unbind("click", a) | |
| } | |
| } | |
| var b; | |
| return function( c, g ) { | |
| b = g; | |
| $(c).toggleClass("active"); | |
| $("#header_userSelectOptions").toggle(); | |
| $("#header_userSelectOptions").is(":visible") ? $("div.capital iframe").hide().parent().hide() : $("div.capital iframe").show().parent().show(); | |
| $(document).unbind("click contextmenu", a).bind("click contextmenu", a) | |
| } | |
| }(), | |
| "ul.dropdownOptions li.option a click": function() { | |
| $("#header_account_button").removeClass("active"); | |
| $("#header_userSelectOptions").hide() | |
| }, | |
| "a.locale click": function() { | |
| GS.getLightbox().open("locale") | |
| }, | |
| "a.invite click": function() { | |
| GS.user.UserID > 0 && GS.getLightbox().open("invite") | |
| }, | |
| "a.feedback click": function() { | |
| GS.user.IsPremium && GS.getLightbox().open("feedback", { | |
| type: "preview" | |
| }) | |
| }, | |
| "a.logout click": function() { | |
| GS.auth.logout() | |
| }, | |
| "input focus": function( a ) { | |
| $(a).parent().parent().addClass("active") | |
| }, | |
| "textarea focus": function( a ) { | |
| $(a).parent().parent().parent().addClass("active") | |
| }, | |
| "input blur": function( a ) { | |
| $(a).parent().parent().removeClass("active") | |
| }, | |
| "textarea blur": function( a ) { | |
| $(a).parent().parent().parent().removeClass("active") | |
| }, | |
| showError: function( a ) { | |
| $("div.message", this.element).html($.localize.getString(a)); | |
| this.element.find(".error").show() | |
| }, | |
| showMessage: function( a ) { | |
| $("div.message", this.element).html(a); | |
| this.element.find(".error").show() | |
| }, | |
| "form#dropdown_loginForm submit": function( a ) { | |
| this.element.find(".error").hide(); | |
| var b = $("input[name=username]", a).val(), | |
| c = $("input[name=password]", a).val(); | |
| a = $("input[name=save]", a).val() ? 1 : 0; | |
| switch ( b.toLowerCase() ) { | |
| case "dbg:googlelogin": | |
| GS.getGoogle().lastError ? this.showMessage("Last Google Login Error: " + JSON.stringify(GS.getGoogle().lastError)) : this.showMessage("There does not appear to be any errors with Google Login"); | |
| break; | |
| case "dbg:facebooklogin": | |
| GS.getFacebook().lastError ? this.showMessage("Last Facebook Login Error: " + JSON.stringify(GS.getFacebook().lastError)) : this.showMessage("There does not appear to be any errors with Facebook Login"); | |
| break; | |
| default: | |
| GS.auth.login(b, c, a, this.callback(this.loginSuccess), this.callback(this.loginFailed)); | |
| break | |
| } | |
| }, | |
| "button.facebookLogin click": function() { | |
| GS.auth.loginViaFacebook(null, this.callback(this.extLoginFailed)); | |
| this.closeLoginDropdown() | |
| }, | |
| "button.googleLogin click": function() { | |
| GS.auth.loginViaGoogle(null, this.callback(this.extLoginFailed)); | |
| this.closeLoginDropdown() | |
| }, | |
| loginSuccess: function() { | |
| this.closeLoginDropdown() | |
| }, | |
| loginFailed: function( a ) { | |
| if ( a.error ) this.showError(a.error); | |
| else a && a.userID == 0 ? this.showError("POPUP_SIGNUP_LOGIN_FORM_AUTH_ERROR") : this.showError("POPUP_SIGNUP_LOGIN_FORM_GENERAL_ERROR") | |
| }, | |
| extLoginFailed: function( a ) { | |
| var b = { | |
| error: "POPUP_SIGNUP_LOGIN_FORM_GENERAL_ERROR", | |
| premiumRequired: gsConfig.isPreview, | |
| notCloseable: gsConfig.isPreview | |
| }; | |
| if ( a.error ) b.error = a.error; | |
| else if ( a && a.authType == "facebook" ) b.error = "POPUP_SIGNUP_LOGIN_FORM_FACEBOOK_ERROR"; | |
| else if ( a && a.authType == "google" ) b.error = "POPUP_SIGNUP_LOGIN_FORM_GOOGLE_ERROR"; | |
| GS.getLightbox().open("login", b) | |
| }, | |
| "a.loginLink click": function() { | |
| $("#dropdown_loginForm_box").hide(); | |
| $("#dropdown_loginForm_box").find("input").blur(); | |
| $("#header_login").removeClass("active") | |
| }, | |
| "a.forget click": function() { | |
| GS.getLightbox().open("forget") | |
| } | |
| }); | |
| GS.Controllers.BaseController.extend("GS.Controllers.AdController", { | |
| isGSSingleton: true | |
| }, { | |
| rotateTimer: 0, | |
| rotationTime: 45E3, | |
| defaultRotationTime: 45E3, | |
| maxRotationTime: 9E4, | |
| lastActive: null, | |
| maxIdleTime: 36E4, | |
| lastIdleTime: null, | |
| lastRotation: null, | |
| rotationCountPerImpression: 0, | |
| useTestAds: false, | |
| rotationCount: 0, | |
| sessionStart: null, | |
| lastAdChange: null, | |
| chooseAdLimit: 4E3, | |
| clickAdCatchTimeout: null, | |
| lastActivePage: null, | |
| campaignArtists: {}, | |
| campaignsByCampaignID: {}, | |
| userCampaigns: [], | |
| locales: { | |
| en: "1", | |
| bg: "2", | |
| ca: "3", | |
| cs: "4", | |
| da: "5", | |
| de: "6", | |
| es: "7", | |
| eu: "8", | |
| fi: "9", | |
| fr: "10", | |
| it: "11", | |
| ja: "12", | |
| lt: "13", | |
| nb: "14", | |
| nl: "15", | |
| pl: "16", | |
| pt: "17", | |
| ro: "18", | |
| ru: "19", | |
| sk: "20", | |
| sl: "21", | |
| sv: "22", | |
| tr: "23", | |
| zh: "24" | |
| }, | |
| adPlacements: ["home_160x600", "search_song_300x250", "search_artist_300x250", "search_album_300x250", "search_playlist_300x250", "search_user_300x250", "search_event_300x250", "search_song_728x90", "search_artist_728x90", "search_album_728x90", "search_playlist_728x90", "search_user_728x90", "search_event_728x90", "explore_featured_300x250", "explore_popular_300x250", "explore_stations_300x250", "explore_playlists_300x250", "explore_popular_728x90", "explore_videos_300x250", "mymusic_songs_160x600", "mymusic_favorites_160x600", "mymusic_playlists_overview_160x600", "mymusic_playlists_subscribed_160x600", "community_activity_300x250", "community_activity_728x90", "community_mentions_300x250", "playlist_music_300x250", "playlist_albums_300x250", "playlist_subscribers_300x250", "playlist_music_728x90", "artist_profile_300x250", "artist_songs_300x250", "artist_albums_300x250", "artist_events_300x250", "artist_profile_728x90", "album_overview_300x250", "song_overview_300x250", "song_overview_728x90", "myprofile_activity_300x250", "myprofile_following_300x250", "myprofile_fans_300x250", "myprofile_activity_728x90", "profile_activity_300x250", "profile_music_300x250", "profile_favorites_300x250", "profile_playlists_300x250", "profile_community_300x250", "profile_following_300x250", "profile_fans_300x250", "profile_activity_728x90"], | |
| init: function() { | |
| this.sessionStart = (new Date).getTime(); | |
| this.lastActive = new Date; | |
| this.subscribe("gs.auth.update", this.callback(this.update)); | |
| this.subscribe("gs.player.nowplaying", this.callback(this.onSongPlay)); | |
| this.subscribe("gs.app.resize", this.callback(this.adSpecific)); | |
| this.subscribe("gs.drag.start", function() { | |
| $("div.capital iframe").hide().parent().hide() | |
| }); | |
| this.subscribe("gs.drag.end", function() { | |
| $("div.capital iframe").show().parent().show() | |
| }); | |
| this.subscribe("gs.menu.show", function() { | |
| $("div.capital iframe").hide().parent().hide() | |
| }); | |
| this.subscribe("gs.menu.hide", function() { | |
| setTimeout(function() { | |
| $("#lightbox:visible").length || $("div.capital iframe").show().parent().show() | |
| }, 10) | |
| }); | |
| var a = this; | |
| $("body").bind("mousemove", function() { | |
| a.lastActive = new Date | |
| }); | |
| this._super() | |
| }, | |
| appReady: function() { | |
| this.update() | |
| }, | |
| update: function() { | |
| this.user = GS.user; | |
| this.parseCampaignsForUser(); | |
| GS.user.IsPremium && this.startAdTimer(); | |
| GS.resize() | |
| }, | |
| onSongPlay: function( a ) { | |
| if ( this.campaignArtists && this.campaignArtists[a.ArtistID] instanceof Array ) for ( var b = 0; b < this.campaignArtists[a.ArtistID].length; b++ ) { | |
| var c = this.campaignArtists[a.ArtistID][b]; | |
| if ( c ) { | |
| var g = | |
| this.campaignsByCampaignID[c]; | |
| if (!g ) { | |
| g = { | |
| id: c, | |
| count: 1 | |
| }; | |
| this.campaignsByCampaignID[c] = g; | |
| this.userCampaigns.push(g) | |
| } | |
| } | |
| } | |
| }, | |
| parseCampaignsForUser: function() { | |
| this.userCampaigns = []; | |
| this.campaignsByCampaignID = {}; | |
| var a = GS.store.get("artistsPlayed" + (this.user ? this.user.UserID : -1)); | |
| if ( this.campaignArtists && a ) for ( var b = 0; b < a.length; b++ ) { | |
| var c = a[b]; | |
| if ( c && this.campaignArtists[c] instanceof Array ) for ( var g = 0; g < this.campaignArtists[c].length; g++ ) { | |
| var h = this.campaignArtists[c][g]; | |
| if ( h ) { | |
| var k = this.campaignsByCampaignID[h]; | |
| if ( k ) k.count++; | |
| else { | |
| k = { | |
| id: h, | |
| count: 1 | |
| }; | |
| this.campaignsByCampaignID[h] = k; | |
| this.userCampaigns.push(k) | |
| } | |
| } | |
| } | |
| } | |
| }, | |
| showAdBar: function() { | |
| $("#capitalSidebar").width(170).show(); | |
| GS.resize() | |
| }, | |
| startAdTimer: function() { | |
| if ( GS.theme.themeIsReady ) { | |
| clearInterval(this.rotateTimer); | |
| this.rotateTimer = setInterval(this.callback("onRotateTimer"), this.defaultRotationTime); | |
| this.chooseAd() | |
| } | |
| }, | |
| resetAdTimer: function() { | |
| if ( GS.theme.themeIsReady ) { | |
| clearInterval(this.rotateTimer); | |
| this.rotateTimer = setInterval(this.callback("onRotateTimer"), this.defaultRotationTime) | |
| } | |
| }, | |
| hideAdBar: function() { | |
| $("#capitalSidebar").hide().width(0); | |
| $("#sidebarCapital_160").children("iframe").attr("src", ""); | |
| GS.resize(); | |
| GS.player && GS.player.updateQueueWidth() | |
| }, | |
| onRotateTimer: function() { | |
| if ( this.lastActive && !GS.user.IsPremium ) { | |
| var a = (new Date).valueOf(), | |
| b = a - (this.lastActive ? this.lastActive.valueOf() : 0); | |
| this.lastRotation && this.lastRotation.valueOf(); | |
| if ( b <= this.maxIdleTime ) this.chooseAd(); | |
| else this.lastIdleTime = a | |
| } | |
| }, | |
| adAction: function( a ) { | |
| if ( a ) if ( $(a.target).hasClass("stopAdAction") ) return; | |
| a = (new Date).getTime(); | |
| if ( GS.theme.themeIsReady && !GS.user.IsPremium && !this.clickAdCatchTimeout && (!this.lastAdChange || a - this.lastAdChange > this.chooseAdLimit) ) this.chooseAd() | |
| }, | |
| chooseAd: function() { | |
| $("div.capital iframe:visible").length !== 0 && setTimeout(this.callback(function() { | |
| this.lastRotation = new Date; | |
| this.updateAds(); | |
| GS.getGuts().logEvent("adRotation", {}) | |
| }), 100) | |
| }, | |
| buildParams: function( a, b, c ) { | |
| a = a instanceof Array ? a : []; | |
| b = _.orEqual(b, "?"); | |
| c = _.orEqual(c, "&"); | |
| GS.player && GS.player.getCurrentSong() && a.push("2=" + GS.player.getCurrentSong().ArtistID); | |
| if ( GS.user.isLoggedIn ) { | |
| if ( GS.user.Sex ) a.push("1=" + (GS.user.Sex.toLowerCase() == "m" ? "0" : "1")); | |
| if ( GS.user.TSDOB ) { | |
| var g = GS.user.TSDOB.split("-"); | |
| if ( g.length == 3 ) { | |
| var h = new Date, | |
| k = h.getFullYear() - parseInt(g[0], 10); | |
| if ( parseInt(g[1], 10) > h.month ) k -= 1; | |
| else if ( parseInt(g[1], 10) == h.month && parseInt(g[2], 10) > h.date ) k -= 1; | |
| var m; | |
| if ( k >= 13 && k < 18 ) m = "1"; | |
| else if ( k >= 18 && k < 25 ) m = "2"; | |
| else if ( k >= 25 && k < 35 ) m = "3"; | |
| else if ( k >= 35 && k < 50 ) m = "4"; | |
| else if ( k >= 50 ) m = "5"; | |
| k >= 21 && a.push("a=1"); | |
| m && a.push("10=" + m); | |
| a.push("14=" + this.encodeInteger(k)) | |
| } | |
| } | |
| } | |
| a.push("3=" + Math.round(((new Date).getTime() - this.sessionStart) / 1E3)); | |
| a.push("4=" + this.rotationCount); | |
| a.push("5=" + ((GS.user.settings.local.themeFlags & GS.theme.THEME_FLAG_FAMILY_FRIENDLY) == GS.theme.THEME_FLAG_FAMILY_FRIENDLY ? 1 : 0)); | |
| GS.theme.currentTheme && GS.theme.currentTheme.sections.indexOf("#theme_page_header") >= 0 && a.push("6=1"); | |
| if ( GS.Controllers.PageController.activePageName && GS.Controllers.PageController.activePageName.toLowerCase() == "home" ) a.push("9=1"); | |
| else GS.Controllers.PageController.activePageName && GS.Controllers.PageController.activePageName.toLowerCase() == "search" && (!GS.search.type || GS.search.type === "" || GS.search.type == "everything") ? a.push("9=2") : a.push("9=0"); | |
| if ( GS.theme && GS.theme.currentTheme )(g = parseInt(GS.theme.currentTheme.themeID, 10)) && a.push("11=" + g); | |
| if ( GS.player && GS.player.queue && GS.player.queue.currentAutoplayTagID ) { | |
| a.push("12=1"); | |
| a.push("13=" + GS.player.queue.currentAutoplayTagID) | |
| } | |
| a.push("15=" + this.rotationCountPerImpression); | |
| gsConfig && gsConfig.isPreview && a.push("16=1"); | |
| if ( GS.user.UserID > 0 ) if ( GS.user.Flags & GS.Models.FLAG_ISARTIST ) a.push("17=1"); | |
| else GS.user.Flags & GS.Models.FLAG_MUSIC_BUSINESS && a.push("17=2"); | |
| if ( g = GS.theme.getRecentSeen() ) for ( h = 0; h < g.length; h++ ) a.push("rec" + g[h] + "=1"); | |
| if ( GS.IE ) { | |
| if ( GS.IE.canPin ) if ( GS.IE.canPin && !GS.IE.isPinned ) a.push("ie=1"); | |
| else GS.IE.isPinned && a.push("ie=2"); | |
| else a.push("ie=0"); | |
| GS.IE.firstPin && !GS.theme.lastTheme && a.push("ie2=1") | |
| } | |
| this.useTestAds && a.push("testAds=1"); | |
| if (!GS.user.IsPremium && !GS.user.isLoggedIn ) if ((g = | |
| GS.store.get("webvisit")) && g.sidebar ) a = a.concat(GS.store.get("webvisit").sidebar); | |
| else if ((g = GS.store.get("krux")) && g.params ) a = a.concat(GS.store.get("krux").params); | |
| var p; | |
| try { | |
| p = "0="; | |
| p += this.locales[GS.getLocale().locale] | |
| } catch (n) { | |
| p = "0=1" | |
| } | |
| a = a.concat([p]); | |
| return b + a.join(c) | |
| }, | |
| encodeInteger: function( a ) { | |
| a = a.toString(2).split(""); | |
| for ( var b = 1, c = a.length, g = 0; b < c; ) { | |
| a.splice(b + g, 0, 0); | |
| b += 3; | |
| g++ | |
| } | |
| return (parseInt(a.join(""), 2) * 751).toString(16) | |
| }, | |
| decodeInteger: function( a ) { | |
| a = (parseInt(a, 16) / 751).toString(2).split(""); | |
| for ( var b = 1, c = 0; a[b + c] !== undefined; ) { | |
| a[b + c] = null; | |
| b += 3; | |
| c++ | |
| } | |
| return parseInt(a.join(""), 2) | |
| }, | |
| buildAd: function( a, b, c, g ) { | |
| if ( a && a.length ) { | |
| g || (g = []); | |
| if ( a.data("data-user-activity") == undefined ) { | |
| a.data("data-user-activity", null); | |
| a.live("mouseover", function() { | |
| $(this).data("data-user-activity", (new Date).getTime() + 9E4) | |
| }); | |
| a.live("mouseout", function() { | |
| $(this).data("data-user-activity", null) | |
| }) | |
| } | |
| $page = $("#page_content"); | |
| for ( var h = 0; h < g.length; h++ ) { | |
| var k = g[h].split("="); | |
| if ( k.length > 1 && k[0] == "p" ) g[h] = GS.getAd().adPlacements.indexOf(k[1] + "_" + b + "x" + c) >= 0 ? g[h] : "p=default" | |
| } | |
| a.data("data-iframe-width", b).data("data-iframe-height", c).data("data-iframe-params", g.concat()).data("data-iframe-born", (new Date).getTime()); | |
| g = GS.getAd().buildParams(g.concat(["w=" + b, "h=" + c])); | |
| var m = a.children("iframe"), | |
| p; | |
| if ( m.length > 1 ) { | |
| for ( c = m.length - 1; c > 0; c-- ) | |
| m.eq(c).unbind("load").remove(); | |
| m = m.eq(0); | |
| p = m.clone() | |
| } else p = $('<iframe height="' + c + '" width="' + b + '" class="capitalFrame_' + b + '" frameborder="0" allowTransparency="true"></iframe>'); | |
| p.css("visibility", "hidden"); | |
| p.bind("load", this.callback(function() { | |
| m.unbind("load").remove(); | |
| p.css("visibility", "visible").width(0); | |
| a.parent().show(); | |
| if ( b == 728 || b == 160 ) { | |
| a.parent().parent().show(); | |
| this.adSpecific(); | |
| $("#capitalSidebar .capitalView_160").scrollTop(0) | |
| } | |
| setTimeout(function() { | |
| p.width(b) | |
| }, 100); | |
| setTimeout(function() { | |
| p.width(b - 1); | |
| p.width(b + 1) | |
| }, 1500) | |
| })); | |
| this.lastAdChange = (new Date).getTime(); | |
| this.resetAdTimer(); | |
| p.attr("src", "/dfpAds.html" + g); | |
| a.append(p) | |
| } | |
| }, | |
| updateAds: function() { | |
| setTimeout(this.callback(function() { | |
| if (!this.lastActivePage || this.lastActivePage != GS.Controllers.PageController.activePageName + (GS.Controllers.PageController.activePage ? GS.Controllers.PageController.activePage.subpage : "") ) this.lastActivePage = GS.Controllers.PageController.activePageName + (GS.Controllers.PageController.activePage ? GS.Controllers.PageController.activePage.subpage : ""); | |
| else { | |
| this.lastActivePage = GS.Controllers.PageController.activePageName + (GS.Controllers.PageController.activePage ? GS.Controllers.PageController.activePage.subpage : ""); | |
| var a = (new Date).getTime(); | |
| if ( $(".capital").length ) { | |
| $(".capital").each(this.callback(function( b, c ) { | |
| c = $(c); | |
| if ( a - c.data("data-iframe-born") > this.chooseAdLimit && (!c.data("data-user-activity") || c.data("data-user-activity") < a) ) c.data("data-iframe-width") && c.data("data-iframe-height") && c.data("data-iframe-params") && this.buildAd(c, c.data("data-iframe-width"), c.data("data-iframe-height"), c.data("data-iframe-params")) | |
| })); | |
| this.updateRotationCount() | |
| } | |
| } | |
| }), 500) | |
| }, | |
| updateRotationCount: function() { | |
| this.rotationCount++; | |
| this.rotationCountPerImpression++; | |
| if ( GS.theme && !GS.theme.hasSeenRotationCount ) GS.theme.hasSeenRotationCount = this.rotationCountPerImpression >= 3 | |
| }, | |
| adSpecific: function() { | |
| if ( $(".capital_728").length && $(".capital_728").is(":visible") ) { | |
| var a = $(".capital_728"), | |
| b = $(".capitalWrapper_728"), | |
| c = $(".capitalSliderBtn"), | |
| g = $(".capitalView_728"); | |
| g.scrollLeft(g.scrollLeft() / 0.5); | |
| if ( b.width() < a.width() + 42 ) { | |
| if (!c.is(":visible") ) { | |
| c.show(); | |
| a.css({ | |
| left: 0, | |
| marginLeft: 0 | |
| }); | |
| g.css({ | |
| left: "21px" | |
| }) | |
| } | |
| g.css({ | |
| width: b.width() - 42 + "px" | |
| }) | |
| } else if ( c.is(":visible") ) { | |
| c.hide(); | |
| a.css({ | |
| left: "50%", | |
| marginLeft: "-364px" | |
| }); | |
| g.css({ | |
| width: "100%", | |
| left: 0 | |
| }) | |
| } | |
| } else if ( $("#capitalSidebar .capital_160").length && $("#capitalSidebar .capital_160").is(":visible") ) { | |
| a = $("#capitalSidebar .capital_160"); | |
| b = $("#capitalSidebar .capitalWrapper_160"); | |
| c = $("#capitalSidebar .capitalSliderBtnRev"); | |
| g = $("#capitalSidebar .capitalView_160"); | |
| if ( b.height() < a.height() + 48 ) { | |
| if (!c.is(":visible") ) { | |
| c.show(); | |
| g.css({ | |
| top: "24px" | |
| }) | |
| } | |
| g.css({ | |
| height: b.height() - 48 + "px" | |
| }) | |
| } else if ( c.is(":visible") ) { | |
| c.hide(); | |
| g.css({ | |
| height: "100%", | |
| top: 0 | |
| }) | |
| } | |
| } else if ( $("#page_wrapper .capital_160").length && $("#page_wrapper .capital_160").is(":visible") ) { | |
| a = $("#page_wrapper .capital_160"); | |
| b = $("#page_wrapper .capitalWrapper_160"); | |
| c = $("#page_wrapper .capitalSliderBtnRev"); | |
| g = $("#page_wrapper .capitalView_160"); | |
| if ( b.height() < a.height() + 42 ) { | |
| if (!c.is(":visible") ) { | |
| c.show(); | |
| g.css({ | |
| top: "21px" | |
| }) | |
| } | |
| g.css({ | |
| height: b.height() - 42 + "px" | |
| }) | |
| } else if ( c.is(":visible") ) { | |
| c.hide(); | |
| g.css({ | |
| height: "100%", | |
| top: 0 | |
| }) | |
| } | |
| } | |
| }, | |
| "#capitalSidebar .capitalSliderBtnRev click": function( a ) { | |
| a = | |
| $(a); | |
| $(a).hasClass("capitalSliderDown") ? $("#capitalSidebar .capitalView_160").animate({ | |
| scrollTop: $("#capitalSidebar .capitalView_160").scrollTop() + 200 | |
| }, 500) : $("#capitalSidebar .capitalView_160").animate({ | |
| scrollTop: $("#capitalSidebar .capitalView_160").scrollTop() - 200 | |
| }, 500) | |
| } | |
| }); | |
| GS.Controllers.BaseController.extend("GS.Controllers.SidebarController", { | |
| onElement: "#sidebar", | |
| isGSSingleton: true, | |
| preSetup: function() { | |
| var a = GS.Controllers.BaseController.singletonCallback, | |
| b = $.subscribe; | |
| b("gs.auth.update", a("sidebar", "update")); | |
| b("gs.auth.pinboard.update", a("sidebar", "populateByType")); | |
| b("gs.auth.playlists.update", a("sidebar", "populateByType", { | |
| type: "playlists" | |
| })); | |
| b("gs.auth.favorites.playlists.update", a("sidebar", "populateByType", { | |
| type: "subscribedPlaylists" | |
| })); | |
| b("gs.page.view", a("sidebar", "updateSection")); | |
| b("gs.app.ready", a("sidebar", "update")) | |
| } | |
| }, { | |
| playlists: [], | |
| subscribedPlaylists: [], | |
| stations: [], | |
| sortBy: "sidebarSort", | |
| doingSubscribed: false, | |
| doResize: true, | |
| isOpen: false, | |
| init: function() { | |
| var a = GS.store.get("gs.sort.sidebar"); | |
| if (["sidebarSort", "PlaylistName"].indexOf(a) != -1 ) this.sortBy = a; | |
| this.subscribe("gs.auth.sidebar.loaded", this.callback(function() { | |
| this.populateByType({ | |
| type: "all" | |
| }) | |
| })); | |
| this.subscribe("gs.app.resize", this.callback("resize")); | |
| this._super() | |
| }, | |
| appReady: function() { | |
| this.update() | |
| }, | |
| updateSection: function( a ) { | |
| if ( a === "music" ) if ( GS.user.UserID == GS.page.activePageIdentifier && !GS.page.activePageParams.subpage ) $("#sidebar_music_collection_link").addClass("active").siblings().removeClass("active"); | |
| else if ( GS.user.UserID == GS.page.activePageIdentifier && GS.page.activePageParams.subpage == "favorites" ) $("#sidebar_favorites_link").addClass("active").siblings().removeClass("active"); | |
| else GS.user.UserID == GS.page.activePageIdentifier && GS.page.activePageParams.subpage == "playlists" ? $("#sidebar_playlists_link").addClass("active").siblings().removeClass("active") : $("#sidebar_music_navigation a").removeClass("active"); | |
| else $("#sidebar_music_navigation a").removeClass("active") | |
| }, | |
| show: function() { | |
| if (!this.isOpen ) { | |
| this.isOpen = true; | |
| this.element.addClass("active").removeClass("hide").width(180); | |
| if ( this.tinyScrollbar ) this.tinyScrollbar.update(); | |
| else this.tinyScrollbar = $("#sidebar_pinboard").tinyscrollbar({ | |
| animationOptions: { | |
| duration: 50, | |
| easing: "linear" | |
| } | |
| }); | |
| GS.resize() | |
| } | |
| }, | |
| hide: function() { | |
| if ( this.isOpen ) { | |
| this.isOpen = false; | |
| this.element.removeClass("active").addClass("hide").width(0); | |
| GS.resize() | |
| } | |
| }, | |
| resize: function() { | |
| this.tinyScrollbar && !this.element.hasClass("hide") && this.tinyScrollbar.update() | |
| }, | |
| update: function() { | |
| if ( GS.user ) { | |
| this.user = GS.user; | |
| this.element.html(this.view("index")); | |
| this.populateByType({ | |
| type: "all" | |
| }); | |
| this.beginDragDrop() | |
| } | |
| }, | |
| changeSort: function( a ) { | |
| this.sortBy = a; | |
| this.populateByType({ | |
| type: "all" | |
| }); | |
| GS.store.set("gs.sort.sidebar", a) | |
| }, | |
| playlistSort: function( a, b ) { | |
| var c, g; | |
| try { | |
| if ( this.sortBy === "sidebarSort" ) { | |
| c = a[this.sortBy]; | |
| g = b[this.sortBy] | |
| } else { | |
| c = a[this.sortBy].toString().toLowerCase(); | |
| g = b[this.sortBy].toString().toLowerCase() | |
| } | |
| } catch (h) {} | |
| return c == g ? 0 : c > g ? 1 : -1 | |
| }, | |
| populateByType: function( a ) { | |
| if ( GS.user.sidebarLoaded ) switch ( a.type ) { | |
| case "all": | |
| this.populateSidebarStations(); | |
| this.populateSidebarSubscribedPlaylists(); | |
| this.populateSidebarPlaylists(); | |
| this.populateSidebarSongs(); | |
| this.populateSidebarArtists(); | |
| this.populateSidebarAlbums(); | |
| break; | |
| case "playlists": | |
| this.populateSidebarPlaylists(); | |
| break; | |
| case "subscribedPlaylists": | |
| this.populateSidebarSubscribedPlaylists(); | |
| break; | |
| case "stations": | |
| this.populateSidebarStations(); | |
| break; | |
| case "songs": | |
| this.populateSidebarSongs(); | |
| break; | |
| case "artists": | |
| this.populateSidebarArtists(); | |
| break; | |
| case "albums": | |
| this.populateSidebarAlbums(); | |
| break | |
| } | |
| }, | |
| populateSidebarPlaylists: function() { | |
| if ( GS.user.sidebarLoaded ) { | |
| this.playlists = []; | |
| for ( var a = GS.user.sidebar.playlists, b = 0; b < a.length; b++ ) { | |
| var c = GS.user.playlists[a[b]]; | |
| if ( c ) { | |
| c.sidebarSort = b + 1; | |
| this.playlists.push(c) | |
| } | |
| } | |
| this.playlists.sort(this.callback(this.playlistSort)); | |
| this.showPlaylists() | |
| } | |
| }, | |
| populateSidebarSubscribedPlaylists: function() { | |
| if ( GS.user.sidebarLoaded ) { | |
| this.subscribedPlaylists = []; | |
| for ( var a = GS.user.sidebar.subscribedPlaylists, b = 0; b < a.length; b++ ) { | |
| var c = a[b], | |
| g = GS.Models.Playlist.getOneFromCache(c), | |
| h = g ? g.PlaylistName : GS.user.sidebar.meta.subscribedPlaylists[c]; | |
| if ( g ) { | |
| if ( g.UserID !== GS.user.UserID ) { | |
| g.sidebarSort = b + 1; | |
| this.subscribedPlaylists.push(g) | |
| } | |
| } else h ? this.subscribedPlaylists.push({ | |
| PlaylistID: c, | |
| PlaylistName: h, | |
| sidebarSort: b + 1 | |
| }) : console.log("subscribedPlaylist shortcut with no name!", c) | |
| } | |
| this.subscribedPlaylists.sort(this.callback(this.playlistSort)); | |
| this.showSubscribedPlaylists() | |
| } | |
| }, | |
| populateSidebarStations: function() { | |
| if ( GS.user.sidebarLoaded ) { | |
| this.stations = []; | |
| var a, b, c, g, h = GS.user.sidebar.stations; | |
| c = 0; | |
| for ( g = h.length; c < g; c++ ) { | |
| a = h[c]; | |
| if ( b = GS.Models.Station.getOneFromCache(a) ) if ( b = b.StationTitle ) { | |
| b = { | |
| StationID: a, | |
| Station: b, | |
| Name: b, | |
| PlaylistName: b, | |
| sidebarSort: c + 1 | |
| }; | |
| this.stations.push(b) | |
| } | |
| } | |
| this.stations.sort(this.callback(this.playlistSort)); | |
| this.showStations() | |
| } | |
| }, | |
| populateSidebarSongs: function() { | |
| if ( GS.user.sidebarLoaded ) { | |
| this.songs = []; | |
| for ( var a = GS.user.sidebar.songs, b = 0; b < a.length; b++ ) { | |
| var c = | |
| a[b], | |
| g = GS.Models.Song.getOneFromCache(c); | |
| (g = g ? g.SongName : GS.user.sidebar.meta.songs[c]) ? this.songs.push({ | |
| SongName: g, | |
| SongID: c, | |
| sidebarSort: b + 1 | |
| }) : console.log("song shortcut with no name!", c) | |
| } | |
| this.songs.sort(this.callback(this.playlistSort)); | |
| this.showSongs() | |
| } | |
| }, | |
| populateSidebarArtists: function() { | |
| if ( GS.user.sidebarLoaded ) { | |
| this.artists = []; | |
| for ( var a = GS.user.sidebar.artists, b = 0; b < a.length; b++ ) { | |
| var c = a[b], | |
| g = GS.Models.Artist.getOneFromCache(c); | |
| (g = g ? g.ArtistName : GS.user.sidebar.meta.artists[c]) ? this.artists.push({ | |
| ArtistName: g, | |
| ArtistID: c, | |
| sidebarSort: b + 1 | |
| }) : console.log("artist shortcut with no name!", c) | |
| } | |
| this.artists.sort(this.callback(this.playlistSort)); | |
| this.showArtists() | |
| } | |
| }, | |
| populateSidebarAlbums: function() { | |
| if ( GS.user.sidebarLoaded ) { | |
| this.albums = []; | |
| for ( var a = GS.user.sidebar.albums, b = 0; b < a.length; b++ ) { | |
| var c = a[b], | |
| g = GS.Models.Album.getOneFromCache(c); | |
| (g = g ? g.AlbumName : GS.user.sidebar.meta.albums[c]) ? this.albums.push({ | |
| AlbumName: g, | |
| AlbumID: c, | |
| sidebarSort: b + 1 | |
| }) : console.log("album shortcut with no name!", c) | |
| } | |
| this.albums.sort(this.callback(this.playlistSort)); | |
| this.showAlbums() | |
| } | |
| }, | |
| showPlaylists: function() { | |
| $("#sidebar_playlists").html(this.view("playlists", { | |
| playlists: this.playlists, | |
| doingSubscribed: false | |
| })); | |
| $("#sidebar_playlists_divider").show(); | |
| $("#sidebar_playlist_new").toggle(!this.playlists.length) | |
| }, | |
| showSubscribedPlaylists: function() { | |
| $("#sidebar_subscribed_playlists").html(this.view("playlists", { | |
| playlists: this.subscribedPlaylists, | |
| doingSubscribed: true | |
| })); | |
| $("#sidebar_playlists_divider").show() | |
| }, | |
| showStations: function() { | |
| $("#sidebar_stations").html(this.view("stations")); | |
| $("#sidebar_stations_divider").show(); | |
| $("#sidebar_station_new").toggle(!this.stations.length) | |
| }, | |
| showSongs: function() { | |
| $("#sidebar_songs").html(this.view("songs")); | |
| var a = $("#sidebar_songs_divider"), | |
| b = a.toggle( !! this.songs.length).hasClass("sidebar_pin_collapsed"); | |
| a.next(".sidebar_pin_group").toggle(!b && !! this.songs.length) | |
| }, | |
| showArtists: function() { | |
| $("#sidebar_artists").html(this.view("artists")); | |
| var a = $("#sidebar_artists_divider"), | |
| b = a.toggle( !! this.artists.length).hasClass("sidebar_pin_collapsed"); | |
| a.next(".sidebar_pin_group").toggle(!b && !! this.artists.length) | |
| }, | |
| showAlbums: function() { | |
| $("#sidebar_albums").html(this.view("albums")); | |
| var a = $("#sidebar_albums_divider"), | |
| b = a.toggle( !! this.albums.length).hasClass("sidebar_pin_collapsed"); | |
| a.next(".sidebar_pin_group").toggle(!b && !! this.albums.length) | |
| }, | |
| ".sidebar_pin_divider click": function( a ) { | |
| $(a).toggleClass("sidebar_pin_collapsed"); | |
| $(a).next(".sidebar_pin_group").toggle() | |
| }, | |
| "a.sidebar_playlist click": function( a, b ) { | |
| b.preventDefault(); | |
| var c = parseInt($(a).attr("rel"), 10); | |
| c && GS.Models.Playlist.getPlaylist(c, function( g ) { | |
| if ( g ) location.hash = g.toUrl() | |
| }) | |
| }, | |
| "a.sidebar_playlist_new click": function( a, b ) { | |
| b.preventDefault(); | |
| GS.getLightbox().open("newPlaylist") | |
| }, | |
| ".sidebar_playlist .remove click": function( a, b ) { | |
| b.stopPropagation(); | |
| b.preventDefault(); | |
| var c = a.parent().attr("rel"), | |
| g = GS.Models.Playlist.getOneFromCache(c), | |
| h = g.isSubscribed(), | |
| k = $(a).closest(".link_group"), | |
| m = function() { | |
| if ( $(".sidebar_link", k).length === 0 ) if (!h ) { | |
| $("#sidebar_subscribed_divider").addClass("sidebar_pin_collapsed"); | |
| $("#sidebar_subscribed_wrapper").css("display", "none") | |
| } | |
| }; | |
| GS.getLightbox().open({ | |
| type: "removePlaylistSidebar", | |
| view: { | |
| header: "POPUP_DELETE_PLAYLIST_TITLE", | |
| messageHTML: (new GS.Models.DataString($.localize.getString("POPUP_DELETE_PLAYLIST_QUESTION"), { | |
| playlist: g.PlaylistName | |
| })).render(), | |
| buttonsLeft: [{ | |
| className: "close", | |
| label: "CANCEL" | |
| }], | |
| buttonsRight: [{ | |
| className: "submit playlist", | |
| label: h ? "PLAYLIST_UNSUBSCRIBE" : "POPUP_DELETE_PLAYLIST_LABEL" | |
| }, | |
| { | |
| className: "submit shortcut", | |
| label: "POPUP_REMOVE_PINBOARD_LABEL" | |
| }] | |
| }, | |
| callbacks: { | |
| "button.playlist": function() { | |
| h ? g.unsubscribe() : g.remove(); | |
| m() | |
| }, | |
| "button.shortcut": function() { | |
| GS.user.removeFromShortcuts("playlist", g.PlaylistID, true); | |
| m() | |
| } | |
| } | |
| }); | |
| return false | |
| }, | |
| "a.playlist contextmenu": function( a, b ) { | |
| var c = a.attr("rel"); | |
| c = GS.Models.Playlist.getOneFromCache(c).getContextMenu(); | |
| $(a).jjmenu(b, c, null, { | |
| xposition: "mouse", | |
| yposition: "mouse", | |
| show: "show", | |
| className: "playlistmenu" | |
| }) | |
| }, | |
| "a.station click": function( a, b ) { | |
| b.stopPropagation(); | |
| var c = a.attr("rel"); | |
| GS.player.setAutoplay(true, c); | |
| return false | |
| }, | |
| "a.station .remove click": function( a, b ) { | |
| b.stopPropagation(); | |
| var c = a.parent().attr("rel"); | |
| this.removeStationID = c; | |
| var g = $(a).closest(".link_group"); | |
| GS.user.removeFromShortcuts("station", c, true); | |
| if ( $(".sidebar_link", g).length == 0 ) { | |
| $("#sidebar_stations_divider").addClass("sidebar_pin_collapsed"); | |
| $("#sidebar_stations_wrapper").css("display", "none") | |
| } | |
| return false | |
| }, | |
| "a.noProfile click": function() { | |
| GS.getLightbox().open("login") | |
| }, | |
| "a.upload click": function() { | |
| window.open("http://" + location.host + "/upload", "_blank") | |
| }, | |
| "a.sidebar_song click": function( a, b ) { | |
| b.preventDefault(); | |
| var c = parseInt($(a).attr("rel"), 10); | |
| c && GS.Models.Song.getSong(c, function( g ) { | |
| if ( g ) location.hash = g.toUrl() | |
| }) | |
| }, | |
| ".sidebar_song .remove click": function( a, b ) { | |
| b.stopPropagation(); | |
| b.preventDefault(); | |
| var c = a.parent().attr("rel"), | |
| g = a.parent().attr("title"); | |
| GS.getLightbox().open({ | |
| type: "removeSongSidebar", | |
| view: { | |
| header: "POPUP_REMOVE_FROM_PINBOARD_TITLE", | |
| messageHTML: (new GS.Models.DataString($.localize.getString("POPUP_REMOVE_FROM_PINBOARD_MSG"), { | |
| name: g, | |
| type: $.localize.getString("SONG").toLowerCase() | |
| })).render(), | |
| buttonsLeft: [{ | |
| className: "close", | |
| label: "CANCEL" | |
| }], | |
| buttonsRight: [{ | |
| className: "submit shortcut", | |
| label: "POPUP_REMOVE_PINBOARD_LABEL" | |
| }] | |
| }, | |
| callbacks: { | |
| "button.shortcut": function() { | |
| GS.user.removeFromShortcuts("song", c) | |
| } | |
| } | |
| }); | |
| return false | |
| }, | |
| "a.sidebar_song contextmenu": function( a, b ) { | |
| var c = parseInt($(a).attr("rel"), 10); | |
| c && GS.Models.Song.getSong(c, function( g ) { | |
| if ( g ) { | |
| g = g.getContextMenu(); | |
| $(a).jjmenu(b, g, null, { | |
| xposition: "mouse", | |
| yposition: "mouse", | |
| show: "show", | |
| className: "songmenu" | |
| }) | |
| } | |
| }) | |
| }, | |
| "a.sidebar_album click": function( a, b ) { | |
| b.preventDefault(); | |
| var c = parseInt($(a).attr("rel"), 10); | |
| c && GS.Models.Album.getAlbum(c, function( g ) { | |
| if ( g ) location.hash = g.toUrl() | |
| }) | |
| }, | |
| ".sidebar_album .remove click": function( a, b ) { | |
| b.stopPropagation(); | |
| b.preventDefault(); | |
| var c = a.parent().attr("rel"), | |
| g = a.parent().attr("title"); | |
| GS.getLightbox().open({ | |
| type: "removeAlbumSidebar", | |
| view: { | |
| header: "POPUP_REMOVE_FROM_PINBOARD_TITLE", | |
| messageHTML: (new GS.Models.DataString($.localize.getString("POPUP_REMOVE_FROM_PINBOARD_MSG"), { | |
| name: g, | |
| type: $.localize.getString("ALBUM").toLowerCase() | |
| })).render(), | |
| buttonsLeft: [{ | |
| className: "close", | |
| label: "CANCEL" | |
| }], | |
| buttonsRight: [{ | |
| className: "submit shortcut", | |
| label: "POPUP_REMOVE_PINBOARD_LABEL" | |
| }] | |
| }, | |
| callbacks: { | |
| "button.shortcut": function() { | |
| GS.user.removeFromShortcuts("album", c) | |
| } | |
| } | |
| }); | |
| return false | |
| }, | |
| "a.sidebar_album contextmenu": function( a, b ) { | |
| var c = parseInt($(a).attr("rel"), 10); | |
| c && GS.Models.Album.getAlbum(c, function( g ) { | |
| if ( g ) { | |
| g = g.getContextMenu(); | |
| $(a).jjmenu(b, g, null, { | |
| xposition: "mouse", | |
| yposition: "mouse", | |
| show: "show", | |
| className: "albummenu" | |
| }) | |
| } | |
| }) | |
| }, | |
| "a.sidebar_artist click": function( a, b ) { | |
| b.preventDefault(); | |
| var c = a.attr("rel"); | |
| c && GS.Models.Artist.getArtist(c, function( g ) { | |
| if ( g ) location.hash = g.toUrl() | |
| }) | |
| }, | |
| ".sidebar_artist .remove click": function( a, b ) { | |
| b.stopPropagation(); | |
| b.preventDefault(); | |
| var c = a.parent().attr("rel"), | |
| g = a.parent().attr("title"); | |
| GS.getLightbox().open({ | |
| type: "removeSongSidebar", | |
| view: { | |
| header: "POPUP_REMOVE_FROM_PINBOARD_TITLE", | |
| messageHTML: (new GS.Models.DataString($.localize.getString("POPUP_REMOVE_FROM_PINBOARD_MSG"), { | |
| name: g, | |
| type: $.localize.getString("ARTIST").toLowerCase() | |
| })).render(), | |
| buttonsLeft: [{ | |
| className: "close", | |
| label: "CANCEL" | |
| }], | |
| buttonsRight: [{ | |
| className: "submit shortcut", | |
| label: "POPUP_REMOVE_PINBOARD_LABEL" | |
| }] | |
| }, | |
| callbacks: { | |
| "button.shortcut": function() { | |
| GS.user.removeFromShortcuts("artist", c) | |
| } | |
| } | |
| }); | |
| return false | |
| }, | |
| "a.sidebar_artist contextmenu": function( a, b ) { | |
| var c = parseInt($(a).attr("rel"), 10); | |
| c && GS.Models.Artist.getArtist(c, function( g ) { | |
| if ( g ) { | |
| g = g.getContextMenu(); | |
| $(a).jjmenu(b, g, null, { | |
| xposition: "mouse", | |
| yposition: "mouse", | |
| show: "show", | |
| className: "artistmenu" | |
| }) | |
| } | |
| }) | |
| }, | |
| "#pinboard_new click": function( a, b ) { | |
| a.jjmenu(b, this.getPinboardMenu(), null, { | |
| xposition: "left", | |
| yposition: "auto", | |
| show: "default", | |
| className: "pinboardmenu" | |
| }) | |
| }, | |
| getPinboardMenu: function() { | |
| return [{ | |
| title: $.localize.getString("SIDEBAR_CONTEXT_ADD_PLAYLIST"), | |
| action: { | |
| type: "fn", | |
| callback: function() { | |
| GS.getLightbox().open("newPlaylist", null); | |
| GS.getGuts().onContextMenuClick("contextNewPlaylist", "pinboard_new", null, null) | |
| } | |
| }, | |
| customClass: "jj_menu_item_hasIcon jj_menu_item_add_playlist" | |
| }, { | |
| title: $.localize.getString("SIDEBAR_CONTEXT_ADD_STATION"), | |
| type: "sub", | |
| src: GS.Models.Station.getStationsStartMenuForPinboard(), | |
| customClass: "stations jj_menu_item_hasIcon jj_menu_item_station" | |
| }] | |
| }, | |
| beginDragDrop: function() { | |
| function a(h, k, m) { | |
| _.orEqual(m, false); | |
| if (!($("#sidebar").within(h.clientX, h.clientY).length <= 0)) { | |
| h = $(".sidebar_link a", "#sidebar").within(h.clientX, h.clientY); | |
| $("#sidebar .sidebar_link a").removeClass("hover"); | |
| h.length && k.draggedItemsType !== "playlist" && h.addClass("hover") | |
| } | |
| } | |
| function b(h, k) { | |
| var m = [], | |
| p, n; | |
| h.draggedItemsType = h.draggedItemsType || _.guessDragType(h.draggedItems); | |
| switch ( h.draggedItemsType ) { | |
| case "song": | |
| for ( p = 0; p < h.draggedItems.length; p++ ) | |
| m.push(h.draggedItems[p].SongID); | |
| var o, t = [], | |
| w = []; | |
| if ( $("#grid").controller() ) { | |
| var x = $("#grid").controller().dataView.rows; | |
| $('#grid .slick-row.selected[id!="showQueue"]').each(function( B, E ) { | |
| o = parseInt($(E).attr("row"), 10); | |
| if (!isNaN(o) ) { | |
| t.push(o + 1); | |
| var H = x[o].ppVersion; | |
| H && w.push(H) | |
| } | |
| }) | |
| } | |
| p = { | |
| ranks: t, | |
| songIDs: m | |
| }; | |
| if ( w.length > 0 ) p.ppVersions = w.join(); | |
| GS.getGuts().logMultiSongDrag("OLSongsDraggedToSidebar", p); | |
| break; | |
| case "album": | |
| var v = function( B ) { | |
| B.sort(GS.Models.Album.defaultSongSort); | |
| for ( n = 0; n < B.length; n++ ) | |
| m.push(B[n].SongID) | |
| }; | |
| for ( p = 0; p < h.draggedItems.length; p++ ) | |
| h.draggedItems[p].getSongs(v, null, true, { | |
| async: false | |
| }); | |
| break; | |
| case "artist": | |
| v = function( B ) { | |
| B.sort(GS.Models.Artist.defaultSongSort); | |
| for ( n = 0; n < B.length; n++ ) | |
| m.push(B[n].SongID) | |
| }; | |
| for ( p = 0; p < h.draggedItems.length; p++ ) | |
| h.draggedItems[p].getSongs(v, null, { | |
| async: false | |
| }); | |
| break; | |
| case "playlist": | |
| v = function( B ) { | |
| for ( n = 0; n < B.length; n++ ) | |
| m.push(B[n].SongID) | |
| }; | |
| for ( p = 0; p < h.draggedItems.length; p++ ) | |
| h.draggedItems[p].getSongs(v, null, false, { | |
| async: false | |
| }); | |
| break; | |
| case "user": | |
| v = function( B ) { | |
| for ( n = 0; n < B.length; n++ ) | |
| m.push(B[n].SongID) | |
| }; | |
| for ( p = 0; p < h.draggedItems.length; p++ ) | |
| h.draggedItems[p].getFavoritesByType("Song", v, null, false, { | |
| async: false | |
| }); | |
| break; | |
| default: | |
| console.error("sidebar drop, invalid drag type", h, h.draggedItemsType); | |
| return | |
| } | |
| if ( k === "library" ) GS.user.addToLibrary(m, true); | |
| else if ( k === "favorites" ) for ( p = 0; p < m.length; p++ ) GS.user.addToSongFavorites(m[p]); | |
| else if ( k === "newPlaylist" ) GS.getLightbox().open("newPlaylist", m); | |
| else if ( k instanceof GS.Models.Playlist ) k.addSongs(m, null, true); | |
| else { | |
| console.error("sidebar drop, invalid thing", k); | |
| return | |
| } | |
| GS.getGuts().gaTrackEvent("sidebar", "dropSuccess") | |
| } | |
| var c = $("li.sidebar_myMusic"), | |
| g = $("li.sidebar_favorites"); | |
| $("#sidebar_playlists,#sidebar_subscribed_playlists,#sidebar_songs,#sidebar_artists,#sidebar_albums,#sidebar_stations").bind("draginit", function( h, k ) { | |
| var m = $(h.target).closest(".sidebar_link"); | |
| if ( m.length === 0 ) return false; | |
| k.draggedSidebarItem = m; | |
| k.proxyOffsetX = h.clientX - m.offset().left; | |
| k.proxyOffsetY = h.clientY - m.offset().top | |
| }).bind("dragstart", function( h, k ) { | |
| var m = k.draggedSidebarItem.attr("rel"), | |
| p, n; | |
| if ( k.draggedSidebarItem.hasClass("sidebar_playlist") ) { | |
| p = "playlist"; | |
| n = GS.Models.Playlist.getOneSynchronous(m) | |
| } else if ( k.draggedSidebarItem.hasClass("sidebar_artist") ) { | |
| p = "artist"; | |
| n = GS.Models.Artist.getOneSynchronous(m) | |
| } else if ( k.draggedSidebarItem.hasClass("sidebar_album") ) { | |
| p = "album"; | |
| n = GS.Models.Album.getOneSynchronous(m) | |
| } else if ( k.draggedSidebarItem.hasClass("sidebar_song") ) { | |
| p = "song"; | |
| n = GS.Models.Song.getOneSynchronous(m) | |
| } else if ( k.draggedSidebarItem.hasClass("sidebar_station") ) { | |
| p = "station"; | |
| n = GS.Models.Station.getOneFromCache(m) | |
| } else return false; | |
| if (!n ) return false; | |
| k.draggedItems = [n]; | |
| k.draggedIemsType = p; | |
| k.draggedItemsSource = "sidebar"; | |
| k.deleteAction = { | |
| label: "CONTEXT_REMOVE_FROM_PINBOARD", | |
| method: function() { | |
| GS.user.removeFromShortcuts(p, m, true) | |
| } | |
| }; | |
| $.publish("gs.drag.start", k); | |
| return $('<div class="dragProxy" style="position:absolute; z-index: 99999;"><div class="status"></div></div>').prepend($(k.draggedSidebarItem).clone()).appendTo("body").mousewheel(_.globalDragProxyMousewheel) | |
| }).bind("drag", function( h, k ) { | |
| k.clientX = h.clientX; | |
| k.clientY = h.clientY; | |
| $(k.proxy).css({ | |
| top: h.clientY - k.proxyOffsetY, | |
| left: h.clientX - k.proxyOffsetX | |
| }); | |
| var m = false, | |
| p = false; | |
| _.forEach(k.drop, function( n ) { | |
| $.isFunction(n.updateDropOnDrag) && n.updateDropOnDrag(h, k); | |
| if (!m ) if ( $(n).within(h.clientX, h.clientY).length > 0 ) if ( $(n).data("ignoreForOverDrop") ) p = true; | |
| else { | |
| p = false; | |
| m = true | |
| } | |
| }); | |
| p || (m ? $(k.proxy).addClass("valid").removeClass("invalid") : $(k.proxy).addClass("invalid").removeClass("valid")) | |
| }).bind("dragend", function( h, k ) { | |
| $(k.proxy).remove(); | |
| GS.getGuts().gaTrackEvent("sidebar", "dragEnd"); | |
| $.publish("gs.drag.end", k) | |
| }).bind("dropinit", function() { | |
| this.updateDropOnDrag = function( h, k ) { | |
| a(h, k, k.draggedItemsType === "playlist") | |
| } | |
| }).bind("dropstart", function( h, k ) { | |
| if (!k.draggedItems ) { | |
| this.updateDropOnDrag = null; | |
| return false | |
| } | |
| k.draggedItemsType = k.draggedItemsType || _.guessDragType(k.draggedItems); | |
| if ( k.draggedItemsSource == "sidebar" ) { | |
| this.updateDropOnDrag = null; | |
| return false | |
| } | |
| if ( k.draggedItemsType !== "playlist" || $(this).attr("id") !== "sidebar_playlists" ) { | |
| this.updateDropOnDrag = | |
| null; | |
| return false | |
| } | |
| }).bind("dropend", function() { | |
| $("#sidebar .sidebar_link a").removeClass("hover") | |
| }).bind("drop", function( h, k ) { | |
| if ( $("#sidebar").width() !== 0 ) { | |
| k.draggedItemsType = k.draggedItemsType || _.guessDragType(k.draggedItems); | |
| var m, p; | |
| if ( k.draggedItemsType === "playlist" ) for ( m = 0; m < k.draggedItems.length; m++ ) { | |
| p = k.draggedItems[m]; | |
| p.UserID == GS.user.UserID || p.isSubscribed() ? GS.user.addToShortcuts("playlist", p.PlaylistID, p.PlaylistName, true) : GS.user.addToPlaylistFavorites(p.PlaylistID, true) | |
| } | |
| else { | |
| m = $(".playlist", "#sidebar_playlists").within(h.clientX, h.clientY).attr("rel"); | |
| p = GS.Models.Playlist.getOneFromCache(m); | |
| if ( p instanceof GS.Models.Playlist ) b(k, p); | |
| else m == "new" && b(k, "newPlaylist") | |
| } | |
| } | |
| }); | |
| c.bind("dropinit", function() { | |
| this.updateDropOnDrag = function( h, k ) { | |
| a(h, k, true) | |
| } | |
| }).bind("dropstart", function( h, k ) { | |
| if (!k.draggedItems ) { | |
| this.updateDropOnDrag = null; | |
| return false | |
| } | |
| }).bind("dropend", function() { | |
| $("#sidebar .sidebar_link a").removeClass("hover") | |
| }).bind("drop", function( h, k ) { | |
| b(k, "library") | |
| }); | |
| g.bind("dropinit", function() { | |
| this.updateDropOnDrag = | |
| function( h, k ) { | |
| a(h, k, true) | |
| } | |
| }).bind("dropstart", function( h, k ) { | |
| if (!k.draggedItems ) { | |
| this.updateDropOnDrag = null; | |
| return false | |
| } | |
| }).bind("dropend", function() { | |
| $("#sidebar .sidebar_link a").removeClass("hover") | |
| }).bind("drop", function( h, k ) { | |
| b(k, "favorites") | |
| }) | |
| } | |
| }); | |
| (function() { | |
| function a(m) { | |
| if (!c ) { | |
| var p = m.draggedItemsType = m.draggedItemsType || _.guessDragType(m.draggedItems); | |
| if ( p != "user" ) { | |
| $("#shortcuts").show(); | |
| if ( p == "song" && m.draggedItems.length > 1 ) p = "manySongs"; | |
| var n = _.orEqual(GS.Controllers.Lightbox.ShareController.allowed[p], []), | |
| o = $("#shortcuts_bar .share_option"), | |
| t = $("#shortcuts_share_wrapper"), | |
| w = GS.user.isLoggedIn && m.draggedItems.length === 1 && k.indexOf(p) !== -1; | |
| if (!GS.user.isLoggedIn ) { | |
| n = n.concat(); | |
| var x = n.indexOf("email"); | |
| x != -1 && n.splice(x, 1) | |
| } | |
| o.hide(); | |
| if ( n.length || w ) { | |
| t.show(); | |
| _.forEach(n, function( v ) { | |
| o.filter("." + v).show() | |
| }); | |
| w && o.filter(".broadcast").show() | |
| } else t.hide(); | |
| $("#shortcuts_add_pinboard").toggle(m.draggedItems.length === 1 && h.indexOf(p) !== -1 && m.draggedItemsSource != "sidebar"); | |
| $("#shortcuts_add_favorites").toggle(p === "song"); | |
| $("#shortcuts_add_library").add("#shortcuts_playlists_wrapper").toggle(p !== "station"); | |
| $("#shortcuts_add_wrapper").toggle($("#shortcuts_add").children(":visible").length > 0); | |
| $("#shortcuts_scroll").height($("#shortcuts_bar").height()); | |
| if ( m.deleteAction ) { | |
| p = $("#shortcuts_trash_label"); | |
| $("#shortcuts_trash_wrapper").show(); | |
| p.removeClass("ellipsis"); | |
| p.localeDataString(m.deleteAction.label, m.deleteAction.labelParams); | |
| p.addClass("ellipsis") | |
| } else $("#shortcuts_trash_wrapper").hide(); | |
| m = $("#shortcuts_scroll .viewport").innerHeight() < $("#shortcuts_scroll .overview").outerHeight() ? 0 : -15; | |
| $("#shortcuts_bar").stop().animate({ | |
| right: m | |
| }, "fast", function() { | |
| if ( g ) g.update(); | |
| else { | |
| g = $("#shortcuts_scroll").tinyscrollbar(); | |
| g.find(".viewport").scroll(function() { | |
| g.update() | |
| }) | |
| } | |
| }); | |
| c = true | |
| } | |
| } | |
| } | |
| function b(m) { | |
| clearTimeout(m.shortcutsAutoScrollWaitTimeout); | |
| m.shortcutsAutoScrollWaitTimeout = false; | |
| m.shortcutsAutoScrollHasWaited = false; | |
| clearInterval(m.shortcutsAutoScrollInterval); | |
| m.shortcutsAutoScrollInterval = false | |
| } | |
| var c = false, | |
| g = false, | |
| h = ["song", "playlist", "album", "artist", "station"], | |
| k = ["song", "playlist", "album", "artist"]; | |
| GS.Controllers.BaseController.extend("GS.Controllers.ShortcutsController", { | |
| onElement: "#shortcuts" | |
| }, { | |
| playlists: [], | |
| playlistsDirty: true, | |
| init: function() { | |
| this.subscribe("gs.drag.start", this.callback("onGlobalDragStart")); | |
| this.subscribe("gs.drag.end", this.callback("onGlobalDragEnd")); | |
| this.subscribe("gs.auth.update", this.callback("dirtyPlaylists")); | |
| this.subscribe("gs.auth.playlists.update", this.callback("dirtyPlaylists")); | |
| this._super() | |
| }, | |
| appReady: function() { | |
| this.update() | |
| }, | |
| update: function() { | |
| this.element.html(this.view("index")); | |
| this.beginDragDrop() | |
| }, | |
| dirtyPlaylists: function() { | |
| this.playlistsDirty = true; | |
| c && this.populatePlaylists() | |
| }, | |
| populatePlaylists: function() { | |
| this.playlists = []; | |
| GS.user && _.forEach(GS.user.playlists, function( m ) { | |
| this.playlists.push(m) | |
| }, this); | |
| this.playlists.sort(function( m, p ) { | |
| var n = m.PlaylistName.toLowerCase(), | |
| o = p.PlaylistName.toLowerCase(); | |
| return n == o ? m == p ? 0 : m < p ? -1 : 1 : n < o ? -1 : 1 | |
| }); | |
| $("#shortcuts_playlists").html(this.view("playlists", { | |
| playlists: this.playlists | |
| })); | |
| this.playlistsDirty = false | |
| }, | |
| beginDragDrop: function() { | |
| function m(v) { | |
| return function() { | |
| if ( v.hasOwnProperty("clientX") && v.clientX < t.offset().left ) b(v); | |
| else x = setTimeout(m(v), 100) | |
| } | |
| } | |
| function p(v, B) { | |
| function E() { | |
| var y = (new Date).valueOf(); | |
| if ( B.shortcutsAutoScrollHasWaited && (!B.shortcutsAutoScrollLast || y - B.shortcutsAutoScrollLast >= D) ) { | |
| B.shortcutsAutoScrollLast = y; | |
| $scrollable.scrollTop(Math.max(0, $scrollable.scrollTop() - 41)) | |
| } | |
| } | |
| function H() { | |
| var y = (new Date).valueOf(); | |
| if ( B.shortcutsAutoScrollHasWaited && (!B.shortcutsAutoScrollLast || y - B.shortcutsAutoScrollLast >= D) ) { | |
| B.shortcutsAutoScrollLast = y; | |
| $scrollable.scrollTop(Math.min(scrollHeight, $scrollable.scrollTop() + 41)) | |
| } | |
| } | |
| $scrollable = $("#shortcuts_scroll .viewport"); | |
| var G = Math.ceil($scrollable.height() * 0.2), | |
| D = 200; | |
| scrollHeight = $scrollable[0].scrollHeight; | |
| if ( B.shortcutsAutoScrollWaitTimeout ) if ( $scrollable.offset().top + G > v.clientY ) { | |
| E(); | |
| clearInterval(B.shortcutsAutoScrollInterval); | |
| B.shortcutsAutoScrollInterval = setInterval(E, D) | |
| } else if ( $scrollable.offset().top + $scrollable.height() - G < v.clientY ) { | |
| H(); | |
| clearInterval(B.shortcutsAutoScrollInterval); | |
| B.shortcutsAutoScrollInterval = setInterval(H, D) | |
| } else b(B); | |
| else B.shortcutsAutoScrollWaitTimeout = setTimeout(function() { | |
| B.shortcutsAutoScrollHasWaited = true; | |
| B.shortcutsAutoScrollWaitTimeout = | |
| false | |
| }, 500) | |
| } | |
| function n(v) { | |
| var B = [], | |
| E, H; | |
| v.draggedItemsType = v.draggedItemsType || _.guessDragType(v.draggedItems); | |
| switch ( v.draggedItemsType ) { | |
| case "song": | |
| for ( E = 0; E < v.draggedItems.length; E++ ) | |
| B.push(v.draggedItems[E].SongID); | |
| var G, D = [], | |
| y = []; | |
| if ( $("#grid").controller() ) { | |
| var A = $("#grid").controller().dataView.rows; | |
| $('#grid .slick-row.selected[id!="showQueue"]').each(function( q, r ) { | |
| G = parseInt($(r).attr("row"), 10); | |
| if (!isNaN(G) ) { | |
| D.push(G + 1); | |
| var s = A[G].ppVersion; | |
| s && y.push(s) | |
| } | |
| }) | |
| } | |
| v = { | |
| ranks: D, | |
| songIDs: B | |
| }; | |
| if ( y.length > 0 ) v.ppVersions = y.join(); | |
| GS.getGuts().logMultiSongDrag("OLSongsDraggedToShortcuts", v); | |
| break; | |
| case "album": | |
| var I = function( q ) { | |
| q.sort(GS.Models.Album.defaultSongSort); | |
| for ( H = 0; H < q.length; H++ ) | |
| B.push(q[H].SongID) | |
| }; | |
| for ( E = 0; E < v.draggedItems.length; E++ ) | |
| v.draggedItems[E].getSongs(I, null, true, { | |
| async: false | |
| }); | |
| break; | |
| case "artist": | |
| I = function( q ) { | |
| q.sort(GS.Models.Artist.defaultSongSort); | |
| for ( H = 0; H < q.length; H++ ) | |
| B.push(q[H].SongID) | |
| }; | |
| for ( E = 0; E < v.draggedItems.length; E++ ) | |
| v.draggedItems[E].getSongs(I, null, { | |
| async: false | |
| }); | |
| break; | |
| case "playlist": | |
| I = function( q ) { | |
| for ( H = 0; H < q.length; H++ ) | |
| B.push(q[H].SongID) | |
| }; | |
| for ( E = 0; E < v.draggedItems.length; E++ ) | |
| v.draggedItems[E].getSongs(I, null, false, { | |
| async: false | |
| }); | |
| break; | |
| case "user": | |
| I = function( q ) { | |
| for ( H = 0; H < q.length; H++ ) | |
| B.push(q[H].SongID) | |
| }; | |
| for ( E = 0; E < v.draggedItems.length; E++ ) | |
| v.draggedItems[E].getFavoritesByType("Song", I, null, false, { | |
| async: false | |
| }); | |
| break; | |
| default: | |
| console.error("shortcut drop, invalid drag type", v, v.draggedItemsType) | |
| } | |
| return B | |
| } | |
| function o(v, B) { | |
| if ( B === "library" ) GS.user.addToLibrary(v, true); | |
| else if ( B === "favorites" ) for ( i = 0; i < v.length; i++ ) GS.user.addToSongFavorites(v[i]); | |
| else if ( B === "newPlaylist" ) GS.getLightbox().open("newPlaylist", v); | |
| else B instanceof GS.Models.Playlist ? B.addSongs(v, null, true) : console.error("shortcut drop, invalid thing", B) | |
| } | |
| var t = $("#shortcuts"), | |
| w = $("#shortcuts_bar"), | |
| x = false; | |
| t.data("ignoreForOverDrop", true).bind("dropinit", function() { | |
| this.updateDropOnDrag = function( v, B ) { | |
| if (!(w.within(v.clientX, v.clientY).length <= 0)) { | |
| var E = w.find(".shortcuts_link a"); | |
| E.removeClass("hover"); | |
| E = E.within(v.clientX, v.clientY); | |
| E.addClass("hover"); | |
| E.length ? $(B.proxy).addClass("valid").removeClass("invalid") : $(B.proxy).addClass("invalid").removeClass("valid") | |
| } | |
| p(v, B) | |
| } | |
| }).bind("dropend", function( v, B ) { | |
| B.isOverShortcuts = false; | |
| clearTimeout(x); | |
| x = setTimeout(m(B), 100) | |
| }).bind("dropstart", function( v, B ) { | |
| B.isOverShortcuts = true; | |
| clearTimeout(x); | |
| if (!B.draggedItems ) { | |
| this.updateDropOnDrag = null; | |
| return false | |
| } | |
| B.draggedItemsType = B.draggedItemsType || _.guessDragType(B.draggedItems) | |
| }).bind("drop", function( v, B ) { | |
| B.draggedItemsType = | |
| B.draggedItemsType || _.guessDragType(B.draggedItems); | |
| var E = w.find(".shortcuts_link").within(v.clientX, v.clientY).last(), | |
| H = E.attr("rel"); | |
| if ( E.is(".share_option") ) a: { | |
| B.draggedItemsType = B.draggedItemsType || _.guessDragType(B.draggedItems); | |
| E = { | |
| service: H | |
| }; | |
| switch ( B.draggedItemsType ) { | |
| case "song": | |
| E.id = n(B); | |
| if ( E.id.length == 1 ) { | |
| E.id = E.id[0]; | |
| E.type = "song" | |
| } else E.type = "manySongs"; | |
| break; | |
| case "playlist": | |
| E.id = B.draggedItems[0].PlaylistID; | |
| E.type = "playlist"; | |
| break; | |
| case "album": | |
| E.id = B.draggedItems[0].AlbumID; | |
| E.type = "album"; | |
| break; | |
| case "artist": | |
| E.id = B.draggedItems[0].ArtistID; | |
| E.type = "artist"; | |
| break; | |
| default: | |
| console.error("shortcut share drop, invalid type", B.draggedItemsType); | |
| break a | |
| } | |
| H == "broadcast" ? GS.getLightbox().open("broadcast", E) : GS.getLightbox().open("share", E) | |
| } | |
| else if ( E.is(".add_option") ) if ( E.is(".pinboard") ) { | |
| E = B.draggedItems[0]; | |
| switch ( B.draggedItemsType ) { | |
| case "playlist": | |
| H = E.PlaylistID; | |
| E = E.PlaylistName; | |
| break; | |
| case "song": | |
| H = E.SongID; | |
| E = E.SongName; | |
| break; | |
| case "album": | |
| H = E.AlbumID; | |
| E = E.AlbumName; | |
| break; | |
| case "artist": | |
| H = E.ArtistID; | |
| E = E.ArtistName; | |
| break; | |
| case "station": | |
| H = E.StationID; | |
| E = ""; | |
| break; | |
| default: | |
| return | |
| } | |
| GS.user.addToShortcuts(B.draggedItemsType, H, E) | |
| } else o(n(B), H); | |
| else if ( E.is(".playlist_option") ) { | |
| E = GS.Models.Playlist.getOneFromCache(H); | |
| if ( E instanceof GS.Models.Playlist ) o(n(B), E); | |
| else H == "new" && o(n(B), "newPlaylist") | |
| } else if ( E.is(".trash_option") ) B.deleteAction && $.isFunction(B.deleteAction.method) && B.deleteAction.method.call(); | |
| else return;GS.getGuts().gaTrackEvent("shortcuts", "dropSuccess") | |
| }) | |
| }, | |
| onGlobalDragStart: function( m ) { | |
| this.playlistsDirty && this.populatePlaylists(); | |
| a(m) | |
| }, | |
| onGlobalDragEnd: function( m ) { | |
| if ( c ) { | |
| $("#shortcuts_bar").stop().css({ | |
| right: -215 | |
| }).find(".shortcuts_link a").removeClass("hover"); | |
| $("#shortcuts").hide(); | |
| c = false | |
| } | |
| b(m) | |
| } | |
| }) | |
| })(); | |
| (function() { | |
| var a; | |
| GS.Controllers.BaseController.extend("GS.Controllers.PlayerController", { | |
| onElement: "#footer" | |
| }, { | |
| REPEAT_NONE: 0, | |
| REPEAT_ALL: 1, | |
| REPEAT_ONE: 2, | |
| repeatStates: { | |
| none: 0, | |
| all: 1, | |
| one: 2 | |
| }, | |
| INDEX_DEFAULT: -1, | |
| INDEX_NEXT: -2, | |
| INDEX_LAST: -3, | |
| INDEX_REPLACE: -4, | |
| PLAY_STATUS_NONE: 0, | |
| PLAY_STATUS_INITIALIZING: 1, | |
| PLAY_STATUS_LOADING: 2, | |
| PLAY_STATUS_PLAYING: 3, | |
| PLAY_STATUS_PAUSED: 4, | |
| PLAY_STATUS_BUFFERING: 5, | |
| PLAY_STATUS_FAILED: 6, | |
| PLAY_STATUS_COMPLETED: 7, | |
| PLAY_CONTEXT_UNKNOWN: "unknown", | |
| PLAY_CONTEXT_SONG: "song", | |
| PLAY_CONTEXT_ALBUM: "album", | |
| PLAY_CONTEXT_ARTIST: "artist", | |
| PLAY_CONTEXT_PLAYLIST: "playlist", | |
| PLAY_CONTEXT_RADIO: "radio", | |
| PLAY_CONTEXT_SEARCH: "search", | |
| PLAY_CONTEXT_POPULAR: "popular", | |
| PLAY_CONTEXT_FEED: "feed", | |
| PLAY_CONTEXT_SIDEBAR: "sidebar", | |
| PLAY_CONTEXT_EXPLORE: "explore", | |
| PLAY_CONTEXT_USER: "user", | |
| QUEUE_ADD_LIMIT: 1E3, | |
| crossfadeAmount: 5E3, | |
| crossfadeEnabled: false, | |
| playPauseFade: false, | |
| prefetchEnabled: true, | |
| lowerQuality: false, | |
| embedTimeout: 0, | |
| playlistName: $.localize.getString("NOW_PLAYING"), | |
| currentSongString: new GS.Models.DataString, | |
| songCountString: new GS.Models.DataString, | |
| numSongs: 0, | |
| player: null, | |
| isPlaying: false, | |
| isPaused: false, | |
| isLoading: false, | |
| repeatMode: null, | |
| autoplayEnabled: null, | |
| activeSong: null, | |
| currentSongs: null, | |
| nextSongToPlay: null, | |
| nullStatus: { | |
| activeSong: {}, | |
| bytesLoaded: 0, | |
| bytesTotal: 0, | |
| duration: 0, | |
| position: 0, | |
| status: 0 | |
| }, | |
| SCRUB_LOCK: false, | |
| QUEUE_SIZES: { | |
| s: { | |
| width: 144, | |
| activeWidth: 144 | |
| }, | |
| m: { | |
| width: 86, | |
| activeWidth: 86 | |
| }, | |
| l: { | |
| width: 106, | |
| activeWidth: 106 | |
| } | |
| }, | |
| queueSize: "m", | |
| songWidth: 86, | |
| activeSongWidth: 86, | |
| queueClosed: false, | |
| queueClosedByUser: false, | |
| gsQueue: null, | |
| allowRestore: true, | |
| lastZoomLevel: 0, | |
| videoModeEnabled: false, | |
| powerModeEnabled: false, | |
| exists: false, | |
| init: function() { | |
| a = this; | |
| var b = location.hash.match(/^#\/s\/(.*)\/?/); | |
| if ( b ) { | |
| b = b[0].replace(/\?([^#]*)$/, ""); | |
| this.allowRestore = false; | |
| this.songToPlayOnReadyToken = b.split("/")[3] | |
| } | |
| this.beginDragDrop(); | |
| this.addQueueSeek(); | |
| this.addShortcuts(); | |
| this.addVolumeSlider(); | |
| this.addQueueResize(); | |
| this.queueSize = _.orEqual(GS.store.get("queueSize"), $(window).height() > 700 ? "m" : "s"); | |
| this.songWidth = this.QUEUE_SIZES[this.queueSize].width; | |
| this.activeSongWidth = this.QUEUE_SIZES[this.queueSize].activeWidth; | |
| this.setQueue("off", false); | |
| this.subscribe("gs.auth.update", this.callback(this.userChange)); | |
| this.subscribe("gs.auth.song.update", this.callback(this.songChange)); | |
| this.subscribe("gs.auth.library.update", this.callback(this.libraryChange)); | |
| this.subscribe("gs.auth.favorites.songs.update", this.callback(this.libraryChange)); | |
| this.subscribe("gs.settings.local.update", this.callback(this.updateWithLocalSettings)); | |
| this.subscribe("gs.song.play", this.callback(this.eventPlaySong)); | |
| this.subscribe("gs.album.play", this.callback(this.eventPlayAlbum)); | |
| this.subscribe("gs.playlist.play", this.callback(this.eventPlayPlaylist)); | |
| this.subscribe("gs.station.play", this.callback(this.eventPlayStation)); | |
| this.subscribe("gs.app.resize", this.callback(this.resize)); | |
| this.subscribe("gs.swf.invalidMethod", this.callback(this.swfDied)); | |
| this.exists = true; | |
| GS.Models.Feature.register("videoMode", { | |
| FeatureID: "videoMode", | |
| TextKey: "VIDEO_MODE", | |
| ActivateCallback: this.callback("enableVideoMode"), | |
| Type: "ACTIVATED" | |
| }); | |
| GS.Models.Feature.register("visualizers", { | |
| FeatureID: "visualizers", | |
| TextKey: "VISUALIZERS", | |
| ActivateCallback: this.callback(function() { | |
| GS.getLightbox().open("visualizer", { | |
| showPlayerControls: true | |
| }) | |
| }), | |
| Type: "ACTIVATED" | |
| }); | |
| GS.Models.Feature.register("powerHour", { | |
| FeatureID: "powerHour", | |
| TextKey: "POWER_HOUR_MODE", | |
| ActivateCallback: this.callback("togglePowerMode"), | |
| IsActiveCallback: this.callback(function() { | |
| return this.powerModeEnabled | |
| }) | |
| }); | |
| this._super() | |
| }, | |
| appReady: function() { | |
| if ( swfobject.hasFlashPlayerVersion("9.0.0") ) this.embedTimeout = setTimeout(this.callback(this.onEmbedTimeout), 1E4); | |
| else setTimeout(function() { | |
| GS.getLightbox().open({ | |
| type: "noFlash", | |
| notCloseable: true, | |
| view: { | |
| header: "POPUP_NO_FLASH_TITLE", | |
| message: "POPUP_NO_FLASH_MSG", | |
| buttonsRight: [{ | |
| label: "POPUP_REFRESH_GROOVESHARK", | |
| className: "submit" | |
| }], | |
| buttonsLeft: [{ | |
| label: "POPUP_INSTALL_FLASH", | |
| href: "http://get.adobe.com/flashplayer/", | |
| className: "install" | |
| }] | |
| }, | |
| callbacks: { | |
| ".submit": function( b ) { | |
| b.stopImmediatePropagation(); | |
| window.location.reload(true) | |
| }, | |
| ".install": function() { | |
| $(this).attr("target", "_blank") | |
| } | |
| } | |
| }) | |
| }, 500) | |
| }, | |
| resize: function() { | |
| a.updateQueueWidth() | |
| }, | |
| setQueue: function( b, c ) { | |
| c = _.orEqual(c, true); | |
| var g = b === "s" ? a.smallQueueSongToHtml : a.queueSongToHtml(b), | |
| h = a.getCurrentQueue(), | |
| k = _.defined(a.queue) && a.queue.songs ? a.queue.songs : [], | |
| m = 0, | |
| p = (b != a.queueSize || a.queueClosed) && b != "off", | |
| n = a.queueClosed, | |
| o = 0; | |
| $("#queue").height("auto"); | |
| if ( a.QUEUE_SIZES[b] ) { | |
| a.queueSize = b; | |
| if ( c ) { | |
| a.queueClosed = false; | |
| a.queueClosedByUser = false | |
| } | |
| a.songWidth = a.QUEUE_SIZES[b].width; | |
| a.activeSongWidth = a.QUEUE_SIZES[b].activeWidth; | |
| GS.store.set("queueSize", b) | |
| } else if ( b == "off" ) { | |
| a.queueClosed = true; | |
| a.queueClosedByUser = c | |
| } | |
| if ( h && h.activeSong ) m = h.activeSong.index; | |
| if ( p ) { | |
| o = a.gsQueue.calcIndex($("#queue .viewport").scrollLeft()); | |
| $("#queue").attr("class", "size-" + a.queueSize); | |
| a.gsQueue.updateSettings({ | |
| activeItemWidth: a.activeSongWidth, | |
| itemWidth: a.songWidth, | |
| itemRenderer: g, | |
| activeIndex: m | |
| }) | |
| } else if (!a.gsQueue ) a.gsQueue = $("#queue").attr("class", "size-" + a.queueSize).gsQueue({ | |
| activeItemWidth: a.activeSongWidth, | |
| itemWidth: a.songWidth, | |
| itemRenderer: g, | |
| activeIndex: m | |
| }, k); | |
| if ( a.queueClosed ) { | |
| a.gsQueue.setDisabled(true); | |
| $("#queue").height(0) | |
| } else { | |
| a.gsQueue.setDisabled(false); | |
| p && setTimeout(function() { | |
| a.gsQueue.moveTo(n ? m : o, true, n ? false : true) | |
| }, 50) | |
| } | |
| $(window).resize() | |
| }, | |
| userChange: function() { | |
| this.updateWithLocalSettings() | |
| }, | |
| libraryChange: function() { | |
| var b = {}; | |
| b = a.player ? a.player.getCurrentQueue() : { | |
| activeSong: false, | |
| songs: [] | |
| }; | |
| if ( b.songs.length ) { | |
| var c = GS.Models.Song.wrapQueue(b.songs); | |
| a.gsQueue.setItems(c, true); | |
| a.updateQueueDetails() | |
| } | |
| if ( b.activeSong ) { | |
| b = GS.Models.Song.wrapQueue([b.activeSong])[0]; | |
| a.updateSongOnPlayer(b, true, true) | |
| } | |
| }, | |
| playerExists: function() { | |
| return this.exists | |
| }, | |
| playerReady: function() { | |
| a.player.setErrorCallback("GS.Controllers.PlayerController.instance().playerError"); | |
| a.player.setPlaybackStatusCallback("GS.Controllers.PlayerController.instance().playerStatus"); | |
| a.player.setPropertyChangeCallback("GS.Controllers.PlayerController.instance().propertyChange"); | |
| a.player.setQueueChangeCallback("GS.Controllers.PlayerController.instance().queueChange"); | |
| a.player.setSongPropertyChangeCallback("GS.Controllers.PlayerController.instance().songChange"); | |
| a.player.setChatServers(gsConfig.chatServersWeighted ? gsConfig.chatServersWeighted : {}); | |
| var b = a.player.setZoomChangeCallback("GS.Controllers.PlayerController.instance().onZoomChange"); | |
| a.onZoomChange(b); | |
| $("#volumeSlider").slider("value", a.player.getVolume()); | |
| a.updateWithLocalSettings(); | |
| clearTimeout(a.embedTimeout); | |
| a.embedTimeout = null; | |
| GS.getLightbox && GS.getLightbox().isOpen && GS.getLightbox().curType == "swfTimeout" && GS.getLightbox().close(); | |
| this.songToPlayOnReadyToken && GS.Models.Song.getSongFromToken(this.songToPlayOnReadyToken, function( c ) { | |
| c && c.validate() && a.addSongAndPlay(c.SongID) | |
| }, null, false); | |
| return true | |
| }, | |
| onEmbedTimeout: function() { | |
| a.player || GS.getLightbox().open("swfTimeout", { | |
| notCloseable: true | |
| }) | |
| }, | |
| swfDied: function() { | |
| GS.getLightbox().open({ | |
| type: "swfCrash", | |
| view: { | |
| header: "POPUP_SWF_CRASH_TITLE", | |
| message: "POPUP_SWF_CRASH_MESSAGE", | |
| buttonsLeft: [{ | |
| label: "POPUP_SWF_CRASH_RELOAD", | |
| className: "reload" | |
| }] | |
| }, | |
| callbacks: { | |
| ".reload": function() { | |
| window.location.reload(true) | |
| } | |
| } | |
| }) | |
| }, | |
| queueIsRestorable: function() { | |
| this.getCurrentQueue(true); | |
| GS.user && GS.user.settings.local.restoreQueue && this.allowRestore ? this.restoreQueue() : $("#queue_clear_button").addClass("undo").attr("title", $.localize.getString("QUEUE_RESTORE_QUEUE")).attr("data-translate-title", "QUEUE_RESTORE_QUEUE").show().$.publish("gs.notification.restorequeue") | |
| }, | |
| onZoomChange: function( b ) { | |
| var c = window.GS && GS.airbridge ? GS.airbridge : GS.Controllers.AirbridgeController.instance(); | |
| if ( b && !c.isDesktop ) { | |
| console.warn("ZOOM CHANGED, NOT ZERO", b); | |
| alert($.localize.getString("ZOOM_ALERT")); | |
| window._gaq && window._gaq.push && window._gaq.push(["_trackPageview", "#/lb/zoom"]) | |
| } else b !== this.lastZoomLevel && $(window).resize(); | |
| this.lastZoomLevel = b | |
| }, | |
| expireSWFService: function() { | |
| a.player && a.player.expireService() | |
| }, | |
| storeQueue: function() { | |
| a.player && a.player.storeQueue() | |
| }, | |
| playerError: function( b ) { | |
| console.log("player.playererror", b); | |
| switch ( b.type ) { | |
| case "errorAddingSongs": | |
| console.log("player. failed to add songs: ", b.details.songs, b.details.reason); | |
| b.details.reason == "tooManySongs" ? $.publish("gs.notification", { | |
| type: "notice", | |
| message: $.localize.getString("ERROR_TOO_MANY_SONGS") | |
| }) : $.publish("gs.notification", { | |
| type: "error", | |
| message: $.localize.getString("ERROR_ADDING_SONG") + ": " + b.details.reason | |
| }); | |
| break; | |
| case "playbackError": | |
| console.log("player. error playing song", b.details.song, b.details.reason, b.details.errorDetail); | |
| b.details.reason === "unknownHasNext" ? $.publish("gs.notification", { | |
| type: "error", | |
| message: $.localize.getString("ERROR_HASNEXT_MESSAGE") | |
| }) : $.publish("gs.notification", { | |
| type: "error", | |
| message: $.localize.getString("ERROR_PLAYING_SONG") | |
| }); | |
| break; | |
| case "autoplayFailed": | |
| console.log("player. error fetching autoplay song", b.details.reason); | |
| if ( b.details.reason === "unknownHasNext" ) $.publish("gs.notification", { | |
| type: "error", | |
| message: $.localize.getString("ERROR_HASNEXT_MESSAGE") | |
| }); | |
| else b.details.reason === "noRecommendations" ? this.showRadioStations() : $.publish("gs.notification", { | |
| type: "error", | |
| message: $.localize.getString("ERROR_FETCHING_RADIO") | |
| }); | |
| break; | |
| case "autoplayVoteError": | |
| console.log("player. error voting song", b.details.song); | |
| $.publish("gs.notification", { | |
| type: "error", | |
| message: $.localize.getString("ERROR_VOTING_SONG") | |
| }); | |
| break; | |
| case "serviceError": | |
| console.log("player. service error", b.details); | |
| $.publish("gs.notification", { | |
| type: "error", | |
| message: $.localize.getString("ERROR_FETCHING_INFO") | |
| }); | |
| break | |
| } | |
| b.details.errorDetail ? GS.getGuts().gaTrackEvent("playerError", b.type, b.details.reason + ", " + b.details.errorDetail) : GS.getGuts().gaTrackEvent("playerError", b.type, b.details.reason) | |
| }, | |
| $seekBar: $("#player_seeking_back"), | |
| $seekBuffer: $("#player_seeking_buffer"), | |
| $seekProgress: $("#player_seeking_progress"), | |
| $seekScrubber: $("#player_seeking_scrubber"), | |
| lastStatus: false, | |
| lastPlayedQueueSongID: false, | |
| playerStatus: function( b ) { | |
| b = b || this.nullStatus; | |
| if (!this.currentSong || !b.activeSong || this.currentSong && b.activeSong && this.currentSong.queueSongID !== b.activeSong.queueSongID ) { | |
| if ( b.status == a.PLAY_STATUS_PLAYING ) return; | |
| b.activeSong = GS.Models.Song.wrapQueue([b.activeSong ? b.activeSong : {}])[0]; | |
| this.updateSongOnPlayer(b.activeSong, true) | |
| } else b.activeSong = this.currentSong; | |
| var c = Math.min(1, b.bytesLoaded / b.bytesTotal), | |
| g = | |
| Math.min(1, b.position / b.duration), | |
| h = this.$seekBar.width(); | |
| c = Math.min(h, c * 100); | |
| var k = Math.min(h, g * 100); | |
| g = Math.min(h, Math.max(0, h * g)); | |
| c = isNaN(c) ? 0 : c; | |
| k = isNaN(k) ? 0 : k; | |
| g = isNaN(g) ? 0 : g; | |
| this.$seekBuffer.width(c + "%"); | |
| this.$seekProgress.width(k + "%"); | |
| this.SCRUB_LOCK || this.$seekScrubber.css("left", g); | |
| if ( b.duration > 0 ) { | |
| b.position == 0 ? $("#player_elapsed").text("00:00") : $("#player_elapsed").text(_.millisToMinutesSeconds(b.position, true)); | |
| b.duration == 0 ? $("#player_duration").text("00:00") : $("#player_duration").text(_.millisToMinutesSeconds(b.duration, true)) | |
| } else { | |
| $("#player_elapsed").text("00:00"); | |
| $("#player_duration").text("00:00") | |
| } | |
| b.currentStreamServer && b.currentStreamServer !== this.lastStatus.currentStreamServer && $.publish("gs.player.streamserver", { | |
| streamServer: b.currentStreamServer | |
| }); | |
| this.powerModeEnabled && b.position > 6E4 && this.nextSong(); | |
| g = b.activeSong ? b.activeSong.SongID : false; | |
| switch ( b.status ) { | |
| case a.PLAY_STATUS_NONE: | |
| this.lastStatus !== b.status && GS.getGuts().logEvent("playStatusUpdate", { | |
| playStatus: "NONE", | |
| activeSong: g, | |
| streamServer: b.currentStreamServer | |
| }); | |
| a.isPlaying = false; | |
| a.isPaused = false; | |
| a.isLoading = false; | |
| a.seek.slider("disable"); | |
| $("#player_play_pause").addClass("play").removeClass("pause").removeClass("buffering"); | |
| $("#queue_list li.queue-item.queue-item-active a.play").addClass("paused"); | |
| $.publish("gs.player.stopped", b.activeSong); | |
| break; | |
| case a.PLAY_STATUS_INITIALIZING: | |
| a.isPlaying = true; | |
| a.isPaused = false; | |
| a.isLoading = true; | |
| if ( this.lastStatus !== b.status ) { | |
| GS.getGuts().logEvent("playStatusUpdate", { | |
| playStatus: "INITIALIZING", | |
| activeSong: g, | |
| streamServer: b.currentStreamServer | |
| }); | |
| this.lastStatus == a.PLAY_STATUS_COMPLETED && GS.getGuts().gaTrackEvent("player", "continueInterrupted", b.currentSongID) | |
| } | |
| if ( GS.airbridge && GS.airbridge.isDesktop && !GS.user.IsPremium || gsConfig.isPreview && !GS.user.IsPremium && GS.user.UserID % 5 != 0 ) { | |
| this.stopSong(); | |
| GS.getLightbox().open("login", { | |
| premiumRequired: true, | |
| notCloseable: gsConfig.isPreview || GS.airbridge && GS.airbridge.isDesktop | |
| }) | |
| } | |
| break; | |
| case a.PLAY_STATUS_LOADING: | |
| if ( this.lastStatus !== b.status ) { | |
| GS.getGuts().logEvent("playStatusUpdate", { | |
| playStatus: "LOADING", | |
| activeSong: g, | |
| streamServer: b.currentStreamServer | |
| }); | |
| a.isPlaying = true; | |
| a.isPaused = false; | |
| a.isLoading = true; | |
| a.updateSongOnPlayer(b.activeSong); | |
| $("#player_play_pause").is(".buffering") || $("#player_play_pause").removeClass("play").removeClass("pause").addClass("buffering"); | |
| GS.getGuts().gaTrackEvent("player", "loading", b.currentStreamServer); | |
| a.lastLoadingQueueSongID = b.activeSong ? b.activeSong.queueSongID : false; | |
| a.lastLoadingTime = (new Date).getTime() | |
| } | |
| $("#queue_list li.queue-item.queue-item-active a.play").removeClass("paused"); | |
| break; | |
| case a.PLAY_STATUS_PLAYING: | |
| if ( this.lastStatus !== b.status || this.lastPlayedQueueSongID !== b.activeSong.queueSongID ) { | |
| GS.getGuts().logEvent("playStatusUpdate", { | |
| playStatus: "PLAYING", | |
| activeSong: g, | |
| streamServer: b.currentStreamServer | |
| }); | |
| a.isPlaying = true; | |
| a.isPaused = false; | |
| a.isLoading = false; | |
| a.seek.slider("enable"); | |
| $("#player_play_pause").is(".pause") || $("#player_play_pause").removeClass("play").addClass("pause").removeClass("buffering"); | |
| $.publish("gs.player.playing", b); | |
| if ( b.activeSong && (this.lastPlayedQueueSongID !== b.activeSong.queueSongID || this.repeatMode == a.REPEAT_ONE && this.lastStatus == a.PLAY_STATUS_LOADING) ) { | |
| this.lastStatus == a.PLAY_STATUS_COMPLETED && GS.getGuts().gaTrackEvent("player", "continueNextSong", g); | |
| GS.getGuts().gaTrackEvent("player", "play", g); | |
| this.trackAutoplayEvent("play"); | |
| this.updateSongOnPlayer(b.activeSong); | |
| $.publish("gs.player.nowplaying", b.activeSong); | |
| $("#queue_list .queueSong a.play[rel=" + this.lastPlayedQueueSongID + "]").addClass("paused"); | |
| this.lastPlayedQueueSongID = b.activeSong ? b.activeSong.queueSongID : false | |
| } | |
| this.lastStatus == a.PLAY_STATUS_LOADING ? GS.getGuts().gaTrackEvent("player", "loadingTime", b.currentStreamServer, (new Date).getTime() - this.lastLoadingTime) : GS.getGuts().gaTrackEvent("player", "loadingTime", b.currentStreamServer, 0) | |
| } | |
| if ( this.pauseNextQueueSongID && b.activeSong && this.pauseNextQueueSongID === b.activeSong.queueSongID ) { | |
| this.pauseNextQueueSongID = false; | |
| setTimeout(this.callback(function() { | |
| this.pauseSong() | |
| }), 10) | |
| } | |
| $("#queue_list li.queue-item.queue-item-active a.play").removeClass("paused"); | |
| $.publish("gs.player.playing.continue", b); | |
| g = new Date; | |
| !GS.user.IsPremium && g - GS.getAd().lastActive > 36E5 && GS.getLightbox().open("interactionTime"); | |
| break; | |
| case a.PLAY_STATUS_PAUSED: | |
| if ( this.lastStatus !== b.status ) { | |
| GS.getGuts().logEvent("playStatusUpdate", { | |
| playStatus: "PAUSED", | |
| activeSong: g, | |
| streamServer: b.currentStreamServer | |
| }); | |
| a.isPlaying = false; | |
| a.isPaused = true; | |
| a.isLoading = false; | |
| $("#player_play_pause").is(".play") || $("#player_play_pause").addClass("play").removeClass("pause").removeClass("buffering"); | |
| $.publish("gs.player.paused", b.activeSong) | |
| } | |
| $("#queue_list li.queue-item.queue-item-active a.play").addClass("paused"); | |
| break; | |
| case a.PLAY_STATUS_BUFFERING: | |
| this.lastStatus !== b.status && GS.getGuts().logEvent("playStatusUpdate", { | |
| playStatus: "BUFFERING", | |
| activeSong: g, | |
| streamServer: b.currentStreamServer | |
| }); | |
| a.isPlaying = true; | |
| a.isPaused = false; | |
| a.isLoading = true; | |
| $("#player_play_pause").is(".buffering") || $("#player_play_pause").removeClass("play").removeClass("pause").addClass("buffering"); | |
| $("#queue_list li.queue-item.queue-item-active a.play").removeClass("paused"); | |
| break; | |
| case a.PLAY_STATUS_FAILED: | |
| this.lastStatus !== b.status && GS.getGuts().logEvent("playStatusUpdate", { | |
| playStatus: "FAILED", | |
| activeSong: g, | |
| streamServer: b.currentStreamServer | |
| }); | |
| a.isPlaying = false; | |
| a.isPaused = false; | |
| a.isLoading = false; | |
| a.seek.slider("disable"); | |
| $("#player_play_pause").addClass("play").removeClass("pause").removeClass("buffering"); | |
| $("#queue_list li.queue-item.queue-item-active a.play").addClass("paused"); | |
| break; | |
| case a.PLAY_STATUS_COMPLETED: | |
| this.lastStatus !== b.status && GS.getGuts().logEvent("playStatusUpdate", { | |
| playStatus: "COMPLETED", | |
| activeSong: g, | |
| streamServer: b.currentStreamServer | |
| }); | |
| a.isPlaying = | |
| false; | |
| a.isPaused = false; | |
| a.isLoading = false; | |
| a.seek.slider("disable"); | |
| $("#player_play_pause").addClass("play").removeClass("pause").removeClass("buffering"); | |
| $("#queue_list li.queue-item.queue-item-active a.play").addClass("paused"); | |
| a.$seekBuffer.width("0%"); | |
| a.$seekProgress.width("0%"); | |
| a.$seekScrubber.css("left", 0); | |
| $.publish("gs.player.stopped", b.activeSong); | |
| $.publish("gs.player.completed", b.activeSong); | |
| break | |
| } | |
| this.lastStatus = b.status; | |
| $.publish("gs.player.playstatus", b) | |
| }, | |
| pauseNextQueueSongID: false, | |
| pauseNextSong: function() { | |
| var b = | |
| this.getCurrentQueue(true); | |
| this.pauseNextQueueSongID = b && b.nextSong && b.nextSong.queueSongID ? b.nextSong.queueSongID : false | |
| }, | |
| propertyChange: function( b ) { | |
| if ( b.isMuted ) { | |
| $("#player_volume").addClass("muted"); | |
| $("#volumeSlider").slider("value", 0) | |
| } else { | |
| $("#player_volume").removeClass("muted"); | |
| $("#volumeSlider").slider("value", b.volume) | |
| } | |
| if ( b.crossfadeEnabled ) { | |
| $("#player_crossfade").addClass("active"); | |
| this.crossfadeEnabled = true | |
| } else { | |
| $("#player_crossfade").removeClass("active"); | |
| this.crossfadeEnabled = false | |
| } | |
| }, | |
| queueChange: function( b ) { | |
| var c = | |
| b.fullQueue; | |
| if ( a.player ) c.hasRestoreQueue = a.player.getQueueIsRestorable(); | |
| a.queue = false; | |
| switch ( b.type ) { | |
| case "queueReset": | |
| c.activeSong = c.activeSong ? GS.Models.Song.wrapQueue([c.activeSong])[0] : null; | |
| c.activeSong && this.updateSongOnPlayer(c.activeSong, true, a.currentSong && a.currentSong.queueSongID == c.activeSong.queueSongID); | |
| c.songs = GS.Models.Song.wrapQueue(c.songs); | |
| a.queue = c; | |
| a.updateQueueDetails(c); | |
| a.updateQueueSongs(c); | |
| if ( b.details.hasOwnProperty("autoplayEnabled") ) if ( b.details.autoplayEnabled == true ) { | |
| GS.player.getCurrentQueue(); | |
| GS.getGuts().logEvent("autoplayOn", { | |
| tagID: b.details.currentAutoplayTagID | |
| }); | |
| GS.getGuts().beginContext({ | |
| autoplay: b.details.currentAutoplayTagID | |
| }) | |
| } else GS.getGuts().endContext("autoplay"); | |
| break; | |
| case "propertyChange": | |
| if ( b.details.hasOwnProperty("autoplayEnabled") ) if ( b.details.autoplayEnabled == true ) { | |
| c = a.getCurrentQueue().songs; | |
| var g = { | |
| tagID: b.fullQueue.currentAutoplayTagID | |
| }; | |
| if ( c ) { | |
| for ( var h = "", k = 0; k < c.length; k++ ) | |
| h = k == 0 ? c[k].SongID : h + "," + c[k].SongID; | |
| g.seedSongs = h | |
| } | |
| GS.getGuts().logEvent("autoplayOn", g); | |
| GS.getGuts().beginContext({ | |
| autoplay: b.fullQueue.currentAutoplayTagID, | |
| autoplaySeedSongs: h | |
| }) | |
| } else GS.getGuts().handleAutoplayOff(); | |
| a.updateQueueDetails(); | |
| break; | |
| case "contentChange": | |
| a.gsQueue.setActive(a.getCurrentQueue().activeSong.index, false); | |
| a.gsQueue.setItems(a.getCurrentQueue().songs); | |
| a.updateQueueWidth(); | |
| a.updateQueueDetails(); | |
| break | |
| } | |
| $.publish("gs.player.queue.change") | |
| }, | |
| songChange: function( b ) { | |
| var c = ["parentQueueID", "queueSongID", "autoplayVote", "source", "sponsoredAutoplayID"], | |
| g = a.player ? a.player.getCurrentQueue() : { | |
| activeSong: false | |
| }, | |
| h, k, m, p, n = true; | |
| b instanceof GS.Models.Song || (b = GS.Models.Song.wrapQueue([b])[0]); | |
| m = g.songs; | |
| for ( h = 0; p = m[h]; h++ ) | |
| if ( p.SongID == b.SongID ) for ( k in b ) if ( b.hasOwnProperty(k) && p[k] != b[k] && (p.queueSongID === b.queueSongID || c.indexOf(k) == -1) ) { | |
| p[k] = b[k]; | |
| n = false | |
| } | |
| if (!n ) { | |
| c = GS.Models.Song.wrapQueue(m); | |
| a.gsQueue.setItems(c, true) | |
| } | |
| a.updateQueueDetails(); | |
| g.activeSong && b.queueSongID === g.activeSong.queueSongID && a.updateSongOnPlayer(b, true, true); | |
| $.publish("gs.player.song.change", b) | |
| }, | |
| updateWithLocalSettings: function( b ) { | |
| if ( this.player ) { | |
| b = b || GS.user.settings.local; | |
| b.crossfadeEnabled != this.getCrossfadeEnabled() && this.setCrossfadeEnabled(b.crossfadeEnabled); | |
| b.crossfadeAmount != this.getCrossfadeAmount() && this.setCrossfadeAmount(b.crossfadeAmount); | |
| b.lowerQuality != this.getLowerQuality() && this.setLowerQuality(b.lowerQuality); | |
| !b.noPrefetch != this.getPrefetchEnabled() && this.setPrefetchEnabled(!b.noPrefetch); | |
| b.playPauseFade != this.getPlayPauseFade() && this.setPlayPauseFade(b.playPauseFade); | |
| this.setPersistShuffle(b.persistShuffle); | |
| b.persistShuffle && b.lastShuffle != this.getShuffle() && this.setShuffle(b.lastShuffle) | |
| } | |
| }, | |
| getEverything: function() { | |
| if ( a.player ) return a.player.getEverything(); | |
| return {} | |
| }, | |
| getPlaybackStatus: function() { | |
| if ( a.player ) return a.player.getPlaybackStatus(); | |
| return {} | |
| }, | |
| getSongDetails: function( b, c ) { | |
| var g; | |
| b = _.orEqual(b, 0); | |
| if ( typeof c === "number" || typeof c === "string" ) c = [c]; | |
| if ( a.player ) { | |
| g = a.player.getSongDetails(b, c); | |
| return GS.Models.Song.wrapQueue(g) | |
| } | |
| return GS.Models.Song.wrap({}) | |
| }, | |
| getCurrentSong: function() { | |
| if ( a.player ) return a.getCurrentQueue().activeSong | |
| }, | |
| setActiveSong: function( b ) { | |
| if ( b && a.player ) return a.player.setActiveSong(b); | |
| return false | |
| }, | |
| addSongsToQueueAt: function( b, c, g, h, k ) { | |
| c = _.orEqual(c, this.INDEX_DEFAULT); | |
| g = _.orEqual(g, false); | |
| h = _.orEqual(h, { | |
| type: this.PLAY_CONTEXT_UNKNOWN | |
| }); | |
| k = _.orEqual(k, false); | |
| $.isArray(b) || (b = isNaN(b) ? b.split(",") : [b]); | |
| var m, p = []; | |
| for ( m = 0; m < b.length; m++ ) | |
| b[m] > 0 && GS.Models.Song.getSong(b[m], this.callback(function( n ) { | |
| n = n.dupe(); | |
| n.songs = {}; | |
| n.albums = {}; | |
| n.fanbase = {}; | |
| p[m] = n | |
| }), false, false, { | |
| async: false | |
| }); | |
| if ( a.player ) { | |
| if ( c == -4 ) { | |
| c = -1; | |
| this.clearQueue() | |
| } | |
| a.player.addSongsToQueueAt(p, c, g, h, k); | |
| GS.getGuts().logEvent("songsQueued", { | |
| songIDs: b | |
| }) | |
| } | |
| }, | |
| playSong: function( b ) { | |
| GS.isPlaying = true; | |
| a.player && a.player.playSong(b) | |
| }, | |
| eventPlaySong: function( b ) { | |
| if ( b && b.songID ) { | |
| GS.getNotice().feedbackOnNextSong = _.orEqual(b.getFeedback, false); | |
| a.addSongAndPlay(b.songID) | |
| } | |
| }, | |
| eventPlayAlbum: function( b ) { | |
| if ( b && b.albumID ) { | |
| GS.getNotice().feedbackOnNextSong = _.orEqual(b.getFeedback, false); | |
| GS.Models.Album.getAlbum(b.albumID, this.callback("playAlbum", b), null, false) | |
| } | |
| }, | |
| playAlbum: function( b, c ) { | |
| console.log("player.playAlbum", b, c); | |
| var g = _.orEqual(b.index, -1), | |
| h = _.orEqual(b.playOnAdd, false), | |
| k = _.orEqual(b.shuffle, false); | |
| c.play(g, h, k) | |
| }, | |
| eventPlayPlaylist: function( b ) { | |
| if ( b && b.playlistID ) { | |
| GS.getNotice().feedbackOnNextSong = _.orEqual(b.getFeedback, false); | |
| GS.Models.Playlist.getPlaylist(b.playlistID, this.callback("playPlaylist", b), null, false) | |
| } | |
| }, | |
| playPlaylist: function( b, c ) { | |
| console.log("player.playPlaylist", b, c); | |
| var g = _.orEqual(b.index, -1), | |
| h = _.orEqual(b.playOnAdd, false), | |
| k = _.orEqual(b.shuffle, false); | |
| c.play(g, h, k) | |
| }, | |
| eventPlayStation: function( b ) { | |
| if ( b && b.tagID ) { | |
| console.log("play station", b.tagID); | |
| a.setAutoplay(true, b.tagID) | |
| } | |
| }, | |
| addSongAndPlay: function( b, c ) { | |
| a.player && a.addSongsToQueueAt([b], a.INDEX_DEFAULT, true, c) | |
| }, | |
| pauseSong: function() { | |
| a.isPlaying = false; | |
| a.isPaused = true; | |
| if ( a.player ) { | |
| a.player.pauseSong(); | |
| $.publish("gs.player.paused") | |
| } | |
| GS.getGuts().gaTrackEvent("player", "pauseSong") | |
| }, | |
| resumeSong: function() { | |
| a.isPlaying = true; | |
| a.isPaused = false; | |
| a.player && a.player.resumeSong(); | |
| GS.getGuts().gaTrackEvent("player", "resumeSong") | |
| }, | |
| stopSong: function() { | |
| a.isPlaying = false; | |
| a.isPaused = false; | |
| a.player && a.player.stopSong(); | |
| GS.getGuts().gaTrackEvent("player", "stopSong") | |
| }, | |
| previousSong: function( b ) { | |
| b = b ? true : false; | |
| if ( a.player && !this.videoModeEnabled ) a.player.previousSong(b); | |
| else { | |
| b = a.getCurrentQueue(); | |
| var c = b.activeSong.index; | |
| if (!b.songs[c - 1] ) return; | |
| b = b.songs[c - 1]; | |
| a.setActiveSong(b.queueSongID); | |
| $.publish("gs.video.player.loadSong", b) | |
| } | |
| GS.getGuts().logEvent("prevSong", {}); | |
| GS.getGuts().gaTrackEvent("player", "prevSong"); | |
| a.trackAutoplayEvent("prev") | |
| }, | |
| nextSong: function() { | |
| if ( a.player && !this.videoModeEnabled ) a.player.nextSong(); | |
| else { | |
| var b = a.getCurrentQueue(), | |
| c = b.activeSong.index; | |
| if (!b.songs[c + 1] ) return; | |
| b = b.songs[c + 1]; | |
| a.setActiveSong(b.queueSongID); | |
| $.publish("gs.video.player.loadSong", b) | |
| } | |
| GS.getGuts().logEvent("nextSong", {}); | |
| GS.getGuts().gaTrackEvent("player", "nextSong"); | |
| a.trackAutoplayEvent("next") | |
| }, | |
| seekTo: function( b ) { | |
| a.player && a.player.seekTo(b); | |
| GS.getGuts().gaTrackEvent("player", "seekTo") | |
| }, | |
| clearQueue: function() { | |
| if ( a.player ) { | |
| a.queue && a.queue.autoplayEnabled && GS.getGuts().handleAutoplayOff(); | |
| a.queue = null; | |
| a.currentSong = null; | |
| a.player.stopSong(); | |
| a.player.clearQueue(); | |
| a.playerStatus(a.player.getPlaybackStatus()); | |
| a.updateQueueWidth(); | |
| a.gsQueue.setActive(0, false); | |
| a.gsQueue.setItems([], true); | |
| a.updateQueueDetails(); | |
| $("#playerDetails_nowPlaying").html(""); | |
| $.publish("gs.player.currentSong", null); | |
| GS.getGuts().logEvent("queueCleared", {}) | |
| } | |
| GS.getGuts().gaTrackEvent("player", "clearQueue"); | |
| $.publish("gs.player.queue.change") | |
| }, | |
| restoreQueue: function() { | |
| a.player && a.player.restoreQueue(); | |
| GS.getGuts().gaTrackEvent("player", "restoreQueue") | |
| }, | |
| saveQueue: function() { | |
| for ( var b = a.getCurrentQueue().songs, c = [], g = 0; g < b.length; g++ ) | |
| c.push(b[g].SongID); | |
| GS.getLightbox().open("newPlaylist", c); | |
| GS.getGuts().logQueueSaveInitiated(); | |
| GS.getGuts().gaTrackEvent("player", "saveQueue") | |
| }, | |
| getCurrentQueue: function( b ) { | |
| b = _.orEqual(b, false); | |
| if (!b && a.queue ) return a.queue; | |
| if ( a.player ) { | |
| b = a.player.getCurrentQueue(); | |
| if ( b.activeSong ) { | |
| b.activeSong = GS.Models.Song.wrapQueue([b.activeSong])[0]; | |
| this.updateSongOnPlayer(b.activeSong, true, true) | |
| } | |
| if ( b.songs && b.songs.length ) b.songs = GS.Models.Song.wrapQueue(b.songs); | |
| b.hasRestoreQueue = a.player.getQueueIsRestorable(); | |
| return a.queue = b | |
| } | |
| }, | |
| getPreviousQueue: function() { | |
| a.player && a.player.getPreviousQueue(); | |
| GS.getGuts().gaTrackEvent("player", "previousQueue") | |
| }, | |
| moveSongsTo: function( b, c ) { | |
| if ( typeof b === "number" || typeof b === "string" ) b = [b]; | |
| a.player && a.player.moveSongsTo(b, c) | |
| }, | |
| removeSongs: function( b ) { | |
| if ( typeof b === "number" || typeof b === "string" ) b = [b]; | |
| if ( a.player ) { | |
| a.player.removeSongs(b); | |
| a.updateQueueWidth() | |
| } | |
| a.queue = false; | |
| a.queue = a.getCurrentQueue(); | |
| $.publish("gs.player.queue.change"); | |
| GS.getGuts().gaTrackEvent("player", "removeSongs"); | |
| a.trackAutoplayEvent("removeSongs") | |
| }, | |
| lastAutoplayInfo: false, | |
| setAutoplay: function( b, c, g ) { | |
| var h = a.getCurrentQueue(); | |
| b = b ? true : false; | |
| c = parseInt(c, 10); | |
| if ( isNaN(c) ) c = 0; | |
| if ( h.songs.length == 0 && !c && !g ) this.showRadioStations(h.songs.length == 0); | |
| else if ((c > 0 || g) && h && h.songs.length > 0 ) { | |
| GS.getLightbox().close(); | |
| GS.getLightbox().open({ | |
| type: "radioClearQueue", | |
| view: { | |
| header: "POPUP_START_RADIO_TITLE", | |
| message: "POPUP_START_RADIO_MESSAGE", | |
| buttonsLeft: [{ | |
| label: "CANCEL", | |
| className: "close" | |
| }], | |
| buttonsRight: [{ | |
| label: "POPUP_START_RADIO_TITLE", | |
| className: "submit" | |
| }] | |
| }, | |
| callbacks: { | |
| ".submit": function() { | |
| GS.player.clearQueue(); | |
| GS.player.setAutoplay(true, c, g) | |
| } | |
| } | |
| }) | |
| } else { | |
| if ( a.player ) { | |
| if ( b ) { | |
| $("#player_radio_button").addClass("active"); | |
| $("#player_radio_switch").stop().css({ | |
| left: 25 | |
| }); | |
| GS.getGuts().beginContext({ | |
| autoplay: c | |
| }) | |
| } else { | |
| $("#player_radio_button").removeClass("active"); | |
| $("#player_radio_switch").stop().css({ | |
| left: 0 | |
| }); | |
| GS.getGuts().endContext("autoplay") | |
| } | |
| a.player.setAutoplay(b, c, g); | |
| $.publish("gs.player.autoplay.update", b) | |
| } | |
| GS.getGuts().gaTrackEvent("player", b ? "enableRadio" : "disableRadio", c) | |
| } | |
| }, | |
| trackLastAutoplayInfo: function( b, c ) { | |
| if ( a.lastAutoplayInfo && (!b || a.lastAutoplayInfo.tagID != c) ) { | |
| var g = (new Date).getTime() - a.lastAutoplayInfo.time; | |
| GS.getGuts().gaTrackEvent("player", "autoplayDuration", a.lastAutoplayInfo.tagID, g) | |
| } | |
| if ( b ) { | |
| if (!a.lastAutoplayInfo || a.lastAutoplayInfo && a.lastAutoplayInfo.tagID !== c ) a.lastAutoplayInfo = { | |
| tagID: c, | |
| time: (new Date).getTime() | |
| } | |
| } else a.lastAutoplayInfo = false | |
| }, | |
| trackAutoplayEvent: function( b ) { | |
| b = "" + b; | |
| a.lastAutoplayInfo && b && GS.getGuts().gaTrackEvent("player", "autoplay" + _.ucwords(b), a.lastAutoplayInfo.tagID) | |
| }, | |
| voteSong: function( b, c ) { | |
| var g; | |
| if ( a.player ) { | |
| a.player.voteSong(b, c); | |
| g = this.getSongDetails(a.queue.queueID, [b])[0].SongID; | |
| switch ( c ) { | |
| case -1: | |
| GS.getGuts().logEvent("songDownVoted", { | |
| songID: g | |
| }); | |
| GS.getGuts().gaTrackEvent("player", "voteSongDown"); | |
| break; | |
| case 0: | |
| GS.getGuts().logEvent("songVotedNeutral", { | |
| songID: g | |
| }); | |
| GS.getGuts().gaTrackEvent("player", "voteSongNeutral"); | |
| break; | |
| case 1: | |
| GS.getGuts().logEvent("songUpVoted", { | |
| songID: g | |
| }); | |
| GS.getGuts().gaTrackEvent("player", "voteSongUp"); | |
| break | |
| } | |
| $.publish("gs.player.voted", c) | |
| } | |
| }, | |
| flagSong: function( b, c ) { | |
| if ( a.player ) { | |
| a.player.flagSong(b, c); | |
| $.publish("gs.notification", { | |
| message: $.localize.getString("SUCCESS_FLAG_SONG") | |
| }) | |
| } | |
| GS.getGuts().gaTrackEvent("player", "flagSong", c) | |
| }, | |
| getVolume: function() { | |
| if ( a.player ) return a.player.getVolume() | |
| }, | |
| setVolume: function( b ) { | |
| b = Math.max(0, Math.min(100, parseInt(b, 10))); | |
| a.player && a.player.setVolume(b); | |
| GS.getGuts().gaTrackEvent("player", "setVolume", b) | |
| }, | |
| getCrossfadeAmount: function() { | |
| if ( a.player ) return a.player.getCrossfadeAmount() | |
| }, | |
| getCrossfadeEnabled: function() { | |
| if ( a.player ) return a.player.getCrossfadeEnabled() | |
| }, | |
| setCrossfadeAmount: function( b ) { | |
| b = parseInt(b, 10); | |
| a.player && a.player.setCrossfadeAmount(b); | |
| GS.getGuts().gaTrackEvent("player", "setCrossfade", b) | |
| }, | |
| setCrossfadeEnabled: function( b ) { | |
| b = b && GS.user.IsPremium ? true : false; | |
| a.player && a.player.setCrossfadeEnabled(b); | |
| GS.user.settings.changeLocalSettings({ | |
| crossfadeEnabled: b ? 1 : 0 | |
| }); | |
| GS.getGuts().gaTrackEvent("player", b ? "enableCrossfade" : "disableCrossfade") | |
| }, | |
| setPrefetchEnabled: function( b ) { | |
| b = b ? true : false; | |
| a.player && a.player.setPrefetchEnabled(b); | |
| GS.getGuts().gaTrackEvent("player", b ? "enablePrefetch" : "disablePrefetch") | |
| }, | |
| getPrefetchEnabled: function() { | |
| if ( a.player ) return a.player.getPrefetchEnabled() | |
| }, | |
| setLowerQuality: function( b ) { | |
| b = b ? true : false; | |
| a.player && a.player.setLowerQuality(b); | |
| GS.getGuts().gaTrackEvent("player", b ? "enableLowerQuality" : "disableLowerQuality") | |
| }, | |
| getLowerQuality: function() { | |
| if ( a.player ) return a.player.getLowerQuality() | |
| }, | |
| getIsMuted: function() { | |
| if ( a.player ) return a.player.getIsMuted() | |
| }, | |
| setIsMuted: function( b ) { | |
| b = b ? true : false; | |
| a.player && a.player.setIsMuted(b); | |
| GS.getGuts().gaTrackEvent("player", b ? "enableMuted" : "disableMuted") | |
| }, | |
| getPlayPauseFade: function() { | |
| if ( a.player ) return a.player.getPlayPauseFade() | |
| }, | |
| setPlayPauseFade: function( b ) { | |
| b = b ? true : false; | |
| a.player && a.player.setPlayPauseFade(b); | |
| GS.user.settings.changeLocalSettings({ | |
| playPauseFade: b ? 1 : 0 | |
| }); | |
| GS.getGuts().gaTrackEvent("player", b ? "enablePlayPauseFade" : "disablePlayPauseFade") | |
| }, | |
| setRepeat: function( b ) { | |
| a.repeat = b; | |
| a.player && a.player.setRepeat(b); | |
| GS.getGuts().gaTrackEvent("player", "setRepeat", b) | |
| }, | |
| getRepeat: function() { | |
| if ( a.player && a.player.getRepeat ) return a.player.getRepeat(); | |
| return a.repeat | |
| }, | |
| setShuffle: function( b ) { | |
| if (!(a.queue && a.queue.autoplayEnabled)) { | |
| b = b ? true : false; | |
| a.player && a.player.setShuffle(b); | |
| GS.user.settings.changeLocalSettings({ | |
| lastShuffle: b ? 1 : 0 | |
| }); | |
| GS.getGuts().gaTrackEvent("player", "shuffle", b ? "on" : "off") | |
| } | |
| }, | |
| getShuffle: function() { | |
| if ( a.player ) return a.player.getShuffle(); | |
| return false | |
| }, | |
| setPersistShuffle: function( b ) { | |
| b = b ? true : false; | |
| a.player && a.player.setPersistShuffle(b); | |
| GS.getGuts().gaTrackEvent("player", "persistShuffle", b ? "on" : "off") | |
| }, | |
| prefetchStreamKeys: function( b ) { | |
| if ( a.player ) return a.player.prefetchStreamKeys(b) | |
| }, | |
| getAPIVersion: function() { | |
| if ( a.player ) return a.player.getAPIVersion() | |
| }, | |
| getApplicationVersion: function() { | |
| if ( a.player ) return a.player.getApplicationVersion() | |
| }, | |
| updateSongOnPlayer: function( b, c, g ) { | |
| if ( b ) { | |
| g = _.orEqual(g, false); | |
| c = _.orEqual(c, false); | |
| if (!(!c && a.currentSong && a.currentSong.queueSongID === b.queueSongID)) { | |
| if ( b instanceof GS.Models.Song ) a.currentSong = b; | |
| else { | |
| a.currentSong = GS.Models.Song.wrapQueue([b])[0]; | |
| if (!(a.currentSong instanceof GS.Models.Song)) return | |
| } | |
| a.videoIndex = a.currentSong.index; | |
| $("#queue_list li.queue-item.queue-item-active").removeClass("active"); | |
| $("#queue_list #" + a.currentSong.queueSongID).addClass("active"); | |
| $("#playerDetails_nowPlaying").html(a.view("currentSongDetails")).attr("rel", a.currentSong.SongID).attr("qsid", a.currentSong.queueSongID); | |
| a.currentSongString.hookup($("#playerDetails_current_song")); | |
| _.defined(a.currentSong.index && a.currentSong.index >= 0) && a.gsQueue.setActive(a.currentSong.index, !a.isMouseDown && !g); | |
| $.publish("gs.player.currentSong", b) | |
| } | |
| } | |
| }, | |
| updateQueueDetails: function( b ) { | |
| b || (b = a.getCurrentQueue(true)); | |
| if ( b && b.hasOwnProperty("songs") && a.currentSongs != b.songs ) { | |
| a.currentSongs = b.songs; | |
| b.songs.length && a.queueClosed && !a.queueClosedByUser && a.setQueue(a.queueSize); | |
| if ( b.songs && b.songs.length > 0 ) { | |
| $("#player_seeking_scrubber").show(); | |
| $("#player_previous").removeAttr("disabled").removeClass("disabled"); | |
| b.previousSong ? $("#player_previous").attr("data-tooltip", _.uncleanText(b.previousSong.SongName)) : $("#player_previous").removeAttr("data-tooltip") | |
| } else if (!GS.player.queue.autoplayEnabled ) { | |
| $("#player_seeking_scrubber").hide(); | |
| $("#player_previous").attr("disabled", "disabled").addClass("disabled").removeAttr("data-tooltip"); | |
| $("#player_radio_button").removeClass("active"); | |
| $("#player_radio_switch").stop().css({ | |
| left: 0 | |
| }) | |
| } | |
| } | |
| if ( b && b.hasOwnProperty("nextSong") && a.nextSongToPlay != b.nextSong ) if ( a.nextSongToPlay = b.nextSong ) { | |
| $("#player_next").removeAttr("disabled").removeClass("disabled").attr("data-tooltip", _.uncleanText(b.nextSong.SongName)); | |
| if ( a.pauseNextQueueSongID && b.nextSong.hasOwnProperty("queueSongID") && b && b.hasOwnProperty("activeSong") && a.pauseNextQueueSongID !== b.activeSong.queueSongID ) a.pauseNextQueueSongID = b.nextSong.queueSongID | |
| } else $("#player_next", a.element).attr("disabled", "disabled").addClass("disabled").removeAttr("data-tooltip"); | |
| if ( a.activeSong != b.activeSong ) { | |
| var c = a.activeSong ? a.activeSong.queueSongID : null; | |
| a.activeSong = b.activeSong; | |
| if ( b && b.hasOwnProperty("activeSong") ) { | |
| $("#player_play_pause").removeAttr("disabled").removeClass("disabled"); | |
| a.updateSongOnPlayer(b.activeSong, true, c && b.activeSong && c == b.activeSong.queueSongID) | |
| } else $("#player_play_pause").attr("disabled", "disabled").addClass("disabled") | |
| } | |
| $("#playerDetails_queue").html(a.view("queueDetails")); | |
| c = b.songs.length === 0 ? "QUEUE_NO_SONGS" : b.songs.length == 1 ? "QUEUE_ONE_SONG" : "QUEUE_NUM_SONGS"; | |
| $("#queue_songCountLink").localeDataString(c, { | |
| numSongs: b.songs.length | |
| }); | |
| if ( b && b.hasOwnProperty("repeatMode") && a.repeatMode != b.repeatMode ) { | |
| a.repeatMode = b.repeatMode; | |
| if ( a.repeatMode === a.REPEAT_ALL ) $("#player_loop").removeClass("none").addClass("all").addClass("active"); | |
| else if ( a.repeatMode === a.REPEAT_ONE ) $("#player_loop").removeClass("all").addClass("one").addClass("active"); | |
| else a.repeatMode === a.REPEAT_NONE && $("#player_loop").removeClass("one").addClass("none").removeClass("active") | |
| } | |
| if ( b && b.hasOwnProperty("autoplayEnabled") && a.autoplayEnabled != b.autoplayEnabled ) { | |
| if ( a.autoplayEnabled = b.autoplayEnabled ) { | |
| $("#queue_list").addClass("autoplay"); | |
| $("#player_shuffle").removeClass("active"); | |
| $("#player_radio_switch").stop().animate({ | |
| left: 25 | |
| }, { | |
| duration: 100, | |
| complete: function() { | |
| $("#player_radio_button").addClass("active") | |
| } | |
| }) | |
| } else { | |
| $("#queue_list").removeClass("autoplay"); | |
| $("#player_radio_switch").stop().animate({ | |
| left: 0 | |
| }, { | |
| duration: 100, | |
| complete: function() { | |
| $("#player_radio_button").removeClass("active") | |
| } | |
| }); | |
| b.shuffleEnabled ? $("#player_shuffle").addClass("active") : $("#player_shuffle").removeClass("active") | |
| } | |
| $.publish("gs.player.autoplay.update", b.autoplayEnabled); | |
| a.trackLastAutoplayInfo(b.autoplayEnabled, b.currentAutoplayTagID) | |
| } | |
| }, | |
| updateQueueSongs: function( b ) { | |
| if ( b.hasOwnProperty("songs") ) if ( b.songs.length ) { | |
| a.currentSong = b.activeSong; | |
| a.songs = b.songs; | |
| a.gsQueue.setActive(b.activeSong.index, false); | |
| a.gsQueue.setItems(b.songs, true) | |
| } else { | |
| a.activeSong = b.activeSong; | |
| a.songs = b.songs; | |
| $("#playerDetails_nowPlaying").html(""); | |
| a.gsQueue.setActive(0, false); | |
| a.gsQueue.setItems([], true) | |
| } | |
| }, | |
| updateQueueWidth: function() { | |
| var b, c, g = a.getCurrentQueue(); | |
| if ( g ) { | |
| parseInt($("#queue_list_window").css("padding-left"), 10); | |
| b = $("#queue").width(); | |
| c = $("#queue").height(); | |
| if ( g && g.songs && g.songs.length > 0 ) { | |
| b = a.songWidth * (g.songs.length - 1) + a.activeSongWidth; | |
| $("#queue_list").removeClass("empty") | |
| } else { | |
| b = b; | |
| $("#queue_list").addClass("empty").width("") | |
| } | |
| c !== $("#queue").height() && a.lastQueueWidth !== b && $(window).resize(); | |
| a.lastQueueWidth = b | |
| } | |
| }, | |
| autoScrollWaitDuration: 300, | |
| beginDragDrop: function() { | |
| function b(k, m) { | |
| var p = $("#queue_songGuide"); | |
| if ( c.within(k.clientX, k.clientY).length > 0 ) { | |
| m.queueLength = _.orEqual(m.queueLength, a.getCurrentQueue().songs.length); | |
| var n = c.parent(), | |
| o = a.activeSongWidth - a.songWidth, | |
| t = 0, | |
| w = c.offset().left, | |
| x = g.scrollLeft() - 10 - (k.clientX > parseInt($("#queue_list .queue-item-active").css("left"), 10) + a.activeSongWidth ? o : 0), | |
| v = parseInt(g.width(), 10) * 0.05; | |
| c.children(); | |
| o = a.getCurrentQueue().activeSong ? _.orEqual(a.getCurrentQueue().activeSong.index, 0) : 0; | |
| stopIndex = Math.max(0, Math.min(m.queueLength, Math.round((k.clientX + x) / a.songWidth))); | |
| guideLeft = stopIndex * a.songWidth + w - p.width() / 2; | |
| w = function() { | |
| var E = (new Date).valueOf(); | |
| if (!m.queueAutoScrollLast || E - m.queueAutoScrollLast >= a.autoScrollWaitDuration ) { | |
| m.queueAutoScrollLast = E; | |
| t = Math.max(0, x - v); | |
| g.scrollLeft(t); | |
| a.gsQueue.updateScrollbar() | |
| } | |
| }; | |
| var B = function() { | |
| var E = (new Date).valueOf(); | |
| if (!m.queueAutoScrollLast || E - m.queueAutoScrollLast >= a.autoScrollWaitDuration ) { | |
| m.queueAutoScrollLast = E; | |
| t = Math.min(c.width(), x + v); | |
| g.scrollLeft(t); | |
| a.gsQueue.updateScrollbar() | |
| } | |
| }; | |
| if ( n.offset().left + 200 > k.clientX ) { | |
| w(); | |
| clearInterval(m.queueAutoScrollInterval); | |
| m.queueAutoScrollInterval = setInterval(w, a.autoScrollWaitDuration) | |
| } else if ( n.width() - 200 < k.clientX ) { | |
| B(); | |
| clearInterval(m.queueAutoScrollInterval); | |
| m.queueAutoScrollInterval = setInterval(B, a.autoScrollWaitDuration) | |
| } else { | |
| clearInterval(m.queueAutoScrollInterval); | |
| m.queueAutoScrollInterval = false | |
| } | |
| if ( stopIndex > o ) guideLeft += a.activeSongWidth - a.songWidth; | |
| p.css("left", guideLeft); | |
| p.show() | |
| } else { | |
| clearInterval(m.queueAutoScrollInterval); | |
| m.queueAutoScrollInterval = false; | |
| p.hide() | |
| } | |
| } | |
| var c = $("#queue_list"), | |
| g = $("#queue_list_window"), | |
| h = $("#queue"); | |
| $footer = $("#footer"); | |
| c.bind("draginit", function( k, m ) { | |
| var p = $(k.target).closest(".queue-item"); | |
| if ( p.length === 0 ) return false; | |
| m.draggedQueueItem = p; | |
| m.proxyOffsetX = k.clientX - p.offset().left; | |
| m.proxyOffsetY = k.clientY - p.offset().top | |
| }).bind("dragstart", function( k, m ) { | |
| m.draggedItems = [GS.Models.Song.getOneFromCache($(m.draggedQueueItem).find(".queueSong").attr("rel"))]; | |
| m.draggedItemsType = "song"; | |
| m.draggedItemSource = "queue"; | |
| var p = parseInt(m.draggedQueueItem.attr("data-queuesongid"), 10); | |
| if ( p ) m.deleteAction = { | |
| label: "SHORTCUTS_DELETE_NOW_PLAYING", | |
| method: function() { | |
| GS.player.removeSongs(p) | |
| } | |
| }; | |
| $.publish("gs.drag.start", m); | |
| return $('<div class="queue-item-drag size-' + GS.player.queueSize + '" style="position:absolute; z-index: 99999;"><div class="status"></div></div>').append($(m.draggedQueueItem).clone()).appendTo("body").mousewheel(_.globalDragProxyMousewheel) | |
| }).bind("drag", function( k, m ) { | |
| m.clientX = k.clientX; | |
| m.clientY = | |
| k.clientY; | |
| $(m.proxy).css("top", k.clientY - m.proxyOffsetY).css("left", k.clientX - m.proxyOffsetX); | |
| var p = false, | |
| n = false; | |
| _.forEach(m.drop, function( o ) { | |
| $.isFunction(o.updateDropOnDrag) && o.updateDropOnDrag(k, m); | |
| if (!p ) if ( $(o).within(k.clientX, k.clientY).length > 0 ) if ( $(o).data("ignoreForOverDrop") ) n = true; | |
| else { | |
| n = false; | |
| p = true | |
| } | |
| }); | |
| n || (p ? $(m.proxy).addClass("valid").removeClass("invalid") : $(m.proxy).addClass("invalid").removeClass("valid")) | |
| }).bind("dragend", function( k, m ) { | |
| $(m.proxy).remove(); | |
| GS.getGuts().gaTrackEvent("player", "dragSuccess"); | |
| $.publish("gs.drag.end", m) | |
| }); | |
| $footer.bind("dropinit", function() { | |
| this.updateDropOnDrag = b | |
| }).bind("dropstart", function( k, m ) { | |
| if (!m.draggedItems ) { | |
| this.updateDropOnDrag = null; | |
| return false | |
| } | |
| m.draggedItemsType = m.draggedItemsType || _.guessDragType(m.draggedItems); | |
| $(".queue-item").length && m.draggedItemsType !== "station" && $("<div id='queue_songGuide'/>").addClass("size_" + GS.player.queueSize).css({ | |
| position: "absolute", | |
| zIndex: "99998", | |
| height: $(".queue-item").outerHeight(true), | |
| width: 10, | |
| top: $(".queue-item").offset().top + 5 | |
| }).hide().appendTo("body") | |
| }).bind("dropend", function( k, m ) { | |
| $("#queue_songGuide").remove(); | |
| clearInterval(m.queueAutoScrollInterval) | |
| }).bind("drop", function( k, m ) { | |
| $(this).offset(); | |
| var p = $footer.within(k.clientX, k.clientY).length > 0; | |
| h.within(k.clientX, k.clientY); | |
| var n = a.activeSongWidth - a.songWidth; | |
| n = $("#queue_list_window").scrollLeft() - 10 - (k.clientX > parseInt($("#queue_list .queue-item-active").css("left"), 10) + a.activeSongWidth ? n : 0); | |
| n = Math.max(0, Math.min(m.queueLength, Math.round((k.clientX + n) / a.songWidth))); | |
| if ( m.draggedItemSource == "queue" ) { | |
| if (!($(".queue-item", c).length < 2)) { | |
| queueSongID = m.draggedQueueItem.find(".queueSong").attr("id"); | |
| a.moveSongsTo([queueSongID], n) | |
| } | |
| } else { | |
| var o = [], | |
| t, w, x, v; | |
| if ( p ) if (!(k.clientX === 0 && k.layerX === 0 && k.offsetX === 0 && k.screenX === 0)) { | |
| m.draggedItemsType = m.draggedItemsType || _.guessDragType(m.draggedItems); | |
| switch ( m.draggedItemsType ) { | |
| case "song": | |
| t = []; | |
| for ( x = 0; x < m.draggedItems.length; x++ ) | |
| t.push(m.draggedItems[x].SongID); | |
| o.push({ | |
| songIDs: t, | |
| context: m.draggedItemsContext | |
| }); | |
| var B, E = [], | |
| H = []; | |
| p = $("#grid"); | |
| if ( p.controller() ) { | |
| var G = p.controller().dataView.rows; | |
| $('#grid .slick-row.selected[id!="showQueue"]').each(function( D, y ) { | |
| B = parseInt($(y).attr("row"), 10); | |
| if (!isNaN(B) ) { | |
| E.push(B + 1); | |
| var A = G[B].ppVersion; | |
| A && H.push(A) | |
| } | |
| }) | |
| } | |
| p = { | |
| ranks: E, | |
| songIDs: t | |
| }; | |
| if ( H.length > 0 ) p.ppVersions = H.join(); | |
| GS.getGuts().logMultiSongDrag("OLSongsDraggedToQueue", p); | |
| break; | |
| case "album": | |
| for ( x = 0; x < m.draggedItems.length; x++ ) { | |
| t = []; | |
| m.draggedItems[x].getSongs(function( D ) { | |
| D.sort(GS.Models.Album.defaultSongSort); | |
| for ( v = 0; v < D.length; v++ ) | |
| t.push(D[v].SongID) | |
| }, null, true, { | |
| async: false | |
| }); | |
| o.push({ | |
| songIDs: t, | |
| context: new GS.Models.PlayContext(GS.player.PLAY_CONTEXT_ALBUM, m.draggedItems[x]) | |
| }) | |
| } | |
| break; | |
| case "artist": | |
| for ( x = 0; x < m.draggedItems.length; x++ ) { | |
| t = []; | |
| m.draggedItems[x].getSongs(function( D ) { | |
| D.sort(GS.Models.Artist.defaultSongSort); | |
| for ( v = 0; v < D.length; v++ ) | |
| t.push(D[v].SongID) | |
| }, null, { | |
| async: false | |
| }); | |
| o.push({ | |
| songIDs: t, | |
| context: new GS.Models.PlayContext(GS.player.PLAY_CONTEXT_ARTIST, m.draggedItems[x]) | |
| }) | |
| } | |
| break; | |
| case "playlist": | |
| for ( x = 0; x < m.draggedItems.length; x++ ) { | |
| t = []; | |
| m.draggedItems[x].getSongs(function( D ) { | |
| for ( v = | |
| 0; v < D.length; v++ ) | |
| t.push(D[v].SongID) | |
| }, null, false, { | |
| async: false | |
| }); | |
| o.push({ | |
| songIDs: t, | |
| context: new GS.Models.PlayContext(GS.player.PLAY_CONTEXT_PLAYLIST, m.draggedItems[x]) | |
| }) | |
| } | |
| break; | |
| case "user": | |
| for ( x = 0; x < m.draggedItems.length; x++ ) { | |
| t = []; | |
| m.draggedItems[x].getFavoritesByType("Songs", function( D ) { | |
| _.forEach(D, function( y ) { | |
| t.push(y.SongID) | |
| }) | |
| }, null, { | |
| async: false | |
| }); | |
| o.push({ | |
| songIDs: t, | |
| context: new GS.Models.PlayContext(GS.player.PLAY_CONTEXT_USER, m.draggedItems[x]) | |
| }) | |
| } | |
| break; | |
| case "station": | |
| GS.player.setAutoplay(true, m.draggedItems[0].StationID); | |
| return; | |
| default: | |
| console.error("queue drop, invalid drag type", m.draggedItemsType); | |
| return | |
| } | |
| w = h.within(k.clientX, k.clientY).length > 0 || a.getCurrentQueue().songs.length > 0 ? false : true; | |
| for ( x = 0; x < o.length; x++ ) { | |
| t = o[x].songIDs; | |
| p = _.orEqual(o[x].context, new GS.Models.PlayContext); | |
| a.addSongsToQueueAt(t, n, w, p); | |
| n += t.length; | |
| w = false | |
| } | |
| GS.getGuts().gaTrackEvent("player", "dropSuccess") | |
| } | |
| } | |
| }) | |
| }, | |
| addQueueSeek: function() { | |
| this.seek = $("#seeking_wrapper"); | |
| this.scrubber = $("#seeking_wrapper .scrubber").addClass("ui-slider-handle").supersleight(); | |
| this.seek.slider({ | |
| disabled: true, | |
| max: 1E3, | |
| start: function() { | |
| GS.player.SCRUB_LOCK = true | |
| }, | |
| stop: function() { | |
| GS.player.SCRUB_LOCK = false | |
| }, | |
| change: function( b, c ) { | |
| var g = c.value / 1E3, | |
| h = a.player.getPlaybackStatus(); | |
| a.seekTo(g * h.duration) | |
| } | |
| }) | |
| }, | |
| addShortcuts: function() { | |
| a.volumeSliderTimeout = null; | |
| a.volumeSliderDuration = 300; | |
| $(document).bind("keyup", "space", function( b ) { | |
| $(b.target).is("button") && b.preventDefault() | |
| }).bind("keydown", "space", function( b ) { | |
| if (!($(b.target).is("input,textarea,select") && $(b.target).val().length > 0)) { | |
| a.togglePlayPause(); | |
| GS.getGuts().gaTrackEvent("player", "playPauseShortcut"); | |
| return false | |
| } | |
| }).bind("keydown", "ctrl+right", function( b ) { | |
| if (!($(b.target).is("input,textarea,select") && $(b.target).val().length > 0)) { | |
| a.nextSong(); | |
| GS.getGuts().gaTrackEvent("player", "nextShortcut"); | |
| return false | |
| } | |
| }).bind("keydown", "meta+right", function( b ) { | |
| if (!($(b.target).is("input,textarea,select") && $(b.target).val().length > 0)) { | |
| a.nextSong(); | |
| GS.getGuts().gaTrackEvent("player", "nextShortcut"); | |
| return false | |
| } | |
| }).bind("keydown", "ctrl+left", function( b ) { | |
| if (!($(b.target).is("input,textarea,select") && $(b.target).val().length > 0)) { | |
| a.previousSong(); | |
| GS.getGuts().gaTrackEvent("player", "prevShortcut"); | |
| return false | |
| } | |
| }).bind("keydown", "meta+left", function( b ) { | |
| if (!($(b.target).is("input,textarea,select") && $(b.target).val().length > 0)) { | |
| a.previousSong(); | |
| GS.getGuts().gaTrackEvent("player", "prevShortcut"); | |
| return false | |
| } | |
| }).bind("keydown", "ctrl+up", function( b ) { | |
| if (!($(b.target).is("input,textarea,select") && $(b.target).val().length > 0)) { | |
| a.setVolume(Math.min(100, a.getVolume() + 5)); | |
| $("#volumeSlider").slider("value", a.getVolume()); | |
| $("#volumeControl").show(); | |
| clearTimeout(a.volumeSliderTimeout); | |
| a.volumeSliderTimeout = setTimeout(function() { | |
| $("#volumeControl").hide() | |
| }, a.volumeSliderDuration); | |
| GS.getGuts().gaTrackEvent("player", "volumeUpShortcut", a.getVolume()); | |
| return false | |
| } | |
| }).bind("keydown", "meta+up", function( b ) { | |
| if (!($(b.target).is("input,textarea,select") && $(b.target).val().length > 0)) { | |
| a.setVolume(Math.min(100, a.getVolume() + 5)); | |
| $("#volumeSlider").slider("value", a.getVolume()); | |
| $("#volumeControl").show(); | |
| clearTimeout(a.volumeSliderTimeout); | |
| a.volumeSliderTimeout = setTimeout(function() { | |
| $("#volumeControl").hide() | |
| }, a.volumeSliderDuration); | |
| GS.getGuts().gaTrackEvent("player", "volumeUpShortcut", a.getVolume()); | |
| return false | |
| } | |
| }).bind("keydown", "ctrl+down", function( b ) { | |
| if (!($(b.target).is("input,textarea,select") && $(b.target).val().length > 0)) { | |
| a.setVolume(Math.max(0, a.getVolume() - 5)); | |
| $("#volumeSlider").slider("value", a.getVolume()); | |
| $("#volumeControl").show(); | |
| clearTimeout(a.volumeSliderTimeout); | |
| a.volumeSliderTimeout = setTimeout(function() { | |
| $("#volumeControl").hide() | |
| }, a.volumeSliderDuration); | |
| GS.getGuts().gaTrackEvent("player", "volumeDownShortcut", a.getVolume()); | |
| return false | |
| } | |
| }).bind("keydown", "meta+down", function( b ) { | |
| if (!($(b.target).is("input,textarea,select") && $(b.target).val().length > 0)) { | |
| a.setVolume(Math.max(0, a.getVolume() - 5)); | |
| $("#volumeSlider").slider("value", a.getVolume()); | |
| $("#volumeControl").show(); | |
| clearTimeout(a.volumeSliderTimeout); | |
| a.volumeSliderTimeout = setTimeout(function() { | |
| $("#volumeControl").hide() | |
| }, a.volumeSliderDuration); | |
| GS.getGuts().gaTrackEvent("player", "volumeDownShortcut", a.getVolume()); | |
| return false | |
| } | |
| }) | |
| }, | |
| addVolumeSlider: function() { | |
| var b = ["off", "one", "two", "three", "four", "five"], | |
| c = function( g, h ) { | |
| var k = _.orEqual(Math.ceil(h.value / 20), 5); | |
| k = b[k]; | |
| $("#player_volume").attr("class", "player_control main_asset " + k); | |
| h.value == 0 && a.getIsMuted() ? $("#player_volume").addClass("muted") : a.setVolume(h.value) | |
| }; | |
| $("#volumeSlider").slider({ | |
| orientation: "vertical", | |
| range: "min", | |
| min: 0, | |
| max: 100, | |
| slide: c, | |
| change: c | |
| }) | |
| }, | |
| addQueueResize: function() { | |
| var b = | |
| this; | |
| $("#player_queue").resizable({ | |
| handles: { | |
| s: $("#player_queue_resize") | |
| }, | |
| minHeight: 0, | |
| maxHeight: 185, | |
| animate: false, | |
| distance: 10, | |
| iframeFix: true, | |
| resize: function() { | |
| $("#deselector").select(); | |
| $("#queue_list_window").hide(); | |
| b.gsQueue && b.gsQueue.setDisabled(true); | |
| GS.resize() | |
| }, | |
| stop: function( c, g ) { | |
| var h = g.size.height - 30; | |
| $("#queue_list_window").show(); | |
| if ( h > 145 ) b.setQueue("l"); | |
| else if ( h > 100 ) b.setQueue("m"); | |
| else h > 15 ? b.setQueue("s") : b.setQueue("off"); | |
| $("#player_queue").height("auto").width("auto"); | |
| GS.resize() | |
| } | |
| }) | |
| }, | |
| ".queueSong a.play click": function( b, c ) { | |
| c.stopImmediatePropagation(); | |
| var g = a.getCurrentQueue(true); | |
| if ( g && g.activeSong && b.attr("rel") == g.activeSong.queueSongID ) if ( a.isPlaying ) a.pauseSong(); | |
| else a.isPaused ? a.resumeSong() : a.playSong(g.activeSong.queueSongID); | |
| else a.playSong(b.attr("rel")); | |
| return false | |
| }, | |
| ".queueSong a.remove click": function( b, c ) { | |
| c.stopImmediatePropagation(); | |
| var g = a.getCurrentQueue().activeSong, | |
| h = a.getSongDetails(a.getCurrentQueue().queueID, b.parents(".queueSong").attr("id"))[0]; | |
| a.removeSongs([h.queueSongID]); | |
| a.queue = false; | |
| a.queue = a.getCurrentQueue(); | |
| a.updateQueueWidth(); | |
| a.gsQueue.setItems(a.queue.songs); | |
| if ( a.queue.activeSong ) a.gsQueue.setActive(a.queue.activeSong.index, false); | |
| else g && g.index && g.index > 0 && a.gsQueue.setActive(g.index - 1, false); | |
| GS.getGuts().gaTrackEvent("player", "removeSong", h.SongID); | |
| return false | |
| }, | |
| ".queueSong a.add click": function( b, c ) { | |
| c.stopImmediatePropagation(); | |
| var g = a.getCurrentQueue(), | |
| h = b.is(".inLibrary"), | |
| k = b.parents(".queueSong").attr("id"); | |
| g = a.getSongDetails(g.queueID, [k])[0]; | |
| if ( a.currentSong && a.currentSong.queueSongID === g.queueSongID ) g = a.currentSong; | |
| if ( h ) { | |
| b.removeClass("inLibrary").removeClass("isFavorite"); | |
| GS.user.removeFromLibrary(g.SongID); | |
| GS.getGuts().logEvent("playerRemoveFromLibrary", { | |
| songID: g.SongID | |
| }) | |
| } else { | |
| b.addClass("inLibrary"); | |
| GS.user.addToLibrary(g.SongID); | |
| GS.getGuts().logEvent("playerAddToLibrary", { | |
| songID: g.SongID | |
| }) | |
| } | |
| return false | |
| }, | |
| ".queueSong a.favorite click": function( b, c ) { | |
| c.stopImmediatePropagation(); | |
| var g = a.getCurrentQueue(), | |
| h = b.is(".isFavorite"), | |
| k = b.parents(".queueSong").attr("id"); | |
| g = a.getSongDetails(g.queueID, [k])[0]; | |
| if ( a.currentSong && a.currentSong.queueSongID === g.queueSongID ) g = a.currentSong; | |
| if ( h ) { | |
| b.removeClass("isFavorite"); | |
| GS.user.removeFromSongFavorites(g.SongID); | |
| GS.getGuts().logEvent("playerRemoveFromSongFavorites", { | |
| songID: g.SongID | |
| }) | |
| } else { | |
| b.addClass("isFavorite"); | |
| GS.user.addToSongFavorites(g.SongID); | |
| GS.getGuts().logEvent("playerAddToSongFavorites", { | |
| songID: g.SongID | |
| }) | |
| } | |
| return false | |
| }, | |
| ".queueSong a.options click": function( b, c ) { | |
| var g = this.getCurrentQueue(), | |
| h = b.parents(".queueSong").attr("id"); | |
| g = this.getSongDetails(g.queueID, [h])[0]; | |
| var k = { | |
| isQueue: true, | |
| flagSongCallback: function( m ) { | |
| GS.player.flagSong(h, m) | |
| }, | |
| voteSongCallback: function( m ) { | |
| GS.player.voteSong(h, m) | |
| } | |
| }; | |
| if ( $("div.qsid" + h).is(":visible") ) { | |
| $("div.qsid" + h).hide(); | |
| b.removeClass("active-context") | |
| } else { | |
| b.addClass("active-context").jjmenu(c, g.getContextMenu(k), null, { | |
| xposition: "auto", | |
| yposition: "top", | |
| orientation: "top", | |
| show: "show", | |
| className: "queuemenu qsid" + h, | |
| keepState: b | |
| }); | |
| GS.getGuts().gaTrackEvent("player", "songMenu", g.SongID) | |
| } | |
| }, | |
| ".queueSong .smile click": function( b, c ) { | |
| c.stopImmediatePropagation(); | |
| console.log("player.smile click", b, c); | |
| var g = b.parents(".queueSong").attr("id"); | |
| b.siblings(".frown").removeClass("active"); | |
| if ( b.is(".active") ) { | |
| this.voteSong(g, 0); | |
| b.removeClass("active"); | |
| GS.getGuts().gaTrackEvent("player", "unsmile", b.parents(".queueSong").attr("id")); | |
| this.trackAutoplayEvent("unsmile") | |
| } else { | |
| this.voteSong(g, 1); | |
| b.addClass("active"); | |
| GS.getGuts().gaTrackEvent("player", "smile", b.parents(".queueSong").attr("id")); | |
| this.trackAutoplayEvent("smile") | |
| } | |
| return false | |
| }, | |
| ".queueSong .frown click": function( b, c ) { | |
| c.stopImmediatePropagation(); | |
| console.log("player.frown click", b.get(), c); | |
| var g = b.parents(".queueSong").attr("id"); | |
| b.siblings(".smile").removeClass("active"); | |
| if ( b.is(".active") ) { | |
| this.voteSong(g, 0); | |
| b.removeClass("active"); | |
| GS.getGuts().gaTrackEvent("player", "unfrown", b.parents(".queueSong").attr("id")); | |
| this.trackAutoplayEvent("unfrown") | |
| } else { | |
| this.voteSong(g, -1); | |
| b.addClass("active"); | |
| GS.getGuts().gaTrackEvent("player", "frown", b.parents(".queueSong").attr("id")); | |
| this.trackAutoplayEvent("frown") | |
| } | |
| return false | |
| }, | |
| ".currentSongLink, a.queueSong_name click": function( b, c ) { | |
| c.stopImmediatePropagation(); | |
| if (!$(c.target).is("a[href]") ) { | |
| var g = b.attr("rel"), | |
| h = GS.Models.Song.getOneFromCache(g); | |
| if ( h = h && $.isFunction(h.toUrl) ? h.toUrl() : false ) { | |
| location.hash = h; | |
| GS.getGuts().gaTrackEvent("player", "songItemLink", g) | |
| } | |
| return false | |
| } | |
| }, | |
| ".queueSong contextmenu": function( b, c ) { | |
| var g = GS.Models.Song.getOneFromCache(b.attr("rel")), | |
| h = b.attr("id"); | |
| b.jjmenu(c, g.getContextMenu({ | |
| isQueue: true, | |
| flagSongCallback: function( k ) { | |
| GS.player.flagSong(h, k) | |
| }, | |
| voteSongCallback: function( k ) { | |
| GS.player.voteSong(h, k) | |
| } | |
| }), null, { | |
| xposition: "mouse", | |
| yposition: "mouse", | |
| show: "show", | |
| className: "queuemenu" | |
| }); | |
| GS.getGuts().gaTrackEvent("player", "songMenu", g.SongID) | |
| }, | |
| "#playerDetails_nowPlaying_options click": function( b, c ) { | |
| var g = $("#playerDetails_nowPlaying").attr("rel"), | |
| h = this.getCurrentSong().queueSongID, | |
| k = GS.Models.Song.getOneFromCache(g), | |
| m = { | |
| isQueue: true, | |
| flagSongCallback: function( p ) { | |
| GS.player.flagSong(h, p) | |
| }, | |
| voteSongCallback: function( p ) { | |
| GS.player.voteSong(h, p) | |
| } | |
| }; | |
| if ( b.hasClass("active-context") ) { | |
| $(".jjplayerNowPlaying").hide(); | |
| b.removeClass("active-context") | |
| } else { | |
| b.addClass("active-context").jjmenu(c, k.getContextMenu(m), null, { | |
| xposition: "left", | |
| yposition: "top", | |
| orientation: "top", | |
| show: "show", | |
| className: "queuemenu jjplayerNowPlaying", | |
| keepState: b | |
| }); | |
| GS.getGuts().gaTrackEvent("player", "nowPlayingMenu", g) | |
| } | |
| }, | |
| togglePlayPause: function() { | |
| var b = this.player.getPlaybackStatus(); | |
| if ( b ) { | |
| switch ( b.status ) { | |
| case this.PLAY_STATUS_NONE: | |
| case this.PLAY_STATUS_FAILED: | |
| case this.PLAY_STATUS_COMPLETED: | |
| default: | |
| b.activeSong && this.playSong(b.activeSong.queueSongID); | |
| break; | |
| case this.PLAY_STATUS_INITIALIZING: | |
| case this.PLAY_STATUS_LOADING: | |
| this.stopSong(); | |
| break; | |
| case this.PLAY_STATUS_PLAYING: | |
| case this.PLAY_STATUS_BUFFERING: | |
| this.pauseSong(); | |
| break; | |
| case this.PLAY_STATUS_PAUSED: | |
| this.resumeSong(); | |
| break | |
| } | |
| $.publish("gs.player.queue.change") | |
| } | |
| }, | |
| "#player_play_pause click": function() { | |
| this.togglePlayPause(); | |
| return false | |
| }, | |
| "#player_previous click": function() { | |
| this.previousSong(); | |
| return false | |
| }, | |
| "#player_next click": function() { | |
| this.nextSong(); | |
| return false | |
| }, | |
| "#player_shuffle click": function( b ) { | |
| if (!a.queue.autoplayEnabled ) { | |
| b.toggleClass("active"); | |
| b = b.is(".active") ? true : false; | |
| a.setShuffle(b); | |
| return false | |
| } | |
| }, | |
| "#player_loop click": function( b ) { | |
| var c; | |
| if ( b.is(".none") ) { | |
| c = a.REPEAT_ALL; | |
| b.removeClass("none").addClass("all").addClass("active") | |
| } else if ( b.is(".all") ) { | |
| c = a.REPEAT_ONE; | |
| b.removeClass("all").addClass("one").addClass("active") | |
| } else { | |
| c = a.REPEAT_NONE; | |
| b.removeClass("one").addClass("none").removeClass("active") | |
| } | |
| a.setRepeat(c); | |
| return false | |
| }, | |
| "#player_crossfade click": function( b ) { | |
| if ( GS.user.UserID > 0 && GS.user.IsPremium ) { | |
| b.toggleClass("active"); | |
| b = b.is(".active") ? true : false; | |
| a.setCrossfadeEnabled(b) | |
| } else GS.getLightbox().open("vipOnlyFeature", { | |
| callback: this.callback(function() { | |
| this.setCrossfadeEnabled(true) | |
| }) | |
| }); | |
| return false | |
| }, | |
| "#player_fullscreen click": function() { | |
| return false | |
| }, | |
| "#player_volume click": function( b ) { | |
| console.log("player_volume toggle", this.getIsMuted()); | |
| if ( this.getIsMuted() ) { | |
| this.setIsMuted(false); | |
| $(b).removeClass("muted"); | |
| $("#volumeSlider").slider("value", a.player.getVolume()) | |
| } else { | |
| this.setIsMuted(true); | |
| $(b).addClass("muted"); | |
| $("#volumeSlider").slider("value", 0) | |
| } | |
| return false | |
| }, | |
| "#player_volume mouseenter": function() { | |
| clearTimeout(this.volumeSliderTimeout); | |
| $("#volumeControl").show(); | |
| return false | |
| }, | |
| "#player_volume mouseleave": function() { | |
| clearTimeout(this.volumeSliderTimeout); | |
| this.volumeSliderTimeout = setTimeout(this.callback(function() { | |
| $("#volumeControl").hide() | |
| }), this.volumeSliderDuration); | |
| return false | |
| }, | |
| "#volumeControl mouseenter": function() { | |
| clearTimeout(this.volumeSliderTimeout); | |
| return false | |
| }, | |
| "#volumeControl mouseleave": function() { | |
| clearTimeout(this.volumeSliderTimeout); | |
| if ( this.isMouseDown ) { | |
| var b = this, | |
| c = function() { | |
| $("body").unbind("mouseup", c); | |
| $("body").unbind("mouseleave", c); | |
| b.isMouseDown = 0; | |
| b.volumeSliderTimeout = setTimeout(b.callback(function() { | |
| $("#volumeControl").hide() | |
| }), b.volumeSliderDuration) | |
| }; | |
| $("body").bind("mouseup", c); | |
| $("body").bind("mouseleave", c) | |
| } else this.volumeSliderTimeout = setTimeout(this.callback(function() { | |
| $("#volumeControl").hide() | |
| }), this.volumeSliderDuration); | |
| return false | |
| }, | |
| isMouseDown: 0, | |
| mousedown: function() { | |
| this.isMouseDown = 1 | |
| }, | |
| mouseup: function() { | |
| this.isMouseDown = | |
| 0 | |
| }, | |
| "#queue_load_button click": function( b, c ) { | |
| this.getCurrentQueue(true); | |
| var g = this, | |
| h = [], | |
| k; | |
| if ( GS.user.favorites.songs ) { | |
| k = _.toArrayID(GS.user.favorites.songs); | |
| k.length && h.push({ | |
| title: $.localize.getString("QUEUE_LOAD_FAVORITES"), | |
| customClass: "stations jj_menu_item_hasIcon jj_menu_item_favorites", | |
| action: { | |
| type: "fn", | |
| callback: function() { | |
| GS.player.addSongsToQueueAt(k) | |
| } | |
| } | |
| }) | |
| } | |
| var m = GS.Models.Playlist.getPlaylistsMenu([], function( p ) { | |
| var n = function() { | |
| var o = [], | |
| t = new GS.Models.PlayContext(GS.player.PLAY_CONTEXT_PLAYLIST, p); | |
| p.getSongs(function( w ) { | |
| for ( j = 0; j < w.length; j++ ) | |
| o.push(w[j].SongID); | |
| GS.player.addSongsToQueueAt(o, g.INDEX_REPLACE, true, t) | |
| }, null, false, { | |
| async: false | |
| }) | |
| }; | |
| if ( GS.player.queue && GS.player.queue.songs && GS.player.queue.songs.length > 0 ) { | |
| GS.getLightbox().close(); | |
| GS.getLightbox().open({ | |
| type: "playlistClearQueue", | |
| view: { | |
| header: "POPUP_LOAD_PLAYLIST_TITLE", | |
| message: "POPUP_LOAD_PLAYLIST_MESSAGE", | |
| buttonsLeft: [{ | |
| label: "CANCEL", | |
| className: "close" | |
| }], | |
| buttonsRight: [{ | |
| label: "POPUP_LOAD_PLAYLIST_BTN", | |
| className: "submit" | |
| }] | |
| }, | |
| callbacks: { | |
| ".submit": function() { | |
| n(); | |
| GS.getGuts().logEvent("playlistOverwriteQueue", { | |
| overwrite: 1 | |
| }) | |
| } | |
| } | |
| }); | |
| GS.getGuts().logEvent("playlistOverwriteQueue", { | |
| overwrite: 0 | |
| }) | |
| } else n() | |
| }, true, false); | |
| m.length > 0 && h.push({ | |
| title: $.localize.getString("QUEUE_LOAD_PLAYLIST"), | |
| customClass: "playlist jj_menu_item_hasIcon jj_menu_item_playlist", | |
| type: "sub", | |
| src: m | |
| }); | |
| h.push({ | |
| title: $.localize.getString("QUEUE_LOAD_STATION"), | |
| customClass: "stations jj_menu_item_hasIcon jj_menu_item_station", | |
| type: "sub", | |
| src: GS.Models.Station.getStationsStartMenu() | |
| }); | |
| if ( b.hasClass("active-context") ) { | |
| $(".jjQueueMenu").hide(); | |
| b.removeClass("active-context") | |
| } else { | |
| b.addClass("active-context").jjmenu(c, h, null, { | |
| xposition: "right", | |
| yposition: "top", | |
| orientation: "top", | |
| spill: "left", | |
| show: "show", | |
| className: "radiomenu jjQueueMenu", | |
| keepState: b | |
| }); | |
| GS.getGuts().gaTrackEvent("player", "queueLoadMenu") | |
| } | |
| }, | |
| "#queue_save_button click": function( b, c ) { | |
| var g = this.getCurrentQueue(true), | |
| h = [], | |
| k = []; | |
| if ( g && g.songs && g.songs.length > 0 ) h = [{ | |
| title: $.localize.getString("CONTEXT_ADD_TO_LIBRARY"), | |
| customClass: "addLibrary jj_menu_item_hasIcon jj_menu_item_music", | |
| action: { | |
| type: "fn", | |
| callback: function() { | |
| var n, o = []; | |
| for ( n = 0; n < g.songs.length; n++ ) { | |
| o.push(g.songs[n].SongID); | |
| GS.getGuts().logEvent("playerAddToLibrary", { | |
| songID: g.songs[n].SongID | |
| }) | |
| } | |
| GS.user.addToLibrary(o) | |
| } | |
| } | |
| }, | |
| { | |
| customClass: "separator" | |
| }]; | |
| if ( g && g.songs && g.songs.length > 0 ) { | |
| _.forEach(g.songs, function( n ) { | |
| k.push(n.SongID) | |
| }); | |
| var m = GS.Models.Playlist.getPlaylistsMenu(k, function( n ) { | |
| GS.getLightbox().open({ | |
| type: "confirm", | |
| view: { | |
| header: "POPUP_ARE_YOU_SURE", | |
| message: "POPUP_ARE_YOU_SURE_OVERWRITE_PLAYLIST", | |
| buttonsLeft: [{ | |
| label: "CANCEL", | |
| className: "close" | |
| }], | |
| buttonsRight: [{ | |
| label: "OK", | |
| className: "submit" | |
| }] | |
| }, | |
| callbacks: { | |
| ".submit": function() { | |
| n.overwriteWithSongs(k, true) | |
| } | |
| } | |
| }) | |
| }, false, true), | |
| p = GS.Models.Playlist.getPlaylistsMenu(k, function( n ) { | |
| n.addSongs(k, n.length, true) | |
| }, false, false); | |
| h.push({ | |
| title: $.localize.getString("QUEUE_SAVE_PLAYLIST"), | |
| customClass: "jj_menu_item_hasIcon jj_menu_item_replace_playlist saveQueue", | |
| type: "sub", | |
| src: m | |
| }); | |
| p.length && h.push({ | |
| title: $.localize.getString("QUEUE_ADD_TO_PLAYLIST"), | |
| customClass: "saveQueue jj_menu_item_hasIcon jj_menu_item_add_playlist", | |
| type: "sub", | |
| src: p | |
| }); | |
| h.length && h.push({ | |
| customClass: "separator" | |
| }); | |
| h.push({ | |
| title: $.localize.getString("QUEUE_EMBED_SONGS"), | |
| customClass: "jj_menu_item_hasIcon jj_menu_item_share_widget shareSongs", | |
| action: { | |
| type: "fn", | |
| callback: function() { | |
| var n, o = []; | |
| for ( n = 0; n < g.songs.length; n++ ) | |
| o.push(g.songs[n].SongID); | |
| GS.getLightbox().open("share", { | |
| service: "widget", | |
| type: "manySongs", | |
| id: o | |
| }) | |
| } | |
| } | |
| }) | |
| } | |
| if ( b.hasClass("active-context") ) { | |
| $(".jjQueueMenu").hide(); | |
| b.removeClass("active-context") | |
| } else { | |
| b.addClass("active-context").jjmenu(c, h, null, { | |
| xposition: "right", | |
| yposition: "top", | |
| orientation: "top", | |
| spill: "left", | |
| show: "show", | |
| className: "radiomenu jjQueueMenu", | |
| keepState: b | |
| }); | |
| GS.getGuts().gaTrackEvent("player", "queueSaveMenu") | |
| } | |
| }, | |
| "#player_options click": function( b, c ) { | |
| var g = this.getCurrentQueue(), | |
| h = this, | |
| k = []; | |
| k.push({ | |
| title: $.localize.getString("SETTINGS"), | |
| customClass: "jj_menu_item_hasIcon jj_menu_item_gear", | |
| action: { | |
| type: "gourl", | |
| url: "#/settings" | |
| } | |
| }); | |
| k.push({ | |
| customClass: "separator" | |
| }); | |
| var m = [{ | |
| title: $.localize.getString("QUEUE_LARGE"), | |
| customClass: !GS.player.queueClosed && GS.player.queueSize == "l" ? "jj_menu_item_hasIcon jj_menu_item_tick" : "jj_menu_item_hasIcon jj_menu_item_blank", | |
| action: { | |
| type: "fn", | |
| callback: function() { | |
| GS.player.setQueue("l") | |
| } | |
| } | |
| }, | |
| { | |
| title: $.localize.getString("QUEUE_NORMAL"), | |
| customClass: !GS.player.queueClosed && GS.player.queueSize == "m" ? "jj_menu_item_hasIcon jj_menu_item_tick" : "jj_menu_item_hasIcon jj_menu_item_blank", | |
| action: { | |
| type: "fn", | |
| callback: function() { | |
| GS.player.setQueue("m") | |
| } | |
| } | |
| }, | |
| { | |
| title: $.localize.getString("QUEUE_SMALL"), | |
| customClass: !GS.player.queueClosed && GS.player.queueSize == "s" ? "jj_menu_item_hasIcon jj_menu_item_tick" : "jj_menu_item_hasIcon jj_menu_item_blank", | |
| action: { | |
| type: "fn", | |
| callback: function() { | |
| GS.player.setQueue("s") | |
| } | |
| } | |
| }, | |
| { | |
| title: $.localize.getString("QUEUE_HIDE"), | |
| customClass: GS.player.queueClosed ? "jj_menu_item_hasIcon jj_menu_item_tick" : "jj_menu_item_hasIcon jj_menu_item_blank", | |
| action: { | |
| type: "fn", | |
| callback: function() { | |
| GS.player.setQueue("off") | |
| } | |
| } | |
| }]; | |
| k.push({ | |
| title: $.localize.getString("QUEUE_SIZES"), | |
| type: "sub", | |
| customClass: "jj_menu_item_queue jj_menu_item_hasIcon jj_menu_item_blank", | |
| src: m | |
| }); | |
| if ( g && g.songs && g.songs.length ) { | |
| k.length && k.push({ | |
| customClass: "separator" | |
| }); | |
| k.push({ | |
| title: $.localize.getString("PLAYER_SHOW_VISUALIZER"), | |
| customClass: "jj_menu_item_hasIcon jj_menu_item_visualizer", | |
| action: { | |
| type: "fn", | |
| callback: function() { | |
| if ( GS.user.IsPremium ) $("#lightbox .lbcontainer:visible").is(".gs_lightbox_visualizer") || GS.getLightbox().open("visualizer", { | |
| showPlayerControls: true | |
| }); | |
| else GS.getLightbox().open("vipOnlyFeature", { | |
| callback: h.callback(function() { | |
| $("#lightbox .lbcontainer:visible").is(".gs_lightbox_visualizer") || GS.getLightbox().open("visualizer", { | |
| showPlayerControls: true | |
| }) | |
| }) | |
| }) | |
| } | |
| } | |
| }); | |
| h.videoModeEnabled ? k.push({ | |
| title: $.localize.getString("PLAYER_DISABLE_VIDEO_MODE"), | |
| customClass: "jj_menu_item_hasIcon jj_menu_item_video", | |
| action: { | |
| type: "fn", | |
| callback: function() { | |
| h.disableVideoMode() | |
| } | |
| } | |
| }) : k.push({ | |
| title: $.localize.getString("PLAYER_ENABLE_VIDEO_MODE"), | |
| customClass: "jj_menu_item_hasIcon jj_menu_item_video", | |
| action: { | |
| type: "fn", | |
| callback: function() { | |
| GS.user.IsPremium ? h.enableVideoMode() : GS.getLightbox().open("vipOnlyFeature", { | |
| callback: h.callback(function() { | |
| this.enableVideoMode() | |
| }) | |
| }) | |
| } | |
| } | |
| }); | |
| h.powerModeEnabled ? k.push({ | |
| title: $.localize.getString("PLAYER_DISABLE_POWER_MODE"), | |
| customClass: "jj_menu_item_hasIcon jj_menu_item_clock", | |
| action: { | |
| type: "fn", | |
| callback: function() { | |
| h.disablePowerMode() | |
| } | |
| } | |
| }) : k.push({ | |
| title: $.localize.getString("PLAYER_ENABLE_POWER_MODE"), | |
| customClass: "jj_menu_item_hasIcon jj_menu_item_clock", | |
| action: { | |
| type: "fn", | |
| callback: function() { | |
| GS.user.IsPremium ? h.enablePowerMode() : GS.getLightbox().open("vipOnlyFeature", { | |
| callback: h.callback(function() { | |
| this.enablePowerMode() | |
| }) | |
| }) | |
| } | |
| } | |
| }) | |
| } | |
| if ( b.hasClass("active-context") ) { | |
| $(".jjQueueMenu").remove(); | |
| b.removeClass("active-context") | |
| } else { | |
| b.addClass("active-context").jjmenu(c, k, null, { | |
| xposition: "right", | |
| yposition: "top", | |
| orientation: "top", | |
| spill: "left", | |
| show: "show", | |
| className: "radiomenu jjQueueMenu", | |
| keepState: b | |
| }); | |
| GS.getGuts().gaTrackEvent("player", "queueSongMenu") | |
| } | |
| }, | |
| showRadioStations: function( b ) { | |
| messageKey = b ? "POPUP_START_RADIO_NO_SONGS_MESSAGE" : "POPUP_START_RADIO_NO_RECS_MESSAGE"; | |
| GS.getLightbox().open({ | |
| type: "radioStations", | |
| view: { | |
| header: "POPUP_START_RADIO_TITLE", | |
| messageHTML: '<p data-translate-text="' + messageKey + '">' + $.localize.getString(messageKey) + '</p><div id="grid" class="gs_grid radioStations"></div>', | |
| buttonsRight: [], | |
| buttonsLeft: [{ | |
| label: "CLOSE", | |
| className: "close" | |
| }] | |
| }, | |
| callbacks: { | |
| ".close": function() { | |
| GS.getLightbox().close(); | |
| return false | |
| } | |
| }, | |
| loadCallback: function() { | |
| var c = GS.Models.Station.tagStations; | |
| $("#lightbox_content .radioStations").gs_grid(c, GS.Controllers.GridController.columns.station, { | |
| allowDragSort: false, | |
| allowDuplicates: false, | |
| disableMultiSelect: true, | |
| sortCol: "StationTitle", | |
| sortDir: true | |
| }, "station"); | |
| GS.getLightbox().positionLightbox(); | |
| $.subscribe("gs.player.autoplay.update", function( g ) { | |
| g && GS.getLightbox().close() | |
| }) | |
| } | |
| }) | |
| }, | |
| "#player_radio_button, #player_radio_label click": function( b ) { | |
| $(b); | |
| if ( a.player && !a.player.getCurrentQueue().autoplayEnabled ) if ( a.player.getCurrentQueue().songs.length > 0 ) { | |
| a.player.setAutoplay(true); | |
| $("#player_radio_switch").stop().animate({ | |
| left: 25 | |
| }, { | |
| duration: 100, | |
| complete: function() { | |
| $("#player_radio_button").addClass("active") | |
| } | |
| }) | |
| } else this.showRadioStations(true); | |
| else { | |
| a.player.setAutoplay(false); | |
| $("#player_radio_switch").stop().animate({ | |
| left: 0 | |
| }, { | |
| duration: 100, | |
| complete: function() { | |
| $("#player_radio_button").removeClass("active") | |
| } | |
| }) | |
| } | |
| }, | |
| videoIndex: 0, | |
| enableVideoMode: function() { | |
| this.videoModeEnabled = true; | |
| this.showVideoLightbox(); | |
| if ( this.powerModeEnabled ) { | |
| clearInterval(this.powerModeInterval); | |
| this.powerModeInterval = setInterval($(".lbcontainer.gs_lightbox_video").controller().callback("powerHourCheckVideoMode"), 1E3) | |
| } | |
| GS.getGuts().gaTrackEvent("player", "enableVideoMode") | |
| }, | |
| disableVideoMode: function() { | |
| this.videoModeEnabled = | |
| false; | |
| this.hideVideoLightbox(); | |
| this.playSong(); | |
| this.powerModeEnabled && clearInterval(this.powerModeInterval); | |
| GS.getGuts().gaTrackEvent("player", "disableVideoMode") | |
| }, | |
| showVideoLightbox: function() { | |
| var b = this.currentSong; | |
| if ( b ) { | |
| GS.getLightbox().close(); | |
| GS.getLightbox().open("video", { | |
| isLoading: true, | |
| isVideoMode: true, | |
| song: b, | |
| sidebarHeader: "POPUP_VIDEO_ALTERNATE" | |
| }) | |
| } else { | |
| $.publish("gs.notification", { | |
| type: "error", | |
| message: $.localize.getString("NOTIF_FEATURE_REQUIREMENT_SONGS") | |
| }); | |
| this.videoModeEnabled = false | |
| } | |
| }, | |
| hideVideoLightbox: function() { | |
| $("div.lbcontainer.gs_lightbox_video").is(":visible") && GS.getLightbox().close() | |
| }, | |
| togglePowerMode: function() { | |
| this.powerModeEnabled ? this.disablePowerMode() : this.enablePowerMode() | |
| }, | |
| enablePowerMode: function() { | |
| this.powerModeEnabled = true; | |
| if ( this.videoModeEnabled && $(".lbcontainer.video") ) { | |
| clearInterval(this.powerModeInterval); | |
| this.powerModeInterval = setInterval($(".lbcontainer.gs_lightbox_video").controller().callback("powerHourCheckVideoMode"), 1E3) | |
| } else { | |
| var b = this.player.getPlaybackStatus(); | |
| if ( b ) switch ( b.status ) { | |
| case this.PLAY_STATUS_NONE: | |
| case this.PLAY_STATUS_FAILED: | |
| case this.PLAY_STATUS_COMPLETED: | |
| case this.PLAY_STATUS_PAUSED: | |
| if ( b.activeSong ) { | |
| this.playSong(b.activeSong.queueSongID); | |
| $.publish("gs.player.queue.change") | |
| } | |
| break | |
| } | |
| } | |
| $.publish("gs.player.feature.change"); | |
| GS.getGuts().gaTrackEvent("player", "enablePowerMode") | |
| }, | |
| disablePowerMode: function() { | |
| this.powerModeEnabled = false; | |
| this.videoModeEnabled && clearInterval(this.powerModeInterval); | |
| $.publish("gs.player.feature.change"); | |
| GS.getGuts().gaTrackEvent("player", "disablePowerMode") | |
| }, | |
| "#queue_clear_button click": function() { | |
| var b = this.getCurrentQueue(); | |
| if ( b.hasRestoreQueue ) a.restoreQueue(); | |
| else if ( b && b.songs && b.songs.length > 0 ) { | |
| a.clearQueue(); | |
| a.setQueue("off", false) | |
| } | |
| }, | |
| queueSongToHtml: function() { | |
| return function( b, c, g ) { | |
| var h = "paused", | |
| k = [], | |
| m = a.getCurrentQueue(), | |
| p = "", | |
| n = b.fromLibrary ? "inLibrary" : "", | |
| o = b.isFavorite ? "isFavorite" : "", | |
| t = "", | |
| w = ""; | |
| if ( b.context.data && b.context.data.hasOwnProperty("CoverArtFilename") ) b.CoverArtFilename = b.context.data.CoverArtFilename; | |
| if ( m.activeSong && b.queueSongID === m.activeSong.queueSongID ) { | |
| p += " active"; | |
| if ( a.isPlaying ) h = "" | |
| } | |
| if ( m.autoplayEnabled ) { | |
| if ( b.autoplayVote === -1 || c === g - 1 && b.source !== "user" ) p += " suggestion"; | |
| if ( b.autoplayVote === 1 || b.autoplayVote === 0 && b.source === "user" ) { | |
| t = "active"; | |
| w = "" | |
| } else if ( b.autoplayVote === -1 ) { | |
| w = "active"; | |
| t = "" | |
| } | |
| } | |
| k.push('<div id="', b.queueSongID, '" rel="', b.SongID, '" class="', p, ' queueSong">', '<a class="remove" title="', $.localize.getString("removeSong"), '"></a>', '<div class="albumart">', '<div class="radio_options ', m && m.autoplayEnabled ? "active" : "", '">', '<a class="smile ', t, '" title="', $.localize.getString("QUEUE_ITEM_SMILE"), '"></a>', '<a class="frown ', w, '" title="', $.localize.getString("QUEUE_ITEM_FROWN"), '"></a>', "</div>", '<div class="song_options ', n, " ", o, '">', '<a class="collection ', o, ' textToggle" title="', $.localize.getString("QUEUE_ADD_SONG_FAVORITE_TITLE"), '"></a>', '<a class="options selectbox" title="', $.localize.getString("QUEUE_ITEM_OPTIONS"), '"></a>', "</div>", '<a class="play ', h, '" rel="', b.queueSongID, '"></a>', '<img src="', b.getImageURL(a.queueSize == "l" ? 90 : 70), '" height="100%" width="100%" />', "</div>", '<a title="', _.cleanText(b.SongName), '" class="queueSong_name song ellipsis" rel="', b.SongID, '">', _.cleanText(b.SongName), "</a>", '<a href="', _.cleanUrl(b.ArtistName, b.ArtistID, "artist"), '" title="', _.cleanText(b.ArtistName), '" class="queueSong_artist artist ellipsis">', _.cleanText(b.ArtistName), "</a>", "</div>"); | |
| return k.join("") | |
| } | |
| }, | |
| smallQueueSongToHtml: function( b, c, g ) { | |
| var h = "paused", | |
| k = [], | |
| m = a.getCurrentQueue(), | |
| p = "", | |
| n = b.fromLibrary ? "inLibrary" : "", | |
| o = b.isFavorite ? "isFavorite" : ""; | |
| if ( b.context.data && b.context.data.hasOwnProperty("CoverArtFilename") ) b.CoverArtFilename = b.context.data.CoverArtFilename; | |
| if ( m.activeSong && b.queueSongID === m.activeSong.queueSongID ) { | |
| p += " active"; | |
| if ( a.isPlaying ) h = "" | |
| } | |
| if ( m.autoplayEnabled ) if ( b.autoplayVote === -1 || c === g - 1 && b.source !== "user" ) p += " suggestion"; | |
| k.push('<div id="', b.queueSongID, '" rel="', b.SongID, '" class="', p, ' queueSong small">', '<div class="albumart ', n, " ", o, '">', '<a class="play ', h, '" rel="', b.queueSongID, '"></a>', '<a class="collection ', o, ' textToggle" title="', $.localize.getString("QUEUE_ADD_SONG_FAVORITE_TITLE"), '"></a>', '<a class="options selectbox" title="', $.localize.getString("QUEUE_ITEM_OPTIONS"), '"></a>', '<img src="', b.getImageURL(70), '" height="33" width="33" />', "</div>", '<a class="remove" title="', $.localize.getString("removeSong"), '"></a>', '<a title="', _.cleanText(b.SongName), '" class="queueSong_name song ellipsis" rel="', b.SongID, '">', _.cleanText(b.SongName), "</a>", '<a href="', _.cleanUrl(b.ArtistName, b.ArtistID, "artist"), '" title="', _.cleanText(b.ArtistName), '" class="queueSong_artist artist ellipsis">', _.cleanText(b.ArtistName), "</a>", "</div>"); | |
| return k.join("") | |
| } | |
| }) | |
| })(); | |
| GS.Controllers.BaseController.extend("GS.Controllers.YoutubeController", { | |
| isGSSingleton: true | |
| }, { | |
| readyCallbacks: [], | |
| API_URL: "http://gdata.youtube.com/feeds/api/videos", | |
| DEV_KEY: "AI39si6SJVyxgw9MFbAdbXE-wbtZFdTl8qnY2UWX3dFA97c9PrcfAYDpqUh0iLeVEkurJsjUvDmObBWvLX-wmsy_kW8KHAgN-Q", | |
| APPLICATION_ID: "Grooveshark", | |
| lastError: null, | |
| init: function() { | |
| window.onYouTubePlayerReady = function( a ) { | |
| var b = GS.getYoutube(), | |
| c = b.makeVideoObject($("#" + a)[0], a); | |
| c.play(); | |
| if ( b.readyCallbacks[a] ) { | |
| b.readyCallbacks[a](c); | |
| delete b.readyCallbacks[a] | |
| } | |
| }; | |
| this._super() | |
| }, | |
| attachPlayer: function( a, b, c, g, h ) { | |
| var k = "videoVObj" + g, | |
| m = "http://www.youtube.com/v/" + a + "?version=3&enablejsapi=1&version=3&fs=1&playerapiid=" + k, | |
| p = { | |
| id: k, | |
| name: k, | |
| allowFullScreen: "true" | |
| }; | |
| if (!a || _.notDefined(a) ) return false; | |
| b = b || 480; | |
| c = c || 385; | |
| if ( $.isFunction(h) ) GS.getYoutube().readyCallbacks[k] = h; | |
| swfobject.embedSWF(m, g, b, c, "8", null, {}, { | |
| allowScriptAccess: "always", | |
| allowFullScreen: "true" | |
| }, p) | |
| }, | |
| makeVideoObject: function( a, b ) { | |
| var c = { | |
| callbacks: [], | |
| addEvent: function( g, h ) { | |
| if ( $.isFunction(h) ) { | |
| var k = "yt" + g + b + Math.floor(Math.random() * 1001); | |
| window[k] = h; | |
| h = k; | |
| this.callbacks.push(k) | |
| } | |
| a.addEventListener(g, h) | |
| }, | |
| play: function() { | |
| a.playVideo() | |
| }, | |
| playVideoAt: function( g ) { | |
| a.playVideoAt(g) | |
| }, | |
| pause: function() { | |
| a.pauseVideo() | |
| }, | |
| isPaused: function() { | |
| var g = this.getState(); | |
| return g != 1 && g != 3 | |
| }, | |
| getState: function() { | |
| return a.getPlayerState() | |
| }, | |
| stop: function() { | |
| a.stopVideo() | |
| }, | |
| getCurrentTime: function() { | |
| return a.getCurrentTime() | |
| }, | |
| getDuration: function() { | |
| return a.getDuration() | |
| }, | |
| getVideoUrl: function() { | |
| return a.getVideoUrl() | |
| }, | |
| getVolume: function() { | |
| return a.getVolume() / 100 | |
| }, | |
| setVolume: function( g ) { | |
| a.setVolume(g * 100) | |
| }, | |
| loadVideoById: function( g ) { | |
| a.loadVideoById(g); | |
| GS.getGuts().gaTrackEvent("youtube", "loadVideoById", g) | |
| }, | |
| loadVideoByUrl: function( g ) { | |
| a.loadVideoByUrl(g) | |
| } | |
| }; | |
| $(a).parent().bind("remove", function() { | |
| try { | |
| c.callbacks && c.callbacks.length && _.forEach(c.callbacks, function( h ) { | |
| window[h] = null | |
| }) | |
| } catch (g) {} | |
| }); | |
| return c | |
| }, | |
| searchCache: {}, | |
| search: function( a, b, c, g, h ) { | |
| a = $.trim(_.orEqual(a, "")); | |
| b = _.orEqual(b, 10); | |
| if ((!a || a == "") && h ) { | |
| a = h.SongName.replace(/[\(\[][a-zA-Z0-9\s]+[\]\)]/g, ""); | |
| a = h.ArtistName.toLowerCase() != "unknown" && h.ArtistName.toLowerCase() != "unknown artist" ? [h.ArtistName || "", a || ""].join(" - ") : a; | |
| a = $.trim(a) | |
| } | |
| if (!a ) { | |
| $.isFunction(g) && g(); | |
| return false | |
| } | |
| this.searchCache[a] && $.isFunction(c) && c(this.searchCache[a]); | |
| var k = "jQueryYoutube" + OAuth.nonce(10), | |
| m = { | |
| "max-results": b, | |
| orderBy: "relevance", | |
| safeSearch: "none", | |
| alt: "json-in-script", | |
| time: "all_time", | |
| "start-index": 1, | |
| q: a, | |
| callback: k, | |
| key: this.DEV_KEY, | |
| v: 2 | |
| }; | |
| b = this.API_URL; | |
| OAuth.completeRequest({ | |
| method: "GET", | |
| action: b, | |
| parameters: m | |
| }, { | |
| consumerKey: this.APPLICATION_ID, | |
| consumerSecret: this.DEV_KEY | |
| }); | |
| m = OAuth.getParameterMap(m); | |
| b = b + "?" + _.httpBuildQuery(m); | |
| $.ajax({ | |
| url: b, | |
| success: this.callback("searchSuccess", c, g, a, h), | |
| error: this.callback("searchFailed", g), | |
| dataType: "jsonp", | |
| jsonp: false, | |
| jsonpCallback: k, | |
| cache: true | |
| }); | |
| GS.getGuts().gaTrackEvent("youtube", "search", a) | |
| }, | |
| searchSuccess: function( a, b, c, g, h ) { | |
| if ( h.feed && h.feed.entry ) { | |
| var k = [], | |
| m = {}; | |
| _.forEach(h.feed.entry, function( p ) { | |
| if ( p.media$group && p.media$group.media$thumbnail ) { | |
| m = { | |
| Author: "", | |
| Description: "", | |
| Duration: 0, | |
| Rating: 0, | |
| LikeRatio: 0, | |
| VideoID: "", | |
| Plays: 0, | |
| URL: "", | |
| Title: "", | |
| Thumbnails: [] | |
| }; | |
| if ( p.author && p.author[0] && p.author[0].name && p.author[0].name.$t ) m.Author = p.author[0].name.$t; | |
| else if ( p.media$group.media$credit && p.media$group.media$credit.$t ) m.Author = p.media$group.media$credit.$t; | |
| if ( p.media$group.media$description && p.media$group.media$description.$t ) m.Description = p.media$group.media$description.$t; | |
| if ( p.media$group.yt$duration && p.media$group.yt$duration.seconds ) m.Duration = parseInt(p.media$group.yt$duration.seconds); | |
| if ( p.gd$rating && p.gd$rating.average ) m.Rating = parseFloat(p.gd$rating.average); | |
| if ( p.yt$rating && p.yt$rating.numLikes && p.yt$rating.numDislikes ) m.LikeRatio = parseInt(p.yt$rating.numLikes) / parseInt(p.yt$rating.numDislikes); | |
| if ( p.media$group.yt$videoid && p.media$group.yt$videoid.$t ) m.VideoID = p.media$group.yt$videoid.$t; | |
| else if ( p.id ) { | |
| var n = p.id.split(":"); | |
| m.VideoID = n[n.length - 1] | |
| } | |
| if ( p.yt$statistics && p.yt$statistics.viewCount ) m.Plays = parseInt(p.yt$statistics.viewCount); | |
| if ( p.title && p.title.$t ) m.Title = p.title.$t; | |
| if ( p.link && p.link[0] && p.link.href ) m.URL = p.link.href; | |
| _.forEach(p.media$group.media$thumbnail, function( o ) { | |
| if ( o.yt$name ) switch ( o.yt$name ) { | |
| case "default": | |
| m.Thumbnails.unshift(o); | |
| return; | |
| case "hqdefault": | |
| m.Thumbnails.length && m.Thumbnails[0].yt$name == "default" ? m.Thumbnails.splice(1, 0, o) : m.Thumbnails.unshift(o); | |
| return | |
| } | |
| m.Thumbnails.push(o) | |
| }); | |
| m = GS.Models.Video.wrapYoutube(m); | |
| k.push(m) | |
| } | |
| }); | |
| if ( g ) k = this.filterSearchResults(g, k); | |
| this.searchCache[c] = k; | |
| $.isFunction(a) && a(k) | |
| } else { | |
| this.lastError = h; | |
| $.isFunction(b) && b(h) | |
| } | |
| }, | |
| filterSearchResults: function( a, b ) { | |
| var c = [], | |
| g = ""; | |
| if ( a && a.ArtistName ) g = a.ArtistName.match(/[a-z0-9]/gi).join("").toLowerCase(); | |
| _.forEach(b, function( h, k ) { | |
| if ( h.VideoID && h.Author && h.Duration > 60 ) { | |
| h.weight = Math.floor(4.01 * (b.length - k)); | |
| if ( h.Author.toLowerCase().lastIndexOf("vevo") > -1 ) h.weight *= 9.7; | |
| else if ( h.Author.toLowerCase().lastIndexOf("emimusic") > -1 ) h.weight *= 8.98; | |
| if ( g ) if ( h.Author.toLowerCase().indexOf(g) > -1 ) h.weight *= 2.101; | |
| if ( h.Author.toLowerCase().lastIndexOf("records") > -1 ) h.weight *= 2.209; | |
| var m = h.Title.toLowerCase(); | |
| if ( m.lastIndexOf("parody") > -1 ) h.weight *= 0.203; | |
| else if ( m.lastIndexOf("official") > -1 ) h.weight *= 2.51; | |
| for ( m = 0; m < c.length; m++ ) | |
| if ( c[m].weight < h.weight ) { | |
| c.splice(m, 0, h); | |
| return | |
| } | |
| c.push(h) | |
| } | |
| }); | |
| return c | |
| }, | |
| searchFailed: function( a, b ) { | |
| this.lastError = b; | |
| $.isFunction(a) && a(b) | |
| }, | |
| loadFloppyMusic: function() { | |
| var a = []; | |
| _.forEach([{ | |
| Author: "sh4dowww90", | |
| Description: "Another useless device. Imperial march played by two floppy disk drives. Read the note about the next video: silent.org.pl Homepage: silent.org.pl Post in English: silent.org.pl Po polsku: silent.org.pl", | |
| VideoID: "yHJOz_y9rZE", | |
| Title: "Floppy music DUO - Imperial march", | |
| type: "youtube", | |
| duration: 84, | |
| thumbnail: "http://i.ytimg.com/vi/yHJOz_y9rZE/default.jpg", | |
| width: 480, | |
| height: 385 | |
| }, | |
| { | |
| Author: "ToxicTripod0", | |
| Description: "Another attempt at playing midi on floppy drives", | |
| VideoID: "dmwLEf_2Tk8", | |
| Title: "Floppy Mario Theme", | |
| type: "youtube", | |
| duration: 51, | |
| thumbnail: "http://i.ytimg.com/vi/dmwLEf_2Tk8/default.jpg", | |
| width: 480, | |
| height: 385 | |
| }, | |
| { | |
| Author: "Sammy1Am", | |
| Description: 'My second multi-floppy song, as suggested by Neutrino. I\'m using an Arduino UNO hooked up to three drives (one 5.25" and two 3.5").', | |
| VideoID: "VJhvRQHNM1w", | |
| Title: "Floppy Kirby's Theme", | |
| type: "youtube", | |
| duration: 82, | |
| thumbnail: "http://i.ytimg.com/vi/VJhvRQHNM1w/default.jpg", | |
| width: 480, | |
| height: 385 | |
| }, | |
| { | |
| Author: "CoolNapkins", | |
| Description: "Playing around with an old computer and the floppymidi driver for BeOS 1. Tetris 2. Super Mario 3. Zelda 4. Mr. Roboto 5. 1812 Overture", | |
| VideoID: "QkkrQ8xHJlM", | |
| Title: "The Floppy Music Machine", | |
| type: "youtube", | |
| duration: 252, | |
| thumbnail: "http://i.ytimg.com/vi/QkkrQ8xHJlM/default.jpg", | |
| width: 480, | |
| height: 385 | |
| }, | |
| { | |
| Author: "Sammy1Am", | |
| Description: "Theme from Tetris as played on three floppy drives.", | |
| VideoID: "73Sie3yrcnE", | |
| Title: "Floppy Korobeiniki (Tetris Theme)", | |
| type: "youtube", | |
| duration: 68, | |
| thumbnail: "http://i.ytimg.com/vi/73Sie3yrcnE/default.jpg", | |
| width: 480, | |
| height: 385 | |
| }], function( b ) { | |
| a.push(GS.Models.Video.wrapYoutube(b)) | |
| }); | |
| GS.getLightbox().open("video", { | |
| videos: a | |
| }) | |
| }, | |
| loadDubstep: function() { | |
| var a = GS.Models.Video.wrapYoutube({ | |
| Author: "tobyharris100", | |
| Description: "", | |
| VideoID: "QbZhbZBK2ZY", | |
| Title: "How To Dance To Dubstep! Parrot", | |
| type: "youtube", | |
| duration: 163, | |
| thumbnail: "http://i.ytimg.com/vi/QbZhbZBK2ZY/default.jpg", | |
| width: 480, | |
| height: 385 | |
| }); | |
| GS.getLightbox().open("video", { | |
| video: a | |
| }) | |
| } | |
| }); | |
| GS.Controllers.BaseController.extend("GS.Controllers.VimeoController", { | |
| isGSSingleton: true | |
| }, { | |
| f: null, | |
| API_URL: "http://vimeo.com/api/rest/v2/", | |
| API_KEY: "6bf5b02fd725f336e2587ee7feadcb42", | |
| API_SECRET: "247c4b613fcf18b5", | |
| init: function() { | |
| if ( window.$f ) { | |
| this.f = window.$f; | |
| window.$f = null | |
| } | |
| if ( window.Froogaloop ) { | |
| if (!this.f ) this.f = window.Froogaloop; | |
| window.Froogaloop = null | |
| } | |
| this._super() | |
| }, | |
| attachPlayer: function( a, b, c, g, h ) { | |
| if ( this.f ) { | |
| var k = "http://player.vimeo.com/video/" + a + "?api=1&player_id=videoVObj" + g + "&autoplay=1"; | |
| if (!a || _.notDefined(a) ) return false; | |
| b = b || 480; | |
| c = c || 385; | |
| a = $("<iframe />").width(b).height(c).attr("src", k).attr("id", "videoVObj" + g); | |
| $("#" + g).html(a); | |
| var m = this.makeVideoObject($("#videoVObj" + g)[0]); | |
| h && m.addEvent("ready", function() { | |
| h(m) | |
| }); | |
| return m[0] | |
| } | |
| }, | |
| makeVideoObject: function( a ) { | |
| var b = this.f(a); | |
| return { | |
| addEvent: function( c, g ) { | |
| b.addEvent(c, g) | |
| }, | |
| play: function() { | |
| b.api("play") | |
| }, | |
| pause: function() { | |
| b.api("pause") | |
| }, | |
| isPaused: function( c ) { | |
| b.api("paused", c) | |
| }, | |
| stop: function() { | |
| b.api("unload") | |
| }, | |
| getCurrentTime: function( c ) { | |
| b.api("getCurrentTime", c) | |
| }, | |
| getVideoUrl: function( c ) { | |
| b.api("getVideoUrl", c) | |
| } | |
| } | |
| }, | |
| searchCache: {}, | |
| search: function( a, b, c ) { | |
| if (!a || a == "" ) return false; | |
| this.searchCache[a] && $.isFunction(b) && b(this.searchCache[a]); | |
| var g = "jQueryVimeo" + OAuth.nonce(10), | |
| h = { | |
| per_page: 10, | |
| query: a, | |
| method: "vimeo.videos.search", | |
| full_response: 1, | |
| format: "jsonp", | |
| callback: g | |
| }, | |
| k = this.API_URL; | |
| OAuth.completeRequest({ | |
| method: "GET", | |
| action: k, | |
| parameters: h | |
| }, { | |
| consumerKey: this.API_KEY, | |
| consumerSecret: this.API_SECRET | |
| }); | |
| h = OAuth.getParameterMap(h); | |
| k = k + "?" + _.httpBuildQuery(h); | |
| $.ajax({ | |
| url: k, | |
| success: this.callback("searchSuccess", b, c, a), | |
| error: this.callback("searchFailed", c), | |
| dataType: "jsonp", | |
| jsonp: false, | |
| jsonpCallback: g, | |
| cache: true | |
| }) | |
| }, | |
| searchSuccess: function( a, b, c, g ) { | |
| if ( g.videos && g.videos.video ) { | |
| var h = []; | |
| _.forEach(g.videos.video, function( k ) { | |
| h.push({ | |
| Description: k.description || "", | |
| Duration: parseInt(k.duration), | |
| Height: parseInt(k.height), | |
| Width: parseInt(k.width), | |
| VideoID: k.id, | |
| Plays: parseInt(k.number_of_plays), | |
| Title: k.title || "", | |
| URL: "http://vimeo.com/" + k.id, | |
| Thumbnails: k.thumbnails.thumbnail | |
| }) | |
| }); | |
| this.searchCache[c] = | |
| h; | |
| $.isFunction(a) && a(h) | |
| } else { | |
| this.lastError = g; | |
| $.isFunction(b) && b(g) | |
| } | |
| }, | |
| searchFailed: function( a, b ) { | |
| this.lastError = b; | |
| $.isFunction(a) && a(b) | |
| } | |
| }); | |
| (function() { | |
| function a(k) { | |
| return "<span class='slick-column-name' data-translate-text='" + k.name + "'>" + $.localize.getString(k.name) + "</span>" | |
| } | |
| function b(k, m, p, n, o) { | |
| k = _.ucwords(n.name); | |
| m = $("#grid").controller(); | |
| return o.IsVerified == 0.5 ? n.name == "ARTIST" ? m.filter.hasOwnProperty("onlyVerified") && !m.filter.onlyVerified ? '<div class="showMore showingMore" data-translate-text="SEARCH_RESULTS_SHOW_LESS">' + $.localize.getString("SEARCH_RESULTS_SHOW_LESS") + "</div>" : '<div class="showMore" data-translate-text="SEARCH_RESULTS_SHOW_MORE">' + $.localize.getString("SEARCH_RESULTS_SHOW_MORE") + "</div>" : "" : ['<a class="field" href="', n.name == "SONG" ? "javascript:_.redirectSong(" + o.SongID + ", event)" : n.name == "USER" ? _.cleanUrl(o.Name, o.UserID, "user") : n.name == "AUTHOR" ? _.cleanUrl(o.UserName, o.UserID, "user") : _.cleanUrl(o[k + "Name"], o[k + "ID"], n.name.toLowerCase()), '" class="ellipsis" title="', p, '">', p, "</a>"].join("") | |
| } | |
| function c(k, m, p) { | |
| return ['<span class="filter field ellipsis" title="', p, '">', p, '</span><span class="arrow rowOption"></span>'].join("") | |
| } | |
| function g(k, m, p, n, o) { | |
| if ( o.IsVerified == 0.5 ) return ""; | |
| else { | |
| k = o.isFavorite ? " isFavorite" : ""; | |
| m = o.fromLibrary ? " inLibrary" : ""; | |
| n = o.fromLibrary ? "SONG_ROW_REMOVE_SONG_LIBRARY_TITLE" : "SONG_ROW_ADD_SONG_LIBRARY_TITLE"; | |
| var t = o.isFavorite ? "SONG_ROW_REMOVE_SONG_FAVORITE_TITLE" : "SONG_ROW_ADD_SONG_FAVORITE_TITLE", | |
| w = GS.player.getCurrentQueue(), | |
| x = "SONG_ROW_ADD_SONG_PLAY_TITLE"; | |
| if ( w && w.songs && w.songs.length > 0 ) x = "SONG_ROW_ADD_SONG_ADD_TO_PLAYING_TITLE"; | |
| return ['<a class="play rowOption" data-translate-title="', x, '" title="', $.localize.getString(x), '" rel="', o.SongID, '"></a><div class="options ', k, " ", m, '"><a class="rowOption favorite option', k, '" data-translate-title="', t, '" title="', $.localize.getString(t), '" rel="', o.SongID, '"></a><a class="rowOption library option', m, '" data-translate-title="', n, '" title="', $.localize.getString(n), '" rel="', o.SongID, '"></a><a class="rowOption more option grid_song_more', m, '" data-translate-title="OPTIONS" title="', $.localize.getString("OPTIONS"), '" rel="', o.SongID, '"></a></div><span class="songName"><a class="songLink ellipsis" title="', p, '" rel="', o.SongID, '">', p, "</a></span>"].join("") | |
| } | |
| } | |
| function h(k, m, p) { | |
| p = p == "0" ? " " : p; | |
| return ['<span class="track">', p, "</span>"].join("") | |
| } | |
| GS.Controllers.BaseController.extend("GS.Controllers.GridController", { | |
| columns: { | |
| song: [{ | |
| id: "song", | |
| name: "SONG", | |
| field: "SongName", | |
| cssClass: "song", | |
| minWidth: 150, | |
| formatter: g, | |
| behavior: "selectAndMove", | |
| sortable: true, | |
| columnFormatter: a | |
| }, | |
| { | |
| id: "artist", | |
| name: "ARTIST", | |
| field: "ArtistName", | |
| cssClass: "artist", | |
| minWidth: 100, | |
| formatter: b, | |
| behavior: "selectAndMove", | |
| sortable: true, | |
| columnFormatter: a | |
| }, | |
| { | |
| id: "album", | |
| name: "ALBUM", | |
| field: "AlbumName", | |
| cssClass: "album", | |
| minWidth: 100, | |
| formatter: b, | |
| behavior: "selectAndMove", | |
| sortable: true, | |
| columnFormatter: a | |
| }, | |
| { | |
| id: "track", | |
| name: "TRACK_NUM", | |
| field: "TrackNum", | |
| cssClass: "track", | |
| minWidth: 70, | |
| maxWidth: 90, | |
| formatter: h, | |
| behavior: "selectAndMove", | |
| sortable: true, | |
| columnFormatter: a | |
| }], | |
| albumSongs: [{ | |
| id: "song", | |
| name: "SONG", | |
| field: "SongName", | |
| cssClass: "song", | |
| minWidth: 150, | |
| formatter: g, | |
| behavior: "selectAndMove", | |
| sortable: true, | |
| columnFormatter: a, | |
| minWidth: 300 | |
| }, | |
| { | |
| id: "artist", | |
| name: "ARTIST", | |
| field: "ArtistName", | |
| cssClass: "artist", | |
| minWidth: 100, | |
| formatter: b, | |
| behavior: "selectAndMove", | |
| sortable: true, | |
| columnFormatter: a | |
| }, | |
| { | |
| id: "track", | |
| name: "TRACK_NUM", | |
| field: "TrackNum", | |
| cssClass: "track", | |
| minWidth: 70, | |
| maxWidth: 90, | |
| formatter: h, | |
| behavior: "selectAndMove", | |
| sortable: true, | |
| columnFormatter: a | |
| }], | |
| queuesong: [{ | |
| id: "song", | |
| name: "SONG", | |
| field: "SongName", | |
| cssClass: "song", | |
| minWidth: 150, | |
| formatter: function( k, m, p, n, o ) { | |
| k = o.isFavorite ? " isFavorite" : ""; | |
| m = o.fromLibrary ? " inLibrary" : ""; | |
| n = o.fromLibrary ? "SONG_ROW_REMOVE_SONG_LIBRARY_TITLE" : "SONG_ROW_ADD_SONG_LIBRARY_TITLE"; | |
| return ['<a class="play rowOption ', GS.player.isPlaying ? "" : "paused", '" rel="', o.SongID, '"></a><div class="options ', k, " ", m, '"><a class="rowOption favorite option', k, '" rel="', o.SongID, '"></a><a class="rowOption library option', m, '" data-translate-title="', n, '" title="', $.localize.getString(n), '" rel="', o.SongID, '"></a><a class="rowOption more option', m, '" rel="', o.SongID, '"></a></div><span class="songName"><a class="songLink ellipsis" title="', p, '" rel="', o.SongID, '">', p, "</a></span>"].join("") | |
| }, | |
| behavior: "selectAndMove", | |
| sortable: true, | |
| columnFormatter: a | |
| }, | |
| { | |
| id: "artist", | |
| name: "ARTIST", | |
| field: "ArtistName", | |
| cssClass: "artist", | |
| minWidth: 100, | |
| formatter: function( k, m, p, n, o ) { | |
| k = o.autoplayVote == 1 || o.autoplayVote == 0 && o.source === "user" ? "selected" : ""; | |
| m = o.autoplayVote == -1 ? "selected" : ""; | |
| var t = _.ucwords(n.name); | |
| n = _.cleanUrl(o[t + "Name"], o[t + "ID"], n.name.toLowerCase()); | |
| return ['<div class="options"><a class="rowOption smile rowOption ', k, '"></a><a class="rowOption frown rowOption ', m, '"></a></div><a class="field ellipsis" href="', n, '" title="', p, '">', p, "</a>"].join("") | |
| }, | |
| behavior: "selectAndMove", | |
| sortable: true, | |
| columnFormatter: a | |
| }, | |
| { | |
| id: "album", | |
| name: "ALBUM", | |
| field: "AlbumName", | |
| cssClass: "album", | |
| minWidth: 100, | |
| formatter: b, | |
| behavior: "selectAndMove", | |
| sortable: true, | |
| columnFormatter: a | |
| }, | |
| { | |
| id: "track", | |
| name: "TRACK_NUM", | |
| field: "TrackNum", | |
| cssClass: "track", | |
| minWidth: 70, | |
| maxWidth: 90, | |
| formatter: h, | |
| behavior: "selectAndMove", | |
| sortable: true, | |
| columnFormatter: a | |
| }], | |
| playlistsong: [{ | |
| id: "song", | |
| name: "SONG", | |
| field: "SongName", | |
| cssClass: "song", | |
| minWidth: 150, | |
| formatter: g, | |
| behavior: "selectAndMove", | |
| sortable: true, | |
| columnFormatter: a | |
| }, | |
| { | |
| id: "artist", | |
| name: "ARTIST", | |
| field: "ArtistName", | |
| cssClass: "artist", | |
| minWidth: 100, | |
| formatter: b, | |
| behavior: "selectAndMove", | |
| sortable: true, | |
| columnFormatter: a | |
| }, | |
| { | |
| id: "album", | |
| name: "ALBUM", | |
| field: "AlbumName", | |
| cssClass: "album", | |
| minWidth: 100, | |
| formatter: b, | |
| behavior: "selectAndMove", | |
| sortable: true, | |
| columnFormatter: a | |
| }], | |
| album: [{ | |
| id: "album", | |
| name: "ALBUM", | |
| field: "AlbumName", | |
| cssClass: "albumDetail", | |
| formatter: function( k, m, p, n, o ) { | |
| k = '<a href="' + o.toArtistUrl() + '">' + o.ArtistName + "</a>"; | |
| $("<span></span>").localeDataString("BY_ARTIST", { | |
| artist: k | |
| }); | |
| return ['<a href="', o.toUrl(), '" class="image insetBorder height30"><img src="', o.getImageURL(30), '" width="30" height="30" class="avatar" /></a><a href="', o.toUrl(), '" class="title ellipsis">', o.AlbumName, "</a>"].join("") | |
| }, | |
| behavior: "selectAndMove", | |
| sortable: true, | |
| columnFormatter: a | |
| }, | |
| { | |
| id: "artist", | |
| name: "ARTIST", | |
| field: "ArtistName", | |
| cssClass: "albumArtist", | |
| formatter: b, | |
| behavior: "selectAndMove", | |
| sortable: true, | |
| columnFormatter: a | |
| }], | |
| artist: [{ | |
| id: "artist", | |
| name: "ARTIST", | |
| field: "ArtistName", | |
| cssClass: "artist-row", | |
| formatter: function( k, m, p, n, o ) { | |
| k = '<a href="' + o.toUrl() + '">' + o.ArtistName + "</a>"; | |
| $("<span></span>").localeDataString("BY_ARTIST", { | |
| artist: k | |
| }); | |
| return ['<a href="', o.toUrl(), '" class="image insetBorder height30"><img src="', o.getImageURL(30), '" width="30" height="30" class="avatar" /></a><a href="', o.toUrl(), '" class="title ellipsis">', o.ArtistName, "</a>"].join("") | |
| }, | |
| behavior: "selectAndMove", | |
| sortable: true, | |
| columnFormatter: a | |
| }], | |
| playlist: [{ | |
| id: "playlist", | |
| name: "PLAYLIST", | |
| field: "PlaylistName", | |
| cssClass: "playlist", | |
| formatter: function( k, m, p, n, o ) { | |
| k = o.isFavorite ? " subscribed" : ""; | |
| m = o && o.NumSongs && o.Artists ? true : false; | |
| p = o.isFavorite ? "Unsubscribe" : "Subscribe"; | |
| k = o.UserID === GS.user.UserID ? "" : ['<a class="subscribe ', k, '" rel="', o.PlaylistID, '"><span>', p, "</span></a>"].join(""); | |
| if ( m ) { | |
| m = o.Artists.split(","); | |
| p = m.length; | |
| m.splice(3, m.length); | |
| p = p > m.length ? "..." : ""; | |
| return ['<a href="', _.cleanUrl(o.PlaylistName, o.PlaylistID, "playlist"), '" class="image insetBorder height30"><img src="', o.getImageURL(30), '" width="30" height="30" class="albumart" /></a>', k, '<p><span class="title"><a class="v-ellip" href="', _.cleanUrl(o.PlaylistName, o.PlaylistID, "playlist"), '">', _.cleanText(o.PlaylistName), " (", o.NumSongs, ' Songs) </a></span><span class="artists">', m.join(", "), p, "</span></p>"].join("") | |
| } else return ['<a href="', _.cleanUrl(o.PlaylistName, o.PlaylistID, "playlist"), '" class="image insetBorder height30"><img src="', o.getImageURL(30), '" width="30" height="30" class="albumart" /></a>', k, '<p><span class="title"><a class="v-ellip" href="', _.cleanUrl(o.PlaylistName, o.PlaylistID, "playlist"), '">', _.cleanText(o.PlaylistName), "</a></span></p>"].join("") | |
| }, | |
| behavior: "selectAndMove", | |
| sortable: true, | |
| columnFormatter: a | |
| }, | |
| { | |
| id: "username", | |
| name: "AUTHOR", | |
| field: "UserName", | |
| cssClass: "playlistAuthor", | |
| formatter: b, | |
| behavior: "selectAndMove", | |
| sortable: true, | |
| columnFormatter: a | |
| }], | |
| user: [{ | |
| id: "username", | |
| name: "USER", | |
| field: "Name", | |
| cssClass: "user", | |
| formatter: function( k, m, p, n, o ) { | |
| k = o.isFavorite ? " following" : ""; | |
| m = o.isFavorite ? "UNFOLLOW" : "FOLLOW"; | |
| k = o.UserID === GS.user.UserID ? "" : ['<a class="follow ', k, '" data-follow-userid="', o.UserID, '"><span data-translate-text="' + m + '">', $.localize.getString(m), "</span></a>"].join(""); | |
| m = _.cleanUrl(o.Name, o.UserID, "user"); | |
| p = '<div class="status ' + o.getVipPackage() + '"></div>'; | |
| return ['<a href="', m, '" class="who image">', p, '<img src="', o.getImageURL(30), '" width="30" height="30" class="avatar" /></a>', k, '<a href="', m, '" class="username">', o.Name, '</a><span class="location">', o.Country, "</span>"].join("") | |
| }, | |
| behavior: "selectAndMove", | |
| sortable: true, | |
| columnFormatter: a | |
| }], | |
| albumFilter: [{ | |
| id: "album", | |
| name: "ALBUM", | |
| field: "AlbumName", | |
| cssClass: "cell-title", | |
| formatter: c, | |
| behavior: "selectAndMove", | |
| sortable: false, | |
| collapsable: true, | |
| columnFormatter: a | |
| }], | |
| artistFilter: [{ | |
| id: "artist", | |
| name: "ARTIST", | |
| field: "ArtistName", | |
| cssClass: "cell-title", | |
| formatter: c, | |
| behavior: "selectAndMove", | |
| sortable: false, | |
| collapsable: true, | |
| columnFormatter: a | |
| }], | |
| event: [{ | |
| id: "date", | |
| name: "DATE", | |
| field: "StartTime", | |
| cssClass: "cell-title", | |
| formatter: function( k, m, p, n, o ) { | |
| k = o.StartTime.split(" "); | |
| m = k[1] ? k[1].split(":") : "00:00:00"; | |
| k = k[0].split("-"); | |
| newDate = new Date(parseInt(k[0], 10), parseInt(k[1], 10) - 1, parseInt(k[2], 10), parseInt(m[0], 10), parseInt(m[1], 10), parseInt(m[2], 10)); | |
| return ['<div class="field event_calendar" title="', newDate.format("D M j Y"), '"><span class="field month" >', newDate.format("M"), '</span><span class="field day" >', newDate.format("j"), "</span></div>"].join("") | |
| }, | |
| behavior: "none", | |
| sortable: false, | |
| columnFormatter: a, | |
| minWidth: 40, | |
| maxWidth: 45 | |
| }, | |
| { | |
| id: "artist", | |
| name: "ARTISTS", | |
| field: "ArtistName", | |
| cssClass: "cell-title", | |
| formatter: function( k, m, p ) { | |
| k = (p || "").split(", "); | |
| m = ""; | |
| p = []; | |
| for ( var n = 0; n < k.length; n++ ) { | |
| m = n === k.length - 1 ? "" : ", "; | |
| p.push([k[n], m].join("")) | |
| } | |
| return ['<div class="filter"><a class="field url event_tickets" title="', $.localize.getString("BUY_TICKETS"), '">', $.localize.getString("BUY_TICKETS"), '</a><span class="field artist ellipsis">', p.join(""), "</span></div>"].join("") | |
| }, | |
| behavior: "none", | |
| sortable: false, | |
| columnFormatter: a | |
| }, | |
| { | |
| id: "location", | |
| name: "LOCATION", | |
| field: "Location", | |
| cssClass: "cell-title", | |
| formatter: function( k, m, p, n, o ) { | |
| return ['<div class="filter"><span class="field ellipsis venue" title="', o.VenueName, '">', o.VenueName, '</span><span class="field ellipsis city" title="', o.City, '">', o.City, "</span></div>"].join("") | |
| }, | |
| behavior: "none", | |
| sortable: false, | |
| columnFormatter: a | |
| }], | |
| topSongs: [{ | |
| id: "song", | |
| name: "TRACK", | |
| field: "SongName", | |
| cssClass: "song", | |
| formatter: g, | |
| behavior: "selectAndMove", | |
| sortable: false, | |
| columnFormatter: a | |
| }, | |
| { | |
| id: "album", | |
| name: "ALBUM", | |
| field: "AlbumName", | |
| cssClass: "album", | |
| formatter: b, | |
| behavior: "selectAndMove", | |
| sortable: true, | |
| columnFormatter: a | |
| }], | |
| station: [{ | |
| id: "station", | |
| name: "STATIONS", | |
| field: "StationTitle", | |
| cssClass: "station", | |
| formatter: function( k, m, p, n, o ) { | |
| return ['<a class="play rowOption" data-translate-title="STATION_ROW_PLAY_TITLE" title="', $.localize.getString("STATION_ROW_PLAY_TITLE"), '" data-tagid="', o.TagID, '"></a><span class="field ellipsis stationName" title="', $.localize.getString(p), '">', $.localize.getString(p), "</span>"].join("") | |
| }, | |
| behavior: "selectAndMove", | |
| sortable: true, | |
| columnFormatter: a | |
| }] | |
| }, | |
| options: { | |
| enableCellNavigation: true, | |
| enableCellRangeSelection: true, | |
| onCellRangeSelected: function() { | |
| console.log("cell range select", arguments) | |
| }, | |
| onSelectedRowChanged: function() { | |
| console.log("selectd row change", arguments) | |
| }, | |
| forceFitColumns: true, | |
| rowHeight: 25, | |
| editable: false, | |
| enableAddRow: false, | |
| rowCssClasses: function( k, m, p ) { | |
| var n = ""; | |
| if ( k && k.IsVerified == 1 ) n = "verified"; | |
| else if ( k && k.IsVerified == 0.5 ) n = "verifiedDivider"; | |
| if ( m == p - 1 ) n += " slick-row-last"; | |
| return n | |
| }, | |
| isSelectable: function( k ) { | |
| return k.IsVerified === 0.5 ? false : true | |
| }, | |
| dragProxy: function( k ) { | |
| var m = k; | |
| if ( k.length > 1 ) if ( k[0] instanceof GS.Models.Song ) m = _.getString("SELECTION_SONGS_COUNT", { | |
| count: k.length | |
| }); | |
| else if ( k[0] instanceof GS.Models.Playlist ) m = _.getString("SELECTION_PLAYLIST_COUNT", { | |
| count: k.length | |
| }); | |
| else if ( k[0] instanceof GS.Models.Album ) m = _.getString("SELECTION_ALBUM_COUNT", { | |
| count: k.length | |
| }); | |
| else { | |
| if ( k[0] instanceof GS.Models.Artist ) m = _.getString("SELECTION_ARTIST_COUNT", { | |
| count: k.length | |
| }) | |
| } | |
| else if ( k instanceof Array ) m = k[0].toProxyLabel ? k[0].toProxyLabel() : k[0]; | |
| return ['<div class="status"></div><span class="info"><span class="text">', m, "</span></span>"].join("") | |
| }, | |
| disableMultiSelect: false | |
| }, | |
| rowHeights: { | |
| song: 25, | |
| album: 41, | |
| artist: 41, | |
| playlist: 41, | |
| user: 41, | |
| event: 41, | |
| station: 25 | |
| }, | |
| columnsByName: { | |
| song: "song", | |
| SongName: "song", | |
| album: "album", | |
| AlbumName: "album", | |
| artist: "artist", | |
| ArtistName: "artist", | |
| playlist: "playlist", | |
| PlaylistName: "playlist", | |
| user: "user", | |
| Name: "user", | |
| TrackNum: "track", | |
| tracknum: "track", | |
| track: "track", | |
| event: "user", | |
| Event: "user" | |
| }, | |
| defaultSort: { | |
| song: "ArtistName", | |
| album: "TrackNum", | |
| artist: "Popularity", | |
| user: "Name", | |
| playlist: "PlaylistName" | |
| }, | |
| defaultMultiSorts: { | |
| SongName: ["SongName", "SongID", "GridKey"], | |
| ArtistName: ["ArtistName", "AlbumName", "TrackNum", "SongName", "SongID", "GridKey"], | |
| AlbumName: ["AlbumName", "TrackNum", "SongName", "SongID", "GridKey"], | |
| TrackNum: ["TrackNum", "SongName", "SongID"], | |
| Popularity: ["Popularity", "Weight", "NumPlays", "ArtistName", "AlbumName", "TrackNum", "SongName", "SongID"] | |
| }, | |
| numericColumns: { | |
| Rank: true, | |
| Sort: true, | |
| TrackNum: true, | |
| Popularity: true, | |
| Weight: true, | |
| NumPlays: true, | |
| Score: true, | |
| IsVerified: true, | |
| GridKey: true, | |
| GeoDist: true | |
| }, | |
| forcedSortDirections: { | |
| TSAdded: false, | |
| TSFavorited: false, | |
| Popularity: false, | |
| TrackNum: true | |
| }, | |
| init: function() { | |
| this._super(); | |
| window.ctrlDown = false; | |
| $(document).keydown(this.callback(function( k ) { | |
| if (!window.ctrlDown && (k.ctrlKey || k.metaKey || k.shiftKey || k.keyCode == 16 || k.keyCode == 17) ) { | |
| $("div.gs_grid.songs .grid-canvas").addClass("noLinks"); | |
| window.ctrlDown = true | |
| } | |
| })); | |
| $(document).keyup(this.callback(function( k ) { | |
| if ( window.ctrlDown && (!(k.ctrlKey || k.metaKey || k.shiftKey) || k.keyCode == 16 || k.keyCode == 17) ) { | |
| $("div.gs_grid.songs .grid-canvas").removeClass("noLinks"); | |
| window.ctrlDown = false | |
| } | |
| })) | |
| }, | |
| resizeTimer: null, | |
| resizeAfterRender: function() { | |
| this.resizeTimer && clearTimeout(this.resizeTimer); | |
| this.resizeTimer = setTimeout(function() { | |
| GS.resize(); | |
| $(".gs_grid").resize() | |
| }, 500) | |
| } | |
| }, { | |
| dataView: null, | |
| grid: null, | |
| idProperty: null, | |
| selectedRowIDs: [], | |
| currentRow: 0, | |
| filter: { | |
| artistIDs: false, | |
| albumIDs: false, | |
| onlyVerified: false | |
| }, | |
| sortCol: "", | |
| sortCols: [], | |
| sortDir: 1, | |
| origSortDir: 1, | |
| onInitSort: true, | |
| sortNumeric: false, | |
| pastSorts: {}, | |
| searchString: "", | |
| data: null, | |
| columns: null, | |
| options: null, | |
| type: null, | |
| SMALL_GRID_WIDTH: 600, | |
| resizeSelf: function() { | |
| if ( this.element ) this.element.hasClass("songList") ? this.element.css({ | |
| height: Math.min(200, Math.max(25, (this.data || []).length * this.options.rowHeight)), | |
| width: this.element.parent().innerWidth() | |
| }) : this.element.css({ | |
| height: Math.min(this.element.parent().height(), $("#page").height()), | |
| width: this.element.parent().width() | |
| }); | |
| this.grid && this.grid.resizeAndRender() | |
| }, | |
| init: function( k, m, p, n, o, t ) { | |
| function w(G, D) { | |
| var y, A, I, q, r = 1, | |
| s = false, | |
| u = false; | |
| if ( v.options.isFilter || v.options.useVerifiedSort ) v.sortCols = ["IsVerified", v.sortCol]; | |
| for ( I = 0; I < v.sortCols.length; I++ ) { | |
| q = v.sortCols[I]; | |
| r = q === "IsVerified" ? v.sortDir ? -1 : 1 : 1; | |
| try { | |
| if ( v.Class.numericColumns[q] ) { | |
| y = parseFloat(G[q], 10); | |
| A = parseFloat(D[q], 10); | |
| if ( isNaN(y) ) y = 0; | |
| if ( isNaN(A) ) A = 0; | |
| if ( q === "TrackNum" ) { | |
| if ( y !== 0 && A === 0 ) return v.sortDir ? -1 : 1; | |
| if ( A !== 0 && y === 0 ) return v.sortDir ? 1 : -1 | |
| } | |
| } else { | |
| y = G[q].toString().toLowerCase(); | |
| A = D[q].toString().toLowerCase() | |
| } | |
| if ( y !== A ) return (y > A ? 1 : -1) * r | |
| } catch (C) { | |
| if ( _.notDefined(G) || isNaN(G) ) s = true; | |
| if ( _.notDefined(D) || isNaN(D) ) u = true; | |
| if ( s && !u ) return -1; | |
| if (!s && u ) return 1; | |
| return 0 | |
| } | |
| } | |
| return 0 | |
| } | |
| o = _.orEqual(o, "song"); | |
| n = _.orEqual(n, {}); | |
| n.rowHeight = _.orEqual(n.rowHeight, GS.Controllers.GridController.rowHeights[o]); | |
| n.allowDragSort = _.orEqual(n.allowDragSort, false); | |
| n.allowDropOn = _.orEqual(n.allowDropOn, false); | |
| n.allowDuplicates = _.orEqual(n.allowDuplicates, false); | |
| n.useVerifiedSort = _.orEqual(n.useVerifiedSort, false); | |
| n.searchText = _.orEqual(n.searchText, "searchText"); | |
| n = $.extend({}, GS.Controllers.GridController.options, n); | |
| if ( n.allowDragSort ) n.autoDragScroll = true; | |
| this.subscribe("gs.auth." + o + ".update", this.callback(o + "Change")); | |
| this.subscribe("gs.auth.favorites." + o + "s.update", this.callback(o + "FavoritesChange")); | |
| this.subscribe("gs.player.queue.change", this.callback("queueChange")); | |
| var x = GS.player.getCurrentQueue(); | |
| this.element.toggleClass("hasSongs", x && x.songs && x.songs.length > 0); | |
| this.data = m; | |
| this.columns = p; | |
| this.options = n; | |
| this.type = o; | |
| this.idProperty = this.grid = this.dataView = null; | |
| this.selectedRowIDs = []; | |
| this.currentRow = 0; | |
| this.filter = _.orEqual(n.filters, { | |
| artistIDs: false, | |
| albumIDs: false, | |
| onlyVerified: false | |
| }); | |
| this.sortCol = _.orEqual(n.sortCol, GS.Controllers.GridController.defaultSort[o]); | |
| this.sortCols = _.orEqual(GS.Controllers.GridController.defaultMultiSorts[this.sortCol], $.makeArray(this.sortCol)); | |
| this.origSortDir = this.sortDir = (this.sortDir = _.orEqual(n.sortDir, 1)) ? true : false; | |
| this.onInitSort = _.orEqual(n.onInitSort, false); | |
| this.sortNumeric = GS.Controllers.GridController.numericColumns[this.sortCol] ? true : false; | |
| this.pastSorts = {}; | |
| this.searchString = ""; | |
| this.allowDragSort = _.orEqual(n.allowDragSort, false); | |
| this.allowDropOn = _.orEqual(n.allowDropOn, false); | |
| var v = this; | |
| this.idProperty = _.orEqual(t, _.ucwords(o) + "ID"); | |
| this.dataView = new Slick.Data.DataView; | |
| this.grid = new Slick.Grid($(k), this.dataView.rows, this.columns, this.options); | |
| this.dataView.setAllowDuplicates(this.options.allowDuplicates); | |
| this.grid.onContextMenu = function( G, D ) { | |
| G.preventDefault(); | |
| var y = v.grid.getSelectedRows().sort(function( q, r ) { | |
| return q - r | |
| }), | |
| A = []; | |
| if (!(y.length > 1)) { | |
| v.currentRow = D; | |
| v.grid.setSelectedRows([D]); | |
| v.grid.onSelectedRowsChanged() | |
| } | |
| switch ( v.type ) { | |
| case "artist": | |
| A = GS.Models.Artist.getOneFromCache(v.dataView.rows[D].ArtistID).getContextMenu(); | |
| break; | |
| case "album": | |
| A = GS.Models.Album.getOneFromCache(v.dataView.rows[D].AlbumID).getContextMenu(); | |
| break; | |
| case "song": | |
| if ( y.length > 1 ) { | |
| A = []; | |
| for ( var I = 0; I < y.length; I++ ) | |
| A.push(v.dataView.rows[y[I]].SongID); | |
| A = v.getContextMenuMultiselectForSong(A) | |
| } else A = v.getContextMenuForSong(v.dataView.rows[D].SongID); | |
| break; | |
| case "playlist": | |
| A = GS.Models.Playlist.getOneFromCache(v.dataView.rows[D].PlaylistID).getContextMenu(); | |
| break; | |
| case "station": | |
| A = GS.Models.Station.getOneFromCache(v.dataView.rows[D].StationID).getContextMenu(); | |
| break | |
| } | |
| $(G.target).jjmenu(G, A, null, { | |
| xposition: "mouse", | |
| yposition: "mouse", | |
| show: "show", | |
| className: "contextmenu" | |
| }) | |
| }; | |
| this.grid.onDblClick = function( G, D ) { | |
| var y = v.dataView.rows[D]; | |
| if (!($(G.target).parents(".options").length > 0)) if (!$(G.target).is("a.play") ) if ( v.options.isNowPlaying && y.queueSongID ) GS.player.playSong(y.queueSongID); | |
| else if ( y.SongID ) { | |
| var A = GS.Controllers.PageController.getActiveController().getPlayContext(); | |
| GS.player.addSongAndPlay(y.SongID, A); | |
| A = { | |
| songID: y.songID, | |
| rank: parseInt(D, 10) + 1 | |
| }; | |
| if ( y.ppVersion ) A.ppVersion = y.ppVersion; | |
| GS.getGuts().logEvent("doubleClickToPlay", A) | |
| } else y.StationID && GS.player.setAutoplay(true, y.StationID) | |
| }; | |
| this.grid.onKeyDown = function( G ) { | |
| if ( G.which === 65 && (G.ctrlKey || G.metaKey) ) { | |
| G = []; | |
| v.selectedRowIDs = []; | |
| for ( var D = 0; D < v.dataView.rows.length; D++ ) { | |
| G.push(D); | |
| v.selectedRowIDs.push(v.dataView.rows[D].id) | |
| } | |
| v.currentRow = v.dataView.rows.length - 1; | |
| v.grid.setSelectedRows(_.arrUnique(G)); | |
| v.grid.onSelectedRowsChanged(); | |
| return true | |
| } | |
| if ( v.handleKeyPress(G) ) return true; | |
| return $(G.target).is("input,textarea,select") ? true : false | |
| }; | |
| this.grid.onSelectedRowsChanged = function() { | |
| v.selectedRowIDs = []; | |
| var G, D, y = v.grid.getSelectedRows().sort(function( I, q ) { | |
| return I - q | |
| }), | |
| A = {}; | |
| if ( v.options.isFilter ) { | |
| if ( y.length === 1 && y[0] === 0 && v.dataView.getItemByIdx(0)[v.idProperty] === -1 ) y = []; | |
| G = y.indexOf(0); | |
| if ( G > -1 ) { | |
| y.splice(G, 1); | |
| v.grid.setSelectedRows(y); | |
| v.grid.onSelectedRowsChanged(); | |
| return | |
| } | |
| y.length === 0 ? $(".slick-row[row=0]", v.element).addClass("selected") : $(".slick-row[row=0]", v.element).removeClass("selected") | |
| } | |
| G = 0; | |
| for ( l = y.length; G < l; G++ ) | |
| if ( D = | |
| v.dataView.rows[y[G]] ) { | |
| v.selectedRowIDs.push(D[v.idProperty]); | |
| A[D[v.idProperty]] = true | |
| } | |
| v.selectedRowIDs = _.arrUnique(v.selectedRowIDs); | |
| if ( v.options.isFilter ) if ( v.type === "album" ) { | |
| if ( y.length === 0 ) $(".gs_grid.songs").controller().filter.albumIDs = false; | |
| else $(".gs_grid.songs").controller().filter.albumIDs = A; | |
| $(".gs_grid.songs").controller().dataView.refresh() | |
| } else if ( v.type === "artist" ) { | |
| if ( y.length === 0 ) { | |
| $(".gs_grid.songs").controller().filter.artistIDs = false; | |
| $(".gs_grid.albums").controller().filter.artistIDs = | |
| false | |
| } else { | |
| $(".gs_grid.songs").controller().filter.artistIDs = A; | |
| $(".gs_grid.albums").controller().filter.artistIDs = A | |
| } | |
| $(".gs_grid.songs").controller().dataView.refresh(); | |
| $(".gs_grid.albums").controller().dataView.refresh(); | |
| $(".gs_grid.albums").controller().grid.onSelectedRowsChanged() | |
| } | |
| v.currentRow = _.orEqual(v.grid.getSelectedRows()[y.length - 1], 0); | |
| $.publish("gs.grid.selectedRows", { | |
| len: v.selectedRowIDs.length, | |
| type: v.type | |
| }) | |
| }; | |
| $(".slick-header-column").click(function() { | |
| $(this).addClass("selected"); | |
| $(this).siblings().removeClass("selected") | |
| }); | |
| this.grid.onSort = function( G, D, y ) { | |
| var A; | |
| if ( _.notDefined(D) ) D = _.defined(v.pastSorts[G]) && G == v.sortCol ? !v.pastSorts[G] : true; | |
| v.sortColData = G; | |
| v.sortName = G.name ? G.name : null; | |
| v.sortCol = G.field ? G.field : G; | |
| v.sortCols = _.orEqual(GS.Controllers.GridController.defaultMultiSorts[v.sortCol], $.makeArray(v.sortCol)); | |
| v.sortDir = D ? true : false; | |
| v.element.find(".slick-sort-indicator").removeClass("slick-sort-indicator-asc").removeClass("slick-sort-indicator-desc"); | |
| A = GS.Controllers.GridController.columnsByName[v.sortCol]; | |
| forcedDir = | |
| GS.Controllers.GridController.forcedSortDirections[v.sortCol]; | |
| if ( _.defined(A) ) v.grid.setSortColumn(A, v.sortDir); | |
| else v.sortDir = _.defined(forcedDir) ? forcedDir : v.origSortDir; | |
| v.pastSorts[v.sortCol] = v.sortDir; | |
| v.sortNumeric = GS.Controllers.GridController.numericColumns[v.sortCol] ? true : false; | |
| v.dataView.sort(w, v.sortDir); | |
| if (!y && G ) { | |
| y = $("button.dropdownButton.sort").find("span.label"); | |
| if ( v.sortName ) { | |
| if ( v.sortName == "PLAYLIST" || v.sortName == "USER" ) v.sortName = "NAME"; | |
| y.attr("data-translate-text", "SORT_BY_" + v.sortName); | |
| y.text($.localize.getString("SORT_BY_" + v.sortName)) | |
| } else if ( v.columns ) { | |
| A = v.columns.length; | |
| for ( var I = 0; I < A; I++ ) | |
| if ( v.columns[I] && v.columns[I].field === v.sortCol ) { | |
| y.attr("data-translate-text", "SORT_BY_" + v.columns[I].name); | |
| y.text($.localize.getString("SORT_BY_" + v.columns[I].name)); | |
| break | |
| } | |
| } | |
| if ( GS.page.activePageName === "music" && GS.page.activePageIdentifier == GS.user.UserID ) v.sortColData === "TSAdded" ? GS.store.remove("gs.sort.user.music") : GS.store.set("gs.sort.user.music", { | |
| sortCol: G, | |
| sortDir: D, | |
| onInitSort: false | |
| }) | |
| } | |
| }; | |
| v.dataView.onRowCountChanged.subscribe(function() { | |
| v.grid.updateRowCount() | |
| }); | |
| v.dataView.onRowsChanged.subscribe(function( G ) { | |
| v.grid.removeRows(G); | |
| v.grid.resizeAndRender(); | |
| if ( v.selectedRowIDs.length > 0 ) { | |
| G = []; | |
| for ( var D, y = 0, A = v.selectedRowIDs.length; y < A; y++ ) { | |
| D = v.dataView.getRowById(v.selectedRowIDs[y]); | |
| D !== undefined && G.push(D) | |
| } | |
| v.currentRow = _.orEqual(D, 0); | |
| v.grid.setSelectedRows(_.arrUnique(G)); | |
| v.grid.onSelectedRowsChanged() | |
| } | |
| }); | |
| v.grid.onBeforeMoveRows = function() { | |
| if ( v.allowDragSort ) return true; | |
| return false | |
| }; | |
| v.grid.onMoveRows = function( G, D ) { | |
| var y = [], | |
| A = [], | |
| I = [], | |
| q = v.dataView.getItems(), | |
| r, s, u; | |
| if (!(!v.allowDragSort || v.sortCol !== "Sort")) if ( v.options.playlistID )(y = GS.Models.Playlist.getOneFromCache(v.options.playlistID)) && y.moveSongsTo(G, D); | |
| else { | |
| r = q.slice(0, D); | |
| s = q.slice(D, q.length); | |
| for ( u = 0; u < G.length; u++ ) { | |
| q[G[u]].Sort = u; | |
| y.push(q[G[u]]) | |
| } | |
| G.sort().reverse(); | |
| for ( u = 0; u < G.length; u++ ) { | |
| q = G[u]; | |
| q < D ? r.splice(q, 1) : s.splice(q - D, 1) | |
| } | |
| q = r.concat(y.concat(s)); | |
| for ( u = 0; u < q.length; u++ ) | |
| q[u].Sort = u + 1; | |
| v.data = q; | |
| for ( u = 0; u < G.length; u++ ) | |
| A.push(r.length + u); | |
| A = _.arrUnique(A); | |
| v.currentRow = A[A.length - 1]; | |
| v.dataView.beginUpdate(); | |
| v.grid.setSelectedRows(A); | |
| v.grid.onSelectedRowsChanged(); | |
| v.dataView.setItems(v.data, v.idProperty); | |
| v.dataView.endUpdate(); | |
| v.dataView.refresh(); | |
| if ( v.options.isNowPlaying ) { | |
| r = D; | |
| for ( u = 0; u < y.length; u++ ) { | |
| I.push(y[u].queueSongID); | |
| A = $("#queue .queueSong:nth-child(" + D + ")"); | |
| A.after($("#" + y[u].queueSongID).remove()); | |
| D += 1 | |
| } | |
| GS.player.moveSongsTo(I, r) | |
| } | |
| } | |
| }; | |
| if ( v.allowDragSort || v.allowDropOn ) { | |
| n = v.grid.getOptions(); | |
| var B = $("#grid .slick-viewport"), | |
| E = n.scrollPane ? $(n.scrollPane) : B, | |
| H = function( G, D ) { | |
| var y = G.clientY - B.find(".grid-canvas").offset().top; | |
| if ( B.within(G.clientX, G.clientY).length > 0 ) { | |
| $(D.proxy).addClass("valid").removeClass("invalid"); | |
| if ( v.allowDragSort ) { | |
| y = Math.max(0, Math.min(Math.round(y / n.rowHeight), m ? m.length : 0)); | |
| if ( y !== D.gridInsertIndex ) { | |
| if ( v.onBeforeMoveRows && v.onBeforeMoveRows(v.grid.getSelectedRows(), y) === false ) { | |
| $("div.slick-reorder-guide").css("top", -1000).show(); | |
| D.canMove = false | |
| } else { | |
| $("div.slick-reorder-guide").css({ | |
| top: y * n.rowHeight + n.padding | |
| }).show(); | |
| D.canMove = true | |
| } | |
| D.gridInsertIndex = y | |
| } | |
| } else { | |
| y = $(".slick-row").within(D.clientX, D.clientY).eq(0); | |
| if ( y.length ) { | |
| y.addClass("hover").siblings().removeClass("hover"); | |
| D.gridInsertIndex = parseInt(y.attr("row"), 10) | |
| } | |
| } | |
| } else { | |
| $(D.proxy).addClass("invalid").removeClass("valid"); | |
| $("div.slick-reorder-guide").hide() | |
| } | |
| if ( n.autoDragScroll ) { | |
| var A = E.within(G.clientX, G.clientY).length > 0; | |
| y = Math.ceil(E.height() * 0.2); | |
| var I = n.rowHeight * (m ? m.length : 0); | |
| if ( A ) if (!($("#shortcuts").within(G.clientX, G.clientY).length > 0 || $("#footer").within(G.clientX, G.clientY).length > 0)) if ( D.gridAutoScrollWaitTimeout ) { | |
| A = function() { | |
| var r = (new Date).valueOf(); | |
| if ( D.gridAutoScrollHasWaited && (!D.gridAutoScrollLast || r - D.gridAutoScrollLast >= 200) ) { | |
| D.gridAutoScrollLast = r; | |
| E.scrollTop(Math.max(0, E.scrollTop() - 41)) | |
| } | |
| }; | |
| var q = function() { | |
| var r = (new Date).valueOf(); | |
| if ( D.gridAutoScrollHasWaited && (!D.gridAutoScrollLast || r - D.gridAutoScrollLast >= 200) ) { | |
| D.gridAutoScrollLast = r; | |
| E.scrollTop(Math.min(I, E.scrollTop() + 41)) | |
| } | |
| }; | |
| if ( E.offset().top + y > G.clientY ) { | |
| A(); | |
| clearInterval(D.gridAutoScrollInterval); | |
| D.gridAutoScrollInterval = setInterval(A, 200) | |
| } else if ( E.offset().top + E.height() - y < G.clientY ) { | |
| q(); | |
| clearInterval(D.gridAutoScrollInterval); | |
| D.gridAutoScrollInterval = setInterval(q, 200) | |
| } else { | |
| clearTimeout(D.gridAutoScrollWaitTimeout); | |
| D.gridAutoScrollWaitTimeout = false; | |
| D.gridAutoScrollHasWaited = false; | |
| clearInterval(D.gridAutoScrollInterval); | |
| D.gridAutoScrollInterval = false | |
| } | |
| } else D.gridAutoScrollWaitTimeout = setTimeout(function() { | |
| D.gridAutoScrollHasWaited = true; | |
| D.gridAutoScrollWaitTimeout = | |
| false | |
| }, 500) | |
| } | |
| }; | |
| E.data("ignoreForOverDrop", true).bind("dropinit", function() { | |
| this.updateDropOnDrag = H | |
| }).bind("dropstart", function( G, D ) { | |
| if (!D.draggedItems ) { | |
| this.updateDropOnDrag = null; | |
| return false | |
| } | |
| $("<div class='slick-reorder-guide'/>").css({ | |
| position: "absolute", | |
| zIndex: "99998", | |
| width: B.innerWidth() - n.padding * 2, | |
| top: -1000, | |
| right: n.padding | |
| }).appendTo(B); | |
| D.gridInsertIndex = -1; | |
| D.gridAutoScrollHasWaited = false; | |
| D.gridAutoScrollWaitTimeout = false | |
| }).bind("dropend", function( G, D ) { | |
| B.find(".slick-reorder-guide").remove(); | |
| B.find(".slick-row").removeClass("hover"); | |
| clearInterval(D.gridAutoScrollInterval); | |
| D.gridAutoScrollInterval = false | |
| }).bind("drop", function( G, D ) { | |
| function y(I, q) { | |
| q = _.orEqual(q, new GS.Models.PlayContext); | |
| var r, s = [], | |
| u; | |
| for ( r = 0; r < I.length; r++ ) | |
| s.push(I[r].SongID); | |
| if ( v.allowDropOn )(r = v.dataView.getItemByIdx(D.gridInsertIndex)) && r instanceof GS.Models.Playlist && r.addSongs(s, null, true); | |
| else if ( v.options.playlistID ) { | |
| r = GS.Models.Playlist.getOneFromCache(v.options.playlistID); | |
| u = D.gridInsertIndex !== -1 ? D.gridInsertIndex : null; | |
| r.addSongs(s, u) | |
| } else { | |
| u = D.gridInsertIndex !== -1 ? D.gridInsertIndex : GS.player.INDEX_DEFAULT; | |
| GS.player.addSongsToQueueAt(s, u, false, q) | |
| } | |
| } | |
| var A; | |
| if ( B.within(G.clientX, G.clientY).length > 0 ) if ( D.draggedItemsSource == "grid" && v.grid.onMoveRows && D.canMove ) { | |
| v.grid.onMoveRows(v.grid.getSelectedRows(), D.gridInsertIndex); | |
| GS.getGuts().gaTrackEvent("grid", "dragSuccess") | |
| } else { | |
| D.draggedItemsType = D.draggedItemsType || _.guessDragType(D.draggedItems); | |
| switch ( D.draggedItemsType ) { | |
| case "song": | |
| y(D.draggedItems, D.draggedItemsContext); | |
| break; | |
| case "album": | |
| for ( A = 0; A < D.draggedItems.length; A++ ) | |
| D.draggedItems[A].getSongs(function( I ) { | |
| I.sort(GS.Models.Album.defaultSongSort); | |
| y(I, new GS.Models.PlayContext(GS.player.PLAY_CONTEXT_ALBUM, D.draggedItems[A])) | |
| }, null, true, { | |
| async: false | |
| }); | |
| break; | |
| case "artist": | |
| for ( A = 0; A < D.draggedItems.length; A++ ) | |
| D.draggedItems[A].getSongs(function( I ) { | |
| I.sort(GS.Models.Artist.defaultSongSort); | |
| y(I, new GS.Models.PlayContext(GS.player.PLAY_CONTEXT_ARTIST, D.draggedItems[A])) | |
| }, null, { | |
| async: false | |
| }); | |
| break; | |
| case "playlist": | |
| for ( A = | |
| 0; A < D.draggedItems.length; A++ ) | |
| D.draggedItems[A].getSongs(function( I ) { | |
| y(I, new GS.Models.PlayContext(GS.player.PLAY_CONTEXT_PLAYLIST, D.draggedItems[A])) | |
| }, null, false, { | |
| async: false | |
| }); | |
| break; | |
| case "user": | |
| for ( A = 0; A < D.draggedItems.length; A++ ) | |
| D.draggedItems[A].getFavoritesByType("Song", function( I ) { | |
| y(I, new GS.Models.PlayContext(GS.player.PLAY_CONTEXT_USER, D.draggedItems[A])) | |
| }, null, false, { | |
| async: false | |
| }); | |
| break; | |
| default: | |
| console.error("grid drop, invalid drag type", D.draggedItemsType); | |
| return | |
| } | |
| } | |
| }) | |
| } | |
| v.dataView.beginUpdate(); | |
| v.dataView.setItems(v.data, v.idProperty); | |
| v.dataView.setFilter(function( G ) { | |
| if ( v.options.isFilter && G.isFilterAll ) return true; | |
| if ( v.searchString != "" && (!G.hasOwnProperty(v.options.searchText) || G[v.options.searchText].toLowerCase().indexOf(v.searchString) == -1) ) return false; | |
| if ( v.filter.hasOwnProperty("onlyVerified") && v.filter.onlyVerified && G.IsVerified === 0 ) return false; | |
| if ( v.filter.artistIDs && !v.filter.artistIDs[G.ArtistID] ) return false; | |
| if ( v.filter.albumIDs && !v.filter.albumIDs[G.AlbumID] ) return false; | |
| return true | |
| }); | |
| v.sortCol !== "" && v.grid.onSort(v.sortCol, v.sortDir, v.onInitSort); | |
| $(window).resize(); | |
| v.dataView.endUpdate(); | |
| if ( v.options.isFilter ) { | |
| v.grid.setSelectedRows([0]); | |
| v.grid.onSelectedRowsChanged() | |
| } | |
| this.Class.resizeAfterRender() | |
| }, | |
| update: function() {}, | |
| songChange: function( k ) { | |
| var m = $("#page").is(".gs_page_playlist") ? $("#page").controllers(GS.Controllers.Page.PlaylistController)[0] : false; | |
| m = m ? m.playlist.songIDLookup[k.SongID] : this.dataView.getItemById(k[this.idProperty]); | |
| if (!m ) return false; | |
| var p = ["IsVerified", "TSAdded", "TSFavorited", "Sort", "Popularity"]; | |
| for ( var n in k ) | |
| if ( k.hasOwnProperty(n) && p.indexOf(n) == -1 ) m[n] = k[n]; | |
| this.dataView.updateItem(m[this.idProperty], m) | |
| }, | |
| albumChange: function( k ) { | |
| var m = this.dataView.getItemById(k[this.idProperty]); | |
| if (!m ) return false; | |
| for ( var p in k ) | |
| if ( k.hasOwnProperty(p) ) m[p] = k[p]; | |
| this.dataView.updateItem(m.AlbumID, m) | |
| }, | |
| artistChange: function( k ) { | |
| var m = this.dataView.getItemById(k[this.idProperty]); | |
| if (!m ) return false; | |
| for ( var p in k ) | |
| if ( k.hasOwnProperty(p) ) m[p] = k[p]; | |
| this.dataView.updateItem(m.ArtistID, m) | |
| }, | |
| playlistChange: function( k ) { | |
| var m = this.dataView.getItemById(k[this.idProperty]); | |
| if ( m ) { | |
| for ( var p in k ) | |
| if ( k.hasOwnProperty(p) ) m[p] = k[p]; | |
| this.dataView.updateItem(m.PlaylistID, m) | |
| } | |
| }, | |
| userChange: function( k ) { | |
| var m = this.dataView.getItemById(k[this.idProperty]); | |
| if (!m ) return false; | |
| for ( var p in k ) | |
| if ( k.hasOwnProperty(p) ) m[p] = k[p]; | |
| this.dataView.updateItem(m.UserID, m) | |
| }, | |
| songFavoritesChange: function() { | |
| this.data = this.dataView.getItems(); | |
| for ( var k = 0; k < this.data.length; k++ ) | |
| if ( GS.user.favorites.songs[this.data[k].SongID] ) { | |
| this.data[k].isFavorite = | |
| 1; | |
| this.data[k].fromLibrary = 1; | |
| this.dataView.updateItem(this.data[k].SongID, this.data[k]) | |
| } | |
| this.dataView.beginUpdate(); | |
| this.dataView.setItems(this.data, "SongID"); | |
| this.dataView.endUpdate() | |
| }, | |
| albumFavoritesChange: function() { | |
| this.data = this.dataView.getItems(); | |
| for ( var k = 0; k < this.data.length; k++ ) | |
| if ( GS.user.favorites.albums[this.data[k].AlbumID] ) { | |
| this.data[k].isFavorite = 1; | |
| this.dataView.updateItem(this.data[k].SongID, this.data[k]) | |
| } | |
| this.dataView.beginUpdate(); | |
| this.dataView.setItems(this.data, "AlbumID"); | |
| this.dataView.endUpdate() | |
| }, | |
| artistFavoritesChange: function() { | |
| this.data = this.dataView.getItems(); | |
| for ( var k = 0; k < this.data.length; k++ ) | |
| if ( GS.user.favorites.artists[this.data[k].ArtistID] ) this.data[k].isFavorite = 1; | |
| this.dataView.beginUpdate(); | |
| this.dataView.setItems(this.data, "ArtistID"); | |
| this.dataView.endUpdate() | |
| }, | |
| playlistFavoritesChange: function() { | |
| this.data = this.dataView.getItems(); | |
| for ( var k = 0; k < this.data.length; k++ ) | |
| if ( GS.user.favorites.playlists[this.data[k].PlaylistID] ) this.data[k].isFavorite = 1; | |
| this.dataView.beginUpdate(); | |
| this.dataView.setItems(this.data, "PlaylistID"); | |
| this.dataView.endUpdate() | |
| }, | |
| userFavoritesChange: function() { | |
| this.data = this.dataView.getItems(); | |
| for ( var k = 0; k < this.data.length; k++ ) | |
| if ( GS.user.favorites.users[this.data[k].UserID] ) this.data[k].isFavorite = 1 | |
| }, | |
| queueChange: function( k ) { | |
| k || (k = GS.player.getCurrentQueue()); | |
| if ( this.element ) { | |
| this.element.toggleClass("hasSongs", k && k.songs && k.songs.length > 0); | |
| k && k.songs && k.songs.length > 0 ? $(".grid-canvas a.play").attr("data-translate-title", "SONG_ROW_ADD_SONG_ADD_TO_PLAYING_TITLE").attr("title", $.localize.getString("SONG_ROW_ADD_SONG_ADD_TO_PLAYING_TITLE")) : $(".grid-canvas a.play").attr("data-translate-title", "SONG_ROW_ADD_SONG_PLAY_TITLE").attr("title", $.localize.getString("SONG_ROW_ADD_SONG_PLAY_TITLE")) | |
| } | |
| }, | |
| getContextMenuForSong: function( k ) { | |
| var m = GS.Controllers.PageController.getActiveController().getPlayContext(), | |
| p = GS.Models.Song.getOneFromCache(k), | |
| n = GS.getGuts().extractSongItemInfo(this), | |
| o = [{ | |
| title: $.localize.getString("CONTEXT_PLAY_SONG_NOW"), | |
| action: { | |
| type: "fn", | |
| callback: function() { | |
| GS.player.addSongAndPlay(k, m); | |
| GS.getGuts().onContextMenuClick("contextPlaySongNow", "rightClickSingleSong", false, n) | |
| } | |
| }, | |
| customClass: "last jj_menu_item_hasIcon jj_menu_item_play" | |
| }, | |
| { | |
| title: $.localize.getString("CONTEXT_PLAY_SONG_NEXT"), | |
| action: { | |
| type: "fn", | |
| callback: function() { | |
| GS.player.addSongsToQueueAt([k], GS.player.INDEX_NEXT, false, m); | |
| GS.getGuts().onContextMenuClick("contextPlaySongNext", "rightClickSingleSong", false, n) | |
| } | |
| }, | |
| customClass: "last jj_menu_item_hasIcon jj_menu_item_play_next" | |
| }, | |
| { | |
| title: $.localize.getString("CONTEXT_PLAY_SONG_LAST"), | |
| action: { | |
| type: "fn", | |
| callback: function() { | |
| GS.player.addSongsToQueueAt([k], GS.player.INDEX_LAST, false, m); | |
| GS.getGuts().onContextMenuClick("contextPlaySongLast", "rightClickSingleSong", false, n) | |
| } | |
| }, | |
| customClass: "last jj_menu_item_hasIcon jj_menu_item_play_last" | |
| }, | |
| { | |
| customClass: "separator" | |
| }]; | |
| if ( p ) o = o.concat(p.getContextMenu({ | |
| menuType: "rightClickSingleSong", | |
| gridController: this | |
| })); | |
| return o | |
| }, | |
| getContextMenuMultiselectForSong: function( k ) { | |
| var m = GS.Controllers.PageController.getActiveController().getPlayContext(), | |
| p = GS.getGuts().extractMultiSongInfo(this, k), | |
| n = { | |
| menuType: "rightClickMultiSong", | |
| multiClick: true, | |
| gridController: this | |
| }, | |
| o = [{ | |
| title: $.localize.getString("CONTEXT_PLAY_SONGS_NOW"), | |
| customClass: "jj_menu_item_hasIcon jj_menu_item_play", | |
| action: { | |
| type: "fn", | |
| callback: function() { | |
| GS.player.addSongsToQueueAt(k, GS.player.INDEX_DEFAULT, true, m); | |
| GS.getGuts().onContextMenuClick("contextPlaySongsNow", "rightClickMultiSong", true, p) | |
| } | |
| } | |
| }, | |
| { | |
| title: $.localize.getString("CONTEXT_PLAY_SONGS_NEXT"), | |
| customClass: "jj_menu_item_hasIcon jj_menu_item_play_next", | |
| action: { | |
| type: "fn", | |
| callback: function() { | |
| GS.player.addSongsToQueueAt(k, GS.player.INDEX_NEXT, false, m); | |
| GS.getGuts().onContextMenuClick("contextPlaySongsNext", "rightClickMultiSong", true, p) | |
| } | |
| } | |
| }, | |
| { | |
| title: $.localize.getString("CONTEXT_PLAY_SONGS_LAST"), | |
| customClass: "jj_menu_item_hasIcon jj_menu_item_play_last", | |
| action: { | |
| type: "fn", | |
| callback: function() { | |
| GS.player.addSongsToQueueAt(k, GS.player.INDEX_LAST, false, m); | |
| GS.getGuts().onContextMenuClick("contextPlaySongsLast", "rightClickMultiSong", true, p) | |
| } | |
| } | |
| }, | |
| { | |
| customClass: "separator" | |
| }], | |
| t = true; | |
| if ( GS.user.library ) for ( i in k ) { | |
| if ( k.hasOwnProperty(i) ) { | |
| songID = | |
| k[i]; | |
| if ( parseInt(songID) && !GS.user.library.songs[songID] ) { | |
| t = false; | |
| break | |
| } | |
| } | |
| } | |
| else t = false; | |
| t ? o.push({ | |
| title: $.localize.getString("CONTEXT_REMOVE_FROM_LIBRARY"), | |
| customClass: "jj_menu_item_hasIcon jj_menu_item_remove_music", | |
| action: { | |
| type: "fn", | |
| callback: function() { | |
| GS.getGuts().onContextMenuClick("contextRemoveFromLibrary", "rightClickMultiSong", true, p); | |
| GS.user.removeFromLibrary(k) | |
| } | |
| } | |
| }) : o.push({ | |
| title: $.localize.getString("CONTEXT_ADD_TO_LIBRARY"), | |
| customClass: "jj_menu_item_hasIcon jj_menu_item_music", | |
| action: { | |
| type: "fn", | |
| callback: function() { | |
| GS.user.addToLibrary(k); | |
| GS.getGuts().onContextMenuClick("contextAddToLibrary", "rightClickMultiSong", true, p) | |
| } | |
| } | |
| }); | |
| o.push({ | |
| title: $.localize.getString("CONTEXT_ADD_TO_PLAYLIST"), | |
| type: "sub", | |
| customClass: "jj_menu_item_hasIcon jj_menu_item_playlists", | |
| src: GS.Models.Playlist.getPlaylistsMenu(k, function( w ) { | |
| w.addSongs(k, null, true) | |
| }, null, null, n) | |
| }, { | |
| customClass: "separator" | |
| }, { | |
| title: $.localize.getString("CONTEXT_SHARE_SONG"), | |
| type: "sub", | |
| customClass: "jj_menu_item_hasIcon jj_menu_item_share", | |
| src: [{ | |
| title: $.localize.getString("SHARE_WIDGET"), | |
| customClass: "jj_menu_item_hasIcon jj_menu_item_share_widget", | |
| action: { | |
| type: "fn", | |
| callback: function() { | |
| GS.getLightbox().open("share", { | |
| service: "widget", | |
| type: "manySongs", | |
| id: k | |
| }); | |
| GS.getGuts().onContextMenuClick("contextShareWidget", "rightClickMultiSong", true, p) | |
| } | |
| } | |
| }] | |
| }, { | |
| customClass: "separator" | |
| }, { | |
| title: $.localize.getString("CONTEXT_REPLACE_ALL_SONGS"), | |
| customClass: "jj_menu_item_hasIcon jj_menu_item_now_playing", | |
| action: { | |
| type: "fn", | |
| callback: function() { | |
| GS.player.addSongsToQueueAt(k, GS.player.INDEX_REPLACE, GS.player.isPlaying, m); | |
| GS.getGuts().onContextMenuClick("contextReplaceAllSongs", "rightClickMultiSong", true, p) | |
| } | |
| } | |
| }); | |
| return o | |
| }, | |
| "input.search keyup": function( k ) { | |
| Slick.GlobalEditorLock.cancelCurrentEdit(); | |
| if ( e.which == 27 ) k.value = ""; | |
| this.searchString = k.value.toLowerCase(); | |
| this.dataView.refresh() | |
| }, | |
| ".grid-canvas click": function( k, m ) { | |
| if ( $(m.target).parents(".slick-row").length === 0 ) { | |
| self.currentRow = 0; | |
| this.grid.setSelectedRows([]); | |
| this.grid.onSelectedRowsChanged() | |
| } | |
| }, | |
| "* keydown": function( k, m ) { | |
| this.handleKeyPress(m) | |
| }, | |
| ".slick-collapse-indicator click": function( k, m ) { | |
| m.preventDefault(); | |
| var p = $(k).parents("div.page_column"), | |
| n = GS.page.getActiveController().Class, | |
| o = p.attr("id") + "Collapse"; | |
| n[o] || (n[o] = {}); | |
| p.toggleClass("collapsed"); | |
| p.addClass("suppressAutoCollapse"); | |
| if ( p.hasClass("collapsed") ) { | |
| p.addClass("manualCollapse").removeClass("manualOpen"); | |
| $(".page_column_fixed.collapsed").width(this.grid.getScrollWidth()); | |
| n[o].manualCollapse = true; | |
| n[o].manualOpen = false; | |
| n[o].collapsed = true | |
| } else { | |
| p.addClass("manualOpen").removeClass("manualCollapse"); | |
| $(".page_column_fixed").width(175); | |
| n[o].manualOpen = true; | |
| n[o].manualCollapse = false; | |
| n[o].collapsed = false | |
| } | |
| n.storeFilterCollapseState(); | |
| GS.resize(); | |
| $(this.element).resize() | |
| }, | |
| handleKeyPress: function( k ) { | |
| if ((k.which === 38 || k.which === 40) && k.shiftKey ) { | |
| var m = this.grid.getSelectedRows().sort(function( o, t ) { | |
| return o - t | |
| }); | |
| _.orEqual(m[m.length - 1], 1); | |
| var p, n; | |
| p = this.currentRow + (k.which === 38 ? -1 : 1); | |
| p = Math.max(0, Math.min(this.dataView.rows.length - 1, p)); | |
| if ( $.inArray(p, m) === -1 ) { | |
| m.push(p); | |
| this.selectedRowIDs.push(this.dataView.getItemByIdx(p).SongID); | |
| this.currentRow = | |
| p; | |
| this.grid.setSelectedRows(_.arrUnique(m)); | |
| this.grid.onSelectedRowsChanged() | |
| } else if ( k.which === 38 ) { | |
| if ( p < this.currentRow ) { | |
| n = $.inArray(this.currentRow, m); | |
| _.arrRemove(m, n, n); | |
| this.currentRow = p; | |
| n = $.inArray(this.currentRow, m); | |
| _.arrRemove(m, n, n); | |
| m.push(this.currentRow); | |
| this.grid.setSelectedRows(_.arrUnique(m)); | |
| this.grid.onSelectedRowsChanged() | |
| } | |
| } else if ( p > this.currentRow ) { | |
| n = $.inArray(this.currentRow, m); | |
| _.arrRemove(m, n, n); | |
| this.currentRow = p; | |
| n = $.inArray(this.currentRow, m); | |
| _.arrRemove(m, n, n); | |
| m.push(this.currentRow); | |
| this.grid.setSelectedRows(_.arrUnique(m)); | |
| this.grid.onSelectedRowsChanged() | |
| } | |
| k.preventDefault(); | |
| return true | |
| } | |
| return false | |
| }, | |
| "#grid.songs a.songLink, #grid.feeds div.songs a.songLink click": function( k, m ) { | |
| m.preventDefault(); | |
| var p = parseInt($(k).attr("rel"), 10); | |
| if ( p && _.defined(m.which) && !$(k).closest(".grid-canvas").hasClass("noLinks") ) { | |
| var n = $(k).data("clickCount"); | |
| n || (n = 0); | |
| n++; | |
| n == 1 && setTimeout(this.callback(function() { | |
| if ( $(k).data("clickCount") == 1 ) if ( k[0].href ) { | |
| var w = $(k).attr("href"); | |
| if ( w.indexOf("#") > 1 ) { | |
| w = w.split("#"); | |
| location.hash = "#" + w[1] | |
| } else location.hash = $(k).attr("href") | |
| } else GS.Models.Song.getSong(p, this.callback(function( x ) { | |
| if ( x ) { | |
| x.toUrl(); | |
| location.hash = x.toUrl(); | |
| var v = parseInt(this.grid.getSelectedRows()[0]) + 1, | |
| B = v <= this.data.length ? this.data[v - 1].ppVersion : 0; | |
| GS.getGuts().handleFieldClick(x.toUrl(), v, p, B) | |
| } | |
| })); | |
| $(k).data("clickCount", 0) | |
| }), 300); | |
| $(k).data("clickCount", n); | |
| if ( n = $(k).attr("href") ) { | |
| var o = parseInt(this.grid.getSelectedRows()[0]) + 1, | |
| t = o <= this.data.length ? this.data[o - 1].ppVersion : 0; | |
| GS.getGuts().handleFieldClick(n, o, p, t) | |
| } | |
| } else if (!_.defined(m.which) ) return false | |
| }, | |
| "#grid .grid-canvas.noLinks mouseenter": function( k, m ) { | |
| if ( window.ctrlDown && !m.shiftKey && !m.ctrlKey && !m.metaKey ) { | |
| $("#grid .grid-canvas").removeClass("noLinks"); | |
| window.ctrlDown = false | |
| } | |
| }, | |
| "#grid.radioStations .station a click": function( k, m ) { | |
| m.stopPropagation(); | |
| var p = k.attr("data-tagid"); | |
| GS.player.setAutoplay(true, p); | |
| return false | |
| } | |
| }) | |
| })(); | |
| GS.Controllers.BaseController.extend("GS.Controllers.GUTSController", { | |
| isGSSingleton: true | |
| }, { | |
| shouldLog: false, | |
| server: "/guts", | |
| appID: "html", | |
| context: false, | |
| bufferLength: 10, | |
| localLogs: [], | |
| searchClickLpid: "searchClick", | |
| init: function() { | |
| this.shouldLog = _.orEqual(gsConfig.shouldUseGuts, 0); | |
| this.server = _.orEqual(gsConfig.gutsServer, false); | |
| this.context = {}; | |
| this.currentPage = {}; | |
| this.currentPage.pageType = "home"; | |
| this.currentPage.section = ""; | |
| this.currentPage.subpage = ""; | |
| this.currentPage.id = ""; | |
| if ( gsConfig.isPreview ) this.appID = "preview"; | |
| var a = _.browserDetect(); | |
| this.beginContext({ | |
| sessionID: GS.service.sessionID | |
| }); | |
| this.beginContext({ | |
| initTime: (new Date).getTime() | |
| }); | |
| this.logEvent("init", { | |
| browser: a.browser, | |
| browserVersion: a.version, | |
| os: navigator.platform, | |
| ip: gsConfig.remoteAddr | |
| }); | |
| GS.user && GS.user.UserID && GS.user.UserID > 0 && this.beginContext({ | |
| userID: GS.user.UserID | |
| }); | |
| window.chrome && window.chrome.app && window.chrome.app.isInstalled ? this.gaTrackEvent("chromeApp", "isInstalled") : this.gaTrackEvent("chromeApp", "notInstalled"); | |
| this._super() | |
| }, | |
| beginContext: function( a ) { | |
| _.forEach(a, function( b, c ) { | |
| if ( a.hasOwnProperty(c) ) this.context[c] = a[c] | |
| }, this) | |
| }, | |
| endContext: function( a ) { | |
| _.defined(this.context[a]) && delete this.context[a] | |
| }, | |
| doLogEvent: function( a, b ) { | |
| var c = { | |
| time: (new Date).getTime(), | |
| lpID: a, | |
| state: {}, | |
| context: {} | |
| }; | |
| currentContext = this.context; | |
| _.forEach(currentContext, function( g, h ) { | |
| if ( currentContext.hasOwnProperty(h) ) if ( $.isArray(currentContext[h]) ) { | |
| this.context[h] = []; | |
| _.forEach(currentContext[h], function( k, m ) { | |
| this.push(m) | |
| }, this.context[h]) | |
| } else this.context[h] = _.orEqual(currentContext[h], "").toString() | |
| }, c); | |
| _.forEach(b, function( g, h ) { | |
| if ( b.hasOwnProperty(h) ) c.state[h] = _.orEqual(g, "").toString() | |
| }, c); | |
| this.localLogs.push(c); | |
| this.checkSendCondition() && this.sendLogs() | |
| }, | |
| logEvent: function( a, b ) { | |
| this.shouldLog && this.doLogEvent(a, b) | |
| }, | |
| forceLogEvent: function( a, b ) { | |
| this.doLogEvent(a, b) | |
| }, | |
| checkSendCondition: function() { | |
| return this.localLogs.length >= this.bufferLength | |
| }, | |
| forceSend: function() { | |
| this.sendLogs(true) | |
| }, | |
| sendLogsTimeout: false, | |
| sendLogsWait: 3E4, | |
| sendLogs: function( a ) { | |
| clearTimeout(this.sendLogsTimeout); | |
| if ( a ) this._internalSend(false); | |
| else this.sendLogsTimeout = setTimeout(this.callback(this._internalSend), this.sendLogsWait) | |
| }, | |
| _internalSend: function( a ) { | |
| a = _.orEqual(a, true); | |
| if ( this.localLogs.length > 0 ) { | |
| var b = this.toTransmissionFormat(this.localLogs); | |
| $.ajax({ | |
| contentType: "text/xml", | |
| type: "POST", | |
| data: b, | |
| url: this.server, | |
| cache: false, | |
| async: a, | |
| success: function() {}, | |
| error: function() {} | |
| }); | |
| this.localLogs = [] | |
| } | |
| }, | |
| toTransmissionFormat: function( a ) { | |
| var b = { | |
| result: (new Date).getTime() + "\n", | |
| appID: this.appID | |
| }; | |
| _.forEach(a, function( c, g ) { | |
| var h = /\:/g, | |
| k = /\\/g, | |
| m = a[g]; | |
| this.result += this.appID + "\t"; | |
| this.result += m.lpID + "\t"; | |
| var p = m.context; | |
| _.forEach(p, function( o, t ) { | |
| if ( p.hasOwnProperty(t) ) this.result += t + ":" + p[t].replace(k, "\\\\").replace(h, "\\:") + "\t" | |
| }, this); | |
| var n = m.state; | |
| _.forEach(n, function( o, t ) { | |
| if ( n.hasOwnProperty(t) ) this.result += t + ":" + n[t].replace(k, "\\\\").replace(h, "\\:") + "\t" | |
| }, this); | |
| this.result += m.time + "\n" | |
| }, b); | |
| return b.result | |
| }, | |
| handlePageLoad: function( a, b ) { | |
| var c = {}; | |
| c.destinationPageType = a; | |
| switch ( a ) { | |
| case "home": | |
| if ( b.redeemingPromoCard ) c.reason = "redeem"; | |
| break; | |
| case "user": | |
| switch ( b.length ) { | |
| case 2: | |
| c.destinationPageID = b.id; | |
| break; | |
| case 3: | |
| c.destinationPageID = b.id; | |
| c.destinationSubpageType = b.section; | |
| break; | |
| case 4: | |
| c.destinationPageID = b.id; | |
| c.destinationSubpageType = b.subpage; | |
| break | |
| } | |
| c.destinationSubpageType = _.orEqual(c.destinationSubpageType, "profile"); | |
| break; | |
| case "playlist": | |
| case "album": | |
| case "artist": | |
| c.destinationPageID = b.id; | |
| c.destinationSubpageType = a == "album" && !b.subpage ? "tracklist" : a == "artist" && !b.subpage ? "overview" : b.subpage; | |
| break; | |
| case "search": | |
| c.destinationSubpageType = | |
| b.type == "everything" ? "everything" : b.type; | |
| break; | |
| case "popular": | |
| c.destinationSubpageType = b.pageType; | |
| break; | |
| case "song": | |
| c.destinationPageID = b.token; | |
| c.destinationSubpageType = b.subpage; | |
| break; | |
| case "notFound": | |
| this.logEvent("pageNotFound", { | |
| pageSought: b.page | |
| }); | |
| c.destinationPageType = "home"; | |
| c.reason = "pageNotFound"; | |
| break; | |
| case "settings": | |
| c.destinationSubpageType = _.orEqual(b.subpage, "profile"); | |
| break; | |
| case "surveys": | |
| if ( b.subpage ) c.destinationSubpageType = b.subpage; | |
| break; | |
| case "signup": | |
| if ( b.subpage ) c.destinationSubpageType = b.subpage; | |
| break; | |
| case "explore": | |
| if ( b.subpage && b.subpage == "popular" ) { | |
| c.destinationPageType = "popular"; | |
| c.destinationSubpageType = b.type || "daily" | |
| } else c.destinationSubpageType = b.subpage || "featured"; | |
| break; | |
| default: | |
| c.destinationPageType = a; | |
| break | |
| } | |
| if ( this.pageParamsAreDifferent(c) ) { | |
| this.logEvent("loadPage", c); | |
| this.beginContext({ | |
| currentPageType: c.destinationPageType | |
| }); | |
| c.destinationSubpageType ? this.beginContext({ | |
| currentSubpage: c.destinationSubpageType | |
| }) : this.endContext("currentSubpage"); | |
| c.destinationPageID ? this.beginContext({ | |
| currentPageID: c.destinationPageID | |
| }) : this.endContext("currentPageID") | |
| } | |
| }, | |
| updateCurrentPage: function( a ) { | |
| this.currentPage.pageType = a.type; | |
| this.currentPage.id = a.id; | |
| this.currentPage.section = a.section; | |
| this.currentPage.subpage = a.subpage | |
| }, | |
| logPageLoad: function( a ) { | |
| a.id ? this.logEvent("loadPage", { | |
| type: a.type, | |
| id: a.id | |
| }) : this.logEvent("loadPage", { | |
| type: a.type | |
| }); | |
| this.beginContext({ | |
| currentPageType: a.type | |
| }); | |
| this.endContext("currentSubpage") | |
| }, | |
| logSubpageLoad: function( a ) { | |
| this.logEvent("loadSubpage", { | |
| type: a.type | |
| }); | |
| this.beginContext({ | |
| currentSubpage: a.type | |
| }) | |
| }, | |
| handleFieldClick: function( a, b, c, g ) { | |
| b = { | |
| songID: c, | |
| rank: b | |
| }; | |
| if ( g != null && g.length > 0 ) b.ppVersion = g; | |
| g = ""; | |
| g = a.indexOf("artist") > -1 ? "OLartistPageLoad" : a.indexOf("album") > -1 ? "OLalbumPageLoad" : "OLSongPageLoad"; | |
| GS.getGuts().logEvent(g, b) | |
| }, | |
| handleFeedEventClick: function( a ) { | |
| var b = {}; | |
| switch ( $(a)[0].tagName ) { | |
| case "A": | |
| feedEvent = $(a).parents(".event"); | |
| if ( $(a).attr("href") ) { | |
| var c = $(a).attr("href").split("/"); | |
| b.clickedType = c[1]; | |
| b.clickedID = c[3] | |
| } else b.clickedType = $(a).attr("class"); | |
| break; | |
| case "LI": | |
| feedEvent = $(a).parents(".event"); | |
| a = $(a).attr("class").split(" "); | |
| a = a[a.length - 1]; | |
| if ( a == "option" ) b.clickedType = "playSongs"; | |
| else if ( a == "show" ) b.clickedType = "showSongs"; | |
| break; | |
| default: | |
| break | |
| } | |
| b.rank = $(feedEvent).index() + 1; | |
| var g = $(feedEvent).attr("class"); | |
| c = g.split(" "); | |
| b.whoseFeed = c[2].split("user")[1]; | |
| _.forEach(c, function( p, n ) { | |
| if ( c[n].indexOf("type") > -1 ) b.eventType = c[n].substring(4, c[n].length) | |
| }, b); | |
| var h = {}; | |
| $('.what>a[class!="showSongs"]', feedEvent).each(function() { | |
| var p = $(this).attr("href"); | |
| if ( p !== undefined ) { | |
| p = p.split("/"); | |
| var n = p[1]; | |
| if ( h[n] ) h[n] += 1; | |
| else h[n] = 1; | |
| b[n + h[n]] = p[3] | |
| } | |
| }); | |
| var k = {}; | |
| $("#feed>li").each(function() { | |
| g = $(this).attr("class"); | |
| c = g.split(" "); | |
| var p = c[1].substring(4, c[1].length); | |
| if ( k[p] ) k[p] += 1; | |
| else k[p] = 1 | |
| }); | |
| var m = ""; | |
| _.forEach(k, function( p, n ) { | |
| m = m + n + ";" + p + "," | |
| }, m); | |
| m = m.slice(0, m.length - 1); | |
| b.counts = m; | |
| this.logEvent("feedEventClick", b) | |
| }, | |
| objectListPlayAdd: function( a, b, c ) { | |
| var g, h; | |
| switch ( c ) { | |
| case "play": | |
| g = "OLPlayClick"; | |
| break; | |
| case "add": | |
| g = "OLAddClick"; | |
| break; | |
| default: | |
| break | |
| } | |
| var k; | |
| b = $("#grid .slick-row.selected", b); | |
| if ( b.length > 0 ) { | |
| h = ""; | |
| $(b).each(function() { | |
| k = parseInt($(this).attr("row"), 10); | |
| isNaN(k) || (h = h + (k + 1) + ",") | |
| }); | |
| h = h.slice(0, h.length - 1) | |
| } else h = "all"; | |
| this.logEvent(g, { | |
| songIDs: a, | |
| ranks: h | |
| }) | |
| }, | |
| songItemLibraryClick: function( a ) { | |
| this.logEvent("OLlibraryClick", a) | |
| }, | |
| songItemFavoriteClick: function( a ) { | |
| this.logEvent("OLfavoriteClick", a) | |
| }, | |
| songsRemovedFromQueue: function( a ) { | |
| var b = a.details.items; | |
| if ( a ) { | |
| var c = ""; | |
| _.forEach(b, function( g, h ) { | |
| c = c + h[g].songID + "," | |
| }, c); | |
| c = c.slice(0, c.length - 1); | |
| GS.getGuts().logEvent("songsRemovedFromQueue", { | |
| songIDs: c | |
| }) | |
| } | |
| }, | |
| handleSearchSidebarClick: function( a, b, c ) { | |
| if ( b = a.attr("href") ) { | |
| b = b.substr(0, b.indexOf("?")); | |
| var g = b.split("/"); | |
| b = g[1]; | |
| g = g[3]; | |
| $(a).attr("class") == "image" ? this.logEvent("searchSidebarClick", { | |
| section: c, | |
| linkType: b, | |
| id: g, | |
| imageClick: "true" | |
| }) : this.logEvent("searchSidebarClick", { | |
| section: c, | |
| linkType: b, | |
| id: g | |
| }) | |
| } else if ( a.hasClass("searchLink") ) { | |
| b = "seeAll"; | |
| this.logEvent("searchSidebarClick", { | |
| section: c, | |
| linkType: b | |
| }) | |
| } | |
| }, | |
| handleAutoplayOff: function() { | |
| this.logEvent("autoplayOff", {}); | |
| this.endContext("autoplay"); | |
| this.endContext("autoplaySeedSongs") | |
| }, | |
| isSearchPage: function() { | |
| var a = $("#page").controller(); | |
| if ( a ) return GS.Controllers.Page.SearchController == a.Class; | |
| return false | |
| }, | |
| onContextMenuClick: function( a, b, c, g, h ) { | |
| if ( a && b && typeof c !== "undefined" && g && this.isSearchPage() ) if ( c ) { | |
| if ( g && g.songIDs && g.ranks ) { | |
| var k = g.songIDs, | |
| m = g.ranks, | |
| p = g.ppVersions; | |
| c = {}; | |
| var n = k.length; | |
| if ((c = m.length == n) && p ) c = p.length == n; | |
| if ( c ) { | |
| c = { | |
| menuType: b, | |
| multiClick: "brokenDown" | |
| }; | |
| for ( var o = 0; o < n; o++ ) { | |
| var t = m[o], | |
| w = k[o]; | |
| if ( p ) c.ppVersions = g.ppVersions[o]; | |
| if ( h ) c.playlistID = h; | |
| this.logSearchSingleSongClick(a, t, w, c) | |
| } | |
| k = g.songIDs.join(); | |
| m = g.ranks.join(); | |
| c = { | |
| menuType: b, | |
| multiClick: "multi" | |
| }; | |
| if ( g.ppVersions ) c.ppVersions = g.ppVersions.join(); | |
| if ( h ) c.playlistID = h; | |
| this.logSearchMultiSongClick(a, m, k, c) | |
| } | |
| } | |
| } else if ( g && g.songID && g.rank ) { | |
| w = g.songID; | |
| t = g.rank; | |
| c = { | |
| menuType: b, | |
| multiClick: "single" | |
| }; | |
| if ( g.ppVersion ) c.ppVersion = g.ppVersion; | |
| if ( h ) c.playlistID = h; | |
| this.logSearchSingleSongClick(a, t, w, c) | |
| } | |
| }, | |
| logSearchSingleSongClick: function( a, b, c, g ) { | |
| if ( a && b && c ) { | |
| var h = {}; | |
| if ( g ) h = g; | |
| h.clickType = a; | |
| h.rank = b; | |
| h.songID = c; | |
| GS.getGuts().logEvent(this.searchClickLpid, h) | |
| } | |
| }, | |
| logSearchMultiSongClick: function( a, b, c, g ) { | |
| if ( a && b && c ) { | |
| var h = {}; | |
| if ( g ) h = g; | |
| h.clickType = a; | |
| h.ranks = b; | |
| h.songIDs = c; | |
| GS.getGuts().logEvent(this.searchClickLpid, h) | |
| } | |
| }, | |
| extractSongItemInfo: function( a ) { | |
| if ( a ) { | |
| var b = a.grid.getSelectedRows(), | |
| c = "", | |
| g = ""; | |
| c = ""; | |
| g = {}; | |
| if ( b.length == 1 ) { | |
| c = b[0]; | |
| g = a.selectedRowIDs[0]; | |
| g = { | |
| rank: c + 1, | |
| songID: g | |
| }; | |
| if ( a.data[c] ) if ( c = a.data[c].ppVersion ) g.ppVersion = c; | |
| return g | |
| } | |
| } else return null | |
| }, | |
| logMultiSongDrag: function( a, b ) { | |
| if ( b.songIDs && b.songIDs.length > 0 && b.ranks && b.ranks.length > 0 ) { | |
| var c, g = b.songIDs.length; | |
| for ( c = 0; c < g; c++ ) | |
| b.ppVersions && b.ppVersions[c] ? this.logSearchSingleSongClick("drag", b.ranks[c], b.songIDs[c], { | |
| ppVersion: b.ppVersions[c] | |
| }) : this.logSearchSingleSongClick("drag", b.ranks[c], b.songIDs[c]) | |
| } | |
| GS.getGuts().logEvent(a, b) | |
| }, | |
| extractMultiSongInfo: function( a, b ) { | |
| if ( a && b ) { | |
| var c = a.grid.getSelectedRows().sort(_.numSortA), | |
| g = [], | |
| h = []; | |
| _.forEach(c, function( k ) { | |
| g.push(k + 1); | |
| (k = a.dataView.rows[k].ppVersion) && h.push(k) | |
| }); | |
| c = { | |
| songIDs: b, | |
| ranks: g | |
| }; | |
| if ( h.length > 0 ) c.ppVersions = h; | |
| return c | |
| } else return null | |
| }, | |
| handleExtrasDeviceButtonClick: function( a ) { | |
| this.logEvent("extrasDeviceButtonClick", { | |
| device: $(a).attr("rel").split("_")[2] | |
| }) | |
| }, | |
| logQueueSaveInitiated: function() { | |
| this.logEvent("queueSaveInitiated", {}) | |
| }, | |
| pageParamsAreDifferent: function( a ) { | |
| if (!this.context.currentPageType || !this.context.currentSubpage || !this.context.currentPageID ) return true; | |
| if ( a && a.destinationPageType && a.destinationSubpageType && a.destinationPageID ) { | |
| if ( this.context.currentPageType != a.destinationPageType ) return true; | |
| if ( this.context.currentSubpage != a.destinationSubpageType ) return true; | |
| if ( this.context.currentPageID != a.destinationPageID ) return true; | |
| return false | |
| } else return true | |
| }, | |
| artistPageSidebarClick: function( a, b, c ) { | |
| b = {}; | |
| b.section = c; | |
| if ( a.hasClass("view_more") ) b.linkType = "seeAll"; | |
| else { | |
| b.linkType = "notSeeAll"; | |
| if ( a = a.attr("href") ) { | |
| var g = a.split("/"); | |
| switch ( c ) { | |
| case "similarArtists": | |
| b.linkType = "artist"; | |
| b.id = g[3]; | |
| break; | |
| case "fans": | |
| b.linkType = "user"; | |
| b.id = g[3]; | |
| break; | |
| case "events": | |
| b.linkType = "event"; | |
| b.href = a; | |
| break; | |
| default: | |
| break | |
| } | |
| } | |
| } | |
| this.logEvent("artistPageSidebarClick", b) | |
| }, | |
| gaTrackEvent: function( a, b, c, g ) { | |
| if ( _.notDefined(a) || _.notDefined(b) ) console.warn("guts.gaTrackEvent: bad category or action", a, b); | |
| else { | |
| c = "" + _.orEqual(c, ""); | |
| g = parseFloat("" + _.orEqual(g, ""), 10); | |
| if ( isNaN(g) || g == "" ) g = null; | |
| if ( window._gaq && window._gaq.push ) if ( c && g ) window._gaq.push(["_trackEvent", a, b, c, g]); | |
| else if ( c ) window._gaq.push(["_trackEvent", a, b, c]); | |
| else g ? window._gaq.push(["_trackEvent", a, b, null, g]) : window._gaq.push(["_trackEvent", a, b]) | |
| } | |
| } | |
| }); | |
| (function() { | |
| GS.Controllers.BaseController.extend("GS.Controllers.FacebookController", { | |
| isGSSingleton: true, | |
| preSetup: function() { | |
| var a = GS.Controllers.BaseController.singletonCallback, | |
| b = $.subscribe; | |
| b("gs.auth.update", a("facebook", "update")); | |
| b("gs.auth.favorites.songs.add", a("facebook", "onFavoriteSong")); | |
| b("gs.auth.playlists.add", a("facebook", "onPlaylistCreate")); | |
| b("gs.player.nowplaying", a("facebook", "onNowPlaying")); | |
| b("gs.player.playing.continue", a("facebook", "onSongPlaying")); | |
| b("gs.player.playstatus", a("facebook", "onPlayStatusChange")); | |
| b("gs.theme.set", a("facebook", "parseTheme")) | |
| } | |
| }, { | |
| APPLICATION_ID: "111132365592157", | |
| SERVICE_ID: 4, | |
| FACEBOOK_ONLY_SERVICE_ID: 16, | |
| PERMISSIONS: "offline_access,publish_stream,email,rsvp_event,read_stream,user_about_me,user_likes,user_interests,user_location,user_birthday,publish_actions,user_actions:grooveshark", | |
| REQUIRED_PERMISSIONS: "offline_access,publish_stream,email,user_about_me,user_location,user_birthday", | |
| PUBLISH_PERMISSION: "publish_stream", | |
| USER_ACTIONS: "user_actions", | |
| WALL_FAVORITES: 8, | |
| WALL_PLAYLIST_CREATE: 16, | |
| SCROBBLING_FLAG: 32, | |
| AUTO_RATE_LIMIT: 18E6, | |
| MINIMUM_DURATION: 15, | |
| profile: null, | |
| friends: null, | |
| registeredWithFacebook: false, | |
| facebookUserID: false, | |
| loggedIntoFacebook: false, | |
| flags: 0, | |
| lastError: null, | |
| facebookLoaded: false, | |
| connectStatus: "unknown", | |
| connected: false, | |
| onLoginSaveData: null, | |
| initialXFBML: null, | |
| onUpdateCallback: null, | |
| lastUser: null, | |
| friendPermissions: {}, | |
| userPermissions: {}, | |
| forceLogin: false, | |
| subXFBML: null, | |
| scrobblingEnabled: false, | |
| currentListening: null, | |
| loginOnLoad: null, | |
| init: function() { | |
| this.LISTEN_APPLICATION_ID = "111132365592157"; | |
| if ( window.location.host.indexOf("grooveshark.com") > -1 && this.APPLICATION_ID !== this.LISTEN_APPLICATION_ID || !this.APPLICATION_ID ) this.APPLICATION_ID = this.LISTEN_APPLICATION_ID; | |
| this._super() | |
| }, | |
| appReady: function() { | |
| this.subscribe("gs.cowbell.ready", this.callback("commReady")) | |
| }, | |
| commReady: function() { | |
| if ( _.browserDetect().browser != "msie" || _.browserDetect().version > 6 ) { | |
| var a = 0; | |
| window.fbAsyncInit = function() { | |
| if ( window.GS && GS.getFacebook ) GS.getFacebook().initFacebook(); | |
| else if ( a < 10 ) { | |
| a++; | |
| setTimeout(window.fbAsyncInit, 100) | |
| } else return false | |
| }; | |
| window.fbLoadAttempts = 0; | |
| window.loadFacebook = function() { | |
| try { | |
| if ( document.getElementById("fb-root") && document.getElementById("fb-root").getElementsByTagName("script").length ) { | |
| document.getElementById("fb-root").removeChild(document.getElementById("fb-root").getElementsByTagName("script")[0]); | |
| document.getElementById("fb-root") && document.getElementById("fb-root").getElementsByTagName("div").length && document.getElementById("fb-root").removeChild(document.getElementById("fb-root").getElementsByTagName("div")[0]); | |
| window.FB = null; | |
| GS.getFacebook().facebookloaded = false | |
| } | |
| var b = document.createElement("script"); | |
| b.async = true; | |
| b.src = document.location.protocol + "//connect.facebook.net/en_US/all.js"; | |
| document.getElementById("fb-root").appendChild(b); | |
| window.fbLoadAttempts++; | |
| window.facebookLoadTimeout = setTimeout(function() { | |
| if ((!window.FB || !GS.getFacebook().facebookloaded) && window.fbLoadAttempts < 3 ) window.loadFacebook(); | |
| else!window.FB && window.fbLoadAttempts >= 3 && $.publish("gs.notification", { | |
| type: "error", | |
| message: $.localize.getString("POPUP_UNABLE_LOAD_FACEBOOK") | |
| }) | |
| }, 2E4) | |
| } catch (c) { | |
| console.error("Could not load Facebook Connect JS. Fatal Error: ", c); | |
| GS.getFacebook().lastError = c; | |
| $.publish("gs.notification", { | |
| type: "error", | |
| message: $.localize.getString("POPUP_UNABLE_LOAD_FACEBOOK") | |
| }) | |
| } | |
| }; | |
| window.loadFacebook() | |
| } | |
| }, | |
| initFacebook: function() { | |
| if ( window.FB && window.FB.init ) { | |
| FB.init({ | |
| appId: this.APPLICATION_ID, | |
| status: false, | |
| cookie: false, | |
| xfbml: false, | |
| oauth: true | |
| }); | |
| this.facebookLoaded = true; | |
| window.facebookLoadTimeout && clearTimeout(window.facebookLoadTimeout); | |
| var a = _.browserDetect(); | |
| if ( a.browser == "chrome" && a.version < 15 ) { | |
| FB.XD._origin = window.location.protocol + "//" + document.domain + "/" + FB.guid(); | |
| FB.XD.Flash.init(); | |
| FB.XD._transport = "flash" | |
| } else if ( a.browser == "opera" ) { | |
| FB.XD._transport = "fragment"; | |
| FB.XD.Fragment._channelUrl = window.location.protocol + "//" + window.location.host + "/" | |
| } else if ( a.browser == "msie" && a.version == 8 ) { | |
| FB.XD._origin = window.location.protocol + "//" + document.domain + "/" + FB.guid(); | |
| FB.XD.Flash.init(); | |
| FB.XD._transport = "flash" | |
| } | |
| FB.getLoginStatus(this.callback(this.onFacebookLoginStatus, true)); | |
| FB.Event.subscribe("auth.statusChange", this.callback(this.onFacebookLoginStatus, false)); | |
| FB.Event.subscribe("edge.create", function( b ) { | |
| window._gaq && window._gaq.push && window._gaq.push(["_trackSocial", "facebook", "like", b]); | |
| if ( GS.page && GS.page.activePage && GS.page.activePage.likeWidth == "48px" ) { | |
| GS.page.activePage.likeWidth = "77px"; | |
| GS.page.activePage.likeWidthCache[GS.page.activePage.fbUrl] = "77px"; | |
| $("#page_content_social_buttons .fblike").css("width", GS.page.activePage.likeWidth) | |
| } | |
| }); | |
| FB.Event.subscribe("edge.remove", function( b ) { | |
| window._gaq && window._gaq.push && window._gaq.push(["_trackSocial", "facebook", "unlike", b]) | |
| }); | |
| if (!window.document.getElementById("theme_home") || window.location.hash && window.location.hash.indexOf("/s/") > -1 ) { | |
| $.publish("gs.facebook.xfbml.ready", true); | |
| GS.getFacebook().initialXFBML = true; | |
| this.subXFBML = $.subscribe("gs.facebook.xfbml.ready", this.callback(this.parseTheme)) | |
| } else this.parseTheme(); | |
| setTimeout(this.callback(function() { | |
| if ( FB.Auth._loadState == "loading" ) { | |
| FB.Auth._loadState = null; | |
| FB.getLoginStatus(this.callback(this.onFacebookLoginStatus, true)); | |
| this.update() | |
| } | |
| }), 1E4); | |
| this.loginOnLoad ? this.login(this.loginOnLoad.callback, this.loginOnLoad.errback, this.loginOnLoad.flags) : this.update() | |
| } | |
| }, | |
| parseTheme: function() { | |
| if ( window.FB ) window.document.getElementById("theme_home") && FB.XFBML.parse(window.document.getElementById("theme_home"), this.callback(function() { | |
| this.subXFBML && $.unsubscribe(this.subXFBML); | |
| setTimeout(function() { | |
| $.publish("gs.facebook.xfbml.ready") | |
| }, 100); | |
| GS.getFacebook().initialXFBML = true | |
| })); | |
| else this.initFacebook() | |
| }, | |
| update: function() { | |
| if ( this.facebookLoaded && GS.user && GS.user.isLoggedIn && GS.user.UserID > 0 && (GS.user.Flags & this.SERVICE_ID || GS.user.Flags & this.FACEBOOK_ONLY_SERVICE_ID) ) { | |
| this.registeredWithFacebook = GS.user.Flags & this.FACEBOOK_ONLY_SERVICE_ID; | |
| GS.service.getUserFacebookData(this.callback("onUserFacebookData", null, null)) | |
| } else if ( this.facebookLoaded ) GS.user && GS.user.isLoggedIn && this.onLoginSaveData && this.onLoginSaveData === GS.user.Email ? this.save(0, null, this.callback(function( a ) { | |
| this.lastError = a; | |
| $.publish("gs.notification", { | |
| type: "error", | |
| message: $.localize.getString("POPUP_UNABLE_SAVE_FACEBOOK") | |
| }); | |
| GS.getLightbox().open("reAuthFacebook") | |
| })) : this.clearInfo() | |
| }, | |
| cleanSession: function( a ) { | |
| if ( a.accessToken.indexOf("|") >= 0 ) { | |
| a = a.accessToken.split("|"); | |
| var b = a[1].split("-"), | |
| c = {}; | |
| c.facebookUserID = b[1]; | |
| c.sessionKey = b[0]; | |
| c.accessToken1 = a[0]; | |
| c.accessToken3 = a[2]; | |
| return c | |
| } else return false | |
| }, | |
| onFacebookLoginStatus: function( a, b ) { | |
| if ( b ) { | |
| this.connectStatus = b.status; | |
| switch ( this.connectStatus ) { | |
| case "connected": | |
| this.loggedIntoFacebook = true; | |
| break; | |
| case "notConnected": | |
| this.loggedIntoFacebook = true; | |
| break; | |
| case "unknown": | |
| default: | |
| if (!a && GS.airbridge && GS.airbridge.isDesktop && GS.user && GS.user.isLoggedIn && (GS.user.Flags & this.SERVICE_ID || GS.user.Flags & this.FACEBOOK_ONLY_SERVICE_ID) ) { | |
| this.connectStatus = "connected"; | |
| GS.service.getUserFacebookData(this.callback("onUserFacebookData", null, null)) | |
| } else this.loggedIntoFacebook = false; | |
| break | |
| } | |
| var c = this.connected; | |
| this.connected = this.loggedIntoFacebook && b.authResponse && b.authResponse.userID ? b.authResponse.userID == this.facebookUserID : false; | |
| if (!a ) if (!this.connected && c && (!GS.airbridge || !GS.airbridge.isDesktop) ) { | |
| c = | |
| this.facebookUserID; | |
| this.clearInfo(); | |
| this.connected = false; | |
| this.facebookUserID = c; | |
| FB.api("/?id=" + this.facebookUserID, this.callback("onGetMyProfile", null, null)); | |
| $.publish("gs.notification", { | |
| type: "error", | |
| message: $.localize.getString("POPUP_LOGOUT_FACEBOOK") | |
| }) | |
| } | |
| $.publish("gs.facebook.status.update"); | |
| if ( $.isFunction(this.onUpdateCallback) ) { | |
| this.onUpdateCallback(); | |
| this.onUpdateCallback = null | |
| } | |
| } | |
| }, | |
| onUserFacebookData: function( a, b, c ) { | |
| try { | |
| if ( window.FB && c && c.FacebookUserID ) { | |
| var g = c.AccessToken1 ? c.AccessToken1 + "|" + c.SessionKey + "-" + c.FacebookUserID + "|" + c.AccessToken3 : c.AccessTokenEx; | |
| this.facebookUserID = c.FacebookUserID; | |
| this.flags = c.Flags; | |
| if ((this.flags & this.SCROBBLING_FLAG) > 0 ) this.scrobblingEnabled = true; | |
| var h = FB.getAuthResponse(); | |
| if ( GS.airbridge && GS.airbridge.isDesktop && (!h || !h.accessToken) ) FB.Auth.setAuthResponse({ | |
| accessToken: g, | |
| expiresIn: 0, | |
| signedRequest: "", | |
| userID: c.FacebookUserID | |
| }, "connected"); | |
| if ( h && h.userID && h.userID == this.facebookUserID ) { | |
| h.accessToken != g && this.save(c.Flags); | |
| this.connected = true; | |
| FB.api("/me", this.callback("onGetMyProfile", a, b)) | |
| } else FB.api("/?id=" + this.facebookUserID, this.callback("onGetMyProfile", a, b)); | |
| this.onUpdateCallback = this.callback(function() { | |
| if (!this.connected && this.flags >= 8 ) $.publish("gs.facebook.notification.cannotPost"); | |
| else this.flags >= 8 && this.checkUserPermissions(this.PUBLISH_PERMISSION, this.callback(function( m ) { | |
| if ( m )(this.flags & this.SCROBBLING_FLAG) > 0 && this.checkUserPermissions(this.USER_ACTIONS, this.callback(function( p ) { | |
| p || $.publish("gs.facebook.notification.cannotPost", { | |
| notifLocale: "POPUP_LOGIN_FACEBOOK_FLAGS_LISTEN_PERMS" | |
| }) | |
| }), function() { | |
| $.publish("gs.facebook.notification.cannotPost", { | |
| notifLocale: "POPUP_LOGIN_FACEBOOK_FLAGS_LISTEN" | |
| }) | |
| }); | |
| else $.publish("gs.facebook.notification.cannotPost", { | |
| notifLocale: "POPUP_LOGIN_FACEBOOK_FLAGS_PERMS" | |
| }) | |
| }), function() { | |
| $.publish("gs.facebook.notification.cannotPost") | |
| }) | |
| }); | |
| FB.getLoginStatus(this.callback(this.onFacebookLoginStatus, false)) | |
| } else { | |
| GS.user.Flags = (GS.user.Flags | this.SERVICE_ID) - this.SERVICE_ID; | |
| if ( this.registeredWithFacebook ) GS.user.Flags = (GS.user.Flags | this.FACEBOOK_ONLY_SERVICE_ID) - this.FACEBOOK_ONLY_SERVICE_ID; | |
| this.connected = false; | |
| $.isFunction(b) && b() | |
| } | |
| } catch (k) { | |
| this.connected = false; | |
| $.isFunction(b) && b() | |
| } | |
| }, | |
| onAuthFacebookUser: function( a, b, c ) { | |
| if ( c ) if ( c.userID == 0 ) this.register(a, b); | |
| else { | |
| this.connected = this.loggedIntoFacebook; | |
| $.isFunction(a) && a(c); | |
| GS.getGuts().logEvent("facebookAuthenticated", { | |
| authenticated: true | |
| }) | |
| } | |
| else $.isFunction(b) && b({ | |
| error: "POPUP_SIGNUP_LOGIN_FORM_FACEBOOK_ERROR" | |
| }) | |
| }, | |
| showReAuthLightbox: function() { | |
| GS.getLightbox().close(); | |
| GS.getLightbox().open({ | |
| type: "reAuthFacebook", | |
| view: { | |
| header: "POPUP_FACEBOOK_REAUTH_TITLE", | |
| message: "POPUP_FACEBOOK_REAUTH_MESSAGE", | |
| buttonsRight: [{ | |
| label: "POPUP_REAUTH_SUBMIT", | |
| className: "submit" | |
| }], | |
| buttonsLeft: GS.getFacebook().registeredWithFacebook ? [] : [{ | |
| label: "POPUP_FACEBOOK_REAUTH_CANCEL", | |
| className: "close" | |
| }] | |
| }, | |
| callbacks: { | |
| ".submit": function() { | |
| var a = GS.getFacebook().flags; | |
| GS.getFacebook().logout(function() { | |
| GS.getFacebook().login(function() { | |
| GS.getLightbox().close() | |
| }, null, a) | |
| }) | |
| }, | |
| ".close": function() { | |
| GS.getFacebook().logout(function() { | |
| GS.getLightbox().close() | |
| }) | |
| } | |
| } | |
| }) | |
| }, | |
| showInvalidPermissionsLightbox: function( a ) { | |
| if ( $.isFunction(a) ) { | |
| GS.getLightbox().close(); | |
| GS.getLightbox().open({ | |
| type: "invalidPermissionsFacebook", | |
| view: { | |
| header: "POPUP_FACEBOOK_PERMS_TITLE", | |
| message: "POPUP_FACEBOOK_PERMS_MESSAGE", | |
| buttonsRight: [{ | |
| label: "POPUP_REAUTH_AUTH_SUBMIT", | |
| className: "submit" | |
| }], | |
| buttonsLeft: [{ | |
| label: "POPUP_FACEBOOK_PERMS_CANCEL", | |
| className: "close" | |
| }] | |
| }, | |
| callbacks: { | |
| ".submit": function() { | |
| a() | |
| }, | |
| ".close": function() { | |
| GS.getFacebook().logout(function() { | |
| GS.getLightbox().close() | |
| }) | |
| } | |
| } | |
| }) | |
| } | |
| }, | |
| authErrors: [608, 450, 451, 452, 453, 454, 455, 200, 190, 10], | |
| queryFQL: function( a, b, c, g ) { | |
| FB.api({ | |
| method: "fql.query", | |
| query: a | |
| }, this.callback(function( h ) { | |
| if ( h.error_code ) { | |
| if ( $.isFunction(c) ) c(h); | |
| else g && $.inArray(h.error_code, this.authErrors) && this.showReAuthLightbox(); | |
| g && GS.getGuts().forceLogEvent("facebookFQLErr", { | |
| errCode: h.error_code | |
| }) | |
| } else $.isFunction(b) && b(h) | |
| })) | |
| }, | |
| register: function( a, b ) { | |
| if ( window.FB && FB.getAuthResponse() && FB.getAuthResponse().userID ) this.queryFQL("select uid,name,first_name,last_name,profile_url,username,about_me,birthday_date,sex,email,locale from user where uid = me()", function( c ) { | |
| if ( c && c[0] ) { | |
| var g = { | |
| id: c[0].uid, | |
| name: c[0].name, | |
| first_name: c[0].first_name, | |
| last_name: c[0].last_name, | |
| link: c[0].profile_url, | |
| birthday: c[0].birthday_date, | |
| about: c[0].profile_blurb, | |
| gender: c[0].sex, | |
| email: c[0].email, | |
| locale: c[0].locale | |
| }; | |
| GS.getFacebook().gotProfileForRegister(a, b, c[0].username ? c[0].username : "", g) | |
| } else GS.getFacebook().gotProfileForRegister(a, b) | |
| }, function() { | |
| var c = FB.getAccessToken(); | |
| FB.getLoginStatus(GS.getFacebook().callback(function( g ) { | |
| if (!g.authResponse || g.authResponse.accessToken != c ) { | |
| this.onFacebookLoginStatus(false, g); | |
| this.login(a, b) | |
| } | |
| }), true) | |
| }, true); | |
| else $.isFunction(b) && b({ | |
| error: "POPUP_SIGNUP_LOGIN_FORM_FACEBOOK_ERROR" | |
| }) | |
| }, | |
| gotProfileForRegister: function( a, b, c, g ) { | |
| if ( g && !g.error ) GS.service.getUsernameSuggestions(c, g.name ? g.name : "", g.id, this.callback("usernameSuggestSuccess", a, b, g), this.callback("usernameSuggestFailed", a, b, g)); | |
| else b && b({ | |
| error: "POPUP_SIGNUP_LOGIN_FORM_FACEBOOK_ERROR" | |
| }) | |
| }, | |
| usernameSuggestSuccess: function( a, b, c, g ) { | |
| b = ""; | |
| if ( g && g.length > 0 ) b = g[0]; | |
| this.openRegisterLightbox(a, b, c) | |
| }, | |
| usernameSuggestFailed: function( a, b, c ) { | |
| a && b ? b({ | |
| error: "POPUP_SIGNUP_LOGIN_FORM_FACEBOOK_ERROR" | |
| }) : this.openRegisterLightbox(null, "", c) | |
| }, | |
| openRegisterLightbox: function( a, b, c ) { | |
| a = { | |
| isFacebook: !_.isEmpty(c), | |
| username: b, | |
| session: this.cleanSession(FB.getAuthResponse()), | |
| fbFlags: 0, | |
| message: $.localize.getString("POPUP_SIGNUP_LOGIN_FORM_FACEBOOK_NOT_FOUND") | |
| }; | |
| if (!a.session ) { | |
| b = FB.getAuthResponse(); | |
| a.session = { | |
| facebookUserID: b.userID, | |
| accessTokenEx: b.accessToken | |
| } | |
| } | |
| if ( c ) { | |
| if ( c.birthday ) { | |
| b = c.birthday.split("/"); | |
| a.month = | |
| b[0]; | |
| a.day = b[1]; | |
| a.year = parseInt(b[2]) | |
| } | |
| a.fname = c.name ? c.name : ""; | |
| if ( c.gender == "female" ) a.sex = "F"; | |
| else if ( c.gender == "male" ) a.sex = "M"; | |
| a.email = c.email ? c.email : "" | |
| } | |
| GS.user.defaultFromService = a; | |
| GS.getLightbox().close(); | |
| if ( GS.page.activePageName == "signup" ) GS.page.activePage.update(a); | |
| else location.hash = "#/signup"; | |
| GS.getGuts().logEvent("facebookRegistered", { | |
| registered: true | |
| }) | |
| }, | |
| login: function( a, b, c ) { | |
| if ( window.FB && window.FB.login ) if ( GS.airbridge && GS.airbridge.isDesktop ) this.connectStatus == "connected" && !this.forceLogin ? FB.getLoginStatus(this.callback("onAIRLogin", a, b, c)) : FB.login(this.callback("onAIRLogin", a, b, c), { | |
| scope: this.PERMISSIONS | |
| }); | |
| else this.connectStatus == "connected" && !this.forceLogin ? FB.getLoginStatus(this.callback("onLogin", a, b, c)) : FB.login(this.callback("onLogin", a, b, c), { | |
| scope: this.PERMISSIONS | |
| }); | |
| else if ( this.facebookLoaded ) b && b({ | |
| error: "POPUP_SIGNUP_LOGIN_FORM_FACEBOOK_ERROR" | |
| }); | |
| else this.loginOnLoad = { | |
| callback: a, | |
| errback: b, | |
| flags: c | |
| } | |
| }, | |
| onAIRLogin: function( a, b, c ) { | |
| window.setTimeout(function() { | |
| GS.getFacebook().onLogin(a, b, flags, c) | |
| }, 300) | |
| }, | |
| onLogin: function( a, b, c, g ) { | |
| g.authResponse && this.checkUserPermissions(this.REQUIRED_PERMISSIONS, this.callback(function( h ) { | |
| if ( h ) if ( GS.user.isLoggedIn ) { | |
| if (!this.connected && this.facebookUserID && this.facebookUserID != g.authResponse.userID ) this.friends = this.profile = null; | |
| this.save(c ? c : 0, a, b) | |
| } else(h = this.cleanSession(g.authResponse)) ? GS.service.authenticateFacebookUser(h.facebookUserID, h.sessionKey, h.accessToken1, h.accessToken3, null, this.callback("onAuthFacebookUser", a, b), function() { | |
| $.isFunction(b) && b({ | |
| error: "POPUP_SIGNUP_LOGIN_FORM_FACEBOOK_ERROR" | |
| }) | |
| }) : GS.service.authenticateFacebookUser(g.authResponse.userID, "", "", "", g.authResponse.accessToken, this.callback("onAuthFacebookUser", a, b), function() { | |
| $.isFunction(b) && b({ | |
| error: "POPUP_SIGNUP_LOGIN_FORM_FACEBOOK_ERROR" | |
| }) | |
| }); | |
| else GS.getFacebook().showInvalidPermissionsLightbox(GS.getFacebook().callback(function() { | |
| GS.airbridge && GS.airbridge.isDesktop ? FB.login(this.callback("onAIRLogin", a, b, c), { | |
| scope: this.REQUIRED_PERMISSIONS | |
| }) : FB.login(this.callback("onLogin", a, b, c), { | |
| scope: this.REQUIRED_PERMISSIONS | |
| }) | |
| })) | |
| }), function() { | |
| $.isFunction(b) && b({ | |
| error: "POPUP_SIGNUP_LOGIN_FORM_FACEBOOK_ERROR" | |
| }); | |
| FB.getLoginStatus(GS.getFacebook().callback("onFacebookLoginStatus", false), true) | |
| }) | |
| }, | |
| save: function( a, b, c ) { | |
| if ( window.FB && FB.getAccessToken() && GS.user.isLoggedIn ) { | |
| var g = FB.getAuthResponse(), | |
| h = this.cleanSession(g); | |
| if ( GS.user.Flags & this.SERVICE_ID || GS.user.Flags & this.FACEBOOK_ONLY_SERVICE_ID ) h ? GS.service.updateUserFacebookData(h.facebookUserID, h.sessionKey, h.accessToken1, h.accessToken3, a ? a : 0, null, this.callback("onSaveUserFacebookData", b, c), c) : GS.service.updateUserFacebookData(g.userID, "", "", "", a ? a : 0, g.accessToken, this.callback("onSaveUserFacebookData", b, c), c); | |
| else h ? GS.service.saveUserFacebookData(h.facebookUserID, h.sessionKey, h.accessToken1, h.accessToken3, a ? a : 0, null, this.callback("onSaveUserFacebookData", b, c), c) : GS.service.saveUserFacebookData(g.userID, "", "", "", a ? a : 0, g.accessToken, this.callback("onSaveUserFacebookData", b, c), c); | |
| this.flags = a | |
| } | |
| }, | |
| onSaveUserFacebookData: function( a, b, c ) { | |
| if ( c == 1 && window.FB ) { | |
| this.facebookUserID = FB.getAuthResponse().userID; | |
| this.connected = true; | |
| FB.api("/me", this.callback("onGetMyProfile", a, b)); | |
| if (!(GS.user.Flags & this.SERVICE_ID) && !(GS.user.Flags & this.FACEBOOK_ONLY_SERVICE_ID) && this.lastUser !== GS.user.UserID ) { | |
| GS.getLightbox().open("newFacebookUser"); | |
| GS.getGuts().logEvent("facebookNewSave", { | |
| newSave: true | |
| }) | |
| } | |
| if ((this.flags & this.SCROBBLING_FLAG) > 0 ) this.scrobblingEnabled = true; | |
| GS.user.Flags |= this.SERVICE_ID | |
| } else if ( c == -1 ) if ( GS.user.Flags & this.SERVICE_ID || GS.user.Flags & this.FACEBOOK_ONLY_SERVICE_ID ) GS.service.getUserFacebookData(this.callback("onUserFacebookData", a, function() { | |
| b("FACEBOOK_PROBLEM_CONNECTING_ERROR_MSG") | |
| }), function() { | |
| b("FACEBOOK_PROBLEM_CONNECTING_ERROR_MSG") | |
| }); | |
| else b && b({ | |
| error: "FACEBOOK_DUPLICATE_ACCOUNT_ERROR_MSG" | |
| }); | |
| else b && b({ | |
| error: "POPUP_SIGNUP_LOGIN_FORM_FACEBOOK_ERROR" | |
| }) | |
| }, | |
| onGetMyProfile: function( a, b, c ) { | |
| if ( c && c.id ) { | |
| this.profile = c; | |
| $.publish("gs.facebook.profile.update"); | |
| a && a() | |
| } else { | |
| this.connected = false; | |
| this.lastError = c; | |
| GS.user && GS.user.isLoggedIn && c.error && c.error.type == "OAuthException" && this.APPLICATION_ID == this.LISTEN_APPLICATION_ID && this.showReAuthLightbox(); | |
| b && b() | |
| } | |
| }, | |
| logout: function( a ) { | |
| if ( GS.user.isLoggedIn ) this.profile && this.profile.id ? GS.service.removeUserFacebookData(this.profile.id, this.callback("onLogout", a)) : GS.service.removeUserFacebookData(false, this.callback("onLogout", a)); | |
| else { | |
| this.clearInfo(); | |
| $.isFunction(a) && a() | |
| } | |
| }, | |
| onLogout: function( a ) { | |
| if (!this.registeredWithFacebook ) { | |
| GS.user.Flags = (GS.user.Flags | this.SERVICE_ID) - this.SERVICE_ID; | |
| this.lastUser = GS.user.UserID | |
| } | |
| this.clearInfo(a); | |
| this.forceLogin = true | |
| }, | |
| clearInfo: function( a ) { | |
| this.profile = {}; | |
| this.friends = null; | |
| this.friendPermissions = {}; | |
| this.userPermissions = {}; | |
| this.registeredWithFacebook = this.connected = false; | |
| this.onLoginSaveData = this.loginOnLoad = null; | |
| this.facebookUserID = false; | |
| this.flags = 0; | |
| this.scrobblingEnabled = false; | |
| this.onUpdateCallback = a; | |
| FB.getLoginStatus(this.callback("onFacebookLoginStatus", false), true); | |
| $.isFunction(this.onUpdateCallback) && setTimeout(this.callback(function() { | |
| if ( $.isFunction(this.onUpdateCallback) ) { | |
| this.onUpdateCallback(); | |
| this.onUpdateCallback = null | |
| } | |
| }), 1E4); | |
| $.publish("gs.facebook.profile.update") | |
| }, | |
| onFavoriteSong: function( a, b, c ) { | |
| if ( this.connected && (c || (this.flags & this.WALL_FAVORITES) > 0) ) { | |
| var g = this.callback(function() { | |
| $.isFunction(a.toUrl) ? this.postLink("me", "http://grooveshark.com" + a.toUrl().substr(1), b, "song", c ? "notif" : "auto", this.callback("initiateRateLimit"), this.callback("onFailedPostEvent"), !c, a) : GS.Models.Song.getSong(_.orEqualEx(a.SongID, a.songID, a), this.callback(function( h ) { | |
| if ( $.isFunction(h.toUrl) ) this.postLink("me", "http://grooveshark.com" + h.toUrl().substr(1), b, "song", c ? "notif" : "auto", this.callback("initiateRateLimit"), this.callback("onFailedPostEvent"), !c, h) | |
| }), this.onFailedPostEvent) | |
| }); | |
| this.autoRateLimited && !c ? setTimeout(function() { | |
| $.publish("gs.facebook.notification.rateLimited", { | |
| callback: g, | |
| type: "song" | |
| }) | |
| }, 300) : g() | |
| } | |
| }, | |
| onPlaylistCreate: function( a, b, c ) { | |
| if ( this.connected && (c || (this.flags & this.WALL_PLAYLIST_CREATE) > 0) ) { | |
| var g = this.callback(function() { | |
| this.postLink("me", "http://grooveshark.com" + a.toUrl().replace("#/", "/"), b, "playlist", c ? "notif" : "auto", this.callback("initiateRateLimit"), this.callback("onFailedPostEvent"), !c, a) | |
| }); | |
| this.autoRateLimited && !c ? setTimeout(function() { | |
| $.publish("gs.facebook.notification.rateLimited", { | |
| callback: g, | |
| type: "playlist" | |
| }) | |
| }, 300) : g() | |
| } | |
| }, | |
| onSubscribePlaylist: function( a, b ) { | |
| this.connected && this.postLink("me", "http://grooveshark.com" + a.toUrl().replace("#/", "/"), b, "playlist", "notif", this.callback("initiateRateLimit"), this.callback("onFailedPostEvent"), false, a) | |
| }, | |
| onFollowUser: function( a, b ) { | |
| this.connected && this.postLink("me", "http://grooveshark.com" + a.toUrl().substr(1), b, "user", "notif", this.callback("initiateRateLimit"), this.callback("onFailedPostEvent"), false, a) | |
| }, | |
| onFailedPostEvent: function() { | |
| $.publish("gs.facebook.notification.sent", { | |
| params: { | |
| type: "error", | |
| hideUndo: true | |
| }, | |
| data: {}, | |
| notifData: {} | |
| }) | |
| }, | |
| initiateRateLimit: function() { | |
| this.autoRateLimited && window.clearTimeout(this.autoRateLimited); | |
| this.autoRateLimited = setTimeout(this.callback(function() { | |
| this.autoRateLimited = null | |
| }), this.AUTO_RATE_LIMIT) | |
| }, | |
| postToFeed: function( a, b, c, g, h, k, m, p, n ) { | |
| a = _.orEqual(a, "me"); | |
| this.postToFacebook("/" + a + "/feed", a, b, c, g, h, k, m, false, n) | |
| }, | |
| postLink: function( a, b, c, g, h, k, m, p, n ) { | |
| a = _.orEqual(a, "me"); | |
| this.postToFacebook("/" + a + "/links", a, b, c, g, h, k, m, p, n) | |
| }, | |
| postToFacebook: function( a, b, c, g, h, k, m, p, n, o ) { | |
| if ( this.connected ) { | |
| var t = {}; | |
| t.link = c; | |
| t.message = g; | |
| t.access_token = FB.getAccessToken(); | |
| t.type = _.orEqual(h, "song"); | |
| t.ref = _.orEqual(k, ""); | |
| c = $.extend(t, { | |
| hideUndo: !n, | |
| object: o | |
| }); | |
| FB.api(a, "post", t, this.callback("onPostAPIReturn", c, a, b, m, p)) | |
| } else $.isFunction(p) && p("No facebook session.") | |
| }, | |
| onPostAPIReturn: function( a, b, c, g, h, k ) { | |
| k.error ? this.onFailedPost(b, h, k.error) : this.onFeedPost(a, g, c, k) | |
| }, | |
| onFeedPost: function( a, b, c, g ) { | |
| g.target = c; | |
| a.type && $.publish("gs.facebook.notification.sent", { | |
| params: a, | |
| data: g, | |
| notifData: {} | |
| }); | |
| b && b() | |
| }, | |
| onFailedPost: function( a, b, c ) { | |
| this.lastError = c; | |
| $.isFunction(b) && b(c); | |
| GS.getGuts().forceLogEvent("facebookShareErrMessage", { | |
| message: c.message, | |
| type: c.type | |
| }) | |
| }, | |
| removeEvent: function( a ) { | |
| if ( window.FB && this.connected && a && a.id ) { | |
| var b = (a.target == "me" ? FB.getAuthResponse().userID : a.user) + "_" + a.id; | |
| FB.api("/" + b + "?method=delete", this.callback("onRemoveEvent", a)) | |
| } | |
| }, | |
| onRemoveEvent: function( a, b ) { | |
| if ( b == true ) $.publish("gs.facebook.notification.removed", { | |
| data: b, | |
| params: a | |
| }); | |
| else { | |
| this.onFailedPost(null, null, b); | |
| $.publish("gs.notification", { | |
| type: "error", | |
| message: $.localize.getString("NOTIF_FACEBOOK_UNDO_FAILED") | |
| }) | |
| } | |
| }, | |
| onNowPlaying: function( a ) { | |
| if ( this.connected && this.scrobblingEnabled ) { | |
| if (!this.currentListening || a.queueSongID != this.currentListening.song.queueSongID || a.SongID != this.currentListening.song.SongID ) this.currentListening = { | |
| song: a, | |
| secondsListened: 0, | |
| id: null | |
| }; | |
| else if ( GS.player.repeatMode == GS.player.REPEAT_ONE && a.queueSongID == this.currentListening.song.queueSongID ) { | |
| this.currentListening.secondsListened = 0; | |
| if ( this.currentListening.id ) { | |
| this.deleteListen(this.currentListening.id, this.callback(function() { | |
| delete this.currentListening.id; | |
| this.postListen(this.currentListening.song, this.callback("onNowPlayingComplete")) | |
| })); | |
| return | |
| } | |
| } else return; | |
| a && this.postListen(a, this.callback("onNowPlayingComplete")) | |
| } | |
| }, | |
| onNowPlayingComplete: function( a, b ) { | |
| if (!b || !b.id ) this.onFailedPost("scrobble", function() { | |
| $.publish("gs.notification", { | |
| type: "error", | |
| message: $.localize.getString("POPUP_FAIL_LISTENS_FACEBOOK") | |
| }) | |
| }, b); | |
| else this.currentListening.id = b.id | |
| }, | |
| onSongPlaying: function( a ) { | |
| if ( this.connected && this.scrobblingEnabled ) { | |
| a = a.activeSong; | |
| if (!this.currentListening || a.queueSongID != this.currentListening.song.queueSongID || a.SongID != this.currentListening.song.SongID ) this.currentListening = { | |
| song: a, | |
| secondsListened: 0, | |
| id: null | |
| }; | |
| else this.currentListening.secondsListened += 0.5 | |
| } | |
| }, | |
| onPlayStatusChange: function( a ) { | |
| if ( this.connected && this.scrobblingEnabled && this.currentListening && this.currentListening.song ) switch ( a.status ) { | |
| case GS.player.PLAY_STATUS_FAILED: | |
| case GS.player.PLAY_STATUS_PAUSED: | |
| case GS.player.PLAY_STATUS_NONE: | |
| if ( this.currentListening.id && this.currentListening.secondsListened < this.MINIMUM_DURATION ) this.deleteListen(this.currentListening.id, this.callback(function() { | |
| delete this.currentListening.id | |
| })); | |
| else if ( this.currentListening.id ) { | |
| this.updateListenExpiresTime(this.currentListening.id, this.currentListening.secondsListened); | |
| this.currentListening.paused = true | |
| } | |
| break; | |
| case GS.player.PLAY_STATUS_PLAYING: | |
| if ( this.currentListening.id ) this.currentListening.id && this.currentListening.secondsListened >= this.MINIMUM_DURATION && this.currentListening.paused && this.deleteListen(this.currentListening.id, this.callback(function() { | |
| delete this.currentListening.id; | |
| this.postListen(this.currentListening.song, this.callback("onNowPlayingComplete")) | |
| })); | |
| else this.postListen(this.currentListening.song, this.callback("onNowPlayingComplete")); | |
| this.currentListening.paused = false; | |
| break | |
| } | |
| }, | |
| postListen: function( a, b ) { | |
| if (!(this.currentListening && this.currentListening.posting)) { | |
| if ( this.currentListening ) this.currentListening.posting = true; | |
| setTimeout(this.callback(function() { | |
| var c = {}; | |
| c.song = "http://grooveshark.com" + a.toUrl().replace("#/", "/") + "&fbRocks"; | |
| c.access_token = FB.getAccessToken(); | |
| if ( a.AlbumID && a.AlbumName ) c.album = "http://grooveshark.com" + _.cleanUrl(a.AlbumName, a.AlbumID, "album").replace("#/", "/") + "?fbRocks"; | |
| if ( a.ArtistID && a.ArtistName ) c.album = "http://grooveshark.com" + _.cleanUrl(a.ArtistName, a.ArtistID, "artist").replace("#/", "/") + "?fbRocks"; | |
| FB.api("/me/grooveshark:listen", "post", c, this.callback(function( g ) { | |
| $.isFunction(b) && b(a, g); | |
| delete this.currentListening.posting | |
| })) | |
| }), 50) | |
| } | |
| }, | |
| updateListenExpiresTime: function( a, b ) { | |
| FB.api("/" + a + "?expires_in=" + b, "post") | |
| }, | |
| deleteListen: function( a, b ) { | |
| FB.api("/" + a + "?method=delete", this.callback("onDeleteListen", b)) | |
| }, | |
| onDeleteListen: function( a, b ) { | |
| if ( b ) $.isFunction(a) && a(); | |
| else $.publish("gs.notification", { | |
| type: "error", | |
| message: $.localize.getString("POPUP_FAIL_LISTENS_FACEBOOK") | |
| }) | |
| }, | |
| getFriends: function( a ) { | |
| if ( this.friends ) a(this.friends); | |
| else if ( this.connected ) FB.api("me/friends", this.callback("onFacebookGetFriends", a)); | |
| else $.isFunction(a) && a(null) | |
| }, | |
| onFacebookGetFriends: function( a, b ) { | |
| if ( b.data ) { | |
| var c = []; | |
| $.each(b.data, function( g, h ) { | |
| c.push(h) | |
| }); | |
| c.sort(function( g, h ) { | |
| var k = (g.name || "").toLowerCase(), | |
| m = (h.name || "").toLowerCase(); | |
| if ( k < m ) return -1; | |
| else if ( k > m ) return 1; | |
| return 0 | |
| }); | |
| this.friends = c | |
| } else if ( b.error ) { | |
| this.lastError = | |
| b.error; | |
| $.publish("gs.notification", { | |
| type: "error", | |
| message: $.localize.getString("NOTIF_FACEBOOK_FINDFRIENDS_ERROR") | |
| }); | |
| $.isFunction(a) && a(null) | |
| } | |
| $.isFunction(a) && a(this.friends) | |
| }, | |
| canPostToFriend: function( a, b ) { | |
| (a = parseInt(a)) || $.isFunction(b) && b(false); | |
| if ( this.friendPermissions[a] && typeof this.friendPermissions[a].canPost != "undefined" ) $.isFunction(b) && b(this.friendPermissions[a].canPost); | |
| else this.queryFQL("select can_post FROM user WHERE uid = " + a, this.callback(function( c ) { | |
| if ( c[0] && c[0] ) { | |
| if ( this.friendPermissions[a] ) this.friendPermissions[a].canPost = c[0].can_post; | |
| else this.friendPermissions[a] = { | |
| canPost: c[0].can_post | |
| }; | |
| $.isFunction(b) && b(c[0].can_post) | |
| } | |
| }), function() {}, true) | |
| }, | |
| checkUserPermissions: function( a, b, c ) { | |
| if ( this.userPermissions ) if ( a.indexOf(",") > 0 ) { | |
| for ( var g = a.split(","), h = true, k = 0, m = g.length; k < m; k++ ) | |
| if (!this.userPermissions[g[k]] || this.userPermissions[g[k]] == "0" ) { | |
| h = false; | |
| break | |
| } | |
| if ( h ) if ( $.isFunction(b) ) { | |
| b(true); | |
| return | |
| } | |
| } else if ( this.userPermissions[a] && this.userPermissions[a] != "0" ) if ( $.isFunction(b) ) { | |
| b(true); | |
| return | |
| } | |
| this.queryFQL("SELECT " + a + " FROM permissions WHERE uid = me()", this.callback(function( p ) { | |
| if ( p && p[0] ) { | |
| $.extend(this.userPermissions, p[0]); | |
| for ( var n in p[0] ) | |
| if ( n && p[0].hasOwnProperty(n) ) if ( p[0][n] == "0" ) { | |
| $.isFunction(b) && b(false); | |
| return | |
| } | |
| $.isFunction(b) && b(true) | |
| } else $.isFunction(b) && b(false) | |
| }), c, true) | |
| }, | |
| getFacebookDetails: function( a, b ) { | |
| if ( a.toUrl ) { | |
| var c = "http://listen.grooveshark.com/" + a.toUrl().replace("#/", ""); | |
| GS.service.makeFacebookRequest("?ids=" + encodeURIComponent(c) + "&limit=100", null, "GET", function( g ) { | |
| try { | |
| if ( g ) { | |
| g = JSON.parse(g); | |
| _.forEach(g, function( k ) { | |
| b(k) | |
| }) | |
| } | |
| } catch (h) {} | |
| }) | |
| } | |
| }, | |
| getGroovesharkUsersFromFriends: function( a ) { | |
| this.getFriends(this.callback(function( b ) { | |
| if ( $.isArray(b) ) { | |
| var c = [], | |
| g = []; | |
| $.each(b, function( h, k ) { | |
| if ( k && k.id ) { | |
| c.push(k.id); | |
| g[k.id] = k.name | |
| } | |
| }); | |
| GS.service.getGroovesharkUsersFromFacebookUserIDs(c, this.callback("onGetGroovesharkUsers", g, a), function() { | |
| $.publish("gs.notification", { | |
| type: "error", | |
| message: $.localize.getString("NOTIF_FACEBOOK_FINDFRIENDS_ERROR") | |
| }); | |
| $.isFunction(a) && a() | |
| }) | |
| } else { | |
| $.publish("gs.notification", { | |
| type: "error", | |
| message: $.localize.getString("NOTIF_FACEBOOK_FINDFRIENDS_ERROR") | |
| }); | |
| $.isFunction(a) && a() | |
| } | |
| })) | |
| }, | |
| onGetGroovesharkUsers: function( a, b, c ) { | |
| var g = [], | |
| h = false; | |
| if ( c ) { | |
| $.each(c, function( k, m ) { | |
| if ( m && m.UserID && m.FacebookUserID && GS.user.favorites.users && !GS.user.favorites.users[m.UserID] ) { | |
| m.FacebookName = a[m.FacebookUserID]; | |
| g.push(m) | |
| } else if ( GS.user.favorites.users && GS.user.favorites.users[m.UserID] ) h = true | |
| }); | |
| if ( g && g.length > 0 ) GS.getLightbox().open("gsUsersFromThirdParty", { | |
| users: g, | |
| isTwitter: false, | |
| isFacebook: true | |
| }); | |
| else h ? $.publish("gs.facebook.notification.findFriends", { | |
| message: "NOTIF_FACEBOOK_FINDFRIENDS_ALREADY", | |
| inviteFriends: false | |
| }) : $.publish("gs.facebook.notification.findFriends", { | |
| message: "NOTIF_FACEBOOK_FINDFRIENDS_NONE", | |
| inviteFriends: true | |
| }) | |
| } else $.publish("gs.notification", { | |
| type: "error", | |
| message: $.localize.getString("NOTIF_FACEBOOK_FINDFRIENDS_ERROR") | |
| }); | |
| $.isFunction(b) && b() | |
| } | |
| }) | |
| })(); | |
| GS.Controllers.BaseController.extend("GS.Controllers.LastfmController", { | |
| isGSSingleton: true, | |
| preSetup: function() { | |
| var a = GS.Controllers.BaseController.singletonCallback, | |
| b = $.subscribe; | |
| b("gs.auth.update", a("lastfm", "update")); | |
| b("gs.player.nowplaying", a("lastfm", "onNowPlaying")); | |
| b("gs.player.playing.continue", a("lastfm", "onSongPlaying")) | |
| } | |
| }, { | |
| SERVICE_ID: 2, | |
| API_KEY: "b1ecfd8a5f8ec4dbb4cdacb8f3638f6d", | |
| P_VERSION: "1.2.1", | |
| URL_USER_AUTH: "http://www.last.fm/api/auth", | |
| URL_AUDIOSCROBBLER: "http://ws.audioscrobbler.com/2.0/", | |
| CLIENT_ID: "gvs", | |
| CLIENT_VERSION: "1", | |
| MINIMUM_DURATION: 240, | |
| SCROBBLING_FLAG: 1, | |
| FAVORITES_FLAG: 2, | |
| DEFAULT_FLAGS: 1, | |
| authToken: null, | |
| sessionKey: null, | |
| username: null, | |
| sessionID: null, | |
| flags: 0, | |
| scrobblingEnabled: false, | |
| lastError: null, | |
| nowPlaying: null, | |
| lastPlayed: null, | |
| currentListening: null, | |
| lastError: null, | |
| onUpdateSubcription: "gs.lastfm.profile.update", | |
| init: function() { | |
| if (!window.confirmLastfmConnection ) window.confirmLastfmConnection = this.callback(function( a ) { | |
| console.log("last.fm confirm connection", a); | |
| if ( this.lastfmOpenerWindow ) { | |
| this.lastfmOpenerWindow.close(); | |
| this.lastfmOpenerWindow = null | |
| } | |
| try { | |
| a = JSON.parse(a) | |
| } catch (b) { | |
| this.lastError = "parseError"; | |
| this.loginFailedCallback(); | |
| return | |
| } | |
| GS.airbridge && GS.airbridge.isDesktop ? window.setTimeout(function() { | |
| GS.getLastfm().onLogin(a) | |
| }, 300) : this.onLogin(a) | |
| }); | |
| this._super() | |
| }, | |
| appReady: function() { | |
| this.subscribe("gs.cowbell.ready", this.callback("commReady")) | |
| }, | |
| commReady: function() { | |
| this.update() | |
| }, | |
| update: function() { | |
| if ( GS.user && GS.user.isLoggedIn && GS.user.UserID > 0 && GS.user.Flags & this.SERVICE_ID ) GS.service.getLastfmService(this.callback("onGetService"), this.callback("onGetService")); | |
| else { | |
| this.clearInfo(); | |
| delete this.onUpdateSubcription | |
| } | |
| }, | |
| onGetService: function( a ) { | |
| if ( a.Session ) { | |
| this.username = a.LastfmUsername; | |
| this.sessionKey = a.Session; | |
| this.flags = 1; | |
| this.scrobblingEnabled = true; | |
| if ( a.FlagScrb ) { | |
| this.flags |= this.SCROBBLING_FLAG; | |
| this.scrobblingEnabled = true | |
| } | |
| if ( a.FlagFav ) this.flags |= this.FAVORITES_FLAG; | |
| this.connected = true; | |
| $.publish("gs.lastfm.profile.update") | |
| } | |
| delete this.onUpdateSubcription | |
| }, | |
| showReAuthLightbox: function() { | |
| GS.getLightbox().open({ | |
| type: "reAuthLastfm", | |
| view: { | |
| header: "POPUP_LASTFM_REAUTH_TITLE", | |
| message: "POPUP_LASTFM_REAUTH_MESSAGE", | |
| buttonsRight: [{ | |
| label: "POPUP_REAUTH_SUBMIT", | |
| className: "submit" | |
| }], | |
| buttonsLeft: GS.getLastfm().registeredWithLastfm ? [] : [{ | |
| label: "POPUP_LASTFM_REAUTH_CANCEL", | |
| className: "close" | |
| }] | |
| }, | |
| callbacks: { | |
| ".submit": function() { | |
| GS.getLastfm().logout(function() { | |
| GS.getLastfm().login(function() { | |
| GS.getLightbox().close() | |
| }) | |
| }) | |
| }, | |
| ".close": function() { | |
| GS.getLastfm().logout(function() { | |
| GS.getLightbox().close() | |
| }) | |
| } | |
| } | |
| }) | |
| }, | |
| login: function( a, b ) { | |
| if ( GS.user && GS.user.isLoggedIn ) { | |
| this.loginSuccessCallback = | |
| a; | |
| this.loginFailedCallback = b; | |
| this.sessionKey = null; | |
| a = "http://" + window.location.host + "/lastfmCallback.php?window=" + window.name; | |
| this.lastfmOpenerWindow = window.open(this.URL_USER_AUTH + "?api_key=" + this.API_KEY + "&cb=" + a, "", "width=950,height=700"); | |
| if ( GS.airbridge && GS.airbridge.isDesktop ) this.lastfmOpenerWindow.parentSandboxBridge = { | |
| confirmLastfmConnection: window.confirmLastfmConnection | |
| } | |
| } else b({ | |
| error: "LASTFM_PROBLEM_NOT_LOGGED_IN_ERROR_MSG" | |
| }) | |
| }, | |
| onLogin: function( a ) { | |
| if ( a.error || !a.token ) { | |
| this.lastError = a.error; | |
| this.loginFailedCallback() | |
| } else { | |
| if (!this.flags ) this.flags = this.DEFAULT_FLAGS; | |
| GS.user.Flags & this.SERVICE_ID || GS.user.Flags & this.LASTFM_ONLY_SERVICE_ID ? GS.service.updateLastfmService("", a.token, "", 0, 0, this.callback("onSaveLastfmService", this.loginSuccessCallback, this.loginFailedCallback), this.loginFailedCallback) : GS.service.saveLastfmService("", a.token, "", this.flags, this.callback("onSaveLastfmService", this.loginSuccessCallback, this.loginFailedCallback), this.loginFailedCallback) | |
| } | |
| }, | |
| onSaveLastfmService: function( a, b, c ) { | |
| if ( c.result == true && c.lastfmData && c.lastfmData.user ) { | |
| this.username = c.lastfmData.user; | |
| this.sessionKey = c.lastfmData.session; | |
| this.connected = true; | |
| $.publish("gs.lastfm.profile.update"); | |
| GS.user.Flags |= this.SERVICE_ID; | |
| $.isFunction(b) && a() | |
| } else if ( c.result == -1 ) if ( GS.user.Flags & this.SERVICE_ID || GS.user.Flags & this.FACEBOOK_ONLY_SERVICE_ID ) GS.service.getLastfmService(this.callback("onGetService", a, function() { | |
| $.isFunction(b) && b({ | |
| error: "LASTFM_PROBLEM_CONNECTING_ERROR_MSG" | |
| }) | |
| }), function() { | |
| $.isFunction(b) && b({ | |
| error: "LASTFM_PROBLEM_CONNECTING_ERROR_MSG" | |
| }) | |
| }); | |
| else $.isFunction(b) && b({ | |
| error: "LASTFM_DUPLICATE_ACCOUNT_ERROR_MSG" | |
| }); | |
| else $.isFunction(b) && b({ | |
| error: "POPUP_SIGNUP_LOGIN_FORM_LASTFM_ERROR" | |
| }) | |
| }, | |
| saveFlags: function( a, b, c ) { | |
| var g = 0, | |
| h = 0; | |
| if ( a & this.SCROBBLING_FLAG && !(this.flags & this.SCROBBLING_FLAG) ) g |= this.SCROBBLING_FLAG; | |
| else if (!(a & this.SCROBBLING_FLAG) && this.flags & this.SCROBBLING_FLAG ) h |= this.SCROBBLING_FLAG; | |
| if ( a & this.FAVORITES_FLAG && !(this.flags & this.FAVORITES_FLAG) ) g |= this.FAVORITES_FLAG; | |
| else if (!(a & this.FAVORITES_FLAG) && this.flags & this.FAVORITES_FLAG ) h |= this.FAVORITES_FLAG; | |
| this.flags = a; | |
| GS.user.Flags & this.SERVICE_ID || GS.user.Flags & this.LASTFM_ONLY_SERVICE_ID ? GS.service.updateLastfmService("", this.sessionKey, this.username, g, h, this.callback("onSaveLastfmService", b, c), c) : GS.service.saveLastfmService("", this.sessionKey, this.username, g, this.callback("onSaveLastfmService", b, c), c) | |
| }, | |
| logout: function( a ) { | |
| this.username ? GS.service.removeLastfmService(this.username, this.callback("onLogout", a)) : GS.service.removeLastfmService(false, this.callback("onLogout", a)) | |
| }, | |
| onLogout: function( a ) { | |
| GS.user.Flags = (GS.user.Flags | this.SERVICE_ID) - this.SERVICE_ID; | |
| this.clearInfo(); | |
| $.isFunction(a) && a() | |
| }, | |
| clearInfo: function() { | |
| this.sessionKey = null; | |
| this.username = ""; | |
| this.flags = null; | |
| this.connected = false; | |
| $.publish("gs.lastfm.profile.update") | |
| }, | |
| onNowPlaying: function( a ) { | |
| if (!this.currentListening || a.queueSongID != this.currentListening.queueSongID || a.SongID != this.currentListening.songID ) this.currentListening = { | |
| songID: a.SongID, | |
| queueSongID: a.queueSongID, | |
| secondsListened: 0, | |
| scrobbled: false | |
| }; | |
| else if ( GS.player.repeatMode == GS.player.REPEAT_ONE && a.queueSongID == this.currentListening.queueSongID ) { | |
| this.currentListening.scrobbled = false; | |
| this.currentListening.secondsListened = 0 | |
| } else return; | |
| if ((this.flags & this.SCROBBLING_FLAG) > 0 && this.scrobblingEnabled && a ) { | |
| this.nowPlaying = { | |
| track: a.SongName, | |
| artist: a.ArtistName, | |
| album: a.AlbumName, | |
| duration: a.EstimateDuration ? Math.round(a.EstimateDuration / 1E3) : 0, | |
| method: "track.updateNowPlaying", | |
| sk: this.sessionKey, | |
| api_key: this.API_KEY | |
| }; | |
| if ( a.TrackNum ) this.nowPlaying.trackNumber = String(a.TrackNum); | |
| this.getJSON(this.URL_AUDIOSCROBBLER, this.nowPlaying, this.callback("onNowPlayingComplete"), this.callback("onNowPlayingFailed"), true) | |
| } | |
| }, | |
| onNowPlayingComplete: function( a ) { | |
| if (!a || !a.nowplaying ) this.onLastfmError("POPUP_FAIL_SCROBBLE_LASTFM", a) | |
| }, | |
| onLastfmError: function( a, b ) { | |
| a || (a = "POPUP_FAIL_COMMUNICATE_LASTFM"); | |
| (this.lastError = b) && b.error && b.error == 9 ? this.showReAuthLightbox() : $.publish("gs.notification", { | |
| type: "error", | |
| message: $.localize.getString(a) | |
| }) | |
| }, | |
| onSongPlaying: function( a ) { | |
| var b = | |
| a.activeSong; | |
| a = Math.round(a.duration / 1E3); | |
| if (!this.currentListening || b.queueSongID != this.currentListening.queueSongID || b.SongID != this.currentListening.songID ) this.currentListening = { | |
| songID: b.SongID, | |
| queueSongID: b.queueSongID, | |
| secondsListened: 0, | |
| scrobbled: false | |
| }; | |
| else this.currentListening.secondsListened += 0.5; | |
| if ((this.flags & this.SCROBBLING_FLAG) > 0 && this.scrobblingEnabled && b && a >= 30 && (this.currentListening.secondsListened >= this.MINIMUM_DURATION || this.currentListening.secondsListened >= a / 2) && !this.currentListening.scrobbled ) { | |
| this.lastPlayed = { | |
| artist: b.ArtistName, | |
| track: b.SongName, | |
| timestamp: Math.round((new Date).getTime() / 1E3), | |
| duration: b.EstimateDuration ? Math.round(b.EstimateDuration / 1E3) : 0, | |
| album: b.AlbumName, | |
| method: "track.scrobble", | |
| sk: this.sessionKey, | |
| api_key: this.API_KEY | |
| }; | |
| if ( b.TrackNum ) this.lastPlayed.trackNumber = String(b.TrackNum); | |
| this.currentListening.scrobbled = true; | |
| this.getJSON(this.URL_AUDIOSCROBBLER, this.lastPlayed, this.callback("onSongPlayingComplete"), this.callback("onNowPlayingFailed"), true) | |
| } | |
| }, | |
| onSongPlayingComplete: function( a ) { | |
| if (!a || !a.scrobbles ) this.onLastfmError("POPUP_FAIL_SCROBBLE_LASTFM", a) | |
| }, | |
| getJSON: function( a, b, c, g, h ) { | |
| if ( a && b && c ) if ( h ) GS.service.makeLastfmRequest(b, function( k ) { | |
| try { | |
| k = JSON.parse(k) | |
| } catch (m) { | |
| k = null | |
| } | |
| c(k) | |
| }, g ? g : c); | |
| else { | |
| b.format = "json"; | |
| $.ajax({ | |
| url: a, | |
| data: b, | |
| success: c, | |
| error: g ? g : c, | |
| dataType: "jsonp", | |
| cache: true | |
| }) | |
| } | |
| } | |
| }); | |
| GS.Controllers.BaseController.extend("GS.Controllers.GoogleController", { | |
| isGSSingleton: true | |
| }, { | |
| SERVICE_ID: 64, | |
| GOOGLE_ONLY_SERVICE_ID: 32, | |
| REQUIRED: "email,firstname,lastname", | |
| EXTENSIONS: { | |
| "openid.ns.ax": "http://openid.net/srv/ax/1.0", | |
| "openid.ax.mode": "fetch_request", | |
| "openid.ax.type.email": "http://axschema.org/contact/email", | |
| "openid.ax.type.firstname": "http://axschema.org/namePerson/first", | |
| "openid.ax.type.lastname": "http://axschema.org/namePerson/last", | |
| "openid.ax.required": "email,firstname,lastname", | |
| "openid.ui.icon": "true" | |
| }, | |
| googleOpener: null, | |
| googleOpenerWindow: null, | |
| googleOpenerInterval: null, | |
| connected: false, | |
| registeredWithGoogle: false, | |
| email: "", | |
| firstname: "", | |
| lastname: "", | |
| googleID: "", | |
| lastError: "", | |
| onLoginSaveData: null, | |
| googlePlusloaded: false, | |
| loginSuccessCallback: null, | |
| loginFailedCallback: null, | |
| init: function() { | |
| this.subscribe("gs.auth.update", this.callback("update")); | |
| if (!window.confirmGoogleConnection ) window.confirmGoogleConnection = this.callback(function( a ) { | |
| if ( this.googleOpenerWindow ) { | |
| this.googleOpenerWindow.close(); | |
| this.googleOpenerWindow = | |
| null | |
| } | |
| try { | |
| a = JSON.parse(a) | |
| } catch (b) { | |
| this.lastError = "parseError"; | |
| this.loginFailedCallback(); | |
| return | |
| } | |
| if ( a.mode == "cancel" || a.error == "cancel" ) { | |
| this.lastError = "cancel"; | |
| this.onCancelledLogin() | |
| } else GS.airbridge && GS.airbridge.isDesktop ? window.setTimeout(function() { | |
| GS.getGoogle().onLogin(a) | |
| }, 300) : this.onLogin(a) | |
| }); | |
| this._super() | |
| }, | |
| appReady: function() { | |
| this.subscribe("gs.cowbell.ready", this.callback("commReady")); | |
| this.googleOpener = googleOpenIDPopup.createPopupOpener({ | |
| realm: "http://*.grooveshark.com", | |
| opEndpoint: "https://www.google.com/accounts/o8/ud", | |
| returnToUrl: (window.location.protocol ? window.location.protocol : "http:") + "//" + (window.location.hostname ? window.location.hostname : "grooveshark.com") + "/googleCallback.php?window=" + window.name, | |
| shouldEncodeUrls: true, | |
| extensions: this.EXTENSIONS | |
| }); | |
| if (!window.name ) window.name = gsConfig.windowName | |
| }, | |
| commReady: function() { | |
| if ( _.browserDetect().browser != "msie" || _.browserDetect().version > 6 ) { | |
| window.goPLoadAttempts = 0; | |
| window.loadGooglePlus = function() { | |
| try { | |
| var a = document.getElementById("go-root"); | |
| if ( a && a.getElementsByTagName("script").length ) { | |
| a.removeChild(a.getElementsByTagName("script")[0]); | |
| a.getElementsByTagName("div").length && a.removeChild(a.getElementsByTagName("div")[0]); | |
| window.gapi = null; | |
| GS.getGoogle().googlePlusloaded = false | |
| } | |
| var b = document.createElement("script"); | |
| b.async = true; | |
| b.src = document.location.protocol + "//apis.google.com/js/plusone.js"; | |
| b.text = "{parsetags: 'explicit'}"; | |
| b.onload = b.onreadystatechange = function() { | |
| if ( $.browser.msie && this.readyState ) { | |
| if ( this.readyState === "complete" || this.readyState === "loaded" ) { | |
| this.onload = this.onreadystatechange = null; | |
| setTimeout(function() { | |
| window.gapi && GS.getGoogle().initGooglePlus() | |
| }, 10) | |
| } | |
| } else { | |
| this.onload = this.onreadystatechange = null; | |
| setTimeout(function() { | |
| window.gapi && GS.getGoogle().initGooglePlus() | |
| }, 10) | |
| } | |
| }; | |
| document.getElementById("go-root").appendChild(b); | |
| window.goPLoadAttempts++; | |
| window.googlePlusLoadTimeout = setTimeout(function() { | |
| if ((!window.gapi || !GS.getGoogle().googlePlusloaded) && window.goPLoadAttempts < 3 ) window.loadGooglePlus(); | |
| else!window.gapi && window.goPLoadAttempts >= 3 || window.gapi && !GS.getGoogle().googlePlusloaded && GS.getGoogle().initGooglePlus() | |
| }, 2E4) | |
| } catch (c) { | |
| console.error("Could not load Google JS. Fatal Error: ", c); | |
| GS.getGoogle().lastError = c | |
| } | |
| }; | |
| window.loadGooglePlus() | |
| } | |
| this.update() | |
| }, | |
| initGooglePlus: function() { | |
| this.googlePlusloaded = true; | |
| window.googlePlusLoadTimeout && clearTimeout(window.googlePlusLoadTimeout); | |
| this.parsePlusWidgets(); | |
| $.subscribe("gs.theme.set", function() { | |
| window.document.getElementById("theme_home") && GS.getGoogle().parsePlusWidgets(window.document.getElementById("theme_home")) | |
| }) | |
| }, | |
| parsePlusWidgets: function( a ) { | |
| if ( window.gapi ) window.gapi.plusone.go(a ? a : document.body) | |
| }, | |
| update: function() { | |
| if ( GS.user && GS.user.isLoggedIn && GS.user.UserID > 0 && (GS.user.Flags & this.SERVICE_ID || GS.user.Flags & this.GOOGLE_ONLY_SERVICE_ID) ) { | |
| this.registeredWithGoogle = (GS.user.Flags & this.GOOGLE_ONLY_SERVICE_ID) > 0; | |
| GS.service.getUserGoogleData(this.callback("onUserGoogleData", null, null)) | |
| } else GS.user && GS.user.isLoggedIn && this.onLoginSaveData && this.onLoginSaveData == GS.user.Email ? GS.service.saveUserGoogleData(this.callback("onSaveUserGoogleData", null, null), function() { | |
| GS.getGoogle().clearInfo() | |
| }) : this.clearInfo() | |
| }, | |
| showReAuthLightbox: function() { | |
| GS.getLightbox().open({ | |
| type: "reAuthGoogle", | |
| view: { | |
| header: "POPUP_GOOGLE_REAUTH_TITLE", | |
| message: "POPUP_GOOGLE_REAUTH_MESSAGE", | |
| buttonsRight: [{ | |
| label: "POPUP_REAUTH_SUBMIT", | |
| className: "submit" | |
| }], | |
| buttonsLeft: GS.getGoogle().registeredWithGoogle ? [] : [{ | |
| label: "POPUP_GOOGLE_REAUTH_CANCEL", | |
| className: "close" | |
| }] | |
| }, | |
| callbacks: { | |
| ".submit": function() { | |
| GS.getGoogle().logout(function() { | |
| GS.getGoogle().login(function() { | |
| GS.getLightbox().close() | |
| }) | |
| }) | |
| }, | |
| ".close": function() { | |
| GS.getGoogle().logout(function() { | |
| GS.getLightbox().close() | |
| }) | |
| } | |
| } | |
| }) | |
| }, | |
| onUserGoogleData: function( a, b, c ) { | |
| try { | |
| if ( c && c.GoogleEmailAddress && c.GoogleID ) { | |
| this.email = c.GoogleEmailAddress; | |
| this.googleID = c.GoogleID; | |
| this.connected = true; | |
| $.publish("gs.google.profile.update"); | |
| a && a() | |
| } else if ( c && (!c.GoogleEmailAddress || !c.GoogleID) ) this.showReAuthLightbox(); | |
| else { | |
| GS.user.Flags = (GS.user.Flags | this.SERVICE_ID) - this.SERVICE_ID; | |
| if ( this.registeredWithGoogle ) GS.user.Flags = (GS.user.Flags | this.GOOGLE_ONLY_SERVICE_ID) - this.GOOGLE_ONLY_SERVICE_ID; | |
| this.clearInfo(); | |
| $.isFunction(b) && b({ | |
| error: "GOOGLE_MISSING_LOGIN_INFO_ERROR_MSG" | |
| }) | |
| } | |
| } catch (g) { | |
| this.connected = | |
| false; | |
| $.isFunction(b) && b({ | |
| error: "GOOGLE_MISSING_LOGIN_INFO_ERROR_MSG" | |
| }) | |
| } | |
| }, | |
| onAuthGoogleUser: function( a, b, c ) { | |
| if ( c ) if ( c.userID == 0 ) this.register(a, b); | |
| else { | |
| a(c); | |
| $.publish("gs.google.profile.update"); | |
| GS.getGuts().logEvent("googleAuthenticated", { | |
| authenticated: true | |
| }) | |
| } | |
| else b && b(c) | |
| }, | |
| onSaveUserGoogleData: function( a, b, c ) { | |
| if ( c == 1 ) { | |
| this.connected = true; | |
| $.publish("gs.google.profile.update"); | |
| GS.user.Flags |= this.SERVICE_ID; | |
| $.isFunction(a) && a() | |
| } else if ( c == -1 ) if ( GS.user.Flags & this.SERVICE_ID || GS.user.Flags & this.GOOGLE_ONLY_SERVICE_ID ) GS.service.getUserGoogleData(this.callback("onUserGoogleData", a, function() { | |
| b("GOOGLE_PROBLEM_CONNECTING_ERROR_MSG") | |
| }), function() { | |
| b("GOOGLE_PROBLEM_CONNECTING_ERROR_MSG") | |
| }); | |
| else b && b({ | |
| error: "GOOGLE_DUPLICATE_ACCOUNT_ERROR_MSG" | |
| }); | |
| else if ( c == -2 ) b && b({ | |
| error: "GOOGLE_MISSING_LOGIN_INFO_ERROR_MSG" | |
| }); | |
| else b && b({ | |
| error: "POPUP_SIGNUP_LOGIN_FORM_GOOGLE_ERROR" | |
| }) | |
| }, | |
| register: function( a, b ) { | |
| var c = this.email.split("@")[0]; | |
| if ( c ) { | |
| c = c.replace(/^[\.\-_]|[^a-zA-Z0-9\.\-_]|[\.\-_]$/g, ""); | |
| c = c.replace(/([\.\-_]){2,}/g, "$1") | |
| } | |
| var g = this.firstname + " " + this.lastname, | |
| h = Math.floor(Math.random() * 997508) + 1005; | |
| g || c ? GS.service.getUsernameSuggestions(c, g, h, this.callback("usernameSuggestSuccess", a, b), this.callback("usernameSuggestFailed", a, b)) : this.usernameSuggestFailed("") | |
| }, | |
| usernameSuggestSuccess: function( a, b, c ) { | |
| b = ""; | |
| if ( c && c.length > 0 ) b = c[0]; | |
| this.openRegisterLightbox(a, b) | |
| }, | |
| usernameSuggestFailed: function( a, b ) { | |
| a && b ? b({ | |
| error: "POPUP_SIGNUP_LOGIN_FORM_GOOGLE_ERROR" | |
| }) : this.openRegisterLightbox(null, "") | |
| }, | |
| openRegisterLightbox: function( a, b ) { | |
| var c = { | |
| isGoogle: true, | |
| googleData: { | |
| email: this.email, | |
| googleID: this.googleID | |
| }, | |
| username: b, | |
| email: this.email, | |
| fname: this.firstname + " " + this.lastname, | |
| message: $.localize.getString("POPUP_SIGNUP_LOGIN_FORM_GOOGLE_NOT_FOUND") | |
| }; | |
| GS.user.defaultFromService = c; | |
| GS.getLightbox().close(); | |
| if ( GS.page.activePageName == "signup" ) GS.page.activePage.update(c); | |
| else location.hash = "#/signup"; | |
| GS.getGuts().logEvent("googleRegistered", { | |
| registered: true | |
| }) | |
| }, | |
| login: function( a, b ) { | |
| this.googleOpenerWindow = this.googleOpener.popup(450, 600); | |
| this.loginSuccessCallback = a; | |
| this.loginFailedCallback = b; | |
| if ( GS.airbridge && GS.airbridge.isDesktop ) this.googleOpenerWindow.parentSandboxBridge = { | |
| confirmGoogleConnection: window.confirmGoogleConnection | |
| } | |
| }, | |
| onLogin: function( a ) { | |
| if ( a.error ) { | |
| this.lastError = a.error; | |
| this.loginFailedCallback() | |
| } else { | |
| if ( a.firstName ) this.firstname = a.firstName; | |
| if ( a.lastName ) this.lastname = a.lastName; | |
| if ( a.email ) this.email = a.email; | |
| if ( a.googleID ) this.googleID = a.googleID; | |
| if ( GS.user.isLoggedIn ) GS.user.Flags & this.SERVICE_ID || GS.user.Flags & this.GOOGLE_ONLY_SERVICE_ID ? GS.service.updateUserGoogleData(this.callback("onSaveUserGoogleData", this.loginSuccessCallback, this.loginFailedCallback), this.loginFailedCallback) : GS.service.saveUserGoogleData(this.callback("onSaveUserGoogleData", this.loginSuccessCallback, this.loginFailedCallback), this.loginFailedCallback); | |
| else GS.service.authenticateGoogleUser(this.callback("onAuthGoogleUser", this.loginSuccessCallback, this.loginFailedCallback), this.loginFailedCallback) | |
| } | |
| }, | |
| onCancelledLogin: function() {}, | |
| onLogout: function( a ) { | |
| if (!this.registeredWithGoogle ) GS.user.Flags = (GS.user.Flags | this.SERVICE_ID) - this.SERVICE_ID; | |
| this.clearInfo(); | |
| $.publish("gs.google.profile.update"); | |
| this.registeredWithGoogle && GS.auth.logout(); | |
| $.isFunction(a) && a() | |
| }, | |
| clearInfo: function() { | |
| this.identity = null; | |
| this.lastname = this.firstname = this.email = ""; | |
| this.registeredWithGoogle = this.connected = false; | |
| this.googleID = this.onLoginSaveData = null | |
| }, | |
| logout: function( a ) { | |
| this.googleID ? GS.service.removeUserGoogleData(this.googleID, this.callback("onLogout", a)) : GS.service.removeUserGoogleData(false, this.callback("onLogout", a)) | |
| }, | |
| serviceLogout: function() { | |
| var a = googleOpenIDPopup.getCenteredCoords(890, 600); | |
| window.open("https://www.google.com/accounts/Logout", "", "width=890,height=600,status=1,location=1,resizable=yes,left=" + a[0] + ",top=" + a[1]) | |
| } | |
| }); | |
| GS.Controllers.BaseController.extend("GS.Controllers.TwitterController", { | |
| isGSSingleton: true | |
| }, { | |
| twitterLoaded: false, | |
| lastError: null, | |
| init: function() { | |
| this._super() | |
| }, | |
| appReady: function() { | |
| this.subscribe("gs.cowbell.ready", this.callback("commReady")) | |
| }, | |
| commReady: function() { | |
| if ( _.browserDetect().browser != "msie" || _.browserDetect().version > 6 ) { | |
| window.twLoadAttempts = 0; | |
| window.loadTwitter = function() { | |
| try { | |
| if ( document.getElementById("tw-root") && document.getElementById("tw-root").getElementsByTagName("script").length ) { | |
| document.getElementById("tw-root").removeChild(document.getElementById("tw-root").getElementsByTagName("script")[0]); | |
| document.getElementById("tw-root") && document.getElementById("tw-root").getElementsByTagName("div").length && document.getElementById("tw-root").removeChild(document.getElementById("tw-root").getElementsByTagName("div")[0]); | |
| window.twttr = null; | |
| GS.getTwitter().twitterloaded = false | |
| } | |
| var a = document.createElement("script"); | |
| a.async = true; | |
| a.src = document.location.protocol + "//platform.twitter.com/widgets.js"; | |
| a.onload = a.onreadystatechange = function() { | |
| if ( $.browser.msie && this.readyState ) { | |
| if ( this.readyState === "complete" || this.readyState === "loaded" ) { | |
| this.onload = this.onreadystatechange = null; | |
| setTimeout(function() { | |
| window.twttr && GS.getTwitter().initTwitter() | |
| }, 10) | |
| } | |
| } else { | |
| this.onload = this.onreadystatechange = null; | |
| setTimeout(function() { | |
| window.twttr && GS.getTwitter().initTwitter() | |
| }, 10) | |
| } | |
| }; | |
| document.getElementById("tw-root").appendChild(a); | |
| window.twLoadAttempts++; | |
| window.twitterLoadTimeout = setTimeout(function() { | |
| if ((!window.twttr || !GS.getTwitter().twitterloaded) && window.twLoadAttempts < 3 ) window.loadTwitter(); | |
| else!window.twttr && window.twLoadAttempts >= 3 || window.twttr && !GS.getTwitter().twitterloaded && GS.getTwitter().initTwitter() | |
| }, 2E4) | |
| } catch (b) { | |
| console.error("Could not load Twitter JS. Fatal Error: ", b); | |
| GS.getTwitter().lastError = b | |
| } | |
| }; | |
| window.loadTwitter() | |
| } | |
| }, | |
| initTwitter: function() { | |
| this.twitterLoaded = true; | |
| window.twitterLoadTimeout && clearTimeout(window.twitterLoadTimeout); | |
| twttr.events.bind("tweet", function( a ) { | |
| if ( a ) { | |
| var b; | |
| if ( a.target && a.target.nodeName == "IFRAME" && a.target.src ) { | |
| a = decodeURI(a.target.src).split("&"); | |
| for ( var c = 0, g; g = a[c]; ++c ) | |
| if ( g.indexOf("url=") === 0 ) b = unescape(g.split("=")[1]) | |
| } | |
| window._gaq && window._gaq.push && window._gaq.push(["_trackSocial", "twitter", "tweet", b]) | |
| } | |
| }); | |
| $.subscribe("gs.theme.set", this.parseWidgets) | |
| }, | |
| parseWidgets: function() { | |
| window.twttr && window.twttr.widgets.load() | |
| }, | |
| getTwitterShareMessage: function( a, b, c, g, h ) { | |
| var k = this.callback(function( m ) { | |
| m = m.tinySongURL; | |
| var p = new GS.Models.DataString; | |
| switch ( a ) { | |
| case "song": | |
| var n = b.SongName; | |
| if ( n.length > 40 ) n = n.substr(0, 40) + "..."; | |
| p.string = $.localize.getString("SHARE_TWITTER_SONG"); | |
| p.data = { | |
| SongName: n, | |
| ArtistName: b.ArtistName | |
| }; | |
| p = p.render(); | |
| break; | |
| case "artist": | |
| n = b.ArtistName; | |
| if ( n.length > 60 ) n = n.substr(0, 60) + "..."; | |
| p.string = $.localize.getString("SHARE_TWITTER_ARTIST"); | |
| p.data = { | |
| ArtistName: n | |
| }; | |
| p = p.render(); | |
| break; | |
| case "album": | |
| n = b.AlbumName; | |
| if ( n.length > 40 ) n = n.substr(0, 40) + "..."; | |
| p.string = $.localize.getString("SHARE_TWITTER_ALBUM"); | |
| p.data = { | |
| AlbumName: n, | |
| ArtistName: b.ArtistName | |
| }; | |
| p = p.render(); | |
| break; | |
| case "playlist": | |
| n = b.PlaylistName; | |
| if ( n.length > 40 ) n = n.substr(0, 40) + "..."; | |
| p.string = $.localize.getString("SHARE_TWITTER_PLAYLIST"); | |
| p.data = { | |
| PlaylistName: n, | |
| UserName: b.UserName | |
| }; | |
| p = p.render(); | |
| break; | |
| default: | |
| p = ""; | |
| break | |
| } | |
| if ( p.length < 129 - m.length - 18 ) p += " #nowplaying"; | |
| if ( p.length < 128 - m.length - 18 && (new Date).format("D") === "Mon" ) p += " #musicmonday"; | |
| if ( p.length < 131 - m.length - 18 && (new Date).format("D") === "Tue" ) p += " #tunesday"; | |
| g(p, m) | |
| }); | |
| if ( a == "playlist" ) { | |
| c = "http://tinysong.com/p/" + _.base62Encode(b.PlaylistID + ""); | |
| k({ | |
| tinySongURL: c | |
| }) | |
| } else if ( a == "song" ) GS.service.getDetailsForBroadcast(b.SongID, k, this.callback(function() { | |
| k({ | |
| tinySongURL: c | |
| }) | |
| })); | |
| else if ( h ) k({ | |
| tinySongURL: c | |
| }); | |
| else { | |
| c = "http://api.bitly.com/v3/shorten?login=grooveshark&apiKey=R_44014f5c4cfe09348eced3baebeadcc3&longUrl=" + c; | |
| $.ajax({ | |
| url: c, | |
| dataType: "jsonp", | |
| success: this.callback(function( m ) { | |
| m && m.data && m.data.url ? k({ | |
| tinySongURL: m.data.url | |
| }) : k({ | |
| tinySongURL: c | |
| }) | |
| }), | |
| error: this.callback(function() { | |
| k({ | |
| tinySongURL: c | |
| }) | |
| }) | |
| }) | |
| } | |
| } | |
| }); | |
| GS.Controllers.BaseController.extend("GS.Controllers.ApiController", { | |
| onDocument: true | |
| }, { | |
| _songStatusCallback: "", | |
| _statusLookup: { | |
| 0: "none", | |
| 1: "loading", | |
| 2: "loading", | |
| 3: "playing", | |
| 4: "paused", | |
| 5: "buffering", | |
| 6: "failed", | |
| 7: "completed" | |
| }, | |
| _protocolActions: ["play", "add", "next"], | |
| _lastStatus: null, | |
| init: function() { | |
| this.subscribe("gs.player.playstatus", this.callback(this._doStatusCallback)); | |
| this.subscribe("gs.player.song.change", this.callback(this._onSongChange)); | |
| this._super() | |
| }, | |
| getApplicationVersion: function() { | |
| return gsConfig.revision | |
| }, | |
| getAPIVersion: function() { | |
| return 1.5 | |
| }, | |
| executeProtocol: function( a ) { | |
| var b = a.toLowerCase(); | |
| if ( b.indexOf("gs://") != -1 ) { | |
| a = a.substring(5); | |
| b = b.substring(5) | |
| } | |
| if ( a.charAt(a.length - 1) == "/" ) { | |
| a = a.substring(0, a.length - 1); | |
| b = b.substring(0, b.length - 1) | |
| } | |
| b = b.split("/"); | |
| var c = b.pop(); | |
| if ( this._protocolActions.indexOf(c) == -1 ) { | |
| b.push(c); | |
| c = "" | |
| } | |
| if ( b[0] == "themes" ) GS.getLightbox().open("themes"); | |
| else { | |
| if ( c ) { | |
| a = a.substring(0, a.length - c.length - 1); | |
| var g = GS.player.INDEX_DEFAULT, | |
| h = false; | |
| switch ( c ) { | |
| case "play": | |
| h = true; | |
| break; | |
| case "next": | |
| g = | |
| GS.player.INDEX_NEXT; | |
| break | |
| } | |
| if ( GS.player ) switch ( b[0] ) { | |
| case "s": | |
| GS.Models.Song.getSong(b[2], this.callback(function( k ) { | |
| GS.player.addSongsToQueueAt(k.SongID, g, h) | |
| }), null, false); | |
| break; | |
| case "song": | |
| GS.Models.Song.getSongFromToken(b[2], this.callback(function( k ) { | |
| GS.player.addSongsToQueueAt(k.SongID, g, h) | |
| }), null, false); | |
| break; | |
| case "album": | |
| GS.Models.Album.getAlbum(b[2], this.callback(function( k ) { | |
| k.play(g, h) | |
| }), null, false); | |
| break; | |
| case "playlist": | |
| GS.Models.Playlist.getPlaylist(b[2], this.callback(function( k ) { | |
| k.play(g, h) | |
| }), null, false); | |
| break | |
| } | |
| } | |
| if ( b[0] == "search" ) { | |
| b = b[b.length - 1]; | |
| a = a.substring(0, a.length - b.length); | |
| a += "?q=" + b | |
| } | |
| location.hash = "/" + a | |
| } | |
| }, | |
| getCurrentSongStatus: function() { | |
| return this._buildCurrentPlayStatus() | |
| }, | |
| setSongStatusCallback: function( a ) { | |
| if ( $.isFunction(a) ) this._songStatusCallback = a; | |
| else if ( _.isString(a) ) { | |
| a = a.split("."); | |
| a = this._getObjectChain(window, a); | |
| if ( $.isFunction(a) ) this._songStatusCallback = a | |
| } | |
| return this._buildCurrentPlayStatus() | |
| }, | |
| _getObjectChain: function( a, b ) { | |
| var c = b.shift(); | |
| return (c = a[c]) ? b.length ? this._getObjectChain(c, b) : c : null | |
| }, | |
| _doStatusCallback: function( a ) { | |
| if ( a && this._lastStatus ) if ( a.status === this._lastStatus.status ) if (!a.activeSong && !this._lastStatus.activeSong ) { | |
| this._lastStatus = a; | |
| return | |
| } else if ( a.activeSong && this._lastStatus.activeSong ) if ( a.activeSong.SongID === this._lastStatus.activeSong.SongID && a.activeSong.autoplayVote === this._lastStatus.activeSong.autoplayVote ) { | |
| this._lastStatus = a; | |
| return | |
| } | |
| this._lastStatus = a; | |
| $.isFunction(this._songStatusCallback) && this._songStatusCallback(this._buildCurrentPlayStatus()) | |
| }, | |
| _onSongChange: function( a ) { | |
| if (!this._lastStatus || this._lastStatus.activeSong && this._lastStatus.activeSong.SongID === a.SongID && this._lastStatus.activeSong.autoplayVote !== a.autoplayVote ) { | |
| if ( this._lastStatus ) this._lastStatus.activeSong.autoplayVote = a.autoplayVote; | |
| $.isFunction(this._songStatusCallback) && this._songStatusCallback(this._buildCurrentPlayStatus()) | |
| } | |
| }, | |
| _buildCurrentPlayStatus: function() { | |
| var a = { | |
| song: null, | |
| status: "none" | |
| }; | |
| if ( GS.player ) { | |
| var b = GS.player.getPlaybackStatus(); | |
| if ( b ) if ( b.activeSong ) { | |
| var c = | |
| GS.Models.Song.getOneFromCache(b.activeSong.SongID); | |
| a.song = { | |
| songID: b.activeSong.SongID, | |
| songName: b.activeSong.SongName.replace(/&\;/g, "&"), | |
| artistID: b.activeSong.ArtistID, | |
| artistName: b.activeSong.ArtistName.replace(/&\;/g, "&"), | |
| albumID: b.activeSong.AlbumID, | |
| albumName: b.activeSong.AlbumName.replace(/&\;/g, "&"), | |
| trackNum: c ? c.TrackNum : 0, | |
| estimateDuration: b.activeSong.EstimateDuration, | |
| artURL: c ? c.getImageURL() : gsConfig.assetHost + "/webincludes/images/default/album_250.png", | |
| calculatedDuration: b.duration, | |
| position: b.position, | |
| vote: b.activeSong.autoplayVote | |
| }; | |
| a.status = this._statusLookup[b.status] | |
| } | |
| } | |
| return a | |
| }, | |
| getPreviousSong: function() { | |
| var a = null; | |
| if ( GS.player && GS.player.queue && GS.player.queue.previousSong ) { | |
| a = GS.player.queue.previousSong; | |
| var b = GS.Models.Song.getOneFromCache(a.SongID); | |
| a = { | |
| songID: a.SongID, | |
| songName: a.SongName.replace(/&\;/g, "&"), | |
| artistID: a.ArtistID, | |
| artistName: a.ArtistName.replace(/&\;/g, "&"), | |
| albumID: a.AlbumID, | |
| albumName: a.AlbumName.replace(/&\;/g, "&"), | |
| trackNum: b ? b.TrackNum : 0, | |
| estimateDuration: a.EstimateDuration, | |
| artURL: b ? b.getImageURL() : gsConfig.assetHost + "/webincludes/images/default/album_250.png", | |
| vote: a.autoplayVote | |
| } | |
| } | |
| return a | |
| }, | |
| getNextSong: function() { | |
| var a = null; | |
| if ( GS.player && GS.player.queue && GS.player.queue.nextSong ) { | |
| a = GS.player.queue.nextSong; | |
| var b = GS.Models.Song.getOneFromCache(a.SongID); | |
| a = { | |
| songID: a.SongID, | |
| songName: a.SongName.replace(/&\;/g, "&"), | |
| artistID: a.ArtistID, | |
| artistName: a.ArtistName.replace(/&\;/g, "&"), | |
| albumID: a.AlbumID, | |
| albumName: a.AlbumName.replace(/&\;/g, "&"), | |
| trackNum: b ? b.TrackNum : 0, | |
| estimateDuration: a.EstimateDuration, | |
| artURL: b ? b.getImageURL() : gsConfig.assetHost + "/webincludes/images/default/album_250.png", | |
| vote: a.autoplayVote | |
| } | |
| } | |
| return a | |
| }, | |
| addSongsByID: function( a, b ) { | |
| GS.player && GS.player.addSongsToQueueAt(a, GS.player.INDEX_DEFAULT, b) | |
| }, | |
| addSongByToken: function( a, b ) { | |
| GS.player && GS.Models.Song.getSongFromToken(a, this.callback(function( c ) { | |
| GS.player.addSongsToQueueAt([c.SongID], GS.player.INDEX_DEFAULT, b) | |
| }), null, false) | |
| }, | |
| addAlbumByID: function( a, b ) { | |
| GS.player && GS.Models.Album.getAlbum(a, this.callback(function( c ) { | |
| c.play(GS.player.INDEX_DEFAULT, b) | |
| }), null, false) | |
| }, | |
| addPlaylistByID: function( a, b ) { | |
| GS.player && GS.Models.Playlist.getPlaylist(a, this.callback(function( c ) { | |
| c.play(GS.player.INDEX_DEFAULT, b) | |
| }), null, false) | |
| }, | |
| play: function() { | |
| if ( GS.player && GS.player.queue && GS.player.queue.activeSong ) GS.player.isPaused ? GS.player.resumeSong() : GS.player.playSong(GS.player.queue.activeSong.queueSongID) | |
| }, | |
| pause: function() { | |
| GS.player && GS.player.pauseSong() | |
| }, | |
| seekToPosition: function( a ) { | |
| GS.player && GS.player.seekTo(a) | |
| }, | |
| togglePlayPause: function() { | |
| if ( GS.player ) GS.player.isPaused ? GS.player.resumeSong() : GS.player.pauseSong() | |
| }, | |
| previous: function() { | |
| GS.player && GS.player.previousSong() | |
| }, | |
| next: function() { | |
| GS.player && GS.player.nextSong() | |
| }, | |
| setVolume: function( a ) { | |
| GS.player && GS.player.setVolume(a) | |
| }, | |
| getVolume: function() { | |
| if ( GS.player ) return GS.player.getVolume(); | |
| return 0 | |
| }, | |
| setIsMuted: function( a ) { | |
| GS.player && GS.player.setIsMuted(a) | |
| }, | |
| getIsMuted: function() { | |
| if ( GS.player ) return GS.player.getIsMuted(); | |
| return false | |
| }, | |
| voteCurrentSong: function( a ) { | |
| GS.player && GS.player.queue && GS.player.queue.activeSong && GS.player.voteSong(GS.player.queue.activeSong.queueSongID, a) | |
| }, | |
| getVoteForCurrentSong: function() { | |
| if ( GS.player && GS.player.queue && GS.player.queue.activeSong ) return GS.player.queue.activeSong.autoplayVote | |
| }, | |
| favoriteCurrentSong: function() { | |
| GS.player && GS.player.queue && GS.player.queue.activeSong && GS.user.addToSongFavorites(GS.player.queue.activeSong.SongID) | |
| }, | |
| addCurrentSongToLibrary: function() { | |
| GS.player && GS.player.queue && GS.player.queue.activeSong && GS.user.addToLibrary([GS.player.queue.activeSong.SongID]) | |
| }, | |
| removeCurrentSongFromQueue: function() { | |
| GS.player && GS.player.queue && GS.player.queue.activeSong && GS.player.removeSongs([GS.player.queue.activeSong.queueSongID]) | |
| } | |
| }); | |
| (function() { | |
| GS.Controllers.BaseController.extend("GS.Controllers.PageController", { | |
| activePage: null, | |
| activePageName: null, | |
| activePageIdentifier: null, | |
| activePageParams: null, | |
| SMALL_APP_LIMIT: 1200, | |
| _element: null, | |
| activate: function( a, b, c ) { | |
| if (!this._element ) this._element = $("#page"); | |
| $(".slick-reorder-proxy").remove(); | |
| $("#tooltip").stop().remove(); | |
| $application = $("#application"); | |
| if ( this.activePageName === a && this.activePageIdentifier === b ) { | |
| this.activePageParams = c; | |
| $.publish("gs.page.view", this.activePageName); | |
| return this.activePage | |
| } | |
| var g = | |
| GS.Controllers.Page, | |
| h = a; | |
| h = h.replace(/\_/g, " "); | |
| h = _.ucwords(h); | |
| h = h.replace(/\s/g, ""); | |
| g = g[h + "Controller"]; | |
| if ( _.defined(g) ) { | |
| this.activePage && this.activePage.destroy(); | |
| this.activePage = new g(this._element); | |
| this.activePageName = a; | |
| this.activePageIdentifier = b; | |
| this.activePageParams = c; | |
| switch ( a ) { | |
| case "home": | |
| case "boxee": | |
| if ( GS.user.settings.local.persistPinboard ) GS.getSidebar().show(); | |
| else GS.getSidebar.prototype.inst && GS.getSidebar().hide(); | |
| $("#theme_home *").show(); | |
| GS.theme.themeCenter(); | |
| break; | |
| case "signup": | |
| GS.getSidebar.prototype.inst && GS.getSidebar().hide(); | |
| $("#theme_home *").hide(); | |
| break; | |
| case "music": | |
| if ( b == GS.user.UserID || GS.user.settings.local.persistPinboard ) GS.getSidebar().show(); | |
| else GS.getSidebar.prototype.inst && GS.getSidebar().hide(); | |
| break; | |
| case "playlist": | |
| if ( GS.user.settings.local.persistPinboard || GS.user.playlists[this.activePageIdentifier] && $("#application").width() > GS.page.SMALL_APP_LIMIT ) GS.getSidebar().show(); | |
| else GS.getSidebar.prototype.inst && GS.getSidebar().hide(); | |
| $("#theme_home *").hide(); | |
| $("ul.ui-autocomplete").remove(); | |
| break; | |
| case "album": | |
| case "explore": | |
| case "artist": | |
| case "search": | |
| case "user": | |
| default: | |
| if ( GS.user.settings.local.persistPinboard ) GS.getSidebar().show(); | |
| else GS.getSidebar.prototype.inst && GS.getSidebar().hide(); | |
| $("#theme_home *").hide(); | |
| $("ul.ui-autocomplete").remove(); | |
| break | |
| } | |
| if ( a != "home" && GS.getAd() ) { | |
| $("#sidebarCapital_160").removeClass("capital"); | |
| GS.getAd().hideAdBar() | |
| } | |
| GS.getLocale(); | |
| $("#theme_page_header").hide().removeClass("measure"); | |
| $("#theme_page_header_expandable").height(0); | |
| $.publish("gs.page.view", this.activePageName); | |
| return this.activePage | |
| } | |
| }, | |
| titlePrepend: "Grooveshark - ", | |
| titlePostpend: " - Grooveshark", | |
| title: function( a, b ) { | |
| b = typeof b === "undefined" ? true : b; | |
| document.title = b ? a + this.titlePostpend : this.titlePrepend + a | |
| }, | |
| ALLOW_LOAD: true, | |
| justDidConfirm: false, | |
| lastPage: "", | |
| confirmMessage: $.localize.getString("ONCLOSE_PAGE_CHANGES"), | |
| checkLock: function() { | |
| if ( GS.Controllers.PageController.justDidConfirm || !GS.Controllers.PageController.ALLOW_LOAD && !confirm($.localize.getString("ONCLOSE_SAVE_PLAYLIST")) ) { | |
| GS.Controllers.PageController.justDidConfirm = | |
| true; | |
| location.replace([location.protocol, "//", location.host, location.pathname, GS.Controllers.PageController.lastPage].join("")); | |
| setTimeout(function() { | |
| GS.Controllers.PageController.justDidConfirm = false | |
| }, 500); | |
| return false | |
| } else { | |
| GS.Controllers.PageController.justDidConfirm = false; | |
| GS.Controllers.PageController.ALLOW_LOAD = true; | |
| GS.Controllers.PageController.lastPage = location.hash; | |
| GS.Controllers.PageController.confirmMessage = $.localize.getString("ONCLOSE_PAGE_CHANGES"); | |
| $.publish("gs.router.before"); | |
| return true | |
| } | |
| }, | |
| getActiveController: function() { | |
| return this.activePage | |
| }, | |
| loadFilterCollapseState: function() { | |
| this.artistFiltersCollapse = GS.store.get(this.shortName + "_artistFiltersCollapse"); | |
| this.albumFiltersCollapse = GS.store.get(this.shortName + "_albumFiltersCollapse"); | |
| if (!this.artistFiltersCollapse ) this.artistFiltersCollapse = { | |
| collapsed: true, | |
| manualCollapse: true, | |
| manualOpen: false | |
| }; | |
| if (!this.albumFiltersCollapse ) this.albumFiltersCollapse = { | |
| collapsed: true, | |
| manualCollapse: true, | |
| manualOpen: false | |
| }; | |
| this.storeFilterCollapseState() | |
| }, | |
| storeFilterCollapseState: function() { | |
| _.defined(this.artistFiltersCollapse) && GS.store.set(this.shortName + "_artistFiltersCollapse", this.artistFiltersCollapse); | |
| _.defined(this.albumFiltersCollapse) && GS.store.set(this.shortName + "_albumFiltersCollapse", this.albumFiltersCollapse) | |
| }, | |
| refreshTimeout: null, | |
| refreshed: null, | |
| resetRefreshButton: function() { | |
| $("#page_content_pane .refresh").addClass("disabled"); | |
| GS.page.refreshTimeout && clearTimeout(GS.page.refreshTimeout); | |
| GS.page.refreshTimeout = setTimeout(function() { | |
| GS.page.refreshed = | |
| null; | |
| GS.page.refreshTimeout = null; | |
| $("#page_content_pane .refresh").removeClass("disabled") | |
| }, 6E4) | |
| }, | |
| fromCorrectUrl: false | |
| }, { | |
| url: false, | |
| type: false, | |
| id: false, | |
| subpage: false, | |
| pageSearchHasFocus: false, | |
| slickbox: null, | |
| feed: null, | |
| header: { | |
| name: false, | |
| breadcrumbs: [], | |
| imageUrl: false, | |
| subpages: [], | |
| options: [], | |
| labels: [] | |
| }, | |
| list: { | |
| doPlayAddSelect: false, | |
| doSearchInPage: false, | |
| sortOptions: [], | |
| gridOptions: { | |
| data: [], | |
| columns: {}, | |
| options: {} | |
| } | |
| }, | |
| cache: {}, | |
| init: function() { | |
| this.subscribe("gs.page.loading.page", this.callback("showPageLoading")); | |
| this.subscribe("gs.page.loading.grid", this.callback("showGridLoading")); | |
| this.subscribe("gs.grid.selectedRows", this.callback("changeSelectionCount")); | |
| this.subscribe("gs.grid.onsort", this.callback("gridOnSort")); | |
| this._super(); | |
| $(document).keydown(this.callback(function( a ) { | |
| if (!$(a.target).is("input,textarea,select,object") ) { | |
| var b = _.orEqual(a.keyCode, a.which), | |
| c = String.fromCharCode(b).replace(/\s+/g, ""), | |
| g = { | |
| 17: true, | |
| 91: true, | |
| 93: true, | |
| 37: true, | |
| 38: true, | |
| 39: true, | |
| 40: true, | |
| 16: true | |
| }, | |
| h = { | |
| 9: true, | |
| 19: true, | |
| 20: true, | |
| 27: true, | |
| 33: true, | |
| 34: true, | |
| 35: true, | |
| 36: true, | |
| 45: true, | |
| 46: true, | |
| 112: true, | |
| 113: true, | |
| 114: true, | |
| 115: true, | |
| 116: true, | |
| 117: true, | |
| 118: true, | |
| 119: true, | |
| 120: true, | |
| 121: true, | |
| 122: true, | |
| 123: true, | |
| 145: true | |
| }; | |
| if (!$(a.target).is("input,textarea,select,object") ) if ( b == 8 ) history.back(); | |
| else c.length && c != "" && !g[b] && !h[b] && !a.metaKey && !a.ctrlKey && !GS.getLightbox().isOpen && $("input.search").select().focus(); | |
| if ( String.fromCharCode(b) == " " && $(a.target).val().length == 0 ) return false | |
| } | |
| })) | |
| }, | |
| destroy: function() { | |
| this.searchTimeout && clearTimeout(this.searchTimeout); | |
| this._super() | |
| }, | |
| index: function() { | |
| this.url = location.hash; | |
| this.element.html(this.view("index")) | |
| }, | |
| notFound: function() { | |
| GS.Controllers.PageController.activate("home", null).notFound() | |
| }, | |
| showPageLoading: function() { | |
| this.element.html(this.view("/shared/pageLoading")); | |
| var a = this.element.find(".page_loading"); | |
| a.css("marginLeft", a.width() / 2 * -1 + "px") | |
| }, | |
| showGridLoading: function() { | |
| $("#grid").html(this.view("/shared/loadingIndicator")); | |
| var a = this.element.find(".page_loading"); | |
| a.css("marginLeft", a.width() / 2 * -1 + "px") | |
| }, | |
| changeSelectionCount: function( a ) { | |
| if ( a.type === "album" || a.type === "artist" ) $("input.search", this.element).val("").trigger("keyup"); | |
| if ( a.type === "song" ) { | |
| var b = _.isNumber(a.len) && a.len > 0 ? a.len : 0, | |
| c = $("#page .page_controls"); | |
| if ( b ) { | |
| c.find(".play.count .label").localeDataString("SELECTION_PLAY_COUNT", { | |
| count: b | |
| }); | |
| c.find(".addSongs.count .label").localeDataString("SELECTION_ADD_COUNT", { | |
| count: b | |
| }); | |
| c.find(".deleteSongs.count .label").localeDataString("SELECTION_DELETE_COUNT", { | |
| count: b | |
| }) | |
| } else { | |
| c.find(".play.count .label").localeDataString("SELECTION_PLAY_ALL"); | |
| c.find(".addSongs.count .label").localeDataString("SELECTION_ADD_ALL"); | |
| c.find(".deleteSongs.count .label").localeDataString("SELECTION_DELETE_ALL") | |
| } | |
| c.find(".music_options").toggleClass("hide", b === 0); | |
| var g = $("#page").attr("class").split("_")[2]; | |
| g = a.len > 0 ? "song" : g; | |
| var h = c.find("a[name=share]"); | |
| h.parent().hide(); | |
| var k = GS.Controllers.Lightbox.ShareController.allowed[g]; | |
| if ( k ) { | |
| c.find("button.share").parent().show(); | |
| $.each(k, function( m, p ) { | |
| h.filter("[rel=" + p + "]").show().parent().show().removeClass("hide") | |
| }) | |
| } else c.find("button.share").parent().hide(); | |
| k = c.find(".share .label"); | |
| if ( g === "song" ) b > 1 ? k.localeDataString("SHARE_SONGS") : k.localeDataString("SHARE_SONG"); | |
| else k.localeDataString("SHARE_" + g.toUpperCase()); | |
| if ( a.len != 1 ) g === "playlist" ? c.find("li.shareOptions").show() : c.find("li.shareOptions .share_single").hide(); | |
| else { | |
| c.find("li.shareOptions").show(); | |
| c.find("li.shareOptions share_single").show() | |
| } | |
| c.find("button.deleteSongs").parent().toggle(a.len > 0); | |
| $("#page").hasClass("gs_page_now_playing") && c.find("button.delete").toggle(a.len > 0) | |
| } | |
| }, | |
| correctUrl: function( a, b ) { | |
| if ( a ) { | |
| var c = function() { | |
| if ( $.isFunction(a.toUrl) ) { | |
| var g = a.toUrl(b); | |
| if ( location.hash !== g ) { | |
| var h = location.hash.match(/(?:&|\?)fb_comment_id=([a-zA-Z0-9\_\-]+)/); | |
| if ( h && h[1] ) g += h[0]; | |
| if ( location.hash.replace(/src=\d/, "") !== g.replace(/src=\d/, "") ) { | |
| GS.page.fromCorrectUrl = true; | |
| location.replace(g) | |
| } | |
| } | |
| } | |
| }; | |
| $.isFunction(a.getPathName) ? a.getPathName(c) : c() | |
| } else console.warn("invalid page.correctUrl obj", a, b) | |
| }, | |
| gridOnSort: function( a ) { | |
| a && a.sortStoreKey && GS.store.set(a.sortStoreKey, a) | |
| }, | |
| getPlayContext: function() { | |
| var a; | |
| switch ( this.type ) { | |
| case "playlist": | |
| if ( this.hasOwnProperty("playlist") && this.playlist instanceof GS.Models.Playlist ) a = new GS.Models.PlayContext(GS.player.PLAY_CONTEXT_PLAYLIST, this.playlist); | |
| break; | |
| case "artist": | |
| if ( this.hasOwnProperty("artist") && this.artist instanceof GS.Models.Artist ) a = new GS.Models.PlayContext(GS.player.PLAY_CONTEXT_ARTIST, this.artist); | |
| break; | |
| case "album": | |
| if ( this.hasOwnProperty("album") && this.album instanceof GS.Models.Album ) a = new GS.Models.PlayContext(GS.player.PLAY_CONTEXT_ALBUM, this.album); | |
| break; | |
| case "user": | |
| case "music": | |
| if ( this.hasOwnProperty("user") && (this.user instanceof GS.Models.User || this.user instanceof GS.Models.AuthUser) ) a = new GS.Models.PlayContext(GS.player.PLAY_CONTEXT_USER, this.user); | |
| break; | |
| case "popular": | |
| a = new GS.Models.PlayContext(GS.player.PLAY_CONTEXT_POPULAR); | |
| break; | |
| default: | |
| if ( this.hasOwnProperty("query") ) a = new GS.Models.PlayContext(GS.player.PLAY_CONTEXT_SEARCH, { | |
| query: this.query, | |
| type: this.type ? this.type : "everything" | |
| }); | |
| break | |
| } | |
| return _.orEqual(a, new GS.Models.PlayContext) | |
| }, | |
| setSort: function( a, b, c ) { | |
| var g = $("#grid").controller(), | |
| h = GS.page.activePage; | |
| if ( g ) a == "Rank" ? g.dataView.setItems(g.data) : g.grid.onSort(a); | |
| else if ( h.slickbox ) { | |
| g = {}; | |
| switch ( h.type ) { | |
| case "playlist": | |
| switch ( a ) { | |
| case "Rank": | |
| g = { | |
| sortType: "relevance", | |
| sortFunction: null | |
| }; | |
| break; | |
| case "PlaylistName": | |
| g = { | |
| sortType: "playlistName", | |
| sortFunction: _.getSort("PlaylistName", true) | |
| }; | |
| break | |
| } | |
| break; | |
| case "artist": | |
| switch ( a ) { | |
| case "Rank": | |
| g = { | |
| sortType: "relevance", | |
| sortFunction: null | |
| }; | |
| break; | |
| case "ArtistName": | |
| g = { | |
| sortType: "artistName", | |
| sortFunction: _.getSort("ArtistName", true) | |
| }; | |
| break | |
| } | |
| break; | |
| case "album": | |
| switch ( a ) { | |
| case "Rank": | |
| g = { | |
| sortType: "relevance", | |
| sortFunction: null | |
| }; | |
| break; | |
| case "AlbumName": | |
| g = { | |
| sortType: "albumName", | |
| sortFunction: _.getSort("AlbumName", true) | |
| }; | |
| break; | |
| case "ArtistName": | |
| g = { | |
| sortType: "artistname", | |
| sortFunction: _.getSort("ArtistName", true) | |
| }; | |
| break | |
| } | |
| break; | |
| case "user": | |
| switch ( a ) { | |
| case "Rank": | |
| g = { | |
| sortType: "byPicture", | |
| sortFunction: h.sortByPicture | |
| }; | |
| break; | |
| case "Name": | |
| g = { | |
| sortType: "username", | |
| sortFunction: _.getSort("Username", true) | |
| }; | |
| break | |
| } | |
| } | |
| if ( h.currentSort && g && h.currentSort.sortType == g.sortType || !h.currentSort.sortFunction && !g.sortFunction ) return; | |
| h.slickbox.setSort(g.sortFunction); | |
| h.currentSort = g | |
| } | |
| a = b.find("span.label"); | |
| a.attr("data-translate-text", c); | |
| a.text($.localize.getString(c)) | |
| }, | |
| getPlayMenu: function() { | |
| var a = this.getPlayContext(), | |
| b = this.getSongsIDsFromSelectedGridRows(), | |
| c = this.element; | |
| return [{ | |
| title: $.localize.getString("PLAY_NOW"), | |
| action: { | |
| type: "fn", | |
| callback: function() { | |
| b.length && GS.player.addSongsToQueueAt(b, GS.player.INDEX_DEFAULT, true, a); | |
| GS.getGuts().objectListPlayAdd(b, c, "play") | |
| } | |
| }, | |
| customClass: "jj_menu_item_hasIcon jj_menu_item_play" | |
| }, { | |
| title: $.localize.getString("PLAY_NEXT"), | |
| action: { | |
| type: "fn", | |
| callback: function() { | |
| b.length && GS.player.addSongsToQueueAt(b, GS.player.INDEX_NEXT, false, a); | |
| GS.getGuts().objectListPlayAdd(b, c, "play") | |
| } | |
| }, | |
| customClass: "jj_menu_item_hasIcon jj_menu_item_play_next" | |
| }, { | |
| title: $.localize.getString("PLAY_LAST"), | |
| action: { | |
| type: "fn", | |
| callback: function() { | |
| b.length && GS.player.addSongsToQueueAt(b, GS.player.INDEX_LAST, false, a); | |
| GS.getGuts().objectListPlayAdd(b, c, "play") | |
| } | |
| }, | |
| customClass: "jj_menu_item_hasIcon jj_menu_item_play_last" | |
| }, { | |
| customClass: "separator" | |
| }, { | |
| title: $.localize.getString("REPLACE_QUEUE"), | |
| action: { | |
| type: "fn", | |
| callback: function() { | |
| b.length && GS.player.addSongsToQueueAt(b, GS.player.INDEX_REPLACE, true, a); | |
| GS.getGuts().objectListPlayAdd(b, c, "play") | |
| } | |
| }, | |
| customClass: "jj_menu_item_hasIcon jj_menu_item_replace_playlist" | |
| }, { | |
| title: $.localize.getString("START_RADIO"), | |
| action: { | |
| type: "fn", | |
| callback: function() { | |
| if ( $("#grid").controller().selectedRowIDs.length ) b.length && GS.player.addSongsToQueueAt(b, GS.player.INDEX_REPLACE, true, a, true); | |
| else GS.player.addSongsToQueueAt(b[0], GS.player.INDEX_REPLACE, true, a, true); | |
| GS.getGuts().objectListPlayAdd(b, c, "play") | |
| } | |
| }, | |
| customClass: "jj_menu_item_hasIcon jj_menu_item_new_station" | |
| }] | |
| }, | |
| getAddMenu: function() { | |
| var a = this.getPlayContext(), | |
| b = this.getSongsIDsFromSelectedGridRows(), | |
| c = this.element, | |
| g = $("#grid").controller(); | |
| g = g ? g.selectedRowIDs.length : 0; | |
| var h = [{ | |
| title: $.localize.getString("CONTEXT_ADD_TO_QUEUE"), | |
| action: { | |
| type: "fn", | |
| callback: function() { | |
| b.length && GS.player.addSongsToQueueAt(b, GS.player.INDEX_LAST, false, a); | |
| GS.getGuts().objectListPlayAdd(b, c, "add") | |
| } | |
| }, | |
| customClass: "jj_menu_item_hasIcon jj_menu_item_now_playing" | |
| }]; | |
| if ( this.type && b.length && (this.type != "artist" || g != 0) && !(this.type == "song" && this.song && this.song.fromLibrary) ) h.push({ | |
| title: $.localize.getString("CONTEXT_ADD_TO_LIBRARY"), | |
| action: { | |
| type: "fn", | |
| callback: function() { | |
| if ( b.length ) { | |
| GS.user.addToLibrary(b); | |
| GS.getGuts().objectListPlayAdd(b, c, "add") | |
| } | |
| } | |
| }, | |
| customClass: "jj_menu_item_hasIcon jj_menu_item_music" | |
| }); | |
| this.song && this.type == "song" && !this.song.isFavorite && h.push({ | |
| title: $.localize.getString("CONTEXT_ADD_TO_FAVORITES"), | |
| action: { | |
| type: "fn", | |
| callback: function() { | |
| if ( b.length == 1 ) { | |
| GS.user.addToSongFavorites(b[0], true); | |
| GS.getGuts().objectListPlayAdd(b, this.element, "add") | |
| } | |
| } | |
| }, | |
| customClass: "jj_menu_item_hasIcon jj_menu_item_favorites" | |
| }); | |
| if ( this.type != "artist" || g != 0 ) h.push({ | |
| title: $.localize.getString("CONTEXT_ADD_TO_PLAYLIST"), | |
| type: "sub", | |
| src: GS.Models.Playlist.getPlaylistsMenu(b, function( k ) { | |
| k.addSongs(b, null, true) | |
| }, false, true), | |
| customClass: "jj_menu_item_hasIcon jj_menu_item_add_playlist" | |
| }); | |
| return h | |
| }, | |
| getSortMenu: function() { | |
| return [] | |
| }, | |
| getOptionMenu: function() { | |
| return [] | |
| }, | |
| getShareMenu: function() { | |
| var a = this.element.find(".gs_grid:last").controller(), | |
| b = this.getSongsIDsFromSelectedGridRows(), | |
| c = GS.getGuts().extractSongItemInfo(a), | |
| g = [], | |
| h = this, | |
| k = a ? a.selectedRowIDs.length : 0; | |
| if (!a || k === 0 ) { | |
| type = this.type; | |
| id = this.id | |
| } else if ( k === 1 ) { | |
| type = "song"; | |
| id = typeof b != "number" && typeof b != "string" ? b[0] : b | |
| } | |
| if ( k === 0 || k === 1 ) { | |
| GS.user.isLoggedIn && type != "album" && g.push({ | |
| title: $.localize.getString("SHARE_EMAIL"), | |
| action: { | |
| type: "fn", | |
| callback: function() { | |
| GS.getLightbox().open("share", { | |
| service: "email", | |
| type: type, | |
| id: id | |
| }); | |
| GS.getGuts().onContextMenuClick("contextShareEmail", "dropdownmenu", false, c) | |
| } | |
| }, | |
| customClass: "jj_menu_item_hasIcon jj_menu_item_share_email" | |
| }); | |
| g.push({ | |
| title: $.localize.getString("SHARE_FACEBOOK"), | |
| action: { | |
| type: "fn", | |
| callback: function() { | |
| GS.getLightbox().open("share", { | |
| service: "facebook", | |
| type: type, | |
| id: id | |
| }); | |
| GS.getGuts().onContextMenuClick("contextShareFacebook", "dropdownmenu", false, c) | |
| } | |
| }, | |
| customClass: "jj_menu_item_hasIcon jj_menu_item_share_facebook" | |
| }, { | |
| title: $.localize.getString("SHARE_TWITTER"), | |
| action: { | |
| type: "fn", | |
| callback: function() { | |
| GS.getLightbox().open("share", { | |
| service: "twitter", | |
| type: type, | |
| id: id | |
| }); | |
| GS.getGuts().onContextMenuClick("contextShareTwitter", "dropdownmenu", false, c) | |
| } | |
| }, | |
| customClass: "jj_menu_item_hasIcon jj_menu_item_share_twitter" | |
| }, { | |
| title: $.localize.getString("SHARE_STUMBLE"), | |
| action: { | |
| type: "fn", | |
| callback: function() { | |
| b && type != "playlist" ? GS.Models.Song.getSong(b, function( m ) { | |
| if ( m ) { | |
| window.open(_.makeUrlForShare("stumbleupon", "song", m), "_blank"); | |
| GS.getGuts().onContextMenuClick("contextShareStumble", "dropdownmenu", false, c) | |
| } | |
| }) : GS.Models.Playlist.getPlaylist(h.id, function( m ) { | |
| window.open(_.makeUrlForShare("stumbleupon", type, m), "_blank"); | |
| GS.getGuts().onContextMenuClick("contextShareStumble", "dropdownmenu", false, c) | |
| }) | |
| } | |
| }, | |
| customClass: "jj_menu_item_hasIcon jj_menu_item_share_stumbleupon" | |
| }, { | |
| title: $.localize.getString("SHARE_REDDIT"), | |
| action: { | |
| type: "fn", | |
| callback: function() { | |
| b && type != "playlist" ? GS.Models.Song.getSong(b, function( m ) { | |
| if ( m ) { | |
| window.open(_.makeUrlForShare("reddit", "song", m), "_blank"); | |
| GS.getGuts().onContextMenuClick("contextShareReddit", "dropdownmenu", false, c) | |
| } | |
| }) : GS.Models.Playlist.getPlaylist(h.id, function( m ) { | |
| window.open(_.makeUrlForShare("reddit", type, m), "_blank"); | |
| GS.getGuts().onContextMenuClick("contextShareReddit", "dropdownmenu", false, c) | |
| }) | |
| } | |
| }, | |
| customClass: "jj_menu_item_hasIcon jj_menu_item_share_reddit" | |
| }, { | |
| title: $.localize.getString("SHARE_WIDGET"), | |
| action: { | |
| type: "fn", | |
| callback: function() { | |
| GS.getLightbox().open("share", { | |
| service: "widget", | |
| type: type, | |
| id: id | |
| }); | |
| GS.getGuts().onContextMenuClick("contextShareWidget", "dropdownmenu", true, c) | |
| } | |
| }, | |
| customClass: "jj_menu_item_hasIcon jj_menu_item_share_widget" | |
| }); | |
| k == 1 && g.push({ | |
| title: $.localize.getString("COPY_URL"), | |
| type: "sub", | |
| action: { | |
| type: "fn", | |
| callback: function() { | |
| if ( ZeroClipboard ) { | |
| GS.getGuts().onContextMenuClick("contextCopyUrl", "dropdownmenu", false, c); | |
| GS.Models.Song.getSong(b, function( m ) { | |
| if ( m ) { | |
| m.getClipboardAction([{ | |
| text: "http://grooveshark.com/" + m.toUrl().replace("#/", ""), | |
| selector: "div.songUrl" | |
| }, | |
| { | |
| text: "http://grooveshark.com/" + _.cleanUrl(m.AlbumName, m.AlbumID, "album").replace("#/", ""), | |
| selector: "div.albumUrl" | |
| }, | |
| { | |
| text: "http://grooveshark.com/" + _.cleanUrl(m.ArtistName, m.ArtistID, "artist").replace("#/", ""), | |
| selector: "div.artistUrl" | |
| }])(); | |
| $("div[name$=Url]", elem).show() | |
| } | |
| }) | |
| } | |
| } | |
| }, | |
| src: [{ | |
| title: $.localize.getString("SONG_URL"), | |
| customClass: "songUrl jj_menu_item_hasIcon jj_menu_item_copy" | |
| }, | |
| { | |
| title: $.localize.getString("ALBUM_URL"), | |
| customClass: "albumUrl jj_menu_item_hasIcon jj_menu_item_copy" | |
| }, | |
| { | |
| title: $.localize.getString("ARTIST_URL"), | |
| customClass: "artistUrl jj_menu_item_hasIcon jj_menu_item_copy" | |
| }], | |
| customClass: "copyUrl jj_menu_item_hasIcon jj_menu_item_copy" | |
| }) | |
| } else if ( k > 1 ) g = [{ | |
| title: $.localize.getString("SHARE_WIDGET"), | |
| action: { | |
| type: "fn", | |
| callback: function() { | |
| GS.getLightbox().open("share", { | |
| service: "widget", | |
| type: "manySongs", | |
| id: b | |
| }); | |
| GS.getGuts().onContextMenuClick("contextShareWidget", "dropdownmenu", true, c) | |
| } | |
| }, | |
| customClass: "jj_menu_item_hasIcon jj_menu_item_share_widget" | |
| }]; | |
| return g | |
| }, | |
| "input focus": function( a ) { | |
| $(a).parent().parent().addClass("active") | |
| }, | |
| "textarea focus": function( a ) { | |
| $(a).parent().parent().parent().addClass("active") | |
| }, | |
| "input blur": function( a ) { | |
| $(a).parent().parent().removeClass("active") | |
| }, | |
| "textarea blur": function( a ) { | |
| $(a).parent().parent().parent().removeClass("active") | |
| }, | |
| lastClickEvent: null, | |
| doubleClickTime: 500, | |
| "button click": function( a, b ) { | |
| if ( this.lastClickEvent && this.lastClickEvent.target == b.target && b.timeStamp - this.lastClickEvent.timeStamp < this.doubleClickTime ) { | |
| b.stopImmediatePropagation(); | |
| this.lastClickEvent = b; | |
| return false | |
| } | |
| this.lastClickEvent = | |
| b | |
| }, | |
| "button.radio click": function( a ) { | |
| a = $(a).attr("data-artists").split(","); | |
| a.length && GS.player.setAutoplay(true, null, { | |
| seeds: a, | |
| seedArtistWeightRange: [110, 130], | |
| secondaryArtistWeightModifier: 0.75 | |
| }) | |
| }, | |
| ".play.dropdownButton click": function( a, b ) { | |
| a.jjmenu(b, this.getPlayMenu(), null, { | |
| xposition: "left", | |
| yposition: "auto", | |
| show: "default", | |
| className: "contextmenu", | |
| keepState: a | |
| }) | |
| }, | |
| ".addSongs.dropdownButton click": function( a, b ) { | |
| a.jjmenu(b, this.getAddMenu(), null, { | |
| xposition: "left", | |
| yposition: "auto", | |
| show: "default", | |
| className: "contextmenu", | |
| keepState: a | |
| }) | |
| }, | |
| ".dropdownButton.sort click": function( a, b ) { | |
| var c = this.getSortMenu(); | |
| c && c.length ? a.jjmenu(b, c, null, { | |
| xposition: "left", | |
| yposition: "auto", | |
| show: "default", | |
| className: "contextmenu", | |
| keepState: a | |
| }) : console.warn("no menu") | |
| }, | |
| ".dropdownButton.share click": function( a, b ) { | |
| a.jjmenu(b, this.getShareMenu(), null, { | |
| xposition: "left", | |
| yposition: "auto", | |
| show: "default", | |
| className: "contextmenu", | |
| keepState: a | |
| }); | |
| var c = parseInt($("#grid .slick-row.selected").attr("row"), 10) + 1; | |
| GS.getGuts().logEvent("OLShare", { | |
| songIDs: this.getSongsIDsFromSelectedGridRows()[0], | |
| ranks: c | |
| }) | |
| }, | |
| ".dropdownButton.option click": function( a, b ) { | |
| var c = this.getOptionMenu(); | |
| a.jjmenu(b, c, null, { | |
| xposition: "left", | |
| yposition: "auto", | |
| show: "default", | |
| className: "contextmenu", | |
| keepState: a | |
| }) | |
| }, | |
| ".play.playTop click": function() { | |
| var a = this.getSongsIDsFromSelectedGridRows(); | |
| a.length && GS.player.addSongsToQueueAt(a, GS.Controllers.PlayerController.INDEX_DEFAULT, true, this.getPlayContext()); | |
| GS.getGuts().objectListPlayAdd(a, this.element, "play") | |
| }, | |
| "#page_header .upload click": function() { | |
| GS.user.isLoggedIn ? window.open("http://" + location.host + "/upload", "_blank") : GS.getLightbox().open("login") | |
| }, | |
| "#page .dropdownButton click": function() { | |
| function a(c) { | |
| if ( c.target !== b.target ) { | |
| c.data.$groups.removeClass("active"); | |
| $(this).unbind("click", a) | |
| } | |
| } | |
| var b; | |
| return function( c, g ) { | |
| b = g; | |
| var h = $("#page .btn_group"), | |
| k = $(c).closest(".btn_group"); | |
| if ( k.hasClass("active") ) h.removeClass("active"); | |
| else { | |
| h.removeClass("active"); | |
| k.addClass("active"); | |
| $(document).unbind("click contextmenu", a).bind("click contextmenu", { | |
| $groups: h | |
| }, a) | |
| } | |
| } | |
| }(), | |
| ".display_toggles .slickbox click": function( a ) { | |
| if ( this.displayMethod != "slickbox" ) { | |
| this.displayResults("slickbox"); | |
| GS.store.set("searchDisplay", "slickbox"); | |
| $("#page_header .display_toggles button").removeClass("active"); | |
| a.addClass("active") | |
| } | |
| }, | |
| ".display_toggles .grid click": function( a ) { | |
| if ( this.displayMethod != "grid" ) { | |
| this.displayResults("grid"); | |
| GS.store.set("searchDisplay", "grid"); | |
| $("#page_header .display_toggles button").removeClass("active"); | |
| a.addClass("active") | |
| } | |
| }, | |
| getSongsIDsFromSelectedGridRows: function() { | |
| var a = $("#grid").controller(), | |
| b = []; | |
| if ( a && a.selectedRowIDs.length > 0 ) b = a.selectedRowIDs; | |
| else if ( a ) for ( var c = 0; c < a.dataView.rows.length; c++ ) { | |
| if ( b.length >= 1E3 ) break; | |
| b.push(a.dataView.rows[c].SongID) | |
| } | |
| else this.type === "song" && this.song && b.push(this.song.SongID); | |
| return b | |
| }, | |
| ".inPageFilter input keydown": function( a, b ) { | |
| if ( b.which == _.keys.ENTER && !a.parents("form").hasClass("inPageSearch") ) { | |
| b.preventDefault(); | |
| b.stopPropagation() | |
| } else if ( b.which == _.keys.ESC && !a.parents("form").hasClass("inPageSearch") ) { | |
| var c = $("#page_search_results"); | |
| if ( c.is(":visible") ) { | |
| c.hide(); | |
| $.publish("gs.menu.hide") | |
| } else { | |
| a.siblings("a.remove").addClass("hide"); | |
| a.val("") | |
| } | |
| } | |
| a.siblings("a.remove").toggleClass("hide", !a.val().length); | |
| this.inpageFilter(a) | |
| }, | |
| ".inPageSearch input keydown": function( a, b ) { | |
| var c = $("#page_search_results li.selected"); | |
| switch ( b.which ) { | |
| case _.keys.ENTER: | |
| a.parents("form").submit(); | |
| return; | |
| case _.keys.ESC: | |
| c = $("#page_search_results"); | |
| if ( c.is(":visible") ) { | |
| c.hide(); | |
| $.publish("gs.menu.hide") | |
| } else { | |
| a.siblings("a.remove").addClass("hide"); | |
| a.val(""); | |
| this.inpageSearch(a) | |
| } | |
| return; | |
| case _.keys.UP: | |
| c.is(":first-child") ? $("#page_search_results li:last").addClass("selected") : c.prev().addClass("selected"); | |
| c.removeClass("selected"); | |
| return; | |
| case _.keys.DOWN: | |
| c.is(":last-child") ? $("#page_search_results li:first").addClass("selected") : c.next().addClass("selected"); | |
| c.removeClass("selected"); | |
| return | |
| } | |
| a.siblings("a.remove").toggleClass("hide", !a.val().length); | |
| this.inpageSearch(a) | |
| }, | |
| filterTimeout: false, | |
| searchTimeout: false, | |
| searchTimeoutWait: 100, | |
| inpageSearch: function( a ) { | |
| clearTimeout(this.searchTimeout); | |
| this.searchTimeout = setTimeout(this.callback(function() { | |
| if ( this.element ) { | |
| this.element.find(".gs_grid:last").controller(); | |
| var b = $.trim(a.val().toLowerCase()); | |
| if ( b.length > 0 ) GS.service.getAutocomplete(b, "artist", this.callback("autocompleteSuccess"), this.callback("autocompleteFail")); | |
| else { | |
| $("#page_search_results").hide(); | |
| $.publish("gs.menu.hide") | |
| } | |
| } | |
| }), this.searchTimeoutWait) | |
| }, | |
| inpageFilter: function( a ) { | |
| clearTimeout(this.filterTimeout); | |
| this.filterTimeout = setTimeout(this.callback(function() { | |
| if ( this.element ) { | |
| var b = this.element.find(".gs_grid:last").controller(), | |
| c = $.trim($(a).val().toLowerCase()); | |
| if ( b ) { | |
| var g = c; | |
| if ( $("#page").is(".gs_page_search") && _.isString(this.query) ) if ( c.indexOf(this.query.toLowerCase()) === 0 ) g = c.substring(this.query.length); | |
| b.searchString = $.trim(g); | |
| b.dataView.refresh() | |
| } else if ( $("#feed.events").length ) if ( c == "" ) $("#feed.events .event").show(); | |
| else { | |
| (new Date).getTime(); | |
| $("#feed.events .event").each(function() { | |
| var h = $(this); | |
| h.text().toLowerCase().indexOf(c) !== -1 ? h.show() : h.hide() | |
| }); | |
| (new Date).getTime() | |
| } | |
| else this.slickbox && this.filterUsers(c) | |
| } | |
| }), this.searchTimeoutWait) | |
| }, | |
| ".inPageSearchBar input focus": function( a ) { | |
| a.siblings(".placeholder").hide(); | |
| this.pageSearchHasFocus = true | |
| }, | |
| ".inPageSearchBar input blur": function( a ) { | |
| if (!a.val() ) { | |
| a.siblings(".placeholder").show(); | |
| a.siblings("a.remove").addClass("hide") | |
| } | |
| setTimeout(this.callback(function() { | |
| if (!this.pageSearchHasFocus ) { | |
| $("#page_search_results").hide(); | |
| $.publish("gs.menu.hide") | |
| } | |
| }), 500); | |
| this.pageSearchHasFocus = false | |
| }, | |
| ".inPageSearchBar .search-item a click": function( a ) { | |
| $("#page_search_results li.selected").removeClass("selected"); | |
| $(a).parent().addClass("selected"); | |
| $(a).is(".search-item") && a.closest("input").val($(a).text()); | |
| a.submit() | |
| }, | |
| ".inPageSearchBar a.icon click": function( a ) { | |
| a.siblings("input").focus().select() | |
| }, | |
| ".inPageSearchBar a.remove click": function( a ) { | |
| a.addClass("hide"); | |
| $("#page_search_results").hide(); | |
| $.publish("gs.menu.hide"); | |
| a.siblings("input").val("").focus(); | |
| a.parents("form").hasClass("inPageSearch") ? this.inpageSearch(a.siblings("input")) : this.inpageFilter(a.siblings("input")) | |
| }, | |
| ".inPageSearchBar submit": function( a, b ) { | |
| b.preventDefault(); | |
| GS.search = _.orEqual(GS.search, {}); | |
| GS.search.type = $(a).attr("data-search-type") || ""; | |
| var c = $("#page_search_results li.selected"); | |
| GS.search.query = c.is(".search-item-result") ? c.find("a").text() : $("input[name=q]", a).val(); | |
| if ( GS.search.query && GS.search.query.length ) { | |
| this.pageSearchHasFocus = false; | |
| GS.router.performSearch(GS.search.type, GS.search.query) | |
| } | |
| }, | |
| autocompleteSuccess: function( a ) { | |
| this.autocompleteResults = a; | |
| $("#page_search_results").html(this.view("/shared/pageSearchResults")); | |
| if ( this.pageSearchHasFocus ) { | |
| $("#page_search_results").show(); | |
| $.publish("gs.menu.show") | |
| } | |
| }, | |
| autocompleteFail: function() { | |
| $("#page_search_results").remove(".search_result").hide(); | |
| $.publish("gs.menu.hide") | |
| }, | |
| addAutocomplete: function( a ) { | |
| a = _.orEqual(a, $("#page").attr("class")); | |
| a.match(".gs_page_") || (a = ".gs_page_" + a); | |
| $("input.search.autocomplete", this.element).autocomplete({ | |
| scroll: true, | |
| matchSubset: false, | |
| selectFirst: false, | |
| source: function( b, c ) { | |
| if ( b = $.trim(b.term || b) ) { | |
| var g = [], | |
| h = $("#searchBar_precomplete"); | |
| h.hide(); | |
| GS.service.getAutocomplete(b, "artist", function( k ) { | |
| if ( $("#page").is(a) ) { | |
| k && k.length && $.each(k, function( p, n ) { | |
| n.hasOwnProperty("Name") && n.hasOwnProperty("ArtistID") && g.push({ | |
| label: n.Name.toLowerCase(), | |
| value: n.ArtistID | |
| }) | |
| }); | |
| if ( a == ".gs_page_home" && g.length ) { | |
| k = $("#searchBar_input input").val(); | |
| var m = g[0].label; | |
| m = [m.substring(0, k.length), m.substring(k.length)]; | |
| k == b && k.toLowerCase() == m[0] ? h.text(k + m[1]).show() : h.text("").hide() | |
| } else h.text("").hide(); | |
| c(g) | |
| } | |
| }, function() {}) | |
| } | |
| }, | |
| select: function( b, c ) { | |
| b.preventDefault(); | |
| if ( a == ".gs_page_home" && parseInt(c.item.value, 10) ) location.hash = "/artist/~/" + c.item.value; | |
| else $("input.search.autocomplete").val(c.item.label).submit() | |
| }, | |
| focus: function( b, c ) { | |
| b.preventDefault(); | |
| $("#searchBar_input input").val(c.item.label); | |
| $("#searchBar_precomplete").hide() | |
| }, | |
| close: function() { | |
| $("#searchBar_precomplete").show() | |
| } | |
| }) | |
| }, | |
| getPlayOptionsMenuForFeeds: function( a ) { | |
| return [{ | |
| title: $.localize.getString("PLAY_NOW"), | |
| action: { | |
| type: "fn", | |
| callback: function() { | |
| a.playSongs(-1, true) | |
| } | |
| }, | |
| customClass: "jj_menu_item_hasIcon jj_menu_item_play" | |
| }, { | |
| title: $.localize.getString("PLAY_NEXT"), | |
| action: { | |
| type: "fn", | |
| callback: function() { | |
| a.playSongs(-2, false) | |
| } | |
| }, | |
| customClass: "jj_menu_item_hasIcon jj_menu_item_play_next" | |
| }, { | |
| title: $.localize.getString("PLAY_LAST"), | |
| action: { | |
| type: "fn", | |
| callback: function() { | |
| a.playSongs(-3, false) | |
| } | |
| }, | |
| customClass: "jj_menu_item_hasIcon jj_menu_item_play_last" | |
| }, { | |
| title: $.localize.getString("REPLACE_QUEUE"), | |
| action: { | |
| type: "fn", | |
| callback: function() { | |
| a.playSongs(-4, true) | |
| } | |
| }, | |
| customClass: "jj_menu_item_hasIcon jj_menu_item_replace_playlist" | |
| }] | |
| }, | |
| scroll: function( a ) { | |
| $page = $(a); | |
| $controls = $(".page_controls"); | |
| $sticky = $(".page_controls .sticky"); | |
| $("#tooltip") && this.closeTooltip(); | |
| if ( $sticky.length ) { | |
| $sticky.width($controls.width()); | |
| $sticky.hasClass("fixed") || $controls.height($controls.height()); | |
| if ( $controls.offset().top < 59 ) $sticky.addClass("fixed"); | |
| else { | |
| $sticky.removeClass("fixed"); | |
| $controls.height("auto") | |
| } | |
| } | |
| }, | |
| "#feed.events .play.dropdownButton click": function( a, b ) { | |
| var c = $(a).closest(".event").data("event"); | |
| c ? a.jjmenu(b, this.getPlayOptionsMenuForFeeds(c), null, { | |
| xposition: "left", | |
| yposition: "auto", | |
| show: "default", | |
| className: "contextmenu", | |
| keepState: a | |
| }) : console.warn("feed data not attached") | |
| }, | |
| "#feed.events button[name=play] click": function( a ) { | |
| $(a).closest(".event").data("event").playSongs(-1, true) | |
| }, | |
| "#feed.events .event .songLink click": function( a, b ) { | |
| b.preventDefault(); | |
| var c = $(a).closest(".event"); | |
| c = $(c).data("event"); | |
| var g; | |
| c = GS.Models.Song.wrapCollection(c.data.songs); | |
| if ( _.defined($(a).attr("data-songid")) ) { | |
| g = parseInt($(a).attr("data-songid"), 10); | |
| g = GS.Models.Song.getOneFromCache(g) | |
| } else { | |
| var h = _.defined($(a).attr("data-song-index")) ? parseInt($(a).attr("data-song-index"), 10) : 0; | |
| if ( c.length > 0 ) g = c[h] | |
| } | |
| if ( g = g && $.isFunction(g.toUrl) ? g.toUrl() : false ) location.hash = g | |
| }, | |
| "#feed.events .event button.subscribe click": function( a ) { | |
| var b = | |
| $(a).closest(".event").data("event").data.playlists[0].playlistID; | |
| GS.Models.Playlist.getPlaylist(b, this.callback("subscribePlaylist", a), this.callback("subscribePlaylistError"), false) | |
| }, | |
| subscribePlaylist: function( a, b ) { | |
| if ( b.isSubscribed() ) { | |
| GS.user.removeFromPlaylistFavorites(b.PlaylistID); | |
| a.find("span.label").localeDataString("PLAYLIST_SUBSCRIBE") | |
| } else { | |
| GS.user.addToPlaylistFavorites(b.PlaylistID); | |
| a.find("span.label").localeDataString("PLAYLIST_UNSUBSCRIBE") | |
| } | |
| }, | |
| subscribePlaylistError: function() { | |
| $.publish("gs.notification", { | |
| type: "error", | |
| message: $.localize.getString("NOTIF_FAVORITE_ERROR_GENERAL") | |
| }) | |
| }, | |
| "#feed.events .event .showSongs click": function( a ) { | |
| a = $(a).closest(".event"); | |
| var b = $(a).data("event"), | |
| c = $(a).find(".songWrapper"), | |
| g = $(a).find(".songList"); | |
| if ( g.children().length ) c.toggle(); | |
| else { | |
| var h = GS.Models.Song.wrapCollection(b.data.songs); | |
| c.css("visibility", "hidden").show(); | |
| oldCols = GS.Controllers.GridController.columns.song.concat(); | |
| b = [oldCols[0], oldCols[1], oldCols[2]]; | |
| g.gs_grid(h, b, { | |
| sortCol: "Sort", | |
| padding: 0 | |
| }); | |
| $(window).resize(); | |
| c.css("visibility", "visible") | |
| } | |
| c = g.is(":visible") ? $.localize.getString("FEED_HIDE_SONGS") : $.localize.getString("FEED_VIEW_SONGS"); | |
| $(a).find("button.showSongs .label").text(c) | |
| }, | |
| "#feed.events .event .remove click": function( a ) { | |
| var b = $(a).closest(".event"); | |
| a = parseInt($(a).attr("rel"), 10); | |
| a == GS.user.UserID ? $(".warning", b).attr("data-translate-text", "FEED_REMOVE_ACTIVITY_WARNING").attr("rel", a).html($.localize.getString("FEED_REMOVE_ACTIVITY_WARNING")).show() : $(".warning", b).attr("data-translate-text", "FEED_HIDE_USER_WARNING").attr("rel", a).html($.localize.getString("FEED_HIDE_USER_WARNING")).show() | |
| }, | |
| "#feed.events .event .removeComment click": function( a ) { | |
| var b = $(a).closest(".feedComment"); | |
| a = $(a).attr("rel"); | |
| $(".warning", b).attr("data-translate-text", "FEED_REMOVE_COMMENT_WARNING").attr("rel", a).html($.localize.getString("FEED_REMOVE_COMMENT_WARNING")).show() | |
| }, | |
| "#feed.events .event .warning .yesRemove click": function( a ) { | |
| var b = $(a).closest(".event"), | |
| c = $(b).data("event"); | |
| a = parseInt($(a).parent().attr("rel"), 10); | |
| if ( a == GS.user.UserID ) { | |
| b.remove(); | |
| c.remove() | |
| } else { | |
| this.find("#feed .user_" + a).remove(); | |
| GS.user.changeFollowFlags([{ | |
| userID: a, | |
| flags: 1 | |
| }]) | |
| } | |
| $(".warning", b).hide() | |
| }, | |
| "#feed.events .event .warning .noRemove click": function( a ) { | |
| a = $(a).closest(".event"); | |
| $(".warning", a).hide() | |
| }, | |
| "#feed.events .event .warning .yesRemoveComment click": function( a ) { | |
| var b = $(a).closest(".event"), | |
| c = $(a).closest(".feedComment"); | |
| a = $(a).parents(".warning").attr("rel"); | |
| var g = $(b).data("event"); | |
| g.removeComment(a); | |
| c.remove(); | |
| if ( g.comments.length ) g.comments.length == 1 ? b.find(".showCommentForm .label").html($.localize.getString("FEED_COMMENTS_COUNT_ONE")) : b.find(".showCommentForm .label").html(_.getString("FEED_COMMENTS_COUNT", { | |
| count: g.comments.length | |
| })); | |
| else { | |
| b.find(".commentWrapper").hide(); | |
| b.find(".showCommentForm .label").html($.localize.getString("FEED_COMMENT")) | |
| } | |
| }, | |
| "#feed.events .event .warning .noRemoveComment click": function( a ) { | |
| a = $(a).closest(".feedComment"); | |
| $(".warning", a).hide() | |
| }, | |
| "#feed.events .event .showCommentForm click": function( a ) { | |
| if (!$(b).find(".commentFormWrapper").hasClass("hide") ) { | |
| var b = $(a).closest(".event"); | |
| $(b).data("event"); | |
| var c = | |
| $(b).find(".commentFormWrapper"); | |
| c.html(this.view("community/eventCommentForm")) | |
| } | |
| c.find(".message").select() | |
| }, | |
| ".feedCommentForm .message keydown": function( a, b ) { | |
| if ( b.which == _.keys.ENTER ) return false | |
| }, | |
| ".feedCommentForm .message keyup": function( a, b ) { | |
| if ( b.which == _.keys.ENTER ) { | |
| b.preventDefault(); | |
| b.stopPropagation(); | |
| a.parents(".feedCommentForm").submit(); | |
| return false | |
| } | |
| }, | |
| ".feedCommentForm submit": function( a, b ) { | |
| b.preventDefault(); | |
| var c = $(a).closest(".event"), | |
| g = $(c).data("event"), | |
| h = $("textarea[name=message]", c).val(), | |
| k = $(".feedCommentForm .error"); | |
| h = $.trim(h); | |
| if ( h.length ) { | |
| k.hide(); | |
| g.addComment(h, this.callback(this.commentSuccess, c), this.callback(this.commentFailed, c)) | |
| } else k.show().find(".message").html($.localize.getString("FEED_COMMENT_ERROR_EMPTY")) | |
| }, | |
| commentSuccess: function( a, b ) { | |
| if ( b ) { | |
| var c = $(a).data("event"); | |
| $(a).find(".commentFormWrapper").html(""); | |
| $(a).find(".commentWrapper").append(this.view("community/eventComments", { | |
| comments: [c.comments[c.comments.length - 1]], | |
| event: c | |
| })).show(); | |
| c.comments.length == 1 ? a.find(".showCommentForm .label").html($.localize.getString("FEED_COMMENTS_COUNT_ONE")) : a.find(".showCommentForm .label").html(_.getString("FEED_COMMENTS_COUNT", { | |
| count: c.comments.length | |
| })) | |
| } else this.commentFailed(a, b) | |
| }, | |
| commentFailed: function( a, b ) { | |
| $(".feedCommentForm .error").show().find(".message").html($.localize.getString("FEED_COMMENT_ERROR")); | |
| console.warn("commentFailed", b) | |
| }, | |
| "#feed.events .event .showMoreComments click": function( a ) { | |
| var b = $(a).closest(".event"), | |
| c = $(b).data("event"); | |
| $(b).find(".commentWrapper").html(this.view("community/eventComments", { | |
| comments: c.comments, | |
| event: c | |
| })); | |
| $(a).remove() | |
| }, | |
| ".feeds_loadMore click": function( a ) { | |
| if ( this.feed ) { | |
| this.feed.next(this.callback("showNextFeedPage")); | |
| $(".showMore", a).hide().siblings().show() | |
| } | |
| }, | |
| showNextFeedPage: function( a ) { | |
| if ( a && a.length ) { | |
| this.activity = a; | |
| $("#feed").append(this.view("/user/community/feedEvents")); | |
| for ( var b = 0; b < a.length; b++ ) { | |
| event = a[b]; | |
| $event = $("#feedEvent_" + event.eventID).data("event", event); | |
| event.dataString && event.dataString.hookup($event.find("p.what")) | |
| } | |
| } | |
| $(".feeds_loadMore .loading").hide().siblings().show(); | |
| this.feed.hasMore || $(".feeds_loadMore").hide() | |
| }, | |
| ".slick-row .song .options .favorite click": function( a ) { | |
| var b = a.attr("rel"), | |
| c = parseInt($(a).parents(".slick-row").attr("row")), | |
| g = c + 1, | |
| h = ""; | |
| if ( $("#grid").controller() ) h = $("#grid").controller().data[c].ppVersion; | |
| c = { | |
| songID: b, | |
| rank: g | |
| }; | |
| if ( h ) c.ppVersion = h; | |
| if ( a.is(".isFavorite") ) { | |
| GS.user.removeFromSongFavorites(b); | |
| a.removeClass("isFavorite") | |
| } else { | |
| GS.user.addToSongFavorites(b); | |
| a.addClass("isFavorite"); | |
| GS.getGuts().songItemFavoriteClick(c) | |
| } | |
| }, | |
| ".slick-row .song .options .library click": function( a ) { | |
| var b = | |
| a.attr("rel"), | |
| c = parseInt($(a).parents(".slick-row").attr("row")), | |
| g = c + 1, | |
| h = $("#grid"), | |
| k = ""; | |
| if ( h.controller() ) { | |
| h = h.controller().data; | |
| if ( h[c] && h[c].ppVersion ) k = h[c].ppVersion | |
| } | |
| c = { | |
| songID: b, | |
| rank: g | |
| }; | |
| if ( k ) c.ppVersion = k; | |
| if ( a.parent().is(".inLibrary") ) { | |
| GS.user.removeFromLibrary(b); | |
| a.parent().removeClass("inLibrary") | |
| } else { | |
| GS.user.addToLibrary([b]); | |
| a.parent().addClass("inLibrary"); | |
| GS.getGuts().songItemLibraryClick(c) | |
| } | |
| }, | |
| ".slick-row .playlist .subscribe click": function( a ) { | |
| console.log("in here"); | |
| var b = a.attr("rel"); | |
| if ( GS.Models.Playlist.getOneFromCache(b).isSubscribed() ) { | |
| GS.user.removeFromPlaylistFavorites(b); | |
| a.removeClass("subscribed").find("span.label").text($.localize.getString("PLAYLIST_SUBSCRIBE")) | |
| } else { | |
| GS.user.addToPlaylistFavorites(b); | |
| a.addClass("subscribed").find("span.label").text($.localize.getString("PLAYLIST_UNSUBSCRIBE")) | |
| } | |
| }, | |
| ".slick-cell.song a.more click": function( a, b ) { | |
| var c = $(a).attr("rel"); | |
| c = GS.Models.Song.getOneFromCache(c); | |
| var g = $(a).parents(".slick-row").attr("row"), | |
| h = $(a).parents(".gs_grid").controller(), | |
| k = {}, | |
| m; | |
| if ( $("#page").is(".gs_page_now_playing") ) { | |
| m = c.queueSongID; | |
| k = { | |
| isQueue: true, | |
| flagSongCallback: function( p ) { | |
| GS.player.flagSong(m, p) | |
| } | |
| } | |
| } | |
| if ( $("div.gridrow" + g).is(":visible") ) { | |
| $("div.gridrow" + g).hide(); | |
| a.removeClass("active-context") | |
| } else { | |
| k = { | |
| menuType: "songOptionMenu", | |
| multiClick: false, | |
| gridController: h | |
| }; | |
| a.addClass("active-context").jjmenu(b, c.getContextMenu(k), null, { | |
| xposition: "left", | |
| yposition: "auto", | |
| show: "show", | |
| className: "rowmenu gridrow" + g, | |
| keepState: a | |
| }) | |
| } | |
| h.currentRow = g; | |
| h.grid.setSelectedRows([g]); | |
| h.grid.onSelectedRowsChanged() | |
| }, | |
| playClickSongID: false, | |
| ".slick-cell.song a.play click": function( a, b ) { | |
| var c = parseInt(a.attr("rel"), 10), | |
| g = GS.player.getCurrentQueue(), | |
| h = GS.player.isPlaying; | |
| isPaused = GS.player.isPaused; | |
| if ( this.playClickSongID != c ) { | |
| this.playClickSongID = c; | |
| row = $(a).parents(".slick-row").attr("row"); | |
| rank = parseInt(row) + 1; | |
| this.playClickSongID = c; | |
| row = parseInt($(a).parents(".slick-row").attr("row"), 10); | |
| rank = row + 1; | |
| var k = ""; | |
| if ( $("#grid").controller() ) { | |
| var m = $("#grid").controller().data; | |
| if ( m[rank - 1] ) k = m[rank - 1].ppVersion | |
| } | |
| gutsInfo = | |
| k ? { | |
| songID: c, | |
| rank: rank, | |
| ppVersion: k | |
| } : { | |
| songID: c, | |
| rank: rank | |
| }; | |
| row = $(a).parents(".slick-row").attr("row"); | |
| rank = parseInt(row) + 1; | |
| if ( a.parents(".slick-row.active").length && g.activeSong.SongID == c ) if (!h && !isPaused ) { | |
| $(a).removeClass("paused"); | |
| GS.player.playSong(c) | |
| } else if ( h ) { | |
| $(a).addClass("paused"); | |
| GS.player.pauseSong() | |
| } else { | |
| $(a).removeClass("paused"); | |
| GS.player.resumeSong() | |
| } | |
| else if ( $("#page").is(".gs_page_now_playing") ) { | |
| b.stopImmediatePropagation(); | |
| GS.player.playSong($(a).parents(".slick-row").attr("rel")) | |
| } else if ( $(a).parents(".gs_grid.hasSongs").length ) { | |
| GS.player.addSongsToQueueAt([c], GS.player.INDEX_DEFAULT, false, this.getPlayContext()); | |
| GS.getGuts().logEvent("songItemAddButton", gutsInfo) | |
| } else { | |
| GS.player.addSongAndPlay(c, this.getPlayContext()); | |
| GS.getGuts().logEvent("songItemPlayButton", gutsInfo) | |
| } | |
| setTimeout(this.callback(function() { | |
| this.playClickSongID = false | |
| }), 500); | |
| return false | |
| } | |
| }, | |
| ".slick-row.event .event_tickets click": function( a, b ) { | |
| var c = a.parents(".slick-row").attr("row"); | |
| c = $("#grid").controller().dataView.getItemByIdx(c); | |
| if (!$(b.target).is("a[href]") && c && c.TicketsURL ) { | |
| window.open(c.TicketsURL, "_blank"); | |
| GS.getGuts().gaTrackEvent("grid", "eventClick", c.TicketsURL); | |
| return false | |
| } | |
| }, | |
| "#searchForm, #homeSearch submit": function( a, b ) { | |
| b.preventDefault(); | |
| var c = $("input[name=q]", a).val(); | |
| if ( c.substring(0, 2).toLowerCase() == "gs" ) switch ( c.toLowerCase() ) { | |
| case "GS.google.lasterror": | |
| alert(JSON.stringify(GS.getGoogle().lastError)); | |
| return false; | |
| case "GS.facebook.lasterror": | |
| alert(JSON.stringify(GS.getFacebook().lastError)); | |
| return false; | |
| case "GS.lastfm.lasterror": | |
| alert(JSON.stringify(GS.getLastfm().lastError)); | |
| return false | |
| } | |
| else if ( c.toLowerCase() == "floppy music" || c.toLowerCase() == "floppy drive music" ) GS.getYoutube().loadFloppyMusic(); | |
| else if ( c.toLowerCase() == "about:dubstep" || c.toLowerCase() == "how do i dubstep" ) GS.getYoutube().loadDubstep(); | |
| else if ( c.toLowerCase() == "about:christmas" ) { | |
| GS.Models.Station.makeChristmasHappen(); | |
| return | |
| } | |
| GS.search = _.orEqual(GS.search, {}); | |
| GS.search.query = c; | |
| GS.search.type = $(a).attr("data-search-type") || ""; | |
| GS.search.query && GS.search.query.length && GS.router.performSearch(GS.search.type, GS.search.query); | |
| return false | |
| }, | |
| "a.searchLink click": function( a, b ) { | |
| b.preventDefault(); | |
| var c = a.data("searchtype"), | |
| g = a.data("searchquery"); | |
| c = c ? c : ""; | |
| g = g ? g : ""; | |
| GS.router.performSearch(c, g) | |
| }, | |
| "#feed .what>a click": function( a, b ) { | |
| GS.getGuts().handleFeedEventClick(a, b) | |
| }, | |
| "#feed li.option click": function( a, b ) { | |
| GS.getGuts().handleFeedEventClick(a, b) | |
| }, | |
| "#feed li.show click": function( a, b ) { | |
| GS.getGuts().handleFeedEventClick(a, b) | |
| }, | |
| "#searchArtists a click": function( a, b ) { | |
| GS.getGuts().handleSearchSidebarClick(a, b, "artist") | |
| }, | |
| "#searchAlbums a click": function( a, b ) { | |
| GS.getGuts().handleSearchSidebarClick(a, b, "album") | |
| }, | |
| "#searchPlaylists a click": function( a, b ) { | |
| GS.getGuts().handleSearchSidebarClick(a, b, "playlist") | |
| }, | |
| "#searchUsers a click": function( a, b ) { | |
| GS.getGuts().handleSearchSidebarClick(a, b, "user") | |
| }, | |
| "a.follow, button.follow click": function( a ) { | |
| var b = parseInt($(a).attr("data-follow-userid"), 10), | |
| c = _.orEqual($(a).attr("data-cachePrefix"), ""), | |
| g = "", | |
| h = function() { | |
| if ( a.is(".following") ) { | |
| GS.user.removeFromUserFavorites(b); | |
| a.removeClass("following").addClass("add"); | |
| g = "FOLLOW" | |
| } else { | |
| GS.user.addToUserFavorites(b); | |
| a.addClass("following").removeClass("add"); | |
| g = "FOLLOWING" | |
| } | |
| a.find("span.label").attr("data-translate-text", g).text($.localize.getString(g)) | |
| }; | |
| GS.Models.User.getOneFromCache(b, c) ? h() : GS.Models.User.getUser(b, h, null, false) | |
| }, | |
| "a.signup, button.signup click": function() { | |
| location.hash = "#/signup" | |
| }, | |
| "a.login, button.login click": function() { | |
| GS.getLightbox().open("login") | |
| }, | |
| "a.uploadMusic, button.uploadMusic click": function() { | |
| GS.user.isLoggedIn ? window.open("http://" + location.host + "/upload", "_blank") : GS.getLightbox().open("login") | |
| }, | |
| "a.saveQueue, button.saveQueue click": function() { | |
| GS.player.saveQueue() | |
| }, | |
| "a.newPlaylist, button.newPlaylist click": function() { | |
| GS.getLightbox().open("newPlaylist") | |
| }, | |
| "a.inviteFriends, button.inviteFriends click": function() { | |
| GS.getLightbox().open("invite") | |
| }, | |
| "select.launchStation change": function( a ) { | |
| (a = $(a).val()) && GS.player.setAutoplay(true, a) | |
| }, | |
| "select change": function( a ) { | |
| $(a).prev("span").text($(a).find("option:selected").html()) | |
| }, | |
| "button.playRecent click": function() { | |
| if ( this.feed ) this.feed.play(GS.player.INDEX_DEFAULT, true); | |
| else this.user && this.user.profileFeed.play(GS.player.INDEX_DEFAULT, true) | |
| }, | |
| "button.playDropdownRecent click": function( a, b ) { | |
| this.user && a.jjmenu(b, this.getPlayMenu(), null, { | |
| xposition: "left", | |
| yposition: "auto", | |
| show: "default", | |
| className: "contextmenu", | |
| keepState: a | |
| }) | |
| }, | |
| "button.refresh click": function( a ) { | |
| feedType = $(a).attr("data-feed-type"); | |
| if (!GS.page.refreshed || GS.page.refreshed.type !== this.feed.type || GS.page.refreshed.user !== this.user.UserID ) { | |
| switch ( this.feed.type ) { | |
| case "profile": | |
| this.user.UserID == GS.user.UserID ? this.loadMyProfile(GS.user) : this.loadProfile(this.user); | |
| break; | |
| case "community": | |
| this.user.communityFeed.isDirty = true; | |
| this.user.UserID == GS.user.UserID || this.UserID == -1 ? this.loadMyCommunity(this.user) : this.loadCommunity(this.user); | |
| break | |
| } | |
| GS.page.refreshed = { | |
| type: this.feed.type, | |
| user: this.user.UserID | |
| }; | |
| GS.page.resetRefreshButton() | |
| } | |
| }, | |
| "button.followArtist click": function( a ) { | |
| var b = a.attr("data-artistid"); | |
| GS.Models.Artist.getArtist(b, function() { | |
| if ( GS.user.favorites.artists.hasOwnProperty(b) ) { | |
| GS.user.removeFromArtistFavorites(b, true); | |
| a.attr("title", ""); | |
| $(".artistID" + b).removeClass("following").addClass("plus").find("span.label").attr("data-translate-text", "ARTIST_FOLLOW").text($.localize.getString("ARTIST_FOLLOW")) | |
| } else { | |
| GS.user.addToArtistFavorites(b, true); | |
| a.attr("title", $.localize.getString("UNFOLLOW")); | |
| $(".artistID" + b).removeClass("plus").addClass("following").find("span.label").attr("data-translate-text", "ARTIST_FOLLOWING").text($.localize.getString("ARTIST_FOLLOWING")) | |
| } | |
| }, null, false) | |
| }, | |
| "button.subscribePlaylist click": function( a ) { | |
| var b = | |
| a.attr("data-playlistid"); | |
| GS.Models.Playlist.getPlaylist(b, function() { | |
| if ( GS.user.favorites.playlists.hasOwnProperty(b) ) { | |
| GS.user.removeFromPlaylistFavorites(b, false); | |
| $(".playlistID" + b).removeClass("subscribed").addClass("plus").find("span.label").attr("data-translate-text", $.localize.getString("PLAYLIST_SUBSCRIBE")).text($.localize.getString("PLAYLIST_SUBSCRIBE")) | |
| } else { | |
| GS.user.addToPlaylistFavorites(b, false); | |
| $(".playlistID" + b).removeClass("plus").addClass("subscribed").find("span.label").attr("data-translate-text", $.localize.getString("PLAYLIST_SUBSCRIBED")).text($.localize.getString("PLAYLIST_SUBSCRIBED")) | |
| } | |
| }, null, false) | |
| }, | |
| "button.librarySong click": function( a ) { | |
| a = a.attr("data-songid"); | |
| if ( GS.user.library.songs.hasOwnProperty(a) ) { | |
| GS.user.removeFromLibrary(a, false); | |
| $(".songID" + a).removeClass("inLibrary").addClass("plus").find("span.label").attr("data-translate-text", $.localize.getString("SONG_ADD_LIBRARY")).text($.localize.getString("SONG_ADD_LIBRARY")) | |
| } else { | |
| GS.user.addToLibrary(a, false); | |
| $(".songID" + a).removeClass("plus").addClass("inLibrary").find("span.label").attr("data-translate-text", $.localize.getString("SONG_IN_LIBRARY")).text($.localize.getString("SONG_IN_LIBRARY")) | |
| } | |
| }, | |
| currentTipElement: null, | |
| tooltipTimer: null, | |
| ".tooltip mouseover": function( a ) { | |
| clearTimeout(this.toolTipTimer); | |
| if ( this.currentTipElement != a.get(0) ) { | |
| this.currentTipElement = a.get(0); | |
| a = $(a); | |
| var b = a.attr("data-tip-type"), | |
| c = null, | |
| g = null, | |
| h = a.offset(), | |
| k = h.left + a.width() + 350 > $("body").width() ? "left" : "right"; | |
| $("#tooltip").stop().remove(); | |
| switch ( b ) { | |
| case "song": | |
| g = GS.Models.Song.getOneFromCache(a.attr("data-SongID"), a.attr("data-cachePrefix")); | |
| break; | |
| case "artist": | |
| g = GS.Models.Artist.getOneFromCache(a.attr("data-ArtistID"), a.attr("data-cachePrefix")); | |
| break; | |
| case "playlist": | |
| g = GS.Models.Playlist.getOneFromCache(a.attr("data-PlaylistID"), a.attr("data-cachePrefix")); | |
| break; | |
| case "album": | |
| g = GS.Models.Album.getOneFromCache(a.attr("data-AlbumID"), a.attr("data-cachePrefix")); | |
| break; | |
| case "video": | |
| g = GS.Models.Video.getOneFromCache(a.attr("data-VideoID"), a.attr("data-cachePrefix")); | |
| break | |
| } | |
| if ( g ) c = $(this.view("/shared/tooltips/" + b, { | |
| data: g, | |
| direction: k | |
| })); | |
| if ( g ) { | |
| k == "left" ? c.css({ | |
| top: h.top, | |
| right: h.left - 5 | |
| }) : c.css({ | |
| top: h.top, | |
| left: h.left + a.width() + 5 | |
| }); | |
| $("body").append(c.hide().delay(500).fadeIn("fast")) | |
| } | |
| } | |
| }, | |
| ".tooltip mouseout": function() { | |
| this.toolTipTimer = setTimeout(this.callback("closeTooltip"), 500) | |
| }, | |
| closeTooltip: function() { | |
| clearTimeout(this.tooltipTimer); | |
| this.tooltipTimer = this.currentTipElement = null; | |
| $("#tooltip").stop().fadeOut(50, function() { | |
| $(this).remove() | |
| }) | |
| }, | |
| ".sliderBtn click": function( a, b ) { | |
| b.preventDefault(); | |
| var c = a.siblings(".page_content_sliderViewport").children(".page_content_slider"); | |
| if (!c.hasClass("sliding") ) { | |
| c.addClass("sliding"); | |
| var g = c.position(), | |
| h = c.outerWidth(), | |
| k = c.parent(".page_content_sliderViewport").width(), | |
| m = c.children(".page_content_slide:first").outerWidth(true), | |
| p = Math.floor(k / m), | |
| n = Math.floor((h + g.left) / m), | |
| o = c.children(".page_content_slide").length, | |
| t = Math.floor((Math.abs(g.left) + k) / m); | |
| h = -(h - k); | |
| if ( a.hasClass("sliderNext") ) if ( t >= o ) c.animate({ | |
| left: g.left - 40 | |
| }, 100, function() { | |
| c.animate({ | |
| left: g.left | |
| }, 400, "swing", function() { | |
| c.removeClass("sliding") | |
| }) | |
| }); | |
| else { | |
| m = g.left - p * m; | |
| c.animate({ | |
| left: Math.max(h, m) | |
| }, 1E3, "swing", function() { | |
| c.removeClass("sliding") | |
| }) | |
| } | |
| else if ( t - n < p && g.left != 0 ) { | |
| m = 0; | |
| c.animate({ | |
| left: m | |
| }, 1E3, "swing", function() { | |
| c.removeClass("sliding") | |
| }) | |
| } else if ( g.left != 0 ) { | |
| m = g.left + p * m; | |
| console.log("Animated to: ", m); | |
| c.animate({ | |
| left: Math.min(m, 0) | |
| }, 1E3, "swing", function() { | |
| c.removeClass("sliding") | |
| }) | |
| } else c.animate({ | |
| left: 40 | |
| }, 100, function() { | |
| c.animate({ | |
| left: 0 | |
| }, 400, "swing", function() { | |
| c.removeClass("sliding") | |
| }) | |
| }) | |
| } | |
| }, | |
| ".slide_playBtn click, .playBtn click": function( a, b ) { | |
| b.preventDefault(); | |
| var c = !(GS.player.queue && GS.player.queue.activeSong); | |
| if ( a.attr("data-playlistid") ) GS.Models.Playlist.getPlaylist(a.attr("data-playlistid"), function( h ) { | |
| h.play(-1, true) | |
| }); | |
| else if ( a.attr("data-songid") ) if ( a.attr("data-eventid") && this.feed && this.feed.cache && this.feed.cache[a.attr("data-eventid")] ) { | |
| var g = _.orEqual(a.attr("data-index"), 0); | |
| (g = GS.Models.Song.wrap(this.feed.cache[a.attr("data-eventid")].data.songs[g])) && GS.player.addSongsToQueueAt([g.SongID], -1, c) | |
| } else GS.player.addSongsToQueueAt([a.attr("data-songid")], -1, c); | |
| else a.attr("data-albumid") ? GS.Models.Album.getAlbum(a.attr("data-albumid"), function( h ) { | |
| h.play(-1, true) | |
| }) : console.warn("Not a valid data attribute") | |
| }, | |
| ".songLink click": function( a, b ) { | |
| b.preventDefault(); | |
| var c; | |
| if ( c = a.attr("data-songid") ) if ( c = (c = GS.Models.Song.getOneFromCache(c) ? GS.Models.Song.getOneFromCache(c) : GS.Models.Song.getSong(c)) && $.isFunction(c.toUrl) ? c.toUrl() : false ) location.hash = c | |
| }, | |
| sliderOrBoxDragSetup: function( a, b ) { | |
| a.unbind("draginit").unbind("dragstart").unbind("drag").unbind("dragend"); | |
| a.bind("draginit", function( c, g ) { | |
| var h = $(c.target).closest(b); | |
| if ( h.length === 0 ) return false; | |
| g.draggedItemID = h.attr("data-dragid"); | |
| g.draggedItemsType = h.attr("data-dragtype"); | |
| if (!g.draggedItemID || !g.draggedItemsType ) return false; | |
| g.proxyOffsetX = c.clientX - h.offset().left; | |
| g.proxyOffsetY = c.clientY - h.offset().top | |
| }).bind("dragstart", function( c, g ) { | |
| var h, k; | |
| h = GS.Controllers.PageController.getActiveController(); | |
| g.draggedItemsContext = h.getPlayContext(); | |
| g.draggedItems = []; | |
| g.draggedItemsSource = "grid"; | |
| switch ( g.draggedItemsType ) { | |
| case "album": | |
| k = | |
| GS.Models.Album.getOneFromCache(parseInt(g.draggedItemID, 10)); | |
| break; | |
| case "playlist": | |
| k = GS.Models.Playlist.getOneFromCache(parseInt(g.draggedItemID, 10)); | |
| break; | |
| case "artist": | |
| k = GS.Models.Artist.getOneFromCache(parseInt(g.draggedItemID, 10)); | |
| break; | |
| case "user": | |
| k = GS.Models.User.getOneFromCache(parseInt(g.draggedItemID, 10)); | |
| break; | |
| case "song": | |
| k = GS.Models.Song.getOneFromCache(parseInt(g.draggedItemID, 10)); | |
| break | |
| } | |
| if (!k ) return false; | |
| g.draggedItems.push(k); | |
| h = $('<div class="dragProxy slick-reorder-proxy"><div class="status"></div><span class="info"><span class="text"></span></span></div>').css({ | |
| position: "absolute", | |
| zIndex: "99999", | |
| "min-height": "50px", | |
| "padding-right": "50px" | |
| }).appendTo("body").mousewheel(_.globalDragProxyMousewheel); | |
| $.isFunction(k.toProxyLabel) ? h.find(".text").html(k.toProxyLabel()) : h.find(".text").html(k.toString()); | |
| g.proxyOffsetX = Math.floor(h.width() / 2) + 15; | |
| g.proxyOffsetY = h.height() * 2 - 52; | |
| $.publish("gs.drag.start", g); | |
| return h | |
| }).bind("drag", function( c, g ) { | |
| g.clientX = c.clientX; | |
| g.clientY = c.clientY; | |
| $(g.proxy).css("top", c.clientY - g.proxyOffsetY).css("left", c.clientX - g.proxyOffsetX); | |
| var h = false, | |
| k = false; | |
| _.forEach(g.drop, function( m ) { | |
| $.isFunction(m.updateDropOnDrag) && m.updateDropOnDrag(c, g); | |
| if (!h ) if ( $(m).within(c.clientX, c.clientY).length > 0 ) if ( $(m).data("ignoreForOverDrop") ) k = true; | |
| else { | |
| k = false; | |
| h = true | |
| } | |
| }); | |
| k || (h ? $(g.proxy).addClass("valid").removeClass("invalid") : $(g.proxy).addClass("invalid").removeClass("valid")) | |
| }).bind("dragend", function( c, g ) { | |
| $(g.proxy).remove(); | |
| $.publish("gs.drag.end", g) | |
| }) | |
| }, | |
| likeWidth: "48px", | |
| likeWidthCache: {}, | |
| loadLikeButtonCount: function( a, b ) { | |
| if (!b && this.likeWidthCache[a] ) { | |
| this.likeWidth = | |
| this.likeWidthCache[a]; | |
| $("#page_content_social_buttons .fblike").css("width", this.likeWidth) | |
| } | |
| GS.getFacebook().queryFQL('SELECT total_count FROM link_stat WHERE url="' + a + '"', this.callback(function( c ) { | |
| if ( c[0].total_count ) { | |
| this.likeWidth = c[0].total_count > 1E4 ? "80px" : c[0].total_count > 1E3 ? "77px" : c[0].total_count > 100 ? "80px" : c[0].total_count > 10 ? "77px" : c[0].total_count > 0 ? "77px" : "48px"; | |
| $("#page_content_social_buttons .fblike").css("width", this.likeWidth); | |
| this.likeWidthCache[a] = this.likeWidth | |
| } | |
| }), this.callback(function() { | |
| this.likeWidth = "48px"; | |
| $("#page_content_social_buttons .fblike").css("width", this.likeWidth) | |
| })) | |
| } | |
| }) | |
| })(); | |
| GS.Controllers.BaseController.extend("GS.Controllers.RapLeafController", { | |
| isGSSingleton: true, | |
| preSetup: function() { | |
| $.subscribe("gs.auth.update", GS.Controllers.BaseController.singletonCallback("rapleaf", "update")) | |
| } | |
| }, { | |
| personalizeMapTheme: { | |
| "4097253982": "10=2", | |
| "4097253968": "10=2", | |
| "4097253992": "10=3", | |
| "4097253999": "10=4", | |
| "4097254011": "10=5", | |
| "4097254001": "10=5", | |
| "4097254007": "10=5", | |
| "4097253897": "1=0", | |
| "4097253890": "1=1" | |
| }, | |
| personalizeMapSidebar: { | |
| "4097253982": "10=2", | |
| "4097253968": "10=2", | |
| "4097253992": "10=3", | |
| "4097253999": "10=4", | |
| "4097254011": "10=5", | |
| "4097254001": "10=5", | |
| "4097254007": "10=5", | |
| "4097253897": "1=0", | |
| "4097253890": "1=1" | |
| }, | |
| init: function() { | |
| this._super() | |
| }, | |
| appReady: function() { | |
| this.onPersonalize() | |
| }, | |
| update: function() { | |
| this.onPersonalize() | |
| }, | |
| onPersonalize: function() { | |
| if (!GS.user.IsPremium && !GS.user.isLoggedIn ) { | |
| var a = GS.store.get("webvisit"); | |
| a ? this.updateParams(a) : $.getScript("http://rd.rlcdn.com/rd?type=js&site=108574", this.callback("onPersonalizeCallback")) | |
| } | |
| }, | |
| updateParams: function( a ) { | |
| for ( var b = 0; b < a.theme.length; b++ ) { | |
| if ( a.theme[b].indexOf("0=") == 0 ) { | |
| a.theme[b] = a.theme[b].replace("0=18-24", "10=2"); | |
| a.theme[b] = a.theme[b].replace("0=25-34", "10=3"); | |
| a.theme[b] = a.theme[b].replace("0=35-44", "10=4"); | |
| a.theme[b] = a.theme[b].replace("0=50-", "10=5") | |
| } | |
| if ( a.sidebar[b].indexOf("AgeRange=") == 0 ) { | |
| a.sidebar[b] = a.sidebar[b].replace("AgeRange=18-24", "10=2"); | |
| a.sidebar[b] = a.sidebar[b].replace("AgeRange=25-34", "10=3"); | |
| a.sidebar[b] = a.sidebar[b].replace("AgeRange=35-44", "10=4"); | |
| a.sidebar[b] = a.sidebar[b].replace("AgeRange=50-", "10=5") | |
| } else if ( a.sidebar[b].indexOf("Gender=M") == 0 ) a.sidebar[b] = a.sidebar[b].replace("Gender=M", "1=0"); | |
| else if ( a.sidebar[b].indexOf("Gender=F") == 0 ) a.sidebar[b] = a.sidebar[b].replace("Gender=F", "1=1") | |
| } | |
| GS.store.set("webvisit", a) | |
| }, | |
| onPersonalizeCallback: function() { | |
| if ( _rlcdnsegs && _rlcdnsegs.length ) { | |
| for ( var a = { | |
| theme: [], | |
| sidebar: [] | |
| }, b = 0; b < _rlcdnsegs.length; b++ ) | |
| try { | |
| a.theme.push(this.personalizeMapTheme[_rlcdnsegs[b].toString()]); | |
| a.sidebar.push(this.personalizeMapSidebar[_rlcdnsegs[b].toString()]) | |
| } catch (c) { | |
| console.warn("[ Personalize Out of Bounds ]") | |
| } | |
| GS.store.set("webvisit", a); | |
| b = {}; | |
| b.params = a.sidebar.toString(); | |
| jQuery.isEmptyObject(b) || GS.getGuts().logEvent("rapleafCollectedData", b) | |
| } else GS.store.remove("webvisit") | |
| } | |
| }); | |
| GS.Controllers.BaseController.extend("GS.Controllers.KruxController", { | |
| isGSSingleton: true, | |
| preSetup: function() { | |
| var a = GS.Controllers.BaseController.singletonCallback; | |
| $.subscribe("gs.auth.update", a("krux", "update")); | |
| $.subscribe("gs.app.ready", a("krux", "update")) | |
| } | |
| }, { | |
| ksgmnts: null, | |
| kuid: null, | |
| kruxTimeoutID: null, | |
| kruxMap: { | |
| lpza0398b: "k=lpza0398b" | |
| }, | |
| init: function() { | |
| this._super() | |
| }, | |
| update: function() { | |
| this.onPersonalize() | |
| }, | |
| onPersonalize: function() { | |
| if ( GS.user.IsPremium ) clearTimeout(this.kruxTimeoutID); | |
| else { | |
| if ( GS.user.isLoggedIn ) { | |
| var a = {}; | |
| if ( GS.user.Sex ) a["1"] = GS.user.Sex.toLowerCase() == "m" ? "0" : "1"; | |
| if ( GS.user.TSDOB ) { | |
| var b = GS.user.TSDOB.split("-"); | |
| if ( b.length == 3 ) { | |
| var c = new Date, | |
| g = c.getFullYear() - parseInt(b[0], 10); | |
| if ( parseInt(b[1], 10) > c.month ) g -= 1; | |
| else if ( parseInt(b[1], 10) == c.month && parseInt(b[2], 10) > c.date ) g -= 1; | |
| var h; | |
| if ( g >= 13 && g < 18 ) h = "1"; | |
| else if ( g >= 18 && g < 25 ) h = "2"; | |
| else if ( g >= 25 && g < 35 ) h = "3"; | |
| else if ( g >= 35 && g < 50 ) h = "4"; | |
| else if ( g >= 50 ) h = "5" | |
| } | |
| a["10"] = h; | |
| a["14"] = GS.getAd().encodeInteger(g) | |
| } | |
| try { | |
| a["0"] = GS.getAd().locales[GS.getLocale().locale] | |
| } catch (k) { | |
| a["0"] = "0=1" | |
| } | |
| window.KRUXSetup = { | |
| pubid: "b5c2e077-e8aa-4ed6-9bf5-d6e958d0e2ca", | |
| site: "Grooveshark.com", | |
| section: "Listen", | |
| sub_section: "Rock", | |
| async: true, | |
| userAttributes: a | |
| } | |
| } else window.KRUXSetup = { | |
| pubid: "b5c2e077-e8aa-4ed6-9bf5-d6e958d0e2ca", | |
| site: "Grooveshark.com", | |
| async: true, | |
| loadSegments: true | |
| }; | |
| a = !GS.user.isLoggedIn ? 1E4 : 100; | |
| this.kruxTimeoutID = setTimeout(this.callback(function() { | |
| $.ajax({ | |
| cache: true, | |
| dataType: "script", | |
| url: "http://cdn.krxd.net/krux.js", | |
| success: this.callback("onKruxLoad") | |
| }) | |
| }), a) | |
| } | |
| }, | |
| onKruxLoad: function() { | |
| if ( KRUX ) { | |
| var a = | |
| KRUX.getSegments(); | |
| if ( a && a.length ) { | |
| var b = { | |
| params: [] | |
| }; | |
| this.ksgmnts = a.split(","); | |
| for ( a = 0; a < this.ksgmnts.length; a++ ) | |
| try { | |
| this.kruxMap[this.ksgmnts[a].toString()] && b.params.push(this.kruxMap[this.ksgmnts[a].toString()]) | |
| } catch (c) { | |
| console.warn("[ Krux Out of Bounds ]") | |
| } | |
| b.params.length && GS.store.set("krux", b) | |
| } else GS.store.set("krux", null) | |
| } | |
| } | |
| }); | |
| GS.Controllers.BaseController.extend("GS.Controllers.InviteInterface", { | |
| onDocument: false | |
| }, { | |
| userInfo: {}, | |
| googleContacts: null, | |
| facebookFriends: [], | |
| fbIDs: {}, | |
| slickbox: false, | |
| peopleError: null, | |
| people: null, | |
| onFollowersSuccess: function( a ) { | |
| var b = []; | |
| $.each(a, this.callback(function( c, g ) { | |
| b.push([g.Email, g.Name + " " + g.Email, g.Name, g.Name]); | |
| this.userInfo[g.UserID] = g; | |
| this.userInfo[g.Email] = g | |
| })); | |
| a = new $.TextboxList("#emails", { | |
| addOnBlur: true, | |
| bitsOptions: { | |
| editable: { | |
| growing: true, | |
| growingOptions: { | |
| maxWidth: $("#emails").innerWidth() - 10 | |
| } | |
| } | |
| }, | |
| plugins: { | |
| autocomplete: { | |
| placeholder: $.localize.getString("SHARE_EMAIL_PLACEHOLDER") | |
| } | |
| }, | |
| encode: this.callback(function( c ) { | |
| for ( var g = [], h = 0; h < c.length; h++ ) | |
| if ( c[h][0] ) this.userInfo[c[h][0]] ? g.push(this.userInfo[c[h][0]].Email) : g.push(c[h][0]); | |
| else if ( c[h][1] ) this.userInfo[c[h][1]] ? g.push(this.userInfo[c[h][1]].Email) : g.push(c[h][1]); | |
| return g.join(",") | |
| }) | |
| }); | |
| a.plugins.autocomplete.setValues(b); | |
| a.addEvent("bitAdd", this.callback(function( c ) { | |
| c.getValue()[1] === "" && c.hide(); | |
| if ( this.userInfo[c.getValue()[1]] && _.notDefined(c.getValue()[0]) ) { | |
| var g = this.userInfo[c.getValue()[1]]; | |
| c.setValue([g.Email, g.Name + " " + g.Email, g.Name, g.Name]); | |
| c.show() | |
| } | |
| })); | |
| $("#services_content input.textboxlist-bit-editable-input").focus() | |
| }, | |
| extractInviteEmails: function( a ) { | |
| var b, c = [], | |
| g, h = $.trim(a).split(","); | |
| for ( a = 0; a < h.length; a++ ) { | |
| g = $.trim(h[a]).split(" "); | |
| for ( b = 0; b < g.length; b++ ) { | |
| g[b] = $.trim(g[b]); | |
| g[b] && c.push(g[b]) | |
| } | |
| } | |
| return c | |
| }, | |
| onFollowersFailed: function( a ) { | |
| console.warn("failed grabbing contact info for followers", autocompleteTerms, a); | |
| $.publish("gs.notification", { | |
| type: "error", | |
| message: $.localize.getString("POPUP_FAIL_FANS_EMAIL_ONLY") | |
| }) | |
| }, | |
| onFacebookFriends: function( a ) { | |
| this.facebookFriends = a || []; | |
| var b = []; | |
| $.each(this.facebookFriends, this.callback(function( c, g ) { | |
| b.push([g.id, g.name, g.name]) | |
| })); | |
| this.facebookLoaded = true; | |
| if ( b.length > 0 ) this.friendsLoaded = true; | |
| $("#lightbox_pane", this.element).html(this.view("/lightbox/invite/facebook")); | |
| GS.getLightbox().positionLightbox(); | |
| if ( b.length > 0 ) { | |
| a = new $.TextboxList("#facebook_invite_list", { | |
| addOnBlur: true, | |
| bitsOptions: { | |
| editable: { | |
| growing: true, | |
| growingOptions: { | |
| maxWidth: $("#facebook_invite_list").innerWidth() - 10 | |
| } | |
| } | |
| }, | |
| plugins: { | |
| autocomplete: { | |
| placeholder: $.localize.getString("SHARE_FACEBOOK_PLACEHOLDER") | |
| } | |
| }, | |
| encode: this.callback(function( c ) { | |
| var g = []; | |
| if ( c.length ) { | |
| for ( var h = 0; h < c.length; h++ ) | |
| c[h][0] && g.push(c[h][0]); | |
| this.element.find(".submit span").attr("data-translate-text", "SHARE_FACEBOOK_FRIENDS").html($.localize.getString("SHARE_FACEBOOK_FRIENDS")) | |
| } else this.element.find(".submit span").attr("data-translate-text", "SHARE_FACEBOOK_WALL").html($.localize.getString("SHARE_FACEBOOK_WALL")); | |
| return g.join(",") | |
| }) | |
| }); | |
| a.plugins.autocomplete.setValues(b); | |
| a.addEvent("bitAdd", this.callback(function( c ) { | |
| this.element.find(".error").hide(); | |
| if ( c.getValue()[1] === "" ) c.hide(); | |
| else { | |
| var g = $("#facebook_invite_list").val().split(","); | |
| if ( g ) { | |
| var h = g.indexOf(c.getValue()[0]); | |
| c.getValue()[0] && h >= 0 && h != g.length - 1 && c.hide(); | |
| c.getValue()[0] ? GS.getFacebook().canPostToFriend(c.getValue()[0], this.callback(function( k ) { | |
| if (!k ) { | |
| k = c.getValue()[1]; | |
| var m = $.localize.getString("POPUP_SHARE_ERROR_FACEBOOK_CANTPOST"); | |
| m = m.replace("{name}", k); | |
| this.element.find(".error").show().find(".message").html(m); | |
| c.hide(); | |
| GS.getLightbox().positionLightbox() | |
| } | |
| })) : c.hide() | |
| } | |
| } | |
| })); | |
| $("#services_content input.textboxlist-bit-editable-input").focus() | |
| } | |
| }, | |
| formSubmit: function() { | |
| var a = this, | |
| b = /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i; | |
| this.peopleError = []; | |
| this.people = []; | |
| switch ( this.submitType ) { | |
| case "email": | |
| var c; | |
| c = $.trim($("textarea[name=emails]", this.element).val()); | |
| var g = | |
| $("div.textboxlist", this.element).find(".textboxlist-bit").not(".textboxlist-bit-box-deletable").filter(":last").text(); | |
| if ( c !== "" ) { | |
| c = this.extractInviteEmails(c); | |
| _.forEach(c, function( m ) { | |
| m.match(b) ? a.people.push(m) : a.peopleError.push(m) | |
| }) | |
| } | |
| if ( g ) { | |
| g = this.extractInviteEmails(g); | |
| for ( c = 0; c < g.length; c++ ) | |
| g[c].match(b) ? this.people.push(g[c]) : this.peopleError.push(g[c]) | |
| } | |
| if ( this.people.length ) GS.service.sendInvites(this.people, this.callback("sendInviteSuccess"), this.callback("sendInviteFailed")); | |
| else this.peopleError.length && this.invalidInviteEmail(); | |
| break; | |
| case "googleLogin": | |
| g = $("input[name=google_username]", this.element).val(); | |
| c = $("input[name=google_password]", this.element).val(); | |
| GS.service.getGoogleAuthToken(g, c, this.callback("googAuthSuccess"), this.callback("googAuthFailed")); | |
| break; | |
| case "googleContacts": | |
| var h = []; | |
| $(".contactsContainer input:checked", this.element).each(function() { | |
| h.push(this.value) | |
| }); | |
| h.length && GS.service.sendInvites(h, this.callback("sendInviteSuccess"), this.callback("sendInviteFailed")); | |
| break; | |
| case "facebook": | |
| g = | |
| $("#facebook_invite_list").val() ? $("#facebook_invite_list").val().split(",") : []; | |
| var k = _.orEqual($("textarea[name=facebookMessage]", this.element).val(), ""); | |
| if ( g.length > 0 ) { | |
| GS.getFacebook().lastError = false; | |
| _.forEach(g, this.callback(function( m ) { | |
| GS.getFacebook().lastError || GS.getFacebook().postToFeed(m, "http://grooveshark.com/", k, "link", "invite", null, this.callback("facebookFailed")) | |
| })); | |
| if (!GS.getFacebook().lastError ) { | |
| g.length > 1 ? $.publish("gs.facebook.notification.sent", { | |
| params: { | |
| type: "invites", | |
| hideUndo: true | |
| }, | |
| data: {}, | |
| notifData: {} | |
| }) : $.publish("gs.facebook.notification.sent", { | |
| params: { | |
| type: "invite", | |
| hideUndo: true | |
| }, | |
| data: {}, | |
| notifData: {} | |
| }); | |
| this.facebookSuccess() | |
| } | |
| } else if ( GS.getFacebook().connected && window.FB && FB.getAccessToken() ) k != "" ? GS.getFacebook().postToFeed("me", "http://grooveshark.com/", k, "link", "invite", this.callback("facebookSuccess"), this.callback("facebookFailed")) : GS.getFacebook().postLink("me", "http://grooveshark.com/", k, "link", "invite", this.callback("facebookSuccess"), this.callback("facebookFailed")); | |
| else if ( GS.getFacebook().facebookLoaded && GS.getFacebook().connected ) this.facebookFailed(); | |
| else { | |
| window.open("http://www.facebook.com/sharer.php?u=http://grooveshark.com&t=Grooveshark&ref=invite"); | |
| this.facebookSuccessCallback() | |
| } | |
| break | |
| } | |
| return false | |
| }, | |
| sendInviteSuccess: function( a ) { | |
| var b = [], | |
| c = [], | |
| g = [], | |
| h = [], | |
| k = ""; | |
| if ( a ) for ( var m in a ) switch ( a[m].status ) { | |
| case "error": | |
| a[m].errorCode == -3 ? h.push(m) : b.push(m); | |
| break; | |
| case "followed": | |
| c.push(a[m].Username || a[m].FName); | |
| break; | |
| case "invited": | |
| g.push(m); | |
| break | |
| } | |
| if ( c.length ) { | |
| k = (new GS.Models.DataString($.localize.getString("POPUP_INVITE_FORM_RESPONSE_FOLLOWING"), { | |
| list: c.join(", ") | |
| })).render(); | |
| $.publish("gs.notification", { | |
| type: "info", | |
| message: k | |
| }) | |
| } | |
| if ( g.length ) { | |
| k = g.length > 5 ? (new GS.Models.DataString($.localize.getString("POPUP_INVITE_FORM_RESPONSE_INVITED_SUM"), { | |
| sum: String(g.length) | |
| })).render() : (new GS.Models.DataString($.localize.getString("POPUP_INVITE_FORM_RESPONSE_INVITED_LIST"), { | |
| list: g.join(", ") | |
| })).render(); | |
| $.publish("gs.notification", { | |
| type: "info", | |
| message: k | |
| }) | |
| } | |
| if ( h.length ) { | |
| k = (new GS.Models.DataString($.localize.getString("POPUP_INVITE_FORM_RESPONSE_ALREADY_SENT"), { | |
| list: h.join(", ") | |
| })).render(); | |
| $.publish("gs.notification", { | |
| type: "info", | |
| message: k | |
| }) | |
| } | |
| if ( b.length ) { | |
| k = (new GS.Models.DataString($.localize.getString("POPUP_INVITE_FORM_RESPONSE_ERROR"), { | |
| list: b.join(", ") | |
| })).render(); | |
| $.publish("gs.notification", { | |
| type: "error", | |
| message: k | |
| }) | |
| } | |
| if ( this.peopleError.length ) this.invalidInviteEmail(); | |
| else if ( b.length + c.length + g.length + h.length == 0 ) { | |
| this.element.find(".message").attr("data-translate-text", "POPUP_INVITE_FORM_RESPONSE_UNKNOWN_ERROR").html($.localize.getString("POPUP_INVITE_FORM_RESPONSE_UNKNOWN_ERROR")); | |
| this.element.find(".error").show() | |
| } else this.sendInviteSuccessCallback() | |
| }, | |
| sendInviteFailed: function( a ) { | |
| console.warn("invite failed", a); | |
| this.element.find(".message").attr("data-translate-text", "POPUP_INVITE_FORM_RESPONSE_UNKNOWN_ERROR").html($.localize.getString("POPUP_INVITE_FORM_RESPONSE_UNKNOWN_ERROR")); | |
| this.element.find(".error").show() | |
| }, | |
| invalidInviteEmail: function() { | |
| console.warn("invalid invite email"); | |
| var a = $("div.textboxlist", this.element).find(".textboxlist-bit").not(".textboxlist-bit-box-deletable").filter(":last").text(); | |
| a && this.people.indexOf(a) >= 0 && $("div.textboxlist", this.element).find(".textboxlist-bit").not(".textboxlist-bit-box-deletable").remove(); | |
| _.forEach(this.people, function( b ) { | |
| $("li.textboxlist-bit:contains('" + b + "')").remove() | |
| }); | |
| this.element.find(".message").attr("data-translate-text", "POPUP_INVITE_FORM_RESPONSE_INVALID_EMAIL_ERROR").html($.localize.getString("POPUP_INVITE_FORM_RESPONSE_INVALID_EMAIL_ERROR")); | |
| this.element.find(".error").show() | |
| }, | |
| googAuthSuccess: function( a ) { | |
| switch ( parseInt(a.result.statusCode) ) { | |
| case 1: | |
| a = String(a.result.rawResponse); | |
| a = a.substr(a.indexOf("Auth=") + 5); | |
| GS.service.getGoogleContacts(a, this.callback("googContactsSuccess"), this.callback("googContactsFailed")); | |
| break; | |
| case 2: | |
| this.element.find(".message").attr("data-translate-text", "POPUP_INVITE_GOOGAUTH_RESPONSE_AUTH_ERROR").html($.localize.getString("POPUP_INVITE_GOOGAUTH_RESPONSE_AUTH_ERROR")); | |
| this.element.find(".error").show(); | |
| break; | |
| default: | |
| this.element.find(".message").attr("data-translate-text", "POPUP_INVITE_GOOGAUTH_RESPONSE_UNKNOWN_ERROR").html($.localize.getString("POPUP_INVITE_GOOGAUTH_RESPONSE_UNKNOWN_ERROR")); | |
| this.element.find(".error").show(); | |
| break | |
| } | |
| }, | |
| googAuthFailed: function() { | |
| this.element.find(".message").attr("data-translate-text", "POPUP_INVITE_GOOGAUTH_RESPONSE_UNKNOWN_ERROR").html($.localize.getString("POPUP_INVITE_GOOGAUTH_RESPONSE_UNKNOWN_ERROR")); | |
| this.element.find(".error").show() | |
| }, | |
| googContactsSuccess: function( a ) { | |
| switch ( parseInt(a.result.statusCode, 10) ) { | |
| case 1: | |
| this.googleContacts = a.result.parsedResult; | |
| this.showOnlyNamedContacts = true; | |
| this.googContactsSuccessCallback(); | |
| break; | |
| case 2: | |
| this.element.find(".message").attr("data-translate-text", "POPUP_INVITE_GOOGAUTH_RESPONSE_AUTH_ERROR").html($.localize.getString("POPUP_INVITE_GOOGAUTH_RESPONSE_AUTH_ERROR")); | |
| this.element.find(".error").show(); | |
| break; | |
| default: | |
| this.element.find(".message").attr("data-translate-text", "POPUP_INVITE_GOOGAUTH_RESPONSE_UNKNOWN_ERROR").html($.localize.getString("POPUP_INVITE_GOOGAUTH_RESPONSE_UNKNOWN_ERROR")); | |
| this.element.find(".error").show(); | |
| break | |
| } | |
| }, | |
| googContactsFailed: function( a ) { | |
| console.warn("goog contacts failed", a); | |
| this.element.find(".message").attr("data-translate-text", "POPUP_INVITE_GOOGAUTH_RESPONSE_UNKNOWN_ERROR").html($.localize.getString("POPUP_INVITE_GOOGAUTH_RESPONSE_UNKNOWN_ERROR")); | |
| this.element.find(".error").show() | |
| }, | |
| facebookSuccess: function() { | |
| this.facebookSuccessCallback() | |
| }, | |
| facebookFailed: function() { | |
| this.element.find(".message").attr("data-translate-text", "POPUP_SHARE_FACEBOOK_ERROR").html($.localize.getString("POPUP_SHARE_FACEBOOK_ERROR")); | |
| this.element.find(".error").show() | |
| }, | |
| "input keydown": function( a, b ) { | |
| b.keyCode && b.keyCode == 13 && a.is("[name*=google]") && this.formSubmit() | |
| }, | |
| "input.googleContact click": function( a ) { | |
| $(a).is(":checked") ? $(a).closest("li.contact").addClass("selected") : $(a).closest("li.contact").removeClass("selected") | |
| }, | |
| "button.uncheckAll click": function() { | |
| if ( this.submitType == "facebook" ) this.facebookClearSelected(); | |
| else this.submitType == "googleContacts" && $(".google_contacts input", this.element).attr("checked", false) | |
| }, | |
| "button.checkAll click": function() { | |
| if ( this.submitType == "facebook" ) { | |
| this.element.find(".submit span").attr("data-translate-text", "SEND_INVITE").html($.localize.getString("SEND_INVITE")); | |
| _.forEach(this.facebookFriends, function( a, b ) { | |
| this.facebookFriends[b].selected = true; | |
| this.fbIDs[a.id] = a.id | |
| }, this); | |
| this.slickbox.setItems(this.facebookFriends) | |
| } else this.submitType == "googleContacts" && $(".google_contacts input", this.element).attr("checked", true) | |
| }, | |
| updateFacebookForm: function() { | |
| $("#settings_facebook_form").html(this.view("/shared/inviteFacebook")); | |
| $("#settings_facebook_form .error").addClass("hide"); | |
| $(window).resize() | |
| }, | |
| updateFacebookFormWithError: function( a ) { | |
| if ( typeof a == "object" && a.error ) a = a.error; | |
| $("#settings_facebook_form .error").html($.localize.getString(a)); | |
| $("#settings_facebook_form .error").removeClass("hide"); | |
| $(window).resize() | |
| }, | |
| "#fbConnect-btn.fbConnect click": function() { | |
| var a = GS.getFacebook().flags; | |
| GS.getFacebook().logout(this.callback(function() { | |
| GS.getFacebook().login(null, this.callback(function( b ) { | |
| b && b.error ? this.element.find(".error").show().find(".message").html($.localize.getString(b.error)) : this.element.find(".error").show().find(".message").html($.localize.getString("FACEBOOK_PROBLEM_CONNECTING_ERROR_MSG")); | |
| GS.getLightbox().positionLightbox() | |
| }), a) | |
| })) | |
| }, | |
| "#fbConnect-btn.fbLogin click": function() { | |
| GS.getFacebook().login(null, this.callback(function( a ) { | |
| a && a.error ? this.element.find(".error").show().find(".message").html($.localize.getString(a.error)) : this.element.find(".error").show().find(".message").html($.localize.getString("FACEBOOK_PROBLEM_CONNECTING_ERROR_MSG")); | |
| GS.getLightbox().positionLightbox() | |
| })) | |
| }, | |
| "#lightbox .error .message .resetPerms click": function( a, b ) { | |
| b.preventDefault(); | |
| var c = GS.getFacebook().flags; | |
| GS.getFacebook().logout(function() { | |
| GS.getFacebook().login(function() { | |
| $("#lightbox").find(".error").hide() | |
| }, this.callback(function() { | |
| error && error.error ? this.element.find(".error").show().find(".message").html($.localize.getString(error.error)) : this.element.find(".error").show().find(".message").html($.localize.getString("FACEBOOK_PROBLEM_CONNECTING_ERROR_MSG")); | |
| GS.getLightbox().positionLightbox() | |
| }), c) | |
| }) | |
| } | |
| }); | |
| GS.Controllers.BaseController.extend("GS.Controllers.VipInterface", { | |
| onDocument: false, | |
| vipErrorCodes: { | |
| "GS-00": "VIP_ERROR_UNKNOWN", | |
| "GS-01": "VIP_ERROR_LOGIN", | |
| "GS-02": "VIP_ERROR_ALREADY_VIP", | |
| "CC-01": "VIP_ERROR_MISSING_NAME", | |
| "CC-02": "VIP_ERROR_UNKNOWN", | |
| "CC-03": "VIP_ERROR_MISSING_CC_INFO", | |
| "CC-04": "VIP_ERROR_ADDRESS", | |
| "CC-05": "VIP_ERROR_UNKNOWN", | |
| "CC-06": "VIP_ERROR_PAYMENT_PROCESSOR", | |
| "CC-07": "VIP_ERROR_SESSION_EXPIRED", | |
| "CC-08": "VIP_ERROR_INVALID_CC", | |
| "CC-09": "VIP_ERROR_MISSING_CVD", | |
| "CC-10": "VIP_ERROR_INVALID_CVD", | |
| "CC-11": "VIP_ERROR_ADDRESS1_TOO_LONG", | |
| "CC-000": "VIP_ERROR_GENERIC_PAYMENT_ERROR", | |
| "CC-000X": "VIP_ERROR_GENERIC_PAYMENT_ERROR", | |
| "PP-01": "VIP_ERROR_UNKNOWN", | |
| "PP-02": "VIP_ERROR_UNKNOWN_PAYPAL", | |
| "PP-03": "VIP_ERROR_UNKNOWN", | |
| "PP-04": "VIP_ERROR_PAYPAL_CANCEL", | |
| "PP-000": "VIP_ERROR_PAYPAL_FAIL", | |
| "PP-000X": "VIP_ERROR_PAYPAL_FAIL", | |
| "PC-01": "VIP_ERROR_NO_PROMOCODE", | |
| "PC-02": "VIP_ERROR_CODE_NOT_FOUND", | |
| "PC-03": "VIP_ERROR_CODE_REDEEMED", | |
| "RC-01": "VIP_ERROR_NOT_ENOUGH_POINTS" | |
| }, | |
| excludedCreditCardCountries: { | |
| AF: true, | |
| AL: true, | |
| AM: true, | |
| AO: true, | |
| AZ: true, | |
| BA: true, | |
| BD: true, | |
| BG: true, | |
| BI: true, | |
| BY: true, | |
| CD: true, | |
| CF: true, | |
| CG: true, | |
| CK: true, | |
| CS: true, | |
| CU: true, | |
| DZ: true, | |
| EG: true, | |
| ER: true, | |
| ET: true, | |
| GE: true, | |
| GT: true, | |
| HT: true, | |
| ID: true, | |
| IQ: true, | |
| IR: true, | |
| KG: true, | |
| KH: true, | |
| KP: true, | |
| KZ: true, | |
| LA: true, | |
| LR: true, | |
| LY: true, | |
| MD: true, | |
| MK: true, | |
| MM: true, | |
| MN: true, | |
| MY: true, | |
| NG: true, | |
| NR: true, | |
| PH: true, | |
| PK: true, | |
| RO: true, | |
| RU: true, | |
| RW: true, | |
| SD: true, | |
| SL: true, | |
| SR: true, | |
| SY: true, | |
| TJ: true, | |
| TM: true, | |
| UA: true, | |
| UZ: true, | |
| VE: true, | |
| YE: true, | |
| ZW: true | |
| } | |
| }, { | |
| vipPackages: { | |
| plus: "plus", | |
| anywhere: "anywhere", | |
| vip: "vip" | |
| }, | |
| vipPackagePrices: GS.Models.AuthUser.getPricing(), | |
| showVipErrors: function( a ) { | |
| if ( a.errorID && a.message ) a.error = [{ | |
| errorID: a.errorID, | |
| message: a.message | |
| }]; | |
| var b, c = ['<ul class="errors">']; | |
| this.element.find(".error.response .message").html(""); | |
| this.element.find(".error.response").hide(); | |
| if ( a.error && a.error.length ) { | |
| _.forEach(a.error, this.callback(function( g ) { | |
| if ( b = $.trim($.localize.getString(GS.Controllers.VipInterface.vipErrorCodes[g.errorID])) ) c.push("<li>" + b + "</li>"); | |
| else { | |
| console.warn("unknown error in arr", g.errorID, g.message, GS.Controllers.VipInterface.vipErrorCodes[g.errorID]); | |
| b = _.isString(g.message) ? g.message : g.message[0]; | |
| if ( b.match("AVS") ) b = $.localize.getString("VIP_ERROR_AVS"); | |
| else if ( b.match("invalid XML") ) b = $.localize.getString("VIP_ERROR_XML"); | |
| else if ( b.match("invalid card number") ) b = $.localize.getString("VIP_ERROR_CARD_NUMBER"); | |
| else if ( b.match("CVD check") ) b = $.localize.getString("VIP_ERROR_CVD"); | |
| b && c.push("<li>" + b + "</li>") | |
| } | |
| })); | |
| c.push("</ul>"); | |
| a = this.element.find(".error").show().find(".message"); | |
| a.html("<strong>" + $.localize.getString("POPUP_VIP_ERROR_MESSAGE") + "</strong> " + c.join("")) | |
| } else { | |
| this.element.find(".message").attr("data-translate-text", "VIP_ERROR_UNKNOWN").html($.localize.getString("VIP_ERROR_UNKNOWN")); | |
| this.element.find(".error").show() | |
| } | |
| }, | |
| "a.login click": function() { | |
| GS.getLightbox().close(); | |
| GS.getLightbox().open("login") | |
| } | |
| }); | |
| GS.Controllers.PageController.extend("GS.Controllers.Page.HomeController", {}, { | |
| init: function( a, b ) { | |
| this.update(b); | |
| this.subscribe("gs.app.resize", this.callback("resize")); | |
| this._super() | |
| }, | |
| update: function() { | |
| if (!GS.getLightbox || !GS.getLightbox().isOpen ) $("input.search.autocomplete", this.element).focus(); | |
| !GS.user.isLoggedIn || GS.user.IsPremium ? $(".home_upgrade").addClass("hide") : $(".home_upgrade").removeClass("hide"); | |
| $.publish("gs.page.home.update") | |
| }, | |
| index: function() { | |
| this._super(); | |
| this.addAutocomplete("home"); | |
| this.resize(); | |
| this.subscribe("gs.app.resize", this.callback("resize")); | |
| this.subscribe("gs.auth.update", this.callback("update")); | |
| GS.Controllers.PageController.title("Listen to Free Music Online - Internet Radio - Free MP3 Streaming", false); | |
| $.publish("gs.page.home.view"); | |
| GS.resize() | |
| }, | |
| resize: function() { | |
| var a = $("#homeSearch"), | |
| b = 500; | |
| if ( a.length ) { | |
| b = Math.max(250, Math.min(500, $(this.element).width() - 200)); | |
| a.width(b).css("marginLeft", -Math.round(b / 2)) | |
| } | |
| }, | |
| toggleHint: function( a, b ) { | |
| var c = $("#searchBar_hint"), | |
| g = | |
| $("#searchBar_input input"), | |
| h = $("#searchBar_precomplete"); | |
| if ( b.type == "mousedown" ) g.val() === "" && b.button != 2 ? c.show().addClass("faded") : c.hide(); | |
| else if ( b.type == "keyup" || b.type == "keydown" ) { | |
| var k = _.orEqual(b.keyCode, b.which), | |
| m = String.fromCharCode(k).replace(/[\b]/g, ""); | |
| if ( String.fromCharCode(k).replace(/[\s]/g, "").length > 0 ) g.val() === "" && m.length < 1 ? c.show().addClass("faded") : c.hide(); | |
| if ( b.type == "keydown" ) { | |
| h.hide(); | |
| if ( k == _.keys.TAB ) { | |
| b.preventDefault(); | |
| c = h.text(); | |
| c.length && g.val(c) | |
| } | |
| } | |
| } else g.val() === "" ? c.show().removeClass("faded") : c.hide(); | |
| g.val() === "" && h.text("") | |
| }, | |
| "#homeSearch submit": function( a, b ) { | |
| if ( $("input[name=q]", a).val() === "" ) { | |
| b.stopImmediatePropagation(); | |
| return false | |
| } | |
| return true | |
| }, | |
| "#searchButton click": function() { | |
| $("#searchBar_input .search").val() ? $("#homeSearch").submit() : $("#searchBar_input span").trigger("click") | |
| }, | |
| "#searchBar_input span click": function() { | |
| $("input.search.autocomplete", this.element).focus(); | |
| $("#searchBar_hint").addClass("faded") | |
| }, | |
| "#homePage keydown": function() { | |
| $("input.search.autocomplete", this.element).focus() | |
| }, | |
| "input.search.autocomplete mousedown": function( a, b ) { | |
| return this.toggleHint(a, b) | |
| }, | |
| "input.search.autocomplete keydown": function( a, b ) { | |
| return this.toggleHint(a, b) | |
| }, | |
| "input.search.autocomplete keyup": function( a, b ) { | |
| return this.toggleHint(a, b) | |
| }, | |
| "input.search.autocomplete focusout": function( a, b ) { | |
| if ( $("#searchBar_input input").hasClass("focused") ) { | |
| setTimeout(function() { | |
| $("input.search.autocomplete", "#page").focus() | |
| }, 0); | |
| $("#searchBar_input input").removeClass("focused"); | |
| return true | |
| } else return this.toggleHint(a, b) | |
| }, | |
| "a.about click": function() { | |
| GS.getLightbox().open("about") | |
| }, | |
| "a.themes click": function() { | |
| GS.getLightbox().open("themes") | |
| }, | |
| "a.upgrade click": function() { | |
| GS.getLightbox().open("vipPerks") | |
| }, | |
| "a.station click": function( a, b ) { | |
| b.stopPropagation(); | |
| var c = a.attr("data-tagid"); | |
| GS.player.setAutoplay(true, c); | |
| return false | |
| }, | |
| notFound: function() { | |
| this.element.html(this.view("not_found")); | |
| this.addAutocomplete("home"); | |
| this.resize(); | |
| this.subscribe("gs.app.resize", this.callback("resize")); | |
| this.subscribe("gs.auth.update", this.callback("update")); | |
| GS.Controllers.PageController.title("Unable To Find What You're Looking For") | |
| } | |
| }); | |
| GS.Controllers.PageController.extend("GS.Controllers.Page.NowPlayingController", {}, { | |
| currentSong: {}, | |
| index: function() { | |
| GS.Controllers.PageController.title("Now Playing"); | |
| this.element.html(this.view("index")); | |
| this.list.doSearchInPage = true; | |
| var a = GS.player.getCurrentQueue(); | |
| this.loadGrid(a); | |
| this.loadCurrentSong(a); | |
| this.subscribe("gs.player.queue.change", this.callback(["loadGrid", "loadCurrentSong"])); | |
| GS.resize() | |
| }, | |
| init: function() { | |
| this._super(); | |
| this.bind("keyup", this.callback(function( a ) { | |
| a.which === 46 && this.deleteSelectedSongs() | |
| })); | |
| this.delegate("button.delete", "click", this.callback(this.deleteSelectedSongs)) | |
| }, | |
| deleteSelectedSongs: function() { | |
| var a = [], | |
| b = this.element.find(".gs_grid").controller(); | |
| if ( b ) { | |
| var c = b.grid.getSelectedRows(); | |
| if ( c.length !== 0 ) { | |
| for ( var g = 0; g < c.length; g++ ) | |
| a.push(b.dataView.rows[c[g]].queueSongID); | |
| GS.player.removeSongs(a); | |
| b.grid.setSelectedRows([]); | |
| b.selectedRowIDs = []; | |
| $.publish("gs.grid.selectedRows", { | |
| len: 0, | |
| type: "song" | |
| }) | |
| } | |
| } | |
| }, | |
| loadCurrentSong: function() { | |
| var a = _.orEqual(GS.player.currentSong, {}); | |
| if (!this.currentSong || a.SongID !== this.currentSong.SongID ) { | |
| this.currentSong = a; | |
| console.log(a); | |
| $("#currentSongInfo").html(this.view("current_song")) | |
| } | |
| }, | |
| loadGrid: function( a ) { | |
| if (!a ) { | |
| a = GS.player.getCurrentQueue(true); | |
| if (!a ) { | |
| this.element.find(".gs_grid").html(this.view("noResults")); | |
| $("#searchForm input").select(); | |
| this.addAutocomplete("now_playing"); | |
| GS.resize(); | |
| return | |
| } | |
| } | |
| this.queue = a; | |
| var b = a.songs.length > 0 && a.songs[0] instanceof GS.Models.Song ? a.songs : GS.Models.Song.wrapQueue(a.songs), | |
| c = this.element.find(".gs_grid").controller(), | |
| g = { | |
| sortCol: "Sort", | |
| sortDir: 1, | |
| sortStoreKey: "gs.sort.nowPlaying.songs", | |
| scrollPane: $("#page_content"), | |
| padding: 0 | |
| }; | |
| g = $.extend(g, { | |
| allowDuplicates: true, | |
| allowDragSort: true, | |
| isNowPlaying: true | |
| }); | |
| for ( var h = 1; h < b.length; h++ ) | |
| b[h].Sort = h; | |
| if ( c ) { | |
| g = c.dataView; | |
| var k = c.grid; | |
| if ( g ) { | |
| g.beginUpdate(); | |
| var m = b.concat(), | |
| p, n = g.getItems().concat(), | |
| o; | |
| for ( h = 0; h < n.length; h++ ) { | |
| p = n[h]; | |
| o = m.indexOf(p); | |
| o != -1 && m.splice(o, 1); | |
| g.getIdxById(p.SongID); | |
| o = b.indexOf(p); | |
| o == -1 ? g.deleteItem(p.SongID) : g.updateItem(p.GridKey, p) | |
| } | |
| m.length && g.addItems(m, "SongID"); | |
| g.endUpdate(); | |
| g.refresh() | |
| } | |
| k && k.onSort(c.sortCol, c.sortDir); | |
| GS.resize() | |
| } else if ( b.length ) { | |
| g.rowCssClasses = this.callback(function( t ) { | |
| var w = ""; | |
| a = GS.player.getCurrentQueue(); | |
| if ( a.activeSong && a.activeSong.queueSongID == t.queueSongID ) w += "active"; | |
| if ( a.autoplayEnabled ) w += " autoplay"; | |
| return w | |
| }); | |
| g.rowAttrs = function( t ) { | |
| return ["rel='", t.queueSongID, "' rel2='", t.SongID, "'"].join("") | |
| }; | |
| this.element.find(".gs_grid").gs_grid(b, GS.Controllers.GridController.columns.queuesong, g, "song") | |
| } else { | |
| this.element.find(".gs_grid").html(this.view("noResults")); | |
| $("#searchForm input").select(); | |
| this.addAutocomplete("now_playing"); | |
| GS.resize() | |
| } | |
| a.hasRestoreQueue ? $("#page_header button.clearRestore .restore").show().siblings().hide() : $("#page_header button.clearRestore .clears").show().siblings().hide(); | |
| $("#grid .slick-row.active").removeClass("active"); | |
| if ( a.activeSong ) { | |
| $("#grid .slick-row[rel=" + a.activeSong.queueSongID + "]").addClass("active"); | |
| GS.player.isPlaying ? $("#grid .slick-row.active a.play").removeClass("paused") : $("#grid .slick-row.active a.play").addClass("paused") | |
| } | |
| }, | |
| getOptionMenu: function() { | |
| var a = []; | |
| addMenu = this.getAddMenu(); | |
| a.concat(addMenu); | |
| this.queue = GS.player.getCurrentQueue(true); | |
| if ( this.queue.songs.length ) { | |
| a = addMenu.concat([{ | |
| customClass: "separator" | |
| }]); | |
| var b = this.queue.activeSong.getShareMenu(); | |
| a.push({ | |
| title: $.localize.getString("SHARE_SONG"), | |
| type: "sub", | |
| src: b, | |
| customClass: "jj_menu_item_hasIcon jj_menu_item_share jj_menu_item_more" | |
| }) | |
| } else if ( GS.player.queue.hasRestoreQueue ) a = a.concat({ | |
| title: $.localize.getString("QUEUE_RESTORE_QUEUE"), | |
| action: { | |
| type: "fn", | |
| callback: GS.player.restoreQueue | |
| }, | |
| customClass: "jj_menu_item_hasIcon jj_menu_item_undo" | |
| }); | |
| if ( a.length ) a = a.concat([{ | |
| customClass: "separator" | |
| }]); | |
| a.push({ | |
| title: $.localize.getString("QUEUE_LOAD_STATION"), | |
| customClass: "stations jj_menu_item_hasIcon jj_menu_item_station", | |
| type: "sub", | |
| src: GS.Models.Station.getStationsStartMenu() | |
| }); | |
| return a | |
| }, | |
| getShareMenu: function() { | |
| return [{ | |
| title: $.localize.getString("SHARE_WIDGET"), | |
| action: { | |
| type: "fn", | |
| callback: this.callback(function() { | |
| for ( var a = [], b = 0; b < this.queue.songs.length; ++b ) | |
| a.push(this.queue.songs[b].SongID); | |
| GS.getLightbox().open("share", { | |
| service: "widget", | |
| type: "manySongs", | |
| id: a | |
| }); | |
| GS.getGuts().onContextMenuClick("contextShareWidget", "dropdownmenu", false, null) | |
| }) | |
| }, | |
| customClass: "jj_menu_item_hasIcon jj_menu_item_share_widget" | |
| }] | |
| }, | |
| getAddMenu: function() { | |
| var a = []; | |
| songID = this.currentSong.SongID; | |
| songName = this.currentSong.SongName; | |
| songIDs = []; | |
| for ( var b = 0; b < this.queue.songs.length; ++b ) | |
| songIDs.push(this.queue.songs[b].SongID); | |
| if ( this.currentSong && this.currentSong.SongID ) GS.user.favorites.songs.hasOwnProperty(songID) ? a.push({ | |
| title: $.localize.getString("CONTEXT_REMOVE_FROM_FAVORITES"), | |
| action: { | |
| type: "fn", | |
| callback: function() { | |
| GS.user.removeFromSongFavorites(songID, true); | |
| GS.getGuts().objectListPlayAdd(songID, triggerElement) | |
| } | |
| }, | |
| customClass: "jj_menu_item_hasIcon jj_menu_item_remove_favorite" | |
| }) : a.push({ | |
| title: $.localize.getString("CONTEXT_ADD_TO_FAVORITES"), | |
| action: { | |
| type: "fn", | |
| callback: function() { | |
| GS.user.addToSongFavorites(songID, true); | |
| GS.getGuts().objectListPlayAdd(songID, triggerElement) | |
| } | |
| }, | |
| customClass: "jj_menu_item_hasIcon jj_menu_item_favorites" | |
| }); | |
| GS.user.isShortcut("song", songID) ? a.push({ | |
| title: $.localize.getString("CONTEXT_REMOVE_FROM_PINBOARD"), | |
| action: { | |
| type: "fn", | |
| callback: function() { | |
| GS.user.removeFromShortcuts("song", songID); | |
| $("#page_header a[name=shortcut]").parent().show(); | |
| $("#page_header a[name=removeshortcut]").parent().hide() | |
| } | |
| }, | |
| customClass: "jj_menu_item_hasIcon jj_menu_item_remove_music" | |
| }) : a.push({ | |
| title: $.localize.getString("CONTEXT_ADD_TO_PINBOARD"), | |
| action: { | |
| type: "fn", | |
| callback: function() { | |
| GS.user.addToShortcuts("song", songID, songName, true); | |
| $("#page_header a[name=shortcut]").parent().hide(); | |
| $("#page_header a[name=removeshortcut]").parent().show() | |
| } | |
| }, | |
| customClass: "jj_menu_item_hasIcon jj_menu_item_pinboard" | |
| }); | |
| a.push({ | |
| title: $.localize.getString("CONTEXT_ADD_TO_PLAYLIST"), | |
| type: "sub", | |
| src: GS.Models.Playlist.getPlaylistsMenu(songIDs, function( c ) { | |
| c.addSongs(songIDs, null, true) | |
| }, false, true), | |
| customClass: "jj_menu_item_hasIcon jj_menu_item_add_playlist" | |
| }); | |
| return a | |
| }, | |
| getSortMenu: function() { | |
| var a = this.setSort; | |
| return [{ | |
| title: $.localize.getString("SORT_BY_PLAYLIST"), | |
| action: { | |
| type: "fn", | |
| callback: function() { | |
| a("Sort", triggerElement, "SORT_BY_PLAYLIST") | |
| } | |
| }, | |
| customClass: "jj_menu_item_blank" | |
| }, { | |
| title: $.localize.getString("SORT_BY_SONG"), | |
| action: { | |
| type: "fn", | |
| callback: function() { | |
| a("SongName", triggerElement, "SORT_BY_SONG") | |
| } | |
| }, | |
| customClass: "jj_menu_item_blank" | |
| }, { | |
| title: $.localize.getString("SORT_BY_ARTIST"), | |
| action: { | |
| type: "fn", | |
| callback: function() { | |
| a("ArtistName", triggerElement, "SORT_BY_ARTIST") | |
| } | |
| }, | |
| customClass: "jj_menu_item_blank" | |
| }, { | |
| title: $.localize.getString("SORT_BY_ALBUM"), | |
| action: { | |
| type: "fn", | |
| callback: function() { | |
| a("AlbumName", triggerElement, "SORT_BY_ALBUM") | |
| } | |
| }, | |
| customClass: "jj_menu_item_blank" | |
| }] | |
| }, | |
| "button.clearRestore click": function() { | |
| GS.player.getCurrentQueue(true).hasRestoreQueue ? GS.player.restoreQueue() : GS.player.clearQueue(); | |
| this.index() | |
| }, | |
| ".slick-row .smile click": function( a, b ) { | |
| b.stopImmediatePropagation(); | |
| var c = a.parents(".slick-row").attr("row"); | |
| c = $("#grid").controller().dataView.getItemByIdx(c).queueSongID; | |
| GS.player.voteSong(c, 1); | |
| $(a).addClass("selected").siblings(".frown").removeClass("selected") | |
| }, | |
| ".slick-row .frown click": function( a, b ) { | |
| b.stopImmediatePropagation(); | |
| var c = a.parents(".slick-row").attr("row"); | |
| c = $("#grid").controller().dataView.getItemByIdx(c).queueSongID; | |
| GS.player.voteSong(c, -1); | |
| $(a).addClass("selected").siblings(".smile").removeClass("selected") | |
| } | |
| }); | |
| (function() { | |
| GS.Controllers.PageController.extend("GS.Controllers.Page.SettingsController", {}, { | |
| user: null, | |
| settings: null, | |
| desktopPrefs: null, | |
| subscriptionData: null, | |
| index: function( a ) { | |
| this.pageType = a || "profile"; | |
| GS.getGuts().handlePageLoad("settings", { | |
| subpage: a | |
| }); | |
| if (!GS.user.isLoggedIn ) if ( this.pageType !== "preferences" && this.pageType !== "subscriptions" ) { | |
| this.pageType = "preferences"; | |
| window.location.hash = "/settings/preferences" | |
| } | |
| GS.user.settings.getUserSettings(this.callback("loadSettings"), GS.router.notFound); | |
| this.subscribe("gs.auth.update", this.callback("index", a)); | |
| this.subscribe("gs.auth.favorites.users.update", this.callback("updateActivityUsersForm")); | |
| this.subscribe("gs.facebook.profile.update", this.callback("updateFacebookForm")); | |
| this.subscribe("gs.facebook.status.update", this.callback("updateFacebookForm")); | |
| this.subscribe("gs.lastfm.profile.update", this.callback("updateLastfmForm")); | |
| this.subscribe("gs.google.profile.update", this.callback("updateGoogleForm")); | |
| this.subscribe("gs.settings.upload.onload", this.callback("iframeOnload")) | |
| }, | |
| loadSettings: function() { | |
| if ( this.element ) { | |
| this.user = GS.user; | |
| this.settings = GS.user.settings; | |
| this.desktopPrefs = GS.airbridge.getDesktopPreferences(); | |
| this.element.html(this.view("index")); | |
| switch ( this.pageType ) { | |
| case "profile": | |
| GS.Controllers.PageController.title("Settings"); | |
| this.showProfile(); | |
| break; | |
| case "password": | |
| GS.Controllers.PageController.title("Change Password"); | |
| this.showPassword(); | |
| break; | |
| case "preferences": | |
| GS.Controllers.PageController.title("Preferences"); | |
| this.showPreferences(); | |
| break; | |
| case "services": | |
| GS.Controllers.PageController.title("Services Settings"); | |
| this.showServices(); | |
| break; | |
| case "activity": | |
| GS.Controllers.PageController.title("Activity Settings"); | |
| this.showActivity(); | |
| break; | |
| case "subscriptions": | |
| GS.Controllers.PageController.title("Subscriptions Settings"); | |
| if ( GS.user.isLoggedIn ) this.subscriptionData !== null ? this.showSubscriptions(this.subscriptionData) : GS.service.getSubscriptionDetails(this.callback("showSubscriptions"), this.callback("showSubscriptions")); | |
| else this.showSubscriptions(false); | |
| break | |
| } | |
| GS.resize() | |
| } | |
| }, | |
| showProfile: function() { | |
| this.today = new Date; | |
| this.dob = new Date; | |
| if ( this.settings.TSDOB ) { | |
| var a = this.settings.TSDOB.split("-"); | |
| this.dob = new Date(parseInt(a[0], 10), parseInt(a[1], 10) - 1, parseInt(a[2], 10)) | |
| } | |
| this.months = $.localize.getString("MONTHS").split(","); | |
| this.countries = _.countries; | |
| GS.user.UserID > 0 && GS.user.getPathName(this.callback("loadProfile")) | |
| }, | |
| loadProfile: function() { | |
| if ( GS.user.UserID > 0 && this.pageType == "profile" ) { | |
| this.element.find("#settings").html(this.view("profile")); | |
| $(".settings_selectbox_country span").html($("select.country option:selected").html()); | |
| $(".selectbox.month span").html($("select.month option:selected").html()); | |
| window.location.hash.match(/pic$/) && setTimeout(function() { | |
| $("#settings").scrollTo("#settings_profilePicture") | |
| }, 100) | |
| } | |
| }, | |
| showPassword: function() { | |
| this.element.find("#settings").html(this.view("password")); | |
| $(window).resize() | |
| }, | |
| showServices: function() { | |
| this.element.find("#settings").html(this.view("services")); | |
| this.updateFacebookForm(); | |
| this.updateLastfmForm(); | |
| this.updateGoogleForm(); | |
| $(window).resize() | |
| }, | |
| showPreferences: function() { | |
| $(window).resize(); | |
| this.element.find("#settings").html(this.view("preferences")); | |
| if ( this.desktopPrefs ) { | |
| $("#desktop_selected_notifDuration", this.element).localeDataString("NUM_SECONDS", { | |
| seconds: this.desktopPrefs.notifications.duration | |
| }); | |
| $("option.notifDuration", this.element).each(function() { | |
| $(this).localeDataString("NUM_SECONDS", { | |
| seconds: $(this).val() | |
| }) | |
| }) | |
| } | |
| }, | |
| showActivity: function() { | |
| this.settings.privacy = GS.service.privacy; | |
| this.element.find("#settings").html(this.view("activity")); | |
| this.hideUsers = new $.TextboxList("#settings_usersToHide", { | |
| addOnBlur: false, | |
| plugins: { | |
| autocomplete: { | |
| placeholder: $.localize.getString("SETTINGS_USER_HIDE_PLACEHOLDER") | |
| } | |
| }, | |
| encode: this.callback(function( a ) { | |
| for ( var b = [], c = 0; c < a.length; c++ ) | |
| a[c][0] ? b.push(a[c][0]) : b.push(a[c][1]); | |
| return b.join(",") | |
| }) | |
| }); | |
| this.hideUsers.addEvent("bitAdd", this.callback("bitCheck")); | |
| this.updateActivityUsersForm(); | |
| $(window).resize() | |
| }, | |
| showSubscriptions: function( a ) { | |
| var b = GS.Models.AuthUser.getPricing(a.bVip); | |
| this.data = this.subscriptionData = a; | |
| this.noData = true; | |
| this.recurring = this.bVip = this.bAnywhere = | |
| this.bPlus = this.hasSpecialVip = false; | |
| this.billingAmount = this.nextBillingDate = this.paymentType = this.subscriptionType = ""; | |
| this.anywhereMonthPrice = b.anywhere.month; | |
| this.plusMonthPrice = b.plus.month; | |
| this.dateUnsubscribed = this.endDate = false; | |
| if ( a === false || a.fault || a.code || a.bVip && _.notDefined(a.paymentType) ) { | |
| this.noData = true; | |
| this.recurring = _.orEqual(a.bRecurring, false); | |
| this.bAnywhere = this.bPlus = false; | |
| if ( GS.user.IsPremium ) this.hasSpecialVip = true; | |
| if ( a && a.bVip ) this.bVip = parseInt(a.bVip, 10) | |
| } else { | |
| this.noData = false; | |
| switch ( a.paymentType ) { | |
| case "OPTIMAL_PAYMENTS": | |
| this.paymentMethod = $.localize.getString("CREDIT_CARD"); | |
| break; | |
| case "PAYPAL": | |
| this.paymentMethod = $.localize.getString("PAYPAL"); | |
| break; | |
| case "FREE_TRIAL": | |
| this.paymentMethod = $.localize.getString("FREE_TRIAL"); | |
| break; | |
| case "ZONG": | |
| this.paymentMethod = $.localize.getString("ZONG"); | |
| break; | |
| case "ALLOPASS": | |
| this.paymentMethod = $.localize.getString("ALLOPASS"); | |
| break; | |
| case "GWALLET": | |
| this.paymentMethod = $.localize.getString("GWALLET"); | |
| break; | |
| case "TRIAL_PAY": | |
| this.paymentMethod = | |
| $.localize.getString("TRIAL_PAY"); | |
| break; | |
| default: | |
| this.paymentMethod = _.orEqual(a.paymentType, "") | |
| } | |
| this.subscriptionType = a.subscriptionType; | |
| this.paymentType = a.paymentType; | |
| this.billingAmount = "$" + a.amount; | |
| this.recurring = a.bRecurring; | |
| this.bVip = parseInt(a.bVip, 10); | |
| this.bAnywhere = (GS.user.Flags & GS.Models.User.FLAG_ANYWHERE) > 0; | |
| this.bPlus = (GS.user.Flags & GS.Models.User.FLAG_PLUS) > 0; | |
| this.dateUnsubscribed = a.dateUnsubscribed; | |
| if ( a.dateStart == a.dateNextCheck && !this.recurring ) this.nextBillingDate = false; | |
| else try { | |
| var c = | |
| _.orEqual(a.dateNextBill, a.dateNextCheck).split("-"); | |
| this.nextBillingDate = (new Date(parseInt(c[0], 10), parseInt(c[1], 10) - 1, parseInt(c[2], 10))).format("F j, Y") | |
| } catch (g) { | |
| console.warn("subPage error:", g); | |
| this.nextBillingDate = $.localize.getString("UNKNOWN") | |
| } | |
| try { | |
| var h = _.orEqual(a.dateSubcriptionEnd, a.dateEnd).split("-"); | |
| this.endDate = (new Date(parseInt(h[0], 10), parseInt(h[1], 10) - 1, parseInt(h[2], 10))).format("F j, Y") | |
| } catch (k) {} | |
| } | |
| if ( this.bVip ) this.plusMonthPrice = this.anywhereMonthPrice = b.vip.month; | |
| $("#page_header_navigation .subscriptions_link").hasClass("active") && this.element.find("#settings").html(this.view("subscriptions")); | |
| $(window).resize() | |
| }, | |
| paymentTypeToString: function( a ) { | |
| var b = ""; | |
| switch ( a ) { | |
| case "FREE_TRIAL": | |
| break; | |
| default: | |
| b = $.localize.getString("SUBSCRIPTIONS_UNKNOWN_PAYMENT_TYPE") | |
| } | |
| return b | |
| }, | |
| bitCheck: function( a ) { | |
| this.userInfo[a.getValue()[1]] || a.hide() | |
| }, | |
| updateActivityUsersForm: function() { | |
| if ( this.element ) { | |
| this.hiddenUsers = GS.user.filterFriends(1); | |
| this.visibleUsers = GS.user.filterFriends(1, true); | |
| this.element.find("#hiddenUsers").html(this.view("hiddenUsers")); | |
| this.element.find("#settings_usersToHide").val(""); | |
| this.element.find(".textboxlist-bit-box-deletable").remove(); | |
| this.userInfo = {}; | |
| var a = []; | |
| $.each(this.visibleUsers, this.callback(function( b, c ) { | |
| a.push([c.UserID, c.Name, c.Name, c.Name]); | |
| this.userInfo[c.UserID] = c; | |
| this.userInfo[c.Name] = c | |
| })); | |
| _.defined(this.hideUsers) && this.hideUsers.plugins && this.hideUsers.plugins.autocomplete.setValues(a) | |
| } | |
| }, | |
| "#settings_userInfo submit": function( a, b ) { | |
| b.preventDefault(); | |
| var c = $.trim($("input[name=fname]", a).val()), | |
| g = $.trim($("input[name=username]", a).val()), | |
| h = $.trim($("input[name=email]", a).val()), | |
| k = $("select[name=country]", a).val(), | |
| m = $("input[name=zip]", a).val(), | |
| p = $("input[name=sex]:checked", a).val(), | |
| n = parseInt($("select[name=month]", this.element).val(), 10), | |
| o = parseInt($("select[name=year]", this.element).val(), 10), | |
| t = parseInt($("select[name=day]", this.element).val(), 10), | |
| w = new Date(o, n - 1, t); | |
| n = n.toString().length == 1 ? "0" + n : n; | |
| t = t.toString().length == 1 ? "0" + t : t; | |
| n = [o, n, t].join("-"); | |
| c = { | |
| FName: c, | |
| Email: h, | |
| Country: k, | |
| Zip: m, | |
| Sex: p, | |
| TSDOB: n, | |
| PageName: g | |
| }; | |
| if ( Math.floor((+new Date - +w) / 864E5 / 365.24) < 13 ) this._userInfoFailed({ | |
| statusCode: 0, | |
| message: $.localize.getString("POPUP_SIGNUP_FORM_TOO_YOUNG_ACCOUNT") | |
| }); | |
| else h.match(_.emailRegex) ? GS.user.settings.updateProfile(c, this.callback(this._userInfoSuccess), this.callback(this._userInfoFailed)) : this._userInfoFailed({ | |
| statusCode: -2 | |
| }); | |
| return false | |
| }, | |
| checkUsernameTimer: null, | |
| "#user_customURL keyup": function( a ) { | |
| a = a.val(); | |
| $(".settings_usernameURL .status", this.element).removeClass("verified alert error"); | |
| clearTimeout(this.checkUsernameTimer); | |
| if ( a !== "" && a.length && a != GS.user.PathName ) this.checkUsernameTimer = setTimeout(this.callback("checkUsername", a), 500) | |
| }, | |
| checkUsername: function( a ) { | |
| var b = 0, | |
| c = /^([a-zA-Z0-9]+[\.\-_]?)+[a-zA-Z0-9]+$/; | |
| $(".settings_usernameURL .status", this.element).removeClass("verified alert error"); | |
| if ( a.length && (a.length < 5 || a.length > 32 || !a.match(c)) ) { | |
| b |= 128; | |
| $(".settings_usernameURL .status", this.element).addClass("alert").attr("title", $.localize.getString("POPUP_SIGNUP_FORM_USERNAME_INVALID")) | |
| } else a.length && a != GS.user.PathName && GS.service.getItemByPageName(a, this.callback(function( g ) { | |
| if (!g || g.type ) { | |
| b |= 4; | |
| $(".settings_usernameURL .status", this.element).addClass("error").attr("title", $.localize.getString("POPUP_SIGNUP_FORM_USERNAME_UNAVAILABLE")) | |
| } else $(".settings_usernameURL .status", this.element).addClass("verified").attr("title", $.localize.getString("POPUP_SIGNUP_FORM_USERNAME_AVAILABLE")) | |
| }), null, { | |
| async: false | |
| }); | |
| return b | |
| }, | |
| _userInfoSuccess: function() { | |
| $("#settings_userInfo .form_buttons .status").addClass("success").removeClass("failure") | |
| }, | |
| _userInfoFailed: function( a ) { | |
| $("#settings_userInfo .form_buttons .status").addClass("failure").removeClass("success"); | |
| switch ( a.statusCode ) { | |
| case -2: | |
| $.publish("gs.notification", { | |
| type: "error", | |
| message: $.localize.getString("POPUP_EMAIL_INVALID") | |
| }); | |
| break; | |
| case -3: | |
| $.publish("gs.notification", { | |
| type: "error", | |
| message: $.localize.getString("POPUP_NAME_CANNOT_BE_EMPTY") | |
| }); | |
| break; | |
| case -4: | |
| $.publish("gs.notification", { | |
| displayDuration: 1E4, | |
| type: "error", | |
| message: $.localize.getString("POPUP_EMAIL_TAKEN") | |
| }); | |
| break; | |
| case -7: | |
| case -9: | |
| $.publish("gs.notification", { | |
| type: "error", | |
| message: $.localize.getString("POPUP_INCORRECT_PASSWORD") | |
| }); | |
| break; | |
| case -10: | |
| $.publish("gs.notification", { | |
| type: "error", | |
| message: $.localize.getString("POPUP_USERNAME_INVALID_CHARACTERS") | |
| }); | |
| break; | |
| case -11: | |
| $.publish("gs.notification", { | |
| type: "error", | |
| message: $.localize.getString("POPUP_USERNAME_INVALID_LENGTH") | |
| }); | |
| break; | |
| case -12: | |
| $.publish("gs.notification", { | |
| type: "error", | |
| message: $.localize.getString("POPUP_USERNAME_RATE_LIMIT") | |
| }); | |
| break; | |
| case -13: | |
| $.publish("gs.notification", { | |
| type: "error", | |
| message: $.localize.getString("POPUP_USERNAME_TAKEN") | |
| }); | |
| break; | |
| default: | |
| a = _.orEqual(a.message, $.localize.getString("POPUP_UNABLE_SAVE_SETTINGS")); | |
| $.publish("gs.notification", { | |
| type: "error", | |
| message: a | |
| }); | |
| break | |
| } | |
| }, | |
| "#uploadPath change": function( a ) { | |
| a = $(a).val(); | |
| a = a.replace(/.+\\/g, ""); | |
| if ( a.length > 20 ) a = a.substr(0, 20) + "…"; | |
| $("#uploadLabel").html(a) | |
| }, | |
| "#settings_profilePicture .browse click": function() { | |
| $("#uploadPath").click() | |
| }, | |
| isFormOnload: false, | |
| "#settings_profilePicture submit": function() { | |
| $("#settings_profilePicture .form_buttons .status").text($.localize.getString("LOADING...")).show(); | |
| return this.isFormOnload = true | |
| }, | |
| iframeOnload: function( a, b ) { | |
| console.log("iframe.upload.onload", a, b); | |
| $("#settings_profilePicture .form_buttons .status").text(""); | |
| var c = a.contentWindow || a.get().contentDocument, | |
| g; | |
| if ( c.document ) c = c.document; | |
| c = c.body.innerHTML; | |
| console.log("iframe.upload.resp str", c); | |
| if ( c ) { | |
| try { | |
| g = $.parseJSON(c) | |
| } catch (h) { | |
| g = {} | |
| } | |
| if (!g || !g.success || !g.filename ) { | |
| g = g || {}; | |
| g.error && g.error.code && (g.error.code == 1 || g.error.code == 2) ? $.publish("gs.notification", { | |
| type: "error", | |
| message: $.localize.getString("POPUP_UPLOAD_IMAGE_TOO_BIG") | |
| }) : $.publish("gs.notification", { | |
| type: "error", | |
| message: $.localize.getString("POPUP_UNABLE_UPLOAD_IMAGE") | |
| }); | |
| $("#settings_profilePicture .form_buttons .status").addClass("failure") | |
| } else { | |
| $("#settings_profilePicture .form_buttons .status").addClass("success"); | |
| c = $("#settings_profilePicture").find("img"); | |
| GS.user.Picture = g.filename; | |
| c.attr("src", GS.user.getImageURL()); | |
| $("#header_account_button .profileImg img").attr("src", GS.user.getImageURL(30)) | |
| } | |
| } else if ( this.isFormOnload ) { | |
| $.publish("gs.notification", { | |
| type: "error", | |
| message: $.localize.getString("POPUP_UNABLE_UPLOAD_IMAGE") | |
| }); | |
| $("#settings_profilePicture .form_buttons .status").addClass("failure") | |
| } | |
| return this.isFormOnload = false | |
| }, | |
| "#settings_changePassword submit": function( a, b ) { | |
| b.preventDefault(); | |
| var c = $("input[name=oldPass]", a).val(), | |
| g = $("input[name=newPass]", a).val(), | |
| h = $("input[name=confirmPass]", a).val(); | |
| g == h && c.length > 4 && g.length > 4 ? GS.user.changePassword(c, g, this.callback(this._passwordSuccess), this.callback(this._passwordFailed)) : $.publish("gs.notification", { | |
| type: "error", | |
| message: $.localize.getString("POPUP_SIGNUP_FORM_PASSWORD_INVALID_NO_MATCH") | |
| }); | |
| return false | |
| }, | |
| _passwordSuccess: function() { | |
| $("#settings_changePassword .form_buttons .status").addClass("success") | |
| }, | |
| _passwordFailed: function() { | |
| $("#settings_changePassword .form_buttons .status").addClass("failure") | |
| }, | |
| "#settings_changePassword a.forgot click": function() { | |
| GS.getLightbox().open("forget") | |
| }, | |
| "#settings_notifications submit": function( a, b ) { | |
| b.preventDefault(); | |
| var c = { | |
| userFollow: $("#settings_notifications_userFollow").is(":checked"), | |
| inviteSignup: $("#settings_notifications_userSignup").is(":checked"), | |
| playlistSubscribe: $("#settings_notifications_userSubscribe").is(":checked"), | |
| newFeature: $("#settings_notifications_newFeature").is(":checked"), | |
| civicScience: $("#settings_notifications_civicScienceNotifs").is(":checked") | |
| }; | |
| GS.user.settings.changeNotificationSettings(c, this.callback(this._notificationsSuccess), this.callback(this._notificationsFailed)); | |
| return false | |
| }, | |
| _notificationsSuccess: function() { | |
| $("#settings_notifications .form_buttons .status").addClass("success") | |
| }, | |
| _notificationsFailed: function() { | |
| $("#settings_notifications .form_buttons .status").addClass("failure"); | |
| $.publish("gs.notification", { | |
| type: "error", | |
| message: $.localize.getString("POPUP_UNABLE_SAVE_NOTIFICATION") | |
| }) | |
| }, | |
| "select blur": function( a ) { | |
| a.change() | |
| }, | |
| "select keydown": function( a ) { | |
| a.change() | |
| }, | |
| "li.settings_genderOrientation mousedown": function( a ) { | |
| $(a).data("previous", $("#settings_userInfo input[name=sex]:checked").val()) | |
| }, | |
| "li.settings_genderOrientation click": function( a, b ) { | |
| var c = $("input", a); | |
| if ( $(c).val() === $(a).data("previous") ) { | |
| $("#gender_none").attr("checked", "checked"); | |
| b.preventDefault(); | |
| $(c).blur(); | |
| return false | |
| } | |
| }, | |
| "form :input change": function( a ) { | |
| $(a).closest("form").find(".form_buttons .status").removeClass("success failure") | |
| }, | |
| "#settings_localSettings button.clearLocal click": function( a, b ) { | |
| b.preventDefault(); | |
| GS.store.clear(); | |
| $("#settings_localSettings .form_buttons .status").addClass("success"); | |
| return false | |
| }, | |
| "#settings_localSettings submit": function( a, b ) { | |
| b.preventDefault(); | |
| var c = GS.theme.THEME_FLAG_DEFAULT; | |
| c |= ($("input[name=familyFriendly]:checked", a).length ? 1 : 0) * GS.theme.THEME_FLAG_FAMILY_FRIENDLY; | |
| c = { | |
| restoreQueue: $("input[name=restoreQueue]:checked", a).length ? 1 : 0, | |
| persistShuffle: $("input[name=persistShuffle]:checked", a).length ? 1 : 0, | |
| lowerQuality: $("input[name=lowerQuality]:checked", a).length ? 1 : 0, | |
| noPrefetch: $("input[name=noPrefetch]:checked", a).length ? 1 : 0, | |
| playPauseFade: $("input[name=doCrossfade]:checked", a).length ? 1 : 0, | |
| crossfadeAmount: $("select[name=crossfadeSecs]", a).val() * 1E3, | |
| tooltips: $("input[name=tooltips]:checked", a).length ? 1 : 0, | |
| themeFlags: c, | |
| persistPinboard: $("input[name=persistPinboard]:checked", a).length ? 1 : 0 | |
| }; | |
| GS.user.settings.changeLocalSettings(c, this.callback(this._localSettingSuccess), this.callback(this._localSettingFailed)); | |
| return false | |
| }, | |
| _localSettingSuccess: function() { | |
| $("#settings_localSettings .form_buttons .status").addClass("success").removeClass("failure") | |
| }, | |
| _localSettingFailed: function() { | |
| $("#settings_localSettings .form_buttons .status").addClass("failure").removeClass("success") | |
| }, | |
| "#settings_activity_privacy submit": function( a, b ) { | |
| b.preventDefault(); | |
| switch ( $(a).find("input:checked").val() ) { | |
| case "-1": | |
| GS.service.privacy = 1; | |
| $("#settings_activity_privacy .form_buttons .status").addClass("success"); | |
| GS.service.reportUserChange(GS.user, 1); | |
| GS.getFacebook().scrobblingEnabled = false; | |
| GS.getLastfm().scrobblingEnabled = false; | |
| break; | |
| case "0": | |
| var c = false; | |
| if (!(GS.user.Privacy & 1) && GS.service.privacy & 1 ) c = true; | |
| GS.service.privacy = GS.user.Privacy = 0; | |
| if ( c ) { | |
| $("#settings_activity_privacy .form_buttons .status").addClass("success"); | |
| GS.service.reportUserChange(GS.user, 1) | |
| } else GS.service.changePrivacySettings(0, this.callback("changePrivacySuccess"), this.callback("changePrivacyFailure")); | |
| if ((GS.getFacebook().flags & GS.getFacebook().SCROBBLING_FLAG) > 0 ) GS.getFacebook().scrobblingEnabled = true; | |
| if ((GS.getLastfm().flags & GS.getLastfm().SCROBBLING_FLAG) > 0 ) GS.getLastfm().scrobblingEnabled = true; | |
| break; | |
| case "1": | |
| GS.service.privacy = GS.user.Privacy = 1; | |
| GS.service.changePrivacySettings(1, this.callback("changePrivacySuccess"), this.callback("changePrivacyFailure")); | |
| GS.getFacebook().scrobblingEnabled = | |
| false; | |
| GS.getLastfm().scrobblingEnabled = false; | |
| break | |
| } | |
| return false | |
| }, | |
| changePrivacySuccess: function( a ) { | |
| if (!a || a.statusCode !== 1 ) this.changePrivacyFailed(a); | |
| else { | |
| $("#settings_activity_privacy .form_buttons .status").addClass("success"); | |
| GS.service.reportUserChange(GS.user) | |
| } | |
| }, | |
| changePrivacyFailed: function() { | |
| $("#settings_activity_privacy .form_buttons .status").addClass("failure") | |
| }, | |
| "#settings_activity_users submit": function( a, b ) { | |
| b.preventDefault(); | |
| for ( var c = ($("#settings_usersToHide").val() || "").split(","), g = [], h = 0; h < c.length; h++ ) | |
| this.userInfo[c[h]] && g.push({ | |
| userID: this.userInfo[c[h]].UserID, | |
| flags: 1 | |
| }); | |
| GS.user.changeFollowFlags(g); | |
| return false | |
| }, | |
| "#settings_activity_users button.showUser click": function( a ) { | |
| a = [{ | |
| userID: parseInt($(a).attr("data-userid"), 10), | |
| flags: 0 | |
| }]; | |
| GS.user.changeFollowFlags(a) | |
| }, | |
| updateFacebookForm: function() { | |
| $("#settings_facebook_form").html(this.view("facebook_form")); | |
| $("#settings_facebook_form .checkbox_list").html(this.view("/shared/facebookSettings")); | |
| $(window).resize() | |
| }, | |
| updateFacebookFormWithError: function( a ) { | |
| if ( typeof a == "object" && a.error ) a = a.error; | |
| $("#settings_facebook_form .error").removeClass("hide").html($.localize.getString(a)); | |
| $(window).resize() | |
| }, | |
| "#fbConnect-btn.fbLogin click": function() { | |
| GS.getFacebook().login(this.callback("updateFacebookForm"), this.callback("updateFacebookFormWithError")) | |
| }, | |
| "#fbConnect-btn.fbConnect click": function() { | |
| var a = GS.getFacebook().flags; | |
| GS.getFacebook().logout(this.callback(function() { | |
| GS.getFacebook().login(this.callback("updateFacebookForm"), this.callback("updateFacebookFormWithError"), a) | |
| })) | |
| }, | |
| "a.fb-logout click": function() { | |
| GS.getFacebook().registeredWithFacebook ? GS.getLightbox().open("resetPassword", this.callback(function( a ) { | |
| var b = GS.getFacebook().flags; | |
| GS.getFacebook().logout(this.callback(function() { | |
| this.callback("updateFacebookForm"); | |
| a() | |
| }), b) | |
| })) : GS.getFacebook().logout(this.callback("updateFacebookForm")) | |
| }, | |
| "form#settings_facebook_form submit": function( a, b ) { | |
| b.preventDefault(); | |
| var c = 0; | |
| $("#settings_facebook_form input:checkbox:checked").each(function( g, h ) { | |
| c |= $(h).val() | |
| }); | |
| GS.getFacebook().save(c, function() { | |
| $("#settings_facebook_form .form_buttons .status").addClass("success") | |
| }, function() { | |
| $("#settings_facebook_form .form_buttons .status").addClass("failure") | |
| }); | |
| return false | |
| }, | |
| "a.fb-findfriends click": function() { | |
| GS.getFacebook().getGroovesharkUsersFromFriends() | |
| }, | |
| "a.fb-disableScrobbling click": function() { | |
| GS.getFacebook().scrobblingEnabled = false; | |
| $("form#settings_facebook_form .fb-disableScrobbling").hide(); | |
| $("form#settings_facebook_form .fb-enableScrobbling").show() | |
| }, | |
| "a.fb-enableScrobbling click": function() { | |
| GS.getFacebook().scrobblingEnabled = | |
| true; | |
| $("form#settings_facebook_form .fb-enableScrobbling").hide(); | |
| $("form#settings_facebook_form .fb-disableScrobbling").show() | |
| }, | |
| updateGoogleForm: function() { | |
| this.element.find("#settings_google_form").html(this.view("google_form")); | |
| this.element.find("#settings_google_form .error").addClass("hide"); | |
| $(window).resize() | |
| }, | |
| updateGoogleFormWithError: function( a ) { | |
| if (!a || !a.error ) a = { | |
| error: "POPUP_SIGNUP_LOGIN_FORM_GOOGLE_ERROR" | |
| }; | |
| this.element.find("#settings_google_form .error").removeClass("hide").html($.localize.getString(a.error)); | |
| $(window).resize() | |
| }, | |
| "#googleLogin-btn click": function() { | |
| GS.getGoogle().login(this.callback("updateGoogleForm"), this.callback("updateGoogleFormWithError")) | |
| }, | |
| "a.google-logout click": function() { | |
| GS.getGoogle().registeredWithGoogle ? GS.getLightbox().open("resetPassword", this.callback(function( a ) { | |
| GS.getGoogle().logout(this.callback(function() { | |
| this.callback("updateGoogleForm"); | |
| a() | |
| })) | |
| })) : GS.getGoogle().logout(this.callback("updateGoogleForm")) | |
| }, | |
| updateLastfmForm: function() { | |
| this.element.find("#settings_lastfm_form").html(this.view("lastfm_form")); | |
| this.element.find("#settings_lastfm_form .error").addClass("hide"); | |
| $(window).resize() | |
| }, | |
| updateLastfmFormWithError: function( a ) { | |
| if (!a || !a.error ) a = { | |
| error: "POPUP_SIGNUP_LOGIN_FORM_LASTFM_ERROR" | |
| }; | |
| console.log($.localize.getString(a.error)); | |
| this.element.find("#settings_lastfm_form .error").removeClass("hide").html($.localize.getString(a.error)); | |
| $(window).resize() | |
| }, | |
| "#lastfmConnect-btn click": function( a, b ) { | |
| b.preventDefault(); | |
| GS.getLastfm().login(this.callback("updateLastfmForm"), this.callback("updateLastfmFormWithError")); | |
| return false | |
| }, | |
| "a.lastfm-logout click": function() { | |
| GS.getLastfm().logout(this.callback("updateLastfmForm")) | |
| }, | |
| "form#settings_lastfm_form submit": function( a, b ) { | |
| b.preventDefault(); | |
| if ( $("#settings_lastfm_enabled:checked").length ) GS.getLastfm().scrobblingEnabled = false; | |
| else GS.getLastfm().scrobblingEnabled = true; | |
| $("#settings_lastfm_form .form_buttons .status").addClass("success"); | |
| return false | |
| }, | |
| "#settings_userSubscriptions button.upgrade click": function( a, b ) { | |
| b.preventDefault(); | |
| var c, g = !this.noData && !this.recurring ? 1 : 0; | |
| if ( GS.user.isLoggedIn ) if ( a.hasClass("plus") ) { | |
| c = this.bVip ? "vip" : "plus"; | |
| GS.getLightbox().open("vipSignup", { | |
| vipPackage: c, | |
| bExtend: g | |
| }) | |
| } else if ( a.hasClass("anywhere") ) { | |
| c = this.bVip ? "vip" : "anywhere"; | |
| GS.getLightbox().open("vipSignup", { | |
| vipPackage: c, | |
| bExtend: g | |
| }) | |
| } else { | |
| c = this.bVip ? "vip" : "anywhere"; | |
| GS.getLightbox().open("vipSignup", { | |
| initOffers: true, | |
| vipPackage: c, | |
| bExtend: g | |
| }) | |
| } | |
| else location.hash = "/signup"; | |
| return false | |
| }, | |
| "#settings_userSubscriptions button.extend click": function( a, b ) { | |
| b.preventDefault(); | |
| var c; | |
| c = this.subscriptionType.match("Anywhere") ? "anywhere" : this.subscriptionType.match("Plus") ? "plus" : this.bVip == true || this.bVip == 1 ? "vip" : "plus"; | |
| if ( c === "vip" || c === "anywhere" ) GS.getLightbox().open("vipSignup", { | |
| bExtend: 1, | |
| vipPackage: this.bVip ? "vip" : c | |
| }); | |
| else location.hash = "/signup/upgrade" | |
| }, | |
| "#settings_userSubscriptions button.cancel click": function( a, b ) { | |
| b.preventDefault(); | |
| this.subscriptionData = null; | |
| GS.getLightbox().open("vipCancel"); | |
| return false | |
| }, | |
| "#settings_userSubscriptions button.update click": function( a, b ) { | |
| b.preventDefault(); | |
| this.subscriptionData = | |
| null; | |
| GS.getLightbox().open("vipSignup", { | |
| updateCreditCard: true | |
| }); | |
| return false | |
| }, | |
| "a.feedback click": function() { | |
| GS.user.IsPremium && GS.getLightbox().open("feedback") | |
| }, | |
| "p.form_finePrint a.login click": function() { | |
| GS.getLightbox().open("login") | |
| }, | |
| "p.form_finePrint a.signup click": function() { | |
| location.hash = "/signup" | |
| }, | |
| "#init_deactivate_account click": function( a, b ) { | |
| b.preventDefault(); | |
| GS.getLightbox().open("deactivateAccount") | |
| }, | |
| "#settings_desktop submit": function( a, b ) { | |
| b.preventDefault(); | |
| var c = { | |
| onClose: $("#settings_desktop input[name=settings_desktop_onClose]:checked").val(), | |
| onMinimize: $("#settings_desktop input[name=settings_desktop_onMinimize]:checked").val(), | |
| externalControlEnabled: $("#settings_desktop_globalKeyboard").is(":checked"), | |
| notifications: { | |
| songNotifications: $("#settings_desktop_songNotifications").is(":checked"), | |
| position: parseInt($("select[name=settings_desktop_notifPosition]", a).val(), 10), | |
| duration: parseInt($("select[name=settings_desktop_notifDuration]", a).val(), 10) | |
| } | |
| }; | |
| this.desktopPrefs = c; | |
| GS.airbridge.setDesktopPreferences(c); | |
| $("#settings_desktop .form_buttons .status").addClass("success"); | |
| return false | |
| }, | |
| "#settings_preview .reload click": function() { | |
| $("#settings_preview_reload").val(1) | |
| }, | |
| "#settings_preview .noReload click": function() { | |
| $("#settings_preview_reload").val(0) | |
| }, | |
| "#settings_preview submit": function( a, b ) { | |
| b.preventDefault(); | |
| var c = $("input[name=settings_preview_usePreview]:checked", a).val(), | |
| g = parseInt($("#settings_preview_reload").val(), 10); | |
| c ? $.cookie("use_preview", true, { | |
| domain: ".grooveshark.com", | |
| expires: 60 | |
| }) : $.cookie("use_preview", null, { | |
| domain: ".grooveshark.com" | |
| }); | |
| if ( g ) c ? setTimeout(function() { | |
| window.location = "http://preview.grooveshark.com" | |
| }, 100) : setTimeout(function() { | |
| window.location = "http://grooveshark.com" | |
| }, 100); | |
| return false | |
| } | |
| }) | |
| })(); | |
| GS.Controllers.PageController.extend("GS.Controllers.Page.SongController", {}, { | |
| type: "song", | |
| scrollToComment: false, | |
| index: function( a, b ) { | |
| this.url = location.hash; | |
| this.token = a || ""; | |
| this.subpage = b || "overview"; | |
| this.token ? GS.Models.Song.getSongFromToken(this.token, this.callback("loadSong")) : GS.router.notFound() | |
| }, | |
| loadSong: function( a ) { | |
| if ( a.validate() ) { | |
| this.song = a; | |
| if (!a.fanbase ) a.fanbase = GS.Models.Fanbase.wrap({ | |
| objectID: a.SongID, | |
| objectType: "song" | |
| }); | |
| this.correctUrl(this.song, this.subpage === "overview" ? "" : this.subpage); | |
| this.id = this.song.SongID; | |
| this.fbCommentsUrl = "http://listen.grooveshark.com/" + this.song.toUrl().replace("#/", ""); | |
| this.fbUrl = "http://grooveshark.com/" + this.song.toUrl().replace("#/", "").split("?")[0]; | |
| this.header.name = this.song.SongName; | |
| this.header.breadcrumbs = [{ | |
| text: this.song.ArtistName, | |
| url: _.cleanUrl(this.song.ArtistName, this.song.ArtistID, "artist") | |
| }, | |
| { | |
| text: this.song.AlbumName, | |
| url: _.cleanUrl(this.song.AlbumName, this.song.AlbumID, "album") | |
| }]; | |
| this.header.subpages = ["overview"]; | |
| this.header.options = false; | |
| this.list.doPlayAddSelect = true; | |
| this.list.doSearchInPage = true; | |
| this.list.sortOptions = [{ | |
| text: "Track", | |
| column: "TrackNum" | |
| }, | |
| { | |
| text: "Popularity", | |
| column: "Popularity" | |
| }, | |
| { | |
| text: "Song Name", | |
| column: "Name" | |
| }, | |
| { | |
| text: "Artist Name", | |
| column: "ArtistName" | |
| }]; | |
| this.element.html(this.view("index")); | |
| switch ( this.subpage ) { | |
| case "overview": | |
| default: | |
| this.song.album = GS.Models.Album.getOneFromCache(this.song.AlbumID); | |
| this.triedUnverified = this.song.album ? this.song.album.songsLoaded && this.song.album.songsUnverifiedLoaded : false; | |
| GS.Controllers.PageController.title(this.song.getTitle()); | |
| $("#page_header button.share").parent().show(); | |
| if ( window.FB && FB.XFBML && this.fbUrl && GS.getFacebook().initialXFBML ) FB.XFBML.parse(window.document.getElementById("page_content"), this.callback("onPageLoaded")); | |
| else if ( this.fbUrl ) { | |
| var b; | |
| b = this.subscribe("gs.facebook.xfbml.ready", this.callback(function() { | |
| FB.XFBML.parse(window.document.getElementById("page_content_pane"), this.callback("onPageLoaded")); | |
| $.unsubscribe(b) | |
| })) | |
| } | |
| this.fans = []; | |
| this.fansLoaded = false; | |
| this.song.fanbase.getFans(this.callback("loadSidebarFans"), this.callback("loadSidebarFans"), false); | |
| break | |
| } | |
| a.getVideos(this.callback("loadVideos"), this.callback("loadVideosFailed")); | |
| GS.Models.Artist.getArtist(this.song.ArtistID, this.callback("loadDigests")); | |
| GS.service.getSongRecentListeners(this.song.SongID) | |
| } else GS.router.notFound() | |
| }, | |
| onPageLoaded: function() { | |
| setTimeout(this.callback(function() { | |
| if ( $("#page_content_social_buttons").length ) { | |
| $("#page_content .comments").removeClass("loadingFBComments"); | |
| $("#page_content_social_buttons .fblike").css("width", this.likeWidth); | |
| this.loadLikeButtonCount(this.fbUrl); | |
| FB.XFBML.parse(window.document.getElementById("fbLike"), this.callback(function() { | |
| setTimeout(function() { | |
| $.publish("gs.facebook.xfbml.ready") | |
| }, 100); | |
| this.scrollToComment && this.scrollToFBComment(); | |
| $("#page_content_social_buttons .fblike").css("width", this.likeWidth) | |
| })); | |
| GS.resize(); | |
| GS.getTwitter().getTwitterShareMessage("song", this.song, this.fbUrl, this.callback(function( a, b ) { | |
| var c = $(document.createElement("a")); | |
| c.attr("data-text", a.replace('"', '"')); | |
| c.attr("data-url", b); | |
| c.attr("data-via", "grooveshark"); | |
| c.attr("data-count", "none"); | |
| c.addClass("twitter-share-button"); | |
| c.text("Tweet"); | |
| $("#page_content_social_buttons .tweetButton").empty().append(c); | |
| GS.getTwitter().parseWidgets() | |
| })); | |
| GS.getGoogle().parsePlusWidgets($("#page_content_social_buttons .googlePlusButton").get(0)) | |
| } | |
| }), 10) | |
| }, | |
| loadDigests: function( a ) { | |
| this.artist = a; | |
| this.artist.getTunipopID(this.callback(function() {})); | |
| this.artist.getSongs(this.callback("loadAlbumDigest")); | |
| GS.service.artistGetSimilarArtists(this.artist.ArtistID, this.callback("loadSimilarDigest")); | |
| GS.service.getSongkickEventsFromArtists([this.artist.ArtistID], [this.artist.ArtistName], this.callback("loadEventsDigest")); | |
| if (!GS.user.IsPremium ) { | |
| GS.getAd().updateRotationCount(); | |
| GS.getAd().buildAd($("#songCapital_300"), 300, 250, ["p=song_overview"]); | |
| GS.getAd().buildAd($("#songCapital_728"), 728, 90, ["p=song_overview"]) | |
| } | |
| }, | |
| loadAlbumDigest: function() { | |
| if ( this.artist && this.artist.albums ) { | |
| var a = _.toArray(this.artist.albums).sort(GS.Models.Album.prettySort).slice(0, 6); | |
| a.length && $("#album_digest").html(this.view("/artist/album_digest", { | |
| artist: this.artist, | |
| albums: a | |
| })) | |
| } | |
| }, | |
| loadSimilarDigest: function( a ) { | |
| this.similarArtists = GS.Models.Artist.wrapCollection(a.SimilarArtists); | |
| this.similarArtists.length && this.element.find("#similarArtists_digest").html(this.view("/artist/similarArtists_digest")) | |
| }, | |
| loadEventsDigest: function( a ) { | |
| if ( a && a.length ) { | |
| a.sort(_.getSort("StartTime", -1)); | |
| a = a.slice(0, 5); | |
| $("#events_digest").html(this.view("/artist/event_digest", { | |
| artist: this.artist, | |
| events: a | |
| })) | |
| } | |
| }, | |
| loadVideos: function( a ) { | |
| if ( this.subpage === "overview" ) if ( a && a.length ) { | |
| this.videos = a; | |
| $("#song_videos").html(this.view("song_videos", { | |
| videos: a | |
| })) | |
| } | |
| }, | |
| loadVideosFailed: function() { | |
| if ( this.subpage === "overview" ) if ( this.fans.length ) { | |
| this.sliderObject = this.videos = this.fans; | |
| this.sliderObject.name = '<span data-translate-text="FANS">' + $.localize.getString("FANS") + "</span>"; | |
| this.sliderWidth = this.fans.length * 140; | |
| this.sliderContents = this.fans; | |
| this.sliderRenderer = GS.Models.User.sliderRenderer; | |
| $("#song_subcontent").removeClass("loading").html(this.view("/shared/slider")) | |
| } else if ( this.fansLoaded ) $("#song_subcontent").removeClass("loading").hide(); | |
| else this.loadSubFans = true | |
| }, | |
| loadSidebarFans: function( a ) { | |
| this.fansLoaded = true; | |
| if ( a ) { | |
| var b = []; | |
| for ( var c in a ) | |
| if ( a.hasOwnProperty(c) ) { | |
| if ( b.length >= 18 ) break; | |
| a[c].Picture && b.push(a[c]) | |
| } | |
| this.fans = b; | |
| this.sidebarFans = true; | |
| $("#song_fans").html(this.view("/shared/sidebarFans", { | |
| fans: b, | |
| seeAll: false | |
| })); | |
| this.loadSubFans && this.loadVideosFailed() | |
| } else this.loadSubFans && $("#song_subcontent").removeClass("loading").hide() | |
| }, | |
| selectCurrentSong: function() { | |
| var a = this.element.find(".gs_grid").controller(); | |
| if ( a ) { | |
| var b = a.dataView.getIdxById(this.song.SongID), | |
| c = a.grid.getSelectedRows(); | |
| c.push(b); | |
| a.selectedRowIDs.push(this.song.SongID); | |
| a.grid.setSelectedRows(c); | |
| a.grid.onSelectedRowsChanged() | |
| } | |
| }, | |
| scrollToFBComment: function() { | |
| this.scrollToComment = true | |
| }, | |
| ".slick-row.verifiedDivider click": function( a, b ) { | |
| b.stopPropagation(); | |
| var c = $("#grid").controller(), | |
| g; | |
| if ( c ) { | |
| if (!this.triedUnverified ) { | |
| this.triedUnverified = true; | |
| this.song.getRelatedSongs(this.callback("loadRelatedGrid"), null, false) | |
| } | |
| if ( c.filter.onlyVerified ) { | |
| a.find(".showMore").addClass("showingMore").attr("data-translate-text", "SEARCH_RESULTS_SHOW_LESS").html($.localize.getString("SEARCH_RESULTS_SHOW_LESS")); | |
| c.filter.onlyVerified = false | |
| } else { | |
| a.find(".showMore").removeClass("showingMore").attr("data-translate-text", "SEARCH_RESULTS_SHOW_MORE").html($.localize.getString("SEARCH_RESULTS_SHOW_MORE")); | |
| c.filter.onlyVerified = 1 | |
| }(g = c.grid) && g.onSort(c.sortCol, c.sortDir) | |
| } | |
| }, | |
| "a.songLink click": function( a, b ) { | |
| b.preventDefault(); | |
| var c = parseInt($(a).attr("rel"), 10); | |
| c && GS.Models.Song.getSong(c, function( g ) { | |
| if ( g ) location.hash = g.toUrl() | |
| }) | |
| }, | |
| "a.video click": function( a ) { | |
| a = parseInt($(a).attr("rel"), 10); | |
| GS.getLightbox().open("video", { | |
| videos: this.videos, | |
| index: a, | |
| autoSkipToNextVideo: false, | |
| renderSection: false | |
| }) | |
| }, | |
| ".capitalSliderBtn click": function( a ) { | |
| a = $(a); | |
| a.scrollLeft(0); | |
| $(a).hasClass("capitalSliderNext") ? $(".capitalView_728").animate({ | |
| scrollLeft: $(".capitalView_728").scrollLeft() + 200 | |
| }, 500) : $(".capitalView_728").animate({ | |
| scrollLeft: $(".capitalView_728").scrollLeft() - 200 | |
| }, 500) | |
| }, | |
| ".capitalSliderBtn mouseup": function( a ) { | |
| a = $(a); | |
| a.scrollLeft(0); | |
| console.warn("hereeee") | |
| }, | |
| getOptionMenu: function() { | |
| var a = [], | |
| b = this.song.getShareMenu(), | |
| c = this.song.SongID; | |
| songName = this.song.SongName; | |
| GS.user.isShortcut("song", c) ? a.push({ | |
| title: $.localize.getString("CONTEXT_REMOVE_FROM_PINBOARD"), | |
| action: { | |
| type: "fn", | |
| callback: function() { | |
| GS.user.removeFromShortcuts("song", c); | |
| $("#page_header a[name=shortcut]").parent().show(); | |
| $("#page_header a[name=removeshortcut]").parent().hide() | |
| } | |
| }, | |
| customClass: "jj_menu_item_hasIcon jj_menu_remove_music" | |
| }) : a.push({ | |
| title: $.localize.getString("CONTEXT_ADD_TO_PINBOARD"), | |
| action: { | |
| type: "fn", | |
| callback: function() { | |
| GS.user.addToShortcuts("song", c, songName, true); | |
| $("#page_header a[name=shortcut]").parent().hide(); | |
| $("#page_header a[name=removeshortcut]").parent().show() | |
| } | |
| }, | |
| customClass: "jj_menu_item_hasIcon jj_menu_item_pinboard" | |
| }); | |
| a.push({ | |
| customClass: "separator" | |
| }); | |
| a.push({ | |
| title: $.localize.getString("SHARE_SONG"), | |
| type: "sub", | |
| src: b, | |
| customClass: "jj_menu_item_hasIcon jj_menu_item_share jj_menu_item_more" | |
| }, { | |
| customClass: "separator" | |
| }, { | |
| title: $.localize.getString("CONTEXT_BUY_SONG"), | |
| action: { | |
| type: "fn", | |
| callback: function() { | |
| GS.getLightbox().open("buySong", c); | |
| GS.getGuts().onContextMenuClick("contextBuySong", "songOptionsMenu", false, null) | |
| } | |
| }, | |
| customClass: "jj_menu_item_hasIcon jj_menu_item_download" | |
| }); | |
| if ( this.artist && (GS.service.country.ID === 0 || GS.service.country.ID == 1 || GS.service.country.ID == 223) && this.artist.tunipopID && !isNaN(this.artist.tunipopID) && this.artist.tunipopID > 0 ) a.push({ | |
| title: $.localize.getString("CONTEXT_BUY_MERCH"), | |
| action: { | |
| type: "fn", | |
| callback: function() { | |
| GS.getLightbox().open("tunipop", { | |
| songID: c | |
| }); | |
| GS.getGuts().onContextMenuClick("contextBuyMerch", "songOptionsMenu", false, null) | |
| } | |
| }, | |
| customClass: "jj_menu_item_hasIcon jj_menu_item_buy_merch" | |
| }); | |
| return a | |
| }, | |
| getPlayMenu: function() { | |
| var a = this.getPlayContext(), | |
| b = [this.song.SongID], | |
| c = this.element; | |
| return [{ | |
| title: $.localize.getString("PLAY_NOW"), | |
| action: { | |
| type: "fn", | |
| callback: function() { | |
| b.length && GS.player.addSongsToQueueAt(b, GS.player.INDEX_DEFAULT, true, a); | |
| GS.getGuts().objectListPlayAdd(b, c, "play") | |
| } | |
| }, | |
| customClass: "jj_menu_item_hasIcon jj_menu_item_play" | |
| }, { | |
| title: $.localize.getString("PLAY_NEXT"), | |
| action: { | |
| type: "fn", | |
| callback: function() { | |
| b.length && GS.player.addSongsToQueueAt(b, GS.player.INDEX_NEXT, false, a); | |
| GS.getGuts().objectListPlayAdd(b, c, "play") | |
| } | |
| }, | |
| customClass: "jj_menu_item_hasIcon jj_menu_item_play_next" | |
| }, { | |
| title: $.localize.getString("PLAY_LAST"), | |
| action: { | |
| type: "fn", | |
| callback: function() { | |
| b.length && GS.player.addSongsToQueueAt(b, GS.player.INDEX_LAST, false, a); | |
| GS.getGuts().objectListPlayAdd(b, c, "play") | |
| } | |
| }, | |
| customClass: "jj_menu_item_hasIcon jj_menu_item_play_last" | |
| }, { | |
| customClass: "separator" | |
| }, { | |
| title: $.localize.getString("REPLACE_QUEUE"), | |
| action: { | |
| type: "fn", | |
| callback: function() { | |
| b.length && GS.player.addSongsToQueueAt(b, GS.player.INDEX_REPLACE, true, a); | |
| GS.getGuts().objectListPlayAdd(b, c, "play") | |
| } | |
| }, | |
| customClass: "jj_menu_item_hasIcon jj_menu_item_replace_playlist" | |
| }, { | |
| title: $.localize.getString("START_RADIO"), | |
| action: { | |
| type: "fn", | |
| callback: function() { | |
| b.length && GS.player.addSongsToQueueAt(b, GS.player.INDEX_REPLACE, true, a, true); | |
| GS.getGuts().objectListPlayAdd(b, c, "play") | |
| } | |
| }, | |
| customClass: "jj_menu_item_hasIcon jj_menu_item_new_station" | |
| }] | |
| } | |
| }); | |
| GS.Controllers.PageController.extend("GS.Controllers.Page.AlbumController", {}, { | |
| type: "album", | |
| index: function( a, b, c ) { | |
| this.url = location.hash; | |
| this.id = parseInt(a, 10) || 0; | |
| this.subpage = _.orEqual(b, "music"); | |
| this.playOnView = c || false; | |
| this.id < 0 ? GS.router.notFound() : GS.Models.Album.getAlbum(this.id, this.callback("loadAlbum")) | |
| }, | |
| loadAlbum: function( a ) { | |
| this.album = a; | |
| if (!a.fanbase ) a.fanbase = GS.Models.Fanbase.wrap({ | |
| objectID: a.AlbumID, | |
| objectType: "album" | |
| }); | |
| this.correctUrl(this.album, this.subpage === "music" ? "" : this.subpage); | |
| this.fbUrl = "http://grooveshark.com/" + this.album.toUrl().replace("#/", ""); | |
| this.element.html(this.view("index")); | |
| $.publish("gs.page.loading.grid"); | |
| switch ( this.subpage ) { | |
| case "fans": | |
| GS.Controllers.PageController.title(this.album.getTitle() + " - fans"); | |
| this.album.fanbase.getFans(this.callback("loadGridFans")); | |
| break; | |
| default: | |
| this.triedUnverified = this.album.songsLoaded && this.album.songsUnverifiedLoaded; | |
| GS.Controllers.PageController.title(this.album.getTitle()); | |
| this.album.getSongs(this.callback("loadGrid"), null, true) | |
| } | |
| GS.Models.Artist.getArtist(this.album.ArtistID, this.callback("loadDigests")); | |
| GS.service.getAlbumRecentListeners(this.album.AlbumID) | |
| }, | |
| onPageLoaded: function() { | |
| setTimeout(this.callback(function() { | |
| if ( $("#page_content_social_buttons").length ) { | |
| var a = this.callback(function() { | |
| $("#page_content_social_buttons .fblike").css("width", this.likeWidth); | |
| this.loadLikeButtonCount(this.fbUrl); | |
| FB.XFBML.parse(window.document.getElementById("fbLike"), this.callback(function() { | |
| $("#page_content_social_buttons .fblike").css("width", this.likeWidth) | |
| })) | |
| }); | |
| if ( window.FB && FB.XFBML ) a(); | |
| else { | |
| var b; | |
| b = this.subscribe("gs.facebook.xfbml.ready", this.callback(function() { | |
| a(); | |
| $.unsubscribe(b) | |
| })) | |
| } | |
| GS.getTwitter().getTwitterShareMessage("album", this.album, this.fbUrl, this.callback(function( c, g ) { | |
| var h = $(document.createElement("a")); | |
| h.attr("data-text", c.replace('"', '"')); | |
| h.attr("data-url", g); | |
| h.attr("data-via", "grooveshark"); | |
| h.attr("data-count", "none"); | |
| h.addClass("twitter-share-button"); | |
| h.text("Tweet"); | |
| $("#page_content_social_buttons .tweetButton").empty().append(h); | |
| GS.getTwitter().parseWidgets() | |
| }), true); | |
| GS.getGoogle().parsePlusWidgets($("#page_content_social_buttons .googlePlusButton").get(0)) | |
| } | |
| }), 10) | |
| }, | |
| loadDigests: function( a ) { | |
| this.artist = a; | |
| this.artist.getSongs(this.callback("loadAlbumDigest")); | |
| GS.service.artistGetSimilarArtists(this.artist.ArtistID, this.callback("loadSimilarDigest")); | |
| GS.service.getSongkickEventsFromArtists([this.artist.ArtistID], [this.artist.ArtistName], this.callback("loadEventsDigest")); | |
| if (!GS.user.IsPremium ) { | |
| GS.getAd().updateRotationCount(); | |
| GS.getAd().buildAd($("#albumCapital_300"), 300, 250, ["p=album_overview"]) | |
| } | |
| }, | |
| loadAlbumDigest: function() { | |
| if ( this.artist && this.artist.albums ) { | |
| var a = this.album, | |
| b = _.toArray(this.artist.albums).sort(GS.Models.Album.prettySort).slice(0, 6).filter(function( c ) { | |
| return a.AlbumID != c.AlbumID | |
| }); | |
| b.length && $("#album_digest").html(this.view("/artist/album_digest", { | |
| artist: this.artist, | |
| albums: b | |
| })) | |
| } | |
| }, | |
| loadSimilarDigest: function( a ) { | |
| this.similarArtists = GS.Models.Artist.wrapCollection(a.SimilarArtists); | |
| this.similarArtists.length && this.element.find("#similarArtists_digest").html(this.view("/artist/similarArtists_digest")) | |
| }, | |
| loadEventsDigest: function( a ) { | |
| if ( a && a.length ) { | |
| a.sort(_.getSort("StartTime", -1)); | |
| a = a.slice(0, 5); | |
| $("#events_digest").html(this.view("/artist/event_digest", { | |
| artist: this.artist, | |
| events: a | |
| })) | |
| } | |
| }, | |
| loadGridFans: function( a ) { | |
| if ( this.subpage === "fans" ) { | |
| var b = GS.store.get("gs.sort.album.fans") || { | |
| sortCol: "Name", | |
| sortDir: 1, | |
| sortStoreKey: "gs.sort.albums.fans" | |
| }; | |
| b.scrollPane = $("#page_content"); | |
| if ( a.length ) this.element.find(".gs_grid").gs_grid(a, GS.Controllers.GridController.columns.user, b, "user"); | |
| else { | |
| this.element.find(".gs_grid").html(this.view("/shared/noResults", { | |
| type: "user" | |
| })); | |
| $("#searchForm input").select(); | |
| this.addAutocomplete("album"); | |
| GS.resize() | |
| } | |
| this.onPageLoaded() | |
| } | |
| }, | |
| loadGrid: function( a ) { | |
| if ( this.subpage === "music" ) { | |
| var b = this.element.find(".gs_grid").controller(), | |
| c = GS.store.get("gs.sort.album.songs") || { | |
| sortCol: "TrackNum", | |
| sortStoreKey: "gs.sort.albums.songs" | |
| }; | |
| c.scrollPane = $("#page_content"); | |
| c.filters = { | |
| artistIDs: false, | |
| albumIDs: false, | |
| onlyVerified: false | |
| }; | |
| c.useVerifiedSort = true; | |
| c.searchText = "SongName"; | |
| if ( b ) { | |
| c = b.dataView; | |
| var g = b.grid; | |
| if ( c ) { | |
| c.beginUpdate(); | |
| c.addItems(a, "SongID"); | |
| c.endUpdate(); | |
| c.refresh() | |
| } | |
| g && g.onSort(b.sortCol, b.sortDir) | |
| } else if ( a.length ) { | |
| if ( a.length < 5 && !this.triedUnverified ) { | |
| this.triedUnverified = true; | |
| this.album.getSongs(this.callback("loadGrid"), null, false) | |
| } else if (!this.triedUnverified ) { | |
| b = GS.Models.Song.getVerifiedDivider(); | |
| a.push(b); | |
| c.filters.onlyVerified = 1 | |
| } | |
| if ( this.playOnView && (a.length >= 5 || this.triedUnverified) ) this.album.play({ | |
| playOnAdd: true | |
| }); | |
| this.element.find(".gs_grid").gs_grid(a, GS.Controllers.GridController.columns.albumSongs, c, "song") | |
| } else if ( this.triedUnverified ) { | |
| this.element.find(".gs_grid").html(this.view("/shared/noResults", { | |
| type: "song" | |
| })); | |
| $("#searchForm input").select(); | |
| this.addAutocomplete("album"); | |
| GS.resize() | |
| } else { | |
| this.triedUnverified = true; | |
| this.album.getSongs(this.callback("loadGrid"), null, false) | |
| } | |
| this.onPageLoaded() | |
| } | |
| }, | |
| getOptionMenu: function() { | |
| var a = []; | |
| albumID = this.album.AlbumID; | |
| albumName = this.album.AlbumName; | |
| GS.user.isShortcut("album", albumID) ? a.push({ | |
| title: $.localize.getString("CONTEXT_REMOVE_FROM_PINBOARD"), | |
| action: { | |
| type: "fn", | |
| callback: function() { | |
| GS.user.removeFromShortcuts("album", albumID); | |
| $("#page_header a[name=shortcut]").parent().show(); | |
| $("#page_header a[name=removeshortcut]").parent().hide() | |
| } | |
| }, | |
| customClass: "jj_menu_item_hasIcon jj_menu_remove_music" | |
| }) : a.push({ | |
| title: $.localize.getString("CONTEXT_ADD_TO_PINBOARD"), | |
| action: { | |
| type: "fn", | |
| callback: function() { | |
| GS.user.addToShortcuts("album", albumID, albumName, true); | |
| $("#page_header a[name=shortcut]").parent().hide(); | |
| $("#page_header a[name=removeshortcut]").parent().show() | |
| } | |
| }, | |
| customClass: "jj_menu_item_hasIcon jj_menu_item_pinboard" | |
| }); | |
| a.push({ | |
| customClass: "separator" | |
| }); | |
| a.push({ | |
| title: $.localize.getString("SHARE_ALBUM"), | |
| type: "sub", | |
| action: { | |
| type: "fn", | |
| callback: this.album.getClipboardAction([{ | |
| text: "http://grooveshark.com/" + this.album.toUrl().replace("#/", ""), | |
| selector: "div.albumUrl" | |
| }]) | |
| }, | |
| src: this.album.getShareMenu(), | |
| customClass: "jj_menu_item_hasIcon jj_menu_item_share jj_menu_item_more" | |
| }); | |
| return a | |
| }, | |
| getShareMenu: function() { | |
| return this.album.getShareMenu() | |
| }, | |
| getSortMenu: function() { | |
| var a = this.setSort; | |
| return [{ | |
| title: $.localize.getString("SORT_BY_TRACK_NUM"), | |
| action: { | |
| type: "fn", | |
| callback: function() { | |
| a("TrackNum", triggerElement, "SORT_BY_TRACK_NUM") | |
| } | |
| }, | |
| customClass: "jj_menu_item_blank" | |
| }, { | |
| title: $.localize.getString("SORT_BY_POPULARITY"), | |
| action: { | |
| type: "fn", | |
| callback: function() { | |
| a("Popularity", triggerElement, "SORT_BY_POPULARITY") | |
| } | |
| }, | |
| customClass: "jj_menu_item_blank" | |
| }, { | |
| title: $.localize.getString("SORT_BY_SONG"), | |
| action: { | |
| type: "fn", | |
| callback: function() { | |
| a("SongName", triggerElement, "SORT_BY_SONG") | |
| } | |
| }, | |
| customClass: "jj_menu_item_blank" | |
| }, { | |
| title: $.localize.getString("SORT_BY_ARTIST"), | |
| action: { | |
| type: "fn", | |
| callback: function() { | |
| a("ArtistName", triggerElement, "SORT_BY_ARTIST") | |
| } | |
| }, | |
| customClass: "jj_menu_item_blank" | |
| }] | |
| }, | |
| ".slick-row.verifiedDivider click": function( a, b ) { | |
| b.stopPropagation(); | |
| var c = $("#grid").controller(), | |
| g; | |
| if ( c ) { | |
| if (!this.triedUnverified ) { | |
| this.triedUnverified = true; | |
| this.album.getSongs(this.callback("loadGrid"), null, false) | |
| } | |
| if ( c.filter.onlyVerified ) { | |
| a.find(".showMore").addClass("showingMore").attr("data-translate-text", "SEARCH_RESULTS_SHOW_LESS").html($.localize.getString("SEARCH_RESULTS_SHOW_LESS")); | |
| c.filter.onlyVerified = false | |
| } else { | |
| a.find(".showMore").removeClass("showingMore").attr("data-translate-text", "SEARCH_RESULTS_SHOW_MORE").html($.localize.getString("SEARCH_RESULTS_SHOW_MORE")); | |
| c.filter.onlyVerified = 1 | |
| }(g = c.grid) && g.onSort(c.sortCol, c.sortDir) | |
| } | |
| } | |
| }); | |
| GS.Controllers.PageController.extend("GS.Controllers.Page.ArtistController", {}, { | |
| type: "artist", | |
| artistImage: null, | |
| albumsSeen: {}, | |
| albums: [], | |
| feedEmpty: false, | |
| index: function( a, b ) { | |
| this.url = location.hash; | |
| this.id = parseInt(a, 10) || 0; | |
| this.subpage = _.orEqual(b, "profile"); | |
| if ( this.id < 0 ) GS.router.notFound(); | |
| else { | |
| this.albumsSeen = {}; | |
| this.albums = []; | |
| GS.Models.Artist.getArtist(this.id, this.callback("loadArtist")) | |
| } | |
| }, | |
| loadArtist: function( a ) { | |
| this.artist = a; | |
| if (!a.fanbase ) a.fanbase = GS.Models.Fanbase.wrap({ | |
| objectID: a.ArtistID, | |
| objectType: "artist" | |
| }); | |
| if (!a.feed ) a.feed = GS.Models.ArtistFeed.wrap({ | |
| artist: a | |
| }); | |
| this.correctUrl(this.artist, this.subpage === "profile" ? "" : this.subpage); | |
| this.fbUrl = "http://grooveshark.com/" + _.cleanUrl(this.artist.ArtistName, this.artist.ArtistID, "artist").replace("#/", ""); | |
| if ((this.artistImage = a.getImageURL(200)) && this.artistImage.indexOf("/webincludes/images/default") != -1 ) this.artistImage = null; | |
| switch ( this.subpage ) { | |
| case "profile": | |
| this.element.html(this.view("index")); | |
| GS.Controllers.PageController.title(this.artist.getTitle()); | |
| this.artist.feed.getFeed(this.callback("loadFeed"), this.callback("loadFeed")); | |
| this.loadDigests(); | |
| if (!GS.user.IsPremium ) { | |
| GS.getAd().updateRotationCount(); | |
| GS.getAd().buildAd($("#artistCapital_728"), 728, 90, ["p=artist_" + this.subpage]) | |
| } | |
| break; | |
| case "songs": | |
| this.element.html(this.view("index")); | |
| GS.Controllers.PageController.title(this.artist.getTitle() + " - Songs"); | |
| this.artist.getSongs(this.callback("loadSongs")); | |
| this.loadDigests(); | |
| break; | |
| case "albums": | |
| this.element.html(this.view("index")); | |
| GS.Controllers.PageController.title(this.artist.getTitle() + " - Albums"); | |
| this.artist.getSongs(this.callback("loadAlbums")); | |
| this.loadDigests(); | |
| break; | |
| case "events": | |
| this.element.html(this.view("index")); | |
| GS.Controllers.PageController.title(this.artist.getTitle() + " - Events"); | |
| GS.service.getSongkickEventsFromArtists([this.artist.ArtistID], [this.artist.ArtistName], this.callback("loadGridEvents"), this.callback("loadGridEventsFailed")); | |
| this.loadDigests(); | |
| break; | |
| case "collection": | |
| this.element.html(this.view("collection")); | |
| GS.Controllers.PageController.title(this.artist.getTitle()); | |
| $.publish("gs.page.loading.grid"); | |
| this.artist.getSongs(this.callback("loadGrid")); | |
| break; | |
| case "similar_artists": | |
| this.element.html(this.view("index")); | |
| GS.Controllers.PageController.title(this.artist.getTitle()); | |
| $.publish("gs.page.loading.grid"); | |
| GS.service.artistGetSimilarArtists(this.artist.ArtistID, this.callback("loadSimilarArtists")); | |
| this.loadDigests(); | |
| break; | |
| case "fans": | |
| this.element.html(this.view("index")); | |
| GS.Controllers.PageController.title(this.artist.getTitle()); | |
| $.publish("gs.page.loading.grid"); | |
| this.artist.fanbase.getFans(this.callback("loadFans"), this.callback("loadFans"), false); | |
| this.loadDigests(); | |
| break; | |
| default: | |
| GS.router.notFound() | |
| } | |
| GS.service.getArtistRecentListeners(this.artist.ArtistID) | |
| }, | |
| onPageLoaded: function() { | |
| setTimeout(this.callback(function() { | |
| if ( $("#page_content_social_buttons").length ) { | |
| var a = this.callback(function() { | |
| $("#page_content_social_buttons .fblike").css("width", this.likeWidth); | |
| this.loadLikeButtonCount(this.fbUrl); | |
| FB.XFBML.parse(window.document.getElementById("fbLike"), this.callback(function() { | |
| $("#page_content_social_buttons .fblike").css("width", this.likeWidth) | |
| })) | |
| }); | |
| if ( window.FB && FB.XFBML ) a(); | |
| else { | |
| var b; | |
| b = this.subscribe("gs.facebook.xfbml.ready", this.callback(function() { | |
| a(); | |
| $.unsubscribe(b) | |
| })) | |
| } | |
| GS.getTwitter().getTwitterShareMessage("artist", this.artist, this.fbUrl, this.callback(function( c, g ) { | |
| var h = $(document.createElement("a")); | |
| h.attr("data-text", c.replace('"', '"')); | |
| h.attr("data-url", g); | |
| h.attr("data-via", "grooveshark"); | |
| h.attr("data-count", "none"); | |
| h.addClass("twitter-share-button"); | |
| h.text("Tweet"); | |
| $("#page_content_social_buttons .tweetButton").empty().append(h); | |
| GS.getTwitter().parseWidgets() | |
| }), true); | |
| GS.getGoogle().parsePlusWidgets($("#page_content_social_buttons .googlePlusButton").get(0)) | |
| } | |
| }), 10) | |
| }, | |
| loadDigests: function() { | |
| this.artist.getTunipopID().then(this.callback("loadTunipop"), this.callback("loadTunipop")); | |
| this.subpage != "similar_artists" && GS.service.artistGetSimilarArtists(this.artist.ArtistID, this.callback("loadSimilarDigest")); | |
| this.fans = []; | |
| this.subpage != "fans" && this.artist.fanbase.getFans(this.callback("loadDigestFans"), this.callback("loadDigestFans"), false); | |
| this.subpage != "songs" && this.artist.getSongs(this.callback("loadTopSongsDigest"), function( a ) { | |
| return a.sort(_.getSort("Popularity")).filter(function( b ) { | |
| return b.CoverArtFilename | |
| }).slice(0, 5) | |
| }); | |
| this.subpage != "albums" && this.artist.getAlbums(this.callback("loadAlbumDigest"), function( a ) { | |
| return a.sort(GS.Models.Album.prettySort).slice(0, 5) | |
| }); | |
| this.subpage != "events" && GS.service.getSongkickEventsFromArtists([this.artist.ArtistID], [this.artist.ArtistName], this.callback("loadEventsDigest")); | |
| if (!GS.user.IsPremium ) { | |
| GS.getAd().updateRotationCount(); | |
| GS.getAd().buildAd($("#artistCapital_300"), 300, 250, ["p=artist_" + this.subpage]) | |
| } | |
| }, | |
| loadFeed: function() { | |
| var a, b; | |
| if ( this.artist && this.artist.feed && this.artist.feed.events && this.artist.feed.events.length ) { | |
| this.feed = this.artist.feed; | |
| this.activity = this.artist.feed.events; | |
| this.filteredUserIDs = []; | |
| $("#artistFeed").html(this.view("/user/community/feedEvents")); | |
| for ( a = 0; a < this.activity.length; a++ ) { | |
| b = this.activity[a]; | |
| $event = $("#feedEvent_" + b.eventID).data("event", b); | |
| b.dataString && b.dataString.hookup($event.find("p.what")) | |
| } | |
| } else { | |
| this.feedEmpty = | |
| true; | |
| this.artist.getSongs(this.callback("loadGridTopSongs")); | |
| $("#topSongs_digest").hide(); | |
| $("#feed").hide() | |
| } | |
| this.onPageLoaded() | |
| }, | |
| loadSimilarArtists: function( a ) { | |
| if ((this.similarArtists = GS.Models.Artist.wrapCollection(a.SimilarArtists)) && this.similarArtists.length ) { | |
| this.slickbox = $("#grid").slickbox({ | |
| scrollPane: "#page", | |
| padding: 0, | |
| listClass: "smallUserView", | |
| itemRenderer: GS.Models.Artist.itemRenderer, | |
| itemWidth: 195, | |
| itemHeight: 70, | |
| maxHorizontalGap: 100, | |
| minHorizontalGap: 15, | |
| verticalGap: 15, | |
| hidePositionInfo: true | |
| }, this.similarArtists); | |
| this.element.find("#page_content_synopsis button.radio").show() | |
| } else $("#grid").html(this.view("noSimilarResults")); | |
| GS.resize() | |
| }, | |
| loadFans: function( a ) { | |
| if ( a && a.length ) this.slickbox = $("#grid").slickbox({ | |
| scrollPane: "#page", | |
| padding: 0, | |
| listClass: "smallUserView", | |
| itemRenderer: GS.Models.User.itemRenderer, | |
| itemWidth: 195, | |
| itemHeight: 70, | |
| maxHorizontalGap: 100, | |
| minHorizontalGap: 15, | |
| verticalGap: 15, | |
| hidePositionInfo: true | |
| }, a); | |
| else $("#grid").html(this.view("noFanResults")); | |
| GS.resize() | |
| }, | |
| loadTopSongsDigest: function( a ) { | |
| a && a.length && $("#topSongs_digest").html(this.view("topSongs_digest", { | |
| songs: a, | |
| artist: this.artist | |
| })) | |
| }, | |
| loadAlbumDigest: function( a ) { | |
| a && a.length && $("#album_digest").html(this.view("album_digest", { | |
| albums: a, | |
| artist: this.artist | |
| })) | |
| }, | |
| loadSimilarDigest: function( a ) { | |
| this.similarArtists = GS.Models.Artist.wrapCollection(a.SimilarArtists); | |
| if ( this.similarArtists.length ) { | |
| this.element.find("#page_content_synopsis button.radio").show(); | |
| this.element.find("#similarArtists_digest").html(this.view("similarArtists_digest")) | |
| } | |
| }, | |
| loadDigestFans: function( a ) { | |
| if ( a ) { | |
| var b = []; | |
| for ( var c in a ) | |
| if ( a.hasOwnProperty(c) ) { | |
| if ( b.length > 19 ) break; | |
| a[c].Picture && b.push(a[c]) | |
| } | |
| this.fans = b; | |
| this.sidebarFans = true; | |
| $("#artistFans_digest").html(this.view("/shared/sidebarFans", { | |
| fans: b, | |
| seeAll: this.artist.toUrl("fans") | |
| })) | |
| } | |
| }, | |
| loadEventsDigest: function( a ) { | |
| if ( a && a.length ) { | |
| a.sort(_.getSort("StartTime", -1)); | |
| a = a.slice(0, 5); | |
| $("#events_digest").html(this.view("/artist/event_digest", { | |
| artist: this.artist, | |
| events: a | |
| })) | |
| } | |
| }, | |
| loadTunipop: function( a ) { | |
| if ( a && a > 0 ) { | |
| this.tunipopID = | |
| parseInt(a, 10); | |
| $(".tunipop").removeClass("hide") | |
| } else { | |
| this.tunipopID = 0; | |
| $(".tunipop").addClass("hide") | |
| } | |
| $(window).resize() | |
| }, | |
| loadSongs: function( a ) { | |
| this.subpage === "songs" && setTimeout(this.callback(function() { | |
| var b, c, g; | |
| c = store.get("gs.sort.artist.songs") || { | |
| sortCol: "Popularity", | |
| sortDir: 0, | |
| sortStoreKey: "gs.sort.artist.songs" | |
| }; | |
| b = $("#grid").controller(); | |
| c = $.extend(c, { | |
| filters: { | |
| artistIDs: false, | |
| albumIDs: false, | |
| onlyVerified: false | |
| }, | |
| padding: 0, | |
| scrollPane: $("#page") | |
| }); | |
| this.element.find("#grid").removeClass("songs artists users").addClass("songs"); | |
| if ( a.length ) { | |
| if ( b ) { | |
| c = b.dataView; | |
| g = b.grid; | |
| b.data = b.data.concat(a); | |
| if ( c ) { | |
| c.beginUpdate(); | |
| c.addItems(a, "SongID"); | |
| c.endUpdate(); | |
| c.refresh() | |
| } | |
| g && g.onSort(b.sortCol, b.sortDir) | |
| } else $("#grid").gs_grid(a, GS.Controllers.GridController.columns.song, c, "song"); | |
| this.onPageLoaded() | |
| } else { | |
| $("#grid").html(this.view("/shared/noResults", { | |
| type: "song" | |
| })); | |
| $("#searchForm input").select(); | |
| this.addAutocomplete("artist"); | |
| GS.resize(); | |
| b = (new GS.Models.DataString($.localize.getString("QUEUE_NUM_SONGS"), { | |
| numSongs: "0" | |
| })).render(); | |
| $("#gridNumItems").text(b).show() | |
| } | |
| }), 100) | |
| }, | |
| loadAlbums: function() { | |
| if ( this.subpage === "albums" ) { | |
| this.albums = _.toArray(this.artist.albums); | |
| this.albums.sort(_.getSort("AlbumName", true)); | |
| var a = this.albums.filter(function( b ) { | |
| return b.IsVerified == 1 || _.count(b.songs) >= 3 | |
| }); | |
| this.slickbox = $("#grid").slickbox({ | |
| scrollPane: "#page", | |
| padding: 0, | |
| itemRenderer: GS.Models.Album.itemRenderer, | |
| itemWidth: 250, | |
| itemHeight: 70, | |
| maxHorizontalGap: 50, | |
| minHorizontalGap: 10, | |
| verticalGap: 15, | |
| dragAs: "album", | |
| dragItemID: "AlbumID" | |
| }, a); | |
| this.sliderOrBoxDragSetup(this.slickbox, ".slickbox-item"); | |
| this.onPageLoaded() | |
| } | |
| }, | |
| loadGrid: function( a ) { | |
| this.subpage === "collection" && setTimeout(this.callback(function() { | |
| var b, c = [], | |
| g; | |
| g = GS.store.get("gs.sort.artist.songs") || { | |
| sortCol: "Popularity", | |
| sortDir: 0, | |
| sortStoreKey: "gs.sort.artist.songs" | |
| }; | |
| var h = this.element.find("#grid").controller(), | |
| k = this.element.find("#albumGrid").controller(); | |
| g = $.extend(g, { | |
| filters: { | |
| artistIDs: false, | |
| albumIDs: false, | |
| onlyVerified: false | |
| }, | |
| padding: 0 | |
| }); | |
| if ( a.length ) { | |
| for ( b = 0; b < a.length; b++ ) | |
| if (!this.albumsSeen[a[b].AlbumID] && a[b].AlbumName && a[b].AlbumName.length ) { | |
| var m = GS.Models.Album.wrap({ | |
| AlbumName: a[b].AlbumName, | |
| AlbumID: a[b].AlbumID, | |
| ArtistName: a[b].ArtistName, | |
| ArtistID: a[b].ArtistID, | |
| CoverArtFilename: a[b].CoverArtFilename | |
| }).dupe(); | |
| m.IsVerified = a[b].IsVerified == 1 ? 1 : 0; | |
| this.albums.push(m); | |
| c.push(m); | |
| this.albumsSeen[a[b].AlbumName] = true; | |
| this.albumsSeen[a[b].AlbumID] = true | |
| } | |
| if ( c.length && c.length === this.albums.length ) { | |
| b = GS.Models.Album.getFilterAll(this.artist.ArtistName); | |
| c.push(b) | |
| } | |
| $("#albumFilters").resizable({ | |
| handles: { | |
| e: $("#albumFilter-resize") | |
| }, | |
| minWidth: 30, | |
| maxWidth: 350, | |
| animate: false, | |
| resize: function() { | |
| $(window).resize() | |
| } | |
| }); | |
| this.element.find("#grid").removeClass("songs artists users").addClass("songs"); | |
| if ( h ) { | |
| b = h.dataView; | |
| g = h.grid; | |
| h.data = h.data.concat(a); | |
| if ( b ) { | |
| b.beginUpdate(); | |
| b.addItems(a, "SongID"); | |
| b.endUpdate(); | |
| b.refresh(); | |
| b = (new GS.Models.DataString($.localize.getString("QUEUE_NUM_SONGS"), { | |
| numSongs: b.rows.length | |
| })).render(); | |
| $("#gridNumItems").text(b).show() | |
| } | |
| g && g.onSort(h.sortCol, h.sortDir) | |
| } else if ( a.length ) { | |
| this.element.find(".gs_grid.songs").gs_grid(a, GS.Controllers.GridController.columns.song, g, "song"); | |
| b = (new GS.Models.DataString($.localize.getString("QUEUE_NUM_SONGS"), { | |
| numSongs: a.length | |
| })).render(); | |
| $("#gridNumItems").text(b).show() | |
| } | |
| if ( k ) { | |
| if ( c.length ) { | |
| b = k.dataView; | |
| g = k.grid; | |
| k.data = k.data.concat(c); | |
| if ( b ) { | |
| b.beginUpdate(); | |
| b.addItems(c, "AlbumID"); | |
| b.endUpdate(); | |
| b.refresh() | |
| } | |
| g && g.onSort(k.sortCol, k.sortDir) | |
| } | |
| } else this.element.find("#albumGrid").gs_grid(c, GS.Controllers.GridController.columns.albumFilter, { | |
| rowHeight: 25, | |
| sortCol: "AlbumName", | |
| isFilter: true, | |
| padding: 0 | |
| }, "album"); | |
| this.onPageLoaded() | |
| } else { | |
| this.element.find(".gs_grid.songs").html(this.view("/shared/noResults", { | |
| type: "song" | |
| })); | |
| $("#searchForm input").select(); | |
| this.addAutocomplete("artist"); | |
| GS.resize(); | |
| b = (new GS.Models.DataString($.localize.getString("QUEUE_NUM_SONGS"), { | |
| numSongs: "0" | |
| })).render(); | |
| $("#gridNumItems").text(b).show() | |
| } | |
| }), 100) | |
| }, | |
| loadGridFans: function( a ) { | |
| if (!(this.subpage !== "fans" && this.subpage !== "profile")) { | |
| var b = GS.store.get("gs.sort.artist.fans") || { | |
| sortCol: "Name", | |
| sortDir: 1, | |
| sortStoreKey: "gs.sort.artist.fans" | |
| }; | |
| b.scrollPane = $("#page"); | |
| var c = this.element.find("#grid").removeClass("songs artists users").addClass("users"); | |
| if ( a.length ) c.gs_grid(a, GS.Controllers.GridController.columns.user, b, "user"); | |
| else { | |
| c.html(this.view("/shared/noResults", { | |
| type: "user" | |
| })); | |
| $("#searchForm input").select(); | |
| this.addAutocomplete("artist"); | |
| GS.resize() | |
| } | |
| } | |
| }, | |
| loadGridTopSongs: function( a ) { | |
| if ( this.subpage === "profile" ) { | |
| var b = this.getTopSongs(a.concat()); | |
| if ( a.length ) { | |
| this.element.find("#topSongsGrid").show(); | |
| this.element.find("#grid.topSongs").gs_grid(b, GS.Controllers.GridController.columns.topSongs, { | |
| scrollPane: $("page"), | |
| padding: 0, | |
| sortCol: "Popularity", | |
| autoHeight: true | |
| }, "song") | |
| } | |
| } | |
| }, | |
| getTopSongs: function( a, b ) { | |
| b = _.orEqual(b, 6); | |
| return a.sort(function( c, g ) { | |
| var h = _.orEqual(parseInt(c.Popularity, 10), 0); | |
| return _.orEqual(parseInt(g.Popularity, 10), 0) - h | |
| }).slice(0, b) | |
| }, | |
| loadGridEvents: function( a ) { | |
| if ( this.subpage === "events" ) { | |
| var b = { | |
| sortCol: "StartTime", | |
| sortDir: 1, | |
| rowCssClasses: function() { | |
| return "event" | |
| }, | |
| scrollPane: $("#page") | |
| }; | |
| a = GS.Models.Event.wrapCollection(a, { | |
| USE_INDEX: "EventID", | |
| ArtistName: this.artist.ArtistName | |
| }); | |
| var c = this.element.find("#grid").removeClass("songs artists users").addClass("events"); | |
| if ( a.length ) c.gs_grid(a, GS.Controllers.GridController.columns.event, b, "event"); | |
| else { | |
| c.html(this.view("/shared/noResults", { | |
| type: "event" | |
| })); | |
| $("#searchForm input").select(); | |
| this.addAutocomplete("artist"); | |
| GS.resize() | |
| } | |
| this.onPageLoaded() | |
| } | |
| }, | |
| loadGridEventsFailed: function() { | |
| if ( this.subpage === "events" ) { | |
| this.element.find("#grid").removeClass("songs artists users").addClass("events").html(this.view("/shared/noResults", { | |
| type: "event" | |
| })); | |
| $("#searchForm input").select(); | |
| this.addAutocomplete("artist"); | |
| GS.resize(); | |
| this.onPageLoaded() | |
| } | |
| }, | |
| getSortMenu: function() { | |
| var a = this.setSort; | |
| return [{ | |
| title: $.localize.getString("SORT_BY_POPULARITY"), | |
| action: { | |
| type: "fn", | |
| callback: function() { | |
| a("Popularity", triggerElement, "SORT_BY_POPULARITY") | |
| } | |
| }, | |
| customClass: "jj_menu_item_blank" | |
| }, { | |
| title: $.localize.getString("SORT_BY_SONG"), | |
| action: { | |
| type: "fn", | |
| callback: function() { | |
| a("SongName", triggerElement, "SORT_BY_SONG") | |
| } | |
| }, | |
| customClass: "jj_menu_item_blank" | |
| }, { | |
| title: $.localize.getString("SORT_BY_ALBUM"), | |
| action: { | |
| type: "fn", | |
| callback: function() { | |
| a("AlbumName", triggerElement, "SORT_BY_ALBUM") | |
| } | |
| }, | |
| customClass: "jj_menu_item_blank" | |
| }, { | |
| title: $.localize.getString("SORT_BY_TRACK_NUM"), | |
| action: { | |
| type: "fn", | |
| callback: function() { | |
| a("TrackNum", triggerElement, "SORT_BY_TRACK_NUM") | |
| } | |
| }, | |
| customClass: "jj_menu_item_blank" | |
| }] | |
| }, | |
| getOptionMenu: function() { | |
| var a = [], | |
| b = this.artist.ArtistID, | |
| c = this.artist.ArtistName; | |
| GS.user.isShortcut("artist", b) ? a.push({ | |
| title: $.localize.getString("CONTEXT_REMOVE_FROM_PINBOARD"), | |
| action: { | |
| type: "fn", | |
| callback: function() { | |
| GS.user.removeFromShortcuts("artist", b); | |
| $("#page_header a[name=shortcut]").parent().show(); | |
| $("#page_header a[name=removeshortcut]").parent().hide() | |
| } | |
| }, | |
| customClass: "jj_menu_item_hasIcon jj_menu_remove_music" | |
| }) : a.push({ | |
| title: $.localize.getString("CONTEXT_ADD_TO_PINBOARD"), | |
| action: { | |
| type: "fn", | |
| callback: function() { | |
| GS.user.addToShortcuts("artist", b, c, true); | |
| $("#page_header a[name=shortcut]").parent().hide(); | |
| $("#page_header a[name=removeshortcut]").parent().show() | |
| } | |
| }, | |
| customClass: "jj_menu_item_hasIcon jj_menu_item_pinboard" | |
| }); | |
| a.push({ | |
| title: $.localize.getString("SHARE_ARTIST"), | |
| type: "sub", | |
| action: { | |
| type: "fn", | |
| callback: this.artist.getClipboardAction([{ | |
| text: "http://grooveshark.com/" + this.artist.toUrl().replace("#/", ""), | |
| selector: "div.artistUrl" | |
| }]) | |
| }, | |
| src: this.artist.getShareMenu(), | |
| customClass: "jj_menu_item_hasIcon jj_menu_item_share jj_menu_item_more" | |
| }); | |
| if ((GS.service.country.ID === 0 || GS.service.country.ID == 1 || GS.service.country.ID == 223) && this.tunipopID && !isNaN(this.tunipopID) && this.tunipopID > 0 ) a.push({ | |
| customClass: "separator" | |
| }, { | |
| title: $.localize.getString("CONTEXT_BUY_MERCH"), | |
| action: { | |
| type: "fn", | |
| callback: function() { | |
| GS.getLightbox().open("tunipop", { | |
| artistID: b | |
| }); | |
| GS.getGuts().onContextMenuClick("contextBuyMerch", "artistOptionsMenu", false, null) | |
| } | |
| }, | |
| customClass: "jj_menu_item_hasIcon jj_menu_item_buy_merch" | |
| }); | |
| return a | |
| }, | |
| getPlayMenu: function() { | |
| var a = this.artist, | |
| b = this.getPlayContext(), | |
| c = this.artist.ArtistID, | |
| g; | |
| g = [{ | |
| title: $.localize.getString("CONTEXT_PLAY_TOP_SONGS"), | |
| action: { | |
| type: "fn", | |
| callback: this.callback(function() { | |
| a.getSongs(this.callback(function( h ) { | |
| h = this.getTopSongs(_.toArray(h), 10); | |
| var k = []; | |
| _.forEach(h, function( m ) { | |
| k.push(m.SongID) | |
| }); | |
| GS.player.addSongsToQueueAt(k, GS.player.INDEX_DEFAULT, true, b) | |
| })) | |
| }) | |
| }, | |
| customClass: "jj_menu_item_hasIcon jj_menu_item_play" | |
| }]; | |
| this.similarArtists && this.similarArtists.length && g.push({ | |
| title: $.localize.getString("CONTEXT_START_STATION"), | |
| action: { | |
| type: "fn", | |
| callback: function() { | |
| GS.player.setAutoplay(true, null, { | |
| seeds: [c], | |
| seedArtistWeightRange: [110, 130], | |
| secondaryArtistWeightModifier: 0.75 | |
| }) | |
| } | |
| }, | |
| customClass: "jj_menu_item_hasIcon jj_menu_item_station" | |
| }); | |
| return g | |
| }, | |
| ".slick-row.verifiedDivider click": function( a, b ) { | |
| b.stopImmediatePropagation(); | |
| var c = $("#grid").controller(), | |
| g; | |
| if ( c ) { | |
| if ( c.filter.onlyVerified ) { | |
| a.find(".showMore").addClass("showingMore").attr("data-translate-text", "SEARCH_RESULTS_SHOW_LESS").html($.localize.getString("SEARCH_RESULTS_SHOW_LESS")); | |
| c.filter.onlyVerified = false | |
| } else { | |
| a.find(".showMore").removeClass("showingMore").attr("data-translate-text", "SEARCH_RESULTS_SHOW_MORE").html($.localize.getString("SEARCH_RESULTS_SHOW_MORE")); | |
| c.filter.onlyVerified = | |
| 1 | |
| }(g = c.grid) && g.onSort(c.sortCol, c.sortDir) | |
| } | |
| }, | |
| "a.tunipop click": function( a ) { | |
| a = parseInt($(a).attr("rel"), 10); | |
| if ( this.tunipopID ) GS.getLightbox().open("tunipop", { | |
| tunipopID: this.tunipopID | |
| }); | |
| else a && GS.getLightbox().open("tunipop", { | |
| artistID: this.artistID | |
| }) | |
| }, | |
| "#profileImage .icon click": function() { | |
| this.artist.getArtAttribution(this.callback(function( a ) { | |
| var b = new GS.Models.DataString, | |
| c = ""; | |
| if ( a.URL ) { | |
| b.string = $.localize.getString("POPUP_ARTIST_ART_MESSAGE"); | |
| c = a.URL | |
| } else b.string = $.localize.getString("POPUP_ARTIST_ART_MESSAGE_BROKEN"); | |
| b.data = { | |
| src: this.artist.getImageURL(500), | |
| url: c | |
| }; | |
| GS.getLightbox().close(); | |
| GS.getLightbox().open({ | |
| type: "artistArtAttribution", | |
| view: { | |
| headerHTML: this.artist.ArtistName, | |
| messageHTML: '<div id="artistPopupImage">' + b.render() + "</div>", | |
| buttonsRight: [], | |
| buttonsLeft: [{ | |
| label: "CLOSE", | |
| className: "close" | |
| }] | |
| }, | |
| loadCallback: function() { | |
| GS.getLightbox().positionLightbox(); | |
| $("#artistPopupImage img").load(function() { | |
| GS.getLightbox().positionLightbox() | |
| }) | |
| } | |
| }) | |
| })) | |
| }, | |
| ".capitalSliderBtn click": function( a ) { | |
| console.warn("here"); | |
| a = $(a); | |
| $(a).hasClass("capitalSliderNext") ? $(".capitalView_728").animate({ | |
| scrollLeft: $(".capitalView_728").scrollLeft() + 200 | |
| }, 500) : $(".capitalView_728").animate({ | |
| scrollLeft: $(".capitalView_728").scrollLeft() - 200 | |
| }, 500) | |
| }, | |
| "#similarArtists_digest a click": function( a, b ) { | |
| GS.getGuts().artistPageSidebarClick(a, b, "similarArtists") | |
| }, | |
| "#artistFans_digest a click": function( a, b ) { | |
| GS.getGuts().artistPageSidebarClick(a, b, "fans") | |
| }, | |
| "#events_digest a click": function( a, b ) { | |
| GS.getGuts().artistPageSidebarClick(a, b, "events") | |
| } | |
| }); | |
| GS.Controllers.PageController.extend("GS.Controllers.Page.ExploreController", {}, { | |
| featuredData: null, | |
| index: function( a, b ) { | |
| this.subpage = _.orEqual(a, "featured"); | |
| this.pageType = _.orEqual(b, ""); | |
| this.type = "explore"; | |
| GS.Controllers.PageController.title("Explore Music: " + _.ucwords(this.subpage)); | |
| switch ( this.subpage ) { | |
| case "featured": | |
| this.explore = GS.Models.Explore.getType("featured"); | |
| this.element.html(this.view("index")); | |
| this.explore.getFeaturedData(this.callback("loadFeaturedPage"), this.callback("loadFeaturedPageError")); | |
| break; | |
| case "playlists": | |
| this.explore = GS.Models.Explore.getType("featured"); | |
| this.element.html(this.view("index")); | |
| this.explore.getFeaturedData(this.callback("loadFeaturedPage"), this.callback("loadFeaturedPageError")); | |
| break; | |
| case "videos": | |
| this.explore = GS.Models.Explore.getType("featured"); | |
| this.element.html(this.view("index")); | |
| this.explore.getFeaturedData(this.callback("loadFeaturedPage"), this.callback("loadFeaturedPageError")); | |
| break; | |
| case "popular": | |
| this.explore = GS.Models.Explore.getType("featured"); | |
| this.element.html(this.view("popular")); | |
| this.loadPopular(); | |
| break; | |
| case "stations": | |
| this.explore = GS.Models.Explore.getType("featured"); | |
| this.element.html(this.view("index")); | |
| this.loadStations(); | |
| break | |
| } | |
| this.loadExploreSidebar(); | |
| GS.resize() | |
| }, | |
| loadPopular: function() { | |
| this.list.doSearchInPage = true; | |
| this.explore.getPopularSongs(this.callback("loadPopularGrid")) | |
| }, | |
| loadPopularGrid: function( a ) { | |
| var b, c = { | |
| sortCol: "Popularity", | |
| sortDir: true, | |
| sortStoreKey: "gs.sort.popular", | |
| scrollPane: $("#page"), | |
| padding: 0 | |
| }; | |
| if ( a.length ) { | |
| b = GS.Controllers.GridController.columns.song.concat(); | |
| b = [b[0], b[1], b[2]]; | |
| this.element.find(".gs_grid").gs_grid(a, b, c, "song") | |
| } else { | |
| this.element.find(".gs_grid").html(this.view("/shared/noResults", { | |
| type: "song" | |
| })); | |
| $("#searchForm input").select(); | |
| GS.resize() | |
| } | |
| }, | |
| loadExploreSidebar: function() { | |
| if ( this.subpage == "featured" || this.subpage == "playlists" || this.subpage == "videos" ) { | |
| this.explore.getPopularSongs(this.callback("loadPopularSidebar"), this.callback("loadFeaturedPageError")); | |
| this.loadStationsSidebar() | |
| } else if ( this.subpage == "popular" ) { | |
| this.loadStationsSidebar(); | |
| this.explore.getFeaturedData(this.callback("loadArtistsSidebar"), this.callback("loadFeaturedPageError")) | |
| } else if ( this.subpage == "stations" ) { | |
| this.explore.getPopularSongs(this.callback("loadPopularSidebar"), this.callback("loadFeaturedPageError")); | |
| this.explore.getFeaturedData(this.callback("loadArtistsSidebar"), this.callback("loadFeaturedPageError")) | |
| } | |
| if (!GS.user.IsPremium ) { | |
| GS.getAd().updateRotationCount(); | |
| GS.getAd().buildAd($("#exploreCapital_300"), 300, 250, ["p=explore_" + this.subpage]); | |
| var a = this.subpage == "popular" || this.subpage == "stations" ? this.subpage : "featured"; | |
| GS.getAd().buildAd($("#exploreCapital_728"), 728, 90, ["p=explore_" + a]) | |
| } | |
| }, | |
| loadPopularSidebar: function( a ) { | |
| a = a.concat().sort(_.getSort("Popularity")).filter(function( b ) { | |
| return b.CoverArtFilename | |
| }).slice(0, 5); | |
| $("#profilePopular").html(this.view("popular_sidebar", { | |
| data: a | |
| })) | |
| }, | |
| loadStationsSidebar: function() { | |
| var a = GS.Models.Station.tagStations; | |
| a.sort(function() { | |
| return 0.5 - Math.random() | |
| }); | |
| $("#profileStations").html(this.view("station_sidebar", { | |
| data: a | |
| })) | |
| }, | |
| loadArtistsSidebar: function() { | |
| var a = this.explore.featuredData.Contents, | |
| b = []; | |
| for ( i = 0; i < a.length; i++ ) | |
| if ( a[i].name == "Artists" ) { | |
| b = a[i].items.slice(0, 5); | |
| break | |
| } | |
| $("#profileArtists").html(this.view("artists_sidebar", { | |
| data: b | |
| })) | |
| }, | |
| loadFeaturedPage: function() { | |
| $("#page_sidebar_featured").html(this.view("page_sidebar_featured")); | |
| if ( this.pageType ) this.loadGrid(this.pageType); | |
| else { | |
| var a; | |
| if ( this.subpage == "featured" ) a = this.explore.featuredData.Contents; | |
| else if ( this.subpage == "playlists" ) a = this.explore.featuredPlaylists; | |
| else if ( this.subpage == "videos" ) a = this.explore.featuredVideos; | |
| this.loadFeaturedSections(a) | |
| } | |
| }, | |
| loadFeaturedPageError: function() { | |
| if ( this.subpage == "featured" ) { | |
| console.warn("failed to load featured content"); | |
| $("#page_sidebar_featured").html(this.view("page_sidebar_featured")); | |
| $("#grid").html(this.view("noResults")) | |
| } | |
| }, | |
| loadFeaturedSections: function( a ) { | |
| $featuredSections = $("#featuredSections"); | |
| if ( a ) { | |
| var b = {}, | |
| c, g; | |
| $featuredSections.empty(); | |
| for ( var h = 0, k = a.length; h < k; h++ ) { | |
| c = _.guessDragType(a[h].items[0]); | |
| g = c != "unknown" ? _.ucwords(c) + "ID" : false; | |
| b.title = a[h].name; | |
| b.sectionID = "featured_" + _.cleanURLSlug(b.title); | |
| $featuredSections.append(this.view("featured_section", $.extend({ | |
| subpage: this.subpage | |
| }, b))); | |
| $sectionElem = $("#" + b.sectionID + " .items"); | |
| $sectionElem.slickbox({ | |
| scrollPane: "#page_content", | |
| padding: 0, | |
| itemRenderer: GS.Models.Explore.proxyRenderer, | |
| itemWidth: 120, | |
| itemHeight: 175, | |
| maxHorizontalGap: 50, | |
| minHorizontalGap: 20, | |
| verticalGap: 30, | |
| dragAs: c, | |
| dragItemID: g, | |
| hidePositionInfo: true, | |
| drawAll: true | |
| }, a[h].items); | |
| g && this.sliderOrBoxDragSetup($sectionElem, ".slickbox-item") | |
| } | |
| GS.resize() | |
| } | |
| }, | |
| loadGrid: function( a ) { | |
| var b = { | |
| sortFunction: null, | |
| scrollPane: "#page", | |
| padding: 15, | |
| itemRenderer: GS.Models.Explore.proxyRenderer, | |
| itemWidth: 120, | |
| itemHeight: 160, | |
| maxHorizontalGap: 60, | |
| minHorizontalGap: 15, | |
| verticalGap: 10, | |
| hidePositionInfo: true | |
| }, | |
| c; | |
| if (["playlists", "artists", "songs", "albums"].indexOf(a) != -1 ) { | |
| b.dragAs = a.substring(0, a.length - 1); | |
| b.dragItemID = _.ucwords(b.dragAs) + "ID" | |
| } | |
| for ( i = 0; i < this.explore.featuredData.Contents.length; i++ ) | |
| if (!c && _.cleanURLSlug(this.explore.featuredData.Contents[i].name) == a ) c = this.explore.featuredData.Contents[i].items; | |
| GS.resize(); | |
| this.slickbox = $("#grid").slickbox(b, c); | |
| GS.resize(); | |
| this.sliderOrBoxDragSetup(this.slickbox, ".slickbox-item") | |
| }, | |
| loadStations: function() { | |
| var a = GS.Models.Station.tagStations; | |
| options = { | |
| sortCol: "StationName", | |
| sortDir: true, | |
| disableMultiSelect: true, | |
| scrollPane: $("#page_content") | |
| }; | |
| $(".gs_grid").gs_grid(a, GS.Controllers.GridController.columns.station, options, "station"); | |
| $(".gs_grid").addClass("radioStations") | |
| }, | |
| getSortMenu: function() { | |
| var a = this.setSort; | |
| return [{ | |
| title: $.localize.getString("SORT_BY_POPULARITY"), | |
| action: { | |
| type: "fn", | |
| callback: function() { | |
| a("Popularity", triggerElement, "SORT_BY_POPULARITY") | |
| } | |
| }, | |
| customClass: "jj_menu_item_blank" | |
| }, { | |
| title: $.localize.getString("SORT_BY_SONG"), | |
| action: { | |
| type: "fn", | |
| callback: function() { | |
| a("SongName", triggerElement, "SORT_BY_SONG") | |
| } | |
| }, | |
| customClass: "jj_menu_item_blank" | |
| }, { | |
| title: $.localize.getString("SORT_BY_ARTIST"), | |
| action: { | |
| type: "fn", | |
| callback: function() { | |
| a("ArtistName", triggerElement, "SORT_BY_ARTIST") | |
| } | |
| }, | |
| customClass: "jj_menu_item_blank" | |
| }, { | |
| title: $.localize.getString("SORT_BY_ALBUM"), | |
| action: { | |
| type: "fn", | |
| callback: function() { | |
| a("AlbumName", triggerElement, "SORT_BY_ALBUM") | |
| } | |
| }, | |
| customClass: "jj_menu_item_blank" | |
| }] | |
| }, | |
| "#profileSongs .songLink click": function( a, b ) { | |
| b.preventDefault(); | |
| GS.Models.Song.getSong(a.attr("data-songid"), function( c ) { | |
| if ( c = c && $.isFunction(c.toUrl) ? c.toUrl() : false ) location.hash = c | |
| }, null, false) | |
| }, | |
| ".station a click": function( a, b ) { | |
| b.stopPropagation(); | |
| var c = a.attr("data-tagid"); | |
| GS.player.setAutoplay(true, c); | |
| return false | |
| }, | |
| ".capitalSliderBtn click": function( a ) { | |
| a = | |
| $(a); | |
| a.scrollLeft(0); | |
| $(a).hasClass("capitalSliderNext") ? $(".capitalView_728").animate({ | |
| scrollLeft: $(".capitalView_728").scrollLeft() + 200 | |
| }, 500) : $(".capitalView_728").animate({ | |
| scrollLeft: $(".capitalView_728").scrollLeft() - 200 | |
| }, 500) | |
| }, | |
| ".showMore_featured click": function( a, b ) { | |
| b.preventDefault(); | |
| if ( a.hasClass("showLess") ) { | |
| a.find(".label").text($.localize.getString("SHOW_MORE")); | |
| a.removeClass("showLess").prev().toggleClass("open") | |
| } else { | |
| a.find(".label").text($.localize.getString("SHOW_LESS")); | |
| a.addClass("showLess").prev().toggleClass("open") | |
| } | |
| }, | |
| "#featuredSections a click": function( a, b ) { | |
| if (!$(b.target).hasClass("playBtn") ) { | |
| var c = $(a).parents(".slickbox-item"), | |
| g = $(a).attr("href"); | |
| if ( c.length ) { | |
| var h = $(a).parents(".page_content_featuredSection").attr("id"), | |
| k = c.attr("data-dragtype"); | |
| c = c.attr("data-dragid"); | |
| GS.getGuts().forceLogEvent("featuredItemClick", { | |
| type: k, | |
| section: h, | |
| id: c, | |
| href: g | |
| }) | |
| } | |
| } | |
| }, | |
| "#featuredSections .playBtn click": function( a ) { | |
| var b = $(a).parents(".slickbox-item"); | |
| if ( b.length ) { | |
| a = $(a).parents(".page_content_featuredSection").attr("id"); | |
| var c = | |
| b.attr("data-dragtype"); | |
| b = b.attr("data-dragid"); | |
| GS.getGuts().forceLogEvent("featuredItemPlay", { | |
| type: c, | |
| section: a, | |
| id: b | |
| }) | |
| } | |
| }, | |
| "#featuredSections .followArtist click": function( a ) { | |
| a = $(a).attr("data-artistid"); | |
| GS.user.favorites.artists.hasOwnProperty(a) ? GS.getGuts().forceLogEvent("featuredArtistUnfollow", { | |
| id: a | |
| }) : GS.getGuts().forceLogEvent("featuredArtistFollow", { | |
| id: a | |
| }) | |
| }, | |
| ".videoPlayBtn click": function( a ) { | |
| var b = this.explore.videoGroups[_.orEqual(a.attr("data-videogroup"), "")]; | |
| a = GS.Models.Video.getOneFromCache(a.attr("data-videoid"), "featured"); | |
| var c = 0; | |
| for ( i = 0; i < b.length; i++ ) | |
| if ( b[i].VideoID == a.VideoID ) c = i; | |
| GS.getLightbox().open("video", { | |
| videos: b, | |
| index: c, | |
| autoSkipToNextVideo: false, | |
| renderSection: false | |
| }) | |
| } | |
| }); | |
| GS.Controllers.PageController.extend("GS.Controllers.Page.UserController", {}, { | |
| adTimeoutID: null, | |
| correctUrl: function( a, b, c ) { | |
| this._super(a, b + (b && c ? "/" : "") + c) | |
| }, | |
| index: function( a ) { | |
| this.UserID = parseInt(a, 10); | |
| if ( this.UserID === 0 ) GS.router.notFound(); | |
| else if ( GS.user.UserID ) { | |
| GS.user.UserID == this.UserID ? this.loadMyProfile() : GS.Models.User.getUser(this.UserID, this.callback(this.loadProfile)); | |
| this.subscribe("gs.auth.user.update", this.callback("userUpdated")); | |
| this.subscribe("gs.auth.favorite.user", this.callback("userUpdated")); | |
| this.subscribe("gs.locale.update", this.callback("onLocaleUpdate")); | |
| this.subscribe("gs.auth.favorites.users.update", this.callback("userFavoritesUpdated")) | |
| } else this.subscribe("gs.app.ready", this.callback(this.index, a)) | |
| }, | |
| userChangeTimeout: false, | |
| userChangeWaitDuration: 100, | |
| userFavoritesUpdated: function() { | |
| clearTimeout(this.userChangeTimeout); | |
| this.userChangeTimeout = setTimeout(this.callback(function() { | |
| if ( this.user ) { | |
| var a = GS.user.favorites.users[this.user.UserID]; | |
| if ( a ) GS.user.UserID == this.user.UserID ? this.loadMyProfile() : this.loadProfile(a) | |
| } | |
| }), this.userChangeWaitDuration) | |
| }, | |
| userUpdated: function( a ) { | |
| clearTimeout(this.userChangeTimeout); | |
| this.userChangeTimeout = setTimeout(this.callback(function() { | |
| if ( this.user && this.user.UserID === a.UserID ) GS.user.UserID == this.user.UserID ? this.loadMyProfile() : this.loadProfile(a) | |
| }), this.userChangeWaitDuration) | |
| }, | |
| loadMyProfile: function() { | |
| this.user = GS.user; | |
| this.UserID = this.user.UserID; | |
| this.subpage = this.section = ""; | |
| this.correctUrl(this.user, this.section, this.subpage); | |
| GS.Controllers.PageController.title(this.user.getTitle()); | |
| this.element.empty().scrollTop(0).html(this.view("profile")); | |
| this.user.getProfileFeed(this.callback("loadGridProfileFeed", this.user), this.callback("loadGridProfileFeed", this.user)); | |
| this.loadDigests(this.user); | |
| $.publish("gs.profile.view", { | |
| user: this.user | |
| }) | |
| }, | |
| loadProfile: function( a ) { | |
| this.user = a; | |
| if (!a.library ) a.library = GS.Models.Library.wrap({ | |
| userID: a.UserID | |
| }); | |
| if (!a.fanbase ) a.fanbase = GS.Models.Fanbase.wrap({ | |
| objectID: a.UserID, | |
| objectType: "user" | |
| }); | |
| if (!a.profileFeed ) a.profileFeed = GS.Models.ProfileFeed.wrap({ | |
| user: a | |
| }); | |
| if (!a.communityFeed ) a.communityFeed = GS.Models.CommunityFeed.wrap({ | |
| user: a | |
| }); | |
| this.UserID = this.user.UserID; | |
| this.subpage = this.section = ""; | |
| this.correctUrl(this.user, this.section, this.subpage); | |
| GS.Controllers.PageController.title(this.user.getTitle()); | |
| this.element.empty().scrollTop(0).html(this.view("profile")); | |
| $.publish("gs.profile.view", { | |
| user: this.user | |
| }); | |
| this.user.getProfileFeed(this.callback("loadGridProfileFeed", this.user), this.callback("loadGridProfileFeed", this.user)); | |
| this.loadDigests(); | |
| this.resetBroadcastForm() | |
| }, | |
| loadDigests: function() { | |
| this.user.getPlaylists(this.callback("loadPlaylistDigest", this.user)); | |
| this.user.getFavoritesByType("Artists", this.callback("loadFavoriteArtistDigest", this.user)); | |
| this.user.getFavoritesByType("Users", this.callback("loadUserFollowingDigest", this.user)) | |
| }, | |
| loadPlaylistDigest: function( a ) { | |
| this.user = a; | |
| this.UserID = this.user.UserID; | |
| this.topPlaylists = _.toArray(this.user.playlists).sort(function( b, c ) { | |
| return c.TSAdded > b.TSAdded | |
| }); | |
| $("#playlist_digest").html(this.view("/user/playlist_digest", { | |
| playlists: this.topPlaylists, | |
| user: this.user | |
| })); | |
| if (!GS.user.IsPremium ) { | |
| a = this.subpage.length ? this.subpage : GS.Controllers.PageController.activePage.section; | |
| a = a.length ? a : "activity"; | |
| if ( GS.getAd ) { | |
| GS.getAd().updateRotationCount(); | |
| GS.getAd().buildAd($("#profileCapital_300"), 300, 250, ["p=" + (GS.user.UserID == this.UserID ? "my" : "") + "profile_" + a]); | |
| GS.user.UserID != this.UserID && GS.getAd().buildAd($("#profileCapital_728"), 728, 90, ["p=profile_" + a]) | |
| } | |
| } | |
| }, | |
| loadUserFollowingDigest: function( a ) { | |
| var b = _.toArray(a.favorites.users); | |
| b = b.sort(function( c, g ) { | |
| return !c.Picture && g.Picture ? 1 : c.Picture && !g.Picture ? -1 : 0 | |
| }); | |
| $("#following_digest").html(this.view("/user/following_digest", { | |
| following: b, | |
| user: a | |
| })) | |
| }, | |
| loadFavoriteArtistDigest: function( a ) { | |
| var b = []; | |
| a = a.favorites.artists; | |
| for ( var c in a ) | |
| a.hasOwnProperty(c) && b.push(a[c]); | |
| b.sort(function( g, h ) { | |
| return Date.parse(h.TSFavorited) - Date.parse(g.TSFavorited) | |
| }); | |
| b = b.slice(0, 5); | |
| $("#artist_digest").html(this.view("/user/artist_digest", { | |
| artists: b, | |
| titleLabel: "USER_FAVORITE_ARTISTS" | |
| })) | |
| }, | |
| loadGridProfileFeed: function( a, b ) { | |
| if (!(this.section !== "" || this.subpage !== "")) { | |
| if (!this.user.profileFeed.isLoaded ) return false; | |
| if (!GS.user.fanbase ) GS.user.fanbase = GS.Models.Fanbase.wrap({ | |
| objectID: GS.user.UserID, | |
| objectType: "user" | |
| }); | |
| if ( GS.user.UserID > 0 && !GS.user.fanbase.fansLoaded ) GS.user.fanbase.getFans(this.callback(function() { | |
| this.loadGridProfileFeed(a, b) | |
| }), null, false); | |
| else { | |
| this.feed = this.user.profileFeed; | |
| this.activity = this.user.profileFeed.events; | |
| this.noFriends = false; | |
| this.filteredUserIDs = []; | |
| if ( this.activity && this.activity.length ) { | |
| this.element.find(".gs_grid").html(this.view("community/activity")); | |
| this.feed.hasMore || $(".feeds_loadMore").show(); | |
| for ( var c, g, h = 0; h < this.activity.length; h++ ) { | |
| g = this.activity[h]; | |
| c = $("#feedEvent_" + g.eventID).data("event", g); | |
| g.dataString && g.dataString.hookup(c.find("p.what")) | |
| } | |
| } else { | |
| this.element.find(".gs_grid").html(this.view("community/noActivityResults")); | |
| $("#searchForm input").select() | |
| } | |
| GS.resize(); | |
| GS.page.resetRefreshButton() | |
| } | |
| } | |
| }, | |
| redirectUser: function( a ) { | |
| this.user = a; | |
| this.UserID = this.user.UserID; | |
| location.hash = this.user.toUrl(); | |
| return false | |
| }, | |
| myCommunity: false, | |
| noFriends: false, | |
| filteredUserIDs: [], | |
| community: function( a, b ) { | |
| this.UserID = a; | |
| this.section = "community"; | |
| this.subpage = b; | |
| this.currentFilterStr = ""; | |
| if ( b == "following" ) GS.user.UserID == this.UserID ? this.loadFollowing(GS.user) : GS.Models.User.getUser(this.UserID, this.callback("loadFollowing")); | |
| else if ( b == "fans" ) GS.user.UserID == this.UserID ? this.loadFans(GS.user) : GS.Models.User.getUser(this.UserID, this.callback("loadFans")); | |
| else if ( b == "recent" ) this.loadRecentActiveFeed(GS.user); | |
| else if ( b == "mentions" ) GS.user.UserID == this.UserID && GS.user.UserID > 0 ? this.loadMyMentions(GS.user) : GS.router.notFound(); | |
| else if ( GS.user.UserID == this.UserID || this.UserID == -1 ) { | |
| this.loadMyCommunity(GS.user); | |
| this.myCommunity = true | |
| } else GS.Models.User.getUser(this.UserID, this.callback("loadCommunity")) | |
| }, | |
| loadMyCommunity: function() { | |
| this.user = GS.user; | |
| this.correctUrl(this.user, this.section, this.subpage); | |
| GS.Controllers.PageController.title(this.user.getTitle() + " - Community"); | |
| this.element.empty().scrollTop(0).html(this.view("community/myCommunity")); | |
| if (!this.user.userFavoritesLoaded && this.UserID > 0 ) this.subscribe("gs.auth.favorites.users.update", this.callback("loadCommunityFeed")); | |
| else { | |
| this.loadCommunityFeed(); | |
| if (!GS.user.IsPremium ) if (!this.adTimeoutID ) this.adTimeoutID = setTimeout(this.callback(function() { | |
| GS.getAd().updateRotationCount(); | |
| var a = this.subpage && this.subpage.length ? this.subpage : "activity"; | |
| GS.getAd().buildAd($("#commCapital_300"), 300, 250, ["p=community_" + a]); | |
| this.adTimeoutID = null | |
| }), 100) | |
| } | |
| }, | |
| loadMyMentions: function() { | |
| this.user = GS.user; | |
| this.correctUrl(this.user, this.section, this.subpage); | |
| GS.Controllers.PageController.title(this.user.getTitle() + " - Mentions"); | |
| this.element.html(this.view("community/myCommunity")); | |
| this.loadMentionFeed(); | |
| if (!GS.user.IsPremium ) if (!this.adTimeoutID ) this.adTimeoutID = setTimeout(this.callback(function() { | |
| GS.getAd().updateRotationCount(); | |
| var a = this.subpage && this.subpage.length ? this.subpage : "activity"; | |
| GS.getAd().buildAd($("#commCapital_300"), 300, 250, ["p=community_" + a]); | |
| this.adTimeoutID = null | |
| }), 100) | |
| }, | |
| communitySidebar: function( a ) { | |
| if ( a && a.isComplete ) { | |
| var b = | |
| a.events, | |
| c, g = {}, | |
| h = {}; | |
| c = []; | |
| for ( var k = [], m = 0; m < b.length; m++ ) { | |
| c = b[m]; | |
| if (!(this.user.UserID == GS.user.UserID && c.user.UserID == this.user.UserID)) { | |
| k = c.user.UserID; | |
| if (!(a.userIDs && a.userIDs.indexOf(k.toString()) > -1)) { | |
| if ( g[c.user.UserID] ) g[c.user.UserID].weight++; | |
| else g[c.user.UserID] = { | |
| user: c.user, | |
| weight: 1 | |
| }; | |
| if ( c.data.hasOwnProperty("songs") && c.data.songs[0].artistID && c.data.songs[0].artistName && c.data.songs[0].artistName != "unknown" ) if ( h[c.data.songs[0].artistID] ) { | |
| h[c.data.songs[0].artistID].weight++; | |
| h[c.data.songs[0].artistID].users[c.user.UserID] = | |
| c.user | |
| } else { | |
| k = {}; | |
| k[c.user.UserID] = c.user; | |
| h[c.data.songs[0].artistID] = { | |
| artist: GS.Models.Artist.wrap({ | |
| ArtistID: c.data.songs[0].artistID, | |
| ArtistName: c.data.songs[0].artistName | |
| }, false), | |
| weight: 1, | |
| users: k | |
| } | |
| } | |
| } | |
| } | |
| } | |
| k = _.toArray(h).sort(_.getSort("weight", false)).slice(0, 10); | |
| c = _.toArray(g).sort(_.getSort("weight", false)).slice(0, 20); | |
| for ( m = 0; m < k.length; m++ ) | |
| k[m].users = _.toArray(k[m].users); | |
| if ( c.length % 11 === 0 ) c = c.slice(0, Math.floor(c.length / 10) * 10); | |
| $("#communityUsers").html(this.view("community/myCommunity_activeUsers", { | |
| userInfo: c | |
| })); | |
| $("#communityArtists").html(this.view("community/myCommunity_topArtists", { | |
| artistInfo: k | |
| })); | |
| if ( this.user.UserID > 0 && this.user.UserID == GS.user.UserID ) { | |
| $("#communityProfileStats").html(this.view("community/myCommunity_profile")); | |
| GS.user.getPlaylists(this.callback("showMyPlaylistCount")); | |
| GS.user.fanbase.getFans(this.callback("showMyFanCount", null, false), null, false) | |
| } | |
| } | |
| }, | |
| showMyPlaylistCount: function() { | |
| $("#bio_playlistCount").html(_.count(GS.user.playlists)) | |
| }, | |
| showMyFanCount: function() { | |
| $("#bio_fanCount").html(GS.user.fanbase.userIDs.length) | |
| }, | |
| loadCommunity: function( a ) { | |
| this.user = a; | |
| this.correctUrl(this.user, this.section, this.subpage); | |
| GS.Controllers.PageController.title(this.user.getTitle() + " - Community"); | |
| this.element.empty().scrollTop(0).html(this.view("community/community")); | |
| $.publish("gs.page.loading.grid"); | |
| this.user.UserID > 0 ? this.user.getFavoritesByType("Users", this.callback("loadCommunityFeed")) : GS.Models.RecentFeed.interestingFeed.getFeed(this.callback("loadGridCommunityFeed", GS.Models.RecentFeed.interestingFeed)); | |
| this.loadDigests(this.user) | |
| }, | |
| loadCommunityFeed: function() { | |
| if (!GS.user.fanbase ) GS.user.fanbase = GS.Models.Fanbase.wrap({ | |
| objectID: GS.user.UserID, | |
| objectType: "user" | |
| }); | |
| if ( GS.user.UserID > 0 && !GS.user.fanbase.fansLoaded ) GS.user.fanbase.getFans(this.callback(this.loadCommunityFeed), null, false); | |
| else { | |
| if (!this.user.communityFeed ) this.user.communityFeed = GS.Models.CommunityFeed.wrap({ | |
| user: this.user | |
| }); | |
| if ( this.user.UserID > 0 && _.count(this.user.favorites.users) ) { | |
| this.users = this.user.favorites.users; | |
| this.noFriends = false; | |
| this.communityFeed = this.user.communityFeed; | |
| this.user.getCommunityFeed(this.callback("loadGridCommunityFeed", this.user.communityFeed), this.callback("loadGridCommunityFeed", this.user.communityFeed)) | |
| } else { | |
| this.communityFeed = GS.Models.RecentFeed.interestingFeed; | |
| GS.Models.RecentFeed.interestingFeed.getFeed(this.callback("loadGridCommunityFeed", GS.Models.RecentFeed.interestingFeed), this.callback("loadGridCommunityFeed", GS.Models.RecentFeed.interestingFeed)) | |
| } | |
| } | |
| }, | |
| loadMentionFeed: function() { | |
| this.mentionFeed = GS.user.mentionsFeed; | |
| this.mentionFeed.getFeed(this.callback("loadGridCommunityFeed", this.mentionFeed)) | |
| }, | |
| loadGridCommunityFeed: function( a ) { | |
| if (!a.isLoaded || !this.element || this.section != "community" || this.subpage == "mentions" && a.type != "mentions" ) return false; | |
| this.feed = a; | |
| this.activity = a.events; | |
| if ( this.user === GS.user && a.type == "community" ) this.myCommunity = true; | |
| this.filteredUserIDs = this.communityFeed && typeof this.communityFeed.userIDs === "object" ? this.communityFeed.userIDs : []; | |
| if ( this.activity.length ) { | |
| this.element.find(".gs_grid").html(this.view("community/activity")); | |
| a.pages.length == 1 && GS.resize(); | |
| a.hasMore || $(".feeds_loadMore").show() | |
| } else { | |
| this.element.find(".gs_grid").html(this.view("community/noActivityResults")); | |
| $("#searchForm input").select(); | |
| GS.resize() | |
| } | |
| for ( var b = 0; b < this.activity.length; b++ ) { | |
| var c = this.activity[b], | |
| g = $("#feedEvent_" + c.eventID).data("event", c); | |
| c.dataString && c.dataString.hookup(g.find("p.what")) | |
| } | |
| this.communitySidebar(a); | |
| GS.page.resetRefreshButton() | |
| }, | |
| loadRecentActiveFeed: function( a ) { | |
| this.user = a; | |
| this.correctUrl(this.user, this.section, this.subpage); | |
| GS.Controllers.PageController.title(this.user.getTitle() + " - Recent Activity"); | |
| this.element.html(this.view("community/community")); | |
| this.user.getRecentlyActiveUsersFeed(this.callback("loadGridRecentActiveFeed")) | |
| }, | |
| loadGridRecentActiveFeed: function() { | |
| this.feed = this.user.recentActiveUsersFeed; | |
| this.activity = this.user.recentActiveUsersFeed.events; | |
| this.noFriends = false; | |
| this.filteredUserIDs = []; | |
| if ( this.activity.length ) this.element.find(".gs_grid").html(this.view("community/activity")); | |
| else { | |
| this.element.find(".gs_grid").html(this.view("/shared/noResults", { | |
| type: "activity" | |
| })); | |
| $("#searchForm input").select() | |
| } | |
| this.element.find(".event").each(this.callback(function( a, b ) { | |
| $(b).data("event", this.activity[a]); | |
| this.activity[a].dataString.hookup($(b).find("p.what")) | |
| })); | |
| GS.resize() | |
| }, | |
| loadFollowing: function( a ) { | |
| this.user = a; | |
| this.correctUrl(this.user, this.section, this.subpage); | |
| GS.Controllers.PageController.title(this.user.getTitle() + " - Following"); | |
| this.element.html(this.view("community/community")); | |
| this.user.getFavoritesByType("Users", this.callback(this.renderFollows)); | |
| this.loadDigests(a); | |
| GS.resize() | |
| }, | |
| renderFollows: function() { | |
| if ( this.subpage == "following" ) { | |
| this.followUsers = _.toArray(this.user.favorites.users); | |
| this.followUsers.sort(this.sortByPictureAlphabet); | |
| if ( this.followUsers.length ) { | |
| var a = this.followUsers.filter(this.callback("filterUsersFunction")); | |
| $("#grid").html("").css("height", "auto").addClass("userlist"); | |
| this.slickbox = $("#grid").slickbox({ | |
| scrollPane: "#page", | |
| padding: 0, | |
| listClass: "smallUserView", | |
| itemRenderer: GS.Models.User.itemRenderer, | |
| itemWidth: 195, | |
| itemHeight: 70, | |
| maxHorizontalGap: 100, | |
| minHorizontalGap: 15, | |
| verticalGap: 15 | |
| }, a) | |
| } else { | |
| $("#grid").html(this.view("noFollowResults")); | |
| GS.resize() | |
| } | |
| } | |
| }, | |
| loadFans: function( a ) { | |
| if ( this.subpage == "fans" ) { | |
| this.user = a; | |
| this.correctUrl(this.user, this.section, this.subpage); | |
| GS.Controllers.PageController.title(this.user.getTitle() + " - Fans"); | |
| this.element.html(this.view("community/community")); | |
| if (!this.user.fanbase ) this.user.fanbase = GS.Models.Fanbase.wrap({ | |
| objectID: a.UserID, | |
| objectType: "user" | |
| }); | |
| this.user.fanbase.getFans(this.callback(this.renderFans)); | |
| this.loadDigests(a); | |
| GS.resize() | |
| } | |
| }, | |
| renderFans: function( a ) { | |
| this.fanUsers = a; | |
| this.fanUsers.sort(this.sortByPictureAlphabet); | |
| if ( this.fanUsers.length ) { | |
| a = this.fanUsers.filter(this.callback(this.filterUsersFunction)); | |
| $("#grid").html("").css("height", "auto").addClass("userlist"); | |
| this.slickbox = $("#grid").slickbox({ | |
| scrollPane: "#page", | |
| padding: 0, | |
| listClass: "smallUserView", | |
| itemRenderer: GS.Models.User.itemRenderer, | |
| itemWidth: 195, | |
| itemHeight: 70, | |
| maxHorizontalGap: 15, | |
| minHorizontalGap: 15, | |
| verticalGap: 15 | |
| }, a) | |
| } else { | |
| $("#grid").html(this.view("noFanResults")); | |
| GS.resize() | |
| } | |
| }, | |
| sortByPictureAlphabet: function( a, b ) { | |
| return !a.Picture && b.Picture ? 1 : a.Picture && !b.Picture ? -1 : a.Name.toLowerCase() < b.Name.toLowerCase() ? -1 : a.Name.toLowerCase() > b.Name.toLowerCase() ? 1 : 0 | |
| }, | |
| currentFilterStr: null, | |
| filterUsers: function( a ) { | |
| if ( this.currentFilterStr != a ) { | |
| this.currentFilterStr = a; | |
| if ( this.subpage == "fans" ) this.fanUsers && this.renderFans(this.fanUsers); | |
| else this.subpage == "following" && this.followUsers && this.renderFollows(this.followUsers) | |
| } | |
| }, | |
| filterUsersFunction: function( a ) { | |
| return (a.Username.toLowerCase() + " " + a.Name.toLowerCase()).indexOf(this.currentFilterStr.toLowerCase()) !== -1 | |
| }, | |
| onLocaleUpdate: function() { | |
| if ( this.user ) { | |
| var a = this.user.getAccountDuration(); | |
| _.isEmpty(a) || $("#userAcctDuration").html((new GS.Models.DataString($.localize.getString(a.key), a)).render()) | |
| } | |
| }, | |
| "#broadcastSearch input focus": function() { | |
| $("#broadcastSearch .placeholder").hide() | |
| }, | |
| "#broadcastSearch input blur": function( a ) { | |
| $("#broadcastSearch .placeholder").toggle(!$(a).val().length) | |
| }, | |
| "#broadcastMentions input focus": function() { | |
| $("#broadcastMentions .placeholder").hide() | |
| }, | |
| "#broadcastMentions input blur": function( a ) { | |
| $("#broadcastMentions .placeholder").toggle(!$(a).val().length) | |
| }, | |
| "#broadcastMessage textarea focus": function() { | |
| $("#broadcastMessage .placeholder").hide() | |
| }, | |
| "#broadcastMessage textarea blur": function( a ) { | |
| $("#broadcastMessage .placeholder").toggle(!$(a).val().length) | |
| }, | |
| ".placeholder click": function( a ) { | |
| $(a).siblings("input, textarea").eq(0).focus() | |
| }, | |
| "#broadcastSearchForm submit": function() { | |
| return false | |
| }, | |
| loadBroadcastSearchResults: function( a, b, c, g ) { | |
| g = g ? g.result || g : []; | |
| b = []; | |
| b = g.slice(0, 5); | |
| switch ( c ) { | |
| case "playlist": | |
| b = _.toArray(GS.user.playlists).concat(_.toArray(GS.user.favorites.playlists)).filter(GS.Models.Playlist.matchFilter(a)).splice(0, 5); | |
| break; | |
| case "song": | |
| b = GS.Models.Song.wrapCollection(b); | |
| b = _.toArray(GS.user.library.songs).filter(GS.Models.Song.matchFilter(a, true)).concat(b).splice(0, 5); | |
| break; | |
| case "album": | |
| b = GS.Models.Album.wrapCollection(b); | |
| break; | |
| case "artist": | |
| b = GS.Models.Artist.wrapCollection(b); | |
| break; | |
| default: | |
| console.warn("Cannot wrap results"); | |
| return | |
| } | |
| b.length ? $("#broadcastSearchResults").html(this.view("/shared/broadcast/searchResults", { | |
| results: b, | |
| type: c | |
| })).removeClass("hide") : $("#broadcastSearchResults").html(this.view("/shared/broadcast/noResults", { | |
| type: this.broadcastType | |
| })).removeClass("hide"); | |
| $("body").unbind("click.broadcastResults").bind("click.broadcastResults", function( h ) { | |
| if (!$(h.target).parent("broadcastResult").length ) { | |
| $("#broadcastSearchResults").addClass("hide"); | |
| $(this).unbind("click.broadcastResults") | |
| } | |
| }) | |
| }, | |
| ".broadcastOption click": function( a, b ) { | |
| $el = $(a); | |
| b.preventDefault(); | |
| this.broadcastType = _.ucwords(a.attr("rel")) + "s"; | |
| $el.siblings().removeClass("active"); | |
| $el.addClass("active"); | |
| $("#broadcastForm").addClass("hide"); | |
| $("#broadcastSearchResults").empty(); | |
| $("#broadcastSearch .placeholder").html($.localize.getString("SEARCH_" + this.broadcastType.toUpperCase()) + "\u2026"); | |
| $("#broadcastSearch input").val("").parent().removeClass("hide").children("input").focus() | |
| }, | |
| "#broadcastForm .close click": function() { | |
| this.resetBroadcastForm() | |
| }, | |
| lastBroadcastSearch: null, | |
| broadcastMentions: {}, | |
| broadcastMentionsLookup: {}, | |
| broadcastType: "Songs", | |
| "#broadcastSearch input keyup": function( a, b ) { | |
| if ( b.which == _.keys.DOWN && $("#broadcastSearchResults ul").length ) $("#broadcastSearchResults .active").length ? $("#broadcastSearchResults .active").removeClass("active").next().addClass("active") : $("#broadcastSearchResults li:first").addClass("active"); | |
| else if ( b.which == _.keys.UP && $("#broadcastSearchResults ul").length ) $("#broadcastSearchResults .active").length ? $("#broadcastSearchResults .active").removeClass("active").prev().addClass("active") : $("#broadcastSearchResults li:last").addClass("active"); | |
| else if ( b.which == _.keys.ENTER && $("#broadcastSearchResults .active").length ) { | |
| b.preventDefault(); | |
| $("#broadcastSearchResults .active a").trigger("click") | |
| } else if ( this.lastBroadcastSearch != a.val() ) { | |
| this.lastBroadcastSearch = a.val(); | |
| this.searchRequest && clearTimeout(this.searchRequest); | |
| if (!this.lastBroadcastSearch || this.lastBroadcastSearch.length && this.lastBroadcastSearch.length < 4 ) $("#broadcastSearchResults").addClass("hide").html(""); | |
| else { | |
| $("#broadcastSearchResults").html("<ul><li>" + this.view("/shared/loadingIndicator") + "</li></ul>").removeClass("hide"); | |
| this.searchRequest = setTimeout(this.callback(function() { | |
| var c = a.val(); | |
| if ( c ) { | |
| var g = this.broadcastType.substr(0, this.broadcastType.length - 1).toLowerCase(); | |
| g == "playlist" ? this.loadBroadcastSearchResults(c, "", "playlist") : GS.service.getAutocomplete(c, g, this.callback(this.loadBroadcastSearchResults, c, "", g), this.callback(this.loadBroadcastSearchResults, c, "", g)) | |
| } else $("#broadcastSearchResults").addClass("hide") | |
| }), 500) | |
| } | |
| } | |
| }, | |
| "#broadcastSearchResults .broadcastResult click": function( a ) { | |
| $("#broadcastSearchResults, #broadcastSearch").addClass("hide"); | |
| $("#broadcastForm").removeClass("hide"); | |
| if ( a.attr("data-playlistid") ) GS.Models.Playlist.getPlaylist(a.attr("data-playlistid"), this.callback(function( b ) { | |
| this.broadcastItem = b; | |
| $("#broadcastItem").html(this.view("/shared/broadcast/searchItem")).removeClass("hide") | |
| })); | |
| else if ( a.attr("data-songid") ) GS.Models.Song.getSong(a.attr("data-songid"), this.callback(function( b ) { | |
| this.broadcastItem = b; | |
| $("#broadcastItem").html(this.view("/shared/broadcast/searchItem")).removeClass("hide") | |
| })); | |
| else if ( a.attr("data-albumid") ) GS.Models.Album.getAlbum(a.attr("data-albumid"), this.callback(function( b ) { | |
| this.broadcastItem = b; | |
| $("#broadcastItem").html(this.view("/shared/broadcast/searchItem")).removeClass("hide") | |
| })); | |
| else a.attr("data-artistid") && GS.Models.Artist.getArtist(a.attr("data-artistid"), this.callback(function( b ) { | |
| this.broadcastItem = b; | |
| $("#broadcastItem").html(this.view("/shared/broadcast/searchItem")).removeClass("hide") | |
| })) | |
| }, | |
| ".broadcastSearchResults li hover": function( a ) { | |
| a.addClass("active").siblings().removeClass("active") | |
| }, | |
| ".broadcastMentions keydown": function( a, b ) { | |
| if ( b.which == _.keys.ENTER && $("#broadcastMentionResults .active").length ) return false | |
| }, | |
| ".broadcastMentions keyup": function( a, b ) { | |
| if ( b.which == _.keys.DOWN && $("#broadcastMentionResults ul").length ) $("#broadcastMentionResults .active").length ? $("#broadcastMentionResults .active").removeClass("active").next().addClass("active") : $("#broadcastMentionResults li:first").addClass("active"); | |
| else if ( b.which == _.keys.UP && $("#broadcastMentionResults ul").length ) $("#broadcastMentionResults .active").length ? $("#broadcastMentionResults .active").removeClass("active").prev().addClass("active") : $("#broadcastMentionResults li:last").addClass("active"); | |
| else { | |
| if ( b.which == _.keys.ENTER && $("#broadcastMentionResults .active").length ) { | |
| b.preventDefault(); | |
| b.stopPropagation(); | |
| $("#broadcastMentionResults .active a").trigger("click"); | |
| return false | |
| } | |
| var c = $(".broadcastMentions").val().match(/(^|\W)(\w+)($|\W)/g); | |
| if ( c && c.length ) { | |
| c = $.trim(c.pop()); | |
| var g = _.toArray(GS.user.favorites.users).filter(GS.Models.User.matchFilter(c)).slice(0, 5); | |
| g.length ? $("#broadcastMentionResults").html(this.view("/shared/broadcast/searchResults", { | |
| results: g, | |
| match: c, | |
| type: "user" | |
| })).show() : $("#broadcastMentionResults").empty().hide() | |
| } else $("#broadcastMentionResults").empty().hide() | |
| } | |
| }, | |
| ".broadcastMessage keyup": function( a ) { | |
| var b = $(".broadcastMessage").val().substr(0, 140); | |
| parseInt($(".broadcastCharCount").text(), 10) <= 0 && $(".broadcastMessage").val(b); | |
| $(".broadcastCharCount").text(140 - a.val().length) | |
| }, | |
| "#broadcastMentionResults .broadcastResult click": function( a ) { | |
| var b = a.attr("data-userid"); | |
| a = a.attr("data-match"); | |
| var c; | |
| if ( GS.user.favorites.users[b] ) { | |
| if ( c = | |
| GS.user.favorites.users[b] ) { | |
| this.broadcastMentions[b] = c.getDetailsForFeeds(); | |
| this.broadcastMentionsLookup[c.Name] = b | |
| } | |
| b = $(".broadcastMentions").val(); | |
| b = b.replace(a, c.Name) + ", "; | |
| $("#broadcastMentionResults").empty().hide(); | |
| $(".broadcastMentions").val(b).focus(); | |
| $("#broadcastItem .mentions").html(this.view("/shared/broadcast/formMentions")) | |
| } | |
| }, | |
| ".broadcastMessage focus": function() { | |
| $("#broadcastMentions").show() | |
| }, | |
| broadcastTypes: { | |
| Songs: "song", | |
| Playlists: "playlist", | |
| Albums: "album", | |
| Artists: "artist" | |
| }, | |
| "#broadcastForm submit": function( a, b ) { | |
| b.preventDefault(); | |
| b.stopPropagation(); | |
| var c = $(".broadcastMentions").val(); | |
| _.forEach(this.broadcastMentionsLookup, function( m, p ) { | |
| c.indexOf(p) == -1 && delete this.broadcastMentions[m] | |
| }, this); | |
| ($("input[name=to]", a).val() || "").split(","); | |
| var g = $("textarea[name=message]", a).val(), | |
| h = $(".broadcastItemInner").attr("id"), | |
| k = _.toArray(this.broadcastMentions); | |
| $(a).find("button.submit").attr("disabled", "true"); | |
| GS.service.sendFeedBroadcast(this.broadcastTypes[this.broadcastType], h, k, g, this.callback("broadcastSuccess"), this.callback("broadcastFail")); | |
| $("#broadcastForm input.facebook:checked").length == 1 && GS.getFacebook().postToFeed("me", "http://grooveshark.com" + this.broadcastItem.toUrl().replace("#/", "/"), g, this.broadcastTypes[this.broadcastType], this.broadcastTypes[this.broadcastType] + "Share"); | |
| return false | |
| }, | |
| resetBroadcastForm: function() { | |
| $("#broadcastForm").addClass("hide"); | |
| $(".broadcastOption:first").addClass("active").siblings().removeClass("active"); | |
| $(".broadcastQuery").val(""); | |
| $(".broadcastMessage").val(""); | |
| $(".broadcastMentions").val(""); | |
| $(".broadcastCharCount").text(140); | |
| $("#broadcastSearch").val("").removeClass("hide"); | |
| $("#broadcastForm button.submit").removeAttr("disabled"); | |
| $("#broadcastForm .placeholder").show(); | |
| this.broadcastMentions = {}; | |
| this.broadcastMentionsLookup = {}; | |
| if ( this.user.UserID !== GS.user.UserID ) { | |
| this.broadcastMentions[this.user.UserID] = this.user.getDetailsForFeeds(); | |
| this.broadcastMentionsLookup[this.user.Name] = this.user.UserID; | |
| $(".broadcastMentions").val(this.user.Name + ", "); | |
| $("#broadcastMentions .placeholder").hide() | |
| } | |
| }, | |
| broadcastSuccess: function() { | |
| this.resetBroadcastForm(); | |
| this.feed.isDirty = true; | |
| if ( this.feed.type == "community" ) setTimeout(this.callback(function() { | |
| this.loadCommunityFeed() | |
| }), 3E3); | |
| else this.feed.type == "profile" && setTimeout(this.callback(function() { | |
| this.loadProfile(this.user) | |
| }), 3E3) | |
| }, | |
| broadcastFail: function() { | |
| $.publish("gs.notification", { | |
| type: "notice", | |
| message: _.getString("NOTIFICATION_BROADCAST_FAILED", { | |
| type: this.broadcastType | |
| }) | |
| }) | |
| }, | |
| "#broadcastForm input.facebook change": function( a ) { | |
| if ( a.is(":checked") ) if (!GS.getFacebook().connected && GS.getFacebook().facebookUserID && GS.getFacebook().loggedIntoFacebook ) GS.getFacebook().showChangeUserLightbox(); | |
| else!GS.getFacebook().connected && GS.getFacebook().facebookUserID && !GS.getFacebook().loggedIntoFacebook && GS.getFacebook().login() | |
| }, | |
| getPlayMenu: function() { | |
| if ( $("#page").hasClass("gs_page_music") ) return this._super(); | |
| var a = this.user; | |
| return [{ | |
| title: $.localize.getString("PLAY_NOW"), | |
| action: { | |
| type: "fn", | |
| callback: function() { | |
| a.profileFeed && a.profileFeed.play(GS.player.INDEX_DEFAULT, true) | |
| } | |
| }, | |
| customClass: "jj_menu_item_hasIcon jj_menu_item_play" | |
| }, { | |
| title: $.localize.getString("PLAY_NEXT"), | |
| action: { | |
| type: "fn", | |
| callback: function() { | |
| a.profileFeed && a.profileFeed.play(GS.player.INDEX_NEXT, false) | |
| } | |
| }, | |
| customClass: "jj_menu_item_hasIcon jj_menu_item_play_next" | |
| }, { | |
| title: $.localize.getString("PLAY_LAST"), | |
| action: { | |
| type: "fn", | |
| callback: function() { | |
| a.profileFeed && a.profileFeed.play(GS.player.INDEX_LAST, false) | |
| } | |
| }, | |
| customClass: "jj_menu_item_hasIcon jj_menu_item_play_last" | |
| }, { | |
| customClass: "separator" | |
| }, { | |
| title: $.localize.getString("REPLACE_QUEUE"), | |
| action: { | |
| type: "fn", | |
| callback: function() { | |
| a.profileFeed && a.profileFeed.play(GS.player.INDEX_REPLACE, true) | |
| } | |
| }, | |
| customClass: "jj_menu_item_hasIcon jj_menu_item_replace_playlist" | |
| }] | |
| }, | |
| "button.play_user click": function() { | |
| this.UserID > 0 && this.user.profileFeed.play(-1, true, 0, 100) | |
| }, | |
| "button.play_community click": function() { | |
| this.user.communityFeed.play(-1, true, 0, 100) | |
| }, | |
| "button.invite click": function() { | |
| this.UserID == GS.user.UserID && GS.user.UserID > 0 && GS.getLightbox().open("invite") | |
| }, | |
| ".capitalSliderBtn click": function( a ) { | |
| a = $(a); | |
| a.scrollLeft(0); | |
| $(a).hasClass("capitalSliderNext") ? $(".capitalView_728").animate({ | |
| scrollLeft: $(".capitalView_728").scrollLeft() + 200 | |
| }, 500) : $(".capitalView_728").animate({ | |
| scrollLeft: $(".capitalView_728").scrollLeft() - 200 | |
| }, 500) | |
| } | |
| }); | |
| GS.Controllers.Page.UserController.extend("GS.Controllers.Page.MusicController", { | |
| init: function() { | |
| this._super(); | |
| this.loadFilterCollapseState() | |
| } | |
| }, { | |
| section: "music", | |
| type: "music", | |
| subscribed: false, | |
| adTimeoutID: null, | |
| correctUrl: function( a, b, c, g ) { | |
| c = _.orEqual(c, ""); | |
| g = _.orEqual(g, ""); | |
| this._super(a, b, c + (b && c && g.length ? "/" : "") + g) | |
| }, | |
| init: function() { | |
| this._super(); | |
| GS.getSidebar() | |
| }, | |
| index: function( a, b ) { | |
| this.UserID = parseInt(a, 10); | |
| this.subpage = _.orEqual(b, ""); | |
| if ( this.UserID === 0 ) GS.router.notFound(); | |
| else { | |
| if ( GS.user.UserID == this.UserID ) { | |
| this.user = GS.user; | |
| this.UserID = this.user.UserID; | |
| this.correctUrl(this.user, this.section, this.subpage); | |
| if ( this.subpage === "favorites" ) { | |
| GS.Controllers.PageController.title(GS.user.getTitle() + " - Favorites"); | |
| this.subscribe("gs.auth.favorites.songs.add", this.callback("addToGrid")); | |
| this.subscribe("gs.auth.favorites.songs.remove", this.callback("removeFromGrid")); | |
| this.loadMySongFavorites() | |
| } else { | |
| GS.Controllers.PageController.title(GS.user.getTitle() + " - Music"); | |
| this.subscribe("gs.auth.library.add", this.callback("addToGrid")); | |
| this.subscribe("gs.auth.library.remove", this.callback("removeFromGrid")); | |
| this.loadMyMusic() | |
| } | |
| this.element.find("#page_header button.opts").show() | |
| } else GS.Models.User.getUser(this.UserID, this.callback("loadMusic")); | |
| if (!GS.user.IsPremium ) if (!this.adTimeoutID ) this.adTimeoutID = setTimeout(this.callback(function() { | |
| GS.getAd().updateRotationCount(); | |
| GS.getAd().buildAd($("#musicCapital_160"), 160, 600, ["p=mymusic_" + (this.subpage.length ? this.subpage : "songs")]); | |
| this.adTimeoutID = null | |
| }), 100) | |
| } | |
| }, | |
| favorites: function( a ) { | |
| this.index(a, "favorites") | |
| }, | |
| albums: function( a ) { | |
| this.UserID = parseInt(a, 10); | |
| this.subpage = "albums"; | |
| if ( GS.user.UserID == this.UserID ) { | |
| this.user = GS.user; | |
| this.UserID = this.user.UserID; | |
| this.correctUrl(this.user, this.section, this.subpage); | |
| GS.Controllers.PageController.title(GS.user.getTitle() + " - Albums"); | |
| this.loadMyAlbums() | |
| } else GS.Models.User.getUser(this.UserID, this.callback("loadAlbums")) | |
| }, | |
| loadMyMusic: function() { | |
| this.user = GS.user; | |
| this.UserID = this.user.UserID; | |
| this.correctUrl(this.user, this.section, this.subpage); | |
| this.element.html(this.view("/user/music/myMusic")); | |
| var a = [], | |
| b; | |
| for ( b in GS.user.library.songs ) | |
| if ( GS.user.library.songs.hasOwnProperty(b) ) { | |
| GS.user.library.songs[b].fromLibrary = 1; | |
| a.push(GS.user.library.songs[b]) | |
| } | |
| this.loadGridMusic(a, true) | |
| }, | |
| loadMyAlbums: function() { | |
| this.user = GS.user; | |
| this.UserID = this.user.UserID; | |
| this.correctUrl(this.user, this.section, this.subpage); | |
| this.element.html(this.view("/user/music/albums")); | |
| var a = [], | |
| b; | |
| for ( b in GS.user.library.songs ) | |
| if ( GS.user.library.songs.hasOwnProperty(b) ) { | |
| GS.user.library.songs[b].fromLibrary = | |
| 1; | |
| a.push(GS.user.library.songs[b]) | |
| } | |
| this.loadGridAlbums(a, true) | |
| }, | |
| addToGrid: function( a ) { | |
| if ( this.UserID === GS.user.UserID ) { | |
| a.isDeleted = false; | |
| var b = this.element.find(".gs_grid.songs").controller(); | |
| if ( b ) { | |
| var c = this.element.find(".gs_grid.artists").controller(), | |
| g = this.element.find(".gs_grid.albums").controller(), | |
| h = b.grid, | |
| k = b.dataView; | |
| b.data.push(a); | |
| if ( k ) { | |
| k.beginUpdate(); | |
| k.addItem(a); | |
| k.endUpdate(); | |
| k = (new GS.Models.DataString($.localize.getString("QUEUE_NUM_SONGS"), { | |
| numSongs: k.rows.length | |
| })).render(); | |
| $("#gridNumItems").text(k).show() | |
| } | |
| h && h.onSort(b.sortCol, b.sortDir); | |
| if (!this.albumsSeen[a.AlbumID] && a.AlbumName && a.AlbumName.length ) { | |
| g.dataView.beginUpdate(); | |
| b = GS.Models.Album.wrap({ | |
| AlbumName: a.AlbumName, | |
| AlbumID: a.AlbumID, | |
| ArtistName: a.ArtistName, | |
| ArtistID: a.ArtistID, | |
| CoverArtFilename: songs[i].CoverArtFilename | |
| }, true, "m_"); | |
| b.IsVerified = 0; | |
| g.dataView.addItem(b); | |
| g.dataView.endUpdate(); | |
| this.albumsSeen[a.AlbumID] = true; | |
| g.grid && g.grid.onSort(g.sortCol, g.sortDir) | |
| } | |
| if (!this.artistsSeen[a.ArtistID] && a.ArtistName && a.ArtistName.length ) { | |
| c.dataView.beginUpdate(); | |
| g = GS.Models.Artist.wrap({ | |
| ArtistName: a.ArtistName, | |
| ArtistID: a.ArtistID | |
| }, true, "m_"); | |
| g.IsVerified = 0; | |
| c.dataView.addItem(g); | |
| c.dataView.endUpdate(); | |
| this.artistsSeen[a.ArtistID] = true; | |
| c.grid && c.grid.onSort(c.sortCol, c.sortDir) | |
| } | |
| } else this.loadMyMusic() | |
| } | |
| }, | |
| removeFromGrid: function( a ) { | |
| a.isDeleted = true; | |
| var b = this.element.find(".gs_grid.songs").controller(), | |
| c = b.grid, | |
| g = b.dataView; | |
| if ( g ) { | |
| g.beginUpdate(); | |
| g.updateItem(a.SongID, a); | |
| g.endUpdate() | |
| } | |
| c && c.onSort(b.sortCol, b.sortDir) | |
| }, | |
| loadMySongFavorites: function() { | |
| this.user = | |
| GS.user; | |
| this.UserID = this.user.UserID; | |
| this.section = "music"; | |
| this.correctUrl(this.user, this.section, this.subpage); | |
| this.element.html(this.view("/user/music/myMusic")); | |
| var a = [], | |
| b; | |
| for ( b in GS.user.favorites.songs ) | |
| GS.user.favorites.songs.hasOwnProperty(b) && a.push(GS.user.favorites.songs[b]); | |
| this.loadGridMusic(a) | |
| }, | |
| loadMusic: function( a ) { | |
| this.user = a; | |
| this.UserID = this.user.UserID; | |
| this.correctUrl(this.user, this.section, this.subpage); | |
| this.element.html(this.view("/user/music/index")); | |
| $("#page_content_profile").hover(function() { | |
| $(this).find(".thumb").stop(true, false); | |
| $(this).find(".thumb").fadeTo(300, 0.5) | |
| }, function() { | |
| $(this).find(".thumb").stop(true, false); | |
| $(this).find(".thumb").fadeTo(300, 0) | |
| }); | |
| if ( this.subpage === "favorites" ) { | |
| GS.Controllers.PageController.title(this.user.getTitle() + " - Favorites"); | |
| this.user.getFavoritesByType("Songs", this.callback("loadGridSongFavorites", true, false)) | |
| } else { | |
| GS.Controllers.PageController.title(this.user.getTitle() + " - Music"); | |
| this.user.getFavoritesByType("Songs", this.callback("loadGridSongFavorites", false, true)) | |
| } | |
| this.loadDigests(this.user) | |
| }, | |
| loadAlbums: function( a ) { | |
| this.user = a; | |
| this.UserID = this.user.UserID; | |
| this.correctUrl(this.user, this.section, this.subpage); | |
| this.element.html(this.view("/user/music/albums")); | |
| GS.Controllers.PageController.title(this.user.getTitle() + " - Albums"); | |
| this.user.library.getSongs(this.callback("loadGridAlbums")) | |
| }, | |
| loadGridSongFavorites: function( a, b ) { | |
| b = _.orEqual(b, false); | |
| var c = [], | |
| g; | |
| for ( g in this.user.favorites.songs ) | |
| this.user.favorites.songs.hasOwnProperty(g) && c.push(this.user.favorites.songs[g]); | |
| this.loadGridMusic(c, a); | |
| b && this.user.library.getSongs(this.callback("loadGridMusic"), null, false) | |
| }, | |
| albumsSeen: {}, | |
| artistsSeen: {}, | |
| buildAlbumsArtists: function( a ) { | |
| var b = [], | |
| c = [], | |
| g, h, k; | |
| h = 0; | |
| for ( k = a.length; h < k; h++ ) { | |
| if (!this.albumsSeen[a[h].AlbumID] && a[h].AlbumName && a[h].AlbumName.length ) { | |
| g = GS.Models.Album.wrap({ | |
| AlbumName: a[h].AlbumName, | |
| AlbumID: a[h].AlbumID, | |
| ArtistName: a[h].ArtistName, | |
| ArtistID: a[h].ArtistID, | |
| CoverArtFilename: a[h].CoverArtFilename | |
| }, true, "m_"); | |
| g.IsVerified = 0; | |
| c.push(g); | |
| this.albumsSeen[a[h].AlbumID] = true | |
| } | |
| if (!this.artistsSeen[a[h].ArtistID] ) { | |
| g = | |
| GS.Models.Artist.wrap({ | |
| ArtistName: a[h].ArtistName, | |
| ArtistID: a[h].ArtistID | |
| }, true, "m_"); | |
| g.IsVerified = 0; | |
| b.push(g); | |
| this.artistsSeen[a[h].ArtistID] = true | |
| } | |
| } | |
| this._albums = this._albums.concat(c); | |
| this._artists = this._artists.concat(b) | |
| }, | |
| _albums: [], | |
| _artists: [], | |
| loadGridMusic: function( a, b ) { | |
| var c, g, h = [], | |
| k = []; | |
| g = { | |
| sortCol: "TSAdded", | |
| sortDir: 0, | |
| padding: 0, | |
| onInitSort: true | |
| }; | |
| var m = this.element.find(".gs_grid.songs").controller(); | |
| artistController = this.element.find(".gs_grid.artists").controller(); | |
| albumController = this.element.find(".gs_grid.albums").controller(); | |
| b = _.orEqual(b, false); | |
| g.padding = 0; | |
| g.rowCssClasses = function( p ) { | |
| return p.isDeleted ? "strikethrough" : "" | |
| }; | |
| if ( GS.store.get("gs.sort.user.music") ) g = $.extend(g, GS.store.get("gs.sort.user.music")); | |
| if (!m ) { | |
| this.albumsSeen = {}; | |
| this.artistsSeen = {}; | |
| this._albums = []; | |
| this._artists = [] | |
| } | |
| if ( a ) { | |
| this.buildAlbumsArtists(a); | |
| h = this._albums.concat(); | |
| k = this._artists.concat() | |
| } | |
| $("#artistFilters").resizable({ | |
| handles: { | |
| e: $("#artistFilter-resize") | |
| }, | |
| minWidth: 30, | |
| maxWidth: 350, | |
| animate: false, | |
| resize: function() { | |
| $(window).resize() | |
| } | |
| }); | |
| $("#albumFilters").resizable({ | |
| handles: { | |
| e: $("#albumFilter-resize") | |
| }, | |
| minWidth: 30, | |
| maxWidth: 350, | |
| animate: false, | |
| resize: function() { | |
| $(window).resize() | |
| } | |
| }); | |
| c = GS.Models.Album.getFilterAll(); | |
| h.push(c); | |
| c = GS.Models.Artist.getFilterAll(); | |
| k.push(c); | |
| if ( this.user.UserID != GS.user.UserID ) g.scrollPane = "#page"; | |
| if ( m ) { | |
| c = m.dataView; | |
| g = m.grid; | |
| m.data = m.data.concat(a); | |
| if ( c ) { | |
| c.beginUpdate(); | |
| if ( this.user.UserID == GS.user.UserID ) { | |
| albumController.dataView.beginUpdate(); | |
| artistController.dataView.beginUpdate() | |
| } | |
| if ( b ) { | |
| c.setItems(a, "SongID"); | |
| if ( this.user.UserID == GS.user.UserID ) { | |
| albumController.dataView.setItems(h, "AlbumID"); | |
| artistController.dataView.setItems(k, "ArtistID") | |
| } | |
| } else { | |
| c.addItems(a, "SongID"); | |
| if ( this.user.UserID == GS.user.UserID ) { | |
| albumController.dataView.addItems(h, "AlbumID"); | |
| artistController.dataView.addItems(k, "ArtistID") | |
| } | |
| } | |
| c.endUpdate(); | |
| if ( this.user.UserID == GS.user.UserID ) { | |
| albumController.dataView.endUpdate(); | |
| artistController.dataView.endUpdate() | |
| } | |
| c.refresh(); | |
| if ( this.user.UserID == GS.user.UserID ) { | |
| albumController.dataView.refresh(); | |
| artistController.dataView.refresh() | |
| } | |
| } | |
| if ( g ) { | |
| g.onSort(m.sortCol, m.sortDir, true); | |
| if ( this.user.UserID == GS.user.UserID ) { | |
| albumController.grid.onSort(albumController.sortCol, albumController.sortDir, true); | |
| artistController.grid.onSort(artistController.sortCol, artistController.sortDir, true) | |
| } | |
| } | |
| } else if ( a && a.length ) if ( this.user.UserID == GS.user.UserID ) { | |
| this.element.find(".grid").html(this.view("/user/music/musicGrid")); | |
| this.element.find(".gs_grid.songs").gs_grid(a, GS.Controllers.GridController.columns.song, g); | |
| this.element.find(".gs_grid.albums").gs_grid(h, GS.Controllers.GridController.columns.albumFilter, { | |
| rowHeight: 25, | |
| sortCol: "AlbumName", | |
| isFilter: true, | |
| padding: 0, | |
| onInitSort: true | |
| }, "album"); | |
| this.element.find(".gs_grid.artists").gs_grid(k, GS.Controllers.GridController.columns.artistFilter, { | |
| rowHeight: 25, | |
| sortCol: "ArtistName", | |
| isFilter: true, | |
| padding: 0, | |
| onInitSort: true | |
| }, "artist") | |
| } else this.element.find(".gs_grid.songs").gs_grid(a, GS.Controllers.GridController.columns.song, g); | |
| else { | |
| this.element.find(".grid").html(this.view("/user/music/noMusicResults")); | |
| $("#searchForm input").select(); | |
| GS.resize() | |
| } | |
| this.subpage !== "favorites" && !this.user.library.songsLoaded && GS.user.UserID != this.UserID && this.user.library.getSongs(this.callback("loadGridMusic"), null, false); | |
| this.fixCollapsedState(); | |
| if ( this.subscribed && this.subpage !== "favorites" ) { | |
| this.subscribed = true; | |
| this.subscribe("gs.auth.library.update", this.callback("loadMyMusic")) | |
| } else if ( this.subscribed ) { | |
| this.subscribed = true; | |
| this.subscribe("gs.auth.favorites.songs.update", this.callback("loadMySongFavorites")) | |
| } | |
| }, | |
| loadGridAlbums: function( a ) { | |
| this.albumsSeen = {}; | |
| this.artistsSeen = {}; | |
| if ( a ) { | |
| this.buildAlbumsArtists(a); | |
| $("#grid").html("").css("height", "auto").addClass("albums"); | |
| this.slickbox = $("#grid").slickbox({ | |
| sortFunction: _.getSort("ArtistName", true), | |
| scrollPane: "#page_content", | |
| padding: 10, | |
| itemRenderer: GS.Models.Album.itemRenderer, | |
| itemWidth: 250, | |
| itemHeight: 70, | |
| maxHorizontalGap: 50, | |
| minHorizontalGap: 10, | |
| verticalGap: 20, | |
| dragAs: "album", | |
| dragItemID: "AlbumID" | |
| }, this._albums); | |
| this.sliderOrBoxDragSetup(this.slickbox, ".slickbox-item") | |
| } | |
| }, | |
| playlists: function( a, b ) { | |
| this.UserID = a; | |
| this.subpage = "playlists"; | |
| this.objType = b; | |
| if ( b === "subscribed" ) { | |
| if ( GS.user.UserID == this.UserID ) { | |
| this.user = GS.user; | |
| this.correctUrl(this.user, this.section, this.subpage, this.objType); | |
| this.loadMySubscribedPlaylists(GS.user) | |
| } else GS.Models.User.getUser(this.UserID, this.callback("loadSubscribedPlaylists")); | |
| this.subscribe("gs.auth.favorites.playlists.update", this.callback("loadGridSubscribedPlaylists")) | |
| } else if ( GS.user.UserID == this.UserID ) { | |
| this.user = GS.user; | |
| this.correctUrl(this.user, this.section, this.subpage); | |
| this.loadMyPlaylists(); | |
| this.subscribe("gs.auth.playlists.update", this.callback("loadGridPlaylists")); | |
| this.subscribe("gs.auth.favorites.playlists.update", this.callback("loadGridPlaylists")) | |
| } else GS.Models.User.getUser(this.UserID, this.callback("loadPlaylists")); | |
| if (!GS.user.IsPremium ) if (!this.adTimeoutID ) this.adTimeoutID = setTimeout(this.callback(function() { | |
| GS.getAd().updateRotationCount(); | |
| GS.getAd().buildAd($("#playlistCapital_160"), 160, 600, ["p=mymusic_playlists_" + (b ? b : "overview")]); | |
| this.adTimeoutID = null | |
| }), 100); | |
| GS.resize() | |
| }, | |
| loadMyPlaylists: function() { | |
| this.user = GS.user; | |
| this.correctUrl(this.user, this.section, this.subpage); | |
| GS.Controllers.PageController.title(this.user.getTitle() + " - Playlists"); | |
| this.element.html(this.view("/user/music/myPlaylists")); | |
| this.loadGridPlaylists() | |
| }, | |
| loadMySubscribedPlaylists: function() { | |
| this.user = GS.user; | |
| this.correctUrl(this.user, this.section, this.subpage, this.objType); | |
| GS.Controllers.PageController.title(this.user.getTitle() + " - Subscribed Playlists"); | |
| this.element.html(this.view("/user/music/myPlaylists")); | |
| this.loadGridSubscribedPlaylists() | |
| }, | |
| loadPlaylists: function( a ) { | |
| this.user = a; | |
| this.correctUrl(this.user, this.section, this.subpage); | |
| GS.Controllers.PageController.title(this.user.getTitle() + " - Playlists"); | |
| this.element.html(this.view("/user/music/playlists")); | |
| this.user.getPlaylists(this.callback("loadGridPlaylists")); | |
| a.UserID != GS.user.UserID && this.loadDigests() | |
| }, | |
| loadSubscribedPlaylists: function( a ) { | |
| this.user = a; | |
| this.correctUrl(this.user, this.section, this.subpage, this.objType); | |
| GS.Controllers.PageController.title(this.user.getTitle() + " - Subscribed Playlists"); | |
| this.element.html(this.view("/user/music/playlists")); | |
| this.user.getFavoritesByType("Playlists", this.callback("loadGridSubscribedPlaylists")); | |
| a.UserID != GS.user.UserID && this.loadDigests() | |
| }, | |
| loadGridPlaylists: function() { | |
| if ( this.user ) if ( this.subpage !== "subscribed" ) { | |
| var a = _.toArray(this.user.playlists), | |
| b, c; | |
| b = GS.store.get("gs.sort.user.playlists") || { | |
| sortCol: "TSAdded", | |
| sortDir: 0, | |
| sortStoreKey: "gs.sort.user.playlists" | |
| }; | |
| var g = this.element.find(".gs_grid.playlists").controller(); | |
| b.disableMultiSelect = | |
| true; | |
| if ( this.user.UserID == GS.user.UserID ) { | |
| b.scrollPane = "#page_content_pane"; | |
| b.allowDropOn = true | |
| } else { | |
| b.scrollPane = "#page"; | |
| b.allowDropOn = false | |
| } | |
| if ( g ) { | |
| b = g.dataView; | |
| c = g.grid; | |
| if ( b ) { | |
| b.beginUpdate(); | |
| b.setItems(a, "PlaylistID"); | |
| b.endUpdate(); | |
| b.refresh() | |
| } | |
| c && c.onSort(g.sortCol, g.sortDir) | |
| } else if ( a.length ) this.element.find(".gs_grid.playlists").gs_grid(a, GS.Controllers.GridController.columns.playlist, b, "playlist"); | |
| else { | |
| this.element.find(".gs_grid.playlists").html(this.view("/user/music/noPlaylistResults")); | |
| $("#searchForm input").select(); | |
| this.addAutocomplete("user"); | |
| GS.resize() | |
| } | |
| } | |
| }, | |
| loadGridSubscribedPlaylists: function() { | |
| if (!(!this.user || this.objType !== "subscribed")) { | |
| var a = _.toArray(this.user.favorites.playlists), | |
| b, c; | |
| b = GS.store.get("gs.sort.user.subscribed") || { | |
| sortCol: "TSFavorited", | |
| sortDir: 0, | |
| sortStoreKey: "gs.sort.user.subscribed", | |
| scrollPane: "#page_content" | |
| }; | |
| var g = this.element.find(".gs_grid").controller(); | |
| if ( b.sortCol == "TSAdded" ) { | |
| b.sortCol = "TSFavorited"; | |
| GS.store.remove("gs.sort.user.subscribed") | |
| } | |
| if ( g ) { | |
| b = g.dataView; | |
| c = g.grid; | |
| if ( b ) { | |
| b.beginUpdate(); | |
| b.setItems(a, "PlaylistID"); | |
| b.endUpdate(); | |
| b.refresh() | |
| } | |
| c && c.onSort(g.sortCol, g.sortDir) | |
| } else if ( a.length ) this.element.find(".gs_grid.playlists").gs_grid(a, GS.Controllers.GridController.columns.playlist, b, "playlist"); | |
| else { | |
| this.element.find(".gs_grid.playlists").html(this.view("/user/music/noPlaylistResults")); | |
| $("#searchForm input").select(); | |
| this.addAutocomplete("user"); | |
| GS.resize() | |
| } | |
| } | |
| }, | |
| fixCollapsedState: function() { | |
| var a = false, | |
| b, c, g; | |
| if ( this.Class.hasOwnProperty("artistFiltersCollapse") ) { | |
| b = $("#artistFilters"); | |
| _.forEach(this.Class.artistFiltersCollapse, function( h, k ) { | |
| g = b.hasClass(k); | |
| if ( h ) { | |
| if (!g ) { | |
| b.addClass(k); | |
| a = true | |
| } | |
| } else if ( g ) { | |
| b.removeClass(k); | |
| a = true | |
| } | |
| }) | |
| } | |
| if ( this.Class.hasOwnProperty("albumFiltersCollapse") ) { | |
| c = $("#albumFilters"); | |
| _.forEach(this.Class.albumFiltersCollapse, function( h, k ) { | |
| g = c.hasClass(k); | |
| if ( h ) { | |
| if (!g ) { | |
| c.addClass(k); | |
| a = true | |
| } | |
| } else if ( g ) { | |
| c.removeClass(k); | |
| a = true | |
| } | |
| }) | |
| } | |
| a && GS.resize() | |
| }, | |
| getSortMenu: function() { | |
| var a = this.setSort, | |
| b = []; | |
| this.subpage == "playlists" ? b.push({ | |
| title: $.localize.getString("SORT_BY_DATE_ADDED"), | |
| action: { | |
| type: "fn", | |
| callback: function() { | |
| var c = "TSAdded"; | |
| if ( _.defined(GS.page.activePageParams.objType) && GS.page.activePageParams.objType == "subscribed" ) c = "TSFavorited"; | |
| a(c, triggerElement, "SORT_BY_DATE_ADDED") | |
| } | |
| }, | |
| customClass: "jj_menu_item_blank" | |
| }, { | |
| title: $.localize.getString("SORT_BY_NAME"), | |
| action: { | |
| type: "fn", | |
| callback: function() { | |
| a("PlaylistName", triggerElement, "SORT_BY_NAME") | |
| } | |
| }, | |
| customClass: "jj_menu_item_blank" | |
| }) : b.push({ | |
| title: $.localize.getString("SORT_BY_DATE_ADDED"), | |
| action: { | |
| type: "fn", | |
| callback: function() { | |
| a("TSAdded", triggerElement, "SORT_BY_DATE_ADDED") | |
| } | |
| }, | |
| customClass: "jj_menu_item_blank" | |
| }, { | |
| title: $.localize.getString("SORT_BY_SONG"), | |
| action: { | |
| type: "fn", | |
| callback: function() { | |
| a("SongName", triggerElement, "SORT_BY_SONG") | |
| } | |
| }, | |
| customClass: "jj_menu_item_blank" | |
| }, { | |
| title: $.localize.getString("SORT_BY_ARTIST"), | |
| action: { | |
| type: "fn", | |
| callback: function() { | |
| a("ArtistName", triggerElement, "SORT_BY_ARTIST") | |
| } | |
| }, | |
| customClass: "jj_menu_item_blank" | |
| }, { | |
| title: $.localize.getString("SORT_BY_ALBUM"), | |
| action: { | |
| type: "fn", | |
| callback: function() { | |
| a("AlbumName", triggerElement, "SORT_BY_ALBUM") | |
| } | |
| }, | |
| customClass: "jj_menu_item_blank" | |
| }, { | |
| title: $.localize.getString("SORT_BY_TRACK_NUM"), | |
| action: { | |
| type: "fn", | |
| callback: function() { | |
| a("TrackNum", triggerElement, "SORT_BY_TRACK_NUM") | |
| } | |
| }, | |
| customClass: "jj_menu_item_blank" | |
| }); | |
| return b | |
| }, | |
| "#page_header a[name=delete] click": function() { | |
| var a = $("#grid").controller(); | |
| if ( a ) { | |
| var b = a.grid.getSelectedRows(), | |
| c, g, h; | |
| if ( b.length !== 0 ) { | |
| var k = []; | |
| g = 0; | |
| for ( h = b.length; g < h; g++ ) { | |
| $("#grid").find(".slick-row[row=" + b[g] + "]").addClass("strikethrough"); | |
| if ( c = a.dataView.rows[b[g]] ) this.subpage === "favorites" ? GS.user.removeFromSongFavorites(c.SongID) : k.push(c.SongID) | |
| } | |
| this.subpage !== "favorites" && k.length && GS.user.removeFromLibrary(k); | |
| a.grid.setSelectedRows([]); | |
| a.selectedRowIDs = []; | |
| $.publish("gs.grid.selectedRows", { | |
| len: 0 | |
| }) | |
| } | |
| } | |
| }, | |
| "#page_header button.newPlaylist, a.newPlaylist click": function() { | |
| GS.getLightbox().open("newPlaylist") | |
| }, | |
| ".slick-row .playlist .subscribe click": function( a ) { | |
| var b = a.attr("rel"); | |
| b = GS.Models.Playlist.getOneFromCache(b); | |
| if ( a.is(".subscribed") ) { | |
| b.unsubscribe(); | |
| a.removeClass("subscribed").find("a.subscribe span").text("Subscribe") | |
| } else { | |
| b.subscribe(); | |
| a.addClass("subscribed").find("a.subscribe span").text("Unsubscribe") | |
| } | |
| }, | |
| "#page_wrapper .capitalSliderBtnRev click": function( a ) { | |
| a = $(a); | |
| $(a).hasClass("capitalSliderDown") ? $("#page_wrapper .capitalView_160").animate({ | |
| scrollTop: $("#page_wrapper .capitalView_160").scrollTop() + 200 | |
| }, 500) : $("#page_wrapper .capitalView_160").animate({ | |
| scrollTop: $("#page_wrapper .capitalView_160").scrollTop() - 200 | |
| }, 500) | |
| } | |
| }); | |
| GS.Controllers.PageController.extend("GS.Controllers.Page.PlaylistController", {}, { | |
| type: "playlist", | |
| index: function( a, b, c ) { | |
| this.url = location.hash; | |
| this.id = parseInt(a, 10) || 0; | |
| this.subpage = b || "music"; | |
| this.playOnView = c || false; | |
| this.subscribe("gs.auth.favorites.playlists.update", this.callback("onPlaylistsUpdate")); | |
| this.subscribe("gs.playlist.view.update", this.callback("onPlaylistUpdate")); | |
| GS.Models.Playlist.getPlaylist(this.id, this.callback("loadPlaylist")) | |
| }, | |
| loadPlaylist: function( a ) { | |
| this.playlist = a; | |
| if ( a.PlaylistID === 0 ) GS.router.notFound(); | |
| else { | |
| if (!this.playlist.fanbase ) this.playlist.fanbase = GS.Models.Fanbase.wrap({ | |
| objectID: a.PlaylistID, | |
| objectType: "playlist", | |
| userIDs: [] | |
| }); | |
| this.correctUrl(this.playlist, this.subpage === "music" ? "" : this.subpage); | |
| this.fbUrl = "http://grooveshark.com/" + this.playlist.toUrl().replace("#/", ""); | |
| this.list.doPlayAddSelect = true; | |
| this.list.doSearchInPage = true; | |
| this.list.sortOptions = [{ | |
| text: "Popularity", | |
| column: "Popularity" | |
| }, | |
| { | |
| text: "Song Name", | |
| column: "Name" | |
| }, | |
| { | |
| text: "Favorite", | |
| column: "Favorite" | |
| }, | |
| { | |
| text: "Artist Name", | |
| column: "ArtistName" | |
| }, | |
| { | |
| text: "Album Name", | |
| column: "AlbumName" | |
| }]; | |
| this.list.useGrid = true; | |
| this.element.html(this.view("index")); | |
| console.warn(); | |
| this.playlist && GS.user.playlists[this.playlist.PlaylistID] && $("#application").width() > GS.page.SMALL_APP_LIMIT && GS.getSidebar().show(); | |
| switch ( this.subpage ) { | |
| case "subscribers": | |
| GS.Controllers.PageController.title(this.playlist.getTitle() + " - subscribers"); | |
| this.playlist.fanbase.getFans(this.callback("loadGridFans")); | |
| this.playlist.getSongs(this.callback(["updatePlaylistArt", "loadDigestAlbums"])); | |
| break; | |
| case "albums": | |
| this.playlist.getSongs(this.callback(["loadGridAlbums", "updatePlaylistArt"])); | |
| this.playlist.fanbase.getFans(this.callback("loadDigestFans"), null, false); | |
| break; | |
| default: | |
| GS.Controllers.PageController.title(this.playlist.getTitle()); | |
| this.playlist.getSongs(this.callback(["loadGrid", "updatePlaylistArt", "loadDigestAlbums"])); | |
| this.playlist.fanbase.getFans(this.callback("loadDigestFans"), null, false); | |
| break | |
| } | |
| this.updatePlaylistProps(this.playlist); | |
| GS.Models.User.getUser(this.playlist.UserID, this.callback("loadUserPlaylists")); | |
| GS.user.IsPremium || GS.getAd().buildAd($("#playlistCapital_300"), 300, 250, ["p=playlist_" + this.subpage]); | |
| GS.Controllers.PageController.confirmMessage = $.localize.getString("ONCLOSE_SAVE_PLAYLIST") | |
| } | |
| }, | |
| onPageLoaded: function() { | |
| this.id > 0 && setTimeout(this.callback(function() { | |
| if ( $("#page_content_social_buttons").length ) { | |
| var a = this.callback(function() { | |
| $("#page_content_social_buttons .fblike").css("width", this.likeWidth); | |
| this.loadLikeButtonCount(this.fbUrl); | |
| FB.XFBML.parse(window.document.getElementById("fbLike"), this.callback(function() { | |
| $("#page_content_social_buttons .fblike").css("width", this.likeWidth) | |
| })) | |
| }); | |
| if ( window.FB && FB.XFBML ) a(); | |
| else { | |
| var b; | |
| b = this.subscribe("gs.facebook.xfbml.ready", this.callback(function() { | |
| a(); | |
| $.unsubscribe(b) | |
| })) | |
| } | |
| GS.getTwitter().getTwitterShareMessage("playlist", this.playlist, this.fbUrl, this.callback(function( c, g ) { | |
| var h = $(document.createElement("a")); | |
| h.attr("data-text", c.replace('"', '"')); | |
| h.attr("data-url", g); | |
| h.attr("data-via", "grooveshark"); | |
| h.attr("data-count", "none"); | |
| h.addClass("twitter-share-button"); | |
| h.text("Tweet"); | |
| $("#page_content_social_buttons .tweetButton").empty().append(h); | |
| GS.getTwitter().parseWidgets() | |
| }), true); | |
| GS.getGoogle().parsePlusWidgets($("#page_content_social_buttons .googlePlusButton").get(0)) | |
| } | |
| }), 10) | |
| }, | |
| updatePlaylistProps: function( a ) { | |
| if (!(!this.playlist || this.playlist.PlaylistID !== a.PlaylistID)) { | |
| if ( this.playlist.hasUnsavedChanges ) { | |
| $("button.save", this.element).show(); | |
| $("button.undo", this.element).show() | |
| } else { | |
| $("button.save", this.element).hide(); | |
| $("button.undo", this.element).hide() | |
| } | |
| this.playlist.isDeleted ? $("#page_content_profile_title").addClass("deleted") : $("#page_content_profile_title").removeClass("deleted") | |
| } | |
| }, | |
| onPlaylistUpdate: function( a ) { | |
| if (!(!this.playlist || this.playlist.PlaylistID !== a.PlaylistID)) { | |
| this.updatePlaylistProps(a); | |
| this.updatePlaylistArt(); | |
| this.subpage == "music" && this.playlist.getSongs(this.callback("loadGrid")) | |
| } | |
| }, | |
| onPlaylistsUpdate: function() { | |
| this.playlist && GS.user.playlists[this.playlist.PlaylistID] && $("#application").width() > GS.page.SMALL_APP_LIMIT && GS.getSidebar().show() | |
| }, | |
| updatePlaylistArt: function() { | |
| this.playlist.images = | |
| this.playlist.getPlaylistArt(200); | |
| this.element.find("#profile_playlistImage").html(this.view("/playlist/playlistArt", { | |
| playlist: this.playlist | |
| })) | |
| }, | |
| loadGrid: function( a ) { | |
| if ( this.subpage === "music" ) { | |
| var b = { | |
| sortCol: "Sort", | |
| sortDir: 1, | |
| sortStoreKey: "gs.sort.playlist.songs" | |
| }, | |
| c = this.element.find(".gs_grid").controller(); | |
| if ( c ) { | |
| a = c.dataView; | |
| b = c.grid; | |
| if ( a ) { | |
| var g, h, k, m = this.playlist.songs.concat(), | |
| p = a.getItems().concat(); | |
| a.beginUpdate(); | |
| for ( k = 0; k < p.length; k++ ) { | |
| g = p[k]; | |
| h = m.indexOf(g); | |
| h != -1 && m.splice(h, 1); | |
| a.getIdxById(g.GridKey); | |
| h = this.playlist.songs.indexOf(g); | |
| h == -1 ? a.deleteItem(g.GridKey) : a.updateItem(g.GridKey, g) | |
| } | |
| m.length && a.addItems(m, "GridKey"); | |
| a.endUpdate(); | |
| a.refresh() | |
| } | |
| b && b.onSort(c.sortCol, c.sortDir) | |
| } else { | |
| if ( GS.user.UserID === this.playlist.UserID ) { | |
| b.allowDragSort = true; | |
| b.allowDuplicates = true; | |
| b.playlistID = this.playlist.PlaylistID | |
| } | |
| if ( a.length ) { | |
| this.playOnView && this.playlist.play({ | |
| playOnAdd: true | |
| }); | |
| b.scrollPane = $("#page"); | |
| b.rowCssClasses = function( o ) { | |
| return o.isDeleted ? "strikethrough" : "" | |
| }; | |
| $(".grid").unbind("dropend"); | |
| this.element.find(".gs_grid").gs_grid(a, GS.Controllers.GridController.columns.playlistsong, b, "song", "GridKey") | |
| } else { | |
| this.element.find(".gs_grid").html(this.view("noResults")); | |
| $("#searchForm input").select(); | |
| this.addAutocomplete("playlist"); | |
| GS.resize(); | |
| var n = this; | |
| $(".grid").bind("dropend", function( o, t ) { | |
| if ( $("#grid").controller() ) return false; | |
| var w = [], | |
| x, v, B = t.draggedItems; | |
| if ( typeof B[0].SongID !== "undefined" ) for ( x = 0; x < B.length; x++ ) w.push(B[x].SongID); | |
| else if ( typeof B[0].PlaylistID !== "undefined" ) for ( x = 0; x < B.length; x++ ) B[x].getSongs(function( E ) { | |
| for ( v = | |
| 0; v < E.length; v++ ) | |
| w.push(E[v].SongID) | |
| }, null, false, { | |
| async: false | |
| }); | |
| w.length && n.playlist.addSongs(w) | |
| }) | |
| } | |
| $(window).resize() | |
| } | |
| this.onPageLoaded() | |
| } | |
| }, | |
| loadGridAlbums: function() { | |
| if ( this.subpage === "albums" ) { | |
| var a = { | |
| sortCol: "Sort", | |
| sortDir: 1 | |
| }, | |
| b = this.element.find(".gs_grid").controller(); | |
| if ( b ) { | |
| a = b.dataView; | |
| var c = b.grid; | |
| if ( a ) { | |
| a.beginUpdate(); | |
| a.endUpdate(); | |
| a.refresh() | |
| } | |
| c && c.onSort(b.sortCol, b.sortDir) | |
| } else { | |
| b = _.toArray(this.playlist.albums); | |
| if ( b.length ) { | |
| a.scrollPane = $("#page"); | |
| this.element.find(".gs_grid").gs_grid(b, GS.Controllers.GridController.columns.album, a, "album") | |
| } else this.element.find(".gs_grid").html(this.view("noResults")); | |
| GS.resize() | |
| } | |
| this.onPageLoaded() | |
| } | |
| }, | |
| loadUserPlaylists: function( a ) { | |
| this.user = a; | |
| this.user.getPlaylists(this.callback("loadDigestPlaylists")) | |
| }, | |
| loadDigestPlaylists: function( a ) { | |
| var b = this.playlist; | |
| a = _.toArray(this.user.playlists).sort(GS.Models.Playlist.prettySort).slice(0, 6).filter(function( c ) { | |
| return b.PlaylistID != c.PlaylistID | |
| }); | |
| a.length && $("#playlist_digest").html(this.view("/user/playlist_digest", { | |
| playlists: a, | |
| user: this.user | |
| })) | |
| }, | |
| loadDigestAlbums: function() { | |
| if ( this.playlist && this.playlist.albums ) { | |
| var a = _.toArray(this.playlist.albums).sort(GS.Models.Album.prettySort).slice(0, 7); | |
| a.length > 1 && $("#album_digest").html(this.view("album_digest", { | |
| playlist: this.playlist, | |
| albums: a | |
| })) | |
| } | |
| }, | |
| loadDigestFans: function( a ) { | |
| if ( a ) { | |
| var b = []; | |
| for ( var c in a ) | |
| if ( a.hasOwnProperty(c) ) { | |
| if ( b.length >= 18 ) break; | |
| a[c].Picture && b.push(a[c]) | |
| } | |
| this.songFans = b; | |
| this.sidebarFans = true; | |
| $("#subscriber_digest").html(this.view("subscriber_digest")); | |
| this.loadSubFans && $("#song_subcontent").removeClass("loading").html(this.view("song_fans_large")) | |
| } | |
| }, | |
| loadGridFans: function( a ) { | |
| if ( this.subpage === "subscribers" ) { | |
| var b = GS.store.get("gs.sort.playlist.fans") || { | |
| sortCol: "Name", | |
| sortDir: 1, | |
| sortStoreKey: "gs.sort.playlist.fans" | |
| }; | |
| if ( a.length ) this.element.find(".gs_grid").gs_grid(a, GS.Controllers.GridController.columns.user, b, "user"); | |
| else { | |
| this.element.find(".gs_grid").html(this.view("/shared/noResults", { | |
| type: "subscribers" | |
| })); | |
| this.addAutocomplete("users") | |
| } | |
| GS.resize(); | |
| this.onPageLoaded() | |
| } | |
| }, | |
| getSortMenu: function() { | |
| var a = this.setSort; | |
| return [{ | |
| title: $.localize.getString("SORT_BY_PLAYLIST"), | |
| action: { | |
| type: "fn", | |
| callback: function() { | |
| a("Sort", triggerElement, "SORT_BY_PLAYLIST") | |
| } | |
| }, | |
| customClass: "jj_menu_item_blank" | |
| }, { | |
| title: $.localize.getString("SORT_BY_SONG"), | |
| action: { | |
| type: "fn", | |
| callback: function() { | |
| a("SongName", triggerElement, "SORT_BY_SONG") | |
| } | |
| }, | |
| customClass: "jj_menu_item_blank" | |
| }, { | |
| title: $.localize.getString("SORT_BY_ARTIST"), | |
| action: { | |
| type: "fn", | |
| callback: function() { | |
| a("ArtistName", triggerElement, "SORT_BY_ARTIST") | |
| } | |
| }, | |
| customClass: "jj_menu_item_blank" | |
| }, { | |
| title: $.localize.getString("SORT_BY_ALBUM"), | |
| action: { | |
| type: "fn", | |
| callback: function() { | |
| a("AlbumName", triggerElement, "SORT_BY_ALBUM") | |
| } | |
| }, | |
| customClass: "jj_menu_item_blank" | |
| }] | |
| }, | |
| getOptionMenu: function() { | |
| var a = [], | |
| b = this.getOptionsSubMenu(); | |
| playlistID = this.playlist.PlaylistID; | |
| if ( GS.user.UserID == this.playlist.UserID ) for ( var c = 0; c < b.length; ++c ) a.push(b[c]); | |
| if ( this.playlist.PlaylistID > 0 ) { | |
| GS.user.UserID == this.playlist.UserID && a.push({ | |
| customClass: "separator" | |
| }); | |
| a.push({ | |
| title: $.localize.getString("SHARE_PLAYLIST"), | |
| type: "sub", | |
| action: { | |
| type: "fn", | |
| callback: this.playlist.getClipboardAction([{ | |
| text: "http://grooveshark.com/" + this.playlist.toUrl().replace("#/", ""), | |
| selector: "div.playlistUrl" | |
| }]) | |
| }, | |
| src: this.playlist.getShareMenu(), | |
| customClass: "jj_menu_item_hasIcon jj_menu_item_share jj_menu_item_more" | |
| }) | |
| } | |
| return a | |
| }, | |
| getOptionsSubMenu: function() { | |
| var a = this.playlist, | |
| b = this.playlist.PlaylistID, | |
| c = this.playlist.PlaylistName, | |
| g = []; | |
| if ( a.UserID == GS.user.UserID ) { | |
| g.push({ | |
| title: $.localize.getString("PLAYLIST_RENAME"), | |
| action: { | |
| type: "fn", | |
| callback: function() { | |
| GS.getLightbox().open("renamePlaylist", b) | |
| } | |
| }, | |
| customClass: "jj_menu_item_hasIcon jj_menu_item_edit" | |
| }); | |
| a.isDeleted ? g.push({ | |
| title: $.localize.getString("PLAYLIST_RESTORE"), | |
| action: { | |
| type: "fn", | |
| callback: function() { | |
| a.restore() | |
| } | |
| }, | |
| customClass: "jj_menu_item_hasIcon jj_menu_item_undo" | |
| }) : g.push({ | |
| title: $.localize.getString("PLAYLIST_DELETE"), | |
| action: { | |
| type: "fn", | |
| callback: function() { | |
| GS.getLightbox().open({ | |
| type: "deletePlaylist", | |
| view: { | |
| header: "POPUP_DELETE_PLAYLIST_TITLE", | |
| messageHTML: (new GS.Models.DataString($.localize.getString("POPUP_DELETE_PLAYLIST_MESSAGE"), { | |
| playlist: c | |
| })).render(), | |
| buttonsLeft: [{ | |
| className: "close", | |
| label: "CANCEL" | |
| }], | |
| buttonsRight: [{ | |
| className: "submit", | |
| label: "DELETE" | |
| }] | |
| }, | |
| callbacks: { | |
| "button.submit": function() { | |
| a.remove() | |
| } | |
| } | |
| }) | |
| } | |
| }, | |
| customClass: "jj_menu_item_hasIcon jj_menu_item_delete" | |
| }) | |
| } | |
| GS.user.isShortcut("playlist", a.PlaylistID) ? g.push({ | |
| title: $.localize.getString("CONTEXT_REMOVE_FROM_PINBOARD"), | |
| action: { | |
| type: "fn", | |
| callback: function() { | |
| GS.user.removeFromShortcuts("playlist", a.PlaylistID) | |
| } | |
| }, | |
| customClass: "jj_menu_item_hasIcon jj_menu_item_pinboard" | |
| }) : g.push({ | |
| title: $.localize.getString("CONTEXT_ADD_TO_PINBOARD"), | |
| action: { | |
| type: "fn", | |
| callback: function() { | |
| GS.user.addToShortcuts("playlist", a.PlaylistID, a.PlaylistName) | |
| } | |
| }, | |
| customClass: "jj_menu_item_hasIcon jj_menu_item_pinboard" | |
| }); | |
| return g | |
| }, | |
| getSongsIDsFromSelectedGridRows: function() { | |
| var a = this.element.find(".gs_grid:last").controller(), | |
| b = [], | |
| c; | |
| if ( a && a.selectedRowIDs.length > 0 ) for ( c = 0; c < a.selectedRowIDs.length; c++ ) { | |
| var g = this.playlist.gridKeyLookup[a.selectedRowIDs[c]]; | |
| g && b.push(g.SongID) | |
| } | |
| else if ( a ) for ( c = 0; c < a.dataView.rows.length; c++ ) b.push(a.dataView.rows[c].SongID); | |
| return b | |
| }, | |
| "#page_header .dropdownButton.opts click": function( a, b ) { | |
| a.jjmenu(b, this.getOptionsMenu(), null, { | |
| xposition: "left", | |
| yposition: "auto", | |
| show: "default", | |
| className: "contextmenu", | |
| keepState: a | |
| }) | |
| }, | |
| ".page_controls button.deleteSongs click": function() { | |
| var a = this.element.find(".gs_grid:last").controller(), | |
| b = [], | |
| c; | |
| if ( a && a.selectedRowIDs.length > 0 ) for ( c = 0; c < a.selectedRowIDs.length; c++ ) { | |
| var g = this.playlist.gridKeyLookup[a.selectedRowIDs[c]]; | |
| g && b.push(this.playlist.songs.indexOf(g)) | |
| } | |
| b.length && this.playlist.removeSongs(b) | |
| }, | |
| "button.save click": function() { | |
| this.playlist.save() | |
| }, | |
| "button.undo click": function() { | |
| this.playlist.undo() | |
| }, | |
| "#playlist_options a.editPlaylist click": function( a, b ) { | |
| b.preventDefault(); | |
| GS.getLightbox().open("renamePlaylist", this.playlist.PlaylistID) | |
| }, | |
| "#playlist_options a.subscribePlaylist click": function( a, b ) { | |
| b.preventDefault(); | |
| GS.user.addToPlaylistFavorites(this.playlist.PlaylistID); | |
| a.addClass("unsubscribePlaylist").removeClass("subscribePlaylist").localeDataString("PLAYLIST_UNSUBSCRIBE") | |
| }, | |
| "#playlist_options a.unsubscribePlaylist click": function( a, b ) { | |
| b.preventDefault(); | |
| GS.user.removeFromPlaylistFavorites(this.playlist.PlaylistID); | |
| a.addClass("subscribePlaylist").removeClass("unsubscribePlaylist").localeDataString("PLAYLIST_SUBSCRIBE") | |
| }, | |
| "#playlist_options a.sharePlaylist click": function( a, b ) { | |
| b.preventDefault(); | |
| GS.getLightbox().open("share", { | |
| id: this.playlist.PlaylistID, | |
| type: "playlist", | |
| service: "email" | |
| }) | |
| }, | |
| "#playlist_options a.pinPlaylist click": function( a, b ) { | |
| b.preventDefault(); | |
| GS.user.addToShortcuts("playlist", this.playlist.PlaylistID, this.playlist.PlaylistName); | |
| a.addClass("unpinPlaylist").removeClass("pinPlaylist").localeDataString("CONTEXT_REMOVE_FROM_PINBOARD") | |
| }, | |
| "#playlist_options a.unpinPlaylist click": function( a, b ) { | |
| b.preventDefault(); | |
| GS.user.removeFromShortcuts("playlist", this.playlist.PlaylistID); | |
| a.addClass("pinPlaylist").removeClass("unpinPlaylist").localeDataString("CONTEXT_ADD_TO_PINBOARD") | |
| } | |
| }); | |
| GS.Controllers.PageController.extend("GS.Controllers.Page.SearchController", { | |
| cache: {} | |
| }, { | |
| defaultType: "song", | |
| validTypes: { | |
| song: true, | |
| playlist: true, | |
| user: true, | |
| event: true, | |
| album: true, | |
| artist: true | |
| }, | |
| query: "", | |
| type: "", | |
| ppOverride: false, | |
| originalUsers: null, | |
| searchUsers: null, | |
| startTimes: {}, | |
| currentFilterStr: null, | |
| currentSort: null, | |
| prefetchSize: 3, | |
| displayMethod: "grid", | |
| index: function( a, b ) { | |
| this.ppOverride = _.orEqual(GS.user.searchVersion, false); | |
| if ( b.indexOf("ppVersion:", 0) === 0 ) { | |
| var c = b.split(/\s+/); | |
| this.ppOverride = c[0].split(":")[1]; | |
| b = c.splice(1, c.length).join(" ") | |
| } | |
| this.query = _.orEqual(b, "").replace(/\s+/g, " "); | |
| this.cleanQuery = _.cleanText(this.query); | |
| if ((this.type = _.orEqual(a, "song")) && !this.validTypes[this.type] ) this.type = this.defaultType; | |
| GS.search.lastSearch = GS.search.search; | |
| GS.search.lastType = GS.search.type; | |
| GS.search.search = this.query; | |
| (GS.search.type = this.type) ? GS.Controllers.PageController.title("All " + _.ucwords(this.type) + " Results: " + this.query) : GS.Controllers.PageController.title("Search: " + this.query); | |
| this.displayMethod = | |
| _.orEqual(GS.store.get("searchDisplay"), "grid"); | |
| this.element.html(this.view("index")); | |
| this.element.find("input:first").focus(); | |
| if ( this.query === "" ) { | |
| this.element.find(".gs_grid." + (a + "s")).html(this.view("noResults")); | |
| $(".gs_grid input[name=q]", this.element).val(this.query); | |
| $("#searchForm input").select(); | |
| this.addAutocomplete("search"); | |
| GS.resize(); | |
| GS.getGuts().logEvent("search", { | |
| type: this.type || "song", | |
| searchString: this.query, | |
| searchTime: 0, | |
| numResults: 0 | |
| }); | |
| GS.getGuts().beginContext({ | |
| mostRecentSearch: this.query, | |
| mostRecentSearchType: this.type || "song", | |
| mostRecentSearchVersion: "" | |
| }) | |
| } else { | |
| $("#page_search a.remove").removeClass("hide"); | |
| $.localize.ready ? this.detectRadio() : this.subscribe("gs.locale.ready", this.callback(function() { | |
| this.detectRadio() | |
| })); | |
| $.publish("gs.page.loading.grid"); | |
| this.startTimes.song = (new Date).getTime(); | |
| this.getResults(false, this.type || "song", this.callback(function() { | |
| var g = (new Date).getTime(); | |
| this.startTimes.artist = g; | |
| this.startTimes.album = g; | |
| this.startTimes.playlist = g; | |
| this.startTimes.user = | |
| g; | |
| this.getResults(this.callback(function( h ) { | |
| $("#page_nav_option_artist .count").text(h ? h.length : 0); | |
| this.artists = h && h.length ? h.slice(0, 3) : []; | |
| $("#searchArtists").html(this.view("topArtists")); | |
| if (!GS.user.IsPremium ) { | |
| h = ["q=" + this.query, "t=" + (this.type || "song"), "p=search_" + this.type]; | |
| this.artists && this.artists[0] && h.push("7=" + this.artists[0].ArtistID, "8=" + this.artists[0].ArtistName); | |
| GS.getAd().updateRotationCount(); | |
| GS.getAd().buildAd($("#searchCapital_300"), 300, 250, h); | |
| GS.getAd().buildAd($("#searchCapital_728"), 728, 90, h) | |
| } | |
| }), "artist"); | |
| this.type != "artist" && this.getResults(this.callback(function( h ) { | |
| this.artists = h && h.length ? h.slice(0, 3) : []; | |
| $("#profile_artists").html(this.view("topArtists")) | |
| }), "artist"); | |
| this.type != "album" && this.getResults(this.callback(function( h ) { | |
| this.albums = h && h.length ? h.slice(0, 3) : []; | |
| $("#profile_albums").html(this.view("topAlbums")) | |
| }), "album"); | |
| this.type != "playlist" && this.getResults(this.callback(function( h ) { | |
| this.playlists = h && h.length ? h.slice(0, 3) : []; | |
| $("#profile_playlists").html(this.view("topPlaylists")) | |
| }), "playlist"); | |
| this.type != "user" && this.getResults(this.callback(function( h ) { | |
| h.sort(this.sortByPicture); | |
| this.users = h && h.length ? h.slice(0, 3) : []; | |
| $("#profile_users").html(this.view("topUsers")) | |
| }), "user"); | |
| this.type != "event" && this.getResults(this.callback(function( h ) { | |
| this.events = h && h.length ? h.slice(0, 3) : []; | |
| $("#profile_events").html(this.view("topEvents")) | |
| }), "event"); | |
| this.suggest() | |
| }), true) | |
| } | |
| }, | |
| getResults: function( a, b, c, g ) { | |
| var h = this.type, | |
| k = "", | |
| m = this.callback(function( p, n, o ) { | |
| if ( p === this.query ) { | |
| var t, w; | |
| p = { | |
| sortCol: "Score", | |
| sortDir: 0 | |
| }; | |
| GS.Controllers.Page.SearchController.cache[n] = o; | |
| if ( $.isArray(o.result) ) { | |
| if ( $.isArray(h) && h.length === 1 ) h = h[0]; | |
| h = h.substring(0, h.length - 1); | |
| w = GS.Models[_.ucwords(h)].wrapCollection(o.result, { | |
| ppVersion: "" | |
| }) | |
| } | |
| if ( w && w.length ) { | |
| h = h.toLowerCase(); | |
| if ( h === "song" ) { | |
| t = GS.Controllers.GridController.columns.song.concat(); | |
| t = [t[0], t[1], t[2]]; | |
| for ( var x = [], v = 0; v < w.length && v < this.prefetchSize; v++ ) | |
| x.push(w[v].SongID); | |
| GS.player.prefetchStreamKeys(x) | |
| } else { | |
| t = GS.Controllers.GridController.columns[h]; | |
| if ( h === "event" ) { | |
| p = { | |
| sortCol: "StartTime", | |
| sortDir: 1, | |
| rowCssClasses: function() { | |
| return "event" | |
| } | |
| }; | |
| for ( x = 0; x < w.length; x++ ) { | |
| w[x].EventID = x; | |
| w[x].StartTime = parseInt(w[x].StartTime); | |
| if ( w[x].StartTime ) w[x].StartTime = (new Date(w[x].StartTime * 1E3)).format("Y-m-d G:i:s"); | |
| w[x].ArtistName = w[x].ArtistName || w[x].Artists | |
| } | |
| } | |
| } | |
| if ( $.isFunction(a) ) a(w, n); | |
| else { | |
| this.items = w; | |
| this.options = p; | |
| this.columns = t; | |
| this.displayResults(this.displayMethod) | |
| } | |
| } else if ( $.isFunction(a) ) a(w, n); | |
| else { | |
| n = (new Date).getTime() - this.startTimes[h.toLowerCase()]; | |
| h = this.type ? this.type + "s" : "songs"; | |
| this.element.find(".gs_grid." + h.toLowerCase()).html(this.view("noResults")); | |
| this.addAutocomplete("search"); | |
| GS.resize() | |
| } | |
| if ( g ) { | |
| n = (new Date).getTime() - this.startTimes[h]; | |
| GS.search.version = o.version; | |
| GS.search.server = _.orEqual(o.server, "not set"); | |
| GS.getGuts().logEvent("search", { | |
| type: this.type || "song", | |
| searchString: this.query, | |
| searchVersion: o.version, | |
| searchTime: n, | |
| numResults: w ? w.length : 0 | |
| }); | |
| GS.getGuts().beginContext({ | |
| mostRecentSearch: this.query, | |
| mostRecentSearchType: this.type || "song", | |
| mostRecentSearchVersion: o.version | |
| }); | |
| GS.getGuts().handlePageLoad("search", { | |
| type: this.type || "song" | |
| }) | |
| } | |
| if ( this.type == "song" && h == "song" && !GS.user.searchVersion ) GS.user.searchVersion = o.assignedVersion; | |
| $.isFunction(c) && c() | |
| } | |
| }); | |
| h = _.orEqual(b, h); | |
| h = $.isArray(h) ? h : _.ucwords(h) + "s"; | |
| k = h + ":" + this.query + ":" + this.ppOverride; | |
| GS.Controllers.Page.SearchController.cache[k] ? m(this.query, k, GS.Controllers.Page.SearchController.cache[k]) : GS.service.getResultsFromSearch(this.query, h, this.ppOverride, this.callback(m, this.query, k), this.callback(m, this.query, k)) | |
| }, | |
| displayResults: function( a ) { | |
| if ( a != this.displayMethod ) if ( this.displayMethod == "grid" ) { | |
| $("#grid").controller().destroy(); | |
| $("#grid").addClass("gs_grid") | |
| } else if ( this.displayMethod == "slickbox" ) { | |
| this.slickbox.destroy(); | |
| this.slickbox = null | |
| } | |
| if ( this.type == "song" || this.type == "event" || this.type == "" || a == "grid" ) { | |
| this.options.scrollPane = $("#page"); | |
| this.options.padding = 0; | |
| if ( this.type === "user" ) { | |
| this.items = this.items.sort(this.sortByPicture); | |
| this.options.sortCol = false | |
| } else if ( this.type === "artist" || this.type == "event" ) this.options.disableMultiSelect = true; | |
| this.element.find("#grid").gs_grid(this.items, this.columns, this.options, this.type) | |
| } else this.type == "user" ? this.renderSlickBox(this.type, this.items, { | |
| sortType: "byPicture", | |
| sortFunction: this.sortByPicture | |
| }) : this.renderSlickBox(this.type, this.items, this.currentSort); | |
| this.displayMethod = a | |
| }, | |
| suggest: function() { | |
| if ( $("#page_content").is(".search") ) { | |
| if (!window.google ) window.google = {}; | |
| if (!window.google.ac ) window.google.ac = {}; | |
| window.google.ac.h = this.callback(function( a ) { | |
| var b = false; | |
| if ( a[1].length > 0 ) { | |
| a = a[1]; | |
| b = a[0][0].replace(/(?:\s?lyrics$|\<\/?[a-zA-Z]+\>)/g, "") | |
| } | |
| b && this.suggestSuccess("eg", b) | |
| }); | |
| $.ajax({ | |
| url: "http://google.com/complete/search?output=json&q=" + this.query + " lyrics&client=serp", | |
| dataType: "jsonp", | |
| jsonp: false, | |
| jsonpCallback: "window.google.ac.h", | |
| success: function() {}, | |
| error: function() {} | |
| }) | |
| } | |
| }, | |
| suggestSuccess: function( a, b ) { | |
| if ((b = _.uncleanText($.trim(b))) && $.trim(this.query).toLowerCase() !== b ) { | |
| this.querySuggest = b; | |
| this.suggestSource = a; | |
| $("#didYouMean a").text(b).attr("title", b).data({ | |
| searchquery: b, | |
| searchtype: this.type ? this.type : "" | |
| }); | |
| $("#page_subheader").removeClass("hide"); | |
| GS.resize(); | |
| GS.getGuts().gaTrackEvent("search", "suggest", this.suggestSource); | |
| GS.getGuts().logEvent("suggest", { | |
| suggest: this.querySuggest, | |
| source: this.suggestSource, | |
| numSongs: $("#grid").controller().dataView.rows.length | |
| }) | |
| } | |
| }, | |
| ".didYouMean a.remove click": function() { | |
| $("#page_subheader").remove(); | |
| GS.resize() | |
| }, | |
| ".didYouMean a click": function() { | |
| var a = $("#grid").controller(); | |
| a = a && a.dataView ? a.dataView.rows.length : 0; | |
| GS.getGuts().gaTrackEvent("search", "suggestClick", this.suggestSource, a); | |
| GS.getGuts().logEvent("suggestClick", { | |
| suggest: this.querySuggest, | |
| source: this.suggestSource, | |
| numSongs: a | |
| }) | |
| }, | |
| detectRadio: function() { | |
| if ( $("#page_content").is(".search") ) { | |
| var a = GS.Models.Station.getStationByName(this.query.toLowerCase()); | |
| if ( a ) { | |
| var b = new GS.Models.DataString; | |
| b.string = $.localize.getString("SEARCH_START_RADIO"); | |
| b.data = { | |
| name: $.localize.getString(a.StationTitle) | |
| }; | |
| $("#page_content_pane .radio_suggestion").removeClass("hide"); | |
| $("#page_content_pane .radio_suggestion a.startRadio").attr("rel", a.StationID).html("<span>" + b.render() + "</span>") | |
| } | |
| } | |
| }, | |
| ".radio_suggestion a.startRadio click": function( a ) { | |
| GS.player.setAutoplay(true, a.attr("rel")) | |
| }, | |
| renderSlickBox: function( a, b, c ) { | |
| switch ( a ) { | |
| case "user": | |
| this.currentFilterStr = this.query; | |
| this.originalUsers = b.concat(); | |
| this.renderUsers(this.originalUsers, c); | |
| break; | |
| case "playlist": | |
| this.renderPlaylists(b, c); | |
| break; | |
| case "album": | |
| this.renderAlbums(b, c); | |
| break; | |
| case "artist": | |
| this.renderArtists(b, c); | |
| break | |
| } | |
| }, | |
| renderAlbums: function( a, b ) { | |
| this.currentSort = _.orEqual(b, { | |
| sortType: "relevance", | |
| sortFunction: null | |
| }); | |
| $("#grid").html("").css("height", "auto").addClass("albums"); | |
| this.slickbox = $("#grid").slickbox({ | |
| sortFunction: this.currentSort.sortFunction, | |
| scrollPane: "#page", | |
| padding: 0, | |
| itemRenderer: GS.Models.Album.itemRenderer, | |
| itemWidth: 250, | |
| itemHeight: 70, | |
| maxHorizontalGap: 50, | |
| minHorizontalGap: 10, | |
| verticalGap: 15, | |
| dragAs: "album", | |
| dragItemID: "AlbumID" | |
| }, a); | |
| this.sliderOrBoxDragSetup(this.slickbox, ".slickbox-item") | |
| }, | |
| renderPlaylists: function( a, b ) { | |
| this.currentSort = _.orEqual(b, { | |
| sortType: "relevance", | |
| sortFunction: null | |
| }); | |
| $("#grid").html("").css("height", "auto").addClass("playlistList"); | |
| this.slickbox = $("#grid").slickbox({ | |
| sortFunction: this.currentSort.sortFunction, | |
| scrollPane: "#page", | |
| padding: 0, | |
| itemRenderer: GS.Models.Playlist.itemRenderer, | |
| itemWidth: 250, | |
| itemHeight: 70, | |
| maxHorizontalGap: 50, | |
| minHorizontalGap: 10, | |
| verticalGap: 15, | |
| dragAs: "playlist", | |
| dragItemID: "PlaylistID" | |
| }, a); | |
| this.sliderOrBoxDragSetup(this.slickbox, ".slickbox-item") | |
| }, | |
| renderArtists: function( a, b ) { | |
| this.currentSort = _.orEqual(b, { | |
| sortType: "relevance", | |
| sortFunction: null | |
| }); | |
| $("#grid").html("").css("height", "auto").addClass("artistList"); | |
| this.slickbox = $("#grid").slickbox({ | |
| sortFunction: this.currentSort.sortFunction, | |
| scrollPane: "#page", | |
| padding: 0, | |
| itemRenderer: GS.Models.Artist.itemRenderer, | |
| itemWidth: 250, | |
| itemHeight: 70, | |
| maxHorizontalGap: 50, | |
| minHorizontalGap: 10, | |
| verticalGap: 15, | |
| dragAs: "artist", | |
| dragItemID: "ArtistID" | |
| }, a); | |
| this.sliderOrBoxDragSetup(this.slickbox, ".slickbox-item") | |
| }, | |
| renderUsers: function( a, b ) { | |
| this.currentSort = _.orEqual(b, { | |
| sortType: "relevance", | |
| sortFunction: null | |
| }); | |
| var c = | |
| $("body").width() <= 1024 || $("body").height() <= 800; | |
| $("#grid").html("").css("height", "auto").addClass("userlist"); | |
| this.slickbox = $("#grid").slickbox({ | |
| sortFunction: this.currentSort.sortFunction, | |
| scrollPane: "#page", | |
| padding: 0, | |
| listClass: c ? "smallUserView" : "", | |
| itemRenderer: GS.Models.User.itemRenderer, | |
| itemWidth: c ? 175 : 130, | |
| itemHeight: c ? 50 : 185, | |
| maxHorizontalGap: 50, | |
| minHorizontalGap: 20, | |
| verticalGap: 15 | |
| }, a) | |
| }, | |
| getSortMenu: function() { | |
| switch ( this.type ) { | |
| case "song": | |
| return this.getSongSortMenu(); | |
| case "playlist": | |
| return this.getPlaylistSortMenu(); | |
| case "user": | |
| return this.getUserSortMenu(); | |
| case "event": | |
| return this.getEventSortMenu(); | |
| case "album": | |
| case "artist": | |
| return this.getArtistAlbumSortMenu(); | |
| default: | |
| return [] | |
| } | |
| }, | |
| getSongSortMenu: function() { | |
| var a = this.setSort; | |
| return [{ | |
| title: $.localize.getString("SORT_BY_RELEVANCE"), | |
| action: { | |
| type: "fn", | |
| callback: function() { | |
| a("Rank", triggerElement, "SORT_BY_RELEVANCE") | |
| } | |
| }, | |
| customClass: "jj_menu_item_blank" | |
| }, { | |
| title: $.localize.getString("SORT_BY_SONG"), | |
| action: { | |
| type: "fn", | |
| callback: function() { | |
| a("SongName", triggerElement, "SORT_BY_SONG") | |
| } | |
| }, | |
| customClass: "jj_menu_item_blank" | |
| }, { | |
| title: $.localize.getString("SORT_BY_ARTIST"), | |
| action: { | |
| type: "fn", | |
| callback: function() { | |
| a("ArtistName", triggerElement, "SORT_BY_ARTIST") | |
| } | |
| }, | |
| customClass: "jj_menu_item_blank" | |
| }, { | |
| title: $.localize.getString("SORT_BY_ALBUM"), | |
| action: { | |
| type: "fn", | |
| callback: function() { | |
| a("AlbumName", triggerElement, "SORT_BY_ALBUM") | |
| } | |
| }, | |
| customClass: "jj_menu_item_blank" | |
| }, { | |
| title: $.localize.getString("SORT_BY_POPULARITY"), | |
| action: { | |
| type: "fn", | |
| callback: function() { | |
| a("Popularity", triggerElement, "SORT_BY_POPULARITY") | |
| } | |
| }, | |
| customClass: "jj_menu_item_blank" | |
| }] | |
| }, | |
| getPlaylistSortMenu: function() { | |
| var a = this.setSort; | |
| return [{ | |
| title: $.localize.getString("SORT_BY_RELEVANCE"), | |
| action: { | |
| type: "fn", | |
| callback: function() { | |
| a("Rank", triggerElement, "SORT_BY_RELEVANCE") | |
| } | |
| }, | |
| customClass: "jj_menu_item_blank" | |
| }, { | |
| title: $.localize.getString("SORT_BY_NAME"), | |
| action: { | |
| type: "fn", | |
| callback: function() { | |
| a("PlaylistName", triggerElement, "SORT_BY_NAME") | |
| } | |
| }, | |
| customClass: "jj_menu_item_blank" | |
| }] | |
| }, | |
| getEventSortMenu: function() { | |
| var a = this.setSort; | |
| return [{ | |
| title: $.localize.getString("SORT_BY_SOONEST_DATE"), | |
| action: { | |
| type: "fn", | |
| callback: function() { | |
| a("StartTime", triggerElement, "SORT_BY_SOONEST_DATE") | |
| } | |
| }, | |
| customClass: "jj_menu_item_blank" | |
| }, { | |
| title: $.localize.getString("SORT_BY_RELEVANCE"), | |
| action: { | |
| type: "fn", | |
| callback: function() { | |
| a("Rank", triggerElement, "SORT_BY_RELEVANCE") | |
| } | |
| }, | |
| customClass: "jj_menu_item_blank" | |
| }] | |
| }, | |
| getUserSortMenu: function() { | |
| var a = this.setSort; | |
| return [{ | |
| title: $.localize.getString("SORT_BY_RELEVANCE"), | |
| action: { | |
| type: "fn", | |
| callback: function() { | |
| a("Rank", triggerElement, "SORT_BY_RELEVANCE") | |
| } | |
| }, | |
| customClass: "jj_menu_item_blank" | |
| }, { | |
| title: $.localize.getString("SORT_BY_NAME"), | |
| action: { | |
| type: "fn", | |
| callback: function() { | |
| a("Name", triggerElement, "SORT_BY_NAME") | |
| } | |
| }, | |
| customClass: "jj_menu_item_blank" | |
| }] | |
| }, | |
| getArtistAlbumSortMenu: function() { | |
| var a = this.setSort; | |
| return [{ | |
| title: $.localize.getString("SORT_BY_RELEVANCE"), | |
| action: { | |
| type: "fn", | |
| callback: function() { | |
| a("Rank", triggerElement, "SORT_BY_RELEVANCE") | |
| } | |
| }, | |
| customClass: "jj_menu_item_blank" | |
| }] | |
| }, | |
| sortByPicture: function( a, b ) { | |
| return !a.Picture && b.Picture ? 1 : a.Picture && !b.Picture ? -1 : GS.user.favorites.users && !GS.user.favorites.users[a.UserID] && GS.user.favorites.users[b.UserID] ? 1 : GS.user.favorites.users && GS.user.favorites.users[a.UserID] && !GS.user.favorites.users[b.UserID] ? -1 : 0 | |
| }, | |
| filterUsers: function( a ) { | |
| if ( this.currentFilterStr != a ) { | |
| this.currentFilterStr = a; | |
| this.type == "user" && this.originalUsers && this.renderUsers(this.originalUsers.filter(this.callback("filterUsersFunction")), this.currentSort) | |
| } | |
| }, | |
| filterUsersFunction: function( a ) { | |
| return (a.Username.toLowerCase() + " " + a.Name.toLowerCase()).indexOf(this.currentFilterStr.toLowerCase()) !== -1 | |
| } | |
| }); | |
| GS.Controllers.PageController.extend("GS.Controllers.Page.SurveysController", {}, { | |
| type: "surveys", | |
| questionIndex: 0, | |
| index: function( a, b ) { | |
| this.subpage = a || "index"; | |
| this.id = b || false; | |
| this.numPointsPerProfiler = GS.Models.Clearvoice.defaultPointsPerProfiler; | |
| this.neverShowNotice = GS.store.get("gs.surveys.neverShowNotice" + GS.user.UserID); | |
| GS.Controllers.PageController.title("Surveys"); | |
| $.publish("gs.page.loading.page"); | |
| GS.Models.Clearvoice.getMember(this.callback("loadMember")); | |
| this.subscribe("gs.auth.pointsUpdated", this.callback("getUserPoints")); | |
| this.subscribe("gs.auth.update", this.callback("index")); | |
| GS.user.isLoggedIn && this.getUserPoints() | |
| }, | |
| getUserPoints: function() { | |
| GS.user.getPoints(this.callback(function( a ) { | |
| $("#userPoints").text(a) | |
| })) | |
| }, | |
| loadMember: function( a ) { | |
| this.member = a; | |
| GS.user.clearvoice = a; | |
| if ( this.subpage === "bonus" ) if ( GS.user.isLoggedIn ) if ( this.currentSurvey ) { | |
| this.pollQuestionIndex = 1; | |
| this.pollAnswers = {}; | |
| for ( a = 0; a < this.member.polls.available.length; a++ ) | |
| if ( this.member.polls.available[a].SurveyID == this.currentSurvey ) { | |
| this.surveyIndex = | |
| a; | |
| a = 0; | |
| var b = this.member.polls.available[this.surveyIndex].Questions; | |
| for ( var c in b ) | |
| b.hasOwnProperty(c) && a++; | |
| this.surveyLength = a; | |
| this.element.html(this.view("bonus")); | |
| break | |
| } | |
| } else location.hash = "/surveys"; | |
| else location.hash = "/surveys"; | |
| else { | |
| this.element.html(this.view("index")); | |
| this.member.resetProgress() | |
| } | |
| $(window).resize() | |
| }, | |
| determineNextQuestion: function() { | |
| for ( var a; a = this.member.questions[this.questionIndex]; ) | |
| if ( this.member.answers && this.member.answers[a.DemographicId] ) this.questionIndex++; | |
| else if ( this.member.answers && a.AnswerId && this.member.answers[a.ParentDemographicId] && !this.member.answers[a.ParentDemographicId][a.AnswerId] ) this.questionIndex++; | |
| else { | |
| if ( this.questionIndex < this.member.questions.length ) { | |
| this.member.resetProgress(); | |
| this.element.html(this.view("profiler")) | |
| } else location.hash = "/surveys"; | |
| $(window).resize(); | |
| return | |
| } | |
| location.hash = "/surveys" | |
| }, | |
| "button.next.rewards click": function( a, b ) { | |
| b.preventDefault(); | |
| var c, g, h = parseInt($(".survey_question").attr("data-questionID")), | |
| k = parseInt(a.attr("data-question-type")); | |
| switch ( k ) { | |
| case 0: | |
| case 1: | |
| var m = $("ul.survey_answers input:checked"); | |
| g = m.attr("data-answerID"); | |
| if ( m.length && g ) c = this.member.polls.available[this.surveyIndex].Questions[this.pollQuestionIndex].PossibleAnswers[g]; | |
| break; | |
| case 2: | |
| case 3: | |
| var p = this; | |
| g = []; | |
| c = []; | |
| $("ul.survey_answers input:checked").each(function() { | |
| g.push($(this).attr("data-answerID")); | |
| c.push(p.member.polls.available[p.surveyIndex].Questions[p.pollQuestionIndex].PossibleAnswers[g[g.length - 1]]) | |
| }); | |
| break; | |
| case 4: | |
| case 5: | |
| case 6: | |
| c = $("ul.survey_answers textarea").val(); | |
| c = $.trim(c); | |
| break; | |
| default: | |
| } | |
| if ( c ) { | |
| this.pollAnswers[h] = k == 2 ? g : g ? [parseInt(g)] : [c]; | |
| this.pollQuestionIndex++; | |
| if ( this.pollQuestionIndex - 1 < this.surveyLength ) this.element.html(this.view("bonus")); | |
| else { | |
| h = this.member.polls.available[this.surveyIndex].Points; | |
| this.member.savePollAnswers(this.currentSurvey, GS.user.UserID, this.pollAnswers, h, this.callback("saveSuccess", h)) | |
| } | |
| } | |
| return false | |
| }, | |
| saveSuccess: function() { | |
| location.hash = "/surveys" | |
| }, | |
| "button.next.profiler click": function( a, b ) { | |
| b.preventDefault(); | |
| var c; | |
| switch ( this.member.questions[this.questionIndex].DemographicTypeId ) { | |
| case 2: | |
| case 9: | |
| case 12: | |
| var g = | |
| $("ul.survey_answers input:checked", this.element); | |
| if ( g.length && this.member.answerLookup[g.val()] ) c = this.member.answerLookup[$("ul.survey_answers input:checked").val()]; | |
| break; | |
| case 6: | |
| case 7: | |
| var h = this; | |
| $("ul.survey_answers input:checked", this.element).each(function() { | |
| c || (c = []); | |
| var k = $(this).val(); | |
| h.member.answerLookup[k] && c.push(h.member.answerLookup[k]) | |
| }); | |
| break; | |
| case 8: | |
| case 10: | |
| if ( this.member.answerLookup[$("ul.survey_answers textarea", this.element).attr("data-answerid")] ) { | |
| c = this.member.answerLookup[$("textarea", this.element).attr("data-answerid")]; | |
| c.LocalizedValue = $("textarea", this.element).val() | |
| } | |
| break; | |
| case 3: | |
| case 5: | |
| break | |
| } | |
| if ( c ) { | |
| this.member.saveAnswers(c, function( k ) { | |
| GS.user.clearvoice.determineValidAnswer(k) | |
| }); | |
| this.questionIndex++; | |
| this.determineNextQuestion() | |
| } | |
| return false | |
| }, | |
| "a.startSurvey click": function( a ) { | |
| a = a.attr("data-index"); | |
| (a = _.defined(GS.user.clearvoice.AvailableSurveys[a]) ? GS.user.clearvoice.AvailableSurveys[a] : GS.user.clearvoice.DynamicSurveys[a]) && GS.getLightbox().open("startSurvey", { | |
| survey: a | |
| }) | |
| }, | |
| "a.clearvoiceSignup click": function( a, b ) { | |
| b.preventDefault(); | |
| if ( GS.user.isLoggedIn ) location.hash = "/surveys/profiler"; | |
| else GS.getLightbox().open("login") | |
| }, | |
| "a.bonus click": function( a, b ) { | |
| b.preventDefault(); | |
| this.currentSurvey = a.attr("data-surveyID"); | |
| if ( GS.user.isLoggedIn ) location.hash = "/surveys/bonus"; | |
| else GS.getLightbox().open("login") | |
| }, | |
| "a.login click": function() { | |
| GS.getLightbox().open("login") | |
| }, | |
| "button.pause click": function( a, b ) { | |
| b.preventDefault(); | |
| if ( this.pollAnswers && !_.isEmpty(this.pollAnswers) ) GS.getLightbox().open({ | |
| type: "dontLeaveSurveys", | |
| view: { | |
| header: "GROOVESHARK_SURVEYS_DONT_LEAVE_TITLE", | |
| message: "GROOVESHARK_SURVEYS_DONT_LEAVE_MESSAGE", | |
| buttonsRight: [{ | |
| label: "GROOVESHARK_SURVEYS_STAY", | |
| className: "stay" | |
| }], | |
| buttonsLeft: [{ | |
| label: "SURVEY_BACK_TO_SURVEYS", | |
| className: "leave" | |
| }] | |
| }, | |
| callbacks: { | |
| ".leave": function() { | |
| GS.getLightbox().close(); | |
| location.hash = "/surveys" | |
| }, | |
| ".stay": function() { | |
| GS.getLightbox().close() | |
| } | |
| } | |
| }); | |
| else location.hash = "/surveys"; | |
| return false | |
| }, | |
| "button.redeem_button click": function( a ) { | |
| if ( GS.user.isLoggedIn ) if ( $(a).is(".redeem_plus") ) GS.getLightbox().open("redeemPoints", { | |
| type: "plus" | |
| }); | |
| else $(a).is(".redeem_anywhere") && GS.getLightbox().open("redeemPoints", { | |
| type: "anywhere" | |
| }); | |
| else GS.getLightbox().open("login") | |
| }, | |
| "button.dontShowAgain click": function() { | |
| $(".featureBox", this.element).slideUp(); | |
| GS.store.set("gs.surveys.neverShowNotice" + GS.user.UserID, true) | |
| }, | |
| "button.hideNotice click": function() { | |
| $(".featureBox", this.element).slideUp() | |
| } | |
| }); | |
| (function() { | |
| var a = { | |
| 1: { | |
| message: "POPUP_SIGNUP_FORM_UNKNOWN_ERROR" | |
| }, | |
| 2: { | |
| message: "POPUP_SIGNUP_FORM_DUPLICATE_EMAIL", | |
| fields: ["#signup_email"] | |
| }, | |
| 4: { | |
| message: "POPUP_SIGNUP_FORM_DUPLICATE_USERNAME", | |
| fields: ["#signup_username"] | |
| }, | |
| 8: { | |
| message: "POPUP_SIGNUP_FORM_INVALID_PASSWORD", | |
| fields: ["#signup_password"] | |
| }, | |
| 16: { | |
| message: "POPUP_SIGNUP_FORM_MISSING_GENDER", | |
| fields: ["#sex_M", "#sex_F"] | |
| }, | |
| 32: { | |
| message: "POPUP_SIGNUP_FORM_MISSING_NAME", | |
| fields: ["#signup_fname"] | |
| }, | |
| 64: { | |
| message: "POPUP_SIGNUP_FORM_USERNAME_LENGTH_ERROR", | |
| fields: ["#signup_username"] | |
| }, | |
| 128: { | |
| message: "POPUP_SIGNUP_FORM_INVALID_USERNAME", | |
| fields: ["#signup_username"] | |
| }, | |
| 256: { | |
| message: "POPUP_SIGNUP_FORM_INVALID_EMAIL", | |
| fields: ["#signup_email"] | |
| }, | |
| 512: { | |
| message: "POPUP_SIGNUP_FORM_TOO_YOUNG", | |
| fields: [] | |
| }, | |
| 16384: { | |
| message: "POPUP_SIGNUP_FORM_PASSWORD_NO_MATCH", | |
| fields: ["#signup_password", "#signup_password2"] | |
| }, | |
| 32768: { | |
| message: "POPUP_SIGNUP_FORM_MUST_ACCEPT_TOS", | |
| fields: ["#signup_tos"] | |
| }, | |
| 65536: { | |
| message: "POPUP_SIGNUP_FORM_MISSING_DOB", | |
| fields: [] | |
| } | |
| }; | |
| GS.Controllers.PageController.extend("GS.Controllers.Page.SignupController", {}, { | |
| curStage: false, | |
| section: false, | |
| stages: { | |
| profile1: "profile1", | |
| profile2: "profile2", | |
| connect: "connect", | |
| upgrade: "upgrade", | |
| complete: "complete" | |
| }, | |
| userInfo: {}, | |
| googleContacts: null, | |
| facebookFriends: [], | |
| fbIDs: {}, | |
| slickbox: false, | |
| thirdPartyErrors: {}, | |
| subProfileUpdate: null, | |
| init: function() { | |
| this._super(); | |
| this.section = ""; | |
| this.today = new Date; | |
| this.months = $.localize.getString("MONTHS").split(","); | |
| this.isFacebook = false; | |
| this.fbSession = {}; | |
| this.isGoogle = false; | |
| this.googleData = {}; | |
| this.subscribe("gs.app.resize", this.callback(this.resize)); | |
| this.subscribe("gs.auth.update", this.callback(this.update)); | |
| this.subscribe("gs.locale.update", this.callback(function() { | |
| this.months = $.localize.getString("MONTHS").split(",") | |
| })) | |
| }, | |
| index: function( b ) { | |
| this.section = b; | |
| var c = {}; | |
| if ( b ) c.subpage = b; | |
| GS.getGuts().handlePageLoad("signup", c); | |
| this._super(); | |
| this.resize(); | |
| GS.resize(); | |
| GS.getLightbox().close(); | |
| GS.Controllers.PageController.title("Signup", false); | |
| this.update() | |
| }, | |
| resize: function() { | |
| $("#page_signup").css({ | |
| top: Math.max(30, ($("#page").height() - $("#page_signup").height()) / 2) | |
| }) | |
| }, | |
| update: function() { | |
| var b = GS.user.defaultFromService; | |
| if ( this.section == "complete" && GS.user.UserID > 0 ) { | |
| this.vipPackage = GS.user.getVipPackage(); | |
| this.initComplete(this.vipPackage) | |
| } else if ( this.section == "upgrade" && GS.user.UserID > 0 ) this.initUpgrade(); | |
| else if ( this.section == "connect" || GS.user.UserID > 0 ) this.initConnect(); | |
| else this.section == "aboutme" ? this.initProfile2() : this.initProfile1(); | |
| if ( b ) { | |
| b.username && $("input[name=username]", this.element).val(b.username); | |
| b.email && $("input[name=email]", this.element).val(b.email); | |
| b.fname && $("input[name=fname]", this.element).val(b.fname); | |
| b.month && $("select[name=month]").val(b.month); | |
| b.day && $("select[name=day]").val(b.day); | |
| b.year && $("select[name=year]").val(b.year); | |
| b.sex && $("#sex_" + b.sex).click(); | |
| this.thirdPartyErrors.facebook = { | |
| 1024: { | |
| message: "POPUP_SIGNUP_FORM_FACEBOOK_GENERAL_ERROR", | |
| fields: [] | |
| }, | |
| 2048: { | |
| message: "POPUP_SIGNUP_FORM_FACEBOOK_GENERAL_ERROR", | |
| fields: [] | |
| }, | |
| 4096: { | |
| message: "FACEBOOK_DUPLICATE_ACCOUNT_ERROR_MSG", | |
| fields: [] | |
| } | |
| }; | |
| this.thirdPartyErrors.google = { | |
| 2048: { | |
| message: "POPUP_SIGNUP_FORM_GOOGLE_GENERAL_ERROR", | |
| fields: [] | |
| }, | |
| 4096: { | |
| message: "GOOGLE_DUPLICATE_ACCOUNT_ERROR_MSG", | |
| fields: [] | |
| } | |
| }; | |
| if ( b.isFacebook ) { | |
| this.isFacebook = true; | |
| if ( b.session ) { | |
| this.fbSession = b.session; | |
| this.fbSession.flags = b.fbFlags | |
| } | |
| $("#page_signup_password").hide(); | |
| $("#page_signup_password2").hide(); | |
| $("#signup_third_parties").hide(); | |
| a[1024] = this.thirdPartyErrors.facebook[1024]; | |
| a[2048] = this.thirdPartyErrors.facebook[2048]; | |
| a[4096] = this.thirdPartyErrors.facebook[4096] | |
| } else if ( b.isGoogle ) { | |
| this.isGoogle = true; | |
| if ( b.googleData ) this.googleData = b.googleData; | |
| $("#page_signup_password").hide(); | |
| $("#page_signup_password2").hide(); | |
| $("#signup_third_parties").hide(); | |
| a[2048] = this.thirdPartyErrors.google[2048]; | |
| a[4096] = this.thirdPartyErrors.google[4096] | |
| } | |
| b.error && this.element.find(".error").show().find(".message").html(b.error); | |
| b.message && this.element.find(".intro-message").show().find(".message").html(b.message); | |
| $(".input_wrapper_selectbox.month span").html($(".input_wrapper_selectbox.month").find("option:selected").html()); | |
| $(".input_wrapper_selectbox.day span").html($(".input_wrapper_selectbox.day").find("option:selected").html()); | |
| $(".input_wrapper_selectbox.year span").html($(".input_wrapper_selectbox.year").find("option:selected").html()); | |
| this.bExtend = GS.user.IsPremium ? 1 : 0; | |
| this.resumeRedeem = b.resumeRedeem ? true : false | |
| } | |
| GS.resize() | |
| }, | |
| initProfile1: function() { | |
| this.curStage = this.stages.profile1; | |
| $(".page_signup_form").addClass("hide"); | |
| $("#page_signup_form_profile1").removeClass("hide"); | |
| $("#page_signup_steps").attr("class", "step1"); | |
| $("#signup_email").focus(); | |
| GS.getLightbox().trackLightboxView("signup/profile1") | |
| }, | |
| initProfile2: function() { | |
| this.curStage = | |
| this.stages.profile2; | |
| $(".page_signup_form").addClass("hide"); | |
| $("#page_signup_form_profile2").removeClass("hide"); | |
| $("#page_signup_steps").attr("class", "step1"); | |
| $("#signup_username").focus(); | |
| GS.getLightbox().trackLightboxView("signup/profile2") | |
| }, | |
| initConnect: function() { | |
| this.curStage = this.stages.connect; | |
| this.submitType = "facebook"; | |
| $("#page_signup_steps").attr("class", "step2"); | |
| $(".page_signup_form").addClass("hide"); | |
| $("#page_signup_form_connect").html(this.view("connect")).removeClass("hide"); | |
| GS.getLightbox().trackLightboxView("signup/invite") | |
| }, | |
| initUpgrade: function() { | |
| this.curStage = this.stages.upgrade; | |
| $("#page_signup_steps").attr("class", "step3"); | |
| $(".page_signup_form").addClass("hide"); | |
| $("#page_signup_form_upgrade").html(this.view("upgrade")).removeClass("hide"); | |
| GS.getLightbox().trackLightboxView("signup/upgrade") | |
| }, | |
| initComplete: function() { | |
| if ( GS.user.PathName || GS.user.PathNameEmpty ) { | |
| this.curStage = this.stages.complete; | |
| this.vipPackage = GS.user.getVipPackage(); | |
| $("#page_signup_steps").attr("class", "hide"); | |
| $(".page_signup_form").addClass("hide"); | |
| $("#page_signup_form").html(this.view("complete")).removeClass("hide"); | |
| GS.resize() | |
| } else GS.user.getPathName(this.callback("initComplete")); | |
| GS.getLightbox().trackLightboxView("signup/complete") | |
| }, | |
| "a.login click": function() { | |
| GS.getLightbox().close(); | |
| GS.getLightbox().open("login") | |
| }, | |
| "a.perks click": function() { | |
| GS.getLightbox().close(); | |
| GS.getLightbox().open("vipPerks") | |
| }, | |
| "button.upgrade click": function( b ) { | |
| b = _.orEqual($(b).attr("rel"), this.vipPackage); | |
| GS.getLightbox().close(); | |
| GS.getLightbox().open("vipSignup", { | |
| vipPackage: b, | |
| isSignup: false | |
| }) | |
| }, | |
| "button.anywhereUpgrade click": function() { | |
| GS.getLightbox().open("vipSignup", { | |
| vipPackage: "anywhere" | |
| }) | |
| }, | |
| "#page_signup_form button.submit click": function( b, c ) { | |
| c.preventDefault(); | |
| this.hideErrors(); | |
| if ( this.curStage == this.stages.profile1 ) this.checkProfile1() && this.initProfile2(); | |
| else if ( this.curStage == this.stages.profile2 ) this.profileSubmit(); | |
| else if ( this.curStage == this.stages.connect ) { | |
| this.isFacebook && GS.getLightbox().open("newFacebookUser"); | |
| GS.user.IsPremium ? this.initComplete() : this.initUpgrade() | |
| } else if ( this.curStage == this.stages.upgrade ) this.initComplete(); | |
| else if ( this.curStage == this.stages.complete ) GS.getFacebook().connected || setTimeout(this.callback(function() { | |
| $.publish("gs.facebook.notification.connect", {}) | |
| }), 3E3); | |
| GS.resize(); | |
| setTimeout("GS.resize()", 100); | |
| return false | |
| }, | |
| "#page_signup_form button.back click": function( b, c ) { | |
| c.preventDefault(); | |
| this.hideErrors(); | |
| if ( this.curStage == this.stages.profile2 ) this.initProfile1(); | |
| else if ( this.curStage == this.stages.connect ) this.initProfile2(); | |
| else if ( this.curStage == this.stages.upgrade ) this.initConnect(); | |
| else this.curStage == this.stages.complete && this.initConnect(); | |
| GS.resize(); | |
| return false | |
| }, | |
| "#signupUpgrade li.upgrade click": function( b ) { | |
| b = b.is(".plus") ? "plus" : "anywhere"; | |
| GS.getLightbox().open("vipSignup", { | |
| vipPackage: b, | |
| isSignup: true, | |
| bExtend: this.bExtend | |
| }) | |
| }, | |
| "button.service click": function( b ) { | |
| switch ( $(b).attr("rel") ) { | |
| case "facebook": | |
| GS.getFacebook().login(function() { | |
| $(b).addClass("active") | |
| }, this.callback("signupFailed", { | |
| errorCode: 1024 | |
| }, this.thirdPartyErrors.facebook)); | |
| break; | |
| case "google": | |
| GS.getGoogle().login(function() { | |
| $(b).addClass("active") | |
| }, this.callback("signupFailed", { | |
| errorCode: 1024 | |
| }, this.thirdPartyErrors.google)); | |
| break | |
| } | |
| return false | |
| }, | |
| "#signup_third_parties button.facebookLogin click": function() { | |
| GS.auth.loginViaFacebook(this.callback("afterSignupLogin", "facebook"), this.callback("signupFailed", { | |
| errorCode: 1024 | |
| }, this.thirdPartyErrors.facebook)) | |
| }, | |
| "#signup_third_parties button.googleLogin click": function() { | |
| GS.auth.loginViaGoogle(this.callback("afterSignupLogin", "google"), this.callback("signupFailed", { | |
| errorCode: 1024 | |
| }, this.thirdPartyErrors.google)) | |
| }, | |
| afterSignupLogin: function( b ) { | |
| switch ( b ) { | |
| case "facebook": | |
| this.subProfileUpdate = $.subscribe("gs.facebook.profile.update", this.callback(function() { | |
| console.log("gotcha"); | |
| var c = new GS.Models.DataString; | |
| c.string = $.localize.getString("NOTIF_FACEBOOK_LOGIN_LOGOUT"); | |
| c.data = { | |
| fullName: GS.facebook.profile.name | |
| }; | |
| $.publish("gs.notification", { | |
| type: "facebook", | |
| message: c.render() | |
| }); | |
| $.unsubscribe(this.subProfileUpdate) | |
| })); | |
| break; | |
| case "google": | |
| b = | |
| new GS.Models.DataString; | |
| b.string = $.localize.getString("NOTIF_GOOGLE_LOGIN_LOGOUT"); | |
| b.data = { | |
| fullName: GS.google.firstname + " " + GS.google.lastname | |
| }; | |
| $.publish("gs.notification", { | |
| type: "google", | |
| message: b.render() | |
| }); | |
| break | |
| } | |
| }, | |
| "#signup_username keyup": function( b ) { | |
| b = b.val(); | |
| this.hideErrors(); | |
| $("#page_signup_customURL_label .status").removeClass("verified error alert"); | |
| if ( b !== "" && b.length ) { | |
| clearTimeout(this.checkUsernameTimer); | |
| this.checkUsernameTimer = setTimeout(this.callback("checkUsername", b), 500) | |
| } | |
| }, | |
| checkUsernameTimer: null, | |
| checkUsername: function( b ) { | |
| var c = 0, | |
| g = /^([a-zA-Z0-9]+[\.\-_]?)+[a-zA-Z0-9]+$/; | |
| if ( b.length && (b.length < 5 || b.length > 32 || !b.match(g)) ) { | |
| c |= 128; | |
| $("#page_signup_customURL_label .status").addClass("alert").attr("title", $.localize.getString("POPUP_SIGNUP_FORM_USERNAME_INVALID")) | |
| } else b.length && GS.service.getItemByPageName(b, this.callback(function( h ) { | |
| if (!h || h.type ) { | |
| c |= 4; | |
| $("#page_signup_customURL_label .status").addClass("error").attr("title", $.localize.getString("POPUP_SIGNUP_FORM_USERNAME_UNAVAILABLE")) | |
| } else $("#page_signup_customURL_label .status").addClass("verified").attr("title", $.localize.getString("POPUP_SIGNUP_FORM_USERNAME_AVAILABLE")) | |
| }), null, { | |
| async: false | |
| }); | |
| return c | |
| }, | |
| "#signup_password change": function( b ) { | |
| var c = b.val(), | |
| g = $("#signup_password2").val(); | |
| this.hideErrors(); | |
| if ( c !== "" && c.length && !(c.length < 5 || c.length > 32) ) { | |
| b.parents(".input_wrapper").removeClass("error").siblings("label").removeClass("error"); | |
| if ( c === g ) $("#signup_password2").parents(".input_wrapper").removeClass("error").siblings("label").removeClass("error"); | |
| else g !== "" && this.signupFailed({ | |
| errorCode: 16384 | |
| }) | |
| } else { | |
| b.parents(".input_wrapper").addClass("error").siblings("label").addClass("error"); | |
| this.signupFailed({ | |
| errorCode: 8 | |
| }) | |
| } | |
| }, | |
| "#signup_password2 change": function( b ) { | |
| var c = $("#signup_password").val(), | |
| g = b.val(); | |
| this.hideErrors(); | |
| if ( g && c === g ) { | |
| b.parents(".input_wrapper").removeClass("error").siblings("label").removeClass("error"); | |
| $("#signup_password").change() | |
| } else { | |
| b.parents(".input_wrapper").addClass("error").siblings("label").addClass("error"); | |
| $("#signup_password").parents(".input_wrapper").addClass("error").siblings("label").addClass("error"); | |
| this.signupFailed({ | |
| errorCode: 16384 | |
| }) | |
| } | |
| }, | |
| "#signup_email change": function( b ) { | |
| var c = | |
| b.val(); | |
| this.hideErrors(); | |
| if ( c.match(_.emailRegex) ) b.parents(".input_wrapper").removeClass("error").siblings("label").removeClass("error"); | |
| else { | |
| b.parents(".input_wrapper").addClass("error").siblings("label").addClass("error"); | |
| this.signupFailed({ | |
| errorCode: 256 | |
| }) | |
| } | |
| }, | |
| "#signup_fname change": function( b ) { | |
| b.val() !== "" ? b.parents(".input_wrapper").removeClass("error").siblings("label").removeClass("error") : b.parents(".input_wrapper").addClass("error").siblings("label").addClass("error") | |
| }, | |
| "#signup_tos change": function( b ) { | |
| b.is(":checked") ? b.parent().removeClass("error") : b.parent().addClass("error") | |
| }, | |
| "input,select keydown": function( b, c ) { | |
| c.keyCode && c.keyCode == 13 && !b.is("[name*=google]") && $("#lightbox_footer li.submit:visible, #pane_footer li.submit:visible").click() | |
| }, | |
| "select focus": function( b ) { | |
| b.parents(".input_wrapper").addClass("active") | |
| }, | |
| "select blur": function( b ) { | |
| b.parents(".input_wrapper").removeClass("active"); | |
| b.change() | |
| }, | |
| "select keydown": function( b ) { | |
| b.change() | |
| }, | |
| "select.year,select.month,select.day change": function() { | |
| var b = parseInt($("select[name=month]", this.element).val(), 10), | |
| c = parseInt($("select[name=year]", this.element).val(), 10), | |
| g = parseInt($("select[name=day]", this.element).val(), 10), | |
| h = $("select[name=month]", this.element).find("option:selected").val(), | |
| k = $("select[name=year]", this.element).find("option:selected").val(), | |
| m = $("select[name=day]", this.element).find("option:selected").val(); | |
| this.hideErrors(); | |
| k !== "" && (!c || c < 0) ? $("select[name=year]", this.element).parents(".input_wrapper").addClass("error").parent().siblings("label").addClass("error") : $("select[name=year]", this.element).parents(".input_wrapper").removeClass("error").parent().siblings("label").removeClass("error"); | |
| h !== "" && (!b || b < 0) ? $("select[name=month]", this.element).parents(".input_wrapper").addClass("error").parent().siblings("label").addClass("error") : $("select[name=month]", this.element).parents(".input_wrapper").removeClass("error").parent().siblings("label").removeClass("error"); | |
| m !== "" && (!g || g < 0) ? $("select[name=day]", this.element).parents(".input_wrapper").addClass("error").parent().siblings("label").addClass("error") : $("select[name=day]", this.element).parents(".input_wrapper").removeClass("error").parent().siblings("label").removeClass("error"); | |
| if ( c && b && g ) { | |
| b = new Date(c, b - 1, g); | |
| b = +new Date - +b; | |
| b = b / 864E5; | |
| b = Math.floor(b / 365.24); | |
| b < 13 ? this.signupFailed({ | |
| errorCode: 512 | |
| }) : $(".input_wrapper.year, .input_wrapper.month, .input_wrapper.day").removeClass("error").parent().siblings("label").removeClass("error") | |
| } | |
| }, | |
| "li.sex_field label mousedown": function( b ) { | |
| $(b).data("previous", $("li.sex_field input[name=sex]:checked").val()) | |
| }, | |
| "li.sex_field label click": function( b, c ) { | |
| var g = $("input", b); | |
| $(".page_signup_sex_option").removeClass("checked"); | |
| if ( $(g).val() === $(b).data("previous") ) { | |
| $("#sex_Deselect").attr("checked", "checked"); | |
| c.preventDefault(); | |
| $(g).blur(); | |
| return false | |
| } else $(b).addClass("checked") | |
| }, | |
| "#page_signup_flags label click": function( b, c ) { | |
| var g = $("input", b); | |
| c.preventDefault(); | |
| if ( g.is(":checked") ) { | |
| g.attr("checked", false); | |
| $(b).removeClass("checked") | |
| } else { | |
| g.attr("checked", "checked"); | |
| $(b).addClass("checked") | |
| } | |
| $(g).blur() | |
| }, | |
| "#page_signup_flags input change": function( b ) { | |
| $(b).closest("label").toggleClass("checked", $(b).is(":checked")) | |
| }, | |
| ".error.response a.toggle click": function() { | |
| this.hideErrors() | |
| }, | |
| checkProfile1: function() { | |
| var b = true, | |
| c = $("#page_signup input[name=email]").val(), | |
| g = $("#page_signup input[name=fname]").val(), | |
| h = $("#page_signup input[name=password]").val(), | |
| k = $("#page_signup input[name=password2]").val(), | |
| m = $("#page_signup input[name=tos]").is(":checked"), | |
| p = /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i, | |
| n = 0; | |
| GS.service.getIsUsernameEmailAvailable("", c, this.callback(function( o ) { | |
| if (!o.email && c.length ) n |= 2 | |
| }), null, { | |
| async: false | |
| }); | |
| this.hideErrors(); | |
| if (!c.length || !c.match(p) ) n |= 256; | |
| g.length || (n |= 32); | |
| if (!this.isFacebook && !this.isGoogle ) { | |
| if ( h.length < 5 || h.length > 32 ) n |= 8; | |
| if ( h !== k ) n |= 16384 | |
| } | |
| m || (n |= 32768); | |
| if ( n > 0 ) { | |
| this.signupFailed({ | |
| errorCode: n | |
| }); | |
| b = false | |
| } else { | |
| this.hideErrors(); | |
| this.element.find(".intro-message.response").hide(); | |
| $("#signup_username").change(); | |
| $("#signup_email").change(); | |
| $("#signup_tos").change(); | |
| if (!this.isGoogle && !this.isFacebook ) { | |
| $("#signup_password").change(); | |
| $("#signup_password2").change() | |
| } | |
| if ( $("#signupAccount .input_wrapper.error, #signupAccount p.tos.error").length ) b = false | |
| } | |
| return b | |
| }, | |
| profileSubmit: function() { | |
| var b = $("#page_signup input[name=username]").val(), | |
| c = $("#page_signup input[name=password]").val(), | |
| g = $("#page_signup input[name=email]").val(), | |
| h = $("#page_signup input[name=fname]").val(), | |
| k = $("#page_signup input[name=sex]:checked").val(), | |
| m = [$("#page_signup select[name=year]").val(), $("#page_signup select[name=month]").val(), $("#page_signup select[name=day]").val()].join("-"), | |
| p = $("#page_signup input[name=tos]").is(":checked"), | |
| n = $("#page_signup input[name=artist]").is(":checked") ? GS.Models.User.FLAG_ISARTIST : 0, | |
| o = $("#page_signup input[name=music_business]").is(":checked") ? GS.Models.User.FLAG_MUSIC_BUSINESS : 0; | |
| n = n | o; | |
| var t = parseInt($("#page_signup select[name=month]", this.element).val(), 10), | |
| w = parseInt($("#page_signup select[name=year]", this.element).val(), 10), | |
| x = parseInt($("#page_signup select[name=day]", this.element).val(), 10), | |
| v = /^([a-zA-Z0-9]+[\.\-_]?)+[a-zA-Z0-9]+$/; | |
| o = 0; | |
| if ( b.length ) if ( b.match(v) ) o = b.length < 5 || b.length > 32 ? o | 64 : o | this.checkUsername(b); | |
| else o |= 128; | |
| p || (o |= 32768); | |
| this.element.find(".error.response").hide(); | |
| $("select.year,select.month,select.day", this.element).change(); | |
| $("#signup_fname").change(); | |
| if ( w && t && x ) { | |
| p = new Date(w, t - 1, x); | |
| p = +new Date - +p; | |
| p = p / 864E5; | |
| p = Math.floor(p / 365.24); | |
| if ( p < 13 ) o |= 512 | |
| } else { | |
| $(".input_wrapper.year, .input_wrapper.month, .input_wrapper.day").addClass("error").parent().siblings("label").addClass("error"); | |
| o |= 65536 | |
| } | |
| k || (k = ""); | |
| if ( o > 0 || $("#page_signup .input_wrapper.error, #signupAccount p.tos.error, #signupAccount div.field.error").length ) { | |
| this.signupFailed({ | |
| errorCode: o | |
| }); | |
| return false | |
| } | |
| if ( this.isFacebook ) GS.auth.signupViaFacebook(b, h, g, k, m, n, this.fbSession, this.callback(this.signupSuccess), this.callback(this.signupFailed)); | |
| else this.isGoogle ? GS.auth.signupViaGoogle(b, h, g, k, m, n, this.callback(this.signupSuccess), this.callback(this.signupFailed)) : GS.auth.signup(b, c, h, g, k, m, n, true, this.callback(this.signupSuccess), this.callback(this.signupFailed)); | |
| return true | |
| }, | |
| signupSuccess: function( b ) { | |
| if ( b && b.userID ) { | |
| this.hideErrors(); | |
| if ( this.isGoogle ) GS.getGoogle().connected = true; | |
| if ( this.isFacebook ) GS.getFacebook().connected = true; | |
| this.initConnect() | |
| } else this.signupFailed(b) | |
| }, | |
| signupFailed: function( b, c ) { | |
| var g, h, k, m = ['<ul class="errors">']; | |
| k = a; | |
| if ( c ) k = c; | |
| $.each(k, function( n, o ) { | |
| if ( b.errorCode & n ) { | |
| m.push("<li>" + $.localize.getString(o.message) + " </li>"); | |
| if ( o.fields ) for ( g = 0; g < o.fields.length; g++ ) $(o.fields[g]).parents(".input_wrapper").addClass("error").siblings("label").addClass("error") | |
| } | |
| }); | |
| m.push("</ul>"); | |
| k = this.element.find(".error.response").show().find(".message"); | |
| if |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment