Page MenuHomePhabricator

User Javascripts cannot be redirected, nor use include, nor be restricted to edit screens.
Closed, DeclinedPublic

Description

As a translator of UI messages, I switch between skins a lot so as to find out how translations look like in various skins. Also, I have a lengthy list of additional buttons in the edit bar supporting translationsal work. They are loaded via JavaScripts in subpages of my user page, one for each skin.

Despite the fact that all look alike, I have to keep an identical copy for each skin.

#redirect [[User:.../common.js]]

{{:user:.../common.js}}

both were useful and make scripts easier to maintain, but unlike everywhere else, do not work for these JavaScripts.

My scripts do something useful only on edit screens. Else, they detect that there is no editbar, and quit. Imho, they should better not be loaded into other pages. This could be had e.g. by having specific action dependent scripts, such as:

:user:.../skinname.js/action=edit
:user:.../skinname.js/action=move

etc.


Version: unspecified
Severity: enhancement

Details

Reference
bz19252

Event Timeline

bzimport raised the priority of this task from to Lowest.Nov 21 2014, 10:40 PM
bzimport set Reference to bz19252.
bzimport added a subscriber: Unknown Object (MLST).

To include other scripts:

importScript('User:.../main.js');

To restrict scripts to certain actions:

if (wgAction == "edit") {

importScript('User:.../edit.js');

}

JavaScript isn't parsed before its loaded, so any wikitext features like transclusion can't work as scripts are just loaded into pages with action=raw.

The script för edit buttons should be:

if ((wgAction == "edit") || (wgAction == "submit")) {

importScript('User:.../edit.js');

}

Marking WONTFIX per comment #1. I don't think we're going to change Javascript pages to be parsed (can't seem to find the bug for it...)