<commit_before>""" This is a python module to convert VA FileMan Like Data to HTML DataTable
"""

from string import Template
"""
  html header using JQuery Table Sorter Plugin
  http://tablesorter.com/docs/
"""

table_sorter_header="""
<script type="text/javascript" src="https://code.jquery.com/jquery-1.11.0.min.js"></script>
<script type="text/javascript" src="https://tablesorter.com/__jquery.tablesorter.js"></script>
<script type="text/javascript" id="js">
  $(document).ready(function() {
  // call the tablesorter plugin
  $("#rpctable").tablesorter({
    // sort on the first column and third column, order asc
    sortList: [[0,0],[2,0]]
  });
}); </script>
"""

"""
  html header using JQuery DataTable Plugin
  https://datatables.net/
"""
data_table_reference = """
<link rel="stylesheet" type="text/css" href="../../css/vivian.css"/>
<link rel="stylesheet" type="text/css" href="../../datatable/css/jquery.dataTables.css"/>
<link rel="stylesheet" type="text/css" href="../../datatable/css/buttons.dataTables.css"/>
<link rel="stylesheet" type="text/css" href="../../datatable/css/dataTables.searchHighlight.css"/>
<script type="text/javascript" src="https://code.jquery.com/jquery-1.11.0.min.js"></script>
<script type="text/javascript" src="../../datatable/js/jquery.dataTables.min.js"></script>
<script type="text/javascript" src="../../datatable/js/buttons.colVis.min.js"></script>
<script type="text/javascript" src="../../datatable/js/jquery.highlight.js"></script>
<script type="text/javascript" src="../../datatable/js/dataTables.searchHighlight.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.32/pdfmake.min.js"></script>
<script type="text/javascript" src="https://cdn.datatables.net/buttons/1.5.1/js/dataTables.buttons.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.32/pdfmake.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.32/vfs_fonts.js"></script>
<script type="text/javascript" src="https://cdn.datatables.net/buttons/1.5.1/js/buttons.html5.min.js"></script>

<!-- Google Analytics -->
<script>
 (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
 (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
 m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
 })(window,document,'script','https://www.google-analytics.com/analytics.js','ga');

 ga('create', 'UA-43872538-6', 'osehra.org');
 ga('send', 'pageview');
</script>
"""

downloadButtons = """
          {
              extend: 'csv',
              title: '${downloadTitle}',
              orientation: 'landscape',
              pageSize: 'LEGAL',
              exportOptions: {
                  columns: ':visible'
              }
          },
          {
              extend: 'pdf',
              title: '${downloadTitle}',
              orientation: 'landscape',
              pageSize: 'LEGAL',
              exportOptions: {
                  columns: ':visible'
              }
          }
"""

data_table_list_init_setup = Template("""
<script type="text/javascript" id="js">
  $$(document).ready(function() {
      $$("#${tableName}").DataTable({
        bInfo: true,
        iDisplayLength: 25,
        pagingType: "full_numbers",
        bStateSave: true,
        bAutoWidth: false,
        buttons: [
""" + downloadButtons + """
        ]
      });
}); </script>
""")

