Refactor generation of object metadata in API calls

Factor out duplicate from the object models into common code.
More refactoring of common code in object models

Tidy up code and extract generation of tag elements to the
common code in the ObjectMetadata module.
Unconditionally unbind moveend event

Can't rely on checking location.pathname -- inside unload,
it already contains the new path. Fortunately, checking is
unnecessary.

Fixes TypeError: Cannot call method 'split' of undefined.