Added import export features
- Added clipboard copy feature
This commit is contained in:
parent
72cb095dec
commit
ac5f58407a
@ -16,7 +16,8 @@
|
||||
"nativeAllowList": [
|
||||
"app.*",
|
||||
"os.*",
|
||||
"debug.log"
|
||||
"debug.log",
|
||||
"clipboard.*"
|
||||
],
|
||||
"globalVariables": {
|
||||
"TEST1": "Hello",
|
||||
|
@ -1,3 +1,4 @@
|
||||
.sidebar {
|
||||
border-left: 1px solid #b1b1b1;
|
||||
transition: all 0.3s;
|
||||
}
|
@ -52,13 +52,11 @@
|
||||
});
|
||||
}
|
||||
|
||||
function clean() {
|
||||
async function clean() {
|
||||
console.log("Cleaning...");
|
||||
|
||||
// Read the input from the textarea
|
||||
let outputText = $("#input-textarea").val();
|
||||
|
||||
// Process each rule
|
||||
config.rules.forEach(rule => {
|
||||
if (rule.enabled) {
|
||||
const searchValue = rule.ignoreCase ? new RegExp(rule.strToReplace, 'gi') : new RegExp(rule.strToReplace, 'g');
|
||||
@ -66,10 +64,12 @@
|
||||
}
|
||||
});
|
||||
|
||||
// Output the processed text to the output textarea
|
||||
$("#output-textarea").val(outputText);
|
||||
|
||||
// Display the output container
|
||||
$("#output-container-div").removeClass("visually-hidden");
|
||||
|
||||
if($("#enable-auto-copy").prop("checked")) {
|
||||
console.log("Copying result to clipboard...")
|
||||
await Neutralino.clipboard.writeText(outputText);
|
||||
}
|
||||
}
|
||||
})();
|
@ -17,18 +17,24 @@
|
||||
<path fill-rule="evenodd" d="M8 2a.5.5 0 0 1 .5.5v5h5a.5.5 0 0 1 0 1h-5v5a.5.5 0 0 1-1 0v-5h-5a.5.5 0 0 1 0-1h5v-5A.5.5 0 0 1 8 2"/>
|
||||
</svg>
|
||||
Create new rule</button>
|
||||
<button class="btn btn-secondary mx-2">
|
||||
<button type="button" class="btn btn-secondary mx-2">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-trash" viewBox="0 0 16 16">
|
||||
<path d="M5.5 5.5A.5.5 0 0 1 6 6v6a.5.5 0 0 1-1 0V6a.5.5 0 0 1 .5-.5m2.5 0a.5.5 0 0 1 .5.5v6a.5.5 0 0 1-1 0V6a.5.5 0 0 1 .5-.5m3 .5a.5.5 0 0 0-1 0v6a.5.5 0 0 0 1 0z"/>
|
||||
<path d="M14.5 3a1 1 0 0 1-1 1H13v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V4h-.5a1 1 0 0 1-1-1V2a1 1 0 0 1 1-1H6a1 1 0 0 1 1-1h2a1 1 0 0 1 1 1h3.5a1 1 0 0 1 1 1zM4.118 4 4 4.059V13a1 1 0 0 0 1 1h6a1 1 0 0 0 1-1V4.059L11.882 4zM2.5 3h11V2h-11z"/>
|
||||
</svg>
|
||||
Clear rules</button>
|
||||
<button type="button" class="btn btn-dark">
|
||||
<button type="button" class="btn btn-dark mx-2" id="export-rules-btn">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-box-arrow-right" viewBox="0 0 16 16">
|
||||
<path fill-rule="evenodd" d="M10 12.5a.5.5 0 0 1-.5.5h-8a.5.5 0 0 1-.5-.5v-9a.5.5 0 0 1 .5-.5h8a.5.5 0 0 1 .5.5v2a.5.5 0 0 0 1 0v-2A1.5 1.5 0 0 0 9.5 2h-8A1.5 1.5 0 0 0 0 3.5v9A1.5 1.5 0 0 0 1.5 14h8a1.5 1.5 0 0 0 1.5-1.5v-2a.5.5 0 0 0-1 0z"/>
|
||||
<path fill-rule="evenodd" d="M15.854 8.354a.5.5 0 0 0 0-.708l-3-3a.5.5 0 0 0-.708.708L14.293 7.5H5.5a.5.5 0 0 0 0 1h8.793l-2.147 2.146a.5.5 0 0 0 .708.708z"/>
|
||||
</svg>
|
||||
Export config</button>
|
||||
<button type="button" class="btn btn-dark mx-2" id="import-rules-btn">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-file-earmark-plus" viewBox="0 0 16 16">
|
||||
<path d="M8 6.5a.5.5 0 0 1 .5.5v1.5H10a.5.5 0 0 1 0 1H8.5V11a.5.5 0 0 1-1 0V9.5H6a.5.5 0 0 1 0-1h1.5V7a.5.5 0 0 1 .5-.5"/>
|
||||
<path d="M14 4.5V14a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V2a2 2 0 0 1 2-2h5.5zm-3 0A1.5 1.5 0 0 1 9.5 3V1H4a1 1 0 0 0-1 1v12a1 1 0 0 0 1 1h8a1 1 0 0 0 1-1V4.5z"/>
|
||||
</svg>
|
||||
Import config</button>
|
||||
</div>
|
||||
<table class="table mt-5 table-borderless">
|
||||
<thead>
|
||||
|
@ -36,6 +36,29 @@ $("document").ready(function() {
|
||||
appendRow(generateRowTemplate("", "", true, true));
|
||||
});
|
||||
|
||||
$("#export-rules-btn").click(async () => {
|
||||
console.log("Exporting rules...");
|
||||
buildAndSaveConfig();
|
||||
await Neutralino.clipboard.writeText(JSON.stringify(configJson));
|
||||
});
|
||||
|
||||
$("#import-rules-btn").click(async () => {
|
||||
console.log("Importing rules...");
|
||||
const importedConfig = await Neutralino.clipboard.readText();
|
||||
if (importedConfig) {
|
||||
try {
|
||||
configJson = JSON.parse(importedConfig);
|
||||
$(".table tbody").empty();
|
||||
configJson["rules"].forEach(function(rule) {
|
||||
appendRow(generateRowTemplate(rule["strToReplace"], rule["replaceStr"], rule["enabled"], rule["ignoreCase"]));
|
||||
});
|
||||
updateRowIndexes();
|
||||
buildAndSaveConfig();
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
} });
|
||||
|
||||
$(document).on("click", ".rule-trash-btn", function() {
|
||||
$(this).closest("tr").remove();
|
||||
updateRowIndexes();
|
||||
|
Loading…
x
Reference in New Issue
Block a user