MediaWiki:Common.js: Difference between revisions
Jump to navigation
Jump to search
Content deleted Content added
No edit summary |
extra code for country select: translations etc |
||
Line 40: | Line 40: | ||
// Allow manual country selection and reload |
// Allow manual country selection and reload |
||
// Run this only when needed |
|||
⚫ | |||
var enableCountrySelect = function() { |
|||
⚫ | |||
var language = mw.config.get('wgPageContentLanguage'), |
|||
⚫ | |||
⚫ | |||
if ( countrySelect.value ) { |
|||
⚫ | |||
// Translations |
|||
⚫ | |||
if ( language !== 'en' && language !== 'en-gb' ) { |
|||
⚫ | |||
const translationsUrl = 'https://donate.wikimedia.org/wiki/Module:Country_links/data.json?action=raw' |
|||
⚫ | |||
$.getJSON( translationsUrl, function( translations ) { |
|||
}); |
|||
if ( translations[language] ) { |
|||
} |
|||
var list = Array.from( countrySelect.options ); |
|||
}); |
|||
list.forEach( option => { |
|||
} |
|||
option.innerText = translations[language][option.value] || option.innerText; |
|||
}); |
|||
// Sort for new language |
|||
list.sort( function(a, b) { |
|||
return a.innerText.localeCompare( b.innerText ); |
|||
}); |
|||
for ( var i = 0; i < list.length; i++ ) { |
|||
list[i].parentNode.appendChild( list[i] ); |
|||
} |
|||
} |
|||
}); |
|||
} |
|||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
}); |
|||
} |
|||
}); |
|||
} |
|||
if ( document.getElementById('country-select') ) { |
|||
enableCountrySelect(); |
|||
} |
|||
// Code for Thank You pages - https://donate.wikimedia.org/wiki/MediaWiki:ThankYouPage.js |
// Code for Thank You pages - https://donate.wikimedia.org/wiki/MediaWiki:ThankYouPage.js |