-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathF5-Frontend-Enhancements.js
1710 lines (1604 loc) · 89.5 KB
/
F5-Frontend-Enhancements.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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// ==UserScript==
// @name F5 Frontend Enhancements
// @description F5 BIG-IP Frontend UI Enhancements
// @match https://*/tmui/Control/*
// @homepage https://devcentral.f5.com/s/articles/WebUI-Tweaks
// @author https://loadbalancing.se/about
// @run-at document-end
// @version 25
// @updateURL https://raw.githubusercontent.com/timriker/F5-UI-FrontendEnhancements/master/F5-Frontend-Enhancements.js
// @downloadURL https://raw.githubusercontent.com/timriker/F5-UI-FrontendEnhancements/master/F5-Frontend-Enhancements.js
// @supportURL https://devcentral.f5.com/s/articles/webui-tweaks-v12-1109
// @grant none
// @require https://code.jquery.com/jquery-latest.js
// ==/UserScript==
/* globals jQuery,$,codeEditor */
/***************************************************************************************
Begin Config section
****************************************************************************************/
/**************************************************************
How many rules you want to see in the rule assignment window
Default:
iRulesCount = 40;
***************************************************************/
var iRulesCount = 40;
/**************************************************************
How many monitors you want to show in the monitor selection
Default:
MonitorCount = 30;
***************************************************************/
var MonitorCount = 30;
/**************************************************************
How many data group list entries to show
Default:
DatagroupListCount = 30;
***************************************************************/
var DatagroupListCount = 30;
/**************************************************************
Set http monitor name default suffix
Default:
HttpMonitorSuffix = "";
***************************************************************/
var HttpMonitorSuffix = "-http_monitor";
/**************************************************************
Set the default pool name
Default:
DefaultPoolName = "";
***************************************************************/
var DefaultPoolName = "pool_";
/**************************************************************
Set the default action on pool down when creating pools
Default:
DefaultActionOnPoolDown = 0;
Options:
0 = None
1 = Reject
2 = Drop
***************************************************************/
var DefaultActionOnPoolDown = 1;
/**************************************************************
Set the default action on pool down when creating pools
Default = 0;
Options:
0 = Round Robin
1 = Ratio (member)
2 = Least Connections (member)
3 = Observed (member)
4 = Predictive (member)
5 = Ratio (node)
6 = Least connections (node)
7 = Fastest (node)
8 = Observed (node)
9 = Predictive (node)
10 = Dynamic Ratio (node)
11 = Fastest (application)
12 = Least sessions
13 = Dynamic ratio (member)
14 = Weighted Least Connections (member)
15 = Weighted Least Connections (node)
16 = Ratio (session)
17 = Ratio Least connections (member)
18 = Ratio Least connections (node)
**************************************************************/
var DefaultLBMethod = 4;
/**************************************************************
Choose Node List as default when creating pools
Default:
ChooseNodeAsDefault = 0;
Options:
0 = No
1 = Yes
**************************************************************/
var ChooseNodeAsDefault = 1;
/**************************************************************
Add default certificate signing alternatives
First one defined is always the default one
This one is a bit tricky to format, look at the example carefully
Options:
false = No
true = Yes
Example that creates two options:
var csroptions = {
Company1: {
OptionName: 'Company 1',
CommonName: '[Example *.domain.com]',
Division: 'Stockholm office',
Organization: 'My Office address',
Locality: 'Stockholm',
StateProvince: 'Stockholm',
Country: 'SE',
Email: '[email protected]',
SubjectAlt: ''
}
,
Company2: {
OptionName: 'Another company',
CommonName: '[Example *.domain.com]',
Division: 'Oslo office',
Organization: 'My Oslo Office address',
Locality: 'Oslo',
StateProvince: 'Oslo',
Country: 'NO',
Email: '[email protected]',
SubjectAlt: ''
}
}
**************************************************************/
var csroptions = {
"Company1": {
"OptionName": "Company 1",
"CommonName": "[Example *.domain.com]",
"Division": "Stockholm office",
"Organization": "My Office address",
"Locality": "Stockholm",
"StateProvince": "Stockholm",
"Country": "SE",
"Email": "[email protected]",
"SubjectAlt": ""
}
,
"Company2": {
"OptionName": "Another company",
"CommonName": "[Example *.domain.com]",
"Division": "Oslo office",
"Organization": "My Oslo Office address",
"Locality": "Oslo",
"StateProvince": "Oslo",
"Country": "NO",
"Email": "[email protected]",
"SubjectAlt": ""
}
}
/*****************************************************************************
Select this default chain certificate when creating client SSL profiles
Default:
defaultChain = "";
defaultChain = "/Common/mychain.crt";
*******************************************************************************/
var defaultChain = "/Common/ca-bundle.crt";
/*************************************************************************
Chooses a default parent profile when creating client SSL profiles
Default:
defaultClientSSLParentProfile = "";
defaultClientSSLParentProfile = "/Common/myParentProfile";
***************************************************************************/
var defaultClientSSLParentProfile = "";
/*************************************************************************
Deactivate the choice to activate the Christmas theme altogether
Default (allow the choice):
allowChristmas = false;
Don't allow the choice:
allowChristmas = true;
***************************************************************************/
var allowChristmas = true;
/**************************************************************************
How often should the script update the LTM log stats (in seconds)
ltmLogCheckInterval = 30;
**************************************************************************/
var ltmLogCheckInterval = 30;
/***************************************************************************************
End Config section
****************************************************************************************/
//Make sure that the tampermonkey jQuery does not tamper with F5's scripts
this.$ = this.jQuery = jQuery.noConflict(true);
//Declare global ajax queue limit
var tamperDataGroupLists = new Array();
var detectedarr = [];
var poolStatuses;
var versionInfo = $(parent.top.document).find("div#deviceid div span").attr("title");
var version = versionInfo.split(" ")[1];
var majorVersion = version.split(".")[0];
var logDatabase;
var ltmLogPatterns = {
"poolFailures": new function(){
this.enabled = true;
this.name = "Pool failures";
this.isMatching = function(event){
return(event.logEvent.match(/^Pool.+monitor status down/) !== null);
}
},
"nodeFailures": new function(){
this.enabled = true;
this.name = "Node failures";
this.isMatching = function(event){
return(event.logEvent.match(/^Node.+monitor status down/) !== null);
}
},
"errors": new function(){
this.enabled = true;
this.name = "Errors";
this.isMatching = function(event){
return(event.logLevel === "error");
}
},
"warnings": new function(){
this.enabled = true;
this.name = "Warnings";
this.isMatching = function(event){
return(event.logLevel === "warning");
}
},
"tclErrors": new function(){
this.enabled = true;
this.name = "TCL Errors";
this.isMatching = function(event){
return(event.logEvent.match(/^TCL error/) !== null);
}
},
"aggressiveMode": new function(){
this.enabled = true;
this.name = "Aggressive Mode"
this.isMatching = function(event){
return(event.logEvent.match(/aggressive mode activated/) !== null);
}
},
"addressConflicts": new function(){
this.enabled = true;
this.name = "Address Conflicts"
this.isMatching = function(event){
return(event.logEvent.match(/address conflict detected for/) !== null);
}
}
}
var enhancementFunctions = {
"enhanceiRuleProperties": new function(){
// Scans for data group lists in an iRule and adds data group lists on the side
this.name = "Improve iRule editor";
this.description = `<ul>
<li>Scans iRule for data group lists</li>
<li>Adds detected data group lists to the right side of the iRule editor</li>
<li>Hovering the mouse over an iRule shows the data group list content</li>
</ul>`;
this.enabled = true;
this.appliesToVersion = ["11", "12", "13", "14", "15"];
this.applicable = function(){
return uriContains("/tmui/Control/jspmap/tmui/locallb/rule/properties.jsp")
&& this.appliesToVersion.indexOf(majorVersion) != -1
&& this.enabled;
};
this.enhance = improveiRuleProperties;
},
"improveiRuleSelection": new function(){
this.name = "Improve virtual server iRules management";
this.description = `<ul>
<li>Increases the selection box</li>
<li>Adds double click to move between sections.</li>
</ul>`;
this.enabled = true;
this.appliesToVersion = ["11", "12", "13", "14", "15"];
this.applicable = function(){
return uriContains("/tmui/Control/form?__handler=/tmui/locallb/virtual_server/resources&__source=Manage")
&& this.appliesToVersion.indexOf(majorVersion) != -1
&& this.enabled;
};
this.enhance = improveiRuleSelection;
},
"addHTTPMonitorSuffix": new function(){
this.name = "Adds HTTP monitor suffix to pool names";
this.description = `<ul>
<li>Adds monitor prefixes when creating pools</li>
</ul>`;
this.enabled = true;
this.appliesToVersion = ["11", "12", "13", "14", "15"];
this.applicable = function(){
return $("select[name=mon_type]").length > 0
&& this.appliesToVersion.indexOf(majorVersion) != -1
&& this.enabled;
};
this.enhance = addHTTPMonitorSuffix;
},
"makeCurrentPartitionObjectsBold": new function(){
this.name = "Make current partition objects bold";
this.description = `<ul>
<li>Adds monitor prefixes</li>
</ul>`;
this.enabled = true;
this.appliesToVersion = ["11", "12", "13", "14", "15"];
this.applicable = function(){
return uriContains('/list.jsp')
&& this.appliesToVersion.indexOf(majorVersion) != -1
&& this.enabled;
};
this.enhance = makeCurrentPartitionObjectsBold;
},
"improvePoolProperties": new function(){
this.name = "Enhance the pool properties page";
this.description = `<ul>
<li>Makes monitor selection bigger</li>
<li>Adds double click functionality</li>
</ul>`;
this.enabled = true;
this.appliesToVersion = ["11", "12", "13", "14", "15"];
this.applicable = function(){
return uriContains("/tmui/Control/jspmap/tmui/locallb/pool/properties.jsp?name")
&& this.appliesToVersion.indexOf(majorVersion) != -1
&& this.enabled;
};
this.enhance = improvePoolProperties;
},
"improvePoolCreation": new function(){
this.name = "Enhance the pool creation page";
this.description = `<ul>
<li>Makes monitor selection bigger</li>
<li>Adds double click functionality</li>
</ul>`;
this.enabled = true;
this.appliesToVersion = ["11", "12", "13", "14", "15"];
this.applicable = function(){
return uriContains("/tmui/Control/jspmap/tmui/locallb/pool/create.jsp")
&& this.appliesToVersion.indexOf(majorVersion) != -1
&& this.enabled;
};
this.enhance = improvePoolCreation;
},
"improvePoolMemberProperties": new function(){
this.name = "Enhance the pool member properties page";
this.description = `<ul>
<li>Adds monitor tests for HTTP monitors</li>
</ul>`;
this.enabled = true;
this.appliesToVersion = ["11", "12", "13", "14", "15"];
this.applicable = function(){
return uriContains("/tmui/Control/jspmap/tmui/locallb/pool/member/properties.jsp")
&& this.appliesToVersion.indexOf(majorVersion) != -1
&& this.enabled;
};
this.enhance = improvePoolMemberProperties;
},
"improveCertKeyChainSelection": new function(){
this.name = "Client SSL Profile enhancements";
this.description = `<ul>
<li>Automatically selects certificate and keys matching the name of the client SSL profile</li>
<li>Selects a default chain certificate according to the script configuration</li>
</ul>`;
this.enabled = true;
this.appliesToVersion = ["11", "12", "13", "14", "15"];
this.applicable = function(){
return $('input[name="cert_key_chain_override"]').length > 0
&& this.appliesToVersion.indexOf(majorVersion) != -1
&& this.enabled;
};
this.enhance = improveCertKeyChainSelection;
},
"improveVirtualServerResources": new function(){
this.name = "Improve Virtual Server resource tab";
this.description = `<ul>
<li>Adds a shortcut to the configured default pool</li>
</ul>`;
this.enabled = true;
this.appliesToVersion = ["11", "12", "13", "14", "15"];
this.applicable = function(){
return uriContains("/tmui/Control/jspmap/tmui/locallb/virtual_server/resources.jsp")
&& this.appliesToVersion.indexOf(majorVersion) != -1
&& this.enabled;
};
this.enhance = improveVirtualServerResources;
},
"improveVirtualServerProperties": new function(){
this.name = "Improve Virtual Server properties page";
this.description = `<ul>
<li>Double click to the multiple selection lists</li>
</ul>`;
this.enabled = true;
this.appliesToVersion = ["11", "12", "13", "14", "15"];
this.applicable = function(){
return uriContains("/tmui/Control/jspmap/tmui/locallb/virtual_server/properties.jsp")
&& this.appliesToVersion.indexOf(majorVersion) != -1
&& this.enabled;
};
this.enhance = improveVirtualServerProperties;
},
"improveDataGroupListProperties": new function(){
this.name = "Data group list editing safe guards";
this.description = `<ul>
<li>Disabled the update button while the key/value fields contains values not in the list to protect from accidentally removing something by mistake.</li>
</ul>`;
this.enabled = true;
this.appliesToVersion = ["11", "12", "13", "14", "15"];
this.applicable = function(){
return uriContains("/tmui/Control/jspmap/tmui/locallb/datagroup/properties.jsp")
&& this.appliesToVersion.indexOf(majorVersion) != -1
&& this.enabled;
};
this.enhance = improveDataGroupListProperties;
},
"improveDataGroupListEditing": new function(){
this.name = "Add data group list editing features";
this.description = `<ul>
<li>Adds the possibility to free-text edit, import, export and merge lists.</li>
</ul>`;
this.enabled = true;
this.appliesToVersion = ["11", "12", "13", "14", "15"];
this.applicable = function(){
return (uriContains("/tmui/Control/jspmap/tmui/locallb/datagroup/properties.jsp")
|| uriContains("/tmui/Control/jspmap/tmui/locallb/datagroup/create.jsp")
|| uriContains("/tmui/locallb/datagroup/properties"))
&& this.appliesToVersion.indexOf(majorVersion) != -1
&& this.enabled;
};
this.enhance = improveDataGroupListEditing;
},
"improveClientSSLProfileCreation": new function(){
this.name = "Improves the client SSL profile creation";
this.description = `<ul>
<li>Automatically selects a parent profile according to the script configuration</li>
</ul>`;
this.enabled = true;
this.appliesToVersion = ["11", "12", "13", "14", "15"];
this.applicable = function(){
return uriContains("/tmui/Control/jspmap/tmui/locallb/profile/clientssl/create.jsp")
&& this.appliesToVersion.indexOf(majorVersion) != -1
&& this.enabled;
};
this.enhance = improveClientSSLProfileCreation;
},
"improvePoolList": new function(){
this.name = "Improves the pool list";
this.description = `<ul>
<li>Gives more granular pool state symbols</li>
<li>Hovering the mouse of the state symbol shows the members and their states</li>
</ul>
<font color="red">Warning: On <i>very</i> large configurations (~2000 pools) this <i><b>can</b></i> be detrimental to the HTTPD process.
<b>This is not a risk for the application delivery itself</b>, but <i>may</i> cause the process to be restarted.</font>`;
this.enabled = true;
this.appliesToVersion = ["11", "12", "13", "14", "15"];
this.applicable = function(){
return uriContains("/tmui/Control/jspmap/tmui/locallb/pool/list.jsp")
&& this.appliesToVersion.indexOf(majorVersion) != -1
&& this.enabled;
};
this.enhance = improvePoolList;
},
"addPartitionFilter": new function(){
this.name = "Partition filter";
this.description = `<ul>
<li>Adds a free text partition filter to ease partition selection</li>
</ul>`
this.enabled = true;
this.appliesToVersion = ["11", "12", "13", "14", "15"];
this.applicable = function(){
return $(parent.top.document).find("input#partitionFilter").length == 0
&& this.appliesToVersion.indexOf(majorVersion) != -1
&& this.enabled;
};
this.enhance = addPartitionFilter;
},
"addChristmasTheme": new function(){
this.name = "Christmas theme";
this.description = `<ul>
<li>Allows the user to enable/disable Christmas theme during December</li>
</ul>`
this.enabled = true;
this.appliesToVersion = ["11", "12", "13", "14", "15"];
this.applicable = function(){
return isItChristmas()
&& allowChristmas
&& this.appliesToVersion.indexOf(majorVersion) != -1
&& this.enabled;
};
this.enhance = showChristmasOption;
},
"addCSRDropDownMenu": new function(){
this.name = "CSR profiles";
this.description = `<ul>
<li>Adds a drop down menu with predefined CSR options</li>
</ul>`;
this.enabled = true;
this.appliesToVersion = ["11", "12", "13", "14", "15"];
this.applicable = function(){
return uriContains("/tmui/Control/jspmap/tmui/locallb/ssl_certificate/create.jsp")
&& this.appliesToVersion.indexOf(majorVersion) != -1
&& this.enabled;
};
this.enhance = addCSRDropDownMenu;
}, "addLTMLogSummary": new function(){
this.name = "LTM log features";
this.description = `<ul>
<li>Adds information from the LTM log to the top bar</li>
<li>Shows pool failures in the pool list</li>
</ul>`;
this.enabled = true;
this.appliesToVersion = ["11", "12", "13", "14", "15"];
this.applicable = function(){
return uriContains("/tmui/Control/jspmap/tmui/overview/welcome/introduction.jsp")
&& this.appliesToVersion.indexOf(majorVersion) != -1
&& this.enabled;
};
this.enhance = startLTMLogFetcher;
}
}
for(let i in enhancementFunctions){
let f = enhancementFunctions[i];
if(f.applicable()){
f.enhance();
}
}
/**************************************************************************
* Modify the top frame
**************************************************************************/
String.prototype.hashCode = function(){
let hash = 0;
if (this.length == 0) return hash;
for (let i = 0; i < this.length; i++) {
let char = this.charCodeAt(i);
hash = ((hash<<5)-hash)+char;
hash = hash & hash; // Convert to 32bit integer
}
return hash;
}
function startLTMLogFetcher(){
//Check if the database contains anything
if(typeof(logDatabase) === "undefined"){
let rawData = localStorage.getItem("ltmLog") || "{\"content\":{},\"lastSynced\":null}";
logDatabase = JSON.parse(rawData);
//updateLTMLogStatistics(getLTMLogStatisticsSummary(logDatabase));
initiateLTMLogStatistics();
}
if(logDatabase.lastSynced){
let lastSynced = new Date(logDatabase.lastSynced);
let now = new Date();
let seconds = (now.getTime() - lastSynced.getTime()) / 1000;
}
let fetchLTMLog = function(){
$.ajax({
url: "https://" + window.location.host + "/tmui/Control/jspmap/tmui/system/log/list_ltm.jsp",
type: "GET",
success: function(response) {
$(response).find("table.list tbody tr").each(function(){
let message = {}
let row = $(this).find("td");
message.timeStamp = $(row[0]).text().trim();
message.logLevel = $(row[1]).text().trim();
message.host = $(row[2]).text().trim();
message.service = $(row[3]).text().trim();
message.statusCode = $(row[4]).text().trim();
message.logEvent = $(row[5]).text().trim();
let data = "";
for(let i in message){
data += message[i]
}
if(!(data in logDatabase)){
logDatabase.content[data] = message
}
logDatabase.lastSynced = new Date();
})
updateLTMLogStatistics(getLTMLogStatisticsSummary(logDatabase));
localStorage.setItem("ltmLog", JSON.stringify(logDatabase));
}
})
}
fetchLTMLog();
setInterval(fetchLTMLog, ltmLogCheckInterval*1000);
}
function initiateLTMLogStatistics(){
let topFrame = $(parent.top.document);
if(topFrame.find("div.ltmLogStats").length == 0){
let styleTag = $(`<style>
.ltmLogStats {
float: left;
padding: 0 15px;
border-right: 1px dotted #444;
margin: 0;
}
</style>`);
topFrame.find('html > head').append(styleTag);
let html = ``;
let parameterList = [];
for(let i in ltmLogPatterns){
if(parameterList.length == 2){
html += `<div class="ltmLogStats" id="ltmLogStats">` + parameterList.join("") + `</div>`
parameterList = [];
}
parameterList.push(`
<div class="" id="logStats` + i + `">
<label>` + ltmLogPatterns[i].name + `:</label>
<span>Loading...</span>
</div>`
);
}
if(parameterList.length != 0){
html += `<div class="ltmLogStats">` + parameterList.join("") + `</div>`
}
topFrame.find("div#userinfo").last().after(html);
}
}
function updateLTMLogStatistics(summary){
let topFrame = $(parent.top.document);
if(topFrame.find("div.ltmLogStats").length != 0){
let i = 0
for(let stats in summary){
let statsSpan = topFrame.find("div#logStats" + stats + " span");
statsSpan.fadeOut(300);
statsSpan.html(summary[stats]);
statsSpan.fadeIn(300);
}
}
}
function getLTMLogStatisticsSummary(logDatabase){
let summary = {};
let events = logDatabase.content;
for(let f in ltmLogPatterns){
let logTest = ltmLogPatterns[f];
if(logTest.enabled){
summary[f] = 0;
}
}
for(let i in events){
let event = events[i];
for(let functionName in ltmLogPatterns){
let f = ltmLogPatterns[functionName];
if(f.isMatching(event)){
summary[functionName]++;
}
}
}
return(summary);
}
function isItChristmas(){
let d = new Date();
return d.getMonth() == 11;
}
function showChristmasOption(){
if($(parent.top.document).find("input#grinch").length == 0){
let partitionDiv = $(parent.top.document).find("div#partition");
partitionDiv.after(`
<div id="christmasdiv" style="float:right;border-left: 1px dotted #444; padding: 5px;">
<span style='font-family: "Comic Sans MS", "Comic Sans";color:#f92c2c;font-size:14px;'>Merry Christmas! Which one are you? </span>
<form action="" style="display:inline;">
<input name="ChristmasButton" class="christmasButton" type="radio" id="grinch" value="grinch"> Grinch
<input name="ChristmasButton" class="christmasButton"type="radio" id="santa" value="santa"> Santa
</form>
<div>
`);
if(localStorage.getItem("tamperMonkey-snowActivated") === "true"){
letItSnow();
$(parent.top.document).find("input#santa").attr("checked", true);
} else {
$(parent.top.document).find("input#grinch").attr("checked", true);
}
$(parent.top.document).find("input.christmasButton").on("click", function(){
if($(this).val() === "santa"){
letItSnow();
localStorage.setItem("tamperMonkey-snowActivated", "true");
} else {
$(parent.top.document).find("#xmasdiv").remove();
$(parent.top.document).find("#santahat").remove();
localStorage.setItem("tamperMonkey-snowActivated", "false")
}
})
}
}
// This function handles the Christmas theme (santa hat on the F5 ball and snow)
function letItSnow(){
if(parent.top.document.getElementById("xmasdiv") === null){
let b = parent.top.document.getElementById("banner");
let logo = parent.top.document.getElementById("logo");
let image = $(logo).find("img");
let position = image.position();
let santacap = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEQAAAA4CAYAAABE814IAAAACXBIWXMAAC4jAAAuIwF4pT92AAATUUlEQVRo3t1bCVhVVdeGywwXLlxEZBARBzTJnIfIAUUmZZA5Qs0wtayvPsv8slQUlVENHHEWUTDTTBP7888hhzTNNHNIEUQckMFQBBld/7v2PRdRIaHs68fzPOs55557OGfvd7/rXcO5aGg8gy3I2krHz1wZ7GZouM1ZSyvXWUOjxkVTkzy1tMhDJqPBOMa5O84y2YlhBgYLfZVK9yArK0ON53HzMTFxGaqnd7yfhgaF6uhQvKkp7bSyomN2dvSrvT2dgR1p3Zq+bNWK4vDdGD09FUBaWhc9jI1jfBUKp+cGjNEvOkX00dCoDNTWpm2Y8NV27aigQwe62b69OM6RLBfG5/i7a9gfBVgLzcwoAH8HICtcdHW3A5gpYE3oCCMjNz+lcugIudzVz9zcw9/SMsJLLk/0Uir3uBrJ97obGGz2khvNBCO9Qlq3Nvt/A8abzs5eveAaU4yN6QomnI/JZjk4UCbscgOm/i5XAo7/7kuwaZy+PvUFwwbAhsHc4WbD4W6eOPaC+ePzWG0telNXm8Kw98HnoTjvoq19zdPIaHGAhUXnfxSMyX4+ps56ejmTDQ3FxJgFfwREQ+AwgHlgzE3cYxuAGWtgwFoj7FWwZ4qhAcWZGNMyMwWtUprSanNTsV8OizaR07/09WgE3M9FJrsLEEP/Od2wsVnmhoH8hgmxa1xuIhj1sYaBuQ7ba2NDc6E1gdCjgQDmFRg/yw+MCdPRpnCcf0NPl+abGgMYBS02M6Fx+IzrKsMdHQP/62AEtW/3NlxFaMYtrGzmXwCjPmNQ8iXW/QAxTrO0hFCb0WS5nCaAkWPhXu/heJ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bud20eOt26lnMD6dN5tcFQoaadlq4yM3Ly8pNSspvqvZnACZ1L+/Bfz+pC/E8PShwypQhPtU1epFaWkZbdr9NTLUJRTLQIAl3KmP27iO3hodTi4o6jz19XdO9fIyeeTm1WXlE0rvlJg0N5a8Zm/fCvVHxgB9fVoxfQblXsmhMuhHYWkpHbtwnhZ9kU6z1ySLBjb3QKLXrqDxwYE0wsqKfzF918fY+NNRDg5aT9y4/G5pFwCi3RxdJ9TaWtPbxOSDfhoaha4mxqL5/WZIEL03ZTJNnx9HUUuTaGZCLE0aE05eLS24IXTdQyaL9jcz66jxPG8h1lZ2w/X1x3vq6a0eoqFxCVYp+hxgz1CZjBvY1zxkWvMDW7Swftq9/g/AgFBTdyRnHAAAAABJRU5ErkJggg==";
$(logo).prepend("<div id=\"santahat\" style=\"position:absolute;left:" + (position.left - 3) + "px;top:" + (position.top - 20) + "px;pointer-events: none;\"><img id=\"santacap\" src=\"" + santacap + "\"\></div>");
$(b).before("<div id=\"xmasdiv\" style=\"position:absolute;left:0px;top:" + b.offsetTop + "px;width:100%;height:105.38px;width:" + b.offsetWidth + ";z-index:999;overflow:hidden;pointer-events: none;\"><canvas id=\"xmassnow\" class=\"snow\"></canvas></div>")
let canvas = parent.top.document.getElementById("xmassnow");
let w = b.offsetWidth
let h = b.offsetHeight
let ctx = canvas.getContext('2d'),
windowW = w,
windowH = h,
numFlakes = 200,
flakes = [];
function Flake(x, y) {
let maxWeight = 5,
maxSpeed = 0.5;
this.x = x;
this.y = y;
this.r = randomBetween(0, 1);
this.a = randomBetween(0, Math.PI);
this.aStep = 0.01;
this.weight = randomBetween(2, maxWeight);
this.alpha = (this.weight / maxWeight);
this.speed = (this.weight / maxWeight) * maxSpeed;
this.update = function() {
this.x += Math.cos(this.a) * this.r;
this.a += this.aStep;
this.y += this.speed;
}
}
function init() {
let i = numFlakes,
flake,
x,
y;
while (i--) {
x = randomBetween(0, windowW, true);
y = randomBetween(0, windowH, true);
flake = new Flake(x, y);
flakes.push(flake);
}
scaleCanvas();
loop();
}
function scaleCanvas() {
canvas.width = windowW;
canvas.height = windowH;
}
function loop() {
let i = flakes.length,
z,
dist,
flakeA,
flakeB;
// clear canvas
ctx.save();
ctx.setTransform(1, 0, 0, 1, 0, 0);
ctx.clearRect(0, 0, windowW, windowH);
ctx.restore();
// loop of hell
while (i--) {
flakeA = flakes[i];
flakeA.update();
/*for (z = 0; z < flakes.length; z++) {
flakeB = flakes[z];
if (flakeA !== flakeB && distanceBetween(flakeA, flakeB) < 150) {
ctx.beginPath();
ctx.moveTo(flakeA.x, flakeA.y);
ctx.lineTo(flakeB.x, flakeB.y);
ctx.strokeStyle = '#444444';
ctx.stroke();
ctx.closePath();
}
}*/
ctx.beginPath();
ctx.arc(flakeA.x, flakeA.y, flakeA.weight, 0, 2 * Math.PI, false);
ctx.fillStyle = 'rgba(255, 255, 255, ' + flakeA.alpha + ')';
ctx.fill();
if (flakeA.y >= windowH) {
flakeA.y = -flakeA.weight;
}
}
requestAnimationFrame(loop);
}
function randomBetween(min, max, round) {
let num = Math.random() * (max - min + 1) + min;
if (round) {
return Math.floor(num);
} else {
return num;
}
}
function distanceBetween(vector1, vector2) {
let dx = vector2.x - vector1.x,
dy = vector2.y - vector1.y;
return Math.sqrt(dx*dx + dy*dy);
}
init();
}
}
function addPartitionFilter(){
let partitionDiv = $(parent.top.document).find("div#partition");
// Add the filter input and the label
partitionDiv.prepend("<input size=10 id=\"partitionFilter\"/> ")
partitionDiv.prepend("<label>Partition filter <a title=\"Hit enter to activate the selected partition\" id=\"partitionFilterHelp\" href=\"https://loadbalancing.se/f5-webui-tweaks/#Partition_filtering\" target=\"_blank\">[?]</a>: </label>");
let partitionDropDown = partitionDiv.find("select#partition_control");
let partitonOptions = partitionDropDown.find("option");
let partitionFilterInput = partitionDiv.find("input#partitionFilter");
partitionFilterInput.on("keyup", function(e){
if(e.keyCode === 13){
triggerEvent("change", parent.top.document.querySelector("div#partition select#partition_control"))
return;
}
let searchValue = this.value;
// Set the local storage in order to re-populate the filter upon page reload
localStorage.setItem("tamperMonkey-PartitionFilter", searchValue);
let re = new RegExp(searchValue, "i");
partitonOptions.each(function(){
if($(this).val().match(re) || $(this).val() === "[All]"){
$(this).attr("ismatch", "true")
$(this).show();
} else {
$(this).attr("ismatch", "false")
$(this).hide();
}
});
let selectedOption = partitionDropDown.find("option:selected");
let selectedOptionValue = selectedOption.val() || ""
let matchedCount = partitionDropDown.find("option[ismatch='true']").length;
if(!selectedOptionValue.match(re) && matchedCount > 0){
selectedOption.removeAttr("selected");
partitionDropDown.find("option[ismatch='true']:eq(0)").attr("selected", "selected");
}
})
partitionFilterInput.val(localStorage.getItem("tamperMonkey-PartitionFilter") || "").trigger("keyup");
}
/**************************************************************************
* iRule improvements
**************************************************************************/
function improveiRuleProperties(){
// Show the data group lists used in an iRule
cacheDataGroupLists(function(dataGroupLists){
//This part prepares the iRule definition table for the data group lists (adds a third column)
$("table#general_table thead tr.tablehead td").attr("colspan", 3);
$("table#general_table tr").not("#definition_ace_row").each(function(){
$(this).find("td").eq(1).attr("colspan", 2);
});
$("tr#definition_ace_row").append("<td id=\"dglist\" class=\"settings\"></td>").css({
"vertical-align": "top"
});
$("tr#definition_ace_row td.settings").css("width","80%");
//This command generates the data group lists (if any)
getDataGroupListsFromRule($("textarea#rule_definition").val());
//getDataGroupListsFromRuleOld($("textarea#rule_definition").val());
//Update the list on every key stroke
$(document).on("keyup", function(){
let iRuleContent = codeEditor.gSettings.editor.container.env.document.doc.$lines.join("\n");
getDataGroupListsFromRule(iRuleContent);
//getDataGroupListsFromRuleOld($("textarea#rule_definition").val());
});
});
}
// Caches a list of all the data group lists available in Common and the current partition (if any)
function cacheDataGroupLists(updateDGPage){
let DataGroupListLink = "https://" + window.location.host + "/tmui/Control/jspmap/tmui/locallb/datagroup/list.jsp";
// We want to get all data group lists in case there is a direct reference
let currentPartition = getCookie("F5_CURRENT_PARTITION");
replaceCookie("F5_CURRENT_PARTITION", "\"[All]\"");
//Request the iRule page to see if the instance exists or not
$.ajax({
url: DataGroupListLink,
type: "GET",
success: function(response) {
let dataGroupListLinks = $(response).find('table.list tbody#list_body tr td:nth-child(3) a');
for(let i = 0; i < dataGroupListLinks.length; i++){
let link = dataGroupListLinks[i].href;
let name = link.split("name=")[1];
tamperDataGroupLists.push(name);
}
replaceCookie("F5_CURRENT_PARTITION", currentPartition);
updateDGPage();
}
});
}
//Parses data group list html to get the key/value pairs for the hover information
function parseDataGroupValues(dg, showBalloon){
let dgLink = 'https://' + window.location.host + '/tmui/Control/jspmap/tmui/locallb/datagroup/properties.jsp?name=' + dg;
let html;
$.ajax({
url: dgLink,
type: "GET",
success: function(htmlresponse) {
let matches = htmlresponse.match(/<option value="[^"]+(\\x0a)?.+?" >/g);
//Set the header
html = '<span style="color:blue">Key</span> = <span style="color:red">Value</span>'
if(matches){
for(let i=0; i < matches.length; i++){
let match = matches[i].replace('<option value="', '').replace('" >', '')
let matcharr = match.split('\\x0a')
if(matcharr.length == 2){
html += '<br><span style="color:blue">' + matcharr[0] + '</span> = <span style="color:red">' + matcharr[1] + '</span>';
} else {
html += '<br><span style="color:blue">' + matcharr[0] + '</span> = <span style="color:red">""</span>';
}
}
} else {
html += "<br><span style=\"color:blue\">Empty data group list</span>";
}
//Show the balloon using the callback function
showBalloon(html);
},
async: false
});
return html;
}
function getDataGroupListsFromRule(str){
"use strict"
let lines = str.split("\n");
let partitionPrefix = "/" + getCookie("F5_CURRENT_PARTITION") + "/";
let foundDataGroupLists = {};
let updateDGObject = function(dg){
let partition = dg.split("/")[1];
let name = dg.split("/")[2];
if(!(partition in foundDataGroupLists)){
foundDataGroupLists[partition] = new Array();
}
foundDataGroupLists[partition].push(name);
};
for(let i = 0; i < lines.length; i++){
// Skip lines that start with a comment
if((lines[i].match(/^\s*#/))){
continue;
}
if(lines[i].indexOf("class ") > -1){
let words = lines[i].split(/[\s\[\]]/);
let classIndex = words.indexOf("class");
words.map(function(word, index){
if(index < classIndex){
return;
}
if(word !== ""){
if(tamperDataGroupLists.indexOf(word) > -1){
updateDGObject(word);
} else if(tamperDataGroupLists.indexOf(partitionPrefix + word) > -1){
updateDGObject(partitionPrefix + word);
} else if(tamperDataGroupLists.indexOf("/Common/" + word) > -1){
updateDGObject("/Common/" + word);