This page is for gadget-specific discussion. For most issues, please visit Wikipedia talk:Tools/Navigation popups. This gadget also has a Phabricator workboard used for implementation-related discussion. |
To help centralize discussions and keep related topics together, MediaWiki talk:Gadget-navpop.css redirects here. |
This page has archives. Sections older than 365 days may be automatically archived by Lowercase sigmabot III when more than 4 sections are present. |
can we change:
return 'History preview failed :-(';
to something like:
return popupString('History preview failed :-(');
for localization purpose? valepert (talk) 10:22, 31 January 2024 (UTC)
This edit request has been answered. Set the |answered= or |ans= parameter to no to reactivate your request. |
Is it possible to add the most recent block log entry (for currently blocked users) into the popup? Similar to how MediaWiki:Gadget-markblocked.js puts the reason in the tooltip. I have both scripts enabled, and it does strikethrough the username but Popups overrides the markblocked tooltip for blocked editors so I can't see the block reason without navigating away from the page I'm on to check the block log. I'd try building it myself based on the markblocked gadget, but my Javascript knowledge is very limited. The WordsmithTalk to me 21:11, 28 February 2024 (UTC)
Usually when you hover over a username, popups shows all their local permissions in regular text, and all their global permissions in italics. However, I've noticed a couple permissions are not showing up. In particular, extended confirmed (local) and global renamer (global). I propose fixing these two, and doing an audit to make sure there's not any other permissions being missed. If there's some hard-coded list in the code somewhere, I propose switching to something that is not hard-coded so that new permissions can be reliably detected without code modifcations. –Novem Linguae (talk) 04:13, 16 April 2024 (UTC)
In a sandbox, I ran the official wikimedia javascript linter on the popups code. Here's the diff.
extends { "wikimedia/client/es6", "wikimedia/jquery", "wikimedia/mediawiki" }
.slice( 0, Math.max(
is more readable/better than the existing .substring(
Will self-merge in a couple days if no objections.
Note to self: Manually test a bit on testwiki before deploying. –Novem Linguae (talk) 06:36, 25 April 2024 (UTC)
"comma-dangle": "never"
setting, it makes subsequent diffs less readable (and accounts for a large part of the current diff as well). Could you change it to only-multiline
(or always-multiline
if you prefer) and revert your changes that removed trailing commas? Thanks in advance!{
"extends": [
"wikimedia/client/es6",
"wikimedia/jquery",
"wikimedia/mediawiki"
],
"globals": {
"mw": "readonly"
},
"parserOptions": {
"ecmaVersion": "latest",
"sourceType": "module"
},
"rules": {
"camelcase": "off",
"es-x/no-array-prototype-includes": "off",
"es-x/no-async-functions": "off",
"es-x/no-class-fields": "off",
"es-x/no-optional-catch-binding": "off",
"es-x/no-regexp-lookbehind-assertions": "off",
"es-x/no-regexp-s-flag": "off",
"es-x/no-rest-spread-properties": "off",
"es-x/no-string-prototype-matchall": "off",
"es-x/no-string-prototype-replaceall": "off",
"jsdoc/require-param": "off",
"jsdoc/require-param-type": "off",
"jsdoc/require-returns": "off",
"max-len": "off",
"mediawiki/class-doc": "off",
"no-jquery/no-class-state": "off",
"no-jquery/no-global-selector": "off",
"no-jquery/no-parse-html-literal": "off",
"no-jquery/variable-pattern": "off",
"no-shadow": "off",
"no-underscore-dangle": "off",
"security/detect-non-literal-regexp": "off",
"security/detect-unsafe-regex": "off",
"unicorn/prefer-string-slice": "off",
"space-in-parens": "off",
"computed-property-spacing": "off",
"eqeqeq": "off",
"no-var": "off",
"spaced-comment": "off",
"array-bracket-spacing": "off",
"jsdoc/no-multi-asterisks": "off",
"no-alert": "off",
"no-tabs": "off",
"jsdoc/require-asterisk-prefix": "off",
"jsdoc/check-alignment": "off"
}
}
comma-dangle
!Although it's in the official Wikimedia JavaScript linter, so I'm sure they have their reasons.
It'd be a pretty big comment, so I will probably have to keep it out of the code for now.
"quotes": "single"
, which is exactly the non-JSON-compatible version, and it’s even much more work to replace all the single quotes with double ones than deleting some commas. —Tacsipacsi (talk) 21:47, 1 June 2024 (UTC)
(the developer community has had this conversation before and decided that easier portability to JSON is more important than cleaner diffs)–Novem Linguae (talk) 00:08, 2 June 2024 (UTC)
This edit request to MediaWiki:Gadget-navpop.css has been answered. Set the |answered= or |ans= parameter to no to reactivate your request. |
Can an interface admin please copy User:The wub/popups sandbox.css to MediaWiki:Gadget-navpop.css (comparison). This updates the styling to work in the new dark mode (phab:T365749), following the guidance at mw:Recommendations for night mode compatibility on Wikimedia wikis. the wub "?!" 20:32, 26 May 2024 (UTC)
This edit request to MediaWiki:Gadget-navpop.css has been answered. Set the |answered= or |ans= parameter to no to reactivate your request. |
This edit request has been answered. Set the |answered= or |ans= parameter to no to reactivate your request. |
I became aware of an issue with Navigation Popups through a discussion started by @Tacsipacsi in translatewiki.net, which is the same issue @MarcoAurelio reported in phab:T329217.
I believe the fix for this is quite simple, and can be achieved by changing this:
function setMainRegex() {
var reStart = '*://';
var preTitles =
literalizeRegex(mw.config.get('wgScriptPath')) + '/(?:indexphp|wikiphtml)title=';
preTitles += '|' + literalizeRegex(pg.wiki.articlePath + '/');
var reEnd = '(' + preTitles + ')(*)*(?:#(.+))?';
pg.re.main = RegExp(reStart + literalizeRegex(pg.wiki.sitebase) + reEnd);
}
into this:
function setMainRegex() {
var reStart = '*://';
var preTitles =
'(?:' + literalizeRegex(mw.config.get('wgScript')) + '|' +
literalizeRegex(mw.config.get('wgScriptPath')) + '/(?:indexphp|wikiphtml))title=';
preTitles += '|' + literalizeRegex(pg.wiki.articlePath + '/');
var reEnd = '(' + preTitles + ')(*)*(?:#(.+))?';
pg.re.main = RegExp(reStart + literalizeRegex(pg.wiki.sitebase) + reEnd);
}
But someone who's familiar with this gadget should test it properly before adding the fix. I've tested it locally in the browser console both here and on translatewiki.net, and it works well in both places, but I'm not very familiar with this script, so someone who is should test this before making the changes. Jon Harald Søby (talk) 20:01, 22 December 2024 (UTC)
function setMainRegex() {
var reStart = '*://';
var preTitles =
// translatewiki.net uses i.php instead of index.php
'(?:' + literalizeRegex(mw.config.get('wgScript')) + '|' +
// handle the more common cases of index.php and wiki.phtml
literalizeRegex(mw.config.get('wgScriptPath')) + '/(?:indexphp|wikiphtml))';
// Hmm. Why is there a | in this one? It doesn't appear to be inside of a (?:
preTitles += 'title=|' + literalizeRegex(pg.wiki.articlePath + '/');
var reEnd = '(' + preTitles + ')(*)*(?:#(.+))?';
pg.re.main = RegExp(reStart + literalizeRegex(pg.wiki.sitebase) + reEnd);
}
|
is put into parentheses in the var reEnd
line. So the part before the bar is /w/index.php type stuff, while the part after it is https://wiki95.com/en/ type stuff, and then the part that comes after them both in reEnd
is the page title. Jon Harald Søby (talk) 22:12, 22 December 2024 (UTC)
index.php
was dropped from the “more common cases” branch? On wikis without exotic configuration (i.e. all WMF wikis, for example), this would make no difference other than making the regex simpler. On wikis like Translatewiki, this would break NavPopups for about ten index.php
links (lot of the results are false positives like user scripts and stack traces). And there was no problem with the naming: the remaining wiki.phtml
is definitely “legacy” rather than “common”. —Tacsipacsi (talk) 22:34, 22 December 2024 (UTC)
function setMainRegex() {
var reStart = '*://';
var preTitles =
literalizeRegex(mw.config.get('wgScript')) + 'title=';
preTitles += '|' + literalizeRegex(pg.wiki.articlePath + '/');
var reEnd = '(' + preTitles + ')(*)*(?:#(.+))?';
pg.re.main = RegExp(reStart + literalizeRegex(pg.wiki.sitebase) + reEnd);
}
wiki.phtml
on enwiki alone. (wgScript
specifies the what URLs MediaWiki generates, while this regex tries to find the URLs MediaWiki is reachable at. The latter is of course a proper superset of the former, in order to make gadget authors’ lives more challenging. ) —Tacsipacsi (talk) 19:49, 23 December 2024 (UTC)
wgScript
to something else after existing for a few years. All old links that people have just copy-pasted will then still include index.php and not the new config setting (just as is the case with wiki.phtml here in enwiki). So I think it makes sense to include a hard-coded index.php in addition to the wgScript
, even though they will be the same in most cases. Jon Harald Søby (talk) 15:53, 25 December 2024 (UTC)@Novem Linguae: Okay, so final (hopefully?) suggestion based on the feedback (I've changed the comments slightly to generalize them):
function setMainRegex() {
var reStart = '*://';
var preTitles =
// Take customizable wgScript into account (it isn't guaranteed to be index.php)
'(?:' + literalizeRegex(mw.config.get('wgScript')) + '|' +
// handle index.php (likely to work even if different from wgScript) and legacy wiki.phtml
literalizeRegex(mw.config.get('wgScriptPath')) + '/(?:indexphp|wikiphtml))';
preTitles += 'title=|' + literalizeRegex(pg.wiki.articlePath + '/');
var reEnd = '(' + preTitles + ')(*)*(?:#(.+))?';
pg.re.main = RegExp(reStart + literalizeRegex(pg.wiki.sitebase) + reEnd);
}
Is this OK? Jon Harald Søby (talk) 15:53, 25 December 2024 (UTC)
When hovering over files in a category, like c:Category:Down_East_Latch_Strings_(1887), I get
Uncaught TypeError: str.includes is not a function isValidImageName https://en.wikipedia.org/w/index.php?title=MediaWiki:Gadget-popups.js&action=raw&ctype=text/javascript&smaxage=21600&maxage=86400:3222 loadImage https://en.wikipedia.org/w/index.php?title=MediaWiki:Gadget-popups.js&action=raw&ctype=text/javascript&smaxage=21600&maxage=86400:5547 nonsimplePopupContent https://en.wikipedia.org/w/index.php?title=MediaWiki:Gadget-popups.js&action=raw&ctype=text/javascript&smaxage=21600&maxage=86400:450 mouseOverWikiLink2 https://en.wikipedia.org/w/index.php?title=MediaWiki:Gadget-popups.js&action=raw&ctype=text/javascript&smaxage=21600&maxage=86400:354 mouseOverWikiLink https://en.wikipedia.org/w/index.php?title=MediaWiki:Gadget-popups.js&action=raw&ctype=text/javascript&smaxage=21600&maxage=86400:232 index.php:3222:15
This appears to be caused by Special:Diff/1265443931 (@Novem Linguae). AntiCompositeNumber (talk) 00:12, 27 December 2024 (UTC)
function isValidImageName(str) {
// extend as needed...
return str.indexOf('{') == -1;
}