Encode and decode HTML entities with javascript