-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathJenkins_Plugin_Popularity.user.js
70 lines (64 loc) · 2.85 KB
/
Jenkins_Plugin_Popularity.user.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
// ==UserScript==
// @name Jenkins Plugin Popularity
// @author https://github.com/daniel-beck
// @downloadURL https://raw.github.com/daniel-beck/jenkins-userscripts/master/Jenkins_Plugin_Popularity.user.js
// @description Enhancement of Jenkins Plugin Manager to show the popularity (number of known installations) of plugins
// @icon https://2.gravatar.com/avatar/ceb204ad3216b4594ba32364def06deb?r=x&s=32
// @namespace com.github.daniel-beck.jenkins-userscripts
// @include http://*/pluginManager/*
// @version 1.0
// @grant none
// @require http://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js
// ==/UserScript==
// Before you're able to use this, you need to make http://stats.jenkins-ci.org/plugin-installation-trend/latestNumbers.json
// available on your Jenkins server. The easiest solution is to place the file in the 'userContent' folder and update it manually
// or through a script.
(function ($) {
$.fn.addPopularity = function (pluginInfo) {
var rows = $(this);
rows.each(function() {
var row = $(this);
var pluginName = "";
var input = $("input[type=checkbox]", this);
if (input) {
var name = input.attr("name");
if (name && name.startsWith("plugin.") && name.endsWith(".default")) {
// is an element
pluginName = name.substring(7, name.length - 8);
} else if (input.attr("url")) {
pluginName = input.attr("url").substring(7);
}
} else {
pluginName = $(":first-child", this).attr("data");
}
if (pluginName == '') {
return;
}
if (pluginInfo[pluginName] == undefined) {
pluginInfo[pluginName] = 0;
}
// optionally hide plugins with fewer than a specific number of plugins
// XXX only really makes sense on the 'Available' tab!
//if (pluginInfo[pluginName] < 2500) {
// row.remove();
// return;
//}
row.append("<td data=" + pluginInfo[pluginName] + ">" + pluginInfo[pluginName] + "</td>");
});
};
})(jQuery);
jQuery(document).ready(function(){
jQuery.noConflict();
jQuery('table#plugins tr:first-of-type').append("<th onclick='showhideCategories(this,0);'>Installations</th>");
/*
* CONFIGURE THIS LINE TO POINT TO THE JSON FILE WITH CURRENT INSTALLATION NUMBERS
*/
jQuery.getJSON("/userContent/latestNumbers.json", function(data, status) {
var pluginInfo = data.plugins;
jQuery('table#plugins tr').addPopularity(pluginInfo);
});
// tr.plugin only on first two tabs..
jQuery('table#plugins tr.plugin-category').each(function() {
$(this).attr('colspan', 5);
});
});