<commit_before>$(function() {
  // global settings
  var options = {
    queryServer: 'http://172.16.31.10:8080/matchp-web/api/',
    imgsRow: 5,
    imgsCol: 4
  }

  // global variables
  var gPageNum      = 0; // total page number
  var gTotalData    = []; // the total data from server

  // jquery DOM objects
  var $imgsPages     = [];
  var $result        = $('#result-container');
  var $imgsContainer = $('#imgs-container');
  var $pager         = $('#pager');
  var $preBtn        = $('#pre-btn');
  var $nxtBtn        = $('#nxt-btn');
  var $pageIndex     = $('#cur-page-index');
  var $pageNum       = $('#total-page-num');
  var $queryText     = $('#query-text');
  var $resultCount   = $('#result-count');

  $.support.cors = true;

  // bind UI element events
  $('#submit').on('click', function(e) {
    e.preventDefault();
    this.disabled = 'disabled'; // disable submit button while fetching data from server

    var that = this;
    var queryText = $queryText.val();
    var queryUrl = options.queryServer + 'query?q=' + queryText;

    $.ajax({
      url: queryUrl,
      dataType: 'json',
      type: 'get',
      success: function(data) {
        resultHandler(data);
        that.disabled = '';
      },
      error: function(xhr, status, err) {
        console.error(queryUrl, status, err.toString());
        alert('Failed to fetch data from server...Orz');
        that.disabled = '';
      }
    });
  });

  $preBtn.on('click', function() {
    var curIndex = +$pageIndex.text() - 1;
    $pageIndex.text(--curIndex + 1);
    showImgsPage(curIndex, -1);
  });

  $nxtBtn.on('click', function() {
    var curIndex = +$pageIndex.text() - 1;
    $pageIndex.text(++curIndex + 1);
    showImgsPage(curIndex, 1);
  });

  // ajax success resultHandler
  function resultHandler(data) {

    // init data for rendering
    gTotalData = data;
    $imgsPages = [];<commit_msg>change front end ajax to post data<commit_after>$(function() {
  // global settings
  var options = {
		  // does it need to be locked?
    queryServer: 'http://localhost:8887/matchp-web/api/',
    imgsRow: 5,
    imgsCol: 4
  }

  // global variables
  var gPageNum      = 0; // total page number
  var gTotalData    = []; // the total data from server

  // jquery DOM objects
  var $imgsPages     = [];
  var $result        = $('#result-container');
  var $imgsContainer = $('#imgs-container');
  var $pager         = $('#pager');
  var $preBtn        = $('#pre-btn');
  var $nxtBtn        = $('#nxt-btn');
  var $pageIndex     = $('#cur-page-index');
  var $pageNum       = $('#total-page-num');
  var $queryText     = $('#query-text');
  var $resultCount   = $('#result-count');

  $.support.cors = true;

  // bind UI element events
  $('#submit').on('click', function(e) {
    e.preventDefault();
    this.disabled = 'disabled'; // disable submit button while fetching data from server

    var that = this;
    var queryText = $queryText.val();
    var queryUrl = options.queryServer + 'query/';
    var queryJson = {
    		text: queryText
    }

    $.ajax({
      url: queryUrl,
      dataType: 'json',
      type: 'POST',
      data: JSON.stringify(queryJson),
      dataType: 'json',
      contentType: "application/json",
      success: function(data) {
        resultHandler(data);
        that.disabled = '';
      },
      error: function(xhr, status, err) {
        console.error(queryUrl, status, err.toString());
        alert('Failed to fetch data from server...Orz');
        that.disabled = '';
      }
    });
  });

  $preBtn.on('click', function() {
    var curIndex = +$pageIndex.text() - 1;
    $pageIndex.text(--curIndex + 1);
    showImgsPage(curIndex, -1);
  });

  $nxtBtn.on('click', function() {
    var curIndex = +$pageIndex.text() - 1;
    $pageIndex.text(++curIndex + 1);
    showImgsPage(curIndex, 1);
  });

  // ajax success resultHandler
  function resultHandler(data) {

    // init data for rendering
    gTotalData = data;
    $imgsPages = [];
{'fraction_non_alphanumeric': 0.17072558373085614, 'fraction_numerical': 0.008787346221441126, 'mean_word_length': 2.4553339115351256, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 1, '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': '233593', 'n_tokens_mistral': 1313, 'n_tokens_neox': 1263, 'n_words': 311}