Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update javascript to current versions #424

Merged
merged 13 commits into from
Sep 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions _layouts/default.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@

<script type="text/javascript" src={{ "/js/jquery.js" | prepend: site.baseurl }}></script>
<script src={{ "/bootstrap/js/bootstrap.min.js" | prepend: site.baseurl }} type="text/javascript"></script>
<script src={{ "/js/jquery-cookie-1.4.1/jquery.cookie.js" | prepend: site.baseurl }} type="text/javascript"></script>

<script src={{ "/js/jquery-cookie.js" | prepend: site.baseurl }} type="text/javascript"></script>-
{% include_cached google_analytics.html %}
<script type="text/javascript" src={{ "/js/toc.js" | prepend: site.baseurl }}></script>

Expand Down
2 changes: 1 addition & 1 deletion _layouts/search.html
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ <h4>No related system dependencies found.</h4>
</script>
{% endraw %}

<script src="{{site.baseurl}}/js/lunr.min.js" type="text/javascript" charset="utf-8"></script>
<script src="{{site.baseurl}}/js/lunr.js" type="text/javascript" charset="utf-8"></script>
<script src="{{site.baseurl}}/js/mustache.js" type="text/javascript" charset="utf-8"></script>
<script src="{{site.baseurl}}/js/pagination.js" type="text/javascript" charset="utf-8"></script>
<!--<script src="/js/date.format.js" type="text/javascript" charset="utf-8"></script>-->
Expand Down
147 changes: 62 additions & 85 deletions _layouts/stats.html
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ <h3>{{distro}} <small>{{hist_values[1] | size}} repos</small></h3>
</div>
</div>

<!--
Adapted from https://github.com/benfred/venn.js/blob/master/examples/intersection_tooltip.html
-->
<style>
.venn {
font-family: "Helvetica Neue",Helvetica,Arial,sans-serif;
Expand All @@ -74,97 +77,67 @@ <h3>{{distro}} <small>{{hist_values[1] | size}} repos</small></h3>
}
</style>

<script src="https://d3js.org/d3.v2.min.js"></script>
<script src="{{site.baseurl}}/js/venn.js/venn.js"></script>
<script src="https://d3js.org/d3.v6.min.js"></script>
<script src="{{site.baseurl}}/js/venn.js"></script>
<script src="{{site.baseurl}}/js/mds.js"></script>
<script src="{{site.baseurl}}/js/numeric-1.2.6.js"></script>
<script src="{{site.baseurl}}/js/numeric.js"></script>
<script>
// define sets and set set intersections
var sets = [
{% for distro in page.distro_counts %}
{label: "{{distro[0]}}", size: {{distro[1]}}},
{sets: ["{{distro[0]}}"], size: {{distro[1]}}},
{% endfor %}
],
overlaps = [
{% for ol in page.distro_overlaps %}
{sets: {{ol[0]}}, size: {{ol[1]}}},
{% endfor %}
];

// get positions for each set
sets = venn.venn(sets, overlaps, {layoutFunction: venn.classicMDSLayout});
sets = sets.concat(overlaps);

// draw the diagram in the 'venn' div
var diagram = venn.drawD3Diagram(d3.select(".venn"), sets, 500, 300);
var diagram = venn.VennDiagram();
var div = d3.select(".venn")
div.datum(sets).call(diagram);

// add a tooltip showing the size of each set/intersection
var tooltip = d3.select("body").append("div")
.attr("class", "venntooltip");

d3.selection.prototype.moveParentToFront = function() {
return this.each(function(){
this.parentNode.parentNode.appendChild(this.parentNode);
});
};
div.selectAll("path")
.style("stroke-opacity", 0)
.style("stroke", "#fff")
.style("stroke-width", 3)

