<commit_before><div id="item_table" class="bb">
  <!-- <div class="item_table_row template"> -->
    <div class="item_table_cell template bb">
      <div class="contents bb">
        <div class="title"></div>
        <div class="img"></div>
        <div class="rep">
          <select class="rep_select">
            <option value="1">1</option>
            <option value="2">2</option>
            <option value="3">3</option>
            <option value="4">4</option>
            <option value="5">5</option>
          </select>
        </div>
      </div>
    </div>
  <!-- </div> -->
</div>

<input id="user_id" type="hidden" value="<?= $this->user_id ?>" />

<button id="sendBtn">送信</button>

<?php

$this->inlineScript()->appendScript(
<<<__END__

var \$itemTable = \$("#item_table"),
    // \$itemRowTmp = \$itemTable.find(".item_table_row").removeClass("template").remove(),
    \$itemCellTmp = \$itemTable.find(".item_table_cell").removeClass("template").remove(),
    canSendFlag = false, items = [],
    userId = $("#user_id").val();

function setRecommendations(_items){
  for(var i in _items){
    var item = _items[i];
    var \$itemCell = \$itemCellTmp.clone();
    log("item", item);
    \$itemCell.attr("data-id", item["id"]);
    \$itemCell.find(".title").text(item["title"]);
    \$itemCell.find(".img").css({"background": "url(\""+item["img"]+"\") no-repeat center center / contain"});
    \$itemTable.append(\$itemCell);
  }
}


function getRecoms() {
  var url = "http://localhost/app/rvr/"+userId,
      query = {};

  log("get recoms", url);

  post({
    "url": url,
    "type": "get",
    "query": query,
    "success": function(_data){
      log("success", _data);
      setRecommendations(_data["items"]);
    },
    "failure": function(_data){
      log("failure", _data);
    }
  });
}






$(function main(){
  getRecoms();
})();



$("#sendBtn").on("click", function(){
  log("a");
  var id = 1
      query = {"text": "<PASSWORD>est"};
  // post({
  //   "url": "http://localhost/app/test",
  //   "type": "post",
  //   "query": query,
  //   "callback": function(_result, _data){
  //     log(_result, _data);
  //     if(!_result){ $("#a1").html(_data["response"]); }
  //   }
  // });
});











function log(_){ console.log.apply(console, arguments); }
function post(_opt){
  var url = _opt["url"],
      type = _opt["type"],
      query = _opt["query"],
      successCB = _opt["success"],
      failureCB = _opt["failure"];
  $.ajax({
    "type": type,<commit_msg>send button activated but not sending<commit_after><div id="item_table" class="bb">
  <!-- <div class="item_table_row template"> -->
    <div class="item_table_cell template bb">
      <div class="contents bb">
        <div class="title"></div>
        <div class="img"></div>
        <div class="rep">
          <select class="rep_select">
            <option value="0" "selected">-</option>
            <option value="1">1</option>
            <option value="2">2</option>
            <option value="3">3</option>
            <option value="4">4</option>
            <option value="5">5</option>
          </select>
        </div>
      </div>
    </div>
  <!-- </div> -->
</div>

<input id="user_id" type="hidden" value="<?= $this->user_id ?>" />

<button id="sendBtn">送信</button>

<?php

$this->inlineScript()->appendScript(
<<<__END__

var \$itemTable = \$("#item_table"),
    // \$itemRowTmp = \$itemTable.find(".item_table_row").removeClass("template").remove(),
    \$itemCellTmp = \$itemTable.find(".item_table_cell").removeClass("template").remove(),
    canSendFlag = false, items = [],
    userId = $("#user_id").val();


getRecoms();

$("#sendBtn").on("click", function(){
  if(!canSendFlag){ return; }
  canSendFlag = false;
  postReputations();
});





function setRecommendations(_items){
  for(var i in _items){
    var item = _items[i];
    var \$itemCell = \$itemCellTmp.clone();
    // log("item", item);
    \$itemCell.attr("data-id", item["id"]);
    \$itemCell.find(".title").text(item["title"]);
    \$itemCell.find(".img").css({"background": "url(\""+item["img"]+"\") no-repeat center center / contain"});
    \$itemTable.append(\$itemCell);
  }
}


function getRecoms() {
  var url = "http://localhost/app/rvr/"+userId,
      query = {};

  log("get recoms", url);

  post({
    "url": url,
    "type": "get",
    "query": query,
    "success": function(_data){
      log("success", _data);
      setRecommendations(_data["items"]);
      canSendFlag = true;
    },
    "failure": function(_data){
      log("failure", _data);
    }
  });
}



function postReputations() {
  log("post reputation");
  return;
  var url = "http://localhost/app/reps/"+userId,
      query = {"reps": []};
  post({
    "url": url,
    "type": "post",
    "query": query,
    "success": function(_data){
      log("success", _data);
      setRecommendations(_data["items"]);
    },
    "failure": function(_data){
      log("failure", _data);
    }
  });
}







function log(_){ console.log.apply(console, arguments); }
function post(_opt){
  var url = _opt["url"],
      type = _opt["type"],
      query = _opt["query"],
      successCB = _opt["success"],
      failureCB = _opt["failure"];
  $.ajax({
    "type": type,
{'fraction_non_alphanumeric': 0.22525792892625143, 'fraction_numerical': 0.004394344669468858, 'mean_word_length': 2.9038031319910513, 'pattern_counts': {'":': 25, '<': 78, '<?xml version=': 0, '>': 76, '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': '4259636', 'n_tokens_mistral': 1790, 'n_tokens_neox': 1740, 'n_words': 325}