Skip to content
This repository has been archived by the owner on Jan 19, 2023. It is now read-only.

Commit

Permalink
works?
Browse files Browse the repository at this point in the history
  • Loading branch information
marwan-mustafa-ap committed Mar 22, 2020
1 parent fb5f900 commit a8704c2
Show file tree
Hide file tree
Showing 14 changed files with 26,276 additions and 343 deletions.
5 changes: 0 additions & 5 deletions app/main.dev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,6 @@ const createWindow = async () => {
// Remove this if your app does not use auto updates
// eslint-disable-next-line
new AppUpdater();

const x = await autoUpdater.checkForUpdatesAndNotify();
console.log('UPDATE ----------------------');
console.log(x);
console.log('=========================');
};

/**
Expand Down
88 changes: 88 additions & 0 deletions app/main.prod.js.LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
/*!
* Tmp
*
* Copyright (c) 2011-2017 KARASZI Istvan <[email protected]>
*
* MIT Licensed
*/

/*!
* normalize-path <https://github.com/jonschlinkert/normalize-path>
*
* Copyright (c) 2014-2018, Jon Schlinkert.
* Released under the MIT License.
*/

/*! http://mths.be/fromcodepoint v0.1.0 by @mathias */

/**
* Archiver Core
*
* @ignore
* @license [MIT]{@link https://github.com/archiverjs/node-archiver/blob/master/LICENSE}
* @copyright (c) 2012-2014 Chris Talkington, contributors.
*/

/**
* Archiver Vending
*
* @ignore
* @license [MIT]{@link https://github.com/archiverjs/node-archiver/blob/master/LICENSE}
* @copyright (c) 2012-2014 Chris Talkington, contributors.
*/

/**
* Character class utilities for XML NS 1.0 edition 3.
*
* @author Louis-Dominique Dubeau
* @license MIT
* @copyright Louis-Dominique Dubeau
*/

/**
* Character classes and associated utilities for the 2nd edition of XML 1.1.
*
* @author Louis-Dominique Dubeau
* @license MIT
* @copyright Louis-Dominique Dubeau
*/

/**
* Character classes and associated utilities for the 5th edition of XML 1.0.
*
* @author Louis-Dominique Dubeau
* @license MIT
* @copyright Louis-Dominique Dubeau
*/

/**
* JSON Format Plugin
*
* @module plugins/json
* @license [MIT]{@link https://github.com/archiverjs/node-archiver/blob/master/LICENSE}
* @copyright (c) 2012-2014 Chris Talkington, contributors.
*/

/**
* TAR Format Plugin
*
* @module plugins/tar
* @license [MIT]{@link https://github.com/archiverjs/node-archiver/blob/master/LICENSE}
* @copyright (c) 2012-2014 Chris Talkington, contributors.
*/

/**
* ZIP Format Plugin
*
* @module plugins/zip
* @license [MIT]{@link https://github.com/archiverjs/node-archiver/blob/master/LICENSE}
* @copyright (c) 2012-2014 Chris Talkington, contributors.
*/

/**
* ZipStream
*
* @ignore
* @license [MIT]{@link https://github.com/archiverjs/node-zip-stream/blob/master/LICENSE}
* @copyright (c) 2014 Chris Talkington, contributors.
*/
5 changes: 5 additions & 0 deletions app/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

120 changes: 74 additions & 46 deletions app/xlsx-functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,37 +3,55 @@
import ExcelJS from 'exceljs';
import { bus } from './message-bus';

