jam-cloud/web/app/assets/javascripts/profile_utils.js

587 lines
18 KiB
JavaScript
Raw Permalink Normal View History

/**
* Common utility functions.
*/
(function (context, $) {
"use strict";
context.JK = context.JK || {};
var profileUtils = {};
context.JK.ProfileUtils = profileUtils;
// genre types
var PROFILE_GENRE_TYPE = 'profile';
var VIRTUAL_BAND_GENRE_TYPE = 'virtual_band';
var TRADITIONAL_BAND_GENRE_TYPE = 'traditional_band';
var PAID_SESSION_GENRE_TYPE = 'paid_sessions';
var FREE_SESSION_GENRE_TYPE = 'free_sessions';
var COWRITING_GENRE_TYPE = 'cowriting';
2015-06-05 22:22:50 +00:00
var NOT_SPECIFIED_TEXT = 'Not specified';
2016-01-13 02:37:00 +00:00
profileUtils.NOT_SPECIFIED_TEXT = NOT_SPECIFIED_TEXT
var proficiencyDescriptionMap = {
"1": "BEGINNER",
"2": "INTERMEDIATE",
"3": "EXPERT"
};
var proficiencyCssMap = {
"1": "proficiency-beginner",
"2": "proficiency-intermediate",
"3": "proficiency-expert"
};
2015-03-23 20:27:36 +00:00
// performance sample types
profileUtils.SAMPLE_TYPES = {
JAMKAZAM: {description: "jamkazam"},
SOUNDCLOUD: {description: "soundcloud"},
YOUTUBE: {description: "youtube"}
};
2015-03-23 20:27:36 +00:00
// online presence types
profileUtils.ONLINE_PRESENCE_TYPES = {
SOUNDCLOUD: {description: "soundcloud"},
REVERBNATION: {description: "reverbnation"},
BANDCAMP: {description: "bandcamp"},
FANDALISM: {description: "fandalism"},
YOUTUBE: {description: "youtube"},
FACEBOOK: {description: "facebook"},
TWITTER: {description: "twitter"}
};
var USER_TYPE = 'JamRuby::User';
profileUtils.skillLevelMap = {
"1": "Amateur",
"2": "Professional"
};
profileUtils.gigMap = {
2016-01-20 11:37:13 +00:00
"": "Not specified",
"0": "0",
"1": "under 10",
"2": "10 to 50",
"3": "50 to 100",
"4": "over 100"
};
profileUtils.studioMap = {
2016-01-20 11:37:13 +00:00
"" : 'Not specified',
"0": "0",
"1": "under 10",
"2": "10 to 50",
"3": "50 to 100",
"4": "over 100"
};
profileUtils.cowritingPurposeMap = {
"1": "just for fun",
"2": "sell music"
};
profileUtils.bandCommitmentMap = {
"1": "infrequent",
"2": "once a week",
"3": "2-3 times a week",
"4": "4+ times a week"
}
function buildGenreList(genres) {
var list = '';
for (var i=0; i < genres.length; i++) {
list = list.concat(genres[i].genre_id);
if (i !== genres.length - 1) {
list = list.concat(', ');
}
}
return list;
}
Squashed commit of the following: commit 30965c6351a4db3897617a0b0d9ae8aabd06d930 Author: Seth Call <sethcall@gmail.com> Date: Tue Sep 15 05:23:27 2015 -0500 * allow jamblaster to fetch http commit 5c8fb6b01ecb11dc0417b3158044da5205759420 Author: Seth Call <sethcall@gmail.com> Date: Fri Sep 11 13:43:07 2015 -0500 * don't issue stop video in session end commit 3e27680ea9fc7161cc23b888a792ed1269bc327c Author: Seth Call <sethcall@gmail.com> Date: Fri Sep 11 13:40:34 2015 -0500 * decommision webcam_viewer in session page commit ac1cc0c8289bd6aefea3ffabbdd6cd9557be8872 Author: Seth Call <sethcall@gmail.com> Date: Thu Sep 10 07:24:42 2015 -0500 * VRFS-3541 - don't use HTML to store data sent to server for genre ID bug in profile commit 004991119a99d7826019c426d75ed1312feaba55 Author: Seth Call <sethcall@gmail.com> Date: Wed Sep 9 15:10:51 2015 -0500 * set 'are you our user' cookie to do better job with ad tracking commit 13a950e65ff0352b05aa8f0646295ed3909a20b2 Author: Seth Call <sethcall@gmail.com> Date: Wed Sep 9 07:58:46 2015 -0500 * align disable vide obutton better commit 9722c6cbc632daa40e06c67611a3a388b078cb82 Author: Seth Call <sethcall@gmail.com> Date: Wed Sep 9 07:45:18 2015 -0500 * whitesapce commit 3976707b14a061371544b4bedb1b991894eb4fb6 Author: Seth Call <sethcall@gmail.com> Date: Wed Sep 9 07:13:51 2015 -0500 * check for video enabled better commit b483dd537f087e29202d0deb6262540ac76014a9 Author: Seth Call <sethcall@gmail.com> Date: Wed Sep 9 07:02:12 2015 -0500 * better text for video test commit a4f465b6d19eabeabe940ddf1992e50d668d1f26 Author: Seth Call <sethcall@gmail.com> Date: Tue Sep 8 20:30:47 2015 -0500 * VRFS-3530, VRFS-3531 - allow user to test and disable video commit ba99f88048dc4e47adc220235d54b74b6f1afaee Author: Seth Call <sethcall@gmail.com> Date: Tue Sep 8 10:05:26 2015 -0500 * VRFS-3534 - fix start recording API signature commit 386ed8144c2d70447ae203c5a5e0b6afad25f654 Author: Seth Call <sethcall@gmail.com> Date: Sun Sep 6 19:03:08 2015 -0500 * VRFS-3528 - make sure open jamtrack dialog passes 'show_purchased_only' commit 6d010a561b389514116b24f9f9789a274659a287 Author: Seth Call <sethcall@gmail.com> Date: Fri Sep 4 20:43:15 2015 -0500 * deal with too-few tracks on landing page, and the 3rd CTA bubble clipping off text commit 0076f0205ab0ce5e8592c4dd7e101d72ca379f2c Author: Seth Call <sethcall@gmail.com> Date: Fri Sep 4 15:00:45 2015 -0500 * VRFS-352 - instrument-centric landing page commit 3ee71634b36d69e93cbf4b6aced2aa726f80b949 Author: Seth Call <sethcall@gmail.com> Date: Wed Sep 2 09:40:06 2015 -0500 * remove test stuff commit d07ac009bf8c51126af9d16ff592e7d547b85de9 Author: Seth Call <sethcall@gmail.com> Date: Tue Sep 1 08:11:35 2015 -0500 * VRFS-3509 - case where no device is configured handled commit 9420cebad48a3e9a854f497f2bf5e7b77cbb91f4 Author: Seth Call <sethcall@gmail.com> Date: Sun Aug 30 05:00:00 2015 -0500 * VRFS-3494 - show popup when video window launches for the 1st time to offer guidance commit c3f81a4d236126d4913da173fd9794cce525a2ce Author: Seth Call <sethcall@gmail.com> Date: Thu Aug 27 10:35:43 2015 -0500 * build bump commit e782d5f9bb31d62c555249466be6f34991f84074 Author: Seth Call <sethcall@gmail.com> Date: Thu Aug 27 09:43:40 2015 -0500 * VRFS-3419 - check better for window opener commit 36b6699cde5adf15d6bbcaf9f4b1442d644c52a4 Author: Seth Call <sethcall@gmail.com> Date: Thu Aug 27 08:12:47 2015 -0500 * validate popup VRFS-3419 commit 8948f0498f79675e9dd9568b82e7480a187dceee Author: Seth Call <sethcall@gmail.com> Date: Thu Aug 27 07:59:21 2015 -0500 * fix changed path commit 2bce35d60402bb06a6773c48323d3973143653e0 Author: Seth Call <sethcall@gmail.com> Date: Wed Aug 26 20:38:34 2015 -0500 * fix jamtrack test commit 63ef63c20daae56ded7367fe7bd7c7209371bacc Author: Seth Call <sethcall@gmail.com> Date: Wed Aug 26 20:34:40 2015 -0500 * fix typo again in webcamViewer. need to go to bed commit 8566cc5bc91bbead2ad3d9a812c28fb992c9ef6d Author: Seth Call <sethcall@gmail.com> Date: Wed Aug 26 20:31:34 2015 -0500 * fix typo added in webcamViewer commit 22ea6e89fdc73f2d1b34faf74ffc7a76b8c9fc99 Author: Seth Call <sethcall@gmail.com> Date: Wed Aug 26 20:26:39 2015 -0500 * VRFS-3488 - jamtrack search by artist and song need to pin to the match, not do a sloppy search commit a4bd28e1687984f35488da7b63e5bf3f5e0d881b Author: Seth Call <sethcall@gmail.com> Date: Wed Aug 26 16:43:34 2015 -0500 VRFS-3474 - watch for USB events and refresh video pages commit d2edfd22c501c4fcd73bee85ce32cfe23bcd703f Author: Seth Call <sethcall@gmail.com> Date: Wed Aug 26 12:01:52 2015 -0500 * VRFS-3467 - previews are 20 seconds long indicator on jamtracks commit defdfa8ce9e109961e2563e848e3fb44fce2b146 Author: Seth Call <sethcall@gmail.com> Date: Wed Aug 26 06:04:53 2015 -0500 * VRFS-3473 - fix 'videoShared' state in webcamViewer commit 090cfa17c0e3bab86f50bad4917b4e3701357166 Merge: 7560b34 818596a Author: Seth Call <sethcall@gmail.com> Date: Tue Aug 25 14:53:35 2015 -0500 Merge branch 'develop' of bitbucket.org:jamkazam/jam-cloud into develop commit 7560b340c777ff9d2c6cefc02fbc9d622df58452 Author: Seth Call <sethcall@gmail.com> Date: Tue Aug 25 14:52:05 2015 -0500 * VRFS-3466 - updated frontend to pass in GUIDs commit 1252dbe1786535982b8cd8336a1f7d5dde6dcb8b Author: Seth Call <sethcall@gmail.com> Date: Tue Aug 25 05:28:15 2015 -0500 * use new bridge calls to handle current FPS and resolution VRFS-3428 commit 818596ae36724d861a9f704d4d6c697b982df34d Author: Jonathan Kolyer <jonathan@jamkazam.com> Date: Tue Aug 25 08:23:52 2015 +0000 VRFS-3451 musician_search verifying instrument and genres inputs commit 6918eaf09573bfe592dd677f89ece86ef29e45f5 Author: Seth Call <sethcall@gmail.com> Date: Mon Aug 24 17:55:06 2015 -0500 more UI tweaks for video settup in account screen VRFS-3428 commit fc69242578f00e99cb83a3432dc0552c3be212c9 Author: Seth Call <sethcall@gmail.com> Date: Mon Aug 24 16:18:31 2015 -0500 * VRFS-3427 - update FTUE to test video, not just audio commit 729974013a242216570536938fb52f74de4387f9 Author: Seth Call <sethcall@gmail.com> Date: Mon Aug 24 16:17:53 2015 -0500 * VRFS-3428 - fix button text commit db1f1d60d5434abad4c112d5bc58e20b05d180f9 Merge: 04825d2 90c8d05 Author: Seth Call <sethcall@gmail.com> Date: Mon Aug 24 15:56:42 2015 -0500 Merge branch 'feature/video_frontend' into develop commit 04825d2659ebbc601069a3a0638aca2ff249ff6c Author: Seth Call <sethcall@gmail.com> Date: Mon Aug 24 15:54:59 2015 -0500 * VRFS-3428 - update how we query backend for frame rates commit 39d0731d7402a05edfe1e891132e118b234b6f1b Author: Seth Call <sethcall@gmail.com> Date: Sat Aug 22 05:44:59 2015 -0500 * VRFS-3456 - remove special chars from search commit 1874720ee87bc4ac0dd4bc48c462469b6ba34fd4 Author: Seth Call <sethcall@gmail.com> Date: Sat Aug 22 05:32:28 2015 -0500 * VRFS-3456 - protect special chars from tsquery commit 29104ff09b0d287b473af65522bd172115b0fd43 Author: Seth Call <sethcall@gmail.com> Date: Fri Aug 21 05:02:48 2015 -0500 * VRFS-3446 - bug fix for no genre specified on join of session; also fix search bar in jamtrack dialog commit 3b6d1febdb7ebd96b7ff3727e3094c6f968a09ea Author: Seth Call <sethcall@gmail.com> Date: Thu Aug 20 15:44:21 2015 -0500 * forget cta image commit 6ac622853c8a9b2c34961e7f922f57450f41c7e4 Author: Seth Call <sethcall@gmail.com> Date: Thu Aug 20 15:02:55 2015 -0500 * VRFS-3449 - a little more tweaking of JamTrack landing page commit d7fcadcd0dd21b24ce1166096a17216fec345fea Author: Seth Call <sethcall@gmail.com> Date: Thu Aug 20 14:49:07 2015 -0500 * VRFS-3450 - fix 'show all tracks' when pagination occurs by not doubleregistering commit e7b50ca4a84de67f0a5519457d93d5729f9c5236 Author: Seth Call <sethcall@gmail.com> Date: Thu Aug 20 14:19:07 2015 -0500 * VRFS-3449 - updates for direct landing pages commit 0d075a9568685aea40fdfe1106cf6332073d2494 Author: Seth Call <sethcall@gmail.com> Date: Thu Aug 20 09:19:17 2015 -0500 * fix spacing issue commit 9c17d9a024936f98b22bee4bfcbf8089c63b9383 Merge: 9873450 0b67ef5 Author: Seth Call <sethcall@gmail.com> Date: Thu Aug 20 09:06:48 2015 -0500 Merge branch 'develop' of bitbucket.org:jamkazam/jam-cloud into develop commit 98734506dfa2c6420fd683429697deb2ccddf572 Author: Seth Call <sethcall@gmail.com> Date: Thu Aug 20 09:06:36 2015 -0500 * VRFS-3448 - fix invisible downloader commit 90c8d05d00a98195617ed47b51f04e8a7584cba2 Author: Seth Call <sethcall@gmail.com> Date: Wed Aug 19 14:17:10 2015 -0500 * wip commit bf4044d92e172869e4e5cbe67e01bfc25b7e877f Author: Seth Call <sethcall@gmail.com> Date: Wed Aug 19 09:24:14 2015 -0500 * VRFS-3422 - don't die if the user has on sale_line_items commit 87c62b4db2a0e6618593ef5d1ec32a0c6b2eb284 Author: Seth Call <sethcall@gmail.com> Date: Wed Aug 19 08:29:22 2015 -0500 * a fix for linux? hfa code commit 3fa58715fcf0aa63017e0be42e7f5b0ac4b9b8ac Author: Seth Call <sethcall@gmail.com> Date: Wed Aug 19 07:36:04 2015 -0500 * fix open jamtrack dialog for people with less than 10 jamtracks commit d045c94f54095bd413add20fde3555d8c32279a1 Author: Seth Call <sethcall@gmail.com> Date: Wed Aug 19 07:17:37 2015 -0500 * more HFA request polish commit dc343f10e3ddf21560b9178f097a60eedd097669 Author: Seth Call <sethcall@gmail.com> Date: Wed Aug 19 07:01:47 2015 -0500 * don't show free jamtrack notice on landing page if redeemed_jamtrack cookie is set commit e6618da456a675ddbe4d1eb2a51bbf21ae86a41c Author: Seth Call <sethcall@gmail.com> Date: Tue Aug 18 21:29:15 2015 -0500 * fix a bug in figuring out if the user should be show GET IT FREE commit 5ba03a2755e7d84b4019c951ea59156500a1ea01 Author: Seth Call <sethcall@gmail.com> Date: Tue Aug 18 20:41:37 2015 -0500 * VRFS-3431 - better response when creating HFA request commit 37d6c3e57c64e5bc7655ff6de317ee628a9499f4 Author: Seth Call <sethcall@gmail.com> Date: Tue Aug 18 15:19:40 2015 -0500 * add csv to dump released JamTracks commit f6101f3621af96255070e3346f377d5e42895a87 Author: Seth Call <sethcall@gmail.com> Date: Tue Aug 18 14:26:41 2015 -0500 VRFS-3422, VRFS-3423, VRFS-3424, VRFS-3429 - JamTrack search/listing commit 0b67ef5f52416080dcb94d5a2a5a1a7a998a3f3f Author: Jonathan Kolyer <jonathan@jamkazam.com> Date: Sat Aug 15 15:03:00 2015 +0000 fixed test for instruments in musician search
2015-09-19 21:33:39 +00:00
profileUtils.getGenreIds = function(genres) {
var list = []
for (var i=0; i < genres.length; i++) {
list.push(genres[i].genre_id);
}
return list;
}
// the server stores money in cents; display it as such
profileUtils.normalizeMoneyForDisplay = function(serverValue) {
if (!serverValue || serverValue==="") {
// Blank value is valid:
return ""
}
if(serverValue || serverValue == 0) {
return (new Number(serverValue) / 100).toFixed(2)
}
else {
return 0;
}
}
// the server stores money in cents; normalize it from what user entered
profileUtils.normalizeMoneyForSubmit = function(clientValue) {
if (!clientValue || clientValue==="") {
// Blank value is valid:
return ""
}
2016-01-20 03:54:55 +00:00
clientValue = clientValue.trim()
// remove leading $ if present
if (clientValue.indexOf('$') == 0) {
clientValue = clientValue.substring(1)
}
var money = new Number(clientValue);
if(!context._.isNaN(money)) {
money = Math.round(money * 100)
}
else {
// restore original value to allow server to reject with validation error
2016-01-20 03:54:55 +00:00
money = '';
}
return money;
}
// Initialize standard profile help bubbles (topics stored as attributes on element):
profileUtils.initializeHelpBubbles = function(parentElement) {
$(".help", parentElement).each(function( index ) {
context.JK.helpBubble($(this), $(this).attr("help-topic"), {}, {})
})
}
// profile genres
profileUtils.profileGenres = function(genres) {
var matches = $.grep(genres, function(g) {
return g.player_type === USER_TYPE && g.genre_type === PROFILE_GENRE_TYPE;
});
return matches;
}
profileUtils.profileGenreList = function(genres) {
var matches = profileUtils.profileGenres(genres);
return buildGenreList(matches);
}
// virtual band genres
profileUtils.virtualBandGenres = function(genres) {
var matches = [];
if (genres) {
matches = $.grep(genres, function(g) {
return g.player_type === USER_TYPE && g.genre_type === VIRTUAL_BAND_GENRE_TYPE;
});
}
return matches;
}
profileUtils.virtualBandGenreList = function(genres) {
var matches = profileUtils.virtualBandGenres(genres);
return buildGenreList(matches);
}
// traditional band genres
profileUtils.traditionalBandGenres = function(genres) {
var matches = [];
if (genres) {
matches = $.grep(genres, function(g) {
return g.player_type === USER_TYPE && g.genre_type === TRADITIONAL_BAND_GENRE_TYPE;
});
}
return matches;
}
profileUtils.traditionalBandGenreList = function(genres) {
var matches = profileUtils.traditionalBandGenres(genres);
return buildGenreList(matches);
}
// paid session genres
profileUtils.paidSessionGenres = function(genres) {
var matches = [];
if (genres) {
matches = $.grep(genres, function(g) {
return g.player_type === USER_TYPE && g.genre_type === PAID_SESSION_GENRE_TYPE;
});
}
return matches;
}
profileUtils.paidSessionGenreList = function(genres) {
var matches = profileUtils.paidSessionGenres(genres);
return buildGenreList(matches);
}
// free session genres
profileUtils.freeSessionGenres = function(genres) {
var matches = [];
if (genres) {
matches = $.grep(genres, function(g) {
return g.player_type === USER_TYPE && g.genre_type === FREE_SESSION_GENRE_TYPE;
});
}
return matches;
}
profileUtils.freeSessionGenreList = function(genres) {
var matches = profileUtils.freeSessionGenres(genres);
return buildGenreList(matches);
}
// cowriting genres
profileUtils.cowritingGenres = function(genres) {
var matches = [];
if (genres) {
matches = $.grep(genres, function(g) {
return g.player_type === USER_TYPE && g.genre_type === COWRITING_GENRE_TYPE;
});
}
return matches;
}
profileUtils.cowritingGenreList = function(genres) {
var matches = profileUtils.cowritingGenres(genres);
return buildGenreList(matches);
}
profileUtils.jamkazamSamples = function(samples) {
var matches = $.grep(samples, function(s) {
return s.service_type === profileUtils.SAMPLE_TYPES.JAMKAZAM.description;
});
return matches;
}
profileUtils.soundCloudSamples = function(samples) {
var matches = $.grep(samples, function(s) {
return s.service_type === profileUtils.SAMPLE_TYPES.SOUNDCLOUD.description;
});
return matches;
}
profileUtils.youTubeSamples = function(samples) {
var matches = $.grep(samples, function(s) {
return s.service_type === profileUtils.SAMPLE_TYPES.YOUTUBE.description;
});
return matches;
}
profileUtils.soundCloudPresences = function(presences) {
var matches = $.grep(presences, function(p) {
return p.service_type === profileUtils.ONLINE_PRESENCE_TYPES.SOUNDCLOUD.description;
});
return matches;
}
profileUtils.reverbNationPresences = function(presences) {
var matches = $.grep(presences, function(p) {
return p.service_type === profileUtils.ONLINE_PRESENCE_TYPES.REVERBNATION.description;
});
return matches;
}
profileUtils.bandCampPresences = function(presences) {
var matches = $.grep(presences, function(p) {
return p.service_type === profileUtils.ONLINE_PRESENCE_TYPES.BANDCAMP.description;
});
return matches;
}
profileUtils.fandalismPresences = function(presences) {
var matches = $.grep(presences, function(p) {
return p.service_type === profileUtils.ONLINE_PRESENCE_TYPES.FANDALISM.description;
});
return matches;
}
profileUtils.youTubePresences = function(presences) {
var matches = $.grep(presences, function(p) {
return p.service_type === profileUtils.ONLINE_PRESENCE_TYPES.YOUTUBE.description;
});
return matches;
}
profileUtils.facebookPresences = function(presences) {
var matches = $.grep(presences, function(p) {
return p.service_type === profileUtils.ONLINE_PRESENCE_TYPES.FACEBOOK.description;
});
return matches;
}
profileUtils.twitterPresences = function(presences) {
var matches = $.grep(presences, function(p) {
return p.service_type === profileUtils.ONLINE_PRESENCE_TYPES.TWITTER.description;
});
return matches;
}
// Render band instruments to a string:
profileUtils.renderBandInstruments = function (band) {
var msg = ""
if (band.instruments) {
for (var i = 0; i < band.instruments.length; i++) {
var instrument = band.instruments[i]
var description = instrument.instrument_id
if (msg.length > 0) {
msg += ", "
}
msg += instrument
msg += "(" + proficiencyDescriptionMap[instrument.proficiency_level] + ")"
}
}
if (msg.length==0) {
msg = "None specified"
}
return msg
}
function formatTitle(title) {
return title;
}
profileUtils.renderMusicalExperience = function(player, $root, isOwner) {
var $instruments = $root.find('.instruments-holder');
2015-06-05 22:22:50 +00:00
var $musicianStatus = $root.find('#musician-status');
var $genres = $root.find('#genres');
var $concertCount = $root.find('#concert-count');
var $studioCount = $root.find('#studio-count');
var $btnAddExperiences = $root.find('.add-experiences')
$instruments.find('.profile-instrument').remove()
if(isOwner) {
$btnAddExperiences.show()
}
else {
$btnAddExperiences.hide()
}
if (player.instruments) {
for (var i = 0; i < player.instruments.length; i++) {
var instrument = player.instruments[i];
var description = instrument.instrument_id;
var proficiency = instrument.proficiency_level;
var instrument_icon_url = context.JK.getInstrumentIcon256(description);
// add instrument info to layout
var template = $('#template-profile-instruments').html();
var instrumentHtml = context.JK.fillTemplate(template, {
instrument_logo_url: instrument_icon_url,
instrument_description: description,
proficiency_level: proficiencyDescriptionMap[proficiency],
proficiency_level_css: proficiencyCssMap[proficiency]
});
$instruments.append(instrumentHtml);
}
}
// status
var status = player.skill_level;
2015-06-05 22:22:50 +00:00
$musicianStatus.html(status ? profileUtils.skillLevelMap[status] + ' musician' : NOT_SPECIFIED_TEXT)
// genres
$genres.empty();
var profileGenres = profileUtils.profileGenreList(player.genres);
$genres.append(profileGenres.length > 0 ? profileGenres : NOT_SPECIFIED_TEXT);
// concert gigs
var concertCount = player.concert_count;
2016-01-20 11:37:13 +00:00
$concertCount.html(concertCount > 0 ? 'Has played ' + profileUtils.gigMap[concertCount] + ' live concert gigs' : 0);
// studio gigs
var studioCount = player.studio_session_count;
2016-01-20 11:37:13 +00:00
$studioCount.html(studioCount > 0 ? 'Has played ' + profileUtils.gigMap[studioCount] + ' studio session gigs' : 0);
}// function renderMusicalExperience
2015-06-05 22:22:50 +00:00
profileUtils.renderPerformanceSamples = function(player, $root, isOwner) {
// performance samples
var performanceSamples = player.performance_samples;
var $noSamples = $root.find('.no-samples');
var $jamkazamSamples = $root.find('.jamkazam-samples');
var $soundCloudSamples = $root.find('.soundcloud-samples');
var $youTubeSamples = $root.find('.youtube-samples');
2015-06-05 22:22:50 +00:00
var $btnAddRecordings = $root.find('.add-recordings');
$jamkazamSamples.find('.playable').remove()
$soundCloudSamples.find('.playable').remove()
$youTubeSamples.find('.playable').remove()
if (isOwner) {
$btnAddRecordings.show();
}
else {
$btnAddRecordings.hide();
}
if (!performanceSamples || performanceSamples.length === 0) {
$noSamples.show()
$jamkazamSamples.hide()
$soundCloudSamples.hide()
$youTubeSamples.hide()
} else {
$noSamples.hide();
// show samples section
var jamkazamSamples = profileUtils.jamkazamSamples(player.performance_samples);
if (!jamkazamSamples || jamkazamSamples.length === 0) {
$jamkazamSamples.hide()
} else {
$jamkazamSamples.show()
}
var soundCloudSamples = profileUtils.soundCloudSamples(player.performance_samples);
if (!soundCloudSamples || soundCloudSamples.length === 0) {
$soundCloudSamples.hide()
} else {
$soundCloudSamples.show()
}
var youTubeSamples = profileUtils.youTubeSamples(player.performance_samples);
if (!youTubeSamples || youTubeSamples.length === 0) {
$youTubeSamples.hide()
} else {
$youTubeSamples.show()
}
$.each(jamkazamSamples, function(index, sample) {
$jamkazamSamples.append("<a class='jamkazam-playable playable' href='/recordings/" + sample.claimed_recording.id + "' rel='external'>" + formatTitle(sample.claimed_recording.name) + "</a>");
});
$.each(soundCloudSamples, function(index, sample) {
$soundCloudSamples.append("<a class='sound-cloud-playable playable' href='' soundcloud_url='" + sample.url + "'>" + formatTitle(sample.description) + "</a>");
});
$.each(youTubeSamples, function(index, sample) {
$youTubeSamples.append("<a class='youtube-playable playable' href='" + sample.url + "' rel='external'>" + formatTitle(sample.description) + "</a>");
});
}
}// function renderPerformanceSamples
2015-06-05 22:22:50 +00:00
profileUtils.renderOnlinePresence = function(player, $root, isOwner) {
var $noOnlinePresence = $root.find('.no-online-presence');
var $userWebsite = $root.find('.user-website');
var $soundCloudPresence = $root.find('.soundcloud-presence');
var $reverbNationPresence = $root.find('.reverbnation-presence');
var $bandCampPresence = $root.find('.bandcamp-presence');
var $fandalismPresence = $root.find('.fandalism-presence');
var $youTubePresence = $root.find('.youtube-presence');
var $facebookPresence = $root.find('.facebook-presence');
var $twitterPresence = $root.find('.twitter-presence');
var $btnAddSites = $root.find('.add-presences');
if (isOwner) {
$btnAddSites.show();
} else {
$btnAddSites.hide();
}
// online presences
var onlinePresences = player.online_presences;
if (onlinePresences.length == 0 && !player.website) {
$noOnlinePresence.show()
2016-01-15 19:21:51 +00:00
$userWebsite.hide()
$soundCloudPresence.hide()
$reverbNationPresence.hide()
$bandCampPresence.hide()
$fandalismPresence.hide()
$youTubePresence.hide()
$facebookPresence.hide()
$twitterPresence.hide()
} else {
$noOnlinePresence.hide();
if (player.website) {
// make sure website is rooted
var website = player.website;
if(website.indexOf('http') == -1) {
website = 'http://' + website;
}
2016-01-15 19:21:51 +00:00
$userWebsite.removeClass('hidden').show().find('a').attr('href', website)
}
else {
2016-01-15 19:21:51 +00:00
$userWebsite.addClass('hidden').hide().find('a').attr('href', '')
}
var soundCloudPresences = profileUtils.soundCloudPresences(onlinePresences);
if (soundCloudPresences && soundCloudPresences.length > 0) {
$soundCloudPresence.find('a').attr('href', 'http://www.soundcloud.com/' + soundCloudPresences[0].username);
$soundCloudPresence.show();
} else {
$soundCloudPresence.hide();
}
var reverbNationPresences = profileUtils.reverbNationPresences(onlinePresences);
if (reverbNationPresences && reverbNationPresences.length > 0) {
$reverbNationPresence.find('a').attr('href', 'http://www.reverbnation.com/' + reverbNationPresences[0].username);
$reverbNationPresence.show();
} else {
$reverbNationPresence.hide();
}
var bandCampPresences = profileUtils.bandCampPresences(onlinePresences);
if (bandCampPresences && bandCampPresences.length > 0) {
$bandCampPresence.find('a').attr('href', 'http://' + bandCampPresences[0].username + '.bandcamp.com/');
$bandCampPresence.show();
} else {
$bandCampPresence.hide();
}
var fandalismPresences = profileUtils.fandalismPresences(onlinePresences);
if (fandalismPresences && fandalismPresences.length > 0) {
$fandalismPresence.find('a').attr('href', 'http://www.fandalism.com/' + fandalismPresences[0].username);
$fandalismPresence.show();
} else {
$fandalismPresence.hide();
}
var youTubePresences = profileUtils.youTubePresences(onlinePresences);
if (youTubePresences && youTubePresences.length > 0) {
$youTubePresence.find('a').attr('href', 'http://www.youtube.com/' + youTubePresences[0].username);
$youTubePresence.show();
} else {
$youTubePresence.hide();
}
var facebookPresences = profileUtils.facebookPresences(onlinePresences);
if (facebookPresences && facebookPresences.length > 0) {
$facebookPresence.find('a').attr('href', 'http://www.facebook.com/' + facebookPresences[0].username);
$facebookPresence.show();
} else {
$facebookPresence.hide();
}
var twitterPresences = profileUtils.twitterPresences(onlinePresences);
if (twitterPresences && twitterPresences.length > 0) {
$twitterPresence.find('a').attr('href', 'http://www.twitter.com/' + twitterPresences[0].username);
$twitterPresence.show();
} else {
$twitterPresence.hide();
}
}
}// function renderOnlinePresence
})(window, jQuery);