-
@@ -43,9 +52,7 @@
cols="30"
rows="2"
class="form-control"
- >
-(filename) => true
+ >
+
+
+
+
+
+Null
+
+
+Null
+ >
-
-
-Null
-
-
-Null
{
tableBody.append(
$(
- `${v.fileAName} | ${
- v.fileBName
- } | ${v.similarPercentage.toString()} |
`
+ `${v.fileAName} | ${v.fileBName} | ${v.similarPercentage} |
`
)
);
});
@@ -132,6 +135,40 @@ function diff() {
$("#diffModal").modal();
}
+function loadConfig() {
+ const config = JSON.parse(fs.readFileSync(configPath));
+ $("#directory-input").val(config.directory ?? "");
+ $("#input-file-fliter").val(config.fileFilter ?? "");
+ $("#language-select").val(config.language ?? "");
+ $("#threshold").val(config.threshold ?? "");
+ $("#result-fliter").val(config.resultFilter ?? "");
+}
+
+function saveConfig(config) {
+ fs.writeFileSync(
+ configPath,
+ JSON.stringify(
+ config ?? {
+ directory: $("#directory-input").val(),
+ fileFilter: $("#input-file-fliter").val(),
+ language: $("#language-select").val(),
+ threshold: $("#threshold").val(),
+ resultFilter: $("#result-fliter").val(),
+ }
+ )
+ );
+}
+function resetConfig() {
+ saveConfig({
+ directory: os.homedir(),
+ fileFilter: "(filename) => true",
+ language: "2",
+ threshold: 75,
+ resultFilter: `(fileAName, fileBName, percentage) => {\n const A = fileAName.split("-");\n const B = fileBName.split("-");\n return A[0] != B[0] && A[1] == B[1];\n};`,
+ });
+ loadConfig();
+}
+
(function () {
const amdLoader = require("./node_modules/monaco-editor/min/vs/loader.js");
const amdRequire = amdLoader.require;
@@ -159,3 +196,12 @@ function diff() {
);
});
})();
+
+(function () {
+ if (!fs.existsSync(configPath)) {
+ resetConfig();
+ } else {
+ loadConfig();
+ }
+ window.onbeforeunload = () => saveConfig();
+})();
diff --git a/package-lock.json b/package-lock.json
index bd58046..c845b84 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "simgui",
- "version": "0.0.4",
+ "version": "0.0.5",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "simgui",
- "version": "0.0.4",
+ "version": "0.0.5",
"license": "MIT",
"dependencies": {
"electron-squirrel-startup": "^1.0.0",
diff --git a/package.json b/package.json
index 4f1f25c..c9b2ddb 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "simgui",
- "version": "0.0.4",
+ "version": "0.0.5",
"description": "SimGUI",
"main": "dist/main.js",
"scripts": {