/**************************************************************************************************** Purpose: This js file contains javascript functions used by Admin components Author: Avinash Wable (Persistent Systems Pvt. Ltd.) Version: 1.0 Version History: --------------------------------------------------------------- Date User Comments 05/28/2007 Avinash Wable Initial Creation ****************************************************************************************************/ /************************************************************************************************** Purpose: This function sets user details to admin details on the registration page depending upon the checkbox selection by user. ***************************************************************************************************/ function fillAdminDetails() { var form = document.forms['registrationForm']; if (form.sameDetailsIndicator.checked) { form.adminFirstName.value = form.userFirstName.value; form.adminMiddleName.value = form.userMiddleName.value; form.adminLastName.value = form.userLastName.value; form.adminEmail.value = form.userEmail.value; form.adminLoginName.value = form.userLoginName.value; form.adminPassword.value = form.userPassword.value; form.adminConfirmPassword.value = form.userConfirmPassword.value; form.adminPhoneAreaCode.value = form.userPhoneAreaCode.value; form.adminPhoneNumber.value = form.userPhoneNumber.value; form.adminPhoneExtension.value = form.userPhoneExtension.value; form.adminPhoneAlternateAreaCode.value = form.userPhoneAlternateAreaCode.value; form.adminPhoneAlternateNumber.value = form.userPhoneAlternateNumber.value; form.adminPhoneAlternateExtension.value = form.userPhoneAlternateExtension.value; /**make readonly the fields***/ document.getElementById("admin1").readOnly=true document.getElementById("admin2").readOnly=true document.getElementById("admin3").readOnly=true document.getElementById("admin4").readOnly=true document.getElementById("admin5").readOnly=true document.getElementById("admin6").readOnly=true document.getElementById("admin7").readOnly=true document.getElementById("admin8").readOnly=true document.getElementById("admin9").readOnly=true document.getElementById("admin10").readOnly=true document.getElementById("admin11").readOnly=true document.getElementById("admin12").readOnly=true } else { form.adminFirstName.value = ""; form.adminMiddleName.value = ""; form.adminLastName.value = ""; form.adminEmail.value = ""; form.adminLoginName.value = ""; form.adminPassword.value = ""; form.adminConfirmPassword.value = ""; form.adminPhoneAreaCode.value = ""; form.adminPhoneNumber.value = ""; form.adminPhoneExtension.value = ""; form.adminPhoneAlternateAreaCode.value = ""; form.adminPhoneAlternateNumber.value = ""; form.adminPhoneAlternateExtension.value = ""; /**enabled the fields***/ document.getElementById("admin1").readOnly=false document.getElementById("admin2").readOnly=false document.getElementById("admin3").readOnly=false document.getElementById("admin4").readOnly=false document.getElementById("admin5").readOnly=false document.getElementById("admin6").readOnly=false document.getElementById("admin7").readOnly=false document.getElementById("admin8").readOnly=false document.getElementById("admin9").readOnly=false document.getElementById("admin10").readOnly=false document.getElementById("admin11").readOnly=false document.getElementById("admin12").readOnly=false } } /************************************************************************************************** Purpose: This method validates Workgroup Name against the email. So if email contains agilent.com then WG name by default changes to Agilent Technologies ***************************************************************************************************/ function validateWorkgroupName(formName, email){ var form = document.forms[formName]; var userEmail = form[email].value; if(userEmail==null) return; var userEmailDomain = userEmail.substring(userEmail.indexOf('@')+1); if(userEmailDomain.toLowerCase() == "agilent.com" || userEmailDomain.toLowerCase() == "non.agilent.com"){ document.forms[0].country.value = "UNITED STATES"; document.forms[0].workgroupName.value = "Agilent Technologies"; document.forms[0].country.disabled=true; document.forms[0].workgroupName.disabled =true; SelectStates(); }else{ document.forms[0].country.disabled=false; document.forms[0].workgroupName.disabled=false; } } /************************************************************************************************** Purpose: called on registration form submit. This method calls struts client side validation method validateRegistrationForm and then other methods required for validating the form data. ***************************************************************************************************/ function validateRegistrationFormData(form) { document.forms[0].country.disabled=false; document.forms[0].workgroupName.disabled=false; // validate form fields, struts client side validation if (!validateRegistrationForm(form)) { if(document.forms[0].workgroupName.value==""){ document.forms[0].workgroupName.disabled=false; }else{ document.forms[0].workgroupName.disabled=true; } if(document.forms[0].country=="Select"){ document.forms[0].country.disabled=false; }else{ document.forms[0].country.disabled=true; } return false; } // users' passwords should match if (!checkPasswords(form.userPassword, form.userConfirmPassword, "User")) { document.forms[0].country.disabled=true; document.forms[0].workgroupName.disabled=true; return false; } // users state validateion if (!checkState(form)) { document.forms[0].country.disabled=true; document.forms[0].workgroupName.disabled=true; return false; } // Workgroup name validation var userEmail = document.forms[0].userEmail.value; var userEmailDomain = userEmail.substring(userEmail.indexOf('@')+1); if(!(userEmailDomain.toLowerCase() == "agilent.com") && !(userEmailDomain.toLowerCase() == "non.agilent.com")){ if(document.forms[0].workgroupName!=null && document.forms[0].workgroupName.value == "Agilent Technologies"){ openAlertDialog("error",resourceBundle.notalloweddomain); document.forms[0].workgroupName.value=""; return false; } } // all validations successfully passed... proceed. return true; } /************************************************************************************************** Purpose: called on validateRegistrationFormData function. ***************************************************************************************************/ function checkState(form){ var stateValue = form.state.value; var countryValue = form.country.value; if(countryValue!= "UNITED STATES"){ if(countryValue!="Select"){ if(stateValue =="" ){ openAlertDialog("error",resourceBundle.enterStateMessage); return false; } for (i=0; i This method calls struts client side validation method validateRegistrationForm and then other methods required for validating the form data. ***************************************************************************************************/ function validateRegistrationFormAdminData(form) { // validate form fields, struts client side validation if (!validateRegistrationForm(form)) { return false; } // admins' passwords should match if (!checkPasswords(form.adminPassword, form.adminConfirmPassword, "Admin")) { return false; } // all validations successfully passed... proceed. return true; } /************************************************************************************************** Purpose: Check user password and confirmPassword ***************************************************************************************************/ function checkPasswords(password, confirmPassword, userType) { if (password.value != confirmPassword.value) { var msg = userType; var resourceMessage = resourceBundle.userPasswordMatch; msg = msg + " " + resourceMessage; openAlertDialog("error",msg); return false; } else { var messages = new Array(); if (!validatePassword(password.value, messages)) { var resourceMessage = resourceBundle.passwordShouldContain; var message = userType + " " + resourceMessage; for (i=0; i parseInt(maxOligo)){ openAlertDialog("error",resourceBundle.minCanntGreaterThanMax); return false; } if(parseInt(maxOligo)< 2 || parseInt(maxOligo) > 230){ openAlertDialog("error",resourceBundle.maxOligoCondition); return false; } return true; } function isNumeric(value){ var strNum = "0123456789"; var strChar; if(parseInt(value)==0) return false; for(var i=0; i This method calls struts client side validation method validateCreateUserForm and then other methods required for validating the form data. ***************************************************************************************************/ function validateCreateUserFormData(form) { // validate form fields, struts client side validation if (!validateCreateUserForm(form)) { return false; } // users' passwords should match if (!checkPasswords(form.userPassword, form.userConfirmPassword, "User")) { return false; } // users state validateion if (!checkState(form)) { return false; } // all validations successfully passed... proceed. // set all options as selected so that all are available at server side for proccessing selectAllOptions(form.selectedSecondaryFolders); selectAllOptions(form.availableSecondaryFolders); return true; } /************************************************************************************************** Purpose: called on edit user form submit. This method . ***************************************************************************************************/ function selectSecondaryFolders(form) { selectAllOptions(form.selectedSecondaryFolders); selectAllOptions(form.availableSecondaryFolders); return true; } /************************************************************************************************** Purpose: Validates Changes Password page values ***************************************************************************************************/ function validateChangePasswordFormData(form) { // validate form fields, struts client side validation if (!validateChangePasswordForm(form)) { return false; } // users' passwords should match if (!checkPasswords(form.userPassword, form.userConfirmPassword, "User")) { return false; } return true; } /************************************************************************************************** Purpose: Validates Changes Personal Password page values ***************************************************************************************************/ function validateChangePersonalPasswordFormData(form) { // validate form fields, struts client side validation if (!validateChangePersonalPasswordForm(form)) { return false; } // users' passwords should match if (!checkPasswords(form.userPassword, form.userConfirmPassword, "User")) { return false; } return true; } /************************************************************************************************** Purpose: resets ChangePasswordForm data ***************************************************************************************************/ function resetChangePasswordForm(form) { var changePasswordForm = document.forms['changePasswordForm']; changePasswordForm.userPassword.value = ""; changePasswordForm.userConfirmPassword.value = ""; } /************************************************************************************************** Purpose: resets ChangePersonalPasswordForm data ***************************************************************************************************/ function resetChangePersonalPasswordForm(form) { var changePasswordForm = document.forms['changePasswordForm']; changePasswordForm.userPassword.value = ""; changePasswordForm.userConfirmPassword.value = ""; changePasswordForm.currentPassword.value = ""; } /************************************************************************************************** Purpose: This function sets action of changePasswordForm to searchUser/ changePersonalInformation depending upon where it came from and submits changePasswordForm ***************************************************************************************************/ function cancelChangePassword() { var changePasswordForm = document.forms['changePasswordForm']; var requestFrom = changePasswordForm.requestIsFrom.value; if (requestFrom == 'searchuser') { changePasswordForm.action = "searchUser.do?eArrayAction=search"; } else if (requestFrom == 'personalinformation') { changePasswordForm.action = "changePersonalInformation.do?eArrayAction=executeShow"; } else if(requestFrom == 'forcePasswordChange') { var contextpath = ''; if (dojo.isIE) { contextpath = getElementHTML('hiddenContextPath'); } else { contextpath = ".." } changePasswordForm.action = contextpath + "/logout.do"; } changePasswordForm.submit(); } /************************************************************************************************** Purpose: This function sets action of changePasswordForm to changePersonalInformation depending upon where it came from and submits changePasswordForm ***************************************************************************************************/ function cancelChangePersonalPassword() { var changePasswordForm = document.forms['changePasswordForm']; var requestFrom = changePasswordForm.requestIsFrom.value; if (requestFrom == 'personalinformation') { changePasswordForm.action = "changePersonalInformation.do?eArrayAction=executeShow"; } changePasswordForm.submit(); } /************************************************************************************************** Purpose: This function sets retrieveData parameter in the url which causes action to retrieve data from database. ***************************************************************************************************/ function resetCreateUserForm() { var createUserForm = document.forms['createUserForm']; createUserForm.action = "createUser.do?eArrayAction=executeShow&retrieveData=true&resetStatus=true"; createUserForm.submit(); } /************************************************************************************************** Purpose: resets ChangePersonalInformationForm data ***************************************************************************************************/ function resetPersonalInformationForm() { // we are using createUserForm for change personal information page var personalInfoForm = document.forms['createUserForm']; // resetting personal info form means retrieving the current state of user info from database personalInfoForm.action = "changePersonalInformation.do?eArrayAction=executeShow&retrieveData=true"; personalInfoForm.submit(); /* personalInfoForm.userFirstName.value = ""; personalInfoForm.userMiddleName.value = ""; personalInfoForm.userLastName.value = ""; personalInfoForm.userEmail.value = ""; personalInfoForm.userLoginName.value = ""; personalInfoForm.userPhoneAreaCode.value = ""; personalInfoForm.userPhoneNumber.value = ""; personalInfoForm.userPhoneExtension.value = ""; personalInfoForm.userPhoneAlternateAreaCode.value = ""; personalInfoForm.userPhoneAlternateNumber.value = ""; personalInfoForm.userPhoneAlternateExtension.value = ""; personalInfoForm.addressLine1.value = ""; personalInfoForm.addressLine2.value = ""; personalInfoForm.city.value = ""; personalInfoForm.state.value = ""; personalInfoForm.zipCode.value = ""; */ } /************************************************************************************************** Purpose: sets action of UploadUserForm to uploadUser and submits this form ***************************************************************************************************/ function confirmUploadUser() { var uploadUserForm = document.forms['uploadUserForm']; uploadUserForm.action = "uploadUser.do?eArrayAction=uploadData"; uploadUserForm.submit(); } /************************************************************************************************************* Purpose: This function is called when user clicks 'Add New Folder' button on createuser or edituser page. **************************************************************************************************************/ function addNewFolder(formName, actionURL) { if(confirm(resourceBundle.wantToChangeDefaultFolder)) { var sessionId = document.getElementById('sessionId').innerHTML; window.name = "Opener" + sessionId; var winname = "CreateUser_AddNewFolder" ; var popup = window.open('about:blank', winname, 'width=500,height=400,scrollbars=yes,resizable=yes'); popup.opener.name=window.name; var form = document.forms[formName]; form.target = winname; form.action = actionURL + "?eArrayAction=addNewFolder"; form.submit(); form.target = "_self"; } } /************************************************************************************************************* Purpose: This function is called when user clicks 'Add New Folder' button on createuser or edituser page. **************************************************************************************************************/ function setFolder(folderId, folderName) { var form = document.forms['addNewFolderForm']; form.parentFolderId.value = folderId; document.getElementById('parentFolderTD').innerHTML = folderName; } /************************************************************************************************************* Purpose: This function is called when user clicks 'Add New Folder' button on createuser or edituser page. **************************************************************************************************************/ function closeAddNewFolderWindow() { var form = document.forms['addNewFolderForm']; var folderName = form.folderName.value; var parentFolderId = form.parentFolderId.value; window.opener.location.href = "addNewFolder.do?eArrayAction=addFolder&folderName=" + folderName + "&parentFolderId=" + parentFolderId; self.close(); } function deleteFilter(filterID, mode) { var contextpath = ''; if (dojo.isIE) { contextpath = getElementHTML('hiddenContextPath'); } else { contextpath = ".." } if(confirm(resourceBundle.deletefilterconfirm)) { document.forms[0].action = contextpath+"/admin/manageFilter.do?eArrayAction=deleteFilter&FilterID="+filterID+"&mode="+mode; document.forms[0].submit(); } } function editFilter(filterID) { var contextpath = ''; if (dojo.isIE) { contextpath = getElementHTML('hiddenContextPath'); } else { contextpath = ".." } var sessionId=document.getElementById('sessionId').innerHTML; window.name="Opener"+sessionId; var winname = "Filter"+sessionId; var popup=window.open('about:blank',winname,'width=1000,height=500,scrollbars=no,status=yes'); if (dojo.isIE) { popup.opener=window; } else { popup.opener.name=window.name; } document.forms[0].target=winname; document.forms[0].action=contextpath+"/admin/manageFilter.do?eArrayAction=editFilter&filterID="+filterID; document.forms[0].submit(); } function createFilter() { var contextpath = ''; if (dojo.isIE) { contextpath = getElementHTML('hiddenContextPath'); } else { contextpath = ".." } var sessionId=document.getElementById('sessionId').innerHTML; window.name="Opener"+sessionId; var winname = "Filter"+sessionId; var popup=window.open('about:blank',winname,'width=1000,height=500,scrollbars=no,status=yes'); if (dojo.isIE) { popup.opener=window; } else { popup.opener.name=window.name; } document.forms[0].target=winname; document.forms[0].action=contextpath+"/admin/manageFilter.do?eArrayAction=createFilterDisplay"; document.forms[0].submit(); } function setDefaultFilter(filterID) { var contextpath = ''; if (dojo.isIE) { contextpath = getElementHTML('hiddenContextPath'); } else { contextpath = ".." } document.forms[0].target=window.name; document.forms[0].action = contextpath+"/admin/UserPreferenceFilterOptions.do?eArrayAction=setDefaultFilter&FilterID="+filterID; document.forms[0].submit(); } function makePublic(filterID) { var contextpath = ''; if (dojo.isIE) { contextpath = getElementHTML('hiddenContextPath'); } else { contextpath = ".." } document.forms[0].target=window.name; document.forms[0].action = contextpath+"/admin/UserPreferenceFilterOptions.do?eArrayAction=makeFilterPublic&FilterID="+filterID; document.forms[0].submit(); } function displayEditCompanyInfo(personid,orgid) { var contextpath = ''; if (dojo.isIE) { contextpath = getElementHTML('hiddenContextPath'); } else { contextpath = ".." } var kw = { url: contextpath+"/admin/viewCompanyInfo.do?eArrayAction=displayEditPage" + "&organizationId="+orgid + "&ofUserId="+personid, load: function( data) { var datePicker1 = dojo.widget.createWidget("dropdowndatepicker", {widgetId:"dojoCsaAcceptDate",name:"dojoCsaAcceptDate"}, dojo.byId("dojoCsaAcceptDate")); datePicker1.show(); var datePicker2 = dojo.widget.createWidget("dropdowndatepicker", {widgetId:"dojoCsaTerminationDate",name:"dojoCsaTerminationDate"}, dojo.byId("dojoCsaTerminationDate")); datePicker2.show(); }, error: function(type, error) { }, headers: {'X-Requested-With': 'XMLHttpRequest'}, mimetype: "text/html" }; //bind this configuration dojo.xhrPost(kw); var sessionId = document.getElementById('sessionId').innerHTML; var path = contextpath + "/admin/viewCompanyInfo.do?eArrayAction=displayEditPage" + "&organizationId="+orgid + "&ofUserId="+personid; var popup=window.open(path, "UsersShare_"+sessionId, "toolbar=no, scrollbars=yes, location=no, width=700, height=600, resizable=yes"); popup.opener.name=window.name; } function viewUserDesigns(personid) { var contextpath = ''; if (dojo.isIE) { contextpath = getElementHTML('hiddenContextPath'); } else { contextpath = ".." } var sessionId = document.getElementById('sessionId').innerHTML; var path = contextpath + "/ofview/listUserShares.do?eArrayAction=searchDesigns&ofUserId="+personid; var popup=window.open(path, "UsersShare_"+sessionId, "toolbar=no, scrollbars=yes, location=no, width=700, height=600, resizable=yes"); popup.opener.name=window.name; } function saveCompanyInfo() { var emptyString = /^\s*$/ ; //workgroup name var value = document.companyInfoForm.companyName.value; if(value) { value=trim(value); document.companyInfoForm.companyName.value = value; } var field="Company Name"; if(emptyString.test(value)) { openAlertDialog("error",resourceBundle.companyNameRequired); return false; } //company number value = document.companyInfoForm.companyNumber.value; if(value) { value=trim(value); document.companyInfoForm.companyNumber.value = value; } field="Company Number"; if(emptyString.test(value)) { openAlertDialog("error",resourceBundle.companyNumber); return false; } var vExpr = new RegExp("[A-Za-z0-9-_.\b]"); var validdata ="[A-Za-z0-9_.-]"; if(testValue(vExpr,value,validdata)==false) return false; //Done this way because otherwise it throws javascript error. for(var i = 0; i< document.companyInfoForm.length; i++ ) { if(document.companyInfoForm.elements[i].name == 'dojoCsaAcceptDate') { document.companyInfoForm.csaAcceptDate.value=document.companyInfoForm.elements[i].value; } if(document.companyInfoForm.elements[i].name == 'dojoCsaTerminationDate') { document.companyInfoForm.csaTerminationDate.value=document.companyInfoForm.elements[i].value; } } var csaNum = document.companyInfoForm.csaNumber.value; var accptDate = document.companyInfoForm.csaAcceptDate.value; var termDate = document.companyInfoForm.csaTerminationDate.value; var csaField = "CSA Number"; var accptField = "Acceptance Date"; var termField = "Termination Date"; if(emptyString.test(csaNum) && emptyString.test(accptDate) && emptyString.test(termDate)) {}//do nothing else { //if any of the filed is provided, other fields are mandatory. if(!emptyString.test(csaNum) && emptyString.test(accptDate) && emptyString.test(termDate)) { openAlertDialog("error",resourceBundle.acceptenaceTermainationDateRequired); return false; } if(emptyString.test(csaNum) && !emptyString.test(accptDate) && emptyString.test(termDate)) { openAlertDialog("error",resourceBundle.csaNumberTermainationDateRequired); return false; } if(emptyString.test(csaNum) && emptyString.test(accptDate) && !emptyString.test(termDate)) { openAlertDialog("error",resourceBundle.csaNumberAcceptenaceDateRequired); return false; } if(!emptyString.test(csaNum) && !emptyString.test(accptDate) && emptyString.test(termDate)) { openAlertDialog("error",resourceBundle.terminationDateRequired); return false; } if(!emptyString.test(csaNum) && emptyString.test(accptDate) && !emptyString.test(termDate)) { openAlertDialog("error",resourceBundle.acceptanceDateRequired); return false; } if(emptyString.test(csaNum) && !emptyString.test(accptDate) && !emptyString.test(termDate)) { openAlertDialog("error",resourceBundle.csaNumberRequired); return false; } return true; } return true; } function testValue(vRegEx, value, validdata) { var len = value.length; for(var i=0;i\n "); return false; } } return true; } /************************************************************************************************** Purpose: This function sets action of searchForm to set Oligo Length passing it the workgroup(org) id. ***************************************************************************************************/ function assignApplicationRole(organizationId) { var searchForm = document.forms['searchForm']; searchForm.action = "assignApplicationRole.do?eArrayAction=displayAppRolePage&organizationId=" + organizationId; searchForm.submit(); } function viewUserDetails(personId) { var contextpath = ''; if (dojo.isIE) { contextpath = getElementHTML('hiddenContextPath'); } else { contextpath = ".." } var path = contextpath + "/maintenance/viewUserInfo.do?eArrayAction=displayInfo&ofUserId="+personId; document.location.href=path; } function cancelViewPageSupportSpecialist() { var contextpath = ''; if (dojo.isIE) { contextpath = getElementHTML('hiddenContextPath'); } else { contextpath = ".." } var path = contextpath + "/maintenance/SearchUsers.do?eArrayAction=display"; document.location.href=path; } /************************************************************************************************** Purpose: This function sets action of searchForm to set Bait Length passing it the workgroup(org) id. ***************************************************************************************************/ function setBaitLength(organizationId , workgroupName) { var searchForm = document.forms['searchForm']; searchForm.action = "setBaitLength.do?eArrayAction=getBaitLength&organizationId=" + organizationId+"&workgroupName="+workgroupName; searchForm.submit(); } /************************************************************************************************** Purpose: This function validate and submit bait length form. ***************************************************************************************************/ function validateBaitLength(form) { var baitLengtObj = form.selectedBaitLength; var baitLengtObjLength = baitLengtObj.options.length; if( baitLengtObjLength == 0) { openAlertDialog("error",resourceBundle.baitlengthblank); return false; } for (i=0;i') { dojo.byId("statestatusvalue").style.display = 'none'; dojo.byId("statestatuslable").style.display = 'block'; dojo.byId("statedropdownvalue").style.display = 'block'; dojo.byId("defaulttelephonevalue").style.display = 'block'; dojo.byId("nonUStelephonevalue").style.display = 'none'; document.forms[0].selectedstate.value='Select'; } else{ dojo.byId("statestatusvalue").style.display = 'block'; dojo.byId("statestatuslable").style.display = 'block'; dojo.byId("statedropdownvalue").style.display = 'none'; dojo.byId("defaulttelephonevalue").style.display = 'none'; dojo.byId("nonUStelephonevalue").style.display = 'block'; document.forms[0].state.value=''; } } /************************************************************************************************** Purpose: This function sets value of control with name fromFieldName to the value of control with name toFieldName on the form with given name for admin user Details while Registration. ***************************************************************************************************/ function setValueForAdmin(formName, fromFieldName, toFieldName) { var form = document.forms[formName]; var userEmail = form[fromFieldName].value; form[toFieldName].value = form[fromFieldName].value; }