Last active
August 29, 2015 14:00
-
-
Save coolaj86/11355252 to your computer and use it in GitHub Desktop.
For updating URLs at http://theldssinglessite.com/YSAsingleswards.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var js = document.createElement('script') | |
; | |
js.src = "//code.jquery.com/jquery-1.11.0.min.js"; | |
document.head.appendChild(js); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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") | |
); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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