//// //// //// PROGRAMMERS: when adding new functions, maintain alphabetical order! (Session timeout function added at the end!!) //// //// //****************************************************************************** var sessionSecs var sessionTimerId = null var sessionTimerRunning = false var ThisDoc ThisDoc = document.forms[0] function anchorScroll( aHash ) { location.href = location.href.substr( 0, location.href.indexOf( '#' ) ) + '#' + aHash } //****************************************************************************** function CheckCursor() { if ( document.forms[0].style.cursor == "wait" ) { alert( "A process is still running. " + "Allow process to complete and try again." ) } else if ( ThisDoc === undefined ) { alert( "Document is still loading. " + "Allow load to complete and try again." ) } } //****************************************************************************** function checkUserAccess() { checkEditMode = location.href.toUpperCase().indexOf("?EDIT") checkedOutBy = ThisDoc.CheckedOutBy.value authors1 = ThisDoc.restricted_authors.value authors2 = ThisDoc.Editors.value userRoles1 = ThisDoc.UserRoles.value userName1 = ThisDoc.UserName.value isEditMode = true if( checkEditMode == -1 ) { isEditMode = false } if( isEditMode ) { //check for District role isNotDistrictAdmin = true if( ThisDoc.districtNum.value == "TBD" || ThisDoc.districtNum == "" ) { districtRole = "NODISTRICT" } else { districtRole = "[ADMINDISTRICT" + ThisDoc.districtNum.value + "]" checkDistrict = userRoles1.indexOf( districtRole ) if ( checkDistrict != -1 ) { isNotDistrictAdmin = false } } //check for Admin role checkAdmin = userRoles1.indexOf( "[ADMIN]" ) isNotAdmin = true if( checkAdmin != -1 ) { isNotAdmin = false } //check for User Name in author field(s) isNotAuthor = true checkUser = authors2.indexOf( userName1 ) if( checkUser != -1 ) { isNotAuthor = false } } continueLoad = true if( isEditMode && isNotDistrictAdmin && isNotAdmin && isNotAuthor ) { continueLoad = false newURL = parseURL( "urlstart", location.href ) + "//" + parseURL( "server", location.href ) + "/" + parseURL( "path" , location.href ) + "/" + parseURL( "dbname", location.href ) + "?logout" location.href = newURL alert( "You do not have editor access to this document." + " \nYou will be logged out of the system." ) //window.history.length = 1 //window.close() } return continueLoad } //****************************************************************************** function clearCheckboxes( argFieldName ) { theField = ThisDoc.elements[ argFieldName ] for ( i=0; i < theField.length; i++ ) { theField[i].checked = false } } //****************************************************************************** function CompareDates( Date1, Date2 ) { if ( Date1 == "" && Date2 == "" ) { return "both blank" } if ( Date1 == "" ) { return "Date1 blank" } if ( Date2 == "" ) { return "Date2 blank" } Date1Month = Date1.substr(0, 2) Date1Day = Date1.substr(3, 2) if (Date1.length == 8) { Date1GivenYear = Date1.substr(6, 2) if (Date1GivenYear < 80 ) { Date1Year = "20" + Date1GivenYear } else { Date1Year = "19" + Date1GivenYear } } else { Date1Year = Date1.substr(6, 4) } Date1Answer = Date1Year + Date1Month + Date1Day Date2Month = Date2.substr(0, 2) Date2Day = Date2.substr(3, 2) if (Date2.length == 8) { Date2GivenYear = Date2.substr(6, 2) if (Date2GivenYear < 80 ) { Date2Year = "20" + Date2GivenYear } else { Date2Year = "19" + Date2GivenYear } } else { Date2Year = Date2.substr(6, 4) } Date2Answer = Date2Year + Date2Month + Date2Day if (Date2Answer > Date1Answer) { return "Date2" } else { if (Date2Answer < Date1Answer) { return "Date1" } else { return "Equal" } } } //****************************************************************************** function DeleteDocument() { if ( ThisDoc.app_stat.value != "IN PROGRESS" && ThisDoc.app_stat.value != "FILE COPY" && ThisDoc.app_stat.value != "DENIED" && ThisDoc.app_stat.value != "APPROVED" ) { alert( "Document cannot be deleted under the current Application Status." ) if ( ThisDoc.UserRoles.value.indexOf( "[ADMIN]" ) == -1 ) { return false } } if ( ThisDoc.sub.value == "Yes" ) { alert( "Document cannot be deleted because it is included with application submission." ) if ( ThisDoc.UserRoles.value.indexOf( "[ADMIN]" ) == -1 ) { return false } } if ( ( ThisDoc.UserRoles.value.indexOf( "[ADMIN]" ) > -1 && confirm( "You have authority to delete documents for System Administration " + " purposes.\n\nAre you sure you want to DELETE this document?" ) ) || ( ThisDoc.UserRoles.value.indexOf( "[ADMIN]" ) == -1 && confirm( "Are you sure you want to DELETE this document?" ) ) ) { SetCursor( "wait" ) runAgent( "DeleteDoc" ) } } //****************************************************************************** function DisableRightClick(e) { message = "Right mouse click has been disabled." if ( document.all ) { if ( event.button == 2 || event.button == 3 ) { alert(message) return false } } else if ( document.layers || document.getElementById ) { if ( e.which == 3 ) { alert(message) return false } } } //****************************************************************************** function ensureValidCharacters(obj) { var returnValue = true // var pattern = /[\b\s,0-9,a-z,A-Z,~,`,!,@,#,$,%,^,&,*,(,),\-,_,+,=,\{,\},\[,\],|,\\,:,\;,\',\",<,>,\,,.,\/,?]/ var pattern = /[\b\s,0-9,a-z,A-Z,~,`,!,@,#,$,%,^,&,*,(,),\-,_,+,=,\{,\},\[,\],|,\\,:,\;,\',\",\,,.,\/,?]/ for( i=0; i < obj.value.length; i++ ) { if ( !pattern.test( obj.value.charAt(i) ) ) { obj.style.backgroundColor = "red" obj.focus() alert( '" ' +obj.value.charAt(i) + ' " is not a valid character for submission to DEP.\n\nPlease delete this character to proceed.' ) obj.style.backgroundColor = "white" return false } } return returnValue } //****************************************************************************** function FixString( Original, BadString, GoodString ) { //replaces every occurence of BadString with GoodString in Original string while ( Original.indexOf( BadString ) > -1 ) { Original = Original.replace( BadString, GoodString ) } return Original } //****************************************************************************** function FormatAreaCode( AreaCode ) { AreaCode = RidString( RidString( RidString( AreaCode, "(" ), ")" ), " " ) return ( AreaCode == "" ? "" : "(" + AreaCode + ")" ) } //****************************************************************************** function FormatETN( ETN ) { ETN = RidString( RidString( ETN, "-" ), " " ) return ETN.substring( 0, 2 ) + ( ETN.length > 2 ? "-" : "" ) + ETN.substring( 2 ) } //****************************************************************************** function FormatPhone( Phone ) { Phone = RidString( RidString( Phone, "-" ), " " ) return Phone.substring(0,3) + (Phone.length >3 ? "-" : "") + Phone.substring(3) } //****************************************************************************** function FormatSSN( SSN ) { SSN = RidString( RidString( SSN, "-" ), " " ) return SSN.substring( 0, 3 ) + ( SSN.length > 3 ? "-" : "" ) + SSN.substring( 3, 5 ) + ( SSN.length > 5 ? "-" : "" ) + SSN.substring( 5 ) } //****************************************************************************** function FormatZip( Zip ) { Zip = RidString( RidString( Zip, "-" ), " " ) return Zip.substring( 0, 5 ) + ( Zip.length > 5 ? "-" : "" ) + Zip.substring(5) } //****************************************************************************** function hideLength( fieldName ) { document.all[ fieldName + "Note" ].style.display = "none" } //****************************************************************************** function Include() { if ( location.href.substring( location.href.lastIndexOf( "ans=" ) + 4 ) == "true" ) { ThisDoc.sub.value = ( ThisDoc.sub.value == "Yes" ? "No" : "Yes" ) if ( document.URL.indexOf("&") != -1 ) { location.replace( document.URL.substr( 0, document.URL.indexOf("&") ) ) } ThisDoc.ver.value = "No" ThisDoc.submit() } } //****************************************************************************** function lastScrollGoTo() { if ( ( location.href.toUpperCase().indexOf( "?EDIT" ) > -1 || location.href.toUpperCase().indexOf( "?OPENFORM" ) > -1 ) && parent.BottomLeftFrame.document.forms[0].FirstEdit.value != "Yes" ) { if ( document.all.form && ThisDoc.txtScrollTopSf.value > 0 ) { document.all.form.scrollTop = ThisDoc.txtScrollTopSf.value ThisDoc.txtScrollTopSf.value = 0 } } } //****************************************************************************** function lastScrollSave() { ThisDoc.txtScrollTopSf.value = document.all.form.scrollTop parent.BottomLeftFrame.document.forms[0].FirstEdit.value = "No" } //****************************************************************************** function LoadDoc( Title ) { HideShow = ( location.href.toUpperCase().indexOf("EDITDOCUMENT") == -1 ? "hidden" : "visible" ) if ( window.name == "BottomRightFrame" ) { ThisDoc = document.forms[0] if (Title == "Placeholder") Title = ThisDoc.form_nm.value //////Title = ThisDoc.form_nm.value+ " (Placeholder)" parent.TopRightFrame.document.all.TopRightFrameLabel.innerHTML = Title Include() //alert(parent.DocList.location.href) if ( parent.DocList.location.href.indexOf( "&JpaId" ) < 0 ) { parent.DocList.location.href = parent.DocList.location.href + "&DocId=" + ThisDoc.DocID.value + "&JpaId=" + ThisDoc.jpa_id.value } else { parent.DocList.location.href = parent.DocList.location.href.substr( 0, parent.DocList.location.href.indexOf( "&" ) ) + "&DocId=" + ThisDoc.DocID.value + "&JpaId=" + ThisDoc.jpa_id.value } if ( ThisDoc.FocusField.value != "" && ( location.href.toUpperCase().indexOf( "OPENFORM" ) > -1 | ( location.href.toUpperCase().indexOf( "EDITDOCUMENT" ) > -1 && ( document.referrer.toUpperCase().indexOf( "EDITDOCUMENT" ) > -1 | document.referrer.toUpperCase().indexOf( "OPENFORM" ) > -1 ) ) ) ) { if ( ThisDoc.FocusField.value == "AttachAction" ) { for ( ElementNum=0; ElementNum -1 || location.href.toUpperCase().indexOf( "OPENFORM" ) > -1 ) { showModalDialog( "/" + parseURL( "path", location.href ) + "/jpaHome.nsf/PopUpCalendar?OpenForm", ThisDoc.elements[ DateField ], "dialogHeight:620px; dialogWidth:480px; help:no; status:no; scroll:no" ) } } //****************************************************************************** function popUpDocList() { showModalDialog( location.href.substr( 0, location.href.toUpperCase().lastIndexOf( ".NSF" ) ) + ".NSF/PopUpDocList?OpenForm&PackNo=" + thisDoc.txtPackNoSf.value, window, "dialogHeight:500px; dialogWidth:850px; help:no; status:no" ) } //****************************************************************************** function PopUpEmailAddress( FieldName, Required, Multiple, AddNames, Groups ) { open( "/" + parseURL( "path", location.href ) + "/jpaHome.nsf/PopUpEmailAddress?OpenForm" + "&Names=" + FieldName + "&Required=" + ( Required == null ? "No" : Required ) + "&Multiple=" + ( Multiple == null ? "Yes" : Multiple ) + "&AddNames=" + ( AddNames == null ? "" : AddNames ) + "&Groups=" + ( Groups == null ? "No" : Groups ), "EmailAddress", "height=425, width=650, left=200, top=100, resize=true" ) } //****************************************************************************** function PopUpAddEmailAddress( FieldName, Required, Multiple, AddNames, Groups ) //Inherited from PopUpEmailAddress() above... RG020209 (CQ 509) { open( "/" + parseURL( "path", location.href ) + "/jpaHome.nsf/PopUpAddEmailAddress?OpenForm" + "&Names=" + FieldName + "&Required=" + ( Required == null ? "No" : Required ) + "&Multiple=" + ( Multiple == null ? "Yes" : Multiple ) + "&AddNames=" + ( AddNames == null ? "" : AddNames ) + "&Groups=" + ( Groups == null ? "No" : Groups ), "EmailAddress", "height=325, width=750, left=200, top=100, resize=true" ) } //****************************************************************************** function PopUpFixFieldApplication( OpenDocID ) { open( "/" + parseURL( "path", location.href ) + "/jpaHome.nsf/PopUpFixFieldApplication?OpenForm&DocID=" + OpenDocID, "FixFieldApplication", "height=150,width=500" ) } //****************************************************************************** function PopUpFixFieldManual( OpenDocID ) { open( "/" + parseURL( "path", location.href ) + "/jpaHome.nsf/PopUpFixFieldManual?OpenForm&DocID=" + OpenDocID, "FixFieldManual", "height=200,width=600" ) } //****************************************************************************** function PopUpGoToSection() { showModalDialog( "/" + parseURL( "path", location.href ) + "/jpaApplications.nsf/PopUpGoToSection?OpenForm&" + ThisDoc.form_nm.value, this, "dialogHeight:350px; dialogWidth:275px; help:no; status:no" ) } //****************************************************************************** function PopUpSelectByJpaId() { showModalDialog( "/" + parseURL( "path", location.href ) + "/" + parseURL( "dbname", location.href ) + "/PopUpSelectByJpaId?OpenForm&JPAID=" + ThisDoc.jpa_id.value, window, "dialogHeight:500px; dialogWidth:800px; help:no; status:no" ) } //****************************************************************************** function PopUpShowFields() { open( "/" + parseURL( "path", location.href ) + "/" + parseURL( "dbname", location.href ) + "/PopUpProperties?OpenForm&DocID=" + document.forms[0].DocID.value, "Properties", "height=650, width=790, top=100, left=150" ).focus() } //****************************************************************************** function PopUpUserAccess( FieldName ) { open( "/" + parseURL( "path", location.href ) + "/jpaHome.nsf/PopUpUserAccess?OpenForm&Names=" + FieldName, "SecurityAccess", "height=300,width=650" ) } //****************************************************************************** function PopUpYesNo( Question, Height, Width ) { return showModalDialog( "/" + parseURL( "path", location.href ) + "/jpaHome.nsf/PopUpYesNo?OpenPage", Question, "dialogHeight:" + ( Height == null ? 170 : Height ) + "px; dialogWidth:" + ( Width == null ? 290 : Width ) + "px; help:no; status:no" ) } //****************************************************************************** function reCalcSizes() { if ( form + "" != "undefined" && actions + "" != "undefined" ) { form.style.left = 5; form.style.width = document.body.offsetWidth-5; actions.style.left = 5; actions.style.width = document.body.offsetWidth-5; } } //****************************************************************************** function RidString( YourString, TrashString ) { //removes every occurence of TrashString in YourString while ( YourString.indexOf( TrashString ) > -1 ) { YourString = YourString.replace( TrashString, "" ) } return YourString } //****************************************************************************** function runAgent(value) { var inputs = document.getElementsByTagName("INPUT") for ( var i=0; i -1 ) { theTitle = "Applications" } else if ( location.href.toUpperCase().indexOf( "SUPPORT" ) > -1 ) { theTitle = "Contacts" } else { // theTitle = "Help" //Hidden for NET.JPA.15 - DSH - 04/11/2016 } parent.TopRightFrame.document.all.TopRightFrameLabel.innerHTML = theTitle + " Search " + ( isResults == true ? "Results" : "" ) } //****************************************************************************** function showLength( fieldName ) { document.all[ fieldName + "Note" ].style.display = "inline" document.all[ fieldName + "Len" ].innerHTML = ThisDoc.elements[ fieldName ].value.length } //****************************************************************************** function SortList( ArrayIn ) { for ( a = 0; a <= ArrayIn.length; a++ ) { b = a for ( c = a; c < ArrayIn.length; c++ ) { if ( ArrayIn[c].text.toUpperCase() < ArrayIn[b].text.toUpperCase() ) { b = c } } if ( b > a ) { TmpText = ArrayIn[a].text ArrayIn[a].text = ArrayIn[b].text ArrayIn[b].text = TmpText } } } //****************************************************************************** function TrimString( s ) { //Modified by Rohan - RG062207 //Removes leading & trailing spaces and carriage returns from String variable: s var allWhiteSpacesOnly = /^(\s+)$/ //RegEx to check all white spaces only var LeadingWhiteSpaces = /^((\s|\n)*)([\W\w]*)$/; //RegEx - Leading spaces and carriage returns var TrailingWhiteSpaces = /(\s*$)/; //RegEx - Trailing spaces and carriage returns if( s.search( allWhiteSpacesOnly ) != -1 ){ //This is a blank string with only spaces... //... and now has been trimmed to a blank (null value) --> result = s.replace( allWhiteSpacesOnly, "" ) }else if( s.search( LeadingWhiteSpaces ) != -1 ){ //Needs to be trimmed s = s.replace( LeadingWhiteSpaces , "$3" ) if ( s.search( TrailingWhiteSpaces != -1) ) //... and now has been trimmed to --> result = s.replace( TrailingWhiteSpaces , "" ) }else //do nothing.. I like the string result = s return result; } //****************************************************************************** function UserWantsToContinueWOSaving( OrVerify ) { if ( OrVerify ) { message = "Any changes after last save or verify will be LOST. " } else { message = "Any changes made after your last save will be LOST. " } if ( confirm( message + "\n\nAre you sure you want to continue?\n" ) ) { return false } return true } //****************************************************************************** String.prototype.repeat = function(l) { return new Array(l+1).join(this) } //****************************************************************************** //All the funtions for timout functionality: RG010810 - R7 (CQ 393) function initializeSessionTimer() { sessionSecs = 1800 stopSessionCountdown() startSessionCountdown() parent.TopRightFrame.document.all.TopRightFrameLabel.style.backgroundColor = "#4040C2" } function stopSessionCountdown() { if( sessionTimerRunning ) { clearTimeout( sessionTimerId ) } sessionTimerRunning = false } function startSessionCountdown() { //self.status = " " + sessionSecs if ( sessionSecs == 0 ) { stopSessionCountdown() self.status = "JPA session may have expired!" parent.TopRightFrame.document.all.TopRightFrameLabel.innerHTML = " JPA session may have expired! " parent.TopRightFrame.document.all.UserNameLink.innerHTML = "" } else { if ( sessionSecs == 60 ) { parent.focus() } else if ( sessionSecs == 300 ) { parent.focus() parent.TopRightFrame.document.all.TopRightFrameLabel.style.backgroundColor = "RED" parent.TopRightFrame.document.all.TopRightFrameLabel.style.color = "WHITE" } if ( sessionSecs > 60 ) { self.status = "Your JPA session will expire in less than " + Math.ceil( sessionSecs / 60 ) + " minutes." if ( sessionSecs <= 300 ) { parent.TopRightFrame.document.all.TopRightFrameLabel.innerHTML = " JPA session will expire in less than " + Math.ceil( sessionSecs / 60 ) + " minutes! " } } else { self.status = "Your JPA session will expire in " + sessionSecs + " seconds." parent.TopRightFrame.document.all.TopRightFrameLabel.innerHTML = " JPA session will expire in " + sessionSecs + " seconds! " } sessionSecs = sessionSecs - 1 sessionTimerRunning = true sessionTimerId = self.setTimeout( "startSessionCountdown()", 1000 ) } } //****************************************************************************** //***The following semi-colon must remain at the end of this script!!! ;