<commit_before><body style="background-color: white">
<div class="main">

  <div style="padding: 20px; overflow: hidden" class="content-part-10">

    <h1 class="text-light">Categories</h1>
    <hr>

    <div style="overflow: hidden" class="content-part-10">

      <div style="padding: 0 10px;margin: 0" class="content-part-7">
        <div class="input-group">
          <span class="input-group-addon" id="basic-addon1">Title</span>
          <input id="title" class="form-control" aria-describedby="basic-addon1">
        </div>
        <button style="margin-bottom: 5px; width: 100%" onclick="load_data()" class="btn btn-sp text-light">SEARCH</button>
      </div>

      <div style="padding: 0 10px;margin: 0" class="content-part-3">
        <button onclick="window.location.href = '/categories/new'" style="margin-bottom: 5px; width: 100%" class="btn btn-success">ADD</button>
        <button onclick="(selected !== null) ? (window.location.href = '/categories/edit?id='+selected.toString()) : null" style="margin-bottom: 5px; width: 100%" class="btn btn-warning">MODIFY</button>
        <button onclick="(selected !== null) ? (destroy()) : null" style="margin-bottom: 5px; width: 100%" class="btn btn-danger" >DISABLE / ENABLE</button>
      </div>

    </div>

    <hr>

    <table border="1" style="width: 100%">
      <thead>
      <tr>
        <th></th>
        <th>ID</th>
        <th>Title</th>
        <th>Active</th>
      </tr>
      </thead>
      <tbody id="data-table">

      </tbody>
    </table>

  </div>

</div>
</body>

<script>

    var selected = null;

    function select_row(id) {
        $('input[name="radio_btn"]').each(function () {
            alert(this.attr('id'))
        });
    }

    function destroy() {
        $.ajax({
            url: '/categories',
            type: 'delete',
            dataType: 'json',
            data: {
                id: selected.toString(),
                "authenticity_token": '<%= form_authenticity_token %>'
            },
            success: function (data) {

                window.location.reload(true);
                //href = '/admin/categories';
            },
            error: function (data) {
                alert(data);
            }
        });
    }

    function load_data() {
        var data_table = document.getElementById('data-table');
        var text = '';
        $.ajax({
            url: '/categories',
            type: 'get',
            dataType: 'json',
            data: {
                title: document.getElementById('title').value
            },
            success: function (data) {
                console.log(data);
                for (var i = 0; i < data.length; i++) {
                    var background_color = data[i]['active'] ? 'white' : '#ff8787';
                    text = text +
                        '<tr style="background: '+ background_color +'">' +
                        '<td><input id="' + data[i]['id'] + '" name="radio_btn" type="radio" onclick="selected = \'' + data[i]['id'] + '\'"></td>' +
                        '<td>' + data[i]['id'] + '</td>' +
                        '<td>' + data[i]['title'] + '</td>' +
                        '<td>' + ((data[i]['active'] === 1) ? 'Active' : 'Disabled')  + '</td>' +
                        '</tr>';
                }
                data_table.innerHTML = text;
            },
            error: function (data) {

            }
        });
    }

    load_data();

</script><commit_msg>Column header change from 'Active' to 'Status'<commit_after><body style="background-color: white">
<div class="main">

  <div style="padding: 20px; overflow: hidden" class="content-part-10">

    <h1 class="text-light">Categories</h1>
    <hr>

    <div style="overflow: hidden" class="content-part-10">

      <div style="padding: 0 10px;margin: 0" class="content-part-7">
        <div class="input-group">
          <span class="input-group-addon" id="basic-addon1">Title</span>
          <input id="title" class="form-control" aria-describedby="basic-addon1">
        </div>
        <button style="margin-bottom: 5px; width: 100%" onclick="load_data()" class="btn btn-sp text-light">SEARCH</button>
      </div>

      <div style="padding: 0 10px;margin: 0" class="content-part-3">
        <button onclick="window.location.href = '/categories/new'" style="margin-bottom: 5px; width: 100%" class="btn btn-success">ADD</button>
        <button onclick="(selected !== null) ? (window.location.href = '/categories/edit?id='+selected.toString()) : null" style="margin-bottom: 5px; width: 100%" class="btn btn-warning">MODIFY</button>
        <button onclick="(selected !== null) ? (destroy()) : null" style="margin-bottom: 5px; width: 100%" class="btn btn-danger" >DISABLE / ENABLE</button>
      </div>

    </div>

    <hr>

    <table border="1" style="width: 100%">
      <thead>
      <tr>
        <th></th>
        <th>ID</th>
        <th>Title</th>
        <th>Status</th>
      </tr>
      </thead>
      <tbody id="data-table">

      </tbody>
    </table>

  </div>

</div>
</body>

<script>

    var selected = null;

    function select_row(id) {
        $('input[name="radio_btn"]').each(function () {
            alert(this.attr('id'))
        });
    }

    function destroy() {
        $.ajax({
            url: '/categories',
            type: 'delete',
            dataType: 'json',
            data: {
                id: selected.toString(),
                "authenticity_token": '<%= form_authenticity_token %>'
            },
            success: function (data) {

                window.location.reload(true);
                //href = '/admin/categories';
            },
            error: function (data) {
                alert(data);
            }
        });
    }

    function load_data() {
        var data_table = document.getElementById('data-table');
        var text = '';
        $.ajax({
            url: '/categories',
            type: 'get',
            dataType: 'json',
            data: {
                title: document.getElementById('title').value
            },
            success: function (data) {
                for (var i = 0; i < data.length; i++) {
                    var background_color = data[i]['active'] ? 'white' : '#ff8787';
                    text = text +
                        '<tr style="background: '+ background_color +'">' +
                        '<td><input id="' + data[i]['id'] + '" name="radio_btn" type="radio" onclick="selected = \'' + data[i]['id'] + '\'"></td>' +
                        '<td>' + data[i]['id'] + '</td>' +
                        '<td>' + data[i]['title'] + '</td>' +
                        '<td>' + ((data[i]['active'] === 1) ? 'Active' : 'Disabled')  + '</td>' +
                        '</tr>';
                }
                data_table.innerHTML = text;
            },
            error: function (data) {

            }
        });
    }

    load_data();

</script>
{'fraction_non_alphanumeric': 0.18537708693149108, 'fraction_numerical': 0.013241220495106506, 'mean_word_length': 1.8099474322684999, 'pattern_counts': {'":': 2, '<': 123, '<?xml version=': 0, '>': 121, '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': '2742372', 'n_tokens_mistral': 2175, 'n_tokens_neox': 2019, 'n_words': 412}