summaryrefslogtreecommitdiffstats
path: root/auth/auth-gui/theme/onap/common.js
diff options
context:
space:
mode:
authorInstrumental <jcgmisc@stl.gathman.org>2018-03-26 13:51:48 -0700
committerInstrumental <jcgmisc@stl.gathman.org>2018-03-26 13:52:07 -0700
commit71037c39a37d3549dcfe31926832a657744fbe05 (patch)
tree78911b2b5e86e4e44228f7a27b3a8cd954b7f3e2 /auth/auth-gui/theme/onap/common.js
parenta20accc73189d8e5454cd26049c0e6fae75da16f (diff)
AT&T 2.0.19 Code drop, stage 3
Issue-ID: AAF-197 Change-Id: I8b02cb073ccba318ccaf6ea0276446bdce88fb82 Signed-off-by: Instrumental <jcgmisc@stl.gathman.org>
Diffstat (limited to 'auth/auth-gui/theme/onap/common.js')
-rw-r--r--auth/auth-gui/theme/onap/common.js101
1 files changed, 101 insertions, 0 deletions
diff --git a/auth/auth-gui/theme/onap/common.js b/auth/auth-gui/theme/onap/common.js
new file mode 100644
index 00000000..fbe8d083
--- /dev/null
+++ b/auth/auth-gui/theme/onap/common.js
@@ -0,0 +1,101 @@
+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);
+ }
+}