adding pagination conditions to javascript