diff --git a/dist/meet-the-fans.min.js b/dist/meet-the-fans.min.js index c32b968..78bfefe 100644 --- a/dist/meet-the-fans.min.js +++ b/dist/meet-the-fans.min.js @@ -1,4 +1,4 @@ -let reposH={"*":gitUser},totals={nbStars:0,nbForks:0},licensesH={};const repos=gitUser.repos;repos.forEach(e=>{totals.nbStars+=e.nbStars,totals.nbForks+=e.nbForks,reposH[e.name]=e;const t=licensesH[e.licenseName];t?t.repos.push(e.name):licensesH[e.licenseName]={id:e.licenseName,repos:[e.name]}}),gitUser.nbStars=totals.nbStars,gitUser.nbForks=totals.nbForks,gitUser.name="*",fans[gitUser.login]&&delete fans[gitUser.login];const size=e=>5+2*(e.starred.length+e.forked.length),userColorGroup=e=>e.forked.length?e.starred.length?"both":"fork":e.follower?"follower":"star",getData=()=>{let o=[],r=[];for(var t in repos.forEach((e,t)=>{e.group=t+2,o.push({id:e.name,oType:"repo",radius:Math.min(10+e.nbStars/10,100),group:e.group,isRepo:!0}),r.push({source:"*",target:e.name,value:4})}),repos.push({name:"*",description:"Evoluteur"}),o.push({id:"*",radius:20,group:0,isRepo:!0}),fans){const s=fans[t];o.push({id:t,radius:size(s),oType:"user",group:userColorGroup(s)}),s.starred.forEach(e=>r.push({source:t,target:e,value:1})),s.forked.forEach(e=>{s.starred.includes(e)||r.push({source:t,target:e,value:1})})}return{nodes:o,links:r}},height=config.height||2e3,width=config.width||2500,userColors=config.userColors,colorFaded=config.colorFaded||"#eeeeee",circleBorder=config.circleBorder||"white",lineColor=config.lineColor||"white",scaleProject=d3.scaleOrdinal(d3.schemeCategory10),color=e=>e.isRepo?scaleProject(e.group):userColors[e.group],linksDistance=config.linksDistance||50,linksCharge=config.linksDistance||-30,drag=t=>{return d3.drag().on("start",e=>{e.active||t.alphaTarget(.3).restart(),e.subject.fx=e.subject.x,e.subject.fy=e.subject.y}).on("drag",e=>{e.subject.fx=e.x,e.subject.fy=e.y}).on("end",e=>{e.active||t.alphaTarget(0),e.subject.fx=null,e.subject.fy=null})};let selectedRepo=null;const graph=e=>{var t=e.links,e=e.nodes,r=d3.select("body").append("div").attr("class","tooltip").style("opacity",0);const o=d3.forceSimulation(e).force("link",d3.forceLink(t).distance(50).id(e=>e.id)).force("charge",d3.forceManyBody().strength(-30)).force("center",d3.forceCenter(width/2,height/2)).force("collision",d3.forceCollide().radius(e=>e.radius)),s=d3.create("svg").attr("viewBox",[0,0,width,height]).on("click",hideDetails),i=s.append("g");s.call(d3.zoom().extent([[0,0],[width,height]]).scaleExtent([1,8]).on("zoom",({transform:e})=>{i.attr("transform",e)}));const l=i.attr("stroke",lineColor).selectAll("line").data(t).join("line").attr("stroke-width",1),a=i.attr("stroke","#fff").attr("stroke-width",1.5).selectAll("circle").data(e).join("circle").attr("id",e=>e.id).attr("r",e=>e.radius).attr("stroke",circleBorder).attr("fill",color).attr("class",e=>e.oType).call(drag(o)).on("click",showDetails).on("mouseover",(e,t)=>{r.transition().duration(200).delay(400).style("opacity",.9);const o=r.html(t.isRepo?repoItem(reposH[t.id]):userTooltip(t));e.pageX+100>window.innerWidth?o.style("left",window.innerWidth-100+"px"):o.style("right",null).style("left",e.pageX+20+"px"),o.style("bottom",null).style("top",e.pageY+10+"px")}).on("mouseout",(e,t)=>{r.transition().duration(200).style("opacity",0)});return o.on("tick",()=>{l.attr("x1",e=>e.source.x).attr("y1",e=>e.source.y).attr("x2",e=>e.target.x).attr("y2",e=>e.target.y),a.attr("cx",e=>e.x).attr("cy",e=>e.y)}),s.node()},hideDetails=e=>{d3.selectAll("circle").transition().duration(600).style("fill",color).style("stroke",circleBorder),d3.selectAll("line").transition().duration(600).style("stroke",lineColor),selectedRepo=null},showDetails=(e,o)=>{if(e?.stopPropagation(),"rgb(238, 238, 238)"===e?.target?.style.fill&&"repo"!==o.oType)return null;if(!e?.detail?.skipModal){const s=document.getElementById("details");s.innerHTML=(o.isRepo&&"*"!==o.id?infoRepo:infoUser)(o.id),s.className=(o.x>width/2?"left":"right")+(o.isRepo?" w220":"")}let t,r=e=>o.id!==e.source.id&&o.id!==e.target.id;"repo"===o.oType?(selectedRepo=o.id,t=e=>{if("repo"===e.oType)return o.id!==e.id||""==e.id;{const t=fans[e.id];return!!t&&!(t.starred.includes(o.id)||t.forked.includes(o.id))}},d3.selectAll("circle").transition().duration(600).style("fill",e=>t(e)?colorFaded:color(e)).style("stroke",e=>t(e)?"#0288d1":circleBorder),d3.selectAll("line").transition().duration(600).style("stroke",e=>r(e)?colorFaded:lineColor).filter(e=>!r(e))):"user"===o.oType?(t=e=>{const t=fans[o.id];return!(t.starred.includes(e.id)||t.forked.includes(e.id))},r=e=>o.id===e.source.id,selectedRepo&&(d3.selectAll("circle.repo").transition().duration(600).style("fill",e=>t(e)?colorFaded:color(e)),r=e=>o.id===e.source.id,d3.selectAll("line").transition().duration(600).filter(r).style("stroke",lineColor))):hideDetails()},selectProject=e=>{var t=new CustomEvent("click",{detail:{skipModal:!0}});const o=document.getElementById(e);o&&o.dispatchEvent(t)},renderGraph=()=>{document.getElementById("graph").appendChild(graph(getData())),document.getElementById("details").onclick=e=>e.stopPropagation(),document.onclick=()=>document.getElementById("details").className="",setTimeout(()=>showDetails(null,{id:"*"}),10)},eMap={},$=e=>{var t=eMap[e];if(t)return t;t=document.getElementById(e);return t&&(eMap[e]=t),t},refreshRepos=(e,t)=>{$("reposList").innerHTML=repoList(e,!1,!0,!0),t&&($("summary-count").innerHTML=''+t+"")},onSearch=(e,t)=>{const o=e?.currentTarget?.value;var r,s=repos?.length||0;o?(e=(r=repos.filter(e=>e.name.includes(o))).length,refreshRepos(r,e+" / "+s)):refreshRepos(repos,s)};let sortDirection=1,lastSortKey="n";const onSort=(e,t)=>{e.stopPropagation(),lastSortKey===t?sortDirection=-sortDirection:(sortDirection=1,lastSortKey=t);t="s"===t?(e,t)=>sortDirection*(t.nbStars-e.nbStars):(e,t)=>sortDirection*e.name.localeCompare(t.name);refreshRepos(repos.sort(t))},searchBox=()=>`${repos?.length||""}`,sortOptions=()=>`
N
/
S
`,searchSortElems=()=>`
+let reposH={"*":gitUser},totals={nbStars:0,nbForks:0},licensesH={};const repos=gitUser.repos;repos.forEach(e=>{totals.nbStars+=e.nbStars,totals.nbForks+=e.nbForks,reposH[e.name]=e;const t=licensesH[e.licenseName];t?t.repos.push(e.name):licensesH[e.licenseName]={id:e.licenseName,repos:[e.name]}}),gitUser.nbStars=totals.nbStars,gitUser.nbForks=totals.nbForks,gitUser.name="*",fans[gitUser.login]&&delete fans[gitUser.login];const size=e=>5+2*(e.starred.length+e.forked.length),userColorGroup=e=>e.forked.length?e.starred.length?"both":"fork":e.follower?"follower":"star",getData=()=>{let o=[],r=[];repos.forEach((e,t)=>{e.group=t+2,o.push({id:e.name,oType:"repo",radius:Math.min(10+e.nbStars/10,100),group:e.group,isRepo:!0}),r.push({source:"*",target:e.name,value:4})}),repos.push({name:"*",description:"Evoluteur"}),o.push({id:"*",radius:20,group:0,isRepo:!0});for(let t in fans){const s=fans[t];o.push({id:t,radius:size(s),oType:"user",group:userColorGroup(s)}),s.starred.forEach(e=>r.push({source:t,target:e,value:1})),s.forked.forEach(e=>{s.starred.includes(e)||r.push({source:t,target:e,value:1})})}return{nodes:o,links:r}},height=config.height||2e3,width=config.width||2500,userColors=config.userColors,colorFaded=config.colorFaded||"#eeeeee",circleBorder=config.circleBorder||"white",lineColor=config.lineColor||"white",scaleProject=d3.scaleOrdinal(d3.schemeCategory10),color=e=>e.isRepo?scaleProject(e.group):userColors[e.group],linksDistance=config.linksDistance||50,linksCharge=config.linksDistance||-30,drag=t=>{return d3.drag().on("start",e=>{e.active||t.alphaTarget(.3).restart(),e.subject.fx=e.subject.x,e.subject.fy=e.subject.y}).on("drag",e=>{e.subject.fx=e.x,e.subject.fy=e.y}).on("end",e=>{e.active||t.alphaTarget(0),e.subject.fx=null,e.subject.fy=null})};let selectedRepo=null;const graph=e=>{var t=e.links,e=e.nodes,r=d3.select("body").append("div").attr("class","tooltip").style("opacity",0);const o=d3.forceSimulation(e).force("link",d3.forceLink(t).distance(50).id(e=>e.id)).force("charge",d3.forceManyBody().strength(-30)).force("center",d3.forceCenter(width/2,height/2)).force("collision",d3.forceCollide().radius(e=>e.radius)),s=d3.create("svg").attr("viewBox",[0,0,width,height]).on("click",hideDetails),i=s.append("g");s.call(d3.zoom().extent([[0,0],[width,height]]).scaleExtent([1,8]).on("zoom",({transform:e})=>{i.attr("transform",e)}));const l=i.attr("stroke",lineColor).selectAll("line").data(t).join("line").attr("stroke-width",1),a=i.attr("stroke","#fff").attr("stroke-width",1.5).selectAll("circle").data(e).join("circle").attr("id",e=>e.id).attr("r",e=>e.radius).attr("stroke",circleBorder).attr("fill",color).attr("class",e=>e.oType).call(drag(o)).on("click",showDetails).on("mouseover",(e,t)=>{r.transition().duration(200).delay(400).style("opacity",.9);const o=r.html(t.isRepo?repoItem(reposH[t.id]):userTooltip(t));e.pageX+100>window.innerWidth?o.style("left",window.innerWidth-100+"px"):o.style("right",null).style("left",e.pageX+20+"px"),o.style("bottom",null).style("top",e.pageY+10+"px")}).on("mouseout",(e,t)=>{r.transition().duration(200).style("opacity",0)});return o.on("tick",()=>{l.attr("x1",e=>e.source.x).attr("y1",e=>e.source.y).attr("x2",e=>e.target.x).attr("y2",e=>e.target.y),a.attr("cx",e=>e.x).attr("cy",e=>e.y)}),s.node()},hideDetails=e=>{d3.selectAll("circle").transition().duration(600).style("fill",color).style("stroke",circleBorder),d3.selectAll("line").transition().duration(600).style("stroke",lineColor),selectedRepo=null},showDetails=(e,o)=>{if(e?.stopPropagation(),"rgb(238, 238, 238)"===e?.target?.style.fill&&"repo"!==o.oType)return null;if(!e?.detail?.skipModal){const s=document.getElementById("details");s.innerHTML=(o.isRepo&&"*"!==o.id?infoRepo:infoUser)(o.id),s.className=(o.x>width/2?"left":"right")+(o.isRepo?" w220":"")}let t,r=e=>o.id!==e.source.id&&o.id!==e.target.id;"repo"===o.oType?(selectedRepo=o.id,t=e=>{if("repo"===e.oType)return o.id!==e.id||""==e.id;{const t=fans[e.id];return!!t&&!(t.starred.includes(o.id)||t.forked.includes(o.id))}},d3.selectAll("circle").transition().duration(600).style("fill",e=>t(e)?colorFaded:color(e)).style("stroke",e=>t(e)?"#0288d1":circleBorder),d3.selectAll("line").transition().duration(600).style("stroke",e=>r(e)?colorFaded:lineColor).filter(e=>!r(e))):"user"===o.oType?(t=e=>{const t=fans[o.id];return!(t.starred.includes(e.id)||t.forked.includes(e.id))},r=e=>o.id===e.source.id,selectedRepo&&(d3.selectAll("circle.repo").transition().duration(600).style("fill",e=>t(e)?colorFaded:color(e)),r=e=>o.id===e.source.id,d3.selectAll("line").transition().duration(600).filter(r).style("stroke",lineColor))):hideDetails()},selectProject=e=>{var t=new CustomEvent("click",{detail:{skipModal:!0}});const o=document.getElementById(e);o&&o.dispatchEvent(t)},renderGraph=()=>{document.getElementById("graph").appendChild(graph(getData())),document.getElementById("details").onclick=e=>e.stopPropagation(),document.onclick=()=>document.getElementById("details").className="",setTimeout(()=>showDetails(null,{id:"*"}),10)},eMap={},$=e=>{var t=eMap[e];if(t)return t;t=document.getElementById(e);return t&&(eMap[e]=t),t},refreshRepos=(e,t)=>{$("reposList").innerHTML=repoList(e,!1,!0,!0),t&&($("summary-count").innerHTML=''+t+"")},onSearch=(e,t)=>{const o=e?.currentTarget?.value;var r,s=repos?.length||0;o?(e=(r=repos.filter(e=>e.name.includes(o))).length,refreshRepos(r,e+" / "+s)):refreshRepos(repos,s)};let sortDirection=1,lastSortKey="n";const onSort=(e,t)=>{e.stopPropagation(),lastSortKey===t?sortDirection=-sortDirection:(sortDirection=1,lastSortKey=t);t="s"===t?(e,t)=>sortDirection*(t.nbStars-e.nbStars):(e,t)=>sortDirection*e.name.localeCompare(t.name);refreshRepos(repos.sort(t))},searchBox=()=>`${repos?.length||""}
`,sortOptions=()=>`
N
/
S
`,searchSortElems=()=>`
${searchBox()} ${sortOptions()}
`,repoArr=e=>e.sort((e,t)=>e.localeCompare(t)).map(e=>"*"===e?gitUser:reposH[e]),textField=(e,t)=>t?`
${t}
`:"",urlField=(e,t)=>e[t]?`
@@ -22,7 +22,7 @@ let reposH={"*":gitUser},totals={nbStars:0,nbForks:0},licensesH={};const repos=g ${s}
- ${r?`
+ ${r&&o?`
${condIcon("followers",e.nbFollowers)} ${condIcon("star",e.nbStars)} ${condIcon("fork",e.nbForks)} diff --git a/js/data.js b/js/data.js index c906c12..dffba03 100644 --- a/js/data.js +++ b/js/data.js @@ -68,7 +68,7 @@ const getData = () => { }); nodes.push({ id: "*", radius: 20, group: 0, isRepo: true }); - for (var u in fans) { + for (let u in fans) { const user = fans[u]; nodes.push({ id: u, diff --git a/js/queries.js b/js/queries.js index fd1d233..12305a3 100644 --- a/js/queries.js +++ b/js/queries.js @@ -179,7 +179,7 @@ const repoDetails = ` repositoryTopics(first:20){ nodes{ topic { - name + name } } } @@ -189,7 +189,7 @@ const repoDetails = ` repoRelease: releases(first:1){ totalCount nodes { - name + name publishedAt } } @@ -424,12 +424,7 @@ const showElem = (id) => document.getElementById(id).classList.remove("hidden"); const hideElem = (id) => document.getElementById(id).classList.add("hidden"); const dataSummary = () => - login + - ": " + - user.nbRepos + - " repos, " + - user.nbStars + - " stars, " + + `${login}: ${user.nbRepos} repos, ${user.nbStars} stars, ` + user.nbForks + " forks, " + user.nbFollowers + diff --git a/js/views.js b/js/views.js index 72b39dd..6147702 100644 --- a/js/views.js +++ b/js/views.js @@ -226,7 +226,7 @@ const repoItem = (r, skipMe, withSummary = true) => {
${ - isMe + isMe && withSummary ? `
${condIcon("followers", r.nbFollowers)} ${condIcon("star", r.nbStars)}