convert js wrapper for wp-pagenavi to pure js