feature/singlelineconverter #2

Merged
Walzen665 merged 5 commits from feature/singlelineconverter into main 2024-08-30 09:44:40 +00:00
10 changed files with 99 additions and 6 deletions

View File

@ -7,6 +7,7 @@ This is a standalone web application designed to clear sensitive data from text.
- Clear sensitive data from text: The application provides a simple and intuitive interface for clearing sensitive data from any text input. - Clear sensitive data from text: The application provides a simple and intuitive interface for clearing sensitive data from any text input.
- Auto copy to clipboard: The cleared text is automatically copied to the clipboard for easy use. - Auto copy to clipboard: The cleared text is automatically copied to the clipboard for easy use.
- Customizable filters: The application comes with a set of predefined filters for common types of sensitive data, and users can enable or disable these filters as needed. - Customizable filters: The application comes with a set of predefined filters for common types of sensitive data, and users can enable or disable these filters as needed.
- **NEW**: Multiline to Singleline: Convert multiline text to singleline text with a single click.
## Compatibility ## Compatibility
@ -34,3 +35,10 @@ This project is licensed under the MIT License. See the `LICENSE` file for more
- NeutralinoJS - The lightweight and portable framework used to build this application. [NeutralinoJS GitHub](https://github.com/neutralinojs/neutralinojs) - NeutralinoJS - The lightweight and portable framework used to build this application. [NeutralinoJS GitHub](https://github.com/neutralinojs/neutralinojs)
- Bootstrap icons - Used for the icons in the application. [Bootstrap icons GitHub](https://github.com/twbs/icons) - Bootstrap icons - Used for the icons in the application. [Bootstrap icons GitHub](https://github.com/twbs/icons)
- DALL-E3 by OpenAI - Used for generating all visible images/graphics. [DALL-E3 GitHub](https://github.com/openai/DALL-E) - DALL-E3 by OpenAI - Used for generating all visible images/graphics. [DALL-E3 GitHub](https://github.com/openai/DALL-E)
### Dev notes
Init dev env
1. run `neu update`
2. run `neu build`
3. run `neu run`

View File

@ -1,7 +1,7 @@
{ {
"$schema": "https://raw.githubusercontent.com/neutralinojs/neutralinojs/main/schemas/neutralino.config.schema.json", "$schema": "https://raw.githubusercontent.com/neutralinojs/neutralinojs/main/schemas/neutralino.config.schema.json",
"applicationId": "de.walzen665.clearapp", "applicationId": "de.walzen665.clearapp",
"version": "1.0.1", "version": "1.1.0",
"defaultMode": "window", "defaultMode": "window",
"port": 0, "port": 0,
"documentRoot": "/src/", "documentRoot": "/src/",

BIN
src/icons/lineconv.webp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 202 KiB

View File

@ -9,7 +9,7 @@
Back Back
</button> </button>
</div> </div>
<section class="py-5"> <section class="py-3">
<div class="container text-center"> <div class="container text-center">
<h1 class="display-4"><strong>Cooperate Cleaner</strong></h1> <h1 class="display-4"><strong>Cooperate Cleaner</strong></h1>
<p class="lead mb-3">Enter your text, clear, done</p> <p class="lead mb-3">Enter your text, clear, done</p>
@ -25,6 +25,7 @@
<div class="visually-hidden" id="output-container-div"> <div class="visually-hidden" id="output-container-div">
<h2 class="mt-5">Output:</h2> <h2 class="mt-5">Output:</h2>
<textarea class="form-control w-100" rows="10" id="output-textarea"></textarea> <textarea class="form-control w-100" rows="10" id="output-textarea"></textarea>
<p class="py-1"><span id="replace-count">XX</span> matches replaced.</p>
</div> </div>
</div> </div>
</section> </section>

View File

@ -56,20 +56,31 @@
console.log("Cleaning..."); console.log("Cleaning...");
let outputText = $("#input-textarea").val(); let outputText = $("#input-textarea").val();
let totalMatches = 0;
config.rules.forEach(rule => { config.rules.forEach(rule => {
if (rule.enabled) { if (rule.enabled) {
const searchValue = rule.ignoreCase ? new RegExp(rule.strToReplace, 'gi') : new RegExp(rule.strToReplace, 'g'); const searchValue = rule.ignoreCase ? new RegExp(rule.strToReplace, 'gi') : new RegExp(rule.strToReplace, 'g');
outputText = outputText.replace(searchValue, rule.replaceStr); let matchCount = 0;
outputText = outputText.replace(searchValue, (match) => {
matchCount++;
return rule.replaceStr;
});
totalMatches += matchCount;
} }
}); });
$("#output-textarea").val(outputText); $("#output-textarea").val(outputText);
$("#output-container-div").removeClass("visually-hidden"); $("#output-container-div").removeClass("visually-hidden");
if($("#enable-auto-copy").prop("checked")) { $("#replace-count").text(totalMatches);
if ($("#enable-auto-copy").prop("checked")) {
console.log("Copying result to clipboard...") console.log("Copying result to clipboard...")
await Neutralino.clipboard.writeText(outputText); await Neutralino.clipboard.writeText(outputText);
} }
} }
})(); })();

View File

