Skip to content
This repository has been archived by the owner on Apr 1, 2023. It is now read-only.

Highlight current page #44

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/helpers/handlebars.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,16 @@ export const constructUrl = (url: string, param: string): string => {
}
export const contains = (a: string, b:string): boolean => {
return a.includes(b);
}

export const ifContains = (a: string, b:string): boolean => {
return a.slice(-1).includes(b);
}

export const portContains = (a: string, b:string): boolean => {
return a.includes(b);
}

export const not = (a: string): boolean=> {
return !a;
}
19 changes: 17 additions & 2 deletions src/views/partials/pagination.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,32 @@
<li class="disabled page-item"><a class="page-link">...</a></li>
{{/if}}
{{#each (displayPagesNumber interval current pages)}}
{{#if (ifEqual . current 0)}}
{{#if (ifEqual current 1)}}
<li class="active page-item"><a class="page-link">{{ . }}</a></li>
{{else}}
{{#if @root.hasParams}}
{{#if (contains @root.fullUrl "page")}}
{{#if (ifContains @root.fullUrl . ) }}
<li class="page-item active"><a href="{{{constructUrl @root.fullUrl .}}}" class="page-link">{{ . }}</a></li>
{{else}}
<li class="page-item"><a href="{{{constructUrl @root.fullUrl .}}}" class="page-link">{{ . }}</a></li>
{{/if}}
{{else}}
<li class="page-item"><a href="{{@root.fullUrl}}&page={{.}}" class="page-link">{{ . }}</a></li>
{{/if}}
{{else}}
<li class="page-item"><a href="{{@root.fullUrl}}?page={{.}}" class="page-link">{{ . }}</a></li>
{{#if (portContains @root.fullUrl "3001") }}
{{#if (not (contains @root.fullUrl "page"))}}
{{#if (contains @root.fullUrl 0 ) }}
{{#if (ifEqual . 1 0)}}
<li class="page-item active"><a href="{{@root.fullUrl}}?page={{.}}" class="page-link">{{ . }}</a></li>
{{else}}<li class="page-item"><a href="{{@root.fullUrl}}?page={{.}}" class="page-link">{{ . }}</a></li>
{{/if}}
{{/if}}
{{/if}}
{{else}}
<li class="page-item"><a href="{{@root.fullUrl}}?page={{.}}" class="page-link">s{{ . }}</a></li>
{{/if}}
{{/if}}
{{/if}}
{{#if (ifEqual . current 4)}}
Expand Down