function profileGen(username, container) { queryAPIByUser("", username, (user) => { if(!user.hasOwnProperty("id")) { alert("User Does Not Exist"); window.location.href = "./GraphGenerator.html"; } parseOrgs(user.login).then( (orgsReturn) => { let html = "
\ \
\
\
"+ (user.name != null ? "
"+user.name+"
" : "") +" \
"+user.login+"
\
\
\
\ \
\ \
\
\

"+user.html_url+"

\ " + (user.blog != null ? "

"+user.blog+"

" : "")+" \
\ \
"; $("#"+container).html(html); }) }, () => { alert("User Does Not Exist"); window.location.href = "./GraphGenerator.html"; }); } function parseOrgs(name) { return new Promise( (resolve, reject) => { let urlpath = `api/users/${name}/orgs`; let orgs_final = []; queryUrl(urlpath, (orgs) => { var prom= []; for(var i = 0;i < orgs.length; i++) { prom.push( new Promise( (res, rej) => { url = orgs[i].url; queryUrl(url, (orgData) => { orgs_final.push(""); res(); }, (error) => { console.log(error); rej(error); console.error("error getting org info"); }); }) ) } Promise.all(prom).then(function() { resolve(orgs_final.join(" ")); }) }, (error) => { resolve([]); }); }) } function queryUrl(url, successCallBack, errorCallBack) { url = url.split("https://api.github.com/").join("api/"); $.ajax({ type:'GET', url: url, crossDomain: true, dataType: "json", success: successCallBack, error:errorCallBack, timeout: 3000 }); } function graphUrl(user) { return "/FriendsGraph.html?name="+user; } function timelineUrl(user) { return "/TimeLineGraph.html?name="+user; }