{"size": 1591, "ext": "js", "max_stars_repo_path": "assets/js/pages/target_hafalan_santri.js", "max_stars_repo_name": "masjitsubekti/tahfidz-booster", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "assets/js/pages/target_hafalan_santri.js", "max_issues_repo_name": "masjitsubekti/tahfidz-booster", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "assets/js/pages/target_hafalan_santri.js", "max_forks_repo_name": "masjitsubekti/tahfidz-booster", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 22.7285714286, "max_line_length": 66, "alphanum_fraction": 0.5556253928}
$(document).ready(function() {
  pageLoad(1)
})

$('#search').on('keypress', function(e) {
  if (e.which == 13) {
    pageLoad(1);
  }
});

function pageLoad(page=1) {
  var search = $('#search').val();
  var limit = $('#limit').val();
  var id_th = $('#hidden_id_th').val();
  var column_name = $('#hidden_column_name').val();
  var sort_type = $('#hidden_sort_type').val();
  $.ajax({
    url: base_url + "/Target_hafalan/fetch_target_hafalan_santri",
    type: 'GET',
    dataType: 'html',
    data: {
      page : page,
      sortby : column_name,
      sorttype : sort_type,
      limit : limit,
      search : search,
    },
    beforeSend: function() {},
    success: function(result) {
        $('#list').html(result);
        $('#hidden_page').val(page);
        sort_finish(id_th,sort_type);
    }
  });
}

function sort_table(id, column){
  var sort = $(id).attr("data-sort");
  $('#hidden_id_th').val(id);
  $('#hidden_column_name').val(column);
  
  if(sort=="asc"){
      sort = 'desc';
  }else if(sort=="desc"){
      sort = 'asc';
  }else{
      sort = 'asc';
  }
  $('#hidden_sort_type').val(sort);
  $('#hidden_page').val(1);
  pageLoad(1);
}

$(document).on('click', '.btn-detail', function(event) {
  event.preventDefault();
  var id = $(this).attr('data-id');
  console.log("id", id)
  $.ajax({
    url: base_url + "/Target_hafalan/load_modal_detail",
    type: 'GET',
    dataType: 'html',
    data:{id:id},
    beforeSend: function () {},
    success: function (result) {    
      $('#div_modal').html(result);
      $('#modal-detail').modal('show');
    }
  });
});
