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