Adding remaining capacity calculation to jquery