Skip to content

Instantly share code, notes, and snippets.

@misbach
Forked from dovy/README.md
Created November 8, 2017 15:22
Show Gist options
  • Save misbach/c57334b7358eee2a21983b12080bd8da to your computer and use it in GitHub Desktop.
Save misbach/c57334b7358eee2a21983b12080bd8da to your computer and use it in GitHub Desktop.
A simple utility to help work with LDS.org Hometeaching for district leaders. Now updated to work for Presidency members as well.

What is this?

This is a utility to properly output all the assignments and teachers in a way that would allow easy email or text message generation.

Instructions

  • Open Google Chrome (Should work on Firefox or Safari as well)
  • Go to this website: https://www.lds.org/htvt/?lang=eng#/companionships
  • Right click on the page, and click on Inspect
  • Click on the Console tab at the top.
  • Copy the code above and paste it in the console (starts with a > symbol, button of the window).

You will now see an output of all teachers, with their phone numbers, emails, and assignments. Making it TONS easier to do your reporting assignment.

var districts = {}
$('#organizeList .accordion-inner').each(function() {
el = $(this).find('#companionship-list');
var companionships = el.scope().district.companionships;
if (el.scope().district.name.indexOf('District') === -1) {
return;
}
console.log(el.scope().district.name);
console.log(companionships);
districts[el.scope().district.name] = companionships
var comps = []
jQuery.each(companionships, function(key, value) {
var data = {
'teachers' : [],
'assignments': []
}
jQuery.each(value.teachers, function(kkey, vvalue) {
if (!vvalue.individual) {
return;
}
var phone = "";
try {
var phone = vvalue.individual.phone.split('-').join('').split('(').join('').split(')').join('').split(' ').join().split(',').join('')
} catch(err) {
}
if (phone.length == 10) {
phone = phone.slice(0,3)+"-"+phone.slice(3,6)+"-"+phone.slice(6)
}
data['teachers'].push({
'given': vvalue.individual.givenName1.split(' ')[0],
'surname': vvalue.individual.surname,
'phone': phone,
'email': vvalue.individual.email,
'birthdate':vvalue.individual.birthdate.split('T')[0]
})
});
jQuery.each(value.assignments, function(kkey, vvalue) {
new_data = {
'given_names':[],
'surname': vvalue.individual.surname,
'new': vvalue.individual.tags
}
new_data['given_names'].push(vvalue.individual.family.headOfHouse.givenName1.split(' ')[0])
if (vvalue.individual.family.spouse) {
new_data['given_names'].push(vvalue.individual.family.spouse.givenName1.split(' ')[0])
}
new_data['names'] = new_data['given_names'].join(' & ')+' '+new_data['surname']
data['assignments'].push(new_data);
});
if ( data['teachers'].length > 0 ) {
data['teacher_names'] = data['teachers'][0]['given']+" "+data['teachers'][0]['surname']
data['teacher_emails'] = data['teachers'][0]['email']
data['teacher_phones'] = data['teachers'][0]['phone']
if (data['teachers'][1]) {
data['teacher_names'] += " & "+data['teachers'][1]['given']+" "+data['teachers'][1]['surname']
data['teacher_emails'] += ", "+data['teachers'][1]['email']
data['teacher_phones'] += ", "+data['teachers'][1]['phone']
}
comps.push(data)
console.log(
'Teachers: '+data['teacher_names']
)
console.log(
"Teacher's Emails: "+data['teacher_emails']
)
console.log(
"Teacher's Phones: "+data['teacher_phones']
)
}
data['assignment_names'] = ""
jQuery.each(data['assignments'], function(kkey, vvalue) {
if (data['assignment_names'] != "") {
data['assignment_names'] += " \n\t"
}
data['assignment_names'] += vvalue['names']
});
console.log("Assignments:\n\t"+data['assignment_names']);
});
});
console.log(districts);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment