Return page 1 for pages without pagination.
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Sat, 16 Apr 2011 11:21:39 +0000 (13:21 +0200)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Sat, 16 Apr 2011 11:21:39 +0000 (13:21 +0200)
src/main/resources/static/javascript/sone.js

index 84208f4..3088aff 100644 (file)
@@ -1115,14 +1115,19 @@ function isIndexPage() {
 }
 
 /**
- * Returns the current page of the selected pagination.
+ * Returns the current page of the selected pagination. If no pagination can be
+ * found with the given selector, {@code 1} is returned.
  *
  * @param paginationSelector
  *            The pagination selector
  * @returns The current page of the pagination
  */
 function getPage(paginationSelector) {
-       return $(".current-page", paginationSelector).text();
+       pagination = $(paginationSelector);
+       if (pagination.length > 0) {
+               return $(".current-page", paginationSelector).text();
+       }
+       return 1;
 }
 
 /**