Webclient: Cleaned up code in inventory.js, factored out a little bit