how to make battery level indicator using javascript