src/js/main.js
/** Displays the current state of the sorter. */
Displays the current state of the sorter.
Displays the current state of the sorter .
function display() {
  const percent         = Math.floor(sortedNo * 100 / totalBattles);
  const leftCharIndex   = sortedIndexList[leftIndex][leftInnerIndex];
  const rightCharIndex  = sortedIndexList[rightIndex][rightInnerIndex];
  const leftChar        = characterDataToSort[leftCharIndex];
  const rightChar       = characterDataToSort[rightCharIndex];
  const charNameDisp = name => {
    const charName = reduceTextWidth(name, 'Arial 12.8px', 220);
    const charTooltip = name !== charName ? name : '';
    return `<p title="${charTooltip}">${charName}</p>`;
  };
  progressBar(`Battle No. ${battleNo}`, percent);
  document.querySelector('.left.sort.image').src = leftChar.img;
  document.querySelector('.right.sort.image').src = rightChar.img;
  document.querySelector('.left.sort.text').innerHTML = charNameDisp(leftChar.name);
  document.querySelector('.right.sort.text').innerHTML = charNameDisp(rightChar.name);
  if (choices.length !== battleNo - 1) {
    switch (Number(choices[battleNo - 1])) {
      case 0: pick('left'); break;
      case 1: pick('right'); break;
      case 2: pick('tie'); break;
      default: break;
    }
  } else { saveProgress('Autosave'); }
}
function display ( ) { const percent = Math . floor ( sortedNo * 100 / totalBattles ) ; const leftCharIndex = sortedIndexList [ leftIndex ] [ leftInnerIndex ] ; const rightCharIndex = sortedIndexList [ rightIndex ] [ rightInnerIndex ] ; const leftChar = characterDataToSort [ leftCharIndex ] ; const rightChar = characterDataToSort [ rightCharIndex ] ; const charNameDisp = name => { const charName = reduceTextWidth ( name , 'Arial 12.8px' , 220 ) ; const charTooltip = name !== charName ? name : '' ; return ` ${ charTooltip } ${ charName } ` ; } ; progressBar ( ` ${ battleNo } ` , percent ) ; document . querySelector ( '.left.sort.image' ) . src = leftChar . img ; document . querySelector ( '.right.sort.image' ) . src = rightChar . img ; document . querySelector ( '.left.sort.text' ) . innerHTML = charNameDisp ( leftChar . name ) ; document . querySelector ( '.right.sort.text' ) . innerHTML = charNameDisp ( rightChar . name ) ; if ( choices . length !== battleNo - 1 ) { switch ( Number ( choices [ battleNo - 1 ] ) ) { case 0 : pick ( 'left' ) ; break ; case 1 : pick ( 'right' ) ; break ; case 2 : pick ( 'tie' ) ; break ; default : break ; } } else { saveProgress ( 'Autosave' ) ; } }
Displays the current state of the sorter.
Displays the current state of the sorter .
/** Autopick if choice has been given. */