<commit_before><%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-tiles.tld" prefix="tiles" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<%@ taglib tagdir="/WEB-INF/tags" prefix="im" %>

<!-- table.jsp -->

<tiles:importAttribute/>
<html:xhtml/>

<c:if test="${!empty param.trail}">
  <tiles:get name="objectTrail.tile"/><im:vspacer height="3"/>
</c:if>

<script type="text/javascript">
  <!--//<![CDATA[
    function selectColumnCheckbox(column, dataType) {
      selectColumnCheckboxes(column + dataType);
      disableAllOthers(dataType);
      if (isClear()) {
        enableAll();
      }
    }
    function disableAllOthers(dataType) {
      if (dataType == 'primitive') {
        disableAllOfType('object');
      } else {
        disableAllOfType('primitive');
      }
    }
    function disableAllOfType(dataType) {
      with(document.saveBagForm) {
        for(i=0;i < elements.length;i++) {
          thiselm = elements[i];
          if(thiselm.id.indexOf('selectedObjects_') != -1 && thiselm.id.indexOf(dataType) != -1) {
            thiselm.disabled = true;
          }
        }
      }
    }
    function enableAll() {
      with(document.saveBagForm) {
        for(i=0;i < elements.length;i++) {
          thiselm = elements[i];
          if(thiselm.id.indexOf('selectedObjects_') != -1) {
            thiselm.disabled = false;
          }
        }
      }
    }
    function isClear() {
      with(document.saveBagForm) {
        for(i=0;i < elements.length;i++) {
          thiselm = elements[i];
          if(thiselm.id.indexOf('selectedObjects_') != -1 && thiselm.checked) {
            return false;
          }
        }
      }
      return true;
    }
    function selectColumnCheckboxes(column) {
      var columnCheckBox = 'selectedObjects_' + column;
      with(document.saveBagForm) {
      for(i=0;i < elements.length;i++) {
        thiselm = elements[i];
        var testString = 'selectedObjects_' + column + '_';
        if(thiselm.id.indexOf(testString) != -1)
          thiselm.checked = document.getElementById(columnCheckBox).checked;
        }
      }
    }
    function itemChecked(column, dataType) {
      unselectColumnCheckbox('' + column + dataType);
      disableAllOthers(dataType);
      if (isClear()) {
        enableAll();
      }
    }
    function unselectColumnCheckbox(column) {
      document.getElementById('selectedObjects_' + column).checked = false;
    }
    function changePageSize() {
      var url = '${requestScope['javax.servlet.include.context_path']}/results.do?';
      var pagesize = document.changeTableSizeForm.pageSize.options[document.changeTableSizeForm.pageSize.selectedIndex].value;
      var page = ${resultsTable.startRow}/pagesize;
      url += 'table=${param.table}' + '&page=' + Math.floor(page) + '&size=' + pagesize;
      if ('${param.trail}' != '') {
      	url += '&trail=${param.trail}';
      }
      document.location.href=url;
    }
    //]]>-->
</script>

<c:choose>
  <c:when test="${resultsTable.size == 0}">
    <div class="body">
      <fmt:message key="results.pageinfo.empty"/><br/>
    </div>
  </c:when>
  <c:otherwise>
  
    <html:form action="/changeTableSize">
      <div class="body">
        <%-- Page size controls --%>
        <fmt:message key="results.changepagesize"/>
        <html:select property="pageSize" onchange="changePageSize()">
          <html:option value="10">10</html:option>
          <html:option value="25">25</html:option>
          <html:option value="50">50</html:option>
          <html:option value="100">100</html:option>
        </html:select>
        <input type="hidden" name="table" value="${param.table}"/>
        <input type="hidden" name="trail" value="${param.trail}"/>
        <noscript>
          <html:submit>
            <fmt:message key="button.change"/>
          </html:submit>
        </noscript>
      </div>
    </html:form>
    
    <div class="body">
      <p><tiles:insert page="/tablePageLinks.jsp"/></p>
    </div>
    
    <html:form action="/saveBag">
    <div class="body">

      <table class="results" cellspacing="0">
        
        <%-- The headers --%>
        <tr>
          <c:forEach var="column" items="${resultsTable.columns}" varStatus="status">
          
            <c:set var="dataType">
              <c:choose>
                <c:when test="${column.type.class.name == 'org.intermine.metadata.ClassDescriptor'}">object</c:when>
                <c:otherwise>primitive</c:otherwise>
              </c:choose>
            </c:set>
          
            <th align="center" rowspan="2">
              <html:multibox property="selectedObjects" styleId="selectedObjects_${status.index}${dataType}"
                             onclick="selectColumnCheckbox(${status.index}, '${dataType}')">
                <c:out value="${status.index}"/>
              </html:multibox>
            </th>

            <th align="center" valign="top" style="border-bottom: none">
              <div>
                <c:out value="${fn:replace(column.name, '.', ' > ')}"/>
              </div>
            </th>
          </c:forEach>
        </tr>

        <tr>
          <c:forEach var="column" items="${resultsTable.columns}" varStatus="status">
            <th align="center">
              <div style="white-space:nowrap">

                <%-- left --%>
                <c:choose>
                  <c:when test="${status.first}">
                    <%-- since this blank GIF is displayed only to balance
                         the right arrow at the other end of the div, it's
                         not needed if there is no arrow --%>
                    <c:if test="${not status.last}">
                      <img style="margin-right: 5px" border="0" align="middle" 
                           src="images/blank13x13.gif" alt=" " width="13"<commit_msg>Fixes #330 Disable select all when there are lots of results<commit_after><%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-tiles.tld" prefix="tiles" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<%@ taglib tagdir="/WEB-INF/tags" prefix="im" %>

<!-- table.jsp -->

<tiles:importAttribute/>
<html:xhtml/>