@ -23,6 +23,18 @@
</div> </div>
</div> </div>
</div> </div>
<div class="col-lg-4 col-md-6 mb-4">
<div class="card app-card shadow-sm animate__animated animate__fadeIn" id="home-btn-sl">
<img src="/icons/lineconv.webp" alt="App 1" class="card-img-top">
<div class="card-body">
<h5 class="card-title">Multiline to single line</h5>
<p class="card-text">Convert multiline text to singleline</p>
</div>
</div>
</div>
<!-- Add more apps here as needed -->
</div>
<div class="row">
<div class="col-lg-4 col-md-6 mb-4"> <div class="col-lg-4 col-md-6 mb-4">
<div class="card app-card shadow-sm animate__animated animate__fadeIn" id="home-btn-about"> <div class="card app-card shadow-sm animate__animated animate__fadeIn" id="home-btn-about">
<img src="/icons/about.webp" alt="App 3" class="card-img-top"> <img src="/icons/about.webp" alt="App 3" class="card-img-top">
@ -32,7 +44,6 @@
</div> </div>
</div> </div>
</div> </div>
<!-- Add more apps here as needed -->
</div> </div>
<div class="row justify-content-center"> <div class="row justify-content-center">
<div class="col-auto"> <div class="col-auto">

View File

@ -16,6 +16,10 @@ function init(){
console.log("About button clicked"); console.log("About button clicked");
loadView("about"); loadView("about");
}); });
$("#home-btn-sl").click(function(){
console.log("Singleline converter button clicked");
loadView("slconv");
});
$("#exit-btn").click(function(){ $("#exit-btn").click(function(){
console.log("Quit button clicked"); console.log("Quit button clicked");
quit(); quit();

View File

View File

@ -0,0 +1,34 @@
<div class="container-fluid h-100">
<div class="row h-100">
<div class="col-md-12">
<div class="position-relative">
<button type="button" class="btn btn-light back-button top-0 start-0 m-3" onclick="loadView('home')">
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-arrow-left" viewBox="0 0 16 16">
<path fill-rule="evenodd" d="M15 8a.5.5 0 0 0-.5-.5H2.707l3.147-3.146a.5.5 0 1 0-.708-.708l-4 4a.5.5 0 0 0 0 .708l4 4a.5.5 0 0 0 .708-.708L2.707 8.5H14.5A.5.5 0 0 0 15 8"/>
</svg>
Back
</button>
</div>
<section class="py-3">
<div class="container text-center">
<h1 class="display-4"><strong>Singleline Converter</strong></h1>
<p class="lead mb-3">Enter your text, convert, done</p>
<h2>Input:</h2>
<textarea class="form-control w-100" rows="10" id="input-textarea"></textarea>
<button type="button" class="btn btn-success mt-5" id="slconv-btn-convert">
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-cpu" viewBox="0 0 16 16">
<path d="M5 0a.5.5 0 0 1 .5.5V2h1V.5a.5.5 0 0 1 1 0V2h1V.5a.5.5 0 0 1 1 0V2h1V.5a.5.5 0 0 1 1 0V2A2.5 2.5 0 0 1 14 4.5h1.5a.5.5 0 0 1 0 1H14v1h1.5a.5.5 0 0 1 0 1H14v1h1.5a.5.5 0 0 1 0 1H14v1h1.5a.5.5 0 0 1 0 1H14a2.5 2.5 0 0 1-2.5 2.5v1.5a.5.5 0 0 1-1 0V14h-1v1.5a.5.5 0 0 1-1 0V14h-1v1.5a.5.5 0 0 1-1 0V14h-1v1.5a.5.5 0 0 1-1 0V14A2.5 2.5 0 0 1 2 11.5H.5a.5.5 0 0 1 0-1H2v-1H.5a.5.5 0 0 1 0-1H2v-1H.5a.5.5 0 0 1 0-1H2v-1H.5a.5.5 0 0 1 0-1H2A2.5 2.5 0 0 1 4.5 2V.5A.5.5 0 0 1 5 0m-.5 3A1.5 1.5 0 0 0 3 4.5v7A1.5 1.5 0 0 0 4.5 13h7a1.5 1.5 0 0 0 1.5-1.5v-7A1.5 1.5 0 0 0 11.5 3zM5 6.5A1.5 1.5 0 0 1 6.5 5h3A1.5 1.5 0 0 1 11 6.5v3A1.5 1.5 0 0 1 9.5 11h-3A1.5 1.5 0 0 1 5 9.5zM6.5 6a.5.5 0 0 0-.5.5v3a.5.5 0 0 0 .5.5h3a.5.5 0 0 0 .5-.5v-3a.5.5 0 0 0-.5-.5z"/>
</svg>
Convert my input
</button>
<div class="visually-hidden" id="output-container-div">
<h2 class="mt-5">Output:</h2>
<textarea class="form-control w-100" rows="10" id="output-textarea"></textarea>
<p class="py-1"><span id="rm-count">XX</span> line breaks removed.</p>
</div>
</div>
</section>
</div>
</div>
</div>

View File

@ -0,0 +1,24 @@
(function () {
$(document).ready(function () {
console.log("Initialization of slconv.js finished.");
$("#slconv-btn-convert").click(function () {
console.log("Convert button clicked");
convert();
});
});
async function convert() {
console.log("Converting...");
const inputText = $("#input-textarea").val();
console.log(inputText);
const matches = inputText.match(/\n/g);
const matchCount = matches ? matches.length : 0;
console.log("Number of matches (newlines):", matchCount);
const outputText = inputText.replace(/\n/g, ' ');
console.log(outputText);
$("#output-textarea").val(outputText);
$("#output-container-div").removeClass("visually-hidden");
$("#rm-count").text(matchCount);
await Neutralino.clipboard.writeText(outputText);
}
})();