api: Add some comments and use promises for ajax calls
api: issue in private API is fixed; we can now pass tags to year list method
library: split count/load into two functions

- When the year or page length is changed, we no longer make an
unnecessary call to the years API method; we just use previously stored
document counts to rebuild the pager.
- Renamed loadDocuments to loadDocumentPage; it now takes a page
argument instead of reading a data variable.
- Added an extra boolean parameter to the setFilter public method which
can trigger a refetch.