<commit_before>
// ----------------------------------------------------------------
// DiaryDetail Class

// ----------------------------------------------------------------
// Model

class DiaryDetailModel extends CommonModel {
  constructor(
    _initSetting = {
      NAME: 'Diary Detail Object'
    }
  ) {
    super(_initSetting);
    
    this.DIARY_DETAIL_AREA_SELECTOR = '#diary-detail-area';
    
    this.TEMPLATE_DIARY_DETAIL_TITLE_SELECTOR = '#diary-detail-title-template';
    this.TEMPLATE_DIARY_DETAIL_CONTENT_SELECTOR = '#diary-detail-content-template';
    this.TEMPLATE_DIARY_DETAIL_IMAGE_BUTTON_SELECTOR = '#diary-detail-image-button-template';
    this.TEMPLATE_DIARY_DETAIL_IMAGE_SELECTOR = '#diary-detail-image-template';
    this.TEMPLATE_DIARY_DETAIL_DATE_SELECTOR = '#diary-detail-date-template';
    this.TEMPLATE_DIARY_DETAIL_LAST_BUTTON_SELECTOR = '#diary-detail-last-button-template';
    
    this.DIARY_DETAIL_ADD_SELECTOR = '#detail-submit-add';
    this.DIARY_DETAIL_SAVE_SELECTOR = '#detail-submit-save';
    this.DIARY_DETAIL_DELETE_SELECTOR = '#detail-submit-delete';
    this.DIARY_DETAIL_CLOSE_SELECTOR = '#detail-submit-close';
    
    this.DIARY_DETAIL_IMAGE_PREVIEW_SELECTOR = '.detail-image-preview';
    this.DIARY_DETAIL_CHOOSE_FILE_SELECTOR = '.detail-choose-file';
    this.DIARY_DETAIL_UPLOAD_FILE_SELECTOR = '.detail-upload-file';
    this.DIARY_DETAIL_FILE_NAME_SELECTOR = '.upload-file-name';
    this.DIARY_DETAIL_FILE_NAME_SELECTOR = '.detail-submit-increase-image';
    
    this.DIARY_DETAIL_UPLOAD_SELECTOR = '.detail-upload';
    
    this.ID = null;
    this.HASH = null;
    this.DIARY = null;
    this.IMAGE = null;
    this.ADD_FLAG = true;
    
    this.UPLOAD_IMAGE = false;
    
    this.DIARY_EDIT = null;
    
    this.TYPE_ADD = 'add';
    this.TYPE_UPDATE = 'update';
    this.TYPE_DELETE = 'delete';
  }
}

// ----------------------------------------------------------------
// View

class DiaryDetailView extends CommonView {
  constructor(
    _initSetting = {
      NAME: 'Diary Detail View'
    }
  ) {
    super(_initSetting);
  }
  
  generateDiaryDetailArea(
    _alertType = this.MODEL.ALERT_SUCCESS,
    _message = null,
    _close = true
  ) {
    $(this.MODEL.DIARY_DETAIL_AREA_SELECTOR).empty();
    
    let body = '';
    if (this.MODEL.DIARY == null) {
      body = '新規作成';
    } else {
      body = this.MODEL.DIARY['title'];
    }
    $(this.MODEL.DIARY_DETAIL_AREA_SELECTOR).append(
      Content.getHeader(body)
    );
    super.generateAlert(
      this.MODEL.DIARY_DETAIL_AREA_SELECTOR,
      _alertType,
      _message,
      _close
    );
    if (this.MODEL.DIARY != null) {
      // 日記がある場合
      $(this.MODEL.DIARY_DETAIL_AREA_SELECTOR).append(this.getTemplate(
        this.MODEL.TEMPLATE_DIARY_DETAIL_SELECTOR,
        {
          diary: this.MODEL.DIARY,
          add: this.MODEL.COPY
        }
      ));
    } else {
      // 日記がない場合
      $(this.MODEL.DIARY_DETAIL_AREA_SELECTOR).append(this.getTemplate(
        this.MODEL.TEMPLATE_DIARY_DETAIL_SELECTOR,
        {
          diary: {
            imageName: "",
            registerDate: (new Date()).getString(),
            updateDate: (new Date()).getString()
          },
          add: this.MODEL.ADD
        }
      ));
    }
  }
  
  getDiaryEdit() {
    let diary = {
      title: $('#detail-title').val(),
      content: $('#detail-content').val(),
      imageName: $('#detail-image .upload-file-name').val(),
      registerDate: (new Date()).getString(),
      updateDate: (new Date()).getString()
    }
    if (this.MODEL.DIARY != null) {
      diary['id'] = this.MODEL.DIARY['id'];
    }
    return diary;
  }
}

// ----------------------------------------------------------------
// Event
<commit_msg>Update function generateDiaryDetailArea in DiaryDetailView<commit_after>
// ----------------------------------------------------------------
// DiaryDetail Class

// ----------------------------------------------------------------
// Model

