<commit_before> <jsp:directive.page import="edu.wustl.catissuecore.domain.ConsentTier"/>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html"%>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic"%>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean"%>
<%@ taglib uri="/WEB-INF/nlevelcombo.tld" prefix="ncombo" %>
<%@ page import="edu.wustl.catissuecore.util.global.Utility"%>
<%@ page import="edu.wustl.catissuecore.actionForm.*"%>

<!-- 
	 @author <NAME> 
	 @version 1.1	
	 Jsp name: ConsentTracking.jsp
	 Company: Washington University, School of Medicine, St. Louis.
-->						
<script language="JavaScript">

var consentIDArray=new Array(<%=form.getConsentTierCounter()%>);
var changeInStatus=false;

function changeInResponse(responseIdkey)
{
	var index=-1;
	var flag=false;
	for(i=0;i<consentIDArray.length;i++)
	{
		if(consentIDArray[i]==responseIdkey)
		{
			flag=true;
			break;
		}
		if(consentIDArray[i]!=null&&consentIDArray[i]!="")
		{
			index=i;
		}
	}
	if(flag==false)
	{
		consentIDArray[index+1]=responseIdkey;
		changeInStatus=true;
	}	
}

function submitString()
{
	var str="";
	str=consentIDArray[0];
	for(i=1;i<consentIDArray.length;i++)
	{
		if(consentIDArray[i]!=null)
		{
			str=str+","+consentIDArray[i];
		}
	}
	document.forms[0].stringOfResponseKeys.value=str;
	//document.forms[0].submit();
}


<%-- On calling this function all the response dropdown value set to "Withdraw" --%>
function withdrawAll(element)
{	
	var withdraw = "<%=form.getConsentTierMap()%>";
	for(var i=0;i<element;i++)
	{
		var withdrawId = withdraw.replace(/`/,i);
		var withdrawObject = document.getElementById(withdrawId);
		if(withdrawObject.options.length==1)
		{
			withdrawObject.selectedIndex=0; 
		}
		else
		{
			withdrawObject.selectedIndex=3; 
		}
	
	}
}

<%--Popup Window will open up on calling this function--%>	
function popupWindow(nofConsentTiers)
{
	<%
		List specimenList = (List)session.getAttribute(Constants.SPECIMEN_LIST);
	%>
	var withdraw = "<%=form.getConsentTierMap()%>";
	var iCount=nofConsentTiers;
	for(var i=0;i<nofConsentTiers;i++)
	{
		var withdrawId = withdraw.replace(/`/,i);
		var withdrawObject = document.getElementById(withdrawId);
		if(withdrawObject.value=="Withdrawn")
		{
			iCount--;
		}
	}	
	<%--When Withdraw All button is clicked--%>	
	if(iCount==0)
	{
		var url="pages/content/ConsentTracking/consentDialog.jsp?withrawall=true&response=withdraw&pageOf="+"<%=pageOf%>";
		window.open(url,'WithdrawAll','height=200,width=550,scrollbars=1,resizable=1');
	}
	else if(iCount==nofConsentTiers)
	{	
		
		<%
			if(pageOf.equals("pageOfConsent"))
			{
		%>
			document.forms[0].submit();
			self.close();
		<%
			}
		%>
		
		if(changeInStatus==false)
		{
			<%
				Object formInstance = form;
				if(formInstance instanceof NewSpecimenForm)
				{
			%>
					return onNormalSubmit();
			<%
				}
				else
			   {
			%>
					return <%=normalSubmit%>;
			<%
			   }
			%>
		}
		else
		{
			submitString();
			<%	
			if(specimenList.size()>1 || !(pageOf.equals("pageOfNewSpecimenCPQuery")))
			{
			%>	
		
				var url="pages/content/ConsentTracking/consentDialog.jsp?withrawall=true&response=nowithdraw&pageOf="+"<%=pageOf%>";
				window.open(url,'WithdrawAll','height=200,width=550,scrollbars=1,resizable=1');
			<%}
			else
			{%>
				document.forms[0].action="<%=Constants.CP_QUERY_SPECIMEN_EDIT_ACTION%>";
				document.forms[0].submit();
			<%}
			%>
		}
		
	}	
	else
	{
		var url="pages/content/ConsentTracking/consentDialog.jsp?withrawall=false&response=withdraw&pageOf="+"<%=pageOf%>";
		window.open(url,'Withdraw','height=200,width=550,scrollbars=1,resizable=1');
	}
}	

</script>							

<%-- Set Variables according to the pages --%>
<%<commit_msg>Added null check - refer to bug 5900<commit_after> <jsp:directive.page import="edu.wustl.catissuecore.domain.ConsentTier"/>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html"%>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic"%>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean"%>
<%@ taglib uri="/WEB-INF/nlevelcombo.tld" prefix="ncombo" %>
<%@ page import="edu.wustl.catissuecore.util.global.Utility"%>
<%@ page import="edu.wustl.catissuecore.actionForm.*"%>

