2013-03-04 03:38:12 +00:00
( function ( context , $ ) {
"use strict" ;
context . JK = context . JK || { } ;
context . JK . Sidebar = function ( app ) {
2014-02-13 04:40:41 +00:00
var logger = context . JK . logger ;
var friends = [ ] ;
var rest = context . JK . Rest ( ) ;
var invitationDialog = null ;
2014-03-20 11:53:26 +00:00
var textMessageDialog = null ;
2014-02-13 04:40:41 +00:00
function initializeSearchPanel ( ) {
$ ( '#search_text_type' ) . change ( function ( ) {
searchForInput ( ) ;
context . JK . SearchResultScreen . searchTypeSelection ( $ ( '#search_text_type' ) . val ( ) ) ;
} ) ;
}
context . JK . Sidebar . searchTypeSelection = function ( typeSelection ) {
$ ( '#search_text_type' ) . val ( typeSelection ) ;
emptySearchResults ( ) ;
}
function initializeFriendsPanel ( ) {
/////////////////////////////////////////////////////////////
// THIS IS TEST CODE TO GENERATE BACK TO BACK NOTIFICATIONS
// app.notify({
// "title": "TEST 1",
// "text": "Test 1",
// "icon_url": context.JK.resolveAvatarUrl("")
// });
// app.notify({
// "title": "TEST 2",
// "text": "Test 2",
// "icon_url": context.JK.resolveAvatarUrl("")
// });
// app.notify({
// "title": "TEST 3",
// "text": "Test 3",
// "icon_url": context.JK.resolveAvatarUrl("")
// });
/////////////////////////////////////////////////////////////
$ ( '#sidebar-search-header' ) . hide ( ) ;
var url = "/api/users/" + context . JK . currentUserId + "/friends"
$ . ajax ( {
type : "GET" ,
dataType : "json" ,
contentType : 'application/json' ,
url : url ,
processData : false ,
success : function ( response ) {
friends = response ;
updateFriendList ( response ) ;
// set friend count
$ ( '#sidebar-friend-count' ) . html ( response . length ) ;
} ,
error : app . ajaxError
} ) ;
return false ;
}
function updateFriendList ( response ) {
$ ( '#sidebar-friend-list li:not(.invite-friend-row)' ) . remove ( ) ;
// show online friends first (sort by first name within online/offline groups)
response . sort ( function ( a , b ) {
var a _online = a . online ;
var b _online = b . online ;
var a _firstname = a . first _name . toLowerCase ( ) ;
var b _firstname = b . first _name . toLowerCase ( ) ;
if ( b _online != a _online ) {
if ( b _online < a _online ) return - 1 ;
if ( b _online > a _online ) return 1 ;
return 0 ;
}
if ( a _firstname < b _firstname ) return - 1 ;
if ( a _firstname > b _firstname ) return 1 ;
return 0 ;
} ) ;
$ . each ( response , function ( index , val ) {
var css = val . online ? '' : 'offline' ;
friends [ val . id ] = val ;
// fill in template for Connect pre-click
var template = $ ( '#template-friend-panel' ) . html ( ) ;
var searchResultHtml = context . JK . fillTemplate ( template , {
userId : val . id ,
cssClass : css ,
avatar _url : context . JK . resolveAvatarUrl ( val . photo _url ) ,
2014-03-02 21:44:36 +00:00
userName : val . name . length > 20 ? val . name . substring ( 0 , 20 ) + "..." : val . name ,
2014-02-13 04:40:41 +00:00
status : val . online ? 'Available' : 'Offline' ,
extra _info : '' ,
hoverAction : val . musician ? "musician" : "fan" ,
info _image _url : ''
} ) ;
$ ( '#sidebar-friend-list li.invite-friend-row' ) . before ( searchResultHtml ) ;
} ) ;
context . JK . bindHoverEvents ( ) ;
}
function initializeNotificationsPanel ( ) {
// retrieve pending notifications for this user
var url = "/api/users/" + context . JK . currentUserId + "/notifications"
$ . ajax ( {
type : "GET" ,
dataType : "json" ,
contentType : 'application/json' ,
url : url ,
processData : false ,
success : function ( response ) {
updateNotificationList ( response ) ;
// set notification count
$ ( '#sidebar-notification-count' ) . html ( response . length ) ;
} ,
error : app . ajaxError
} ) ;
}
function updateNotificationList ( response ) {
$ ( '#sidebar-notification-list' ) . empty ( ) ;
$ . each ( response , function ( index , val ) {
2014-03-20 11:53:26 +00:00
if ( val . description == 'TEXT_MESSAGE' ) {
2014-03-21 20:21:03 +00:00
val . formatted _msg = textMessageDialog . formatTextMessage ( val . message . substring ( 0 , 200 ) , val . source _user _id , val . source _user . name , val . message . length > 200 ) . html ( ) ;
2014-03-20 11:53:26 +00:00
}
2014-02-13 04:40:41 +00:00
// fill in template for Connect pre-click
var template = $ ( '#template-notification-panel' ) . html ( ) ;
var notificationHtml = context . JK . fillTemplate ( template , {
notificationId : val . notification _id ,
2014-03-08 00:56:27 +00:00
sessionId : val . session _id ,
2014-02-13 04:40:41 +00:00
avatar _url : context . JK . resolveAvatarUrl ( val . photo _url ) ,
2014-03-21 20:21:03 +00:00
text : val . formatted _msg ,
2014-03-07 06:30:23 +00:00
date : $ . timeago ( val . created _at )
2014-02-13 04:40:41 +00:00
} ) ;
$ ( '#sidebar-notification-list' ) . append ( notificationHtml ) ;
// val.description contains the notification record's description value from the DB (i.e., type)
initializeActions ( val , val . description ) ;
} ) ;
}
function initializeActions ( payload , type ) {
var $notification = $ ( 'li[notification-id=' + payload . notification _id + ']' ) ;
2014-02-23 20:47:53 +00:00
var $btnNotificationAction = '#btn-notification-action' ;
2014-02-13 04:40:41 +00:00
// wire up "x" button to delete notification
$notification . find ( '#img-delete-notification' ) . click ( deleteNotificationHandler ) ;
// customize action buttons based on notification type
if ( type === context . JK . MessageType . FRIEND _REQUEST ) {
2014-02-23 20:47:53 +00:00
var $action _btn = $notification . find ( $btnNotificationAction ) ;
2014-02-13 04:40:41 +00:00
$action _btn . text ( 'ACCEPT' ) ;
$action _btn . click ( function ( ) {
2014-03-07 05:38:10 +00:00
acceptFriendRequest ( payload ) ;
2014-02-13 04:40:41 +00:00
} ) ;
}
else if ( type === context . JK . MessageType . FRIEND _REQUEST _ACCEPTED ) {
$notification . find ( '#div-actions' ) . hide ( ) ;
}
else if ( type === context . JK . MessageType . NEW _USER _FOLLOWER || type === context . JK . MessageType . NEW _BAND _FOLLOWER ) {
$notification . find ( '#div-actions' ) . hide ( ) ;
}
else if ( type === context . JK . MessageType . SESSION _INVITATION ) {
2014-02-23 20:47:53 +00:00
var $action _btn = $notification . find ( $btnNotificationAction ) ;
2014-02-13 04:40:41 +00:00
$action _btn . text ( 'JOIN' ) ;
$action _btn . click ( function ( ) {
2014-03-07 05:38:10 +00:00
openTerms ( payload ) ;
2014-02-13 04:40:41 +00:00
} ) ;
}
else if ( type === context . JK . MessageType . JOIN _REQUEST ) {
2014-02-23 20:47:53 +00:00
var $action _btn = $notification . find ( $btnNotificationAction ) ;
2014-02-13 04:40:41 +00:00
$action _btn . text ( 'APPROVE' ) ;
$action _btn . click ( function ( ) {
2014-03-07 05:38:10 +00:00
approveJoinRequest ( payload ) ;
2014-02-13 04:40:41 +00:00
} ) ;
}
else if ( type === context . JK . MessageType . JOIN _REQUEST _APPROVED ) {
2014-02-23 20:47:53 +00:00
var $action _btn = $notification . find ( $btnNotificationAction ) ;
2014-02-13 04:40:41 +00:00
$action _btn . text ( 'JOIN' ) ;
$action _btn . click ( function ( ) {
2014-03-07 05:38:10 +00:00
openTerms ( payload ) ;
2014-02-13 04:40:41 +00:00
} ) ;
}
else if ( type === context . JK . MessageType . JOIN _REQUEST _REJECTED ) {
$notification . find ( '#div-actions' ) . hide ( ) ;
}
else if ( type === context . JK . MessageType . MUSICIAN _SESSION _JOIN || type === context . JK . MessageType . BAND _SESSION _JOIN ) {
2014-03-07 05:38:10 +00:00
var actionText = '' ;
var callback ;
if ( context . JK . currentUserMusician ) {
// user is MUSICIAN; musician_access = TRUE
if ( payload . musician _access ) {
actionText = "JOIN" ;
callback = joinSession ;
}
// user is MUSICIAN; fan_access = TRUE
else if ( payload . fan _access ) {
actionText = "LISTEN" ;
callback = listenToSession ;
}
}
else {
// user is FAN; fan_access = TRUE
if ( payload . fan _access ) {
actionText = "LISTEN" ;
callback = listenToSession ;
}
}
2014-02-23 20:47:53 +00:00
var $action _btn = $notification . find ( $btnNotificationAction ) ;
2014-03-07 05:38:10 +00:00
$action _btn . text ( actionText ) ;
2014-02-13 04:40:41 +00:00
$action _btn . click ( function ( ) {
2014-03-07 05:38:10 +00:00
callback ( payload ) ;
2014-02-13 04:40:41 +00:00
} ) ;
}
else if ( type === context . JK . MessageType . MUSICIAN _RECORDING _SAVED || type === context . JK . MessageType . BAND _RECORDING _SAVED ) {
2014-02-23 20:47:53 +00:00
var $action _btn = $notification . find ( $btnNotificationAction ) ;
2014-02-13 04:40:41 +00:00
$action _btn . text ( 'LISTEN' ) ;
$action _btn . click ( function ( ) {
2014-03-07 05:38:10 +00:00
listenToRecording ( payload ) ;
2014-02-13 04:40:41 +00:00
} ) ;
}
else if ( type === context . JK . MessageType . RECORDING _MASTER _MIX _COMPLETE ) {
$notification . find ( '#div-actions' ) . hide ( ) ;
context . jamClient . OnDownloadAvailable ( ) ; // poke backend, letting it know a download is available
}
else if ( type === context . JK . MessageType . BAND _INVITATION ) {
2014-02-23 20:47:53 +00:00
var $action _btn = $notification . find ( $btnNotificationAction ) ;
2014-02-13 04:40:41 +00:00
$action _btn . text ( 'ACCEPT' ) ;
$action _btn . click ( function ( ) {
2014-03-07 05:38:10 +00:00
acceptBandInvitation ( payload ) ;
2014-02-13 04:40:41 +00:00
} ) ;
}
else if ( type === context . JK . MessageType . BAND _INVITATION _ACCEPTED ) {
$notification . find ( '#div-actions' ) . hide ( ) ;
}
2014-03-20 11:53:26 +00:00
else if ( type === context . JK . MessageType . TEXT _MESSAGE ) {
var $action _btn = $notification . find ( $btnNotificationAction ) ;
$action _btn . text ( 'REPLY' ) ;
$action _btn . click ( function ( ) {
var userId = $notification . find ( '.more-text-available' ) . attr ( 'data-sender-id' ) ;
app . layout . showDialog ( 'text-message' , { d1 : userId } ) ;
} ) ;
var moreTextLink = $notification . find ( '.more-text-available' ) ;
var textMessage = $notification . find ( '.text-message' ) ;
var clipped _msg = textMessage . attr ( 'data-is-clipped' ) === 'true' ;
if ( clipped _msg ) {
moreTextLink . text ( 'more' ) . show ( ) ;
moreTextLink . click ( function ( e ) {
var userId = $ ( this ) . attr ( 'data-sender-id' ) ;
return false ;
} ) ;
}
else {
moreTextLink . hide ( ) ;
}
}
2014-02-13 04:40:41 +00:00
}
function deleteNotificationHandler ( evt ) {
evt . stopPropagation ( ) ;
var notificationId = $ ( this ) . attr ( 'notification-id' ) ;
deleteNotification ( notificationId ) ;
}
function deleteNotification ( notificationId ) {
var url = "/api/users/" + context . JK . currentUserId + "/notifications/" + notificationId ;
$ . ajax ( {
type : "DELETE" ,
dataType : "json" ,
contentType : 'application/json' ,
url : url ,
processData : false ,
success : function ( response ) {
$ ( 'li[notification-id=' + notificationId + ']' ) . hide ( ) ;
decrementNotificationCount ( ) ;
} ,
error : app . ajaxError
} ) ;
}
function initializeChatPanel ( ) {
}
function search ( query ) {
logger . debug ( 'query=' + query ) ;
if ( query !== '' ) {
context . JK . search ( query , app , context . JK . SearchResultScreen . onSearchSuccess ) ;
}
}
context . JK . Sidebar . getHeight = function ( ) {
// TODO: refactor this - copied from layout.js
var sidebarHeight = $ ( context ) . height ( ) - 75 - 2 * 60 + $ ( '[layout-sidebar-expander]' ) . height ( ) ;
var combinedHeaderHeight = $ ( '[layout-panel="contents"]' ) . length * 36 ;
var searchHeight = $ ( '.sidebar .search' ) . first ( ) . height ( ) ;
var expanderHeight = $ ( '[layout-sidebar-expander]' ) . height ( ) ;
var expandedPanelHeight = sidebarHeight - ( combinedHeaderHeight + expanderHeight + searchHeight ) ;
return expandedPanelHeight ;
}
function showFriendsPanel ( ) {
var $expandedPanelContents = $ ( '[layout-id="panelFriends"] [layout-panel="contents"]' ) ;
var expandedPanelHeight = context . JK . Sidebar . getHeight ( ) ;
// hide all other contents
$ ( '[layout-panel="contents"]' ) . hide ( ) ;
$ ( '[layout-panel="contents"]' ) . css ( { "height" : "1px" } ) ;
// show the appropriate contens
$expandedPanelContents . show ( ) ;
$expandedPanelContents . animate ( { "height" : expandedPanelHeight + "px" } , 400 ) ;
}
function hideSearchResults ( ) {
emptySearchResults ( ) ;
$ ( '#search-input' ) . val ( '' ) ;
$ ( '#sidebar-search-header' ) . hide ( ) ;
showFriendsPanel ( ) ;
}
function emptySearchResults ( ) {
$ ( '#sidebar-search-results' ) . empty ( ) ;
$ ( '#sidebar-search-results' ) . height ( '0px' ) ;
}
function incrementNotificationCount ( ) {
var count = parseInt ( $ ( '#sidebar-notification-count' ) . html ( ) ) ;
$ ( '#sidebar-notification-count' ) . html ( count + 1 ) ;
}
function decrementNotificationCount ( ) {
var count = parseInt ( $ ( '#sidebar-notification-count' ) . html ( ) ) ;
if ( count === 0 ) {
$ ( '#sidebar-notification-count' ) . html ( 0 ) ;
}
else {
$ ( '#sidebar-notification-count' ) . html ( count - 1 ) ;
}
}
// default handler for incoming notification
function handleNotification ( payload , type ) {
2014-03-20 11:53:26 +00:00
// on a load of notifications, it is possible to load a very new notification,
// and get a websocket notification right after for that same notification,
// so we need to protect against such duplicates
if ( $ ( '#sidebar-notification-list' ) . find ( 'li[notification-id="' + payload . notification _id + '"]' ) . length > 0 ) {
return false ;
}
2014-02-13 04:40:41 +00:00
// increment displayed notification count
incrementNotificationCount ( ) ;
// add notification to sidebar
var template = $ ( "#template-notification-panel" ) . html ( ) ;
var notificationHtml = context . JK . fillTemplate ( template , {
2014-03-20 11:53:26 +00:00
notificationId : payload . notification _id ,
2014-02-23 20:47:53 +00:00
sessionId : payload . session _id ,
2014-02-13 04:40:41 +00:00
avatar _url : context . JK . resolveAvatarUrl ( payload . photo _url ) ,
2014-03-20 11:53:26 +00:00
text : payload . msg instanceof jQuery ? payload . msg . html ( ) : payload . msg ,
2014-03-07 06:30:23 +00:00
date : $ . timeago ( payload . created _at )
2014-02-13 04:40:41 +00:00
} ) ;
$ ( '#sidebar-notification-list' ) . prepend ( notificationHtml ) ;
initializeActions ( payload , type ) ;
2014-03-20 11:53:26 +00:00
return true ;
2014-02-13 04:40:41 +00:00
}
var delay = ( function ( ) {
var timer = 0 ;
return function ( callback , ms ) {
clearTimeout ( timer ) ;
timer = setTimeout ( callback , ms ) ;
} ;
} ) ( ) ;
function inviteHoverIn ( ) {
$ ( '.invitation-button-holder' ) . slideDown ( ) ;
}
function inviteHoverOut ( ) {
$ ( '.invitation-button-holder' ) . slideUp ( ) ;
}
function searchForInput ( ) {
var query = $ ( '#search-input' ) . val ( ) ;
// logger.debug("query=" + query);
if ( query === '' ) {
return hideSearchResults ( ) ;
}
if ( query . length > 2 ) {
// FIXME: this is in searchResults
$ ( '#query' ) . html ( query ) ;
query += '&search_text_type=' + $ ( '#search_text_type' ) . val ( ) ;
emptySearchResults ( ) ;
search ( query ) ;
}
}
function events ( ) {
$ ( '#search-input' ) . keyup ( function ( evt ) {
delay ( function ( ) {
// ENTER KEY
if ( evt . which === 13 ) {
return hideSearchResults ( ) ;
}
// ESCAPE KEY
if ( evt . which === 27 ) {
return hideSearchResults ( ) ;
}
searchForInput ( ) ;
} , 500 ) ;
} ) ;
$ ( '#sidebar-search-expand' ) . click ( function ( evt ) {
$ ( '#searchForm' ) . submit ( ) ;
hideSearchResults ( ) ;
} ) ;
$ ( '.sidebar .invite-friend-row' ) . hoverIntent ( inviteHoverIn , inviteHoverOut ) ;
// friend notifications
registerFriendUpdate ( ) ;
registerFriendRequest ( ) ;
registerFriendRequestAccepted ( ) ;
registerNewUserFollower ( ) ;
registerNewBandFollower ( ) ;
// session invitations
registerSessionInvitation ( ) ;
registerSessionEnded ( ) ;
registerJoinRequest ( ) ;
registerJoinRequestApproved ( ) ;
registerJoinRequestRejected ( ) ;
registerSessionJoin ( ) ;
registerSessionDepart ( ) ;
registerMusicianSessionJoin ( ) ;
registerBandSessionJoin ( ) ;
// recording notifications
registerMusicianRecordingSaved ( ) ;
registerBandRecordingSaved ( ) ;
registerRecordingStarted ( ) ;
registerRecordingEnded ( ) ;
registerRecordingMasterMixComplete ( ) ;
// band notifications
registerBandInvitation ( ) ;
registerBandInvitationAccepted ( ) ;
// broadcast notifications
registerSourceUpRequested ( ) ;
registerSourceDownRequested ( ) ;
registerSourceUp ( ) ;
registerSourceDown ( ) ;
2014-03-20 11:53:26 +00:00
// register text messages
registerTextMessage ( ) ;
2014-02-13 04:40:41 +00:00
// watch for Invite More Users events
$ ( '#sidebar-div .btn-email-invitation' ) . click ( function ( ) {
invitationDialog . showEmailDialog ( ) ;
return false ;
} ) ;
$ ( '#sidebar-div .btn-gmail-invitation' ) . click ( function ( ) {
invitationDialog . showGoogleDialog ( ) ;
return false ;
} ) ;
$ ( '#sidebar-div .btn-facebook-invitation' ) . click ( function ( evt ) {
invitationDialog . showFacebookDialog ( evt ) ;
return false ;
} ) ;
}
function registerFriendUpdate ( ) {
context . JK . JamServer . registerMessageCallback ( context . JK . MessageType . FRIEND _UPDATE , function ( header , payload ) {
logger . debug ( "Handling FRIEND_UPDATE msg " + JSON . stringify ( payload ) ) ;
friends [ payload . user _id ] . online = payload . online ;
updateFriendList ( friends ) ;
var online _text = payload . online ? "online" : "offline" ;
app . notify ( {
"title" : "Friend is now " + online _text ,
"text" : payload . msg ,
"icon_url" : context . JK . resolveAvatarUrl ( payload . photo _url )
} ) ;
} ) ;
}
function registerFriendRequest ( ) {
context . JK . JamServer . registerMessageCallback ( context . JK . MessageType . FRIEND _REQUEST , function ( header , payload ) {
logger . debug ( "Handling FRIEND_REQUEST msg " + JSON . stringify ( payload ) ) ;
handleNotification ( payload , header . type ) ;
app . notify ( {
"title" : "New Friend Request" ,
"text" : payload . msg ,
"icon_url" : context . JK . resolveAvatarUrl ( payload . photo _url )
} , {
"ok_text" : "ACCEPT" ,
"ok_callback" : acceptFriendRequest ,
"ok_callback_args" : { "friend_request_id" : payload . friend _request _id , "notification_id" : payload . notification _id }
2013-10-16 07:23:43 +00:00
} ) ;
2014-02-13 04:40:41 +00:00
} ) ;
}
function acceptFriendRequest ( args ) {
rest . acceptFriendRequest ( {
2014-03-08 06:37:25 +00:00
status : 'accept' ,
friend _request _id : args . friend _request _id
2014-02-13 04:40:41 +00:00
} ) . done ( function ( response ) {
deleteNotification ( args . notification _id ) ; // delete notification corresponding to this friend request
initializeFriendsPanel ( ) ; // refresh friends panel when request is accepted
} ) . error ( app . ajaxError ) ;
}
function registerFriendRequestAccepted ( ) {
context . JK . JamServer . registerMessageCallback ( context . JK . MessageType . FRIEND _REQUEST _ACCEPTED , function ( header , payload ) {
logger . debug ( "Handling FRIEND_REQUEST_ACCEPTED msg " + JSON . stringify ( payload ) ) ;
handleNotification ( payload , header . type ) ;
initializeFriendsPanel ( ) ;
app . notify ( {
"title" : "Friend Request Accepted" ,
"text" : payload . msg ,
"icon_url" : context . JK . resolveAvatarUrl ( payload . photo _url )
} ) ;
} ) ;
}
function registerNewUserFollower ( ) {
context . JK . JamServer . registerMessageCallback ( context . JK . MessageType . NEW _USER _FOLLOWER , function ( header , payload ) {
logger . debug ( "Handling NEW_USER_FOLLOWER msg " + JSON . stringify ( payload ) ) ;
handleNotification ( payload , header . type ) ;
app . notify ( {
"title" : "New Follower" ,
"text" : payload . msg ,
"icon_url" : context . JK . resolveAvatarUrl ( payload . photo _url )
} ) ;
} ) ;
}
function registerNewBandFollower ( ) {
context . JK . JamServer . registerMessageCallback ( context . JK . MessageType . NEW _BAND _FOLLOWER , function ( header , payload ) {
logger . debug ( "Handling NEW_BAND_FOLLOWER msg " + JSON . stringify ( payload ) ) ;
handleNotification ( payload , header . type ) ;
app . notify ( {
"title" : "New Band Follower" ,
"text" : payload . msg ,
"icon_url" : context . JK . resolveAvatarUrl ( payload . photo _url )
} ) ;
} ) ;
}
function registerSessionInvitation ( ) {
context . JK . JamServer . registerMessageCallback ( context . JK . MessageType . SESSION _INVITATION , function ( header , payload ) {
logger . debug ( "Handling SESSION_INVITATION msg " + JSON . stringify ( payload ) ) ;
handleNotification ( payload , header . type ) ;
var participants = [ ] ;
rest . getSession ( payload . session _id ) . done ( function ( response ) {
$ . each ( response . participants , function ( index , val ) {
2014-02-23 18:31:18 +00:00
participants . push ( { "photo_url" : context . JK . resolveAvatarUrl ( val . user . photo _url ) , "name" : val . user . name } ) ;
2014-02-13 04:40:41 +00:00
} ) ;
2013-12-29 04:51:35 +00:00
2014-03-01 23:01:45 +00:00
var participantHtml = "You have been invited to join a session with: <br/><br/>" ;
participantHtml += "<table><tbody>" ;
2013-12-29 04:51:35 +00:00
2014-03-01 23:01:45 +00:00
$ . each ( participants , function ( index , val ) {
if ( index < 4 ) {
participantHtml += "<tr><td><img class='avatar-small' src='" + context . JK . resolveAvatarUrl ( val . photo _url ) + "' /></td><td>" + val . name + "</td></tr>" ;
}
} ) ;
2013-12-29 04:51:35 +00:00
2014-03-01 23:01:45 +00:00
participantHtml += "</tbody></table>" ;
app . notify ( {
"title" : "Session Invitation" ,
"text" : participantHtml
} , {
"ok_text" : "JOIN SESSION" ,
"ok_callback" : openTerms ,
"ok_callback_args" : { "session_id" : payload . session _id , "notification_id" : payload . notification _id }
} ) ;
} ) . error ( app . ajaxError ) ;
2014-01-05 21:42:18 +00:00
2014-02-13 04:40:41 +00:00
} ) ;
}
2013-03-10 01:57:09 +00:00
2014-02-13 04:40:41 +00:00
function openTerms ( args ) {
var termsDialog = new context . JK . TermsDialog ( app , args , onTermsAccepted ) ;
termsDialog . initialize ( ) ;
app . layout . showDialog ( 'terms' ) ;
}
2013-07-13 04:15:47 +00:00
2014-02-13 04:40:41 +00:00
function onTermsAccepted ( args ) {
deleteNotification ( args . notification _id ) ;
context . location = '/client#/session/' + args . session _id ;
}
2013-09-25 15:34:53 +00:00
2014-02-13 04:40:41 +00:00
function registerSessionEnded ( ) {
// TODO: this should clean up all notifications related to this session
2014-02-23 20:47:53 +00:00
context . JK . JamServer . registerMessageCallback ( context . JK . MessageType . SESSION _ENDED , function ( header , payload ) {
logger . debug ( "Handling SESSION_ENDED msg " + JSON . stringify ( payload ) ) ;
deleteSessionNotifications ( payload . session _id ) ;
} ) ;
}
// remove all notifications for this session
function deleteSessionNotifications ( sessionId ) {
$ ( 'li[session-id=' + sessionId + ']' ) . hide ( ) ;
decrementNotificationCount ( ) ;
2014-02-13 04:40:41 +00:00
}
2013-03-31 13:54:00 +00:00
2014-02-13 04:40:41 +00:00
function registerJoinRequest ( ) {
context . JK . JamServer . registerMessageCallback ( context . JK . MessageType . JOIN _REQUEST , function ( header , payload ) {
logger . debug ( "Handling JOIN_REQUEST msg " + JSON . stringify ( payload ) ) ;
2013-10-16 07:23:43 +00:00
2014-02-13 04:40:41 +00:00
handleNotification ( payload , header . type ) ;
2014-01-30 01:55:16 +00:00
2014-02-13 04:40:41 +00:00
app . notify ( {
"title" : "New Join Request" ,
2013-03-31 13:54:00 +00:00
"text" : payload . msg ,
2013-07-09 03:06:01 +00:00
"icon_url" : context . JK . resolveAvatarUrl ( payload . photo _url )
2014-02-13 04:40:41 +00:00
} , {
"ok_text" : "APPROVE" ,
"ok_callback" : approveJoinRequest ,
"ok_callback_args" : { "join_request_id" : payload . join _request _id , "notification_id" : payload . notification _id } ,
"cancel_text" : "REJECT" ,
"cancel_callback" : rejectJoinRequest ,
"cancel_callback_args" : { "join_request_id" : payload . join _request _id , "notification_id" : payload . notification _id }
2013-03-31 13:54:00 +00:00
} ) ;
2014-02-13 04:40:41 +00:00
} ) ;
}
function approveJoinRequest ( args ) {
rest . updateJoinRequest ( args . join _request _id , true )
. done ( function ( response ) {
deleteNotification ( args . notification _id ) ;
} ) . error ( app . ajaxError ) ;
}
function rejectJoinRequest ( args ) {
rest . updateJoinRequest ( args . join _request _id , false )
. done ( function ( response ) {
deleteNotification ( args . notification _id ) ;
} ) . error ( app . ajaxError ) ;
}
function registerJoinRequestApproved ( ) {
context . JK . JamServer . registerMessageCallback ( context . JK . MessageType . JOIN _REQUEST _APPROVED , function ( header , payload ) {
logger . debug ( "Handling JOIN_REQUEST_APPROVED msg " + JSON . stringify ( payload ) ) ;
handleNotification ( payload , header . type ) ;
app . notify ( {
"title" : "Join Request Approved" ,
2013-04-14 02:59:43 +00:00
"text" : payload . msg ,
2013-07-09 03:06:01 +00:00
"icon_url" : context . JK . resolveAvatarUrl ( payload . photo _url )
2014-02-13 04:40:41 +00:00
} , {
"ok_text" : "JOIN SESSION" ,
"ok_callback" : openTerms ,
"ok_callback_args" : { "session_id" : payload . session _id , "notification_id" : payload . notification _id }
} ) ;
} ) ;
}
function registerJoinRequestRejected ( ) {
context . JK . JamServer . registerMessageCallback ( context . JK . MessageType . JOIN _REQUEST _REJECTED , function ( header , payload ) {
logger . debug ( "Handling JOIN_REQUEST_REJECTED msg " + JSON . stringify ( payload ) ) ;
handleNotification ( payload , header . type ) ;
app . notify ( {
"title" : "Join Request Rejected" ,
"text" : payload . msg ,
"icon_url" : context . JK . resolveAvatarUrl ( payload . photo _url )
} ) ;
} ) ;
}
function registerSessionJoin ( ) {
context . JK . JamServer . registerMessageCallback ( context . JK . MessageType . SESSION _JOIN , function ( header , payload ) {
logger . debug ( "Handling SESSION_JOIN msg " + JSON . stringify ( payload ) ) ;
// display notification
app . notify ( {
"title" : "New Session Participant" ,
"text" : payload . msg ,
"icon_url" : context . JK . resolveAvatarUrl ( payload . photo _url )
} ) ;
} ) ;
}
function registerSessionDepart ( ) {
context . JK . JamServer . registerMessageCallback ( context . JK . MessageType . SESSION _DEPART , function ( header , payload ) {
logger . debug ( "Handling SESSION_DEPART msg " + JSON . stringify ( payload ) ) ;
var recordingId = payload . recording _id ;
2014-02-23 20:47:53 +00:00
if ( recordingId && context . JK . CurrentSessionModel . recordingModel . isRecording ( recordingId ) ) {
2014-02-13 04:40:41 +00:00
context . JK . CurrentSessionModel . recordingModel . onServerStopRecording ( recordingId ) ;
}
else {
app . notify ( {
"title" : "Musician Left Session" ,
"text" : payload . msg ,
"icon_url" : context . JK . resolveAvatarUrl ( payload . photo _url )
2013-11-26 07:47:56 +00:00
} ) ;
2014-02-13 04:40:41 +00:00
}
} ) ;
}
function registerMusicianSessionJoin ( ) {
context . JK . JamServer . registerMessageCallback ( context . JK . MessageType . MUSICIAN _SESSION _JOIN , function ( header , payload ) {
logger . debug ( "Handling MUSICIAN_SESSION_JOIN msg " + JSON . stringify ( payload ) ) ;
2014-03-07 05:38:10 +00:00
var okText = '' ;
var showNotification = false ;
var callback ;
if ( context . JK . currentUserMusician ) {
// user is MUSICIAN; musician_access = TRUE
if ( payload . musician _access ) {
showNotification = true ;
okText = "JOIN" ;
callback = joinSession ;
}
// user is MUSICIAN; fan_access = TRUE
else if ( payload . fan _access ) {
showNotification = true ;
okText = "LISTEN" ;
callback = listenToSession ;
}
}
else {
// user is FAN; fan_access = TRUE
if ( payload . fan _access ) {
showNotification = true ;
okText = "LISTEN" ;
callback = listenToSession ;
}
}
2014-02-13 04:40:41 +00:00
2014-03-07 05:38:10 +00:00
if ( showNotification ) {
handleNotification ( payload , header . type ) ;
app . notify ( {
"title" : "Musician Joined Session" ,
"text" : payload . msg ,
"icon_url" : context . JK . resolveAvatarUrl ( payload . photo _url )
} , {
"ok_text" : okText ,
"ok_callback" : callback ,
"ok_callback_args" : {
"session_id" : payload . session _id ,
"fan_access" : payload . fan _access ,
"musician_access" : payload . musician _access ,
"approval_required" : payload . approval _required ,
"notification_id" : payload . notification _id
}
2014-02-13 04:40:41 +00:00
}
2014-03-07 05:38:10 +00:00
) ;
}
2014-02-13 04:40:41 +00:00
} ) ;
}
function registerBandSessionJoin ( ) {
context . JK . JamServer . registerMessageCallback ( context . JK . MessageType . BAND _SESSION _JOIN , function ( header , payload ) {
logger . debug ( "Handling BAND_SESSION_JOIN msg " + JSON . stringify ( payload ) ) ;
2014-03-07 05:38:10 +00:00
var okText = '' ;
var showNotification = false ;
var callback ;
if ( context . JK . currentUserMusician ) {
// user is MUSICIAN; musician_access = TRUE
if ( payload . musician _access ) {
showNotification = true ;
okText = "JOIN" ;
callback = joinSession ;
}
// user is MUSICIAN; fan_access = TRUE
else if ( payload . fan _access ) {
showNotification = true ;
okText = "LISTEN" ;
callback = listenToSession ;
}
}
else {
// user is FAN; fan_access = TRUE
if ( payload . fan _access ) {
showNotification = true ;
okText = "LISTEN" ;
callback = listenToSession ;
}
}
2014-02-13 04:40:41 +00:00
2014-03-07 05:38:10 +00:00
if ( showNotification ) {
handleNotification ( payload , header . type ) ;
app . notify ( {
"title" : "Band Joined Session" ,
"text" : payload . msg ,
"icon_url" : context . JK . resolveAvatarUrl ( payload . photo _url )
} , {
"ok_text" : "LISTEN" ,
"ok_callback" : callback ,
"ok_callback_args" : {
"session_id" : payload . session _id ,
"fan_access" : payload . fan _access ,
"musician_access" : payload . musician _access ,
"approval_required" : payload . approval _required ,
"notification_id" : payload . notification _id
}
2014-02-13 04:40:41 +00:00
}
2014-03-07 05:38:10 +00:00
) ;
}
2014-02-13 04:40:41 +00:00
} ) ;
}
2013-06-26 03:12:01 +00:00
2014-02-13 04:40:41 +00:00
function listenToSession ( args ) {
deleteNotification ( args . notification _id ) ;
2014-02-28 02:32:55 +00:00
context . JK . popExternalLink ( '/sessions/' + args . session _id ) ;
2014-02-13 04:40:41 +00:00
}
2013-06-26 03:12:01 +00:00
2014-03-07 05:38:10 +00:00
/*********** TODO: THE NEXT 3 FUNCTIONS ARE COPIED FROM sessionList.js. REFACTOR TO COMMON PLACE. *************/
function joinSession ( args ) {
// NOTE: invited musicians get their own notification, so no need to check if user has invitation here
// like other places because an invited user would never get this notification
if ( args . musician _access ) {
if ( args . approval _required ) {
openAlert ( args . session _id ) ;
}
else {
openTerms ( args ) ;
}
}
deleteNotification ( args . notification _id ) ;
}
function openAlert ( sessionId ) {
var alertDialog = new context . JK . AlertDialog ( context . JK . app , "YES" ,
"You must be approved to join this session. Would you like to send a request to join?" ,
sessionId , onCreateJoinRequest ) ;
alertDialog . initialize ( ) ;
context . JK . app . layout . showDialog ( 'alert' ) ;
}
function onCreateJoinRequest ( sessionId ) {
var joinRequest = { } ;
joinRequest . music _session = sessionId ;
joinRequest . user = context . JK . currentUserId ;
rest . createJoinRequest ( joinRequest )
. done ( function ( response ) {
} ) . error ( context . JK . app . ajaxError ) ;
context . JK . app . layout . closeDialog ( 'alert' ) ;
}
//////////////////////////////////////////////////////////////////////////////////////////
2014-02-13 04:40:41 +00:00
function registerMusicianRecordingSaved ( ) {
context . JK . JamServer . registerMessageCallback ( context . JK . MessageType . MUSICIAN _RECORDING _SAVED , function ( header , payload ) {
logger . debug ( "Handling MUSICIAN_RECORDING_SAVED msg " + JSON . stringify ( payload ) ) ;
2013-12-29 04:51:35 +00:00
2014-02-13 04:40:41 +00:00
handleNotification ( payload , header . type ) ;
2013-06-26 03:12:01 +00:00
2014-02-13 04:40:41 +00:00
app . notify ( {
"title" : "Musician Recording Saved" ,
2013-12-29 04:51:35 +00:00
"text" : payload . msg ,
2013-07-09 03:06:01 +00:00
"icon_url" : context . JK . resolveAvatarUrl ( payload . photo _url )
2014-02-13 04:40:41 +00:00
} , {
"ok_text" : "LISTEN" ,
"ok_callback" : listenToRecording ,
"ok_callback_args" : {
2014-02-23 20:47:53 +00:00
"recording_id" : payload . recording _id ,
"notification_id" : payload . notification _id
2014-02-13 04:40:41 +00:00
}
2013-06-26 03:12:01 +00:00
} ) ;
2014-02-13 04:40:41 +00:00
} ) ;
}
2013-06-26 03:12:01 +00:00
2014-02-13 04:40:41 +00:00
function registerBandRecordingSaved ( ) {
context . JK . JamServer . registerMessageCallback ( context . JK . MessageType . BAND _RECORDING _SAVED , function ( header , payload ) {
logger . debug ( "Handling BAND_RECORDING_SAVED msg " + JSON . stringify ( payload ) ) ;
2013-06-26 03:12:01 +00:00
2014-02-13 04:40:41 +00:00
handleNotification ( payload , header . type ) ;
app . notify ( {
"title" : "Band Recording Saved" ,
2013-12-29 04:51:35 +00:00
"text" : payload . msg ,
2013-07-09 03:06:01 +00:00
"icon_url" : context . JK . resolveAvatarUrl ( payload . photo _url )
2014-02-13 04:40:41 +00:00
} , {
"ok_text" : "LISTEN" ,
"ok_callback" : listenToRecording ,
"ok_callback_args" : {
2014-02-23 20:47:53 +00:00
"recording_id" : payload . recording _id ,
"notification_id" : payload . notification _id
2014-02-13 04:40:41 +00:00
}
2013-06-26 03:12:01 +00:00
} ) ;
2014-02-13 04:40:41 +00:00
} ) ;
}
2013-10-16 07:23:43 +00:00
2014-02-13 04:40:41 +00:00
function listenToRecording ( args ) {
deleteNotification ( args . notification _id ) ;
2014-02-23 20:47:53 +00:00
context . JK . popExternalLink ( '/recordings/' + args . recording _id ) ;
2014-02-13 04:40:41 +00:00
}
2013-10-16 07:23:43 +00:00
2014-02-13 04:40:41 +00:00
function registerRecordingStarted ( ) {
context . JK . JamServer . registerMessageCallback ( context . JK . MessageType . RECORDING _STARTED , function ( header , payload ) {
logger . debug ( "Handling RECORDING_STARTED msg " + JSON . stringify ( payload ) ) ;
2013-10-16 07:23:43 +00:00
2014-02-13 04:40:41 +00:00
app . notify ( {
"title" : "Recording Started" ,
2013-10-16 07:23:43 +00:00
"text" : payload . msg ,
"icon_url" : context . JK . resolveAvatarUrl ( payload . photo _url )
} ) ;
2014-02-13 04:40:41 +00:00
} ) ;
}
2013-03-04 03:38:12 +00:00
2014-02-13 04:40:41 +00:00
function registerRecordingEnded ( ) {
context . JK . JamServer . registerMessageCallback ( context . JK . MessageType . RECORDING _ENDED , function ( header , payload ) {
logger . debug ( "Handling RECORDING_ENDED msg " + JSON . stringify ( payload ) ) ;
2013-12-29 04:51:35 +00:00
2014-02-13 04:40:41 +00:00
app . notify ( {
"title" : "Recording Ended" ,
2014-01-02 19:57:16 +00:00
"text" : payload . msg ,
2013-12-29 04:51:35 +00:00
"icon_url" : context . JK . resolveAvatarUrl ( payload . photo _url )
} ) ;
2014-02-13 04:40:41 +00:00
} ) ;
}
2013-12-29 04:51:35 +00:00
2014-02-13 04:40:41 +00:00
function registerRecordingMasterMixComplete ( ) {
context . JK . JamServer . registerMessageCallback ( context . JK . MessageType . RECORDING _MASTER _MIX _COMPLETE , function ( header , payload ) {
logger . debug ( "Handling RECORDING_MASTER_MIX_COMPLETE msg " + JSON . stringify ( payload ) ) ;
2013-12-29 04:51:35 +00:00
2014-02-13 04:40:41 +00:00
handleNotification ( payload , header . type ) ;
2014-01-04 22:02:47 +00:00
2014-02-13 04:40:41 +00:00
app . notify ( {
"title" : "Recording Master Mix Complete" ,
2014-01-04 22:02:47 +00:00
"text" : payload . msg ,
"icon_url" : context . JK . resolveAvatarUrl ( payload . photo _url )
} , {
2014-02-13 04:40:41 +00:00
"ok_text" : "SHARE" ,
"ok_callback" : shareRecording ,
"ok_callback_args" : {
"recording_id" : payload . recording _id
}
} ) ;
} ) ;
}
2013-11-26 07:47:56 +00:00
2014-02-13 04:40:41 +00:00
function shareRecording ( args ) {
var recordingId = args . recording _id ;
}
2013-11-26 07:47:56 +00:00
2014-02-13 04:40:41 +00:00
function registerBandInvitation ( ) {
context . JK . JamServer . registerMessageCallback ( context . JK . MessageType . BAND _INVITATION , function ( header , payload ) {
logger . debug ( "Handling BAND_INVITATION msg " + JSON . stringify ( payload ) ) ;
2013-11-26 07:47:56 +00:00
2014-02-13 04:40:41 +00:00
handleNotification ( payload , header . type ) ;
2013-11-26 07:47:56 +00:00
2014-02-13 04:40:41 +00:00
app . notify ( {
"title" : "Band Invitation" ,
2013-11-26 07:47:56 +00:00
"text" : payload . msg ,
"icon_url" : context . JK . resolveAvatarUrl ( payload . photo _url )
2014-02-13 04:40:41 +00:00
} , {
"ok_text" : "ACCEPT" ,
"ok_callback" : acceptBandInvitation ,
"ok_callback_args" : {
"band_invitation_id" : payload . band _invitation _id ,
"band_id" : payload . band _id ,
"notification_id" : payload . notification _id
}
2013-11-26 07:47:56 +00:00
} ) ;
2014-02-13 04:40:41 +00:00
} ) ;
}
function acceptBandInvitation ( args ) {
rest . updateBandInvitation (
args . band _id ,
args . band _invitation _id ,
true
2014-03-20 11:53:26 +00:00
) . done ( function ( response ) {
2014-02-13 04:40:41 +00:00
deleteNotification ( args . notification _id ) ; // delete notification corresponding to this friend request
2014-03-20 11:53:26 +00:00
} ) . error ( app . ajaxError ) ;
}
function registerTextMessage ( ) {
context . JK . JamServer . registerMessageCallback ( context . JK . MessageType . TEXT _MESSAGE , function ( header , payload ) {
logger . debug ( "Handling TEXT_MESSAGE msg " + JSON . stringify ( payload ) ) ;
textMessageDialog . messageReceived ( payload ) ;
handleNotification ( payload , header . type ) ;
} ) ;
2014-02-13 04:40:41 +00:00
}
function registerBandInvitationAccepted ( ) {
context . JK . JamServer . registerMessageCallback ( context . JK . MessageType . BAND _INVITATION _ACCEPTED , function ( header , payload ) {
logger . debug ( "Handling BAND_INVITATION_ACCEPTED msg " + JSON . stringify ( payload ) ) ;
handleNotification ( payload , header . type ) ;
app . notify ( {
"title" : "Band Invitation Accepted" ,
"text" : payload . msg ,
"icon_url" : context . JK . resolveAvatarUrl ( payload . photo _url )
} ) ;
} ) ;
}
function registerSourceUpRequested ( ) {
context . JK . JamServer . registerMessageCallback ( context . JK . MessageType . SOURCE _UP _REQUESTED , function ( header , payload ) {
logger . debug ( "Handling SOURCE_UP_REQUESTED msg " + JSON . stringify ( payload ) ) ;
var current _session _id = context . JK . CurrentSessionModel . id ( ) ;
if ( ! current _session _id ) {
// we are not in a session
var last _session = context . JK . CurrentSessionModel . getCurrentOrLastSession ( ) ;
if ( last _session && last _session . id == payload . music _session ) {
// the last session we were in was responsible for this message. not that odd at all
logger . debug ( "SOURCE_UP_REQUESTED came in for session_id" + payload . music _session + ", but was dropped because we have left that session" )
}
else {
// this means we aren't in a session, and, what's worse,
// the last session we were in does not match the specified music_session id
throw "SOURCE_UP_REQUESTED came in for session_id:" + payload . music _session + ", but we are not in a session and the last session ID did not match the one specified" ;
}
}
else {
// we are in a session
if ( current _session _id == payload . music _session ) {
context . jamClient . SessionLiveBroadcastStart ( payload . host , payload . port , payload . mount ,
payload . source _user , payload . source _pass ,
'' , payload . bitrate )
}
else {
2014-01-25 23:38:03 +00:00
var last _session = context . JK . CurrentSessionModel . getCurrentOrLastSession ( ) ;
if ( last _session && last _session . id == payload . music _session ) {
// the last session we were in was responsible for this message. not that odd at all
2014-02-13 04:40:41 +00:00
logger . debug ( "SOURCE_UP_REQUESTED came in for session_id" + payload . music _session + ", but was dropped because we have left that session and are in a new one" )
2014-01-25 23:38:03 +00:00
}
else {
// this means we aren't in a session, and, what's worse,
// the last session we were in does not match the specified music_session id
2014-02-13 04:40:41 +00:00
throw "SOURCE_UP_REQUESTED came in for session_id:" + payload . music _session + ", but we are in a session and the last session ID did not match the one specified" ;
2014-01-25 23:38:03 +00:00
}
}
2014-02-13 04:40:41 +00:00
}
} ) ;
}
function registerSourceDownRequested ( ) {
context . JK . JamServer . registerMessageCallback ( context . JK . MessageType . SOURCE _DOWN _REQUESTED , function ( header , payload ) {
logger . debug ( "Handling SOURCE_DOWN_REQUESTED msg " + JSON . stringify ( payload ) ) ;
var current _session _id = context . JK . CurrentSessionModel . id ( ) ;
if ( ! current _session _id ) {
// we are not in a session
var last _session = context . JK . CurrentSessionModel . getCurrentOrLastSession ( ) ;
if ( last _session && last _session . id == payload . music _session ) {
// the last session we were in was responsible for this message. not that odd at all
logger . debug ( "SOURCE_DOWN_REQUESTED came in for session_id" + payload . music _session + ", but was dropped because we have left that session" )
}
2014-01-25 23:38:03 +00:00
else {
2014-02-13 04:40:41 +00:00
// this means we aren't in a session, and, what's worse,
// the last session we were in does not match the specified music_session id
throw "SOURCE_DOWN_REQUESTED came in for session_id:" + payload . music _session + ", but we are not in a session and the last session ID did not match the one specified" ;
2014-01-25 23:38:03 +00:00
}
2014-02-13 04:40:41 +00:00
}
else {
// we are in a session
if ( current _session _id == payload . music _session ) {
context . jamClient . SessionLiveBroadcastStop ( ) ;
}
else {
2014-01-25 23:38:03 +00:00
var last _session = context . JK . CurrentSessionModel . getCurrentOrLastSession ( ) ;
if ( last _session && last _session . id == payload . music _session ) {
// the last session we were in was responsible for this message. not that odd at all
2014-02-13 04:40:41 +00:00
logger . debug ( "SOURCE_DOWN_REQUESTED came in for session_id" + payload . music _session + ", but was dropped because we have left that session and are in a new one" )
2014-01-25 23:38:03 +00:00
}
else {
// this means we aren't in a session, and, what's worse,
// the last session we were in does not match the specified music_session id
2014-02-13 04:40:41 +00:00
throw "SOURCE_DOWN_REQUESTED came in for session_id:" + payload . music _session + ", but we are in a session and the last session ID did not match the one specified" ;
2014-01-25 23:38:03 +00:00
}
}
2014-02-13 04:40:41 +00:00
}
} ) ;
}
function registerSourceUp ( ) {
context . JK . JamServer . registerMessageCallback ( context . JK . MessageType . SOURCE _UP , function ( header , payload ) {
logger . debug ( "Handling SOURCE_UP msg " + JSON . stringify ( payload ) ) ;
logger . debug ( "session %o is now being broadcasted" , payload . music _session ) ;
app . notify ( {
"title" : "Now Broadcasting" ,
"text" : "This session is now being broadcasted."
} ) ;
} ) ;
}
function registerSourceDown ( ) {
context . JK . JamServer . registerMessageCallback ( context . JK . MessageType . SOURCE _DOWN , function ( header , payload ) {
logger . debug ( "Handling SOURCE_DOWN msg " + JSON . stringify ( payload ) ) ;
logger . debug ( "session %o is no longer being broadcasted" , payload . music _session ) ;
app . notify ( {
"title" : "No Longer Broadcasting" ,
"text" : "This session is no longer being broadcasted."
} ) ;
} ) ;
}
2014-03-20 11:53:26 +00:00
this . initialize = function ( invitationDialogInstance , textMessageDialogInstance ) {
2014-01-25 23:38:03 +00:00
events ( ) ;
2014-02-13 04:40:41 +00:00
initializeSearchPanel ( ) ;
2014-01-25 23:38:03 +00:00
initializeFriendsPanel ( ) ;
initializeChatPanel ( ) ;
initializeNotificationsPanel ( ) ;
invitationDialog = invitationDialogInstance ;
2014-03-20 11:53:26 +00:00
textMessageDialog = textMessageDialogInstance ;
2014-02-13 04:40:41 +00:00
} ;
}
2013-03-04 03:38:12 +00:00
} ) ( window , jQuery ) ;