JIRA - Show Total Number of Points for Each Column

Displays the total amount of points in each column of your board

当前为 2016-01-24 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name JIRA - Show Total Number of Points for Each Column
  3. // @namespace chriskim06
  4. // @description Displays the total amount of points in each column of your board
  5. // @include https://*jira*com/secure/*Board*
  6. // @require http://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js
  7. // @require https://greasyfork.org/scripts/5392-waitforkeyelements/code/WaitForKeyElements.js?version=19641
  8. // @version 1.0.1
  9. // @grant none
  10. // @locale en
  11. // ==/UserScript==
  12.  
  13. this.$ = this.jQuery = jQuery.noConflict(true);
  14.  
  15. waitForKeyElements('#ghx-pool', getNumPoints);
  16. // jNode is the board
  17. function getNumPoints(jNode) {
  18. var columns = {};
  19. var columnHeaders = $('#ghx-column-headers');
  20. columnHeaders.children('li').each(function() {
  21. columns[$(this).attr('data-id')] = 0;
  22. });
  23. // For each column...
  24. $('.ghx-columns > .ghx-column.ui-sortable').each(function() {
  25. var id = $(this).attr('data-column-id');
  26. // Get each ticket and...
  27. $(this).children('div').each(function() {
  28. // Add it to the total
  29. var points = parseInt($(this).find('.ghx-end').find('span.aui-badge').html(), 10);
  30. if (points > 0) {
  31. columns[id] += points;
  32. }
  33. });
  34. });
  35. // Append the total point value for this column to the column's name
  36. columnHeaders.children('li').each(function() {
  37. var columnId = $(this).attr('data-id');
  38. var columnTitle = $(this).find('h2');
  39. console.log(columns[columnId]);
  40. columnTitle.append(' (' + columns[columnId] + ')');
  41. console.log("POINTS - " + columnTitle.html());
  42. });
  43. }