This repository has been archived by the owner on Sep 8, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
zenterio.dashboard.js
83 lines (75 loc) · 2.57 KB
/
zenterio.dashboard.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
(function() {
/**
* Returns an associative arrays with key-value pairs based on the
* query string part of an url.
* If no search string is provided, it uses an empty string.
* Multiple uses of a key results in all the associated values being saved in
* a single array associated with that key.
*
* @param {string} [searchStr] Search string
*
* @returns {Object} Object of search string key-value parameters.
*/
function getQueryStringParams() {
var searchStr = window.location.search
// If search string not set, empty search string.
if (typeof searchStr === 'undefined') {
searchStr = "?";
}
var match;
var pl = /\+/g; // Regex for replacing addition symbol with a space
var search = /([^&=]+)=?([^&]*)/g;
var decode = function(s) {
return decodeURIComponent(s.replace(pl, " "));
};
var query = searchStr.substring(1);
var result = {};
var key = "";
var value = "";
while ((match = search.exec(query))) {
key = decode(match[1]);
value = decode(match[2]);
value = convertURLValue(value)
if (key in result) {
var oldValue = result[key];
if (oldValue instanceof Array) {
oldValue.push(value);
} else {
result[key] = [oldValue, value];
}
} else {
result[key] = value;
}
}
return result;
}
function convertURLValue(value) {
switch (value.toLowerCase()) {
case "false":
return false;
case "true":
return true;
}
if (! isNaN(value)) {
return +value // Converts to a number
}
return value
}
/**
* Manipulates the DOM to strip away unwanted sections.
*/
function activateDashBoardMode(e) {
AJS.$('#footer').hide();
AJS.$('#header').hide();
AJS.$('#announcement-banner').hide();
AJS.$('div#dashboard').find('ul.dashboard-tabs').hide();
AJS.$('div#dashboard').css('margin-left', '0px');
AJS.$('div#dashboard-content').css('margin-left', '0px');
AJS.$('div#dashboard-content').find('div.aui-page-header').hide();
AJS.$('div#dashboard-content').css('margin-top', '10px');
}
var cfg = getQueryStringParams();
if (cfg.zenterioDashboardMode == true) {
AJS.$(document).ready(activateDashBoardMode);
}
})();