summaryrefslogtreecommitdiffstats
path: root/authz-gui/theme/common.js
blob: e9af8fef4916a3c866dc0ca6b7cd34a240a378a5 (plain)
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
/*******************************************************************************
 * Copyright (c) 2016 AT&T Intellectual Property. All rights reserved.
 *******************************************************************************/
Object.defineProperty(Element.prototype, 'outerHeight', {
    'get': function(){
        var height = this.clientHeight;
        height += getStyle(this,'marginTop');
        height += getStyle(this,'marginBottom');
        height += getStyle(this,'borderTopWidth');
        height += getStyle(this,'borderBottomWidth');
        return height;
    }
});

if (document.addEventListener) {
	document.addEventListener('DOMContentLoaded', function () {
		var height = document.querySelector("#footer").outerHeight;
		document.querySelector("#inner").setAttribute("style",
				"margin-bottom:" + height.toString()+ "px");
	});
} else {
	window.attachEvent("onload", function () {
		var height = document.querySelector("#footer").outerHeight;
		document.querySelector("#inner").setAttribute("style",
				"margin-bottom:" + height.toString()+ "px");
	});
}



function getStyle(el, prop) {
	var result = el.currentStyle ? el.currentStyle[prop] :
		document.defaultView.getComputedStyle(el,"")[prop];
	if (parseInt(result,10))
		return parseInt(result,10);
	else
		return 0;
}

function divVisibility(divID) {
	var element = document.querySelector("#"+divID);
	if (element.style.display=="block")
		element.style.display="none";
	else
		element.style.display="block";
}

function datesURL(histPage) {
	var validated=true;
	var yearStart = document.querySelector('#yearStart').value;
	var yearEnd = document.querySelector('#yearEnd').value;
	var monthStart = document.querySelector('#monthStart').value;
	var monthEnd = document.querySelector('#monthEnd').value;
	if (monthStart.length == 1) monthStart = 0 + monthStart;
	if (monthEnd.length == 1) monthEnd = 0 + monthEnd;

	validated &= validateYear(yearStart);
	validated &= validateYear(yearEnd);
	validated &= validateMonth(monthStart);
	validated &= validateMonth(monthEnd);
	
	if (validated) window.location=histPage+"&dates="+yearStart+monthStart+"-"+yearEnd+monthEnd;
	else alert("Please correct your date selections");
}

function userFilter(approvalPage) {
	var user = document.querySelector('#userTextBox').value;
	if (user != "")
		window.location=approvalPage+"?user="+user;
	else
		window.location=approvalPage;
}

function validateYear(year) {
	var today = new Date();
	if (year >= 1900 && year <= today.getFullYear()) return true;
	else return false;
}

function validateMonth(month) {
	if (month) return true;
	else return false;
}

function alterLink(breadcrumbToFind, newTarget) {
	var breadcrumbs = document.querySelector("#breadcrumbs").getElementsByTagName("A");
	for (var i=0; i< breadcrumbs.length;i++) {
		var breadcrumbHref = breadcrumbs[i].getAttribute('href');
		if (breadcrumbHref.indexOf(breadcrumbToFind)>-1) 
			breadcrumbs[i].setAttribute('href', newTarget);
	}
}

// clipBoardData object not cross-browser supported. Only IE it seems
function copyToClipboard(controlId) { 
    var control = document.getElementById(controlId); 
    if (control == null) { 
    	alert("ERROR - control not found - " + controlId); 
    } else { 
    	var controlValue = control.href; 
    	window.clipboardData.setData("text/plain", controlValue); 
    	alert("Copied text to clipboard : " + controlValue); 
    } 
}