$('.children').click(function () {
$card = $(this).closest('.card');
$card_text = $(this).closest('.card-header').siblings('.card-body').children('.card-text')
if ($(this).attr('data-downloaded') == 'false') {
$(this).attr('data-downloaded', 'true')
getStructure($card.attr('data-parent'), $card_text)
}
else {
}
});
const file1 = {
host: 'something.io',
timeout: 50,
proxy: '123.234.53.22',
follow: false,
};
const file2 = {
timeout: 20,
verbose: true,
host: 'something.io',
};
const genDiff = (file1, file2) => {
const mergeFiles = { ...file1, ...file2 };
const uniqueKeys = Object.keys(mergeFiles);
const diff = uniqueKeys.map((key, index, arr) => {
if (file1.hasOwnProperty(key) && !file2.hasOwnProperty(key)) {
return { key, value: file1[key], status: 'removed' };
} else if (!file1.hasOwnProperty(key) && file2.hasOwnProperty(key)) {
return { key, value: file2[key], status: 'new' };
} else if (file1.hasOwnProperty(key) && file2.hasOwnProperty(key) && file1[key] === file2[key]) {
return { key, value: file1[key], status: 'same' };
} else if (file1.hasOwnProperty(key) && file2.hasOwnProperty(key) && file1[key] !== file2[key]) {
return { key, value: { oldValue: file1[key], newValue: file2[key] }, status: 'changed' };
}
});
return diff.map((item, index, arr) => {
if (item.status === 'removed') {
console.log(`- ${item.key}: ${item.value}`);
} else if (item.status === 'new') {
console.log(`+ ${item.key}: ${item.value}`);
} else if (item.status === 'same') {
console.log(` ${item.key}: ${item.value}`);
} else if (item.status === 'changed') {
console.log(`- ${item.key}: ${item.value.oldValue}`);
console.log(`+ ${item.key}: ${item.value.newValue}`);
}
});
};
genDiff(file1, file2);