text: $(document).ready(function() {
      var _token = $('meta[name="_token"]').attr('content');
      var ssl = $('meta[name="ssl"]').attr('content');
  
      function populate_features() {
  
          dataTable = $('#feature_table').DataTable({
              "serverSide": true,
              "processing": false,
              "pageLength": 20,
              "order": [],
              dom: 'Bfrtip',
              buttons: [
                  'copy', 'csv', 'excel', 'pdf', 'print', 'colvis'
              ],
              "ajax": {
                  url: ssl + window.location.hostname + "/customize/feature/list",
                  type: "POST",
                  data: {
                      _token
                  },
              },
              "language": {
                  "paginate": {
                      "previous": "&#706",
                      "next": "&#707"
                  }
              }
          });
  
      }
      populate_features();
  
      $("#feature_table").on("click", '#delete-feature', function() {
          var feature_id = $(this).attr("data-feature-id");
          $.ajax({
              url: ssl + window.location.hostname + "/customize/feature/delete",
              type: "POST",
              data: {
                  'id': feature_id,
                  _token
              },
              success: function(response) {
                  $('#feature_table').DataTable().destroy();
                  populate_features();
                  Swal.fire({
                      title: "SUCCESS!!",
                      text: response,
                      type: "success",
                  });
              },
              error: function(response) {
                  Swal.fire({
                      title: "ERROR!",
                      text: response.responseJSON,
                      type: "error",
                  });
              }
          });
      });
  
      $(document).on('click', '#bulk_delete_feature', function() {
          var id = [];
          Swal.fire({
              title: 'Are you sure?',
              text: "You won't be able to revert this!",
              icon: 'warning',
              showCancelButton: true,
              confirmButtonColor: '#3085d6',
              cancelButtonColor: '#d33',
              confirmButtonText: 'Yes, delete the Selected!'
          }).then((result) => {
              if (result.isConfirmed) {
                  $('.feature_checkbox:checked').each(function() {
                      id.push($(this).val());
                  });
                  if (id.length > 0) {
                      $.ajax({
                          url: ssl + window.location.hostname + "/customize/feature/delete-selected",
                          method: "POST",
                          data: {
                              id: id,
                              _token
                          },
                          success: function(data) {
                              $('#feature_table').DataTable().destroy();
                              populate_features();
                              Swal.fire({
                                  title: "SUCCESS!!",
                                  text: data,
                                  type: "success",
                              });
                          },
                          error: function(response) {
                              Swal.fire({
                                  title: "ERROR!",
                                  text: response.responseJSON,
                                  type: "error",
                              });
                          }
                      });
                  } else {
                      Swal.fire({
                          title: "ERROR!",
                          text: "Please select at least one checkbox",
                          type: "error",
                      });
                  }
              }
          })
      });
      $(document).on('click', '#delete_all_feature', function() {
          Swal.fire({
              title: 'Are you sure?',
              text: "You won't be able to revert this!",
              icon: 'warning',
              showCancelButton: true,
              confirmButtonColor: '#3085d6',
              cancelButtonColor: '#d33',
              confirmButtonText: 'Yes, delete All Features!'
          }).then((result) => {
              if (result.isConfirmed) {
                  $.ajax({
                      url: ssl + window.location.hostname + "/customize/feature/delete-all",
                      method: "POST",
                      data: {
                          _token
                      },
                      success: function(data) {
                          $('#feature_table').DataTable().destroy();
                          populate_features();
                          Swal.fire(
                              'Deleted!',
                              data,
                              'success'
                          )
                      }
                  });
              }
          })
      });
  });