BlueCat Address Manager Resizable Columns

Dynamic Column Resizing in BlueCat Address Manager

当前为 2018-06-05 提交的版本,查看 最新版本

  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 6
  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-300x300.png
  12. // @require http://code.jquery.com/jquery-latest.js
  13. // ==/UserScript==
  14.  
  15. //jQuery fix
  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. }
  46. });
  47. });
  48. }
  49.  
  50. // do something on specific pages
  51. if (document.readyState === "interactive" ) {
  52. var page = document.childNodes[2].nodeValue;
  53. if (/Page: AddEdit/.test(page)) {
  54. page = "AddEditDummy";
  55. } else if (/Page: Edit/.test(page)) {
  56. page = "AddEditDummy";
  57. }
  58. switch(page) {
  59. case " Page: SystemInformation ":
  60. break;
  61. case " Page: UpdateSystem ":
  62. break;
  63. case "AddEditDummy":
  64. break;
  65. case " Page: AllocateIP4Address ":
  66. break;
  67. default:
  68. reSize();
  69. }
  70. }