Javascript handling of favourites adding