class DiaryDetailModel extends CommonModel {
  constructor(
    _initSetting = {
      NAME: 'Diary Detail Object'
    }
  ) {
    super(_initSetting);
    
    this.DIARY_DETAIL_AREA_SELECTOR = '#diary-detail-area';
    
    this.TEMPLATE_DIARY_DETAIL_TITLE_SELECTOR = '#diary-detail-title-template';
    this.TEMPLATE_DIARY_DETAIL_CONTENT_SELECTOR = '#diary-detail-content-template';
    this.TEMPLATE_DIARY_DETAIL_IMAGE_BUTTON_SELECTOR = '#diary-detail-image-button-template';
    this.TEMPLATE_DIARY_DETAIL_IMAGE_SELECTOR = '#diary-detail-image-template';
    this.TEMPLATE_DIARY_DETAIL_DATE_SELECTOR = '#diary-detail-date-template';
    this.TEMPLATE_DIARY_DETAIL_LAST_BUTTON_SELECTOR = '#diary-detail-last-button-template';
    
    this.DIARY_DETAIL_ADD_SELECTOR = '#detail-submit-add';
    this.DIARY_DETAIL_SAVE_SELECTOR = '#detail-submit-save';
    this.DIARY_DETAIL_DELETE_SELECTOR = '#detail-submit-delete';
    this.DIARY_DETAIL_CLOSE_SELECTOR = '#detail-submit-close';
    
    this.DIARY_DETAIL_IMAGE_PREVIEW_SELECTOR = '.detail-image-preview';
    this.DIARY_DETAIL_CHOOSE_FILE_SELECTOR = '.detail-choose-file';
    this.DIARY_DETAIL_UPLOAD_FILE_SELECTOR = '.detail-upload-file';
    this.DIARY_DETAIL_FILE_NAME_SELECTOR = '.upload-file-name';
    this.DIARY_DETAIL_FILE_NAME_SELECTOR = '.detail-submit-increase-image';
    
    this.DIARY_DETAIL_UPLOAD_SELECTOR = '.detail-upload';
    
    this.ID = null;
    this.HASH = null;
    this.DIARY = null;
    this.IMAGE = null;
    this.ADD_FLAG = true;
    
    this.UPLOAD_IMAGE = false;
    
    this.DIARY_EDIT = null;
    
    this.TYPE_ADD = 'add';
    this.TYPE_UPDATE = 'update';
    this.TYPE_DELETE = 'delete';
  }
}

// ----------------------------------------------------------------
// View

class DiaryDetailView extends CommonView {
  constructor(
    _initSetting = {
      NAME: 'Diary Detail View'
    }
  ) {
    super(_initSetting);
  }
  
  generateDiaryDetailArea(
    _alertType = this.MODEL.ALERT_SUCCESS,
    _message = null,
    _close = true
  ) {
    $(this.MODEL.DIARY_DETAIL_AREA_SELECTOR).empty();
    
    let body = '';
    if (this.MODEL.DIARY == null) {
      body = '新規作成';
      this.MODEL.DIARY = this.getDiaryEdit();
    } else {
      body = this.MODEL.DIARY['title'];
    }
    $(this.MODEL.DIARY_DETAIL_AREA_SELECTOR).append(
      Content.getHeader(body)
    );
    super.generateAlert(
      this.MODEL.DIARY_DETAIL_AREA_SELECTOR,
      _alertType,
      _message,
      _close
    );
    
    // タイトル
    $(this.MODEL.DIARY_DETAIL_AREA_SELECTOR).append(this.getTemplate(
      this.MODEL.TEMPLATE_DIARY_DETAIL_TITLE_SELECTOR,
      {
        diary: this.MODEL.DIARY
      }
    ));
    
    // 内容
    $(this.MODEL.DIARY_DETAIL_AREA_SELECTOR).append(this.getTemplate(
      this.MODEL.TEMPLATE_DIARY_DETAIL_CONTENT_SELECTOR,
      {
        diary: this.MODEL.DIARY
      }
    ));
    
    // 画像選択ボタン
    $(this.MODEL.DIARY_DETAIL_AREA_SELECTOR).append(this.getTemplate(
      this.MODEL.TEMPLATE_DIARY_DETAIL_IMAGE_BUTTON_SELECTOR
    ));
    
    // 画像単体
    let imageId = 0;
    for (const imageName of this.MODEL.IMAGE) {
      $(this.MODEL.DIARY_DETAIL_AREA_SELECTOR).append(this.getTemplate(
        this.MODEL.TEMPLATE_DIARY_DETAIL_IMAGE_SELECTOR,
        {
          imageName: imageName,
          imageId: imageId
        }
      ));
      imageId ++;
    }
    
    // 日時
    $(this.MODEL.DIARY_DETAIL_AREA_SELECTOR).append(this.getTemplate(
      this.MODEL.TEMPLATE_DIARY_DETAIL_DATE_SELECTOR,
      {
        diary: this.MODEL.DIARY
      }
    ));
    
    // 下のボタン
    $(this.MODEL.DIARY_DETAIL_AREA_SELECTOR).append(this.getTemplate(
      this.MODEL.TEMPLATE_DIARY_DETAIL_LAST_BUTTON_SELECTOR,
      {
        add: this.MODEL.ADD_FLAG
      }
    ));
  }
  
  getDiaryEdit() {
    let diary = {
      title: $('#detail-title').val(),
      content: $('#detail-content').val(),
      imageName: $('#detail-image .upload-file-name').val(),
      registerDate: (new Date()).getString(),
      updateDate: (new Date()).getString()
    }
    if (this.MODEL.DIARY != null) {
      diary['id'] = this.MODEL.DIARY['id'];
    }
    return diary;
  }
}

// ----------------------------------------------------------------
// Event

{'fraction_non_alphanumeric': 0.18165293262239457, 'fraction_numerical': 0.0001211827435773146, 'mean_word_length': 2.1864864864864866, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '84708', 'n_tokens_mistral': 2887, 'n_tokens_neox': 2845, 'n_words': 329}