// eslint-disable-next-line no-underscore-dangle
function _compareStrings(stringA, stringB) {
if (!stringA || !stringB) return null;
if (typeof stringA !== 'string') {
stringA = stringA.toString();
}
if (typeof stringB !== 'string') {
stringB = stringB.toString();
function excelRichTextToString(obj) {
let normalized = obj;
if (typeof obj === 'object') {
normalized = '';
obj.richText.forEach(richTextObj => {
normalized += richTextObj.text;
});
}
const split = stringA.split(' ');
const changeIndexes = [];
split.forEach((word, i) => {
if (!` ${stringB.toLowerCase()} `.includes(` ${word.toLowerCase()} `))
changeIndexes.push(i);
});

return changeIndexes;
return normalized;
}

// eslint-disable-next-line no-underscore-dangle
function _findWord(word, sentence) {
if (!sentence || sentence === '') {
return [];
}
const normalized = excelRichTextToString(sentence);

return normalized
.split(' ')
.filter(word => word !== ' ')
.reduce((acc, val, index) => {
if (
` ${val.toLowerCase().trim()} ` === ` ${word.toLowerCase().trim()} `
) {
return acc.concat(index);
}
return acc;
}, []);
}

return sentence.split(' ').reduce((acc, val, index) => {
if (` ${val.toLowerCase()} `.includes(word.toLowerCase())) {
return acc.concat(index);
}
return acc;
}, []);
// eslint-disable-next-line no-underscore-dangle
function _compareStrings(stringA, stringB) {
if (!stringA || !stringB) return null;
const normalizedStringA = excelRichTextToString(stringA);
const normalizedStringB = excelRichTextToString(stringB);

const split = normalizedStringA.split(' ');
const changeIndexes = [];
split.forEach((word, i) => {
if (
!` ${normalizedStringB.toLowerCase()} `.includes(
` ${word.toLowerCase()} `
)
)
changeIndexes.push(i);
});

return changeIndexes;
}

function changeColorOfWordInCell(cell, wordIndex, color) {
Expand Down Expand Up @@ -88,7 +106,7 @@ async function doFind(payload, file) {
return acc;
}, 0);

for (let r = 0; r < totalRows; r++) {
for (let r = 1; r < totalRows; r++) {
progress(`Processing cell ${r} of ${totalRows}`, r / totalRows);
const searchWord = wordColumn.values[r];
allColumns.forEach((col, i) => {
Expand All @@ -108,6 +126,35 @@ async function doFind(payload, file) {
return book;
}

export function differencesFn({ cell, changeIndex = [], wordSearch = [] }) {
const cellValue = {
richText: []
};

cell.text.split(' ').forEach((word, i) => {
if (word === '' || word === ' ') {
return;
}
const obj = { text: `${word} ` };
// Is different

const changeIndexIndex = changeIndex.indexOf(i);
if (changeIndexIndex > -1) {
obj.font = { color: { argb: 'FFDE1738' } };
}

const wordSearchIndex = wordSearch.indexOf(i);
if (wordSearchIndex > -1) {
obj.font = { color: { argb: 'FF32CD32' } };
}

cellValue.richText.push(obj);
});
cell.value = cellValue;

return cell;
}

async function doCompare(compare, file) {
const { find, columns } = compare;

Expand Down Expand Up @@ -161,40 +208,21 @@ async function doCompare(compare, file) {
if (compared !== null) {
const [cellAChangeIndex, cellBChangeIndex] = compared;
columnADifferences.push({
address: cellAAddress,
cell: ws.getCell(cellAAddress),
changeIndex: cellAChangeIndex,
wordSearch: find ? _findWord(wordSearchCell, cellA) : null
wordSearch: wordSearchCell && _findWord(wordSearchCell, cellA)
});
columnBDifferences.push({
address: cellBAddress,
cell: ws.getCell(cellBAddress),
changeIndex: cellBChangeIndex,
wordSearch: find ? _findWord(wordSearchCell, cellB) : null
wordSearch: wordSearchCell && _findWord(wordSearchCell, cellB)
});
}
}
}

compareFn();

function differencesFn({ address, changeIndex, wordSearch }) {
const cell = ws.getCell(address);
const cellValue = {
richText: []
};
cell.text.split(' ').forEach((word, i) => {
const obj = { text: `${word} ` };
// Is different
if (changeIndex && changeIndex.some(c => c === i)) {
obj.font = { color: { argb: 'FFDE1738' } };
}
if (wordSearch && wordSearch.some(c => c === i)) {
obj.font = { color: { argb: 'FF32CD32' } };
}
cellValue.richText.push(obj);
});
cell.value = cellValue;
}

columnADifferences.forEach(differencesFn);
columnBDifferences.forEach(differencesFn);

Expand Down
Loading

0 comments on commit a8704c2

Please sign in to comment.