]> saetta.ns0.it Git - zakegg_go/commitdiff
Paginazione: non veniva disabilitato il pulsante successiva e ultima.
authorAndrea Zagli <azagli@libero.it>
Mon, 11 Apr 2022 14:40:41 +0000 (16:40 +0200)
committerAndrea Zagli <azagli@libero.it>
Mon, 11 Apr 2022 14:40:41 +0000 (16:40 +0200)
zakegg.go

index a0a5589ecee54190ca54d34bf42504a6c66c9d93..5a6803edfab95d1d2a90f13e2e9eb6d60ca2c3a2 100644 (file)
--- a/zakegg.go
+++ b/zakegg.go
@@ -64,16 +64,34 @@ func Paginazione(start int, rows int, rows_x_page int, url string) string {
                }
 
                if start < int(rows / rows_x_page) * rows_x_page {
-                       ret += fmt.Sprintf(`<li class="page-item">
+                       successiva := start + rows_x_page
+                       if successiva >= rows {
+                               ret += `<li class="page-item disabled">
+                                       <a class="page-link" href="#" aria-label="Successiva" title="Successiva">
+                                       <span aria-hidden="true">&rsaquo;</span>
+                                       </a>
+                                       </li>`
+                               ret += `<li class="page-item disabled">
+                                       <a class="page-link" href="#" aria-label="Ultima" title="Ultima">
+                                       <span aria-hidden="true">&raquo;</span>
+                                       </a>
+                                       </li>`
+                       } else {
+                               ret += fmt.Sprintf(`<li class="page-item">
                                                    <a class="page-link" href="%s/%d" aria-label="Successiva" title="Successiva">
                                                    <span aria-hidden="true">&rsaquo;</span>
                                                    </a>
-                                                   </li>`, url, start + rows_x_page)
-                       ret += fmt.Sprintf(`<li class="page-item">
+                                                   </li>`, url, successiva)
+                               ultima := (rows / rows_x_page) * rows_x_page
+                               if ultima >= rows {
+                                       ultima -= rows_x_page
+                               }
+                               ret += fmt.Sprintf(`<li class="page-item">
                                                    <a class="page-link" href="%s/%d" aria-label="Ultima" title="Ultima">
                                                    <span aria-hidden="true">&raquo;</span>
                                                    </a>
-                                                   </li>`, url, (rows / rows_x_page) * rows_x_page)
+                                                   </li>`, url, ultima)
+                       }
                } else {
                        ret += `<li class="page-item disabled">
                                        <a class="page-link" href="#" aria-label="Successiva" title="Successiva">