Tidy up enumeration of pages to display in pager-custom-controls.js

This simplifies the logic used to generate pageArray and removes the call to
pageArray.sort, making this perfectly O(n).

This also fixes an issue where the page numbers are completely missing with only
one page present.