<c:if test="${!empty param.trail}">
  <tiles:get name="objectTrail.tile"/><im:vspacer height="3"/>
</c:if>

<script type="text/javascript">
  <!--//<![CDATA[
    function selectColumnCheckbox(column, dataType) {
      selectColumnCheckboxes(column + dataType);
      disableAllOthers(dataType);
      if (isClear()) {
        enableAll();
      }
    }
    function disableAllOthers(dataType) {
      if (dataType == 'primitive') {
        disableAllOfType('object');
      } else {
        disableAllOfType('primitive');
      }
    }
    function disableAllOfType(dataType) {
      with(document.saveBagForm) {
        for(i=0;i < elements.length;i++) {
          thiselm = elements[i];
          if(thiselm.id.indexOf('selectedObjects_') != -1 && thiselm.id.indexOf(dataType) != -1) {
            thiselm.disabled = true;
          }
        }
      }
    }
    function enableAll() {
      with(document.saveBagForm) {
        for(i=0;i < elements.length;i++) {
          thiselm = elements[i];
          if(thiselm.id.indexOf('selectedObjects_') != -1) {
            thiselm.disabled = false;
          }
        }
      }
    }
    function isClear() {
      with(document.saveBagForm) {
        for(i=0;i < elements.length;i++) {
          thiselm = elements[i];
          if(thiselm.id.indexOf('selectedObjects_') != -1 && thiselm.checked) {
            return false;
          }
        }
      }
      return true;
    }
    function selectColumnCheckboxes(column) {
      var columnCheckBox = 'selectedObjects_' + column;
      with(document.saveBagForm) {
      for(i=0;i < elements.length;i++) {
        thiselm = elements[i];
        var testString = 'selectedObjects_' + column + '_';
        if(thiselm.id.indexOf(testString) != -1)
          thiselm.checked = document.getElementById(columnCheckBox).checked;
        }
      }
    }
    function itemChecked(column, dataType) {
      unselectColumnCheckbox('' + column + dataType);
      disableAllOthers(dataType);
      if (isClear()) {
        enableAll();
      }
    }
    function unselectColumnCheckbox(column) {
      document.getElementById('selectedObjects_' + column).checked = false;
    }
    function changePageSize() {
      var url = '${requestScope['javax.servlet.include.context_path']}/results.do?';
      var pagesize = document.changeTableSizeForm.pageSize.options[document.changeTableSizeForm.pageSize.selectedIndex].value;
      var page = ${resultsTable.startRow}/pagesize;
      url += 'table=${param.table}' + '&page=' + Math.floor(page) + '&size=' + pagesize;
      if ('${param.trail}' != '') {
      	url += '&trail=${param.trail}';
      }
      document.location.href=url;
    }
    //]]>-->
</script>

<c:choose>
  <c:when test="${resultsTable.size == 0}">
    <div class="body">
      <fmt:message key="results.pageinfo.empty"/><br/>
    </div>
  </c:when>
  <c:otherwise>
  
    <html:form action="/changeTableSize">
      <div class="body">
        <%-- Page size controls --%>
        <fmt:message key="results.changepagesize"/>
        <html:select property="pageSize" onchange="changePageSize()">
          <html:option value="10">10</html:option>
          <html:option value="25">25</html:option>
          <html:option value="50">50</html:option>
          <html:option value="100">100</html:option>
        </html:select>
        <input type="hidden" name="table" value="${param.table}"/>
        <input type="hidden" name="trail" value="${param.trail}"/>
        <noscript>
          <html:submit>
            <fmt:message key="button.change"/>
          </html:submit>
        </noscript>
      </div>
    </html:form>
    
    <div class="body">
      <p><tiles:insert page="/tablePageLinks.jsp"/></p>
    </div>
    
    <html:form action="/saveBag">
    <div class="body">

      <table class="results" cellspacing="0">
        
        <%-- The headers --%>
        <tr>
          <c:forEach var="column" items="${resultsTable.columns}" varStatus="status">
          
            <c:set var="dataType">
              <c:choose>
                <c:when test="${column.type.class.name == 'org.intermine.metadata.ClassDescriptor'}">object</c:when>
                <c:otherwise>primitive</c:otherwise>
              </c:choose>
            </c:set>
          
            <th align="center" rowspan="2">
              <html:multibox property="selectedObjects" styleId="selectedObjects_${status.index}${dataType}"
                             onclick="selectColumnCheckbox(${status.index}, '${dataType}')"
                             disabled="${resultsTable.maxRetrievableIndex > resultsTable.size ? 'false' : 'true'}">
                <c:out value="${status.index}"/>
              </html:multibox>
            </th>

            <th align="center" valign="top" style="border-bottom: none">
              <div>
                <c:out value="${fn:replace(column.name, '.', ' > ')}"/>
              </div>
            </th>
          </c:forEach>
        </tr>

        <tr>
          <c:forEach var="column" items="${resultsTable.columns}" varStatus="status">
            <th align="center">
              <div style="white-space:nowrap">

                <%-- left --%>
                <c:choose>
                  <c:when test="${status.first}">
                    <%-- since this blank GIF is displayed only to balance
                         the right arrow at the other end of the div, it's
                         not needed if there is no arrow --%>
                    <c:if test="${not status.last}">
                      <img style="margin-right: 5px" border="0" align="middle" 
                           src="images/blank13x13.gif" alt=" " width="13"
{'fraction_non_alphanumeric': 0.1713911191217434, 'fraction_numerical': 0.006636080616090448, 'mean_word_length': 2.1731219131791004, 'pattern_counts': {'":': 0, '<': 189, '<?xml version=': 0, '>': 182, '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': '895516', 'n_tokens_mistral': 3841, 'n_tokens_neox': 3708, 'n_words': 603}