Skip to content

Instantly share code, notes, and snippets.

@gartnera
Last active April 2, 2016 21:46
Show Gist options
  • Save gartnera/912f25150ef93a45138d to your computer and use it in GitHub Desktop.
Save gartnera/912f25150ef93a45138d to your computer and use it in GitHub Desktop.
webadvisor json roster creator
!function(e,t){"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?module.exports=t():e.download=t()}(this,function(){return function e(t,n,o){function a(e){var t=e.split(/[:;,]/),n=t[1],o="base64"==t[2]?atob:decodeURIComponent,a=o(t.pop()),r=a.length,i=0,d=new Uint8Array(r);for(i;r>i;++i)d[i]=a.charCodeAt(i);return new h([d],{type:n})}function r(e,t){if("download"in m)return m.href=e,m.setAttribute("download",v),m.className="download-js-link",m.innerHTML="downloading...",b.body.appendChild(m),setTimeout(function(){m.click(),b.body.removeChild(m),t===!0&&setTimeout(function(){c.URL.revokeObjectURL(m.href)},250)},66),!0;if("undefined"!=typeof safari)return e="data:"+e.replace(/^data:([\w\/\-\+]+)/,s),window.open(e)||confirm("Displaying New Document\n\nUse Save As... to download, then click back to return to this page.")&&(location.href=e),!0;var n=b.createElement("iframe");b.body.appendChild(n),t||(e="data:"+e.replace(/^data:([\w\/\-\+]+)/,s)),n.src=e,setTimeout(function(){b.body.removeChild(n)},333)}var i,d,l,c=window,s="application/octet-stream",f=o||s,u=t,p=!n&&!o&&u,b=document,m=b.createElement("a"),w=function(e){return String(e)},h=c.Blob||c.MozBlob||c.WebKitBlob||w,v=n||"download";if(h=h.call?h.bind(c):Blob,"true"===String(this)&&(u=[u,f],f=u[0],u=u[1]),p&&p.length<2048&&(v=p.split("/").pop().split("?")[0],m.href=p,-1!==m.href.indexOf(p))){var l=new XMLHttpRequest;return l.open("GET",p,!0),l.responseType="blob",l.onload=function(t){e(t.target.response,v,s)},l.send(),l}if(/^data\:[\w+\-]+\/[\w+\-]+[,;]/.test(u))return navigator.msSaveBlob?navigator.msSaveBlob(a(u),v):r(u);if(i=u instanceof h?u:new h([u],{type:f}),navigator.msSaveBlob)return navigator.msSaveBlob(i,v);if(c.URL)r(c.URL.createObjectURL(i),!0);else{if("string"==typeof i||i.constructor===w)try{return r("data:"+f+";base64,"+c.btoa(i))}catch(y){return r("data:"+f+","+encodeURIComponent(i))}d=new FileReader,d.onload=function(e){r(this.result)},d.readAsDataURL(i)}return!0}});
function download(e,t,n){function o(e){var t=e.split(/[:;,]/),n=t[1],o="base64"==t[2]?atob:decodeURIComponent,a=o(t.pop()),r=a.length,i=0,d=new Uint8Array(r);for(i;r>i;++i)d[i]=a.charCodeAt(i);return new p([d],{type:n})}function a(e,t){if("download"in f)return f.href=e,f.setAttribute("download",v),f.innerHTML="downloading...",s.body.appendChild(f),setTimeout(function(){f.click(),s.body.removeChild(f),t===!0&&setTimeout(function(){l.URL.revokeObjectURL(f.href)},250)},66),!0;var n=s.createElement("iframe");s.body.appendChild(n),t||(e="data:"+e.replace(/^data:([\w\/\-\+]+)/,c)),n.src=e,setTimeout(function(){s.body.removeChild(n)},333)}var r,i,d,l=window,c="application/octet-stream",u=n||c,b=e,s=document,f=s.createElement("a"),m=function(e){return String(e)},p=l.Blob||l.MozBlob||l.WebKitBlob||m,w=l.MSBlobBuilder||l.WebKitBlobBuilder||l.BlobBuilder,v=t||"download";if("true"===String(this)&&(b=[b,u],u=b[0],b=b[1]),String(b).match(/^data\:[\w+\-]+\/[\w+\-]+[,;]/))return navigator.msSaveBlob?navigator.msSaveBlob(o(b),v):a(b);try{r=b instanceof p?b:new p([b],{type:u})}catch(B){w&&(i=new w,i.append([b]),r=i.getBlob(u))}if(navigator.msSaveBlob)return navigator.msSaveBlob(r,v);if(l.URL)a(l.URL.createObjectURL(r),!0);else{if("string"==typeof r||r.constructor===m)try{return a("data:"+u+";base64,"+l.btoa(r))}catch(B){return a("data:"+u+","+encodeURIComponent(r))}d=new FileReader,d.onload=function(e){a(this.result)},d.readAsDataURL(r)}return!0}
var a = document.getElementById("GROUP_Grp_LIST_VAR7").children[2].children[0].children;
var c = [];
for (i = 2; i < a.length; ++i)
{
b = a[i].children;
name = b[1].innerText.trim();
id = b[2].innerText.trim();
email = b[4].innerText.trim();
phone = b[5].innerText.trim().split(" ")[0];
d = {"Student": name, "ID": id, "E-mail Address": email, "Phone Number": phone};
c.push(d);
}
download(JSON.stringify(c),"roster.json", "text/plain");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment