Skip to content

Instantly share code, notes, and snippets.

@coolaj86
Last active August 29, 2015 14:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save coolaj86/11355252 to your computer and use it in GitHub Desktop.
Save coolaj86/11355252 to your computer and use it in GitHub Desktop.
var js = document.createElement('script')
;
js.src = "//code.jquery.com/jquery-1.11.0.min.js";
document.head.appendChild(js);
// For updating URLs at http://theldssinglessite.com/YSAsingleswards.html in-place
$('a[href^="https://secure.lds.org/units/stake"]').each(function (i, el) {
$(el).attr(
'href'
, 'https://www.lds.org/maps/#m=google.road&find=stake.ysa:'
+ $(el).attr('href').replace(/.+-(\d+),.+/, "$1")
);
});
$('a[href^="https://secure.lds.org/units/home"]').each(function (i, el) {
$(el).attr(
'href'
, 'https://www.lds.org/maps/#m=google.road&find=ward.ysa:'
+ $(el).attr('href').replace(/.+-(\d+),.+/, "$1")
);
});
// To get ids to try with
// https://www.lds.org/maps/services/layers/details?id=234400&layer=ward.ysa&lang=eng
var maps = {};
$($($($('table')[2]).find('p table')[1]).find('tr')).each(function (i, el) {
var stakeHref = $(el).find('a[href^="https://secure.lds.org/units/stake"]').attr('href') || ''
, wardHref = $(el).find('a[href^="https://secure.lds.org/units/home"]').attr('href') || ''
, stakeId = stakeHref.replace(/.+-(\d+),.+/, "$1")
, wardId = wardHref.replace(/.+-(\d+),.+/, "$1")
, newStakeHref = 'https://www.lds.org/maps/#m=google.road&find=stake.ysa:' + stakeId
, newWardHref = 'https://www.lds.org/maps/#m=google.road&find=ward.ysa:' + wardId
;
maps[stakeId] = maps[stakeId] || {};
maps[stakeId][wardId] = true;
$(el).find('a[href^="https://secure.lds.org/units/stake"]').attr('href', newStakeHref)
$(el).find('a[href^="https://secure.lds.org/units/home"]').attr('href', newWardHref)
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment