javascript for player's fundamental functions