// hover on all the circles
diagram.circles
.style("stroke-opacity", 0)
.style("stroke", "white")
.style("stroke-width", "2");
// add listeners to all the groups to display tooltip on mouseover
div.selectAll("g")
.on("mouseover", function(event, d) {
// sort all the areas relative to the current item
venn.sortAreas(div, d);

diagram.nodes
.on("mousemove", function() {
tooltip.style("left", (d3.event.pageX) + "px")
.style("top", (d3.event.pageY - 28) + "px");
})
.on("mouseover", function(d, i) {
var selection = d3.select(this).select("circle");
selection.moveParentToFront()
.transition()
.style("fill-opacity", .5)
.style("stroke-opacity", 1);

tooltip.transition().style("opacity", .9);
// Display a tooltip with the current size
tooltip.transition().duration(400).style("opacity", .9);
tooltip.text(d.size + " packages");
})
.on("mouseout", function(d, i) {
d3.select(this).select("circle").transition()
.style("fill-opacity", .3)
.style("stroke-opacity", 0);
tooltip.transition().style("opacity", 0);
});

// draw a path around each intersection area, add hover there as well
diagram.svg.selectAll("path")
.data(overlaps)
.enter()
.append("path")
.attr("d", function(d) {
return venn.intersectionAreaPath(d.sets.map(function(j) { return sets[j]; }));
})
.style("fill-opacity","0")
.style("fill", "black")
.style("stroke-opacity", 0)
.style("stroke", "white")
.style("stroke-width", "2")
.on("mouseover", function(d, i) {
d3.select(this).transition()
.style("fill-opacity", .1)
// highlight the current path
var selection = d3.select(this).transition("tooltip").duration(400);
selection.select("path")
.style("fill-opacity", d.sets.length == 1 ? .4 : .1)
.style("stroke-opacity", 1);
tooltip.transition().style("opacity", .9);
tooltip.text(d.size + " packages");
})
.on("mouseout", function(d, i) {
d3.select(this).transition()
.style("fill-opacity", 0)
.style("stroke-opacity", 0);
tooltip.transition().style("opacity", 0);
})
.on("mousemove", function() {
tooltip.style("left", (d3.event.pageX) + "px")
.style("top", (d3.event.pageY - 28) + "px");

.on("mousemove", function(event) {
tooltip.style("left", (event.pageX) + "px")
.style("top", (event.pageY - 28) + "px");
})

.on("mouseout", function(event, d) {
tooltip.transition().duration(400).style("opacity", 0);
var selection = d3.select(this).transition("tooltip").duration(400);
selection.select("path")
.style("fill-opacity", d.sets.length == 1 ? .25 : .0)
.style("stroke-opacity", 0);
});
</script>

<style>
Expand Down Expand Up @@ -210,58 +183,62 @@ <h3>{{distro}} <small>{{hist_values[1] | size}} repos</small></h3>
height = 150 - margin.top - margin.bottom;

var max_age = 2000;
var x = d3.scale.linear()
var x = d3.scaleLinear()
.domain([1, max_age])
.range([0, width]);

// Generate a histogram using twenty uniformly-spaced bins.
var data = d3.layout.histogram()
.bins(x.ticks(30))
(values);
// Generate a histogram using thirty uniformly-spaced bins.
var histogram = d3.histogram()
.domain(x.domain())
.thresholds(x.ticks(30))
var data = histogram(values)

var y = d3.scale.linear()
.domain([0, d3.max(data, function(d) { return d.y; })])
var y = d3.scaleLinear()
.domain([0, d3.max(data, function(d) { return d.length || 1; })])
.range([height, 0]);

var xAxis = d3.svg.axis()
.scale(x)
.orient("bottom");
var xAxis = d3.axisBottom()
.scale(x);

var svg = d3.select(selector).append("svg")
.attr("width", width + margin.left + margin.right)
.attr("height", height + margin.top + margin.bottom)
.append("g")
.attr("transform", "translate(" + margin.left + "," + margin.top + ")");
.attr("transform", function(d) {
return "translate(" + margin.left + "," + margin.top + ")";
});

var bar = svg.selectAll(".bar")
.data(data)
.enter().append("g")
.attr("class", "bar")
.attr("transform", function(d) { return "translate(" + x(d.x) + "," + y(d.y) + ")"; });
.attr("transform", function(d) { return "translate(" + x(d.x0) + "," + y(d.length) + ")"; });

var tooltip = d3.select("body").append("div")
.attr("class", "histtooltip");

bar.append("rect")
.attr("x", 1)
.attr("width", function(d) { return x(d.dx) - 1; })
.attr("height", function(d) { return height - y(d.y); })
.on("mouseover", function(d, i) {
.attr("width", function(d) { return x(d.x1) - x(d.x0)- 1; })
.attr("height", function(d) {
return height - y(d.length);
})
.on("mouseover", function(event, d) {
d3.select(this).transition()
.style("fill-opacity", .1)
.style("stroke-opacity", 1);
tooltip.transition().style("opacity", .9);
tooltip.text(d.y);
tooltip.text(d.length);
})
.on("mouseout", function(d, i) {
.on("mouseout", function(event, d) {
d3.select(this).transition()
.style("fill-opacity", 1)
.style("stroke-opacity", 0);
tooltip.transition().style("opacity", 0);
})
.on("mousemove", function() {
tooltip.style("left", (d3.event.pageX) + "px")
.style("top", (d3.event.pageY - 28) + "px");
.on("mousemove", function(event) {
tooltip.style("left", (event.pageX) + "px")
.style("top", (event.pageY - 28) + "px");
});

/*
Expand Down
8 changes: 8 additions & 0 deletions _plugins/rosindex_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1593,6 +1593,14 @@ def generate(site)
# create errors page
puts "Generating errors page...".blue
site.pages << ErrorsPage.new(site, @errors)

# remove symlinks in js to workaround issue #422
Dir.glob(File.join(site.dest, 'js', '*.js')) do |filename|
File.delete(filename) if File.symlink?(filename)
# needed for js/venn.js/venn.js
FileUtils.rm_rf(filename) if File.directory?(filename)
end

end

end
14 changes: 7 additions & 7 deletions _ruby_libs/pages.rb
Original file line number Diff line number Diff line change
Expand Up @@ -263,20 +263,20 @@ def initialize(site, package_names, all_repos, errors)

# compute venn diagram model
distro_counts = Hash[$recent_distros.collect { |d| [d, 0] }]
distro_overlaps = Hash[(2..$recent_distros.length).flat_map{|n| (0..$recent_distros.length-1).to_a.combination(n).to_a}.collect { |s| [s, 0] }]
distro_overlaps = Hash[(2..$recent_distros.length).flat_map{|n| $recent_distros.combination(n).to_a}.collect { |s| [s, 0] }]
puts 'distro_overlaps: ' + distro_overlaps.to_s

package_names.each do |package_name, package_instances|
overlap = []
#package_instances.snapshots.reject.with_index{|dr, i| dr[1].nil? || dr[1].version.nil? }
package_instances.snapshots.each.with_index do |s,i|
puts "s: " + s.to_s
if not s[1].nil? and not s[1].version.nil? and not distro_counts[s[0]].nil?
overlap << i
distro_counts[s[0]] = distro_counts[s[0]] + 1
package_instances.snapshots.each do |distro, s|
if not s.nil? and not s.version.nil? and not distro_counts[distro].nil?
overlap << distro
distro_counts[distro] += 1
end
end

dputs package_name.to_s + " " + overlap.to_s
puts package_name.to_s + " " + overlap.to_s

package_overlaps = (2..$recent_distros.length).flat_map{|n| overlap.combination(n).to_a}

Expand Down
2 changes: 1 addition & 1 deletion index.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ baseurl: "" # the subpath of your site, e.g. /blog/
url: "https://index.ros.org" # the base hostname & protocol for your site
#twitter_username: jekyllrb
github_username: ros-infrastructure/rosindex
keep_files: [cache, .git]
# keep_files: [cache, .git]

# Sources
rosdep_path: _remotes/rosdep
Expand Down
Loading
Loading