BlueCat Address Manager Resizable Columns

Dynamic Column Resizing in BlueCat Address Manager

当前为 2018-12-04 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name BlueCat Address Manager Resizable Columns
  3. // @namespace *
  4. // @description Dynamic Column Resizing in BlueCat Address Manager
  5. // @include */app*
  6. // @version 9
  7. // @grant none
  8. // @author Marius Galm
  9. // @copyright 2018, Marius Galm
  10. // @license MIT
  11. // @icon https://www.bluecatnetworks.com/wp-content/uploads/2018/03/cropped-bluecat-favicon-32x32.png
  12. // @require http://code.jquery.com/jquery-latest.min.js
  13. // ==/UserScript==
  14.  
  15. //jQuery fix - is now broken or not necessary any more
  16. //this.$ = this.jQuery = jQuery.noConflict(true);
  17.  
  18. // declare used function
  19. function reSize() {
  20. $(function() {
  21. var pressed = false;
  22. var start = undefined;
  23. var startX, startWidth;
  24.  
  25. $("table th").mousedown(function(e) {
  26. start = $(this);
  27. pressed = true;
  28. startX = e.pageX;
  29. startWidth = $(this).width();
  30. $(start).addClass("resizing");
  31. });
  32.  
  33. $(document).mousemove(function(e) {
  34. if(pressed) {
  35. if(startWidth+(e.pageX-startX) > 9 ) {
  36. $(start).width(startWidth+(e.pageX-startX));
  37. }
  38. }
  39. });
  40.  
  41. $(document).mouseup(function() {
  42. if(pressed) {
  43. $(start).removeClass("resizing");
  44. pressed = false;
  45. $(start).style.cursor;
  46. }
  47. });
  48. });
  49. }
  50.  
  51. // do something on specific pages
  52. if (document.readyState === "interactive" ) {
  53. var page = document.childNodes[2].nodeValue;
  54. if (/Page: AddEdit/.test(page)) {
  55. page = "AddEditDummy";
  56. } else if (/Page: Edit/.test(page)) {
  57. page = "AddEditDummy";
  58. }
  59. switch(page) {
  60. case " Page: SystemInformation ":
  61. break;
  62. case " Page: UpdateSystem ":
  63. break;
  64. case "AddEditDummy":
  65. break;
  66. case " Page: AllocateIP4Address ":
  67. break;
  68. default:
  69. reSize();
  70. }
  71. var links = document.getElementsByTagName("link");
  72. var linksList = Array.prototype.slice.call(links);
  73. linksList.forEach(function(link) {
  74. if (link.href.includes("/cached-style/proteus-silver.css")) {
  75. var sheet = link.sheet;
  76. var rule = "table.value-table { table-layout: auto; }";
  77. sheet.insertRule(rule,0);
  78. }
  79. });
  80. }
  81.  
  82. // general styling function
  83. function addGlobalStyle(css) {
  84. var head, style;
  85. head = document.getElementsByTagName('head')[0];
  86. if (!head) { return; }
  87. style = document.createElement('style');
  88. style.type = 'text/css';
  89. style.innerHTML = css;
  90. head.appendChild(style);
  91. }
  92.  
  93. // add resize cursor to table header
  94. addGlobalStyle("*[id^='header'] { cursor: col-resize; }");