mirror of
				https://github.com/Theodor-Springmann-Stiftung/kgpz_web.git
				synced 2025-10-31 01:55:29 +00:00 
			
		
		
		
	THE GREAT JS CLEANUP
This commit is contained in:
		| @@ -32,56 +32,9 @@ | ||||
| {{ $issue.When.Year }}/{{ $issue.Nr }} | ||||
| {{- end -}} | ||||
| {{- if $issue.Von }}, {{ if $issue.Beilage }}Beil. {{ else }}S. {{ end }}{{ $issue.Von }}{{- if and $issue.Bis (ne $issue.Von $issue.Bis) -}} | ||||
| -{{ $issue.Bis }} | ||||
| -{{- $issue.Bis -}} | ||||
| {{- end -}} | ||||
| {{- end -}} | ||||
| </a> | ||||
|  | ||||
| <script> | ||||
| // Check if citation links point to current page (without hash) | ||||
| function updateCitationLinks() { | ||||
|     const currentPath = window.location.pathname; | ||||
|     const citationLinks = document.querySelectorAll('.citation-link[data-citation-url]'); | ||||
|  | ||||
|     citationLinks.forEach(link => { | ||||
|         const citationUrl = link.getAttribute('data-citation-url'); | ||||
|         let isCurrentPage = false; | ||||
|  | ||||
|         // Check for exact match | ||||
|         if (citationUrl === currentPath) { | ||||
|             isCurrentPage = true; | ||||
|         } else { | ||||
|             // Check if current path is an issue with page number that matches this citation | ||||
|             const currentPathMatch = currentPath.match(/^\/(\d{4})\/(\d+)(?:\/(\d+))?$/); | ||||
|             const citationUrlMatch = citationUrl.match(/^\/(\d{4})\/(\d+)$/); | ||||
|  | ||||
|             if (currentPathMatch && citationUrlMatch) { | ||||
|                 const [, currentYear, currentIssue, currentPage] = currentPathMatch; | ||||
|                 const [, citationYear, citationIssue] = citationUrlMatch; | ||||
|  | ||||
|                 // If year and issue match, this citation refers to the current issue | ||||
|                 if (currentYear === citationYear && currentIssue === citationIssue) { | ||||
|                     isCurrentPage = true; | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         if (isCurrentPage) { | ||||
|             // Style as current page: red text, no underline, not clickable | ||||
|             link.classList.add('text-red-700', 'pointer-events-none'); | ||||
|             link.setAttribute('aria-current', 'page'); | ||||
|         } else { | ||||
|             // Reset to default styling for non-current pages | ||||
|             link.classList.remove('text-red-700', 'pointer-events-none'); | ||||
|             link.removeAttribute('aria-current'); | ||||
|         } | ||||
|     }); | ||||
| } | ||||
|  | ||||
| // Run on initial load | ||||
| document.addEventListener('DOMContentLoaded', updateCitationLinks); | ||||
|  | ||||
| // Run on HTMX page swaps | ||||
| document.addEventListener('htmx:afterSwap', updateCitationLinks); | ||||
| document.addEventListener('htmx:afterSettle', updateCitationLinks); | ||||
| </script> | ||||
| {{- /* This is a dummy element to remove all whitespace at the end of the file, as some editiors | ||||
| will insert a newline at the end of the file, UGH. */ -}} | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Simon Martens
					Simon Martens