BlueCat Address Manager Resizable Columns

Dynamic Column Resizing in BlueCat Address Manager

当前为 2018-09-13 提交的版本,查看 最新版本

  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 8
  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. }
  72.  
  73. // general styling function
  74. function addGlobalStyle(css) {
  75. var head, style;
  76. head = document.getElementsByTagName('head')[0];
  77. if (!head) { return; }
  78. style = document.createElement('style');
  79. style.type = 'text/css';
  80. style.innerHTML = css;
  81. head.appendChild(style);
  82. }
  83.  
  84. // add resize cursor to table header
  85. addGlobalStyle("*[id^='header'] { cursor: col-resize; }");