Page MenuHomePhabricator

Add wgAction to JS variables
Closed, ResolvedPublic

Description

Please add wgAction to JavaScript variables rendered at the beginning of the
page with values similar to action parameter in URL + default value could be
either empty or "view".

Some scripts should be triggered only if certain action with page is being done
and it's much easier to check the variable instead of having to get it from URL.

Thanks


Version: unspecified
Severity: enhancement

Details

Reference
bz8421

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 21 2014, 9:35 PM
bzimport set Reference to bz8421.
bzimport added a subscriber: Unknown Object (MLST).

ayg wrote:

I don't think we want to add tons of superfluous variables. Is it hard to do
var action =
window.location.search.match(/^action=[^&]*|&action=[^&]*/i).replace(/[^=]*=/,
""); or whatever? I mean, it's a mouthful for sure, but it's not like the
proposed variable would be very useful. Inclined to WONTFIX.

As a JS programmer myself I'd be inclined to WONFIX as well. The current
variables on there sometimes require nasty hacks to otherwise get, adding this
one isn't worth it as it can cleanly be retrieved otherwise.

(In reply to comment #2)

As a JS programmer myself I'd be inclined to WONFIX as well. The current
variables on there sometimes require nasty hacks to otherwise get, adding this
one isn't worth it as it can cleanly be retrieved otherwise.

Are you trying to say, that starting the entire regexp machine is better than
touch the variable?

And what does nasty hacking of _other variables_ (got an example? I'd say, if
you do nasty hacks, something is bad) have in common with adding of new simple one?

Action can't be cleanly retrieved from a URL; it may be present only in POST
data for form submissions or only indirectly through knowing how $wgActionPaths
are set up on the current wiki.