Refactor javascript, fix resource category editing