/*! CPAN Distributions List - v1.0.3 - 2016-04-16
* https://github.com/guillaumeaubert/jquery-cpan-distributions-list
* Copyright (c) 2016 Guillaume Aubert; Licensed MIT */
!function(a){function b(b,d){a.ajax({type:"GET",async:!0,dataType:"json",url:"https://api.metacpan.org/v0/release/_search?q=author:"+d.pause_id+"%20AND%20status:latest&fields=version,distribution,date,tests&size=100&sort=distribution",success:function(f){return"false"===f.timed_out?void alert("MetaCPAN timed out ("+f.timed_out+")!"):0===f.hits.total?void alert("MetaCPAN returned no distributions for this author!"):(a(".cpan_distributions_count").html(f.hits.total),f.hits.hits.forEach(function(a,c){e(b,d,c,a.fields)}),void c(b,d))},error:function(a){console.log("Error querying MetaCPAN for information about the distributions: "+a.statusText)}})}function c(b,e,f){"undefined"==typeof f&&(f=1),a.ajax({type:"GET",async:!0,dataType:"json",url:"https://api.github.com/users/"+e.github_id+"/repos?page="+f+"&per_page=100",success:function(g){if(g.length<=0)return void(e.on_success&&e.on_success(g));g.forEach(function(c){var f=c.name,g=d(e,f);b.find("tr#distribution_"+f+" td.github_open_issues").html(a("").attr("href","https://github.com/"+e.github_id+"/"+g+"/issues").html(c.open_issues_count))});var h="undefined"==typeof e.max_github_requests?5:e.max_github_requests;h>f&&c(b,e,f+1)},error:function(a){console.log("Error querying GitHub for repository information: "+a.statusText)}})}function d(a,b){return a.repositories[b]?a.repositories[b]:a.repository_lowercase?b.toLowerCase():b}function e(b,c,e,f){var g=f.distribution,h=d(c,g);"undefined"==typeof f.tests&&(f.tests={pass:"",fail:"",na:"",unknown:""});var i={distribution:g,"metacpan-distname":a("").attr("href","https://metacpan.org/release/"+g).html(g),version:f.version,date:f.date,travis_status_badge:c.travis_ci?a("").attr("href","https://travis-ci.org/"+c.github_id+"/"+h).html(a("").attr("src","https://travis-ci.org/"+c.github_id+"/"+h+".svg?branch=master").attr("alt","Build Status")):"",coveralls_badge:c.coveralls?a("").attr("href","https://coveralls.io/r/"+c.github_id+"/"+h+"?branch=master").html(a("").attr("src","https://coveralls.io/repos/"+c.github_id+"/"+h+"/badge.svg?branch=master").attr("alt","Coverage Status")):"",github:a("").attr("href","https://github.com/"+c.github_id+"/"+h).html("GitHub"),metacpan:a("").attr("href","https://metacpan.org/release/"+g).html("MetaCPAN"),cpants:a("").attr("href","http://cpants.cpanauthors.org/dist/"+g).html("CPANTS"),"cpan-testers-pass":f.tests.pass,"cpan-testers-fail":f.tests.fail,"cpan-testers-na":f.tests.na,"cpan-testers-unknown":f.tests.unknown},j=c.template_row.clone();for(var k in i)j.find("."+k).html(i[k]);j.css("display",""),j.attr("id","distribution_"+g),j.addClass("distribution"),j.removeClass("template"),b.find("tbody:last").append(j)}a.fn.createDistributionsList=function(c){var d=this;d.find("tbody:last tr.distribution").remove();var e=a.extend({pause_id:"AUBERTG",github_id:"guillaumeaubert",coveralls:!0,travis_ci:!0,repositories:{},repository_lowercase:!1,template_row:this.find("tr.template:first")},c);b(d,e)}}(jQuery);