sg481n | bd890c5 | 2017-08-28 12:11:35 -0400 | [diff] [blame^] | 1 | /******************************************************************************* |
| 2 | * Copyright (c) 2016 AT&T Intellectual Property. All rights reserved. |
| 3 | *******************************************************************************/ |
| 4 | Object.defineProperty(Element.prototype, 'outerHeight', { |
| 5 | 'get': function(){ |
| 6 | var height = this.clientHeight; |
| 7 | height += getStyle(this,'marginTop'); |
| 8 | height += getStyle(this,'marginBottom'); |
| 9 | height += getStyle(this,'borderTopWidth'); |
| 10 | height += getStyle(this,'borderBottomWidth'); |
| 11 | return height; |
| 12 | } |
| 13 | }); |
| 14 | |
| 15 | if (document.addEventListener) { |
| 16 | document.addEventListener('DOMContentLoaded', function () { |
| 17 | var height = document.querySelector("#footer").outerHeight; |
| 18 | document.querySelector("#inner").setAttribute("style", |
| 19 | "margin-bottom:" + height.toString()+ "px"); |
| 20 | }); |
| 21 | } else { |
| 22 | window.attachEvent("onload", function () { |
| 23 | var height = document.querySelector("#footer").outerHeight; |
| 24 | document.querySelector("#inner").setAttribute("style", |
| 25 | "margin-bottom:" + height.toString()+ "px"); |
| 26 | }); |
| 27 | } |
| 28 | |
| 29 | |
| 30 | |
| 31 | function getStyle(el, prop) { |
| 32 | var result = el.currentStyle ? el.currentStyle[prop] : |
| 33 | document.defaultView.getComputedStyle(el,"")[prop]; |
| 34 | if (parseInt(result,10)) |
| 35 | return parseInt(result,10); |
| 36 | else |
| 37 | return 0; |
| 38 | } |
| 39 | |
| 40 | function divVisibility(divID) { |
| 41 | var element = document.querySelector("#"+divID); |
| 42 | if (element.style.display=="block") |
| 43 | element.style.display="none"; |
| 44 | else |
| 45 | element.style.display="block"; |
| 46 | } |
| 47 | |
| 48 | function datesURL(histPage) { |
| 49 | var validated=true; |
| 50 | var yearStart = document.querySelector('#yearStart').value; |
| 51 | var yearEnd = document.querySelector('#yearEnd').value; |
| 52 | var monthStart = document.querySelector('#monthStart').value; |
| 53 | var monthEnd = document.querySelector('#monthEnd').value; |
| 54 | if (monthStart.length == 1) monthStart = 0 + monthStart; |
| 55 | if (monthEnd.length == 1) monthEnd = 0 + monthEnd; |
| 56 | |
| 57 | validated &= validateYear(yearStart); |
| 58 | validated &= validateYear(yearEnd); |
| 59 | validated &= validateMonth(monthStart); |
| 60 | validated &= validateMonth(monthEnd); |
| 61 | |
| 62 | if (validated) window.location=histPage+"&dates="+yearStart+monthStart+"-"+yearEnd+monthEnd; |
| 63 | else alert("Please correct your date selections"); |
| 64 | } |
| 65 | |
| 66 | function userFilter(approvalPage) { |
| 67 | var user = document.querySelector('#userTextBox').value; |
| 68 | if (user != "") |
| 69 | window.location=approvalPage+"?user="+user; |
| 70 | else |
| 71 | window.location=approvalPage; |
| 72 | } |
| 73 | |
| 74 | function validateYear(year) { |
| 75 | var today = new Date(); |
| 76 | if (year >= 1900 && year <= today.getFullYear()) return true; |
| 77 | else return false; |
| 78 | } |
| 79 | |
| 80 | function validateMonth(month) { |
| 81 | if (month) return true; |
| 82 | else return false; |
| 83 | } |
| 84 | |
| 85 | function alterLink(breadcrumbToFind, newTarget) { |
| 86 | var breadcrumbs = document.querySelector("#breadcrumbs").getElementsByTagName("A"); |
| 87 | for (var i=0; i< breadcrumbs.length;i++) { |
| 88 | var breadcrumbHref = breadcrumbs[i].getAttribute('href'); |
| 89 | if (breadcrumbHref.indexOf(breadcrumbToFind)>-1) |
| 90 | breadcrumbs[i].setAttribute('href', newTarget); |
| 91 | } |
| 92 | } |
| 93 | |
| 94 | // clipBoardData object not cross-browser supported. Only IE it seems |
| 95 | function copyToClipboard(controlId) { |
| 96 | var control = document.getElementById(controlId); |
| 97 | if (control == null) { |
| 98 | alert("ERROR - control not found - " + controlId); |
| 99 | } else { |
| 100 | var controlValue = control.href; |
| 101 | window.clipboardData.setData("text/plain", controlValue); |
| 102 | alert("Copied text to clipboard : " + controlValue); |
| 103 | } |
| 104 | } |