From b5355a61d452b9037208635e32b3890f259244c6 Mon Sep 17 00:00:00 2001 From: Brandon Fowler Date: Thu, 25 Apr 2024 21:01:40 -0400 Subject: [PATCH] Add links to rows --- includes/LinkCount.php | 7 ++++++- static/index.css | 10 +++++++++- static/index.js | 8 ++++++-- 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/includes/LinkCount.php b/includes/LinkCount.php index 221f7c1..6c8cf87 100644 --- a/includes/LinkCount.php +++ b/includes/LinkCount.php @@ -170,6 +170,11 @@ public function getHtml() { 'href' => $this->projectURL . str_replace('PAGE', $encodedPage, $this->typeInfo[$key]['url']) ])->appendContent($this->typeInfo[$key]['name']); + $link = (new OOUI\Tag('a'))->addClasses(['hash-link'])->setAttributes([ + 'href' => '#' . $key, + 'title' => 'Link to row' + ])->appendContent('(#)'); + $all = number_format($singleCount ? $count : $count['all']); $direct = $singleCount ? new OOUI\HtmlSnippet('‒') : number_format($count['direct']); $indirect = $singleCount ? new OOUI\HtmlSnippet('‒') : number_format($count['indirect']); @@ -181,7 +186,7 @@ public function getHtml() { ])->appendContent( (new OOUI\Tag('div'))->addClasses(['type'])->setAttributes([ 'role' => 'cell' - ])->appendContent($label), + ])->appendContent($label, ' ', $link), (new OOUI\Tag('div'))->addClasses(['all'])->setAttributes([ 'role' => 'cell' ])->appendContent($all), diff --git a/static/index.css b/static/index.css index 7023637..60c1953 100644 --- a/static/index.css +++ b/static/index.css @@ -83,6 +83,14 @@ footer, .out .type { border-radius: 2px 0 0 2px; white-space: nowrap; + display: inline-flex; + align-items: center; + gap: 6px; +} + +.hash-link { + color: #5d5f62; + font-size: 70%; } .out .all, @@ -134,7 +142,7 @@ footer, border-radius: 2px 2px 0 0; margin-bottom: 0; line-height: 80%; - text-align: center; + justify-content: center; } .out .all, diff --git a/static/index.js b/static/index.js index 4ea517e..da09de6 100644 --- a/static/index.js +++ b/static/index.js @@ -13,7 +13,8 @@ var projectLookup = OO.ui.infuse($('#project')), align: 'top' }), out = $('#out'), - request = undefined; + request = undefined, + currentSearch = location.search; function submitForm(pushState) { var params = { @@ -63,9 +64,12 @@ button.on('click', function() { }); window.addEventListener('popstate', function() { + if (currentSearch === location.search) return; + currentSearch = location.search; + var params = {}; - location.search.slice(1).split('&').forEach(param => { + currentSearch.slice(1).split('&').forEach(param => { var chunks = param.split('='), key = chunks.shift(), value = decodeURIComponent(chunks.join('='));