ShowFeedID improvements v2 (#331)

This commit is contained in:
Inverle 2025-06-03 01:41:50 +02:00 committed by GitHub
parent 850bd65734
commit 02455c5f8a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 17 additions and 7 deletions

View file

@ -5,7 +5,8 @@ declare(strict_types=1);
final class ShowFeedIdExtension extends Minz_Extension { final class ShowFeedIdExtension extends Minz_Extension {
#[\Override] #[\Override]
public function init(): void { public function init(): void {
if (Minz_Request::paramString('c') === 'subscription') { if (Minz_Request::paramString('c') === 'subscription'
&& Minz_Request::actionName() === 'index') {
$this->registerTranslates(); $this->registerTranslates();
$this->registerHook('js_vars', [$this, 'jsVars']); $this->registerHook('js_vars', [$this, 'jsVars']);
Minz_View::appendScript($this->getFileUrl('showfeedid.js')); Minz_View::appendScript($this->getFileUrl('showfeedid.js'));

View file

@ -2,7 +2,7 @@
"name": "ShowFeedID", "name": "ShowFeedID",
"author": "math-GH, Inverle", "author": "math-GH, Inverle",
"description": "Show the ID of feed and category", "description": "Show the ID of feed and category",
"version": "0.4.0", "version": "0.4.1",
"entrypoint": "ShowFeedID", "entrypoint": "ShowFeedID",
"type": "user" "type": "user"
} }

View file

@ -5,17 +5,26 @@ window.addEventListener("load", function () {
const i18n = context.extensions.showfeedid_i18n; const i18n = context.extensions.showfeedid_i18n;
const div = document.querySelector('h1 ~ div'); const div = document.querySelector('h1 ~ div');
const button = document.createElement('button'); const button = document.createElement('a');
button.classList.add('btn'); button.classList.add('btn');
button.classList.add('btn-icon-text');
button.id = 'showFeedId'; button.id = 'showFeedId';
button.innerHTML = '<img class="icon" src="../themes/icons/look.svg" /> <span>' + i18n.show + '</span>'; button.innerHTML = '<img class="icon" src="../themes/icons/look.svg" /> <span>' + i18n.show + '</span>';
if (new URLSearchParams(location.search).get('error')) {
button.style.display = 'block';
button.style.marginTop = '1rem';
}
div.appendChild(button); div.appendChild(button);
const parent = button.parentElement;
parent.style.display = 'inline-flex';
parent.style.flexWrap = 'wrap';
parent.style.gap = '0.5rem';
// Check if only feeds with errors are being shown
if (document.querySelector('main.post > p.alert.alert-warn')) {
parent.style.flexDirection = 'column';
button.style.marginTop = '0.5rem';
}
const buttonText = button.querySelector('span'); const buttonText = button.querySelector('span');
button.addEventListener('click', function () { button.addEventListener('click', function () {