Skip to content

Instantly share code, notes, and snippets.

@chadmaughan
Last active January 31, 2017 05:04
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 chadmaughan/23c25cc0243acd5554e40bfd8e9e6b73 to your computer and use it in GitHub Desktop.
Save chadmaughan/23c25cc0243acd5554e40bfd8e9e6b73 to your computer and use it in GitHub Desktop.
Bookmarklet for downloading member callings in tabular format (CSV) from the LDS.org "Leader and Clerk Resources" section
Here's some instructions on how to create a Bookmarklet:
1) Copy the contents of the "lds-ward-member-callings-as-csv.min.js" file (make sure and get it all,
clicking the "Raw" button might help you copy it more easily).
2) In Chrome (other browsers should work), open the bookmark manager from the Bookmarks menu
(or ALT+COMMAND+B keyboard shortcut on a mac)
3) Right click in the "Organize" panel and select "Add Page"
4) Give the bookmark a "Name", and in the "URL" field, paste the contents copied from step 1
5) After logging in to LDS.org (while on any page) click on your bookmark (from the Bookmarks menu)
and your file will download!
javascript:(function(){
$.ajax({
type: "GET",
url: "/mls/mbr/services/report/members-with-callings",
cache: true,
contentType:"application/json; charset=utf-8",
dataType:"json",
xhrFields: {
withCredentials: true
},
success: function(resp) {
var output = '"Name","Organization","Calling","Sustained Date","Set Apart","Set Apart Date"\n';
for (var i = 0; i < resp.length; i++) {
var setApartDate = "";
if(resp[i].setApartDate !== null) {
var sdate = new Date(resp[i].setApartDate);
setApartDate = sdate.getFullYear() + '-' + (sdate.getMonth()+1) + '-' + sdate.getDate();
}
var cdate = new Date(resp[i].activeDate);
var calledDate = cdate.getFullYear() + '-' + (cdate.getMonth()+1) + '-' + cdate.getDate();
output += '"' + resp[i].name + '","' + resp[i].organization + '","' + resp[i].position + '","' + calledDate + '","' + resp[i].setApart + '","' + setApartDate + '"\n';
}
var a = document.createElement('a');
a.setAttribute('href', 'data:text/csv;charset=utf-8,' + encodeURIComponent(output));
a.setAttribute('download', 'callings.csv');
a.click();
}
});
})();
javascript:(function(){$.ajax({type:"GET",url:"/mls/mbr/services/report/members-with-callings",cache:!0,contentType:"application/json; charset=utf-8",dataType:"json",xhrFields:{withCredentials:!0},success:function(t){for(var e='"Name","Organization","Calling","Sustained Date","Set Apart","Set Apart Date"\n',a=0;a<t.length;a++){var n="";if(null!==t[a].setApartDate){var r=new Date(t[a].setApartDate);n=r.getFullYear()+"-"+(r.getMonth()+1)+"-"+r.getDate()}var i=new Date(t[a].activeDate),s=i.getFullYear()+"-"+(i.getMonth()+1)+"-"+i.getDate();e+='"'+t[a].name+'","'+t[a].organization+'","'+t[a].position+'","'+s+'","'+t[a].setApart+'","'+n+'"\n'}var c=document.createElement("a");c.setAttribute("href","data:text/csv;charset=utf-8,"+encodeURIComponent(e)),c.setAttribute("download","callings.csv"),c.click()}})})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment