I am currently working on a Chat Application and ran into a slight hiccup, I want a message that is addressed to a user to only be visible to the user and the sender.
<script>
//PRIVATE MESSAGE
var username = '<?=$_SESSION['username'];?>'.toUpperCase();
$('#chatbox').children('.msgln').each(function(){
var msgln = $(this);
$$select = msgln.find('.messagelinebox');
$message = $$select.text();
if($message.indexOf('@') !== -1){
var $product = $message.substr($message.indexOf("@") + 1);
$$product = $product.substring(0,7).toUpperCase();
var receiver = $$product;
if(username = receiver){
$(this).show();
}else if(receiver = username){
$(this).show();
}else if(receiver != username){
$(this).hide();
}else{
$(this).show();
}
}
});
</script>
Any help will be appreciated.