-
Notifications
You must be signed in to change notification settings - Fork 1
/
F5 UI Enhancements Shared.js
63 lines (51 loc) · 2.24 KB
/
F5 UI Enhancements Shared.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
/* Description
This script will house the shared methods and variables within other Tampermonkey scripts, so we don't have to duplicate effort in every new scripts. It will help with the 'modularization' of these scripts.
Disclaimer: All scripts are provided AS IS without warranty of any kind. I dislaim any/all liability from the use of this script.
*/
// Turns on logging for the script (useful for debugging issues)
// 0 - Off
// 1 - Notice
// 2 - Informational
// 3 - Debug
var DebugLevel = 3;
// Make sure that the tampermonkey jQuery does not tamper with F5's scripts
this.$ = this.jQuery = jQuery.noConflict(true);
// ***********************************
// ***** SECTION: Helper Functions ***
// ***********************************
// If the IsDebug setting not empty/undefined/false, then we'll log messages to the console
function dlog(o, minLevel) {
if (DebugLevel && (!minLevel || (minLevel >= DebugLevel) )) { console.log(o); }
}
// Most functionality is specific to a certain page, so this function is used to check the current page against a specific URL
function checkLocation(str) {
return (window.location.href.indexOf(str) >= 0);
}
// This will parse the specified url parameter value form the current page URL if it exists
function getParameterByName(name) {
// REF: http://stackoverflow.com/questions/901115/how-can-i-get-query-string-values-in-javascript
name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
results = regex.exec(location.search);
return results === null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
}
// This will grab the specified cookie if it exists
function getCookie(cname) {
// REF: http://www.w3schools.com/js/js_cookies.asp
var name = cname + "=";
var ca = document.cookie.split(';');
for(var i=0; i<ca.length; i++) {
var c = ca[i];
while (c.charAt(0)==' ') c = c.substring(1);
if (c.indexOf(name) === 0) return c.substring(name.length,c.length);
}
return "";
}
// This will redirect the user the specified url (in a new window if specified)
function redirect(url, newWindow) {
if (newWindow) {
window.open(url);
} else {
window.location = url;
}
}