Index: src/bp-messages/js/autocomplete/jquery.autocompletefb.js =================================================================== --- src/bp-messages/js/autocomplete/jquery.autocompletefb.js +++ src/bp-messages/js/autocomplete/jquery.autocompletefb.js @@ -19,13 +19,15 @@ var settings = { ul : tmp, - urlLookup : [""], + urlLookup : [''], acOptions : {}, - foundClass : ".friend-tab", - inputClass : ".send-to-input" - } + foundClass : '.friend-tab', + inputClass : '.send-to-input' + }; - if(options) jQuery.extend(settings, options); + if (options) { + jQuery.extend(settings, options); + } var acfb = { @@ -40,25 +42,49 @@ var newID = o.parentNode.id.substr( o.parentNode.id.indexOf('-')+1 ); jQuery('#send-to-usernames').removeClass(newID); } - } + }; - jQuery(settings.foundClass+" img.p").click(function(){ + jQuery(settings.foundClass+' img.p').click(function(){ acfb.removeFind(this); }); jQuery(settings.inputClass,tmp).autocomplete(settings.urlLookup,settings.acOptions); jQuery(settings.inputClass,tmp).result(function(e,d,f){ - var f = settings.foundClass.replace(/\./,''); - var d = String(d).split(' ('); + f = settings.foundClass.replace(/\./,''); + d = String(d).split(' ('); var un = d[1].substr(0, d[1].length-1); /* Don't add the same user multiple times */ if( 0 === jQuery(settings.inputClass).siblings('#un-' + un).length ) { + // Get URL parameter function. + // http://stackoverflow.com/a/21903119 + var getUrlParameter = function getUrlParameter(sParam) { + var sPageURL = decodeURIComponent(window.location.search.substring(1)), + sURLVariables = sPageURL.split('&'), + sParameterName, + i; + + for (i = 0; i < sURLVariables.length; i++) { + sParameterName = sURLVariables[i].split('='); + + if (sParameterName[0] === sParam) { + return sParameterName[1] === undefined ? true : sParameterName[1]; + } + } + }; + var ln = '#link-' + un; var l = jQuery(ln).attr('href'); var v = '