pagination: Fix js error if url has no page param.

Reapply 87472d9 because of a regression by 5a9c5f4.
pagination: Fix the Prev and the Next link.
project: Show pagination for ten or more projects.