JSFiddle - React, Tailwind, and code Playground

by pierian_design

JavaScript

function getSheetName(oSheetInfo) {
  let sMainSheetName = '';

  if (oSheetInfo.hasOwnProperty('bIsDupName')) {
    sMainSheetName = oSheetInfo.sSpreadsheetName + ': ' + oSheetInfo.sName;
  } else {
    sMainSheetName = oSheetInfo.sName;
  }

  return sMainSheetName;
}

AcceptDmp = (function(accdmp) {
  let oMainSheet = {};
  let oComparableSheet = {};
  let numWorkCols = 0;

  let oOptions = {};
  let oMainRows = {};
  let curCompSheetIndex = 0;
  let rowEnd = '\n';
  let sCellEnd = ' ';
  let aCompDiffsBySheets = [];
  let oComparableRows = {};
  let aClMainSheetValues = [];
  let aClCompSheetValues = [];

  let aMainVarCols = [];
  let aFirstDiffRows = [];
  let aCompRowIndTmp = [];

  let oUniqueValues = {};

  let aDiffMainRowIndexes = [];
  let aDiffComparableRowIndexes = [];

  let oCurrentStepMainRows = {};

  function Row(index, sStatus, aCols, bMainSheet) {
    this.index = index;
    this.status = sStatus;

    if (sStatus === 'different') {
      this.cols = aCols;
    }

    if (bMainSheet) {
      this.sheetRole = 'main';
    } else {
      this.sheetRole = 'comp';
      this.sheetIndex = curCompSheetIndex;
    }
  }

  let _getEmptyValues = function(numCols) {
    let arr = new Array(numCols);

    return arr.fill("'=");
  }

  let _getRowStatus = function(aColIndexes, columnCount) {
    if (!aColIndexes.length) {
      return 'equal';
    } else {
      if (aColIndexes.length >= columnCount) {
        return 'unique';
      } else {
        return 'different';
      }
    }
  }

  let _mergeLostCells = function(oMain, oComparable) {
    if (aMainVarCols.join(' ') !== oComparable.cols.join(' ')) {
      let aMergedCompCols = oComparable.cols.concat(aMainVarCols);
      let aMergedMainCols = oMain.cols.concat(oComparable.cols);

      aMergedCompCols = [...new Set(aMergedCompCols)].sort();
      aMergedMainCols = [...new Set(aMergedMainCols)].sort();
      oMain.cols = aMergedMainCols;
      oComparable.cols = aMergedCompCols;
    }
  }

  let...