2013-03-04 03:38:12 +00:00
|
|
|
(function(context,$) {
|
|
|
|
|
|
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
|
|
context.JK = context.JK || {};
|
|
|
|
|
context.JK.Sidebar = function(app) {
|
|
|
|
|
var logger = context.JK.logger;
|
2013-03-31 13:54:00 +00:00
|
|
|
var friends = [];
|
2013-09-27 21:39:51 +00:00
|
|
|
var rest = context.JK.Rest();
|
2013-10-21 22:13:53 +00:00
|
|
|
var invitationDialog = null;
|
2013-03-04 03:38:12 +00:00
|
|
|
|
2013-03-10 03:00:34 +00:00
|
|
|
function initializeFriendsPanel() {
|
2013-03-04 03:38:12 +00:00
|
|
|
|
2013-08-10 17:37:09 +00:00
|
|
|
/////////////////////////////////////////////////////////////
|
2013-08-07 03:18:32 +00:00
|
|
|
// THIS IS TEST CODE TO GENERATE BACK TO BACK NOTIFICATIONS
|
2013-08-10 17:37:09 +00:00
|
|
|
// 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("")
|
|
|
|
|
// });
|
|
|
|
|
/////////////////////////////////////////////////////////////
|
2013-08-07 03:18:32 +00:00
|
|
|
|
2013-03-10 01:57:09 +00:00
|
|
|
$('#sidebar-search-header').hide();
|
|
|
|
|
|
2013-03-04 03:38:12 +00:00
|
|
|
var url = "/api/users/" + context.JK.currentUserId + "/friends"
|
|
|
|
|
$.ajax({
|
|
|
|
|
type: "GET",
|
|
|
|
|
dataType: "json",
|
|
|
|
|
contentType: 'application/json',
|
|
|
|
|
url: url,
|
|
|
|
|
processData: false,
|
|
|
|
|
success: function(response) {
|
2013-03-10 01:57:09 +00:00
|
|
|
|
2013-03-31 13:54:00 +00:00
|
|
|
friends = response;
|
|
|
|
|
updateFriendList(response);
|
2013-03-10 01:57:09 +00:00
|
|
|
|
2013-03-31 13:54:00 +00:00
|
|
|
// set friend count
|
|
|
|
|
$('#sidebar-friend-count').html(response.length);
|
|
|
|
|
},
|
|
|
|
|
error: app.ajaxError
|
|
|
|
|
});
|
2013-03-10 01:57:09 +00:00
|
|
|
|
2013-03-31 13:54:00 +00:00
|
|
|
return false;
|
|
|
|
|
}
|
2013-03-10 01:57:09 +00:00
|
|
|
|
2013-03-31 13:54:00 +00:00
|
|
|
function updateFriendList(response) {
|
2013-10-15 02:25:15 +00:00
|
|
|
$('#sidebar-friend-list li:not(.invite-friend-row)').remove();
|
2013-03-10 01:57:09 +00:00
|
|
|
|
2013-03-31 13:54:00 +00:00
|
|
|
// show online friends first (sort by first name within online/offline groups)
|
|
|
|
|
response.sort(function(a, b) {
|
2013-03-04 03:38:12 +00:00
|
|
|
|
2013-03-31 13:54:00 +00:00
|
|
|
var a_online = a.online;
|
|
|
|
|
var b_online = b.online;
|
2013-03-04 03:38:12 +00:00
|
|
|
|
2013-03-31 13:54:00 +00:00
|
|
|
var a_firstname = a.first_name.toLowerCase();
|
|
|
|
|
var b_firstname = b.first_name.toLowerCase();
|
2013-03-04 03:38:12 +00:00
|
|
|
|
2013-03-31 13:54:00 +00:00
|
|
|
if (b_online != a_online) {
|
|
|
|
|
if (b_online < a_online) return -1;
|
|
|
|
|
if (b_online > a_online) return 1;
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
2013-03-04 03:38:12 +00:00
|
|
|
|
2013-03-31 13:54:00 +00:00
|
|
|
if (a_firstname < b_firstname) return -1;
|
|
|
|
|
if (a_firstname > b_firstname) return 1;
|
|
|
|
|
return 0;
|
2013-03-04 03:38:12 +00:00
|
|
|
});
|
|
|
|
|
|
2013-03-31 13:54:00 +00:00
|
|
|
$.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),
|
|
|
|
|
userName: val.name,
|
|
|
|
|
status: val.online ? 'Available' : 'Offline',
|
|
|
|
|
extra_info: '',
|
|
|
|
|
info_image_url: ''
|
|
|
|
|
});
|
|
|
|
|
|
2013-09-25 15:46:00 +00:00
|
|
|
$('#sidebar-friend-list li.invite-friend-row').before(searchResultHtml);
|
2013-03-31 13:54:00 +00:00
|
|
|
});
|
2013-03-04 03:38:12 +00:00
|
|
|
}
|
|
|
|
|
|
2013-03-10 03:00:34 +00:00
|
|
|
function initializeNotificationsPanel() {
|
2013-04-05 03:51:01 +00:00
|
|
|
// 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) {
|
2013-10-05 14:33:51 +00:00
|
|
|
|
2013-04-05 03:51:01 +00:00
|
|
|
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) {
|
|
|
|
|
|
|
|
|
|
// fill in template for Connect pre-click
|
|
|
|
|
var template = $('#template-notification-panel').html();
|
|
|
|
|
var notificationHtml = context.JK.fillTemplate(template, {
|
2013-04-14 02:59:43 +00:00
|
|
|
notificationId: val.notification_id,
|
2013-04-05 03:51:01 +00:00
|
|
|
avatar_url: context.JK.resolveAvatarUrl(val.photo_url),
|
|
|
|
|
text: val.formatted_msg,
|
2013-08-01 05:16:32 +00:00
|
|
|
date: context.JK.formatDate(val.created_at)
|
2013-04-05 03:51:01 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$('#sidebar-notification-list').append(notificationHtml);
|
2013-04-07 01:41:43 +00:00
|
|
|
|
2013-10-03 07:16:27 +00:00
|
|
|
// val.description contains the notification record's description value from the DB (i.e., type)
|
2013-04-14 02:59:43 +00:00
|
|
|
initializeActions(val, val.description);
|
2013-04-05 03:51:01 +00:00
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2013-10-03 07:16:27 +00:00
|
|
|
function initializeActions(payload, type) {
|
2013-04-14 17:24:38 +00:00
|
|
|
|
2013-10-05 13:04:07 +00:00
|
|
|
var $notification = $('li[notification-id=' + payload.notification_id + ']');
|
|
|
|
|
|
|
|
|
|
// wire up "x" button to delete notification
|
|
|
|
|
$notification.find('#img-delete-notification').click(deleteNotificationHandler);
|
2013-10-16 07:23:43 +00:00
|
|
|
|
|
|
|
|
// customize action buttons based on notification type
|
2013-06-26 03:12:01 +00:00
|
|
|
if (type === context.JK.MessageType.FRIEND_REQUEST) {
|
2013-10-05 14:33:51 +00:00
|
|
|
var $action_btn = $notification.find('#btn-notification-action');
|
2013-04-14 02:59:43 +00:00
|
|
|
$action_btn.text('ACCEPT');
|
|
|
|
|
$action_btn.click(function() {
|
2013-10-03 07:16:27 +00:00
|
|
|
acceptFriendRequest({ "friend_request_id": payload.friend_request_id, "notification_id": payload.notification_id });
|
2013-04-14 02:59:43 +00:00
|
|
|
});
|
|
|
|
|
}
|
2013-12-29 04:51:35 +00:00
|
|
|
|
2013-06-26 03:12:01 +00:00
|
|
|
else if (type === context.JK.MessageType.FRIEND_REQUEST_ACCEPTED) {
|
2013-10-05 13:04:07 +00:00
|
|
|
$notification.find('#div-actions').hide();
|
2013-10-03 07:16:27 +00:00
|
|
|
}
|
2013-12-29 04:51:35 +00:00
|
|
|
|
2013-12-29 19:40:21 +00:00
|
|
|
else if (type === context.JK.MessageType.NEW_USER_FOLLOWER || type === context.JK.MessageType.NEW_BAND_FOLLOWER) {
|
|
|
|
|
$notification.find('#div-actions').hide();
|
|
|
|
|
}
|
|
|
|
|
|
2013-10-03 07:16:27 +00:00
|
|
|
else if (type === context.JK.MessageType.SESSION_INVITATION) {
|
2013-10-05 13:04:07 +00:00
|
|
|
var $action_btn = $notification.find('#btn-notification-action');
|
2013-10-03 07:16:27 +00:00
|
|
|
$action_btn.text('JOIN');
|
|
|
|
|
$action_btn.click(function() {
|
2013-10-16 07:23:43 +00:00
|
|
|
openTerms({ "session_id": payload.session_id, "notification_id": payload.notification_id });
|
|
|
|
|
});
|
|
|
|
|
}
|
2013-12-29 04:51:35 +00:00
|
|
|
|
2013-10-16 07:23:43 +00:00
|
|
|
else if (type === context.JK.MessageType.JOIN_REQUEST) {
|
|
|
|
|
var $action_btn = $notification.find('#btn-notification-action');
|
|
|
|
|
$action_btn.text('APPROVE');
|
|
|
|
|
$action_btn.click(function() {
|
|
|
|
|
approveJoinRequest({ "join_request_id": payload.join_request_id, "notification_id": payload.notification_id });
|
|
|
|
|
});
|
|
|
|
|
}
|
2013-12-29 04:51:35 +00:00
|
|
|
|
2013-10-16 07:23:43 +00:00
|
|
|
else if (type === context.JK.MessageType.JOIN_REQUEST_APPROVED) {
|
|
|
|
|
var $action_btn = $notification.find('#btn-notification-action');
|
|
|
|
|
$action_btn.text('JOIN');
|
|
|
|
|
$action_btn.click(function() {
|
|
|
|
|
openTerms({ "session_id": payload.session_id, "notification_id": payload.notification_id });
|
2013-10-03 07:16:27 +00:00
|
|
|
});
|
2013-04-14 12:45:13 +00:00
|
|
|
}
|
2013-12-29 04:51:35 +00:00
|
|
|
|
2013-10-16 07:23:43 +00:00
|
|
|
else if (type === context.JK.MessageType.JOIN_REQUEST_REJECTED) {
|
|
|
|
|
$notification.find('#div-actions').hide();
|
|
|
|
|
}
|
2013-12-29 04:51:35 +00:00
|
|
|
|
2013-11-26 07:47:56 +00:00
|
|
|
else if (type === context.JK.MessageType.BAND_INVITATION) {
|
|
|
|
|
var $action_btn = $notification.find('#btn-notification-action');
|
|
|
|
|
$action_btn.text('ACCEPT');
|
|
|
|
|
$action_btn.click(function() {
|
|
|
|
|
acceptBandInvitation({ "band_invitation_id": payload.band_invitation_id, "band_id": payload.band_id, "notification_id": payload.notification_id });
|
|
|
|
|
});
|
|
|
|
|
}
|
2013-12-29 04:51:35 +00:00
|
|
|
|
2013-11-26 07:47:56 +00:00
|
|
|
else if (type === context.JK.MessageType.BAND_INVITATION_ACCEPTED) {
|
|
|
|
|
$notification.find('#div-actions').hide();
|
|
|
|
|
}
|
2013-04-14 02:59:43 +00:00
|
|
|
}
|
|
|
|
|
|
2013-04-14 17:24:38 +00:00
|
|
|
function deleteNotificationHandler(evt) {
|
2013-04-07 01:41:43 +00:00
|
|
|
evt.stopPropagation();
|
|
|
|
|
var notificationId = $(this).attr('notification-id');
|
2013-04-14 17:24:38 +00:00
|
|
|
deleteNotification(notificationId);
|
|
|
|
|
}
|
2013-04-07 01:41:43 +00:00
|
|
|
|
2013-04-14 17:24:38 +00:00
|
|
|
function deleteNotification(notificationId) {
|
2013-04-07 01:41:43 +00:00
|
|
|
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
|
|
|
|
|
});
|
2013-03-10 03:00:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function initializeChatPanel() {
|
|
|
|
|
}
|
|
|
|
|
|
2013-03-10 01:57:09 +00:00
|
|
|
function search(query) {
|
|
|
|
|
|
|
|
|
|
logger.debug('query=' + query);
|
|
|
|
|
if (query !== '') {
|
2013-03-15 05:18:16 +00:00
|
|
|
context.JK.search(query, app, onSearchSuccess);
|
|
|
|
|
}
|
|
|
|
|
}
|
2013-03-10 01:57:09 +00:00
|
|
|
|
2013-03-15 05:18:16 +00:00
|
|
|
function onSearchSuccess(response) {
|
|
|
|
|
|
2013-04-17 04:46:43 +00:00
|
|
|
// TODO: generalize this for each search result type (band, musician, recordings, et. al.)
|
|
|
|
|
$.each(response.musicians, function(index, val) {
|
2013-03-15 05:18:16 +00:00
|
|
|
// fill in template for Connect pre-click
|
|
|
|
|
var template = $('#template-sidebar-search-result').html();
|
|
|
|
|
var searchResultHtml = context.JK.fillTemplate(template, {
|
|
|
|
|
userId: val.id,
|
|
|
|
|
avatar_url: context.JK.resolveAvatarUrl(val.photo_url),
|
2013-04-28 19:09:30 +00:00
|
|
|
profile_url: "/#/profile/" + val.id,
|
2013-03-15 05:18:16 +00:00
|
|
|
userName: val.name,
|
|
|
|
|
location: val.location
|
2013-03-10 01:57:09 +00:00
|
|
|
});
|
2013-03-15 05:18:16 +00:00
|
|
|
|
|
|
|
|
$('#sidebar-search-results').append(searchResultHtml);
|
|
|
|
|
|
|
|
|
|
// fill in template for Connect post-click
|
|
|
|
|
template = $('#template-sidebar-invitation-sent').html();
|
|
|
|
|
var invitationSentHtml = context.JK.fillTemplate(template, {
|
|
|
|
|
userId: val.id,
|
|
|
|
|
first_name: val.first_name,
|
2013-04-28 19:09:30 +00:00
|
|
|
profile_url: "/#/profile/" + val.id
|
2013-03-15 05:18:16 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$('#sidebar-search-results').append(invitationSentHtml);
|
|
|
|
|
|
|
|
|
|
// initialize visibility of the divs
|
|
|
|
|
$('div[layout=sidebar] div[user-id=' + val.id + '].sidebar-search-connected').hide();
|
|
|
|
|
$('div[layout=sidebar] div[user-id=' + val.id + '].sidebar-search-result').show();
|
|
|
|
|
|
2013-04-22 02:22:03 +00:00
|
|
|
// wire up button click handler if search result is not a friend or the current user
|
2013-10-05 14:33:51 +00:00
|
|
|
var $sidebar = $('div[layout=sidebar] div[user-id=' + val.id + ']');
|
2013-04-22 02:22:03 +00:00
|
|
|
if (!val.is_friend && val.id !== context.JK.currentUserId) {
|
2013-10-05 14:33:51 +00:00
|
|
|
$sidebar.find('.btn-connect-friend').click(sendFriendRequest);
|
2013-04-07 00:42:18 +00:00
|
|
|
}
|
|
|
|
|
// hide the button if the search result is already a friend
|
|
|
|
|
else {
|
2013-10-05 14:33:51 +00:00
|
|
|
$sidebar.find('.btn-connect-friend').hide();
|
2013-04-07 00:42:18 +00:00
|
|
|
}
|
2013-03-15 05:18:16 +00:00
|
|
|
});
|
|
|
|
|
|
2013-03-22 00:17:28 +00:00
|
|
|
// show header
|
2013-03-15 05:18:16 +00:00
|
|
|
$('#sidebar-search-header').show();
|
2013-03-10 01:57:09 +00:00
|
|
|
|
2013-03-22 00:17:28 +00:00
|
|
|
// hide panels
|
2013-03-10 01:57:09 +00:00
|
|
|
$('[layout-panel="contents"]').hide();
|
|
|
|
|
$('[layout-panel="contents"]').css({"height": "1px"});
|
2013-03-22 00:17:28 +00:00
|
|
|
|
|
|
|
|
// resize search results area
|
|
|
|
|
$('#sidebar-search-results').height(getHeight() + 'px');
|
2013-03-10 01:57:09 +00:00
|
|
|
}
|
|
|
|
|
|
2013-03-10 04:28:21 +00:00
|
|
|
function getHeight() {
|
|
|
|
|
// 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 = 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);
|
|
|
|
|
}
|
|
|
|
|
|
2013-04-07 01:04:18 +00:00
|
|
|
function friendRequestCallback(userId) {
|
|
|
|
|
// toggle the pre-click and post-click divs
|
|
|
|
|
$('div[layout=sidebar] div[user-id=' + userId + '].sidebar-search-connected').show();
|
|
|
|
|
$('div[layout=sidebar] div[user-id=' + userId + '].sidebar-search-result').hide();
|
|
|
|
|
}
|
|
|
|
|
|
2013-03-04 03:38:12 +00:00
|
|
|
function sendFriendRequest(evt) {
|
|
|
|
|
evt.stopPropagation();
|
|
|
|
|
var userId = $(this).parent().attr('user-id');
|
2013-04-07 01:04:18 +00:00
|
|
|
context.JK.sendFriendRequest(app, userId, friendRequestCallback);
|
2013-03-04 03:38:12 +00:00
|
|
|
}
|
|
|
|
|
|
2013-03-10 01:57:09 +00:00
|
|
|
function hideSearchResults() {
|
|
|
|
|
emptySearchResults();
|
|
|
|
|
$('#search-input').val('');
|
|
|
|
|
$('#sidebar-search-header').hide();
|
2013-03-10 04:28:21 +00:00
|
|
|
showFriendsPanel();
|
2013-03-10 01:57:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function emptySearchResults() {
|
|
|
|
|
$('#sidebar-search-results').empty();
|
2013-03-10 04:28:21 +00:00
|
|
|
$('#sidebar-search-results').height('0px');
|
2013-03-10 01:57:09 +00:00
|
|
|
}
|
|
|
|
|
|
2013-04-07 00:23:39 +00:00
|
|
|
function incrementNotificationCount() {
|
|
|
|
|
var count = parseInt($('#sidebar-notification-count').html());
|
|
|
|
|
$('#sidebar-notification-count').html(count + 1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function decrementNotificationCount() {
|
|
|
|
|
var count = parseInt($('#sidebar-notification-count').html());
|
2013-10-03 07:16:27 +00:00
|
|
|
if (count === 0) {
|
|
|
|
|
$('#sidebar-notification-count').html(0);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
$('#sidebar-notification-count').html(count - 1);
|
|
|
|
|
}
|
2013-04-07 00:23:39 +00:00
|
|
|
}
|
|
|
|
|
|
2013-04-14 02:59:43 +00:00
|
|
|
// default handler for incoming notification
|
|
|
|
|
function handleNotification(payload, type) {
|
2013-10-03 07:16:27 +00:00
|
|
|
var sidebarText;
|
2014-01-02 19:57:16 +00:00
|
|
|
sidebarText = payload.msg;
|
2013-04-14 02:59:43 +00:00
|
|
|
|
2013-11-26 07:47:56 +00:00
|
|
|
// increment displayed notification count
|
2013-04-14 02:59:43 +00:00
|
|
|
incrementNotificationCount();
|
|
|
|
|
|
2013-11-26 07:47:56 +00:00
|
|
|
// add notification to sidebar
|
2013-04-14 02:59:43 +00:00
|
|
|
var template = $("#template-notification-panel").html();
|
|
|
|
|
var notificationHtml = context.JK.fillTemplate(template, {
|
|
|
|
|
notificationId: payload.notification_id,
|
|
|
|
|
avatar_url: context.JK.resolveAvatarUrl(payload.photo_url),
|
2013-10-03 07:16:27 +00:00
|
|
|
text: sidebarText,
|
2013-08-01 05:16:32 +00:00
|
|
|
date: context.JK.formatDate(payload.created_at)
|
2013-04-14 02:59:43 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$('#sidebar-notification-list').prepend(notificationHtml);
|
|
|
|
|
|
|
|
|
|
initializeActions(payload, type);
|
|
|
|
|
}
|
|
|
|
|
|
2013-07-13 04:15:47 +00:00
|
|
|
var delay = (function(){
|
|
|
|
|
var timer = 0;
|
|
|
|
|
return function(callback, ms) {
|
|
|
|
|
clearTimeout(timer);
|
|
|
|
|
timer = setTimeout(callback, ms);
|
|
|
|
|
};
|
|
|
|
|
})();
|
|
|
|
|
|
2013-09-25 15:34:53 +00:00
|
|
|
|
|
|
|
|
function inviteHoverIn() {
|
2013-09-25 15:56:22 +00:00
|
|
|
$('.invitation-button-holder').slideDown();
|
2013-09-25 15:34:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function inviteHoverOut() {
|
2013-09-25 15:56:22 +00:00
|
|
|
$('.invitation-button-holder').slideUp();
|
2013-09-25 15:34:53 +00:00
|
|
|
}
|
|
|
|
|
|
2013-03-04 03:38:12 +00:00
|
|
|
function events() {
|
2013-03-10 01:57:09 +00:00
|
|
|
$('#search-input').keyup(function(evt) {
|
2013-07-13 04:15:47 +00:00
|
|
|
delay(function() {
|
|
|
|
|
// ENTER KEY
|
|
|
|
|
if (evt.which === 13) {
|
|
|
|
|
return hideSearchResults();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ESCAPE KEY
|
|
|
|
|
if (evt.which === 27) {
|
|
|
|
|
return hideSearchResults();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var query = $('#search-input').val();
|
|
|
|
|
logger.debug("query=" + query);
|
|
|
|
|
|
|
|
|
|
if (query === '') {
|
|
|
|
|
return hideSearchResults();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (query.length > 2) {
|
|
|
|
|
emptySearchResults();
|
|
|
|
|
search(query);
|
|
|
|
|
}
|
|
|
|
|
}, 1000);
|
2013-03-10 01:57:09 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$('#sidebar-search-expand').click(function(evt) {
|
|
|
|
|
$('#searchForm').submit();
|
|
|
|
|
hideSearchResults();
|
|
|
|
|
});
|
2013-03-31 13:54:00 +00:00
|
|
|
|
2013-09-25 15:56:22 +00:00
|
|
|
$('.sidebar .invite-friend-row').hoverIntent(inviteHoverIn, inviteHoverOut);
|
|
|
|
|
|
2013-12-29 04:51:35 +00:00
|
|
|
// friend notifications
|
2013-10-16 07:23:43 +00:00
|
|
|
registerFriendUpdate();
|
|
|
|
|
registerFriendRequest();
|
|
|
|
|
registerFriendRequestAccepted();
|
2013-12-29 04:51:35 +00:00
|
|
|
registerNewUserFollower();
|
|
|
|
|
registerNewBandFollower();
|
|
|
|
|
|
|
|
|
|
// session invitations
|
2013-10-16 07:23:43 +00:00
|
|
|
registerSessionInvitation();
|
2013-12-29 04:51:35 +00:00
|
|
|
registerSessionEnded();
|
2013-10-16 07:23:43 +00:00
|
|
|
registerJoinRequest();
|
|
|
|
|
registerJoinRequestApproved();
|
|
|
|
|
registerJoinRequestRejected();
|
2014-01-02 19:57:16 +00:00
|
|
|
registerSessionJoin();
|
|
|
|
|
registerSessionDepart();
|
2013-12-29 04:51:35 +00:00
|
|
|
registerMusicianSessionJoin();
|
2014-01-04 22:02:47 +00:00
|
|
|
registerBandSessionJoin();
|
2013-12-29 04:51:35 +00:00
|
|
|
|
|
|
|
|
// recording notifications
|
|
|
|
|
registerMusicianRecordingSaved();
|
|
|
|
|
registerBandRecordingSaved();
|
|
|
|
|
registerRecordingStarted();
|
|
|
|
|
registerRecordingEnded();
|
|
|
|
|
registerRecordingMasterMixComplete();
|
|
|
|
|
|
|
|
|
|
// band notifications
|
2013-11-26 07:47:56 +00:00
|
|
|
registerBandInvitation();
|
|
|
|
|
registerBandInvitationAccepted();
|
2013-06-24 23:41:29 +00:00
|
|
|
|
2013-10-16 07:23:43 +00:00
|
|
|
// watch for Invite More Users events
|
|
|
|
|
$('#sidebar-div .btn-email-invitation').click(function() {
|
|
|
|
|
invitationDialog.showEmailDialog();
|
2013-10-21 22:13:53 +00:00
|
|
|
return false;
|
2013-10-16 07:23:43 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$('#sidebar-div .btn-gmail-invitation').click(function() {
|
|
|
|
|
invitationDialog.showGoogleDialog();
|
2013-10-21 22:13:53 +00:00
|
|
|
return false;
|
2013-10-16 07:23:43 +00:00
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function registerFriendUpdate() {
|
2013-03-31 13:54:00 +00:00
|
|
|
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,
|
2013-07-09 03:06:01 +00:00
|
|
|
"icon_url": context.JK.resolveAvatarUrl(payload.photo_url)
|
2013-03-31 13:54:00 +00:00
|
|
|
});
|
|
|
|
|
});
|
2013-10-16 07:23:43 +00:00
|
|
|
}
|
2013-03-31 13:54:00 +00:00
|
|
|
|
2013-10-16 07:23:43 +00:00
|
|
|
function registerFriendRequest() {
|
2013-03-31 13:54:00 +00:00
|
|
|
context.JK.JamServer.registerMessageCallback(context.JK.MessageType.FRIEND_REQUEST, function(header, payload) {
|
|
|
|
|
logger.debug("Handling FRIEND_REQUEST msg " + JSON.stringify(payload));
|
|
|
|
|
|
2013-04-14 02:59:43 +00:00
|
|
|
handleNotification(payload, header.type);
|
2013-04-05 03:51:01 +00:00
|
|
|
|
2013-04-14 02:59:43 +00:00
|
|
|
app.notify({
|
|
|
|
|
"title": "New Friend Request",
|
|
|
|
|
"text": payload.msg,
|
2013-07-09 03:06:01 +00:00
|
|
|
"icon_url": context.JK.resolveAvatarUrl(payload.photo_url)
|
2013-11-26 07:47:56 +00:00
|
|
|
}, {
|
2013-04-14 02:59:43 +00:00
|
|
|
"ok_text": "ACCEPT",
|
|
|
|
|
"ok_callback": acceptFriendRequest,
|
2013-04-14 17:24:38 +00:00
|
|
|
"ok_callback_args": { "friend_request_id": payload.friend_request_id, "notification_id": payload.notification_id }
|
2013-11-26 07:47:56 +00:00
|
|
|
});
|
2013-04-14 02:59:43 +00:00
|
|
|
});
|
2013-10-16 07:23:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function acceptFriendRequest(args) {
|
|
|
|
|
|
|
|
|
|
rest.acceptFriendRequest({
|
|
|
|
|
status : 'accept',
|
|
|
|
|
friend_request_id : args.friend_request_id
|
|
|
|
|
}).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);
|
|
|
|
|
}
|
2013-04-05 03:51:01 +00:00
|
|
|
|
2013-10-16 07:23:43 +00:00
|
|
|
function registerFriendRequestAccepted() {
|
2013-04-14 02:59:43 +00:00
|
|
|
context.JK.JamServer.registerMessageCallback(context.JK.MessageType.FRIEND_REQUEST_ACCEPTED, function(header, payload) {
|
|
|
|
|
logger.debug("Handling FRIEND_REQUEST_ACCEPTED msg " + JSON.stringify(payload));
|
2013-04-05 03:51:01 +00:00
|
|
|
|
2013-04-14 02:59:43 +00:00
|
|
|
handleNotification(payload, header.type);
|
|
|
|
|
|
|
|
|
|
initializeFriendsPanel();
|
2013-03-31 13:54:00 +00:00
|
|
|
|
|
|
|
|
app.notify({
|
2013-04-14 02:59:43 +00:00
|
|
|
"title": "Friend Request Accepted",
|
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)
|
2013-03-31 13:54:00 +00:00
|
|
|
});
|
|
|
|
|
});
|
2013-10-16 07:23:43 +00:00
|
|
|
}
|
2013-06-26 03:12:01 +00:00
|
|
|
|
2013-12-29 04:51:35 +00:00
|
|
|
function registerNewUserFollower() {
|
2013-06-26 03:12:01 +00:00
|
|
|
|
2013-12-29 04:51:35 +00:00
|
|
|
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)
|
|
|
|
|
});
|
2013-06-26 03:12:01 +00:00
|
|
|
});
|
2013-10-16 07:23:43 +00:00
|
|
|
}
|
2013-06-26 03:12:01 +00:00
|
|
|
|
2013-12-29 04:51:35 +00:00
|
|
|
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);
|
2013-06-26 03:12:01 +00:00
|
|
|
|
|
|
|
|
app.notify({
|
2013-12-29 04:51:35 +00:00
|
|
|
"title": "New Band Follower",
|
|
|
|
|
"text": payload.msg,
|
2013-07-09 03:06:01 +00:00
|
|
|
"icon_url": context.JK.resolveAvatarUrl(payload.photo_url)
|
2013-06-26 03:12:01 +00:00
|
|
|
});
|
|
|
|
|
});
|
2013-12-29 04:51:35 +00:00
|
|
|
|
2013-10-16 07:23:43 +00:00
|
|
|
}
|
2013-10-03 07:16:27 +00:00
|
|
|
|
2013-10-16 07:23:43 +00:00
|
|
|
function registerSessionInvitation() {
|
2013-10-03 07:16:27 +00:00
|
|
|
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) {
|
|
|
|
|
logger.debug(val.user.photo_url + "," + val.user.name);
|
|
|
|
|
participants.push({"photo_url": val.user.photo_url, "name": val.user.name});
|
|
|
|
|
});
|
|
|
|
|
}).error(app.ajaxError);
|
|
|
|
|
|
|
|
|
|
var participantHtml = "You have been invited to join a session with: <br/><br/>";
|
2013-10-03 12:51:25 +00:00
|
|
|
participantHtml += "<table><tbody>";
|
2013-10-03 07:16:27 +00:00
|
|
|
|
|
|
|
|
$.each(participants, function(index, val) {
|
2013-10-05 13:04:07 +00:00
|
|
|
if (index < 4) {
|
2013-10-03 12:51:25 +00:00
|
|
|
participantHtml += "<tr><td><img class='avatar-small' src='" + val.photo_url + "' /></td><td>" + val.name + "</td></tr>";
|
2013-10-05 13:04:07 +00:00
|
|
|
}
|
2013-10-03 07:16:27 +00:00
|
|
|
});
|
|
|
|
|
|
2013-10-03 12:51:25 +00:00
|
|
|
participantHtml += "</tbody></table>";
|
|
|
|
|
|
2013-10-03 07:16:27 +00:00
|
|
|
app.notify({
|
|
|
|
|
"title": "Session Invitation",
|
|
|
|
|
"text": participantHtml
|
2013-11-26 07:47:56 +00:00
|
|
|
}, {
|
2013-10-03 07:16:27 +00:00
|
|
|
"ok_text": "JOIN SESSION",
|
2013-10-16 07:23:43 +00:00
|
|
|
"ok_callback": openTerms,
|
2013-10-03 07:16:27 +00:00
|
|
|
"ok_callback_args": { "session_id": payload.session_id, "notification_id": payload.notification_id }
|
2013-11-26 07:47:56 +00:00
|
|
|
});
|
2013-10-03 07:16:27 +00:00
|
|
|
});
|
2013-10-16 07:23:43 +00:00
|
|
|
}
|
2013-10-02 21:32:57 +00:00
|
|
|
|
2013-10-16 07:23:43 +00:00
|
|
|
function openTerms(args) {
|
|
|
|
|
var termsDialog = new context.JK.TermsDialog(app, args, onTermsAccepted);
|
|
|
|
|
termsDialog.initialize();
|
|
|
|
|
app.layout.showDialog('terms');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function onTermsAccepted(args) {
|
|
|
|
|
deleteNotification(args.notification_id);
|
|
|
|
|
context.location = '#/session/' + args.session_id;
|
|
|
|
|
}
|
|
|
|
|
|
2013-12-29 04:51:35 +00:00
|
|
|
function registerSessionEnded() {
|
2014-01-04 22:02:47 +00:00
|
|
|
// TODO: this should clean up all notifications related to this session
|
2013-12-29 04:51:35 +00:00
|
|
|
}
|
|
|
|
|
|
2013-10-16 07:23:43 +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));
|
|
|
|
|
|
|
|
|
|
handleNotification(payload, header.type);
|
|
|
|
|
|
|
|
|
|
app.notify({
|
2013-11-26 07:47:56 +00:00
|
|
|
"title": "New Join Request",
|
|
|
|
|
"text": payload.msg,
|
|
|
|
|
"icon_url": context.JK.resolveAvatarUrl(payload.photo_url)
|
|
|
|
|
}, {
|
2013-10-16 07:23:43 +00:00
|
|
|
"ok_text": "APPROVE",
|
|
|
|
|
"ok_callback": approveJoinRequest,
|
2013-10-16 08:07:30 +00:00
|
|
|
"ok_callback_args": { "join_request_id": payload.join_request_id, "notification_id": payload.notification_id },
|
2013-10-16 07:23:43 +00:00
|
|
|
"cancel_text": "REJECT",
|
|
|
|
|
"cancel_callback": rejectJoinRequest,
|
|
|
|
|
"cancel_callback_args": { "join_request_id": payload.join_request_id, "notification_id": payload.notification_id }
|
2013-11-26 07:47:56 +00:00
|
|
|
});
|
2013-10-02 21:32:57 +00:00
|
|
|
});
|
2013-10-16 07:23:43 +00:00
|
|
|
}
|
2013-10-02 21:32:57 +00:00
|
|
|
|
2013-10-16 07:23:43 +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({
|
2013-11-26 07:47:56 +00:00
|
|
|
"title": "Join Request Approved",
|
|
|
|
|
"text": payload.msg,
|
|
|
|
|
"icon_url": context.JK.resolveAvatarUrl(payload.photo_url)
|
|
|
|
|
}, {
|
2013-10-16 07:23:43 +00:00
|
|
|
"ok_text": "JOIN SESSION",
|
|
|
|
|
"ok_callback": openTerms,
|
|
|
|
|
"ok_callback_args": { "session_id": payload.session_id, "notification_id": payload.notification_id }
|
2013-11-26 07:47:56 +00:00
|
|
|
});
|
2013-10-16 07:23:43 +00:00
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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)
|
|
|
|
|
});
|
2013-10-02 21:32:57 +00:00
|
|
|
});
|
2013-03-04 03:38:12 +00:00
|
|
|
}
|
|
|
|
|
|
2014-01-02 19:57:16 +00:00
|
|
|
function registerSessionJoin() {
|
|
|
|
|
context.JK.JamServer.registerMessageCallback(context.JK.MessageType.SESSION_JOIN, function(header, payload) {
|
|
|
|
|
logger.debug("Handling SESSION_JOIN msg " + JSON.stringify(payload));
|
2013-12-29 04:51:35 +00:00
|
|
|
|
|
|
|
|
// display notification
|
|
|
|
|
app.notify({
|
2014-01-02 19:57:16 +00:00
|
|
|
"title": "New Session Participant",
|
|
|
|
|
"text": payload.msg,
|
2013-12-29 04:51:35 +00:00
|
|
|
"icon_url": context.JK.resolveAvatarUrl(payload.photo_url)
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2014-01-02 19:57:16 +00:00
|
|
|
function registerSessionDepart() {
|
|
|
|
|
context.JK.JamServer.registerMessageCallback(context.JK.MessageType.SESSION_DEPART, function(header, payload) {
|
|
|
|
|
logger.debug("Handling SESSION_DEPART msg " + JSON.stringify(payload));
|
2013-12-29 04:51:35 +00:00
|
|
|
|
2014-01-04 22:02:47 +00:00
|
|
|
var recordingId = payload.recording_id;
|
|
|
|
|
|
|
|
|
|
if(recordingId&& context.JK.CurrentSessionModel.recordingModel.isRecording(recordingId)) {
|
|
|
|
|
context.JK.CurrentSessionModel.recordingModel.onServerStopRecording(recordingId);
|
2013-12-29 04:51:35 +00:00
|
|
|
/**app.notify({
|
|
|
|
|
"title": "Recording Stopped",
|
|
|
|
|
"text": payload.username + " has left the session.",
|
|
|
|
|
"icon_url": context.JK.resolveAvatarUrl(payload.photo_url)
|
|
|
|
|
}); */
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
app.notify({
|
|
|
|
|
"title": "Musician Left Session",
|
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-01-02 19:57:16 +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));
|
|
|
|
|
|
|
|
|
|
handleNotification(payload, header.type);
|
|
|
|
|
|
|
|
|
|
app.notify({
|
|
|
|
|
"title": "Musician Joined Session",
|
|
|
|
|
"text": payload.msg,
|
|
|
|
|
"icon_url": context.JK.resolveAvatarUrl(payload.photo_url)
|
2014-01-04 22:02:47 +00:00
|
|
|
}, {
|
|
|
|
|
"ok_text": "LISTEN",
|
|
|
|
|
"ok_callback": listenToSession,
|
|
|
|
|
"ok_callback_args": {
|
|
|
|
|
"session_id": payload.session_id
|
|
|
|
|
}
|
|
|
|
|
});
|
2014-01-02 19:57:16 +00:00
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2014-01-04 22:02:47 +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));
|
|
|
|
|
|
|
|
|
|
handleNotification(payload, header.type);
|
|
|
|
|
|
|
|
|
|
// TODO: add LISTEN button linking to session
|
|
|
|
|
app.notify({
|
|
|
|
|
"title": "Band Joined Session",
|
|
|
|
|
"text": payload.msg,
|
|
|
|
|
"icon_url": context.JK.resolveAvatarUrl(payload.photo_url)
|
|
|
|
|
}, {
|
|
|
|
|
"ok_text": "LISTEN",
|
|
|
|
|
"ok_callback": listenToSession,
|
|
|
|
|
"ok_callback_args": {
|
|
|
|
|
"session_id": payload.session_id
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function listenToSession(args) {
|
|
|
|
|
var sessionId = args.session_id;
|
|
|
|
|
}
|
|
|
|
|
|
2013-12-29 04:51:35 +00:00
|
|
|
function registerMusicianRecordingSaved() {
|
2014-01-04 22:02:47 +00:00
|
|
|
context.JK.JamServer.registerMessageCallback(context.JK.MessageType.MUSICIAN_RECORDING_SAVED, function(header, payload) {
|
|
|
|
|
logger.debug("Handling MUSICIAN_RECORDING_SAVED msg " + JSON.stringify(payload));
|
|
|
|
|
|
|
|
|
|
handleNotification(payload, header.type);
|
|
|
|
|
|
|
|
|
|
app.notify({
|
|
|
|
|
"title": "Musician Recording Saved",
|
|
|
|
|
"text": payload.msg,
|
|
|
|
|
"icon_url": context.JK.resolveAvatarUrl(payload.photo_url)
|
|
|
|
|
}, {
|
|
|
|
|
"ok_text": "LISTEN",
|
|
|
|
|
"ok_callback": listenToRecording,
|
|
|
|
|
"ok_callback_args": {
|
|
|
|
|
"recording_id": payload.recording_id
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
});
|
2013-12-29 04:51:35 +00:00
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function registerBandRecordingSaved() {
|
2014-01-04 22:02:47 +00:00
|
|
|
context.JK.JamServer.registerMessageCallback(context.JK.MessageType.BAND_RECORDING_SAVED, function(header, payload) {
|
|
|
|
|
logger.debug("Handling BAND_RECORDING_SAVED msg " + JSON.stringify(payload));
|
2013-12-29 04:51:35 +00:00
|
|
|
|
2014-01-04 22:02:47 +00:00
|
|
|
handleNotification(payload, header.type);
|
|
|
|
|
|
|
|
|
|
app.notify({
|
|
|
|
|
"title": "Band Recording Saved",
|
|
|
|
|
"text": payload.msg,
|
|
|
|
|
"icon_url": context.JK.resolveAvatarUrl(payload.photo_url)
|
|
|
|
|
}, {
|
|
|
|
|
"ok_text": "LISTEN",
|
|
|
|
|
"ok_callback": listenToRecording,
|
|
|
|
|
"ok_callback_args": {
|
|
|
|
|
"recording_id": payload.recording_id
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function listenToRecording(args) {
|
|
|
|
|
var recordingId = args.recording_id;
|
2013-12-29 04:51:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function registerRecordingStarted() {
|
2014-01-02 19:57:16 +00:00
|
|
|
context.JK.JamServer.registerMessageCallback(context.JK.MessageType.RECORDING_STARTED, function(header, payload) {
|
|
|
|
|
logger.debug("Handling RECORDING_STARTED msg " + JSON.stringify(payload));
|
2013-12-29 04:51:35 +00:00
|
|
|
|
2014-01-02 19:57:16 +00:00
|
|
|
app.notify({
|
|
|
|
|
"title": "Recording Started",
|
|
|
|
|
"text": payload.msg,
|
|
|
|
|
"icon_url": context.JK.resolveAvatarUrl(payload.photo_url)
|
|
|
|
|
});
|
|
|
|
|
});
|
2013-12-29 04:51:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function registerRecordingEnded() {
|
2014-01-02 19:57:16 +00:00
|
|
|
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-01-02 19:57:16 +00:00
|
|
|
app.notify({
|
|
|
|
|
"title": "Recording Ended",
|
|
|
|
|
"text": payload.msg,
|
|
|
|
|
"icon_url": context.JK.resolveAvatarUrl(payload.photo_url)
|
|
|
|
|
});
|
|
|
|
|
});
|
2013-12-29 04:51:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function registerRecordingMasterMixComplete() {
|
2014-01-04 22:02:47 +00:00
|
|
|
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));
|
|
|
|
|
|
|
|
|
|
handleNotification(payload, header.type);
|
|
|
|
|
|
|
|
|
|
app.notify({
|
|
|
|
|
"title": "Recording Master Mix Complete",
|
|
|
|
|
"text": payload.msg,
|
|
|
|
|
"icon_url": context.JK.resolveAvatarUrl(payload.photo_url)
|
|
|
|
|
}, {
|
|
|
|
|
"ok_text": "SHARE",
|
|
|
|
|
"ok_callback": shareRecording,
|
|
|
|
|
"ok_callback_args": {
|
|
|
|
|
"recording_id": payload.recording_id
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
}
|
2013-12-29 04:51:35 +00:00
|
|
|
|
2014-01-04 22:02:47 +00:00
|
|
|
function shareRecording(args) {
|
|
|
|
|
var recordingId = args.recording_id;
|
2013-12-29 04:51:35 +00:00
|
|
|
}
|
|
|
|
|
|
2013-11-26 07:47:56 +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));
|
|
|
|
|
|
|
|
|
|
handleNotification(payload, header.type);
|
|
|
|
|
|
|
|
|
|
app.notify({
|
|
|
|
|
"title": "Band Invitation",
|
|
|
|
|
"text": payload.msg,
|
|
|
|
|
"icon_url": context.JK.resolveAvatarUrl(payload.photo_url)
|
|
|
|
|
}, {
|
|
|
|
|
"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
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function acceptBandInvitation(args) {
|
|
|
|
|
rest.updateBandInvitation(
|
|
|
|
|
args.band_id,
|
|
|
|
|
args.band_invitation_id,
|
|
|
|
|
true
|
|
|
|
|
).done(function(response) {
|
|
|
|
|
deleteNotification(args.notification_id); // delete notification corresponding to this friend request
|
|
|
|
|
}).error(app.ajaxError);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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)
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2013-10-21 22:13:53 +00:00
|
|
|
this.initialize = function(invitationDialogInstance) {
|
2013-03-04 03:38:12 +00:00
|
|
|
events();
|
2013-03-10 03:00:34 +00:00
|
|
|
initializeFriendsPanel();
|
|
|
|
|
initializeChatPanel();
|
|
|
|
|
initializeNotificationsPanel();
|
2013-10-21 22:13:53 +00:00
|
|
|
invitationDialog = invitationDialogInstance;
|
2013-03-04 03:38:12 +00:00
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
})(window,jQuery);
|