User:Pcoombe (WMF)/FRgeotarget.js
Note: After publishing, you may have to bypass your browser's cache to see the changes.
- Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
- Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
- Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
- Opera: Press Ctrl-F5.
function selectAllCountries( x ) {
var selectBox = document.getElementById('geo_countries[]');
var firstSelect = selectBox.options.length - 1;
for (var i = firstSelect; i >= 0; i--) {
selectBox.options[i].selected = x;
}
var noList = new Array('IR','CU','SY');
for (var i = 0; i < selectBox.options.length; i++) {
var c = selectBox.options[i].value;
if (noList.toString().indexOf(c)!==-1) {
selectBox.options[i].selected = false;
}
}
}
function selectEN() {
var selectBox = document.getElementById('geo_countries[]');
var noList = new Array('US','CH','DE','FR','GF','PF','TF','GP','MQ','YT','NC','RE','PM','WF','GB','BM','IO','VG','KY','FK','GI','MS','PN','SH','TC','IR','CU','SY');
selectAllCountries(true);
for (var i = 0; i < selectBox.options.length; i++) {
var c = selectBox.options[i].value;
if (noList.toString().indexOf(c)!==-1) {
selectBox.options[i].selected = false;
}
}
}
function selectGBplus() {
var selectBox = document.getElementById('geo_countries[]');
var GBplus = new Array('GB', 'BM', 'IO', 'VG', 'KY', 'FK', 'GI', 'MS', 'PN', 'SH', 'TC');
selectAllCountries(false);
for (var i = 0; i < selectBox.options.length; i++) {
var c = selectBox.options[i].value;
if (GBplus.toString().indexOf(c)!==-1) {
selectBox.options[i].selected = true;
}
}
}
function selectFRplus() {
var selectBox = document.getElementById('geo_countries[]');
var GBplus = new Array('FR', 'GF', 'PF', 'TF', 'GP', 'MQ', 'YT', 'NC', 'RE', 'PM', 'WF');
selectAllCountries(false);
for (var i = 0; i < selectBox.options.length; i++) {
var c = selectBox.options[i].value;
if (GBplus.toString().indexOf(c)!==-1) {
selectBox.options[i].selected = true;
}
}
}
$("#geoMultiSelector select").after('<div><img style="vertical-align:baseline;" src="http://bits.wikimedia.org/w/extensions-1.17/CentralNotice/up-arrow.png">Select: <a onclick="selectAllCountries(true); return false;" href="#">All</a>, <a onclick="selectEN(); return false;" href="#">EN</a>, <a onclick="selectGBplus(); return false;" href="#">GB+territories</a>, <a onclick="selectFRplus(); return false;" href="#">FR+territories</a> </div>');