<!-- 
	 @author <NAME> 
	 @version 1.1	
	 Jsp name: ConsentTracking.jsp
	 Company: Washington University, School of Medicine, St. Louis.
-->						
<script language="JavaScript">

var consentIDArray=new Array(<%=form.getConsentTierCounter()%>);
var changeInStatus=false;

function changeInResponse(responseIdkey)
{
	var index=-1;
	var flag=false;
	for(i=0;i<consentIDArray.length;i++)
	{
		if(consentIDArray[i]==responseIdkey)
		{
			flag=true;
			break;
		}
		if(consentIDArray[i]!=null&&consentIDArray[i]!="")
		{
			index=i;
		}
	}
	if(flag==false)
	{
		consentIDArray[index+1]=responseIdkey;
		changeInStatus=true;
	}	
}

function submitString()
{
	var str="";
	str=consentIDArray[0];
	for(i=1;i<consentIDArray.length;i++)
	{
		if(consentIDArray[i]!=null)
		{
			str=str+","+consentIDArray[i];
		}
	}
	document.forms[0].stringOfResponseKeys.value=str;
	//document.forms[0].submit();
}


<%-- On calling this function all the response dropdown value set to "Withdraw" --%>
function withdrawAll(element)
{	
	var withdraw = "<%=form.getConsentTierMap()%>";
	for(var i=0;i<element;i++)
	{
		var withdrawId = withdraw.replace(/`/,i);
		var withdrawObject = document.getElementById(withdrawId);
		if(withdrawObject.options.length==1)
		{
			withdrawObject.selectedIndex=0; 
		}
		else
		{
			withdrawObject.selectedIndex=3; 
		}
	
	}
}

<%--Popup Window will open up on calling this function--%>	
function popupWindow(nofConsentTiers)
{
	<%
		List specimenList = (List)session.getAttribute(Constants.SPECIMEN_LIST);
	%>
	var withdraw = "<%=form.getConsentTierMap()%>";
	var iCount=nofConsentTiers;
	for(var i=0;i<nofConsentTiers;i++)
	{
		var withdrawId = withdraw.replace(/`/,i);
		var withdrawObject = document.getElementById(withdrawId);
		if(withdrawObject.value=="Withdrawn")
		{
			iCount--;
		}
	}	
	<%--When Withdraw All button is clicked--%>	
	if(iCount==0)
	{
		var url="pages/content/ConsentTracking/consentDialog.jsp?withrawall=true&response=withdraw&pageOf="+"<%=pageOf%>";
		window.open(url,'WithdrawAll','height=200,width=550,scrollbars=1,resizable=1');
	}
	else if(iCount==nofConsentTiers)
	{	
		
		<%
			if(pageOf.equals("pageOfConsent"))
			{
		%>
			document.forms[0].submit();
			self.close();
		<%
			}
		%>
		
		if(changeInStatus==false)
		{
			<%
				Object formInstance = form;
				if(formInstance instanceof NewSpecimenForm)
				{
			%>
					return onNormalSubmit();
			<%
				}
				else
			   {
			%>
					return <%=normalSubmit%>;
			<%
			   }
			%>
		}
		else
		{
			submitString();
			<%	
			if(specimenList!=null && specimenList.size()>1 || !(pageOf.equals("pageOfNewSpecimenCPQuery")))
			{
			%>	
		
				var url="pages/content/ConsentTracking/consentDialog.jsp?withrawall=true&response=nowithdraw&pageOf="+"<%=pageOf%>";
				window.open(url,'WithdrawAll','height=200,width=550,scrollbars=1,resizable=1');
			<%}
			else
			{%>
				document.forms[0].action="<%=Constants.CP_QUERY_SPECIMEN_EDIT_ACTION%>";
				document.forms[0].submit();
			<%}
			%>
		}
		
	}	
	else
	{
		var url="pages/content/ConsentTracking/consentDialog.jsp?withrawall=false&response=withdraw&pageOf="+"<%=pageOf%>";
		window.open(url,'Withdraw','height=200,width=550,scrollbars=1,resizable=1');
	}
}	

</script>							

<%-- Set Variables according to the pages --%>
<%
{'fraction_non_alphanumeric': 0.1811720531044656, 'fraction_numerical': 0.012069196727906665, 'mean_word_length': 4.369330453563715, 'pattern_counts': {'":': 0, '<': 77, '<?xml version=': 0, '>': 69, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4548587', 'n_tokens_mistral': 3288, 'n_tokens_neox': 2849, 'n_words': 351}