MediaWiki talk:Gadget-VisualFileChange.js/install.js

From Wikimedia Commons, the free media repository
Jump to navigation Jump to search

{{Edit request}}

Please replace the page contents with:

/*jshint scripturl:true*/
mw.util.addPortletLink('p-tb', 'javascript:importScript("MediaWiki:VisualFileChange.js");', 'Perform batch task', 't-AjaxQuickDeleteOnDemand');
/*jshint scripturl:false*/

in order to avoid nasty warning messages by JSHint which notifies users when they attempt to save or by CommonsMaintenanceBot on their talk page. Later we can create a gadget and automagically remove this kind of installation from user's js pages. -- Rillke(q?) 23:53, 29 October 2014 (UTC)[reply]

✓ Done --Steinsplitter (talk) 20:08, 30 October 2014 (UTC)[reply]

Proposed alternative

[edit]

@Rillke: @Steinsplitter: How about:

var visualFileChange = mw.util.addPortletLink('p-tb', '#', 'Perform batch task', 't-AjaxQuickDeleteOnDemand');
$( visualFileChange ).click( function ( evt ) {
	importScript("MediaWiki:VisualFileChange.js");
	evt.preventDefault();
} );

so we don't have to disable that jshint rule (I tested and it works). Mattflaschen - Talk 06:04, 21 July 2015 (UTC)[reply]

jsHint consideres JavaScript links harmful because they do not work well when bookmarked and it looks like a protocol (SO says "pseudo protocol" but if users were aware of "pseudo", it wouldn't be confusing). I guess VFC's user profile is advanced enough to understand the nature of JavaScript links. So I do not share the concerns jsHint brings up.
OTOH, your code looks sane, although I'd prefer if it'd be just one line of code; users might mess with it otherwise. If you do not agree with me, just post an edit request, and I'll or Steinsplitter will fulfil this. -- Rillke(q?) 07:04, 21 July 2015 (UTC)[reply]
Although I am not entirely happy with the code quality, it might be worth converting this into a gadget, given there are about 500 people using it. -- Rillke(q?) 23:41, 23 July 2015 (UTC)[reply]
This should be possibly wrapped into an IIFE/ closure; visualFileChange is a link reference no one wants in the window scope and user scripts aren't wrapped by RL, AFAIK. -- Rillke(q?) 23:43, 23 July 2015 (UTC)[reply]

Broken JavaScript

[edit]

MediaWiki developers found that this page probably breaks JavaScript for users (example: not seeing the buttons when editing a page). You probably need to edit this .js page and/or MediaWiki:Gadgets-definition as in the examples at phabricator:T122755. List more pages to check.

If you have questions or need help, please ask at phabricator:T164242. You can login with your wiki account. Best wishes, Nemo 09:49, 14 May 2017 (UTC)[reply]