// template-related scripts go here... (function () { 'use strict'; function extractHotkey(linkEl) { if (!linkEl) return ''; // Prefer the human-facing "[X]" in the title when present. // DokuWiki commonly uses titles like "Edit this page [E]". var title = linkEl.getAttribute('title') || ''; var match = title.match(/\[([^\]]+)\]\s*$/); if (match && match[1]) return match[1].trim(); var accessKey = linkEl.getAttribute('accesskey') || ''; if (accessKey) return accessKey.trim().toUpperCase(); return ''; } function prependHotkey(linkEl, hotkey) { if (!hotkey) return; if (linkEl.querySelector('.luxtools__hotkey')) return; var label = (linkEl.textContent || '').trim(); if (!label) return; linkEl.textContent = ''; var span = document.createElement('span'); span.className = 'luxtools__hotkey red-168-text'; span.textContent = hotkey; linkEl.appendChild(span); linkEl.appendChild(document.createTextNode(' ' + label)); } document.addEventListener('DOMContentLoaded', function () { var pagetools = document.getElementById('dokuwiki__pagetools'); if (!pagetools) return; var links = pagetools.querySelectorAll('a'); for (var i = 0; i < links.length; i++) { var hotkey = extractHotkey(links[i]); if (!hotkey) continue; prependHotkey(links[i], hotkey); } }); })();