-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
108 lines (90 loc) · 3.83 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
var $ = require('jquery');
var fs = require('fs');
const {
dialog
} = require('electron').remote;
var compare = require('./compare.js');
var sourceDirectory, destinationDirectory;
$(document).ready(() => {
console.log("***App Ready***");
$('#source-folder').on('click', (event) => {
console.log("***Source Directory***");
$('.alert').addClass('d-none');
dialog.showOpenDialog({
title: "Select the Source Folder",
properties: ["openDirectory"]
}).then((paths) => {
if (paths === undefined) {
console.log("***No Source Folder Selected***");
return;
} else {
sourceDirectory = paths.filePaths;
console.log(sourceDirectory);
printFolderName(sourceDirectory, 'source-folder-value');
}
});
});
$('#destination-folder').on('click', (event) => {
console.log("***Destination Directory***");
$('.alert').addClass('d-none');
dialog.showOpenDialog({
title: "Select the Destination Folder",
properties: ["openDirectory"]
}).then((paths) => {
if (paths === undefined) {
console.log("***No Destination Folder Selected***");
return;
} else {
destinationDirectory = paths.filePaths;
console.log(destinationDirectory);
printFolderName(destinationDirectory, 'destination-folder-value');
}
});
});
$('#compare-button').on('click', (event) => {
if (sourceDirectory && destinationDirectory) {
reset();
$('.loadingIndicator').removeClass('d-none');
initializeComparison(sourceDirectory[0], destinationDirectory[0]);
} else {
$('.alert').removeClass('d-none');
$('.alert').find('#alertText').text("Please select both the directories.");
}
});
});
function printFolderName(folderName, targetElement) {
targetElement && $('#' + targetElement).text(folderName);
}
function initializeComparison(src, dest) {
compare.initializeComparison(src, dest, function (result) {
console.log("Logging Control Back");
$('#summary').removeClass('d-none');
$('.loadingIndicator').addClass('d-none');
$('#summary').find('#summaryFilesMatched').find('span').text(result.filesMatched.length);
$('#summary').find('#summaryFilesAdded').find('span').text(result.filesAddedDestination.length);
$('#summary').find('#summaryFilesRemoved').find('span').text(result.filesRemovedSource.length);
for (i = 0; i < result.filesMatched.length; i++) {
$('#details').removeClass('d-none');
$('#details').find('#detailsFilesMatched').append('<li>' + result.filesMatched[i] + '</li>');
}
for (i = 0; i < result.filesAddedDestination.length; i++) {
$('#details').removeClass('d-none');
$('#details').find('#detailsFilesAdded').append('<li>' + result.filesAddedDestination[i] + '</li>');
}
for (i = 0; i < result.filesRemovedSource.length; i++) {
$('#details').removeClass('d-none');
$('#details').find('#detailsFilesRemoved').append('<li>' + result.filesRemovedSource[i] + '</li>');
}
$('#difference').removeClass('d-none');
$('#difference').find('#consolidatedDifference').text(result.diffContent);
console.log("Logging Done");
}.bind(this));
}
function reset() {
$('#details').addClass('d-none');
$('#difference').addClass('d-none');
$('.alert').addClass('d-none');
$('#summary').find('#summaryFilesMatched').find('span').text(0);
$('#summary').find('#summaryFilesAdded').find('span').text(0);
$('#summary').find('#summaryFilesRemoved').find('span').text(0);
}