JS implementation of a PHP Pagination class