MediaWiki:Common.js: Difference between revisions
MediaWiki interface page
More actions
Content deleted Content added
No edit summary |
Updated VisualEdit button link fix |
||
| Line 1: | Line 1: | ||
/* Any JavaScript here will be loaded for all users on every page load. */ |
/* Any JavaScript here will be loaded for all users on every page load. */ |
||
/ |
/* Fix VisualEditor button to use pretty URL with ?veaction=edit */ |
||
$(function() { |
$(function() { |
||
var $veTab = $('#ca-ve-edit a'); |
var $veTab = $('#ca-ve-edit a'); |
||
| Line 9: | Line 9: | ||
var titleMatch = currentHref.match(/title=([^&]+)/); |
var titleMatch = currentHref.match(/title=([^&]+)/); |
||
if (titleMatch) { |
if (titleMatch) { |
||
var title = decodeURIComponent(titleMatch[1].replace(/ |
var title = decodeURIComponent(titleMatch[1]).replace(/ /g, '_'); // Replace spaces with _, leave : and / literal |
||
var prettyBase = '/' + |
var prettyBase = '/' + title; |
||
$veTab.attr('href', prettyBase + '?veaction=edit'); |
$veTab.attr('href', prettyBase + '?veaction=edit'); |
||
} |
} |
||
Revision as of 13:54, 21 February 2026
/* Any JavaScript here will be loaded for all users on every page load. */
/* Fix VisualEditor button to use pretty URL with ?veaction=edit */
$(function() {
var $veTab = $('#ca-ve-edit a');
if ($veTab.length) {
var currentHref = $veTab.attr('href');
if (currentHref.includes('index.php') && currentHref.includes('veaction=edit')) {
var titleMatch = currentHref.match(/title=([^&]+)/);
if (titleMatch) {
var title = decodeURIComponent(titleMatch[1]).replace(/ /g, '_'); // Replace spaces with _, leave : and / literal
var prettyBase = '/' + title;
$veTab.attr('href', prettyBase + '?veaction=edit');
}
}
}
});