MediaWiki:Common.js: Difference between revisions

Content deleted Content added
load MediaWiki:SupportPage.js on any page with a .language-switcher element too
No edit summary
 
(6 intermediate revisions by the same user not shown)
Line 5:
$(function() {
 
mw.loader.using( ['mediawiki.util', 'mediawiki.Uri'] ).done( function() {
 
// If Jimmy tweets a bare link to https://donate.wikimedia.org/w/index.php?title=Special:LandingPage
// we are gonna have a bad time as geolocation doesn't happen. Do a redirect to send them round again
try {
var uriurl = new mw.UriURL( window.location.href );
if (
if ( uri.query.title === 'Special:LandingPage' && uri.query.country === undefined && uri.query.retried === undefined ) {
url.searchParams.get( 'title' ) === 'Special:LandingPage' &&
url.searchParams.get( 'country' ) === null &&
url.searchParams.get( 'retried' ) === null
}); {
console.log( 'redirecting to pick up country parameter' );
uriurl.pathpathname = '/';
uriurl.querysearchParams.set( 'retried =', 1 ); // only do this once
delete uriurl.querysearchParams.delete( 'title' );
window.location.href = uriurl.toString();
}
} catch (error) {
Line 67 ⟶ 71:
document.getElementById('country-select-go').addEventListener( 'click', function(e) {
if ( countrySelect.value ) {
// Chapter countries, use the built-in donatewiki redirects
mw.loader.using( ['mediawiki.Uri'] ).done( function() {
uri.query.countryif =( countrySelect.value; === 'DE' ) {
var uri = new mw.Uri( document.location.href );
window.location = 'https://donate.wikimedia.org/?country=DE';
uri.query.country = countrySelect.value;
} else if ( countrySelect.value === 'CH' ) {
document.location = uri.toString();
window.location = 'https://donate.wikimedia.org/?country=CH';
});
} else {
var uriurl = new mw.UriURL( document.location.href );
url.searchParams.set( 'country', countrySelect.value );
documentwindow.location = uriurl.toString();
}
}
});
Line 85 ⟶ 94:
if ( document.getElementById('geolocate-error') ) {
enableCountrySelect();
}
// Fundraise Up privacy footer
if ( mw.util.getParamValue('fundraiseupScript') ) {
document.getElementById('donate-privacy-third-party').style.display = 'block';
}