Redmine Status Highlighter

Highlight issue status etc. in redmine issue list and details

目前為 2015-03-24 提交的版本,檢視 最新版本

  1. // ==UserScript==
  2. // @name Redmine Status Highlighter
  3. // @namespace http://cbaoth.yav.in
  4. // @version 0.2.1
  5. // @description Highlight issue status etc. in redmine issue list and details
  6. //
  7. // Change "mydomain" or path "/redmine/" if needed:
  8. // @match *://*/*/issues*
  9. // @match *://*/issues/*
  10. // @match *://*/redmine/*/issues*
  11. // @match *://*/redmine/issues/*
  12. //
  13. // @require https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js
  14. // @copyright 2014, cbaoth@gmx.net
  15. // ==/UserScript==
  16.  
  17. // Basis: http://userscripts.org/scripts/source/177488.user.js
  18.  
  19. // Change the colors as desired (examples below)
  20.  
  21. // prevent jQuery version conflicts (with page)
  22. this.$ = this.jQuery = jQuery.noConflict(true);
  23.  
  24. (function(){
  25.  
  26. // CONFIG
  27. var ENABLE_PRIORITY = true; // highlight priority
  28. var ENABLE_STATUS = true; // highlight status (and custome fields)
  29. var ENABLE_IN_LIST = true; // highlight in issue list
  30. var ENABLE_IN_DETAILS = true; // highlight in issue detail view
  31. var DEV_TODO_ONLY = true; // just highlight things that could be dev todos
  32. var MY_NAME = "John Doe"; // for 'assigned to' highlighting
  33.  
  34. // which screen are we in
  35. var screen = 0;
  36. if (/\/issues\//.test(window.location.pathname)) {
  37. screen = 2; // detail screen
  38. } else {
  39. screen = 1; // list screen
  40. }
  41. // not enabled for current screen?
  42. if ((screen == 1 && !ENABLE_IN_LIST) || (screen == 2 && !ENABLE_IN_DETAILS)) {
  43. return;
  44. }
  45.  
  46. // -- PRIORITY ----------------------------------------------------------------
  47. if (ENABLE_PRIORITY) {
  48. var priorityList = $('.priority');
  49. jQuery.each(priorityList, function(i, elem){
  50. text = $(elem).text().trim();
  51. if (text == "Immediate") $(elem).css("background-color", "#FBA"); // red
  52. if (text == "Urgent") $(elem).css("background-color", "#FCA"); // orange
  53. if (text == "High") $(elem).css("background-color", "#FE8"); // gold
  54. if (text == "Normal") $(elem).css("background-color", "#DFF7FF"); // light blue
  55. if (text == "Low") $(elem).css("background-color", "#DFE"); // light mint
  56. });
  57. }
  58.  
  59. // -- STATUS ------------------------------------------------------------------
  60. if (ENABLE_STATUS) {
  61. var statusList = $('.status');
  62. jQuery.each(statusList, function(i, elem){
  63. text = $(elem).text().trim();
  64. // change statuses and colors here
  65. if (text == "New") $(elem).css("background-color", "#FBA"); // red
  66. if (text == "Feedback") $(elem).css("background-color", "#FBF"); // pink
  67. if (text == "In Progress") $(elem).css("background-color", "#FE8"); // gold
  68. if (!DEV_TODO_ONLY) { // ignore the following (not critical for devs)
  69. if(text == "Resolved") $(elem).css("background-color", "#DFE"); // light mint
  70. if(text == "Closed") $(elem).css("background-color", "#DDD"); // grey
  71. if(text == "Rejected") $(elem).css("background-color", "#FB9"); // red/orange
  72. }
  73. });
  74. }
  75. // Assigned To
  76. var assignedTo = $('.assigned_to');
  77. jQuery.each(assignedTo, function(i, elem){
  78. text = $(elem).text().trim();
  79. if (text == MY_NAME) $(elem).css("background-color", "#FE8"); // gold
  80. });
  81. })();