
// ----------------------------------------------------------------
// Card Class

class CardModel extends SwitchModel {
  constructor({
    name,
    lsKeyView,
    triggerSelector,
    switchSelector,
    hash = null
  } = {}) {
    super({
      name: name,
      lsKeyView: lsKeyView,
      triggerSelector: triggerSelector,
      switchSelector: switchSelector
    });
    
    this.NAME = name;
    this.HASH = hash;
    
    this.CARD_AREA_SELECTOR = '#card-area';
    this.$CARD_AREA_SELECTOR = $(this.CARD_AREA_SELECTOR);
    this.TEMPLATE_CARD_TABLE_SELECTOR = '#card-table-template';
    this.$TEMPLATE_CARD_TABLE_SELECTOR = $(this.TEMPLATE_CARD_TABLE_SELECTOR);
    
    this.CARD_TBODY = '#card-tbody';
    this.$CARD_TBODY = $(this.CARD_TBODY);
  }
}

class CardView extends SwitchView {
  constructor(_model = new CardModel()) {
    super(_model);
  }
  
  generateCardArea(_alertType = 'success', _message = null) {
    this.model.$CARD_AREA_SELECTOR.empty();
    this.model.$CARD_AREA_SELECTOR.append(Content.getHeader('名刺情報'));
    this.generateAlert(this.model.$CARD_AREA_SELECTOR, _alertType, _message);
    
    let template = null;
    if (this.model.DOWNLOAD) {
      template = this.model.$TEMPLATE_CARD_TABLE_SELECTOR.text();
      const compiled = _.template(template);
      const model = {};
      this.model.$CARD_AREA_SELECTOR.append(compiled(model));
      this.model.$CARD_TBODY = $(this.model.CARD_TBODY);
    }
  }
}

// ----------------------------------------------------------------
// Controller

class CardController extends CommonController {
  constructor(_obj) {
    super(_obj);
    
    this.model = new CardModel(_obj);
    this.view = new CardView(this.model);
    
    this.model.ID = null;
    this.model.HASH = null;
    this.model.DOWNLOAD = null;
    
    this.downloadCard();
  }
  
  setUser(_id = null, _hash = null) {
    this.model.ID = _id;
    this.model.HASH = _hash;
    if (this.model.ID != null && this.model.HASH != null) {
      this.model.DOWNLOAD = true;
    } else {
      this.model.DOWNLOAD = false;
    }
    
    this.downloadCard(this.model.ID, this.model.HASH)
  }
  
  downloadCard(_id = null, _hash = null) {
    
    this.view.generateLoading(this.model.$CARD_AREA_SELECTOR, '通信中', `ユーザーID ${_id} の名刺データを取得中...`);
    
    this.DOWNLOAD = false;
    
    if (_id != null && _hash != null) {
      
    } else {
      this.view.generateUserArea('danger', 'ログインしてください。');
    }
  }
}

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

class CardEvent extends CommonEvent {
  constructor({
    name = 'Card Event'
  } = {})
  {
    super({
      name: name
    });
    
    this.NAME = name;
    this.CONTROLLER = new CardController({
      name: 'Card Switch',
      lsKeyView: 'card',
      triggerSelector: '#action-card',
      switchSelector: '#card-area'
    });
  }
}

@@ -199,25 +199,8 @@
 ctor
-,%0A    hash = null
 %0A  %7D
@@ -382,30 +382,8 @@
 me;%0A
-    this.HASH = hash;%0A
     
@@ -2324,24 +2324,666 @@
 ll) %7B%0A      
+$.ajax(%7B%0A        url: 'ruby/getCard.rb',%0A        data: %7B%0A          id: _id,%0A          password: _hash%0A        %7D,%0A        type: json,%0A        success: (_data) =%3E %7B%0A          Log.logClass(this.NAME, 'signupUser ajax success');%0A          if (_data.length %3E 0) %7B%0A            this.DOWNLOAD = true;%0A            this.view.generateUserArea('success', %60%E5%90%8D%E5%88%BA%E3%83%87%E3%83%BC%E3%82%BF%E3%81%AE%E5%8F%96%E5%BE%97%E3%81%AB%E6%88%90%E5%8A%9F%E3%81%97%E3%81%BE%E3%81%97%E3%81%9F%E3%80%82%60);%0A          %7D else %7B%0A            this.view.generateCardArea('danger', '%E5%90%8D%E5%88%BA%E3%83%87%E3%83%BC%E3%82%BF%E3%81%AF%E5%AD%98%E5%9C%A8%E3%81%97%E3%81%BE%E3%81%9B%E3%82%93%E3%80%82');%0A          %7D%0A        %7D,%0A        error: () =%3E %7B%0A          Log.logClass(this.NAME, 'signupUser ajax failed');%0A          this.view.generateUserArea('danger', 'ajax%E9%80%9A%E4%BF%A1%E3%81%AB%E5%A4%B1%E6%95%97%E3%81%97%E3%81%BE%E3%81%97%E3%81%9F%E3%80%82');%0A        %7D%0A      %7D);
 %0A    %7D else 

Remove hash in CardModel constructor