data_table_list_with_columns_init_setup = Template("""
<script type="text/javascript" id="js">
  $(document).ready(function() {
    var table = $("#${tableName}").DataTable({
        bInfo: true,
        dom: '<Bfr<t>ilp>',
        iDisplayLength: 25,
        pagingType: "full_numbers",
        bStateSave: true,<commit_msg>Add limit on PDF download size<commit_after>""" This is a python module to convert VA FileMan Like Data to HTML DataTable
"""

from string import Template
"""
  html header using JQuery Table Sorter Plugin
  http://tablesorter.com/docs/
"""

table_sorter_header="""
<script type="text/javascript" src="https://code.jquery.com/jquery-1.11.0.min.js"></script>
<script type="text/javascript" src="https://tablesorter.com/__jquery.tablesorter.js"></script>
<script type="text/javascript" id="js">
  $(document).ready(function() {
  // call the tablesorter plugin
  $("#rpctable").tablesorter({
    // sort on the first column and third column, order asc
    sortList: [[0,0],[2,0]]
  });
}); </script>
"""

"""
  html header using JQuery DataTable Plugin
  https://datatables.net/
"""
data_table_reference = """
<link rel="stylesheet" type="text/css" href="../../css/vivian.css"/>
<link rel="stylesheet" type="text/css" href="../../datatable/css/jquery.dataTables.css"/>
<link rel="stylesheet" type="text/css" href="../../datatable/css/buttons.dataTables.css"/>
<link rel="stylesheet" type="text/css" href="../../datatable/css/dataTables.searchHighlight.css"/>
<script type="text/javascript" src="https://code.jquery.com/jquery-1.11.0.min.js"></script>
<script type="text/javascript" src="../../datatable/js/jquery.dataTables.min.js"></script>
<script type="text/javascript" src="../../datatable/js/buttons.colVis.min.js"></script>
<script type="text/javascript" src="../../datatable/js/jquery.highlight.js"></script>
<script type="text/javascript" src="../../datatable/js/dataTables.searchHighlight.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.32/pdfmake.min.js"></script>
<script type="text/javascript" src="https://cdn.datatables.net/buttons/1.5.1/js/dataTables.buttons.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.32/pdfmake.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.32/vfs_fonts.js"></script>
<script type="text/javascript" src="https://cdn.datatables.net/buttons/1.5.1/js/buttons.html5.min.js"></script>

<!-- Google Analytics -->
<script>
 (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
 (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
 m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
 })(window,document,'script','https://www.google-analytics.com/analytics.js','ga');

 ga('create', 'UA-43872538-6', 'osehra.org');
 ga('send', 'pageview');
</script>
"""

downloadButtons = """
          {
              extend: 'csv',
              title: '${downloadTitle}',
              orientation: 'landscape',
              pageSize: 'LEGAL',
              exportOptions: {
                  columns: ':visible'
              }
          },
          {
              extend: 'pdf',
              title: '${downloadTitle}',
              orientation: 'landscape',
              pageSize: 'LEGAL',
              exportOptions: {
                  columns: ':visible'
              },
              customize: function (doc) {
                  // Taken from https://stackoverflow.com/questions/35642802/datatables-export-pdf-with-100-width
                  var colCount = new Array();
                  var length = $$('#${tableName} tbody tr:first-child td').length;
                  console.log('length / number of td in report one record = '+length);
                  $$('#${tableName}').find('tbody tr:first-child td').each(function(){
                      colCount.push(parseFloat(100 / length)+'%');
                  });
                  doc.content[1].table.widths = colCount;
              }
          }
"""

data_table_list_init_setup = Template("""
<script type="text/javascript" id="js">
  $$(document).ready(function() {
      $$("#${tableName}").DataTable({
        bInfo: true,
        iDisplayLength: 25,
        pagingType: "full_numbers",
        bStateSave: true,
        bAutoWidth: false,
        buttons: [
""" + downloadButtons + """
        ]
      });
}); </script>
""")

data_table_list_with_columns_init_setup = Template("""
<script type="text/javascript" id="js">
  $(document).ready(function() {
    var table = $("#${tableName}").DataTable({
        bInfo: true,
        dom: '<Bfr<t>ilp>',
        iDisplayLength: 25,
        pagingType: "full_numbers",
        bStateSave: true,
{'fraction_non_alphanumeric': 0.20122537241710717, 'fraction_numerical': 0.013094666025949064, 'mean_word_length': 3.1604197901049473, 'pattern_counts': {'":': 0, '<': 79, '<?xml version=': 0, '>': 79, 'https://': 21, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 9, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5821041', 'n_tokens_mistral': 2717, 'n_tokens_neox': 2629, 'n